diff --git a/playground/nextjs/src/posthog.ts b/playground/nextjs/src/posthog.ts index 865d7cfca..3a82e1766 100644 --- a/playground/nextjs/src/posthog.ts +++ b/playground/nextjs/src/posthog.ts @@ -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', @@ -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(), }) @@ -82,7 +80,6 @@ export const posthogHelpers = { } posthog.register(eventProperties) posthog.setPersonPropertiesForFlags(user) - } else { // NOTE: Would this always get set? if (user.team) { diff --git a/src/__tests__/heatmaps.test.ts b/src/__tests__/heatmaps.test.ts index 3094f0d3d..73eb1fa6a 100644 --- a/src/__tests__/heatmaps.test.ts +++ b/src/__tests__/heatmaps.test.ts @@ -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) }) @@ -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) diff --git a/src/heatmaps.ts b/src/heatmaps.ts index 987ce5fe1..e7abff958 100644 --- a/src/heatmaps.ts +++ b/src/heatmaps.ts @@ -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 } diff --git a/src/types.ts b/src/types.ts index a7b3a7dee..bf71fcbef 100644 --- a/src/types.ts +++ b/src/types.ts @@ -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[]