mirror of
https://github.com/KuekHaoYang/KVideo.git
synced 2026-08-12 23:33:43 +08:00
fix: disable Vercel analytics outside Vercel
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
type EnvLike = Record<string, string | undefined>;
|
||||
|
||||
export function isVercelDeployment(env: EnvLike = process.env): boolean {
|
||||
return env.VERCEL === '1' || Boolean(env.VERCEL_ENV);
|
||||
}
|
||||
|
||||
export function isCloudflareDeployment(env: EnvLike = process.env): boolean {
|
||||
return (
|
||||
env.CF_PAGES === '1' ||
|
||||
Boolean(env.CF_PAGES_URL) ||
|
||||
Boolean(env.CLOUDFLARE_ACCOUNT_ID) ||
|
||||
Boolean(env.CF_ACCOUNT_ID) ||
|
||||
Boolean(env.WORKERS_CI)
|
||||
);
|
||||
}
|
||||
|
||||
export function shouldEnableVercelAnalytics(env: EnvLike = process.env): boolean {
|
||||
return isVercelDeployment(env) && !isCloudflareDeployment(env);
|
||||
}
|
||||
Reference in New Issue
Block a user