diff --git a/web/lib/posthog-provider.tsx b/web/lib/posthog-provider.tsx index 1f8f6f64a..dad0edba5 100644 --- a/web/lib/posthog-provider.tsx +++ b/web/lib/posthog-provider.tsx @@ -42,9 +42,9 @@ const PostHogProvider: FC = (props) => { }, [user, workspaceRole, projectRole]); useEffect(() => { - if (posthogAPIKey && posthogHost) { + if (posthogAPIKey && (process.env.NEXT_PUBLIC_POSTHOG_HOST || posthogHost)) { posthog.init(posthogAPIKey, { - api_host: posthogHost || "https://app.posthog.com", + api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST || posthogHost || "https://app.posthog.com", 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 diff --git a/web/next-env.d.ts b/web/next-env.d.ts index 4f11a03dc..fd36f9494 100644 --- a/web/next-env.d.ts +++ b/web/next-env.d.ts @@ -1,5 +1,6 @@ /// /// +/// // NOTE: This file should not be edited // see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/web/next.config.js b/web/next.config.js index 256183e31..82405ce45 100644 --- a/web/next.config.js +++ b/web/next.config.js @@ -3,6 +3,9 @@ require("dotenv").config({ path: ".env" }); const { withSentryConfig } = require("@sentry/nextjs"); const nextConfig = { + reactStrictMode: false, + swcMinify: true, + output: "standalone", async headers() { return [ { @@ -11,8 +14,6 @@ const nextConfig = { }, ]; }, - reactStrictMode: false, - swcMinify: true, images: { remotePatterns: [ { @@ -22,7 +23,18 @@ const nextConfig = { ], unoptimized: true, }, - output: "standalone", + async rewrites() { + return [ + { + source: "/ingest/static/:path*", + destination: "https://us-assets.i.posthog.com/static/:path*", + }, + { + source: "/ingest/:path*", + destination: "https://us.i.posthog.com/:path*", + }, + ] + } }; if (parseInt(process.env.NEXT_PUBLIC_ENABLE_SENTRY || "0", 10)) { diff --git a/web/tsconfig.json b/web/tsconfig.json index 8fcf13199..310d42730 100644 --- a/web/tsconfig.json +++ b/web/tsconfig.json @@ -1,13 +1,28 @@ { "extends": "tsconfig/nextjs.json", - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], - "exclude": ["node_modules"], + "include": [ + "next-env.d.ts", + "**/*.ts", + "**/*.tsx", + ".next/types/**/*.ts" + ], + "exclude": [ + "node_modules" + ], "compilerOptions": { "baseUrl": ".", "jsx": "preserve", "esModuleInterop": true, "paths": { - "@/*": ["*"] - } + "@/*": [ + "*" + ] + }, + "plugins": [ + { + "name": "next" + } + ], + "strictNullChecks": true } }