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 <tingwai@continue.dev>
This commit is contained in:
Continue Agent 2025-10-07 19:54:50 +00:00
parent 2fb5a740ac
commit 73057d374b
6 changed files with 11 additions and 10 deletions

View file

@ -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` |

View file

@ -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

View file

@ -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;
}
});
});

View file

@ -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);
});

View file

@ -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;

View file

@ -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", () => ({