diff --git a/web/src/app/layout.tsx b/web/src/app/layout.tsx index 9fc1ae0..cc95153 100644 --- a/web/src/app/layout.tsx +++ b/web/src/app/layout.tsx @@ -5,8 +5,10 @@ import "~/styles/globals.css"; import { type Metadata } from "next"; import { Geist } from "next/font/google"; +import Script from "next/script"; import { ThemeProviderWrapper } from "~/components/deer-flow/theme-provider-wrapper"; +import { env } from "~/env"; import { Toaster } from "../components/deer-flow/toaster"; @@ -30,6 +32,20 @@ export default function RootLayout({ {children} + { + // NO USER BEHAVIOR TRACKING OR PRIVATE DATA COLLECTION BY DEFAULT + // + // When `NEXT_PUBLIC_STATIC_WEBSITE_ONLY` is `true`, the script will be injected + // into the page only when `AMPLITUDE_API_KEY` is provided in `.env` + } + {env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY && env.AMPLITUDE_API_KEY && ( + <> + + + + )} ); diff --git a/web/src/env.js b/web/src/env.js index 7d4448a..f6bbf3f 100644 --- a/web/src/env.js +++ b/web/src/env.js @@ -11,6 +11,7 @@ export const env = createEnv({ */ server: { NODE_ENV: z.enum(["development", "test", "production"]), + AMPLITUDE_API_KEY: z.string().optional(), }, /** @@ -32,6 +33,7 @@ export const env = createEnv({ NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL, NEXT_PUBLIC_STATIC_WEBSITE_ONLY: process.env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY === "true", + AMPLITUDE_API_KEY: process.env.AMPLITUDE_API_KEY, }, /** * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially