fix: Set campaign params to null on person creation #25132
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
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 #25169 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.
Changes
On person creation, set all known campaign params to null, so that if they are not set when the person is created, they cannot overridden later on.
This is the 80/20 solution, it's possible to come up with edge-cases that would be fixed by a more complex implementation (see #25135), but given we don't want to touch the person properties code too much at the moment, let's go for this fix.
Does this work well for both Cloud and self-hosted?
Yes
How did you test this code?
Added some tests - also the grafana chart shows the impact of this change in prod