From 195beeacac8b99c605a17b7eb3bdd591b13c479e Mon Sep 17 00:00:00 2001 From: Huang Xin Date: Fri, 10 Oct 2025 13:03:49 +0800 Subject: [PATCH] chore: don't init posthog if users opt-out the usage data telemetry, closes #2187 (#2192) --- apps/readest-app/src/context/PHContext.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/apps/readest-app/src/context/PHContext.tsx b/apps/readest-app/src/context/PHContext.tsx index 97222701..058500b2 100644 --- a/apps/readest-app/src/context/PHContext.tsx +++ b/apps/readest-app/src/context/PHContext.tsx @@ -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 }) => {