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: Move heatmaps out of preview #1156

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading