-
Notifications
You must be signed in to change notification settings - Fork 4
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
Fix the alias api in the libraries to match the docs #89
Comments
Aliasing doesn't seem to work currently as I'd expect import posthog
posthog.project_api_key = "KEY"
distinct_id = "distinct_id"
alias_id = "alias_id"
posthog.capture(distinct_id, "distinct id test event")
posthog.capture(alias_id, "alias test event 1")
posthog.alias(distinct_id, alias_id)
posthog.capture(
alias_id, "alias test event 2"
) # this should be associated with distinct_id, however it's not |
I'm seeing some unexpected behaviour:
Bonus |
typically people set
The reason why your test didn't work is because you used an illegal distinct_id (see https://posthog.com/docs/integrate/identifying-users#considerations), with witch we don't allow merges, if you head over to https://app.posthog.com/data-management/ingestion-warnings
If you change your ids to be valid ones, then it works as expected. |
btw I see that we have added this into https://posthog.com/docs/integrate/identifying-users (it's not clear to me which way I should provide the IDs from this example, but it's important) If you use a different identifier or multiple identifiers, be sure to alias the two IDs together for example on the backend with posthog-node JavaScript posthog.alias({ |
I've proposed us to explain things this way: https://posthog.com/docs/integrate/server/node#alias An alias call requires: distinctId – the user id Node.js client.alias({ |
Curious: Is there a reason why aliasing isn't commutative? (i.e. merging A into B, is not same as merging B into A)? One reason I can think of is that we discard properties of the aliased id. If this is true, can we explain what aliasing does using this lens? Since, if it were commutative, it wouldn't matter which id came first, but if it does matter, what exactly changes for the second ID? Otherwise, trying to remember the ordering here is very confusing, and we don't (yet) do a good job of giving users a good conceptual model to make this easier. |
The backend library types and the docs have diverged. I've gone through the different libraries and updated the errors I've seen
Currently the docs state that the API is as follows:
posthog.alias('distinct_id', 'alias_id);
where alias_id is added as an alias of the user with distinct_id. The properties of user with distinct_id take presidentLibrary fixes:
The other libraries are fine or it's not implemented
I've also noted an error in our own code where it looks like we are using it wrong:
PostHog/posthog#13906
The text was updated successfully, but these errors were encountered: