-
Notifications
You must be signed in to change notification settings - Fork 128
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: swap the default to identified_only #1468
Changes from 8 commits
700a639
b72e8de
0de33c3
e7b986b
6798a2e
51a2ed2
b39fb37
642b349
2080958
bf232be
745e594
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,7 +179,7 @@ export const defaultConfig = (): PostHogConfig => ({ | |
bootstrap: {}, | ||
disable_compression: false, | ||
session_idle_timeout_seconds: 30 * 60, // 30 minutes | ||
person_profiles: 'always', | ||
person_profiles: 'identified_only', | ||
__add_tracing_headers: false, | ||
}) | ||
|
||
|
@@ -272,6 +272,7 @@ export class PostHog { | |
decideEndpointWasHit: boolean | ||
analyticsDefaultEndpoint: string | ||
version = Config.LIB_VERSION | ||
_initialPersonProfilesConfig: 'always' | 'never' | 'identified_only' | null | ||
|
||
SentryIntegration: typeof SentryIntegration | ||
sentryIntegration: (options?: SentryIntegrationOptions) => ReturnType<typeof sentryIntegration> | ||
|
@@ -294,6 +295,7 @@ export class PostHog { | |
this.__loaded = false | ||
this.analyticsDefaultEndpoint = '/e/' | ||
this._initialPageviewCaptured = false | ||
this._initialPersonProfilesConfig = null | ||
|
||
this.featureFlags = new PostHogFeatureFlags(this) | ||
this.toolbar = new Toolbar(this) | ||
|
@@ -390,6 +392,10 @@ export class PostHog { | |
this.config = {} as PostHogConfig // will be set right below | ||
this._triggered_notifs = [] | ||
|
||
if (config.person_profiles) { | ||
this._initialPersonProfilesConfig = config.person_profiles | ||
} | ||
Comment on lines
+395
to
+397
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in order to roll this out slowly, we need to know if the person has already set their config - that it's not just using the default. So we need to store the initial config somewhere. |
||
|
||
this.set_config( | ||
extend({}, defaultConfig(), configRenames(config), { | ||
name: name, | ||
|
@@ -408,6 +414,8 @@ export class PostHog { | |
this.config.persistence === 'sessionStorage' | ||
? this.persistence | ||
: new PostHogPersistence({ ...this.config, persistence: 'sessionStorage' }) | ||
|
||
// should I store the initial person profiles config in persistence? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The way I've handled this so far is to save whether or not they've sent an event with person processing. If they have then we persist I'm just wondering whether saving their config gives us anything beyond this. Here's a couple of cases: Case 1
Case 2
In case 2 there's a difference, but I'd argue that those events should be sent as anonymous. Wdyt? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TLDR no I don't think so :D There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ooooook so it turns out we don't actually handle this case correctly. I added a fix and some tests to this PR. I hope you don't mind me piggybacking like this, I can very much move it to its own PR if you prefer. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No this is great, thanks! |
||
const initialPersistenceProps = { ...this.persistence.props } | ||
const initialSessionProps = { ...this.sessionPersistence.props } | ||
|
||
|
@@ -538,6 +546,12 @@ export class PostHog { | |
this.analyticsDefaultEndpoint = response.analytics.endpoint | ||
} | ||
|
||
this.config.person_profiles = this._initialPersonProfilesConfig | ||
? this._initialPersonProfilesConfig | ||
: response['defaultIdentifiedOnly'] | ||
? 'identified_only' | ||
: 'always' | ||
raquelmsmith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
this.sessionRecording?.afterDecideResponse(response) | ||
this.autocapture?.afterDecideResponse(response) | ||
this.heatmaps?.afterDecideResponse(response) | ||
|
@@ -977,8 +991,13 @@ export class PostHog { | |
properties = sanitize_properties(properties, event_name) | ||
} | ||
|
||
// add person processing flag as very last step, so it cannot be overridden. process_person=true is default | ||
properties['$process_person_profile'] = this._hasPersonProcessing() | ||
// add person processing flag as very last step, so it cannot be overridden | ||
const hasPersonProcessing = this._hasPersonProcessing() | ||
properties['$process_person_profile'] = hasPersonProcessing | ||
// if the event has person processing, ensure that all future events will too, even if the setting changes | ||
if (hasPersonProcessing) { | ||
this._requirePersonProcessing('_calculate_event_properties') | ||
} | ||
|
||
return properties | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -398,6 +398,7 @@ export interface DecideResponse { | |
isAuthenticated: boolean | ||
siteApps: { id: number; url: string }[] | ||
heatmaps?: boolean | ||
defaultIdentifiedOnly?: boolean | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this will be returned with |
||
} | ||
|
||
export type FeatureFlagsCallback = ( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the main change for swapping the default