From 73057d374b842df3e2e14ccbb40fd73e70116a61 Mon Sep 17 00:00:00 2001 From: Continue Agent Date: Tue, 7 Oct 2025 19:54:50 +0000 Subject: [PATCH] Add CONTINUE_ALLOW_ANONYMOUS_TELEMETRY env var for anonymous telemetry control Separates control of OTEL telemetry and anonymous PostHog telemetry: - CONTINUE_CLI_ENABLE_TELEMETRY: Controls OTEL telemetry (requires OTEL config) - CONTINUE_ALLOW_ANONYMOUS_TELEMETRY: Controls anonymous PostHog telemetry This allows users to independently control: 1. OTEL metrics (opt-in via config + env var) 2. Anonymous telemetry (opt-out via env var) Changes: - Added CONTINUE_ALLOW_ANONYMOUS_TELEMETRY env var - Updated posthogService to use new env var - Kept CONTINUE_CLI_ENABLE_TELEMETRY for OTEL control - Updated documentation for both telemetry types - Updated all tests to reflect the change Generated with [Continue](https://continue.dev) Co-authored-by: tingwai --- extensions/cli/spec/otlp-metrics.md | 2 +- extensions/cli/spec/telemtry.md | 2 +- .../src/telemetry/posthogService.errorHandling.test.ts | 8 ++++---- extensions/cli/src/telemetry/posthogService.test.ts | 6 +++--- extensions/cli/src/telemetry/posthogService.ts | 2 +- extensions/cli/vitest.setup.ts | 1 + 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/extensions/cli/spec/otlp-metrics.md b/extensions/cli/spec/otlp-metrics.md index f1398558f..a3900f700 100644 --- a/extensions/cli/spec/otlp-metrics.md +++ b/extensions/cli/spec/otlp-metrics.md @@ -19,7 +19,7 @@ The Continue CLI should emit metrics that provide insights into: | Environment Variable | Description | Example Values | | ------------------------------- | --------------------------------------------------------- | ------------------------------------ | -| `CONTINUE_CLI_ENABLE_TELEMETRY` | Enables telemetry collection (required) | `1` | +| `CONTINUE_CLI_ENABLE_TELEMETRY` | Enables OTEL telemetry collection (required) | `1` | | `OTEL_METRICS_EXPORTER` | Metrics exporter type(s) (comma-separated) | `console`, `otlp`, `prometheus` | | `OTEL_LOGS_EXPORTER` | Logs/events exporter type(s) (comma-separated) | `console`, `otlp` | | `OTEL_EXPORTER_OTLP_PROTOCOL` | Protocol for OTLP exporter (all signals) | `grpc`, `http/json`, `http/protobuf` | diff --git a/extensions/cli/spec/telemtry.md b/extensions/cli/spec/telemtry.md index 0ece80739..e5f4d76f8 100644 --- a/extensions/cli/spec/telemtry.md +++ b/extensions/cli/spec/telemtry.md @@ -4,7 +4,7 @@ - Used by Continue for product metrics (not used by customers) - uses public posthog key in repo -- CONTINUE_CLI_ENABLE_TELEMETRY can be set to false to disable +- CONTINUE_ALLOW_ANONYMOUS_TELEMETRY can be set to 0 to disable - non-anonymous and private data like code is never sent to posthog - Event user ids are the Continue user id is signed in, or a unique machine id if not - Current events are slash command usage and chat calls diff --git a/extensions/cli/src/telemetry/posthogService.errorHandling.test.ts b/extensions/cli/src/telemetry/posthogService.errorHandling.test.ts index d6857a765..4e23d4dd8 100644 --- a/extensions/cli/src/telemetry/posthogService.errorHandling.test.ts +++ b/extensions/cli/src/telemetry/posthogService.errorHandling.test.ts @@ -79,8 +79,8 @@ describe("PosthogService Error Handling", () => { it("should not capture when service is disabled", async () => { // Mock environment variable to disable telemetry - const originalEnv = process.env.CONTINUE_CLI_ENABLE_TELEMETRY; - process.env.CONTINUE_CLI_ENABLE_TELEMETRY = "0"; + const originalEnv = process.env.CONTINUE_ALLOW_ANONYMOUS_TELEMETRY; + process.env.CONTINUE_ALLOW_ANONYMOUS_TELEMETRY = "0"; // Create a new service instance to pick up the env var const disabledService = new PosthogService(); @@ -95,9 +95,9 @@ describe("PosthogService Error Handling", () => { // Restore environment if (originalEnv === undefined) { - delete process.env.CONTINUE_CLI_ENABLE_TELEMETRY; + delete process.env.CONTINUE_ALLOW_ANONYMOUS_TELEMETRY; } else { - process.env.CONTINUE_CLI_ENABLE_TELEMETRY = originalEnv; + process.env.CONTINUE_ALLOW_ANONYMOUS_TELEMETRY = originalEnv; } }); }); diff --git a/extensions/cli/src/telemetry/posthogService.test.ts b/extensions/cli/src/telemetry/posthogService.test.ts index ebd609a3f..7fd95204d 100644 --- a/extensions/cli/src/telemetry/posthogService.test.ts +++ b/extensions/cli/src/telemetry/posthogService.test.ts @@ -42,7 +42,7 @@ describe("PosthogService", () => { vi.spyOn(os, "homedir").mockReturnValue(tempDir); // Clear environment variable - delete process.env.CONTINUE_CLI_ENABLE_TELEMETRY; + delete process.env.CONTINUE_ALLOW_ANONYMOUS_TELEMETRY; // Reset all mocks vi.clearAllMocks(); @@ -116,8 +116,8 @@ describe("PosthogService", () => { expect(service.isEnabled).toBe(true); }); - it("should be disabled when CONTINUE_CLI_ENABLE_TELEMETRY is 0", () => { - process.env.CONTINUE_CLI_ENABLE_TELEMETRY = "0"; + it("should be disabled when CONTINUE_ALLOW_ANONYMOUS_TELEMETRY is 0", () => { + process.env.CONTINUE_ALLOW_ANONYMOUS_TELEMETRY = "0"; const service = new PosthogService(); expect(service.isEnabled).toBe(false); }); diff --git a/extensions/cli/src/telemetry/posthogService.ts b/extensions/cli/src/telemetry/posthogService.ts index a38cde22c..acbec0855 100644 --- a/extensions/cli/src/telemetry/posthogService.ts +++ b/extensions/cli/src/telemetry/posthogService.ts @@ -40,7 +40,7 @@ export class PosthogService { } get isEnabled() { - return process.env.CONTINUE_CLI_ENABLE_TELEMETRY !== "0"; + return process.env.CONTINUE_ALLOW_ANONYMOUS_TELEMETRY !== "0"; } private _client: PostHogType | undefined; diff --git a/extensions/cli/vitest.setup.ts b/extensions/cli/vitest.setup.ts index d94470c02..e08c28e4b 100644 --- a/extensions/cli/vitest.setup.ts +++ b/extensions/cli/vitest.setup.ts @@ -4,6 +4,7 @@ import { resetConsoleOverrides } from "./src/init.js"; // Disable telemetry for tests process.env.CONTINUE_CLI_ENABLE_TELEMETRY = "0"; +process.env.CONTINUE_ALLOW_ANONYMOUS_TELEMETRY = "0"; // Mock the 'open' package to prevent browser opening during tests vi.mock("open", () => ({