Skip to content

Commit 2e33584

Browse files
committed
address comment: support do_not_track
1 parent 5209073 commit 2e33584

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/telemetry/telemetry.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,27 @@ export class Telemetry {
4747
/**
4848
* Checks if telemetry is currently enabled
4949
* This is a method rather than a constant to capture runtime config changes
50+
*
51+
* Follows the Console Do Not Track standard (https://consoledonottrack.com/)
52+
* by respecting the DO_NOT_TRACK environment variable
5053
*/
5154
private static isTelemetryEnabled(): boolean {
52-
return config.telemetry !== "disabled";
55+
// Check if telemetry is explicitly disabled in config
56+
if (config.telemetry === "disabled") {
57+
return false;
58+
}
59+
60+
// Check for DO_NOT_TRACK environment variable as per https://consoledonottrack.com/
61+
const doNotTrack = process.env.DO_NOT_TRACK;
62+
if (doNotTrack) {
63+
const value = doNotTrack.toLowerCase();
64+
// Telemetry should be disabled if DO_NOT_TRACK is "1", "true", or "yes"
65+
if (value === "1" || value === "true" || value === "yes") {
66+
return false;
67+
}
68+
}
69+
70+
return true;
5371
}
5472

5573
/**

0 commit comments

Comments
 (0)