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

feat: Person Processing 3: Handle $initial props across sessions, send $initial props with all person processing events, remove __preview #1127

Merged
merged 5 commits into from
Apr 10, 2024

Conversation

robbie-c
Copy link
Member

@robbie-c robbie-c commented Apr 10, 2024

Changes

  • Move the initial campaign and referrer props to regular persistence, not session persistence, so that it works for users who don't identify until their second session
  • Send the $initial props when in always mode, not just in identified_only mode
  • Remove the __preview_ prefix on the config option

Checklist

  • Tests for new code (see advice on the tests we use)
  • Accounted for the impact of any changes across different browsers
  • Accounted for backwards compatibility of any changes (no breaking changes in posthog-js!)

@robbie-c robbie-c marked this pull request as ready for review April 10, 2024 10:29
@robbie-c robbie-c changed the title Person Processing 3: Handle $initial props across sessions, send $initial props with all person processing events, remove __preview feat: Person Processing 3: Handle $initial props across sessions, send $initial props with all person processing events, remove __preview Apr 10, 2024
@PostHog PostHog deleted a comment from posthog-bot Apr 10, 2024
Copy link

github-actions bot commented Apr 10, 2024

Size Change: +632 B (0%)

Total Size: 950 kB

Filename Size Change
dist/array.full.js 226 kB +158 B (0%)
dist/array.js 127 kB +158 B (0%)
dist/es.js 127 kB +158 B (0%)
dist/module.js 128 kB +158 B (0%)
ℹ️ View Unchanged
Filename Size
dist/exception-autocapture.js 12.2 kB
dist/recorder-v2.js 105 kB
dist/recorder.js 105 kB
dist/surveys-module-previews.js 62 kB
dist/surveys.js 58.3 kB

compressed-size-action

Copy link
Member

@pauldambra pauldambra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't run it... but this looks good to me

coupling between persistence and sessionPersistence stands out for me across these changes - not a review of this more typing it so it goes in my brain as something to care about 🤣

I wonder if we should follow up with some cypress tests here to test the e2e behaviour of this new config 🤔

@@ -112,12 +133,59 @@ describe('person processing', () => {
const identifyCall = onCapture.mock.calls[0]
expect(identifyCall[0]).toEqual('$identify')
expect(identifyCall[1].$set_once).toEqual({
$initial_referrer: '$direct',
$initial_referring_domain: '$direct',
$initial_referrer: 'https://referrer.com',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll lazily assume that tests elsewhere cover $direct being the default

Comment on lines 741 to 748
if (this.config.store_google) {
this.sessionPersistence.update_campaign_params()
this.persistence.set_initial_campaign_params()
}
if (this.config.save_referrer) {
this.sessionPersistence.update_referrer_info()
this.persistence.set_initial_referrer_info()
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the coupling "hard" here... i.e. if you call this.sessionPersistence.update_campaign_params() should you always call this.persistence.set_initial_campaign_params() or vice versa?

we could make that explicit so that callers don't have to remember... these two persistence stores by necessity will be super coupled anyway

but I'm thinking out loud - feel free to ignore

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more than we wanted the initial params to be stored at a person level, as they are person-initial, whereas the other params need to be session level, so we get the correct session-initial props in the sessions table. I can add a comment

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To actually answer your question which I kinda avoided :D

While the caller is "us", I'm not too worried that we have to remember which persistence to us. The alternative would be to have a combined persistence, where the caller just says what it want to save and it calls the right storage. That would be doable but I'd worry about increasing the bundle size by doing so.

@robbie-c robbie-c merged commit b53b923 into main Apr 10, 2024
11 checks passed
@robbie-c robbie-c deleted the feat/person-processing-3 branch April 10, 2024 11:17
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