From cd7f3ef6a7384cc46eaf2bf10c6f7629e6fc7747 Mon Sep 17 00:00:00 2001 From: Bee <68532117+abeatrix@users.noreply.github.com> Date: Tue, 15 Jul 2025 22:46:58 -0700 Subject: [PATCH] Disable recording webview click events (#4709) * Disable recording webview click events Introduces a temporary measure to disable the recording of webview click events in PostHog. This is achieved by adding a `temporaryDisabled` flag that, when true, prevents the initialization of PostHog and stops the identification of users. This change is intended to be temporary and should be reverted in a future commit by removing the `temporaryDisabled` flag. * Use separate PostHog config for development environment This commit introduces a separate PostHog project for the development environment. This allows us to track events in the development environment without polluting the production data. The `posthogConfig` now uses `posthogDevEnvConfig` when `process.env.isDev` is true, and `posthogProdConfig` otherwise. * process.env.IS_DEV * Update src/shared/services/config/posthog-config.ts Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix format --------- Co-authored-by: Beatrix Woo Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> --- src/shared/services/config/posthog-config.ts | 11 ++++++++++- webview-ui/src/CustomPostHogProvider.tsx | 10 +++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/shared/services/config/posthog-config.ts b/src/shared/services/config/posthog-config.ts index fa68ad01..39a10146 100644 --- a/src/shared/services/config/posthog-config.ts +++ b/src/shared/services/config/posthog-config.ts @@ -1,6 +1,15 @@ // Public PostHog key (safe for open source) -export const posthogConfig = { +const posthogProdConfig = { apiKey: "phc_qfOAGxZw2TL5O8p9KYd9ak3bPBFzfjC8fy5L6jNWY7K", host: "https://data.cline.bot", uiHost: "https://us.posthog.com", } + +// Public PostHog key for Development Environment project +const posthogDevEnvConfig = { + apiKey: "phc_uY24EJXNBcc9kwO1K8TJUl5hPQntGM6LL1Mtrz0CBD4", + host: "https://data.cline.bot", + uiHost: "https://us.i.posthog.com", +} + +export const posthogConfig = process.env.IS_DEV === "true" ? posthogDevEnvConfig : posthogProdConfig diff --git a/webview-ui/src/CustomPostHogProvider.tsx b/webview-ui/src/CustomPostHogProvider.tsx index 12c10132..114b6f6d 100644 --- a/webview-ui/src/CustomPostHogProvider.tsx +++ b/webview-ui/src/CustomPostHogProvider.tsx @@ -8,7 +8,15 @@ export function CustomPostHogProvider({ children }: { children: ReactNode }) { const { telemetrySetting, distinctId, version } = useExtensionState() const isTelemetryEnabled = telemetrySetting !== "disabled" + // NOTE: This is a hack to stop recording webview click events temporarily. + // Remove this to re-enable. + const temporaryDisabled = true + useEffect(() => { + if (temporaryDisabled) { + return + } + posthog.init(posthogConfig.apiKey, { api_host: posthogConfig.host, ui_host: posthogConfig.uiHost, @@ -19,7 +27,7 @@ export function CustomPostHogProvider({ children }: { children: ReactNode }) { }, []) useEffect(() => { - if (distinctId.length === 0 || version.length === 0) { + if (temporaryDisabled || distinctId.length === 0 || version.length === 0) { return }