chore: don't init posthog if users opt-out the usage data telemetry, closes #2187 (#2192)

This commit is contained in:
Huang Xin
2025-10-10 13:03:49 +08:00
committed by GitHub
parent 5b23ed35b6
commit 195beeacac
+5 -6
View File
@@ -19,12 +19,11 @@ const posthogKey =
atob(process.env['NEXT_PUBLIC_DEFAULT_POSTHOG_KEY_BASE64']!);
if (typeof window !== 'undefined' && process.env['NODE_ENV'] === 'production' && posthogKey) {
posthog.init(posthogKey, {
api_host: posthogUrl,
person_profiles: 'always',
});
if (shouldDisablePostHog()) {
posthog.opt_out_capturing();
if (!shouldDisablePostHog()) {
posthog.init(posthogKey, {
api_host: posthogUrl,
person_profiles: 'always',
});
}
}
export const CSPostHogProvider = ({ children }: { children: ReactNode }) => {