Skip to content
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

posthog-destination: fix an issue with the tracking of anonymous users #1179

Open
wants to merge 1 commit into
base: newjitsu
Choose a base branch
from

Conversation

jspizziri
Copy link
Contributor

@jspizziri jspizziri commented Feb 6, 2025

Currently, it seems to us that there are a few issues with the tracking of anonymous users. First I want to specify that the term "anonymous" is overloaded here. There are 3 categories of events, and I'll specify some terms I'll refer to them by to keep them straight:

  1. Anonymous/Unidentified - Events that occur before a user has identified themselves, which should have some sort of anonymousId associated with them. Importantly, we do intend to merge these events into an identified user/"Person" at some point.
  2. Identified - Events that occur after a user has identified themselves.
  3. Anonymous/Anonymous - Posthog "anonymous" events which are intended never to have identifiable information associated with them. Importantly, these events should never be merged into a "Person" record.

When Enable Anonymous User Profiles Is Enabled

When this setting is enabled, over multiple sessions where the user starts as Anonymous/Unidentified and then becomes Identified, currently, you'll end up with duplicate "person" records in Posthog for that user. While there is an alias event that connects the two of them together, they don't get merged into a single record as they should properly be. Therefore, overtime you accumulate a large set of distinct "Person" records in Posthog all containing the Anonymous/Unidentified event history of a user prior to identification, with aliases back to the true identity with the actual Identified events.

By default, all Posthog events are associated with a person profile. Therefore, identify should not be called for a Anonymous/Unidentified user, but rather only called for the actual Identified user and then immediately aliased to the Anonymous/Unidentified users' previous distinctId. This merges all the users' data (both Anonymous/Unidentified & Identified) into a single record.

When Enable Anonymous User Profiles Is Disabled

If you disable this setting, no events are sent to posthog at all, whereas what I would expect would happen is to have Anonymous/Anonymous events sent to Posthog.

@jspizziri jspizziri force-pushed the fix/posthog-anonymous branch from d870d9d to 03f3ef5 Compare February 6, 2025 19:04
@jspizziri
Copy link
Contributor Author

This documentation video also is a good source of information on this:

https://www.youtube.com/watch?v=3afzkLS-zQA

@absorbb
Copy link
Contributor

absorbb commented Feb 7, 2025

@jspizziri

Thank you!

this PR will enable anonymous events capture for clients that have enableAnonymousUserProfiles disabled.
That may be unwanted or unexpected.
I assume that we need the extra boolean flag e.g. sendAnonymousEvents which when not present will take value of enableAnonymousUserProfiles flag

And also improve description of enableAnonymousUserProfiles flag in UI.

We need some time to make sure that no other unwanted side effect will occur for existing clients.

@jspizziri
Copy link
Contributor Author

@absorbb

Thanks for taking a look. Yeah, I assumed there might be a need for additional user config options. I've never put in the work to get the stack running locally :), nor did I actually run the code in the PR locally (although I tested my research via direct REST calls to the Posthog API). LMK if there's anything I can do to help get this over the line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants