From 55e84cdc572e2e183fe16d7322347f193f5f64b5 Mon Sep 17 00:00:00 2001 From: Lucas Faria Date: Wed, 22 Jan 2025 11:52:07 -0300 Subject: [PATCH] fix functional tests by disabling surveys --- functional_tests/identify.test.ts | 8 ++++---- src/posthog-surveys.ts | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/functional_tests/identify.test.ts b/functional_tests/identify.test.ts index 3f53aa1b4..b0ae78ca4 100644 --- a/functional_tests/identify.test.ts +++ b/functional_tests/identify.test.ts @@ -1,12 +1,12 @@ import '../src/__tests__/helpers/mock-logger' -import 'regenerator-runtime/runtime' import { waitFor } from '@testing-library/dom' -import { getRequests } from './mock-server' +import 'regenerator-runtime/runtime' import { createPosthogInstance } from '../src/__tests__/helpers/posthog-instance' +import { PostHog } from '../src/posthog-core' import { logger } from '../src/utils/logger' import { uuidv7 } from '../src/uuidv7' -import { PostHog } from '../src/posthog-core' +import { getRequests } from './mock-server' describe('FunctionalTests / Identify', () => { let token: string @@ -15,7 +15,7 @@ describe('FunctionalTests / Identify', () => { beforeEach(async () => { token = uuidv7() - posthog = await createPosthogInstance(token) + posthog = await createPosthogInstance(token, { disable_surveys: true }) anonymousId = posthog.get_distinct_id() }) diff --git a/src/posthog-surveys.ts b/src/posthog-surveys.ts index 4c80f3f23..3b2b59cf4 100644 --- a/src/posthog-surveys.ts +++ b/src/posthog-surveys.ts @@ -161,6 +161,13 @@ export class PostHogSurveys { return } + const disableSurveys = this.instance.config.disable_surveys + + if (disableSurveys) { + logger.info('Disabled. Not loading surveys.') + return + } + const phExtensions = assignableWindow?.__PosthogExtensions__ if (!phExtensions) { @@ -170,13 +177,6 @@ export class PostHogSurveys { const generateSurveys = phExtensions.generateSurveys - const disableSurveys = this.instance.config.disable_surveys - - if (disableSurveys) { - logger.info('Disabled. Not loading surveys.') - return - } - if (!this._decideServerResponse) { logger.warn('Decide not loaded yet. Not loading surveys.') return