Skip to content

Don't nest custom properties under a "properties" key in docs #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 14, 2025

Conversation

axelson
Copy link
Contributor

@axelson axelson commented Apr 4, 2025

When I tested integrating this, if I call capture with my custom properties nested under a properties key like:

Posthog.capture("purchase", [
  distinct_id: "user_123",
  properties: %{
    product_id: "prod_123",
    price: 99.99
  }
])

Then all my values are nested in Posthog which means I cannot filter on individual properties.

So instead it seems more appropriate to directly send each property at the top-level like:

Posthog.capture("purchase", [
  distinct_id: "user_123",
  product_id: "prod_123",
  price: 99.99
])

And that also matches the format in the example for Posthog.Client.build_event/2

@axelson axelson requested a review from rafaeelaudibert as a code owner April 4, 2025 01:16
Copy link
Member

@rafaeelaudibert rafaeelaudibert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes, you are right, this was a mistake. The intention here was to follow closely what our other backend libraries do, and this is a change in behavior.

Namely, posthog-node works like this:

posthog.capture({ distinct_id: "user_123", event: "event_name", properties: { ... } })

I like how we have the event name as a separate property, but it'd have been ideal if we had captured distinctId separately.

I'll create a mega issue with suggested changes for v2 and include this there.

In the meantime, I agree this is a needed fix in the docs. Thank you so much! I'll be merging this now, but wont release a new version until we get your other PR to merge to avoid a lot of dummy versions

Thank you!

@rafaeelaudibert rafaeelaudibert merged commit 853e60d into PostHog:master Apr 14, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants