From a18152713ccc44f0d0f534cfb69f1be31d931fe8 Mon Sep 17 00:00:00 2001 From: Brian Love Date: Sat, 2 May 2026 10:36:18 -0700 Subject: [PATCH] fix(website): ensure PostHog captures events --- apps/website/instrumentation-client.ts | 1 + apps/website/src/lib/analytics/client.ts | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/website/instrumentation-client.ts b/apps/website/instrumentation-client.ts index 2f08ee5ee..716f7823d 100644 --- a/apps/website/instrumentation-client.ts +++ b/apps/website/instrumentation-client.ts @@ -12,5 +12,6 @@ if (shouldCaptureAnalytics({ token, captureLocal, host: browserHost })) { posthog.init(token!, { api_host: normalizePostHogHost(process.env.NEXT_PUBLIC_POSTHOG_HOST), defaults: '2026-01-30', + capture_pageview: true, }); } diff --git a/apps/website/src/lib/analytics/client.ts b/apps/website/src/lib/analytics/client.ts index 0ccac187d..ad403bef1 100644 --- a/apps/website/src/lib/analytics/client.ts +++ b/apps/website/src/lib/analytics/client.ts @@ -11,12 +11,15 @@ function currentSourcePage(): string { export function track(event: AnalyticsEventName, properties: AnalyticsProperties = {}) { if (typeof window === 'undefined') return; - if (!posthog.__loaded) return; - posthog.capture(event, { - source_page: currentSourcePage(), - ...properties, - }); + try { + posthog.capture(event, { + source_page: currentSourcePage(), + ...properties, + }); + } catch (err) { + console.error('[posthog] client capture failed:', err); + } } export function trackCtaClick(properties: AnalyticsProperties) {