mirror of
https://git.mirrors.martin98.com/https://github.com/bytedance/deer-flow
synced 2025-08-20 01:29:04 +08:00
feat: integrated with Amplitude in static website mode
This commit is contained in:
parent
98830dbd04
commit
0042b7276a
@ -5,8 +5,10 @@ import "~/styles/globals.css";
|
|||||||
|
|
||||||
import { type Metadata } from "next";
|
import { type Metadata } from "next";
|
||||||
import { Geist } from "next/font/google";
|
import { Geist } from "next/font/google";
|
||||||
|
import Script from "next/script";
|
||||||
|
|
||||||
import { ThemeProviderWrapper } from "~/components/deer-flow/theme-provider-wrapper";
|
import { ThemeProviderWrapper } from "~/components/deer-flow/theme-provider-wrapper";
|
||||||
|
import { env } from "~/env";
|
||||||
|
|
||||||
import { Toaster } from "../components/deer-flow/toaster";
|
import { Toaster } from "../components/deer-flow/toaster";
|
||||||
|
|
||||||
@ -30,6 +32,20 @@ export default function RootLayout({
|
|||||||
<body className="bg-app">
|
<body className="bg-app">
|
||||||
<ThemeProviderWrapper>{children}</ThemeProviderWrapper>
|
<ThemeProviderWrapper>{children}</ThemeProviderWrapper>
|
||||||
<Toaster />
|
<Toaster />
|
||||||
|
{
|
||||||
|
// 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 && (
|
||||||
|
<>
|
||||||
|
<Script src="https://cdn.amplitude.com/script/d2197dd1df3f2959f26295bb0e7e849f.js"></Script>
|
||||||
|
<Script id="amplitude-init" strategy="lazyOnload">
|
||||||
|
{`window.amplitude.init('${env.AMPLITUDE_API_KEY}', {"fetchRemoteConfig":true,"autocapture":true});`}
|
||||||
|
</Script>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
|
@ -11,6 +11,7 @@ export const env = createEnv({
|
|||||||
*/
|
*/
|
||||||
server: {
|
server: {
|
||||||
NODE_ENV: z.enum(["development", "test", "production"]),
|
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_API_URL: process.env.NEXT_PUBLIC_API_URL,
|
||||||
NEXT_PUBLIC_STATIC_WEBSITE_ONLY:
|
NEXT_PUBLIC_STATIC_WEBSITE_ONLY:
|
||||||
process.env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY === "true",
|
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
|
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
|
||||||
|
Loading…
x
Reference in New Issue
Block a user