diff --git a/turbo.json b/turbo.json index 4fb34d29d..fde4ffc79 100644 --- a/turbo.json +++ b/turbo.json @@ -8,7 +8,6 @@ "NEXT_PUBLIC_SPACE_BASE_URL", "NEXT_PUBLIC_SPACE_BASE_PATH", "NEXT_PUBLIC_WEB_BASE_URL", - "NEXT_PUBLIC_TRACK_EVENTS", "NEXT_PUBLIC_PLAUSIBLE_DOMAIN", "NEXT_PUBLIC_CRISP_ID", "NEXT_PUBLIC_ENABLE_SESSION_RECORDER", diff --git a/web/lib/posthog-provider.tsx b/web/lib/posthog-provider.tsx index 3517fb7a7..6a5bcbaaf 100644 --- a/web/lib/posthog-provider.tsx +++ b/web/lib/posthog-provider.tsx @@ -20,7 +20,7 @@ export interface IPosthogWrapper { } const PostHogProvider: FC = (props) => { - const { children, user, workspaceRole, currentWorkspaceId, projectRole, posthogAPIKey, posthogHost } = props; + const { children, user, workspaceRole, currentWorkspaceId, projectRole } = props; // states const [lastWorkspaceId, setLastWorkspaceId] = useState(currentWorkspaceId); // router @@ -42,15 +42,16 @@ const PostHogProvider: FC = (props) => { }, [user, workspaceRole, projectRole]); useEffect(() => { - if (posthogAPIKey && (process.env.NEXT_PUBLIC_POSTHOG_HOST || posthogHost)) { - posthog.init(posthogAPIKey, { - api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST || posthogHost || "https://app.posthog.com", + if (process.env.NEXT_PUBLIC_POSTHOG_KEY && process.env.NEXT_PUBLIC_POSTHOG_HOST) { + posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, { + api_host: "/ingest", + ui_host: process.env.NEXT_PUBLIC_POSTHOG_HOST, debug: process.env.NEXT_PUBLIC_POSTHOG_DEBUG === "1", // Debug mode based on the environment variable autocapture: false, capture_pageview: false, // Disable automatic pageview capture, as we capture manually }); } - }, [posthogAPIKey, posthogHost]); + }, []); useEffect(() => { // Join workspace group on workspace change diff --git a/web/next.config.js b/web/next.config.js index 0482f507f..2a69a01a7 100644 --- a/web/next.config.js +++ b/web/next.config.js @@ -55,14 +55,15 @@ const nextConfig = { ] }, async rewrites() { + const posthogHost = process.env.NEXT_PUBLIC_POSTHOG_HOST || "https://app.posthog.com" const rewrites = [ { source: "/ingest/static/:path*", - destination: "https://us-assets.i.posthog.com/static/:path*", + destination: `${posthogHost}/static/:path*`, }, { source: "/ingest/:path*", - destination: "https://us.i.posthog.com/:path*", + destination: `${posthogHost}/:path*`, }, ]; if (process.env.NEXT_PUBLIC_ADMIN_BASE_URL || process.env.NEXT_PUBLIC_ADMIN_BASE_PATH) {