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

fix: Only set initial campaign params on person creation #25135

Closed

Conversation

robbie-c
Copy link
Member

@robbie-c robbie-c commented Sep 23, 2024

Problem

See #7710

Campaign params can be set on a later visit, so a user that was originally organic traffic (no campaign params) could be attributed to a different channel if they click a link with a UTM tag set

Changes

On Person update, don't update initial campaign properties. These can only be set when the person is created, and future events that include campaign properties don't update the initial campaign properties.

TRICKY: To make upgrading anonymous users work, the pipeline now assumes that if you send any $initial props, you will send all relevant $initial campaign params, as this is what posthog-js does. To sanity-check this, I added a counter in this PR to see if this would negatively affect anyone, see this grafana chart. It only says web, which is expected, and the fact that no other SDKs are present means that this would not negatively impact anyone.

This is an improvement on the workaround in #7710 (comment)

  • it does not require an SDK update
  • will always be up to date with the latest campaign params
  • does not increase the bundle size
  • it will work for users created before this fix
  • unlike the other potential fix in fix: Set campaign params to null on person creation #25132, it doesn't need us to store a bunch of unnecessary null properties in PG

The BIG downside (maybe deal-breaker) is that it touches some person processing code that we might not want to touch this quarter.

Does this work well for both Cloud and self-hosted?

Yes

How did you test this code?

I added some tests for the new cases covered, including the edge cases around upgrading anonymous users to identified.

I created some new snapshot tests for real events from posthog.com

@robbie-c robbie-c marked this pull request as ready for review September 23, 2024 15:03
@robbie-c robbie-c changed the title fix: WIP Strip initial campaign params on person updates fix: Strip initial campaign params on person updates Sep 23, 2024
@robbie-c robbie-c changed the title fix: Strip initial campaign params on person updates fix: Only set initial campaign params on person creation Sep 23, 2024
@robbie-c robbie-c force-pushed the fix/set-campaign-params-to-null-on-person-creation-2 branch from e476739 to dfd12ae Compare September 24, 2024 12:52
@posthog-bot
Copy link
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week. If you want to permanentely keep it open, use the waiting label.

@posthog-bot
Copy link
Contributor

This PR was closed due to lack of activity. Feel free to reopen if it's still relevant.

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

Successfully merging this pull request may close these issues.

2 participants