fix: Only set initial campaign params on person creation #25135
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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)
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