From d724a1c45f04681f1d7ce30362f6f71a9a28385a Mon Sep 17 00:00:00 2001 From: pauldambra Date: Wed, 25 Jun 2025 11:00:15 +0100 Subject: [PATCH 1/8] feat: push replay and person data to intercom and crisp chat --- .../browser/playground/nextjs/pages/_app.tsx | 21 ++++++-- .../playground/nextjs/pages/external_chat.tsx | 42 +++++++++++++++ .../browser/playground/nextjs/src/Header.tsx | 1 + .../browser/playground/nextjs/src/posthog.ts | 4 ++ .../browser/src/entrypoints/array.full.es5.ts | 3 +- .../src/entrypoints/crisp-chat-integration.ts | 53 +++++++++++++++++++ .../src/entrypoints/intercom-integration.ts | 48 +++++++++++++++++ .../src/extensions/external-integration.ts | 36 +++++++++++++ packages/browser/src/posthog-core.ts | 3 ++ packages/browser/src/types.ts | 7 +++ packages/browser/src/utils/globals.ts | 8 ++- 11 files changed, 219 insertions(+), 7 deletions(-) create mode 100644 packages/browser/playground/nextjs/pages/external_chat.tsx create mode 100644 packages/browser/src/entrypoints/crisp-chat-integration.ts create mode 100644 packages/browser/src/entrypoints/intercom-integration.ts create mode 100644 packages/browser/src/extensions/external-integration.ts diff --git a/packages/browser/playground/nextjs/pages/_app.tsx b/packages/browser/playground/nextjs/pages/_app.tsx index 79ebc8c73..03c596845 100644 --- a/packages/browser/playground/nextjs/pages/_app.tsx +++ b/packages/browser/playground/nextjs/pages/_app.tsx @@ -11,6 +11,14 @@ import Head from 'next/head' import { PostHogProvider } from 'posthog-js/react' const CDP_DOMAINS = ['https://*.redditstatic.com', 'https://*.reddit.com'].join(' ') +const CHAT_DOMAINS = [ + 'https://*.intercom.io', + 'https://*.intercomcdn.com', + 'wss://*.intercom.io', + 'https://static.intercomassets.com', + 'https://*.crisp.chat', + 'wss://*.relay.crisp.chat', +].join(' ') export default function App({ Component, pageProps }: AppProps) { const user = useUser() @@ -43,11 +51,14 @@ export default function App({ Component, pageProps }: AppProps) { httpEquiv="Content-Security-Policy" content={` default-src 'self'; - connect-src 'self' ${localhostDomain} https://*.posthog.com https://lottie.host ${CDP_DOMAINS}; - script-src 'self' 'unsafe-eval' 'unsafe-inline' ${localhostDomain} https://*.posthog.com ${CDP_DOMAINS}; - style-src 'self' 'unsafe-inline' ${localhostDomain} https://*.posthog.com; - img-src 'self' ${localhostDomain} https://*.posthog.com https://lottie.host https://cataas.com ${CDP_DOMAINS}; - worker-src 'self' blob:; + connect-src 'self' ${localhostDomain} https://*.posthog.com https://lottie.host ${CDP_DOMAINS} ${CHAT_DOMAINS}; + script-src 'self' 'unsafe-eval' 'unsafe-inline' ${localhostDomain} https://*.posthog.com ${CDP_DOMAINS} ${CHAT_DOMAINS}; + style-src 'self' 'unsafe-inline' ${localhostDomain} https://*.posthog.com ${CHAT_DOMAINS}; + img-src 'self' data: blob: ${localhostDomain} https://*.posthog.com https://lottie.host https://cataas.com ${CDP_DOMAINS} ${CHAT_DOMAINS}; + worker-src 'self' blob: ${CHAT_DOMAINS}; + font-src 'self' ${localhostDomain} https://*.posthog.com ${CHAT_DOMAINS}; + media-src 'self' ${localhostDomain} https://*.posthog.com ${CHAT_DOMAINS}; + frame-src 'self' ${localhostDomain} https://*.posthog.com ${CHAT_DOMAINS}; `} /> diff --git a/packages/browser/playground/nextjs/pages/external_chat.tsx b/packages/browser/playground/nextjs/pages/external_chat.tsx new file mode 100644 index 000000000..b1ad86b92 --- /dev/null +++ b/packages/browser/playground/nextjs/pages/external_chat.tsx @@ -0,0 +1,42 @@ +import Script from 'next/script' + +export default function ExternalChat() { + return ( +
+

ExternalChat

+

This is a page for testing external chat widgets

+ + {/* Intercom Settings Script */} + + + {/* Intercom Widget Script */} + + + {/* Crisp chat Script */} + +
+ ) +} diff --git a/packages/browser/playground/nextjs/src/Header.tsx b/packages/browser/playground/nextjs/src/Header.tsx index 687e9a57b..59575577d 100644 --- a/packages/browser/playground/nextjs/src/Header.tsx +++ b/packages/browser/playground/nextjs/src/Header.tsx @@ -27,6 +27,7 @@ export const PageHeader = () => { Long E-commerce Toolbar Tests + External Chat
diff --git a/packages/browser/playground/nextjs/src/posthog.ts b/packages/browser/playground/nextjs/src/posthog.ts index fd7a51fa1..a68329a40 100644 --- a/packages/browser/playground/nextjs/src/posthog.ts +++ b/packages/browser/playground/nextjs/src/posthog.ts @@ -66,6 +66,10 @@ if (typeof window !== 'undefined') { person_profiles: PERSON_PROCESSING_MODE === 'never' ? 'identified_only' : PERSON_PROCESSING_MODE, persistence_name: `${process.env.NEXT_PUBLIC_POSTHOG_KEY}_nextjs`, opt_in_site_apps: true, + integrations: { + intercom: true, + crispChat: true, + }, __preview_remote_config: true, __preview_experimental_cookieless_mode: false, __preview_flags_v2: true, diff --git a/packages/browser/src/entrypoints/array.full.es5.ts b/packages/browser/src/entrypoints/array.full.es5.ts index 28c8c2d92..0c81c5d74 100644 --- a/packages/browser/src/entrypoints/array.full.es5.ts +++ b/packages/browser/src/entrypoints/array.full.es5.ts @@ -3,8 +3,9 @@ // to allow es5/IE11 support // it doesn't include recorder which doesn't support IE11, -// and it doesn't include web-vitals which doesn't support IE11 +// and it doesn't include "web-vitals" which doesn't support IE11 +import 'core-js/features/object/entries' import 'core-js/features/object/from-entries' import './surveys' diff --git a/packages/browser/src/entrypoints/crisp-chat-integration.ts b/packages/browser/src/entrypoints/crisp-chat-integration.ts new file mode 100644 index 000000000..2c3dbd20d --- /dev/null +++ b/packages/browser/src/entrypoints/crisp-chat-integration.ts @@ -0,0 +1,53 @@ +import { PostHog } from '../posthog-core' +import { assignableWindow } from '../utils/globals' +import { createLogger } from '../utils/logger' + +const logger = createLogger('[PostHog Crisp Chat]') + +const reportedSessionIds = new Set() + +assignableWindow.__PosthogExtensions__ = assignableWindow.__PosthogExtensions__ || {} +assignableWindow.__PosthogExtensions__.integrations = assignableWindow.__PosthogExtensions__.integrations || {} +assignableWindow.__PosthogExtensions__.integrations.crispChat = { + start: (posthog: PostHog) => { + if (!posthog.config.integrations?.crispChat) { + return + } + + const crispChat = (assignableWindow as any).$crisp + if (!crispChat) { + logger.warn(' Crisp Chat not found while initializing the integration') + return + } + + const updateCrispChat = () => { + const replayUrl = posthog.get_session_replay_url() + const personUrl = posthog.requestRouter.endpointFor( + 'ui', + `/project/${posthog.config.token}/person/${posthog.get_distinct_id()}` + ) + + crispChat.push([ + 'set', + 'session:data', + [ + [ + ['posthogSessionURL', replayUrl], + ['posthogPersonURL', personUrl], + ], + ], + ]) + } + + // this is called immediately if there's a session id + // and then again whenever the session id changes + posthog.onSessionId((sessionId) => { + if (!reportedSessionIds.has(sessionId)) { + updateCrispChat() + reportedSessionIds.add(sessionId) + } + }) + + logger.info('integration started') + }, +} diff --git a/packages/browser/src/entrypoints/intercom-integration.ts b/packages/browser/src/entrypoints/intercom-integration.ts new file mode 100644 index 000000000..3193f378f --- /dev/null +++ b/packages/browser/src/entrypoints/intercom-integration.ts @@ -0,0 +1,48 @@ +import { PostHog } from '../posthog-core' +import { assignableWindow } from '../utils/globals' +import { createLogger } from '../utils/logger' + +const logger = createLogger('[PostHog Intercom integration]') + +const reportedSessionIds = new Set() + +assignableWindow.__PosthogExtensions__ = assignableWindow.__PosthogExtensions__ || {} +assignableWindow.__PosthogExtensions__.integrations = assignableWindow.__PosthogExtensions__.integrations || {} +assignableWindow.__PosthogExtensions__.integrations.intercom = { + start: (posthog: PostHog) => { + if (!posthog.config.integrations?.intercom) { + return + } + + const intercom = (assignableWindow as any).Intercom + if (!intercom) { + logger.warn(' Intercom not found while initializing the integration') + return + } + + const updateIntercom = () => { + const replayUrl = posthog.get_session_replay_url() + const personUrl = posthog.requestRouter.endpointFor( + 'ui', + `/project/${posthog.config.token}/person/${posthog.get_distinct_id()}` + ) + + intercom('update', { + latestPosthogReplayURL: replayUrl, + latestPosthogPersonURL: personUrl, + }) + intercom('trackEvent', 'posthog:sessionInfo', { replayUrl, personUrl }) + } + + // this is called immediately if there's a session id + // and then again whenever the session id changes + posthog.onSessionId((sessionId) => { + if (!reportedSessionIds.has(sessionId)) { + updateIntercom() + reportedSessionIds.add(sessionId) + } + }) + + logger.info('integration started') + }, +} diff --git a/packages/browser/src/extensions/external-integration.ts b/packages/browser/src/extensions/external-integration.ts new file mode 100644 index 000000000..9cda16001 --- /dev/null +++ b/packages/browser/src/extensions/external-integration.ts @@ -0,0 +1,36 @@ +import { PostHog } from '../posthog-core' +import { ExternalIntegrationKind } from '../types' +import { assignableWindow, ExternalExtensionKind } from '../utils/globals' +import { createLogger } from '../utils/logger' + +const logger = createLogger('[PostHog ExternalIntegrations]') + +const MAPPED_INTEGRATIONS: Record = { + intercom: 'intercom-integration', + crispChat: 'crisp-chat-integration', +} + +export class ExternalIntegrations { + constructor(private readonly _instance: PostHog) {} + + private _loadScript(name: ExternalExtensionKind, cb: () => void): void { + assignableWindow.__PosthogExtensions__?.loadExternalDependency?.(this._instance, name, (err) => { + if (err) { + return logger.error('failed to load script', err) + } + cb() + }) + } + + public startIfEnabledOrStop() { + for (const [key, value] of Object.entries(this._instance.config.integrations ?? {})) { + if (value && !assignableWindow.__PosthogExtensions__?.integrations?.[key as ExternalIntegrationKind]) { + this._loadScript(MAPPED_INTEGRATIONS[key as ExternalIntegrationKind], () => { + assignableWindow.__PosthogExtensions__?.integrations?.[key as ExternalIntegrationKind]?.start( + this._instance + ) + }) + } + } + } +} diff --git a/packages/browser/src/posthog-core.ts b/packages/browser/src/posthog-core.ts index 9c5b77261..ab7c1ce9b 100644 --- a/packages/browser/src/posthog-core.ts +++ b/packages/browser/src/posthog-core.ts @@ -299,6 +299,7 @@ export class PostHog { _requestQueue?: RequestQueue _retryQueue?: RetryQueue sessionRecording?: SessionRecording + externalIntegrations?: ExternalIntegrations webPerformance = new DeprecatedWebPerformanceObserver() _initialPageviewCaptured: boolean @@ -355,6 +356,7 @@ export class PostHog { this.rateLimiter = new RateLimiter(this) this.requestRouter = new RequestRouter(this) this.consent = new ConsentManager(this) + this.externalIntegrations = new ExternalIntegrations(this) // NOTE: See the property definition for deprecation notice this.people = { set: (prop: string | Properties, to?: string, callback?: RequestCallback) => { @@ -1912,6 +1914,7 @@ export class PostHog { this.heatmaps?.startIfEnabled() this.surveys.loadIfEnabled() this._sync_opt_out_with_persistence() + this.externalIntegrations?.startIfEnabledOrStop() } } diff --git a/packages/browser/src/types.ts b/packages/browser/src/types.ts index 1623340e3..f55e7816e 100644 --- a/packages/browser/src/types.ts +++ b/packages/browser/src/types.ts @@ -277,6 +277,8 @@ export type BeforeSendFn = (cr: CaptureResult | null) => CaptureResult | null export type ConfigDefaults = '2025-05-24' | 'unset' +export type ExternalIntegrationKind = 'intercom' | 'crispChat' + /** * Configuration options for the PostHog JavaScript SDK. * @see https://posthog.com/docs/libraries/js#config @@ -958,6 +960,11 @@ export interface PostHogConfig { */ request_queue_config?: RequestQueueConfig + /** + * Used to set-up external integrations with PostHog data - such as session replays, distinct id, etc. + */ + integrations?: Record + // ------- PREVIEW CONFIGS ------- /** diff --git a/packages/browser/src/utils/globals.ts b/packages/browser/src/utils/globals.ts index 3f4b986e6..94bbd6f96 100644 --- a/packages/browser/src/utils/globals.ts +++ b/packages/browser/src/utils/globals.ts @@ -1,7 +1,7 @@ import { ErrorProperties } from '../extensions/exception-autocapture/error-conversion' import type { PostHog } from '../posthog-core' import { SessionIdManager } from '../sessionid' -import { DeadClicksAutoCaptureConfig, RemoteConfig, SiteAppLoader } from '../types' +import { DeadClicksAutoCaptureConfig, ExternalIntegrationKind, RemoteConfig, SiteAppLoader } from '../types' /* * Global helpers to protect access to browser globals in a way that is safer for different targets @@ -49,6 +49,8 @@ export type AssignableWindow = Window & * changes to this interface can be breaking changes for users of the SDK */ +export type ExternalExtensionKind = 'intercom-integration' | 'crisp-chat-integration' + export type PostHogExtensionKind = | 'toolbar' | 'exception-autocapture' @@ -58,6 +60,7 @@ export type PostHogExtensionKind = | 'surveys' | 'dead-clicks-autocapture' | 'remote-config' + | ExternalExtensionKind export interface LazyLoadedDeadClicksAutocaptureInterface { start: (observerTarget: Node) => void @@ -95,6 +98,9 @@ interface PostHogExtensions { ph: PostHog, config: DeadClicksAutoCaptureConfig ) => LazyLoadedDeadClicksAutocaptureInterface + integrations?: { + [K in ExternalIntegrationKind]?: { start: (posthog: PostHog) => void } + } } const global: typeof globalThis | undefined = typeof globalThis !== 'undefined' ? globalThis : win From b700da8634634cabe70ea875a80cd106c912f9b1 Mon Sep 17 00:00:00 2001 From: pauldambra Date: Wed, 25 Jun 2025 11:00:53 +0100 Subject: [PATCH 2/8] import --- packages/browser/src/posthog-core.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/browser/src/posthog-core.ts b/packages/browser/src/posthog-core.ts index ab7c1ce9b..98b359155 100644 --- a/packages/browser/src/posthog-core.ts +++ b/packages/browser/src/posthog-core.ts @@ -92,6 +92,7 @@ import { } from './utils/type-utils' import { uuidv7 } from './uuidv7' import { WebExperiments } from './web-experiments' +import { ExternalIntegrations } from './extensions/external-integration' /* SIMPLE STYLE GUIDE: From 786f21a8a9ad6f84b0d027c30d09699d8db82994 Mon Sep 17 00:00:00 2001 From: pauldambra Date: Wed, 25 Jun 2025 11:16:11 +0100 Subject: [PATCH 3/8] fix --- packages/browser/src/entrypoints/intercom-integration.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/browser/src/entrypoints/intercom-integration.ts b/packages/browser/src/entrypoints/intercom-integration.ts index 3193f378f..e41077f87 100644 --- a/packages/browser/src/entrypoints/intercom-integration.ts +++ b/packages/browser/src/entrypoints/intercom-integration.ts @@ -16,7 +16,7 @@ assignableWindow.__PosthogExtensions__.integrations.intercom = { const intercom = (assignableWindow as any).Intercom if (!intercom) { - logger.warn(' Intercom not found while initializing the integration') + logger.warn('Intercom not found while initializing the integration') return } From 1193cb67425d6442dd849c4da94bec622594c46b Mon Sep 17 00:00:00 2001 From: pauldambra Date: Wed, 25 Jun 2025 11:16:28 +0100 Subject: [PATCH 4/8] fix --- packages/browser/src/entrypoints/crisp-chat-integration.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/browser/src/entrypoints/crisp-chat-integration.ts b/packages/browser/src/entrypoints/crisp-chat-integration.ts index 2c3dbd20d..66867c994 100644 --- a/packages/browser/src/entrypoints/crisp-chat-integration.ts +++ b/packages/browser/src/entrypoints/crisp-chat-integration.ts @@ -16,7 +16,7 @@ assignableWindow.__PosthogExtensions__.integrations.crispChat = { const crispChat = (assignableWindow as any).$crisp if (!crispChat) { - logger.warn(' Crisp Chat not found while initializing the integration') + logger.warn('Crisp Chat not found while initializing the integration') return } From 46f3a045e348e8c46fc8648c5eed3c3700a6a7a1 Mon Sep 17 00:00:00 2001 From: pauldambra Date: Wed, 25 Jun 2025 11:26:14 +0100 Subject: [PATCH 5/8] fix --- packages/browser/src/entrypoints/crisp-chat-integration.ts | 7 ++++++- packages/browser/src/entrypoints/intercom-integration.ts | 7 ++++++- packages/browser/src/extensions/external-integration.ts | 5 +++++ packages/browser/src/utils/globals.ts | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/browser/src/entrypoints/crisp-chat-integration.ts b/packages/browser/src/entrypoints/crisp-chat-integration.ts index 66867c994..90c009096 100644 --- a/packages/browser/src/entrypoints/crisp-chat-integration.ts +++ b/packages/browser/src/entrypoints/crisp-chat-integration.ts @@ -5,6 +5,7 @@ import { createLogger } from '../utils/logger' const logger = createLogger('[PostHog Crisp Chat]') const reportedSessionIds = new Set() +let sessionIdListenerUnsubscribe: undefined | (() => void) = undefined assignableWindow.__PosthogExtensions__ = assignableWindow.__PosthogExtensions__ || {} assignableWindow.__PosthogExtensions__.integrations = assignableWindow.__PosthogExtensions__.integrations || {} @@ -41,7 +42,7 @@ assignableWindow.__PosthogExtensions__.integrations.crispChat = { // this is called immediately if there's a session id // and then again whenever the session id changes - posthog.onSessionId((sessionId) => { + sessionIdListenerUnsubscribe = posthog.onSessionId((sessionId) => { if (!reportedSessionIds.has(sessionId)) { updateCrispChat() reportedSessionIds.add(sessionId) @@ -50,4 +51,8 @@ assignableWindow.__PosthogExtensions__.integrations.crispChat = { logger.info('integration started') }, + stop: () => { + sessionIdListenerUnsubscribe?.() + sessionIdListenerUnsubscribe = undefined + }, } diff --git a/packages/browser/src/entrypoints/intercom-integration.ts b/packages/browser/src/entrypoints/intercom-integration.ts index e41077f87..fd73c1559 100644 --- a/packages/browser/src/entrypoints/intercom-integration.ts +++ b/packages/browser/src/entrypoints/intercom-integration.ts @@ -5,6 +5,7 @@ import { createLogger } from '../utils/logger' const logger = createLogger('[PostHog Intercom integration]') const reportedSessionIds = new Set() +let sessionIdListenerUnsubscribe: undefined | (() => void) = undefined assignableWindow.__PosthogExtensions__ = assignableWindow.__PosthogExtensions__ || {} assignableWindow.__PosthogExtensions__.integrations = assignableWindow.__PosthogExtensions__.integrations || {} @@ -36,7 +37,7 @@ assignableWindow.__PosthogExtensions__.integrations.intercom = { // this is called immediately if there's a session id // and then again whenever the session id changes - posthog.onSessionId((sessionId) => { + sessionIdListenerUnsubscribe = posthog.onSessionId((sessionId) => { if (!reportedSessionIds.has(sessionId)) { updateIntercom() reportedSessionIds.add(sessionId) @@ -45,4 +46,8 @@ assignableWindow.__PosthogExtensions__.integrations.intercom = { logger.info('integration started') }, + stop: () => { + sessionIdListenerUnsubscribe?.() + sessionIdListenerUnsubscribe = undefined + }, } diff --git a/packages/browser/src/extensions/external-integration.ts b/packages/browser/src/extensions/external-integration.ts index 9cda16001..3145144ba 100644 --- a/packages/browser/src/extensions/external-integration.ts +++ b/packages/browser/src/extensions/external-integration.ts @@ -24,6 +24,7 @@ export class ExternalIntegrations { public startIfEnabledOrStop() { for (const [key, value] of Object.entries(this._instance.config.integrations ?? {})) { + // if the integration is enabled, and not present, then load it if (value && !assignableWindow.__PosthogExtensions__?.integrations?.[key as ExternalIntegrationKind]) { this._loadScript(MAPPED_INTEGRATIONS[key as ExternalIntegrationKind], () => { assignableWindow.__PosthogExtensions__?.integrations?.[key as ExternalIntegrationKind]?.start( @@ -31,6 +32,10 @@ export class ExternalIntegrations { ) }) } + // if the integration is disabled, and present, then stop it + if (!value && assignableWindow.__PosthogExtensions__?.integrations?.[key as ExternalIntegrationKind]) { + assignableWindow.__PosthogExtensions__?.integrations?.[key as ExternalIntegrationKind]?.stop() + } } } } diff --git a/packages/browser/src/utils/globals.ts b/packages/browser/src/utils/globals.ts index 94bbd6f96..dcf33aaec 100644 --- a/packages/browser/src/utils/globals.ts +++ b/packages/browser/src/utils/globals.ts @@ -99,7 +99,7 @@ interface PostHogExtensions { config: DeadClicksAutoCaptureConfig ) => LazyLoadedDeadClicksAutocaptureInterface integrations?: { - [K in ExternalIntegrationKind]?: { start: (posthog: PostHog) => void } + [K in ExternalIntegrationKind]?: { start: (posthog: PostHog) => void; stop: () => void } } } From de15c1394714364f57e6c229d95b3eba35cc3f6a Mon Sep 17 00:00:00 2001 From: pauldambra Date: Wed, 25 Jun 2025 12:39:18 +0100 Subject: [PATCH 6/8] fix --- README.md | 6 +++--- .../__tests__/__snapshots__/config-snapshot.test.ts.snap | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 97d3d003c..2d3fcb341 100644 --- a/README.md +++ b/README.md @@ -24,13 +24,13 @@ These dependencies are marked as optional to reduce installation size for users ## -## Testing +## Testing posthog-js > [!NOTE] -> Run `pnpm build` at least once before running tests. +> Run `pnpm --filter=posthog-js build` at least once before running tests. -- Unit tests: run `pnpm test`. +- Unit tests: run `pnpm --filter=posthog-js test`. - Cypress: run `pnpm start` to have a test server running and separately `pnpm cypress` to launch Cypress test engine. - Playwright: run e.g. `pnpm exec playwright test --ui --project webkit --project firefox` to run with UI and in webkit and firefox diff --git a/packages/browser/src/__tests__/__snapshots__/config-snapshot.test.ts.snap b/packages/browser/src/__tests__/__snapshots__/config-snapshot.test.ts.snap index 32432a16b..67c43d5eb 100644 --- a/packages/browser/src/__tests__/__snapshots__/config-snapshot.test.ts.snap +++ b/packages/browser/src/__tests__/__snapshots__/config-snapshot.test.ts.snap @@ -517,6 +517,10 @@ exports[`config snapshot for PostHogConfig 1`] = ` ] } ], + \\"integrations\\": [ + \\"undefined\\", + \\"Record\\" + ], \\"__add_tracing_headers\\": [ \\"undefined\\", \\"false\\", From cb2e0fc50c2f718c989f37d1a097925bcf3a470f Mon Sep 17 00:00:00 2001 From: pauldambra Date: Wed, 25 Jun 2025 12:41:38 +0100 Subject: [PATCH 7/8] fix --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2d3fcb341..cf586f271 100644 --- a/README.md +++ b/README.md @@ -30,9 +30,9 @@ These dependencies are marked as optional to reduce installation size for users > Run `pnpm --filter=posthog-js build` at least once before running tests. -- Unit tests: run `pnpm --filter=posthog-js test`. -- Cypress: run `pnpm start` to have a test server running and separately `pnpm cypress` to launch Cypress test engine. -- Playwright: run e.g. `pnpm exec playwright test --ui --project webkit --project firefox` to run with UI and in webkit and firefox +- Unit tests: run `pnpm --filter=posthog-js test`. + +- Playwright: run `pnpm --filter=posthog-js start` to have a test server running and then run e.g. `pnpm --filter=posthog-js exec playwright test --ui --project webkit --project firefox` to run with UI and in webkit and firefox ### Running TestCafe E2E tests with BrowserStack From 8fb9f33726631ca5291468c8589f6fee0eb48fc4 Mon Sep 17 00:00:00 2001 From: pauldambra Date: Wed, 25 Jun 2025 12:45:48 +0100 Subject: [PATCH 8/8] fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cf586f271..83e774e49 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ We have 2 options for linking this project to your local version: via [pnpm link #### local paths (preferred) - from whichever repo needs to require `posthog-js`, go to the `package.json` of that file, and replace the `posthog-js` dependency version number with `file:` -- e.g. from the `package.json` within `posthog`, replace `"posthog-js": "1.131.4"` with `"posthog-js": "file:../posthog-js"` +- e.g. from the `package.json` within `posthog`, replace `"posthog-js": "1.131.4"` with `"posthog-js": "file:/Users/yourhomefolder/github/posthog-js/packages/browser"` - run `pnpm install` from the root of the project in which you just created a local path Then, once this link has been created, any time you need to make a change to `posthog-js`, you can run `pnpm build` from the `posthog-js` root and the changes will appear in the other repo.