Skip to content

Commit

Permalink
feat: Move heatmaps out of preview (#1156)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite committed Apr 26, 2024
1 parent 5a8ce20 commit e8ace28
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
3 changes: 0 additions & 3 deletions playground/nextjs/src/posthog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const updatePostHogConsent = (consentGiven: boolean) => {
posthog.set_config(configForConsent())
}


if (typeof window !== 'undefined') {
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY || '', {
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST || 'https://us.i.posthog.com',
Expand All @@ -48,7 +47,6 @@ if (typeof window !== 'undefined') {
scroll_root_selector: ['#scroll_element', 'html'],
persistence: cookieConsentGiven() ? 'localStorage+cookie' : 'memory',
person_profiles: PERSON_PROCESSING_MODE === 'never' ? 'identified_only' : PERSON_PROCESSING_MODE,
__preview_heatmaps: true,
persistence_name: `${process.env.NEXT_PUBLIC_POSTHOG_KEY}_nextjs`,
...configForConsent(),
})
Expand Down Expand Up @@ -82,7 +80,6 @@ export const posthogHelpers = {
}
posthog.register(eventProperties)
posthog.setPersonPropertiesForFlags(user)

} else {
// NOTE: Would this always get set?
if (user.team) {
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/heatmaps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('heatmaps', () => {
})

it('should be enabled if client config option is enabled', () => {
posthog.config.__preview_heatmaps = true
posthog.config.enable_heatmaps = true
expect(posthog.heatmaps!.isEnabled).toBe(true)
})

Expand All @@ -132,7 +132,7 @@ describe('heatmaps', () => {
])(
'when client side config is %p and remote opt in is %p - heatmaps enabled should be %p',
(clientSideOptIn, serverSideOptIn, expected) => {
posthog.config.__preview_heatmaps = clientSideOptIn
posthog.config.enable_heatmaps = clientSideOptIn
posthog.heatmaps!.afterDecideResponse({
heatmaps: serverSideOptIn,
} as DecideResponse)
Expand Down
4 changes: 2 additions & 2 deletions src/heatmaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ export class Heatmaps {
}

public get isEnabled(): boolean {
return !isUndefined(this.instance.config.__preview_heatmaps)
? this.instance.config.__preview_heatmaps
return !isUndefined(this.instance.config.enable_heatmaps)
? this.instance.config.enable_heatmaps
: this._enabledServerSide
}

Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export interface PostHogConfig {
bootstrap: BootstrapConfig
segment?: SegmentAnalytics
__preview_send_client_session_params?: boolean
__preview_heatmaps?: boolean
enable_heatmaps?: boolean
disable_scroll_properties?: boolean
// Let the pageview scroll stats use a custom css selector for the root element, e.g. `main`
scroll_root_selector?: string | string[]
Expand Down

0 comments on commit e8ace28

Please sign in to comment.