Skip to content

Commit 9b4a931

Browse files
Pablo Vitassoclaude
andcommitted
fix(cloud): respect user telemetry opt-out in CloudTelemetryClient
CloudTelemetryClient was ignoring the didUserOptIn parameter and always returning true from isTelemetryEnabled(), causing telemetry to be sent even when users disabled it. Now checks VS Code global telemetry level and stores the opt-in state, consistent with PostHogTelemetryClient. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d26b04c commit 9b4a931

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

packages/cloud/src/TelemetryClient.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,21 @@ export class CloudTelemetryClient extends BaseTelemetryClient {
257257
}
258258
}
259259

260-
public override updateTelemetryState(_didUserOptIn: boolean) {}
260+
public override updateTelemetryState(didUserOptIn: boolean): void {
261+
let globalTelemetryEnabled = true
262+
try {
263+
// eslint-disable-next-line @typescript-eslint/no-require-imports
264+
const vscode = require("vscode")
265+
const telemetryLevel: string = vscode.workspace.getConfiguration("telemetry").get("telemetryLevel") ?? "all"
266+
globalTelemetryEnabled = telemetryLevel === "all"
267+
} catch {
268+
// Not in a VS Code environment; defer to didUserOptIn only.
269+
}
270+
this.telemetryEnabled = globalTelemetryEnabled && didUserOptIn
271+
}
261272

262273
public override isTelemetryEnabled(): boolean {
263-
return true
274+
return this.telemetryEnabled
264275
}
265276

266277
protected override isEventCapturable(eventName: TelemetryEventName): boolean {

0 commit comments

Comments
 (0)