SurfSense/surfsense_web/instrumentation-client.ts
DESKTOP-RTLN3BA\$punk 8298efe0b1 feat: configure PostHog reverse proxy to bypass ad blockers
- Updated PostHog initialization to use a reverse proxy for API requests.
- Added rewrites in Next.js configuration to route requests through the domain.
- Set ui_host for proper toolbar functionality and ensured correct pageview tracking.
2025-12-25 14:22:48 -08:00

16 lines
594 B
TypeScript

import posthog from "posthog-js";
if (process.env.NEXT_PUBLIC_POSTHOG_KEY) {
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, {
// Use reverse proxy to bypass ad blockers
api_host: "/ingest",
// Required for toolbar and other UI features to work correctly
ui_host: "https://us.posthog.com",
defaults: "2025-11-30",
// Disable automatic pageview capture, as we capture manually with PostHogProvider
// This ensures proper pageview tracking with Next.js client-side navigation
capture_pageview: "history_change",
// Enable session recording
capture_pageleave: true,
});
}