@@ -11,41 +11,41 @@ type EventResult = {
1111 error ?: Error ;
1212} ;
1313
14- export class Telemetry {
15- private readonly commonProperties : CommonProperties ;
16-
17- constructor (
18- private readonly session : Session ,
19- private readonly eventCache : EventCache = EventCache . getInstance ( )
20- ) {
21- this . commonProperties = {
22- ...MACHINE_METADATA ,
23- } ;
24- }
25-
26- /**
14+ /**
2715 * Checks if telemetry is currently enabled
2816 * This is a method rather than a constant to capture runtime config changes
2917 *
3018 * Follows the Console Do Not Track standard (https://consoledonottrack.com/)
3119 * by respecting the DO_NOT_TRACK environment variable
3220 */
33- private static isTelemetryEnabled ( ) : boolean {
34- // Check if telemetry is explicitly disabled in config
35- if ( config . telemetry === "disabled" ) {
21+ export function isTelemetryEnabled ( ) : boolean {
22+ // Check if telemetry is explicitly disabled in config
23+ if ( config . telemetry === "disabled" ) {
24+ return false ;
25+ }
26+
27+ const doNotTrack = process . env . DO_NOT_TRACK ;
28+ if ( doNotTrack ) {
29+ const value = doNotTrack . toLowerCase ( ) ;
30+ // Telemetry should be disabled if DO_NOT_TRACK is "1", "true", or "yes"
31+ if ( value === "1" || value === "true" || value === "yes" ) {
3632 return false ;
3733 }
34+ }
3835
39- const doNotTrack = process . env . DO_NOT_TRACK ;
40- if ( doNotTrack ) {
41- const value = doNotTrack . toLowerCase ( ) ;
42- // Telemetry should be disabled if DO_NOT_TRACK is "1", "true", or "yes"
43- if ( value === "1" || value === "true" || value === "yes" ) {
44- return false ;
45- }
46- }
36+ return true ;
37+ }
38+
39+ export class Telemetry {
40+ private readonly commonProperties : CommonProperties ;
4741
48- return true ;
42+ constructor (
43+ private readonly session : Session ,
44+ private readonly eventCache : EventCache = EventCache . getInstance ( )
45+ ) {
46+ this . commonProperties = {
47+ ...MACHINE_METADATA ,
48+ } ;
4949 }
5050
5151 /**
@@ -54,7 +54,8 @@ export class Telemetry {
5454 */
5555 public async emitEvents ( events : BaseEvent [ ] ) : Promise < void > {
5656 try {
57- if ( ! Telemetry . isTelemetryEnabled ( ) ) {
57+ if ( ! isTelemetryEnabled ( ) ) {
58+ logger . info ( LogId . telemetryEmitFailure , "telemetry" , `Telemetry is disabled.` ) ;
5859 return ;
5960 }
6061
0 commit comments