Skip to content

Commit 9ec6590

Browse files
Use env.isTelemetryEnabled instead of checking configuration values ourselves
1 parent 5fc9a73 commit 9ec6590

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

extensions/ql-vscode/src/common/vscode/telemetry.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
Extension,
44
ExtensionContext,
55
ConfigurationChangeEvent,
6+
env,
67
} from "vscode";
78
import TelemetryReporter from "vscode-extension-telemetry";
89
import {
@@ -224,7 +225,7 @@ export class ExtensionTelemetryListener
224225
// if global telemetry is disabled, avoid showing the dialog or making any changes
225226
let result = undefined;
226227
if (
227-
isGlobalTelemetryEnabled() &&
228+
env.isTelemetryEnabled &&
228229
// Avoid showing the dialog if we are in integration test mode.
229230
!isIntegrationTestMode()
230231
) {
@@ -297,21 +298,3 @@ export async function initializeTelemetry(
297298
ctx.subscriptions.push(telemetryListener);
298299
return telemetryListener;
299300
}
300-
301-
function isGlobalTelemetryEnabled(): boolean {
302-
// If "enableTelemetry" is set to false, no telemetry will be sent regardless of the value of "telemetryLevel"
303-
const enableTelemetry: boolean | undefined =
304-
GLOBAL_ENABLE_TELEMETRY.getValue();
305-
if (enableTelemetry === false) {
306-
return false;
307-
}
308-
309-
// If a value for "telemetry.telemetryLevel" is provided, then use that
310-
const telemetryLevel: string | undefined = GLOBAL_TELEMETRY_LEVEL.getValue();
311-
if (telemetryLevel !== undefined) {
312-
return telemetryLevel !== "off";
313-
}
314-
315-
// Otherwise fall back to the deprecated "telemetry.enableTelemetry" setting
316-
return !!enableTelemetry;
317-
}

0 commit comments

Comments
 (0)