@@ -11,41 +11,41 @@ type EventResult = {
11
11
error ?: Error ;
12
12
} ;
13
13
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
+ /**
27
15
* Checks if telemetry is currently enabled
28
16
* This is a method rather than a constant to capture runtime config changes
29
17
*
30
18
* Follows the Console Do Not Track standard (https://consoledonottrack.com/)
31
19
* by respecting the DO_NOT_TRACK environment variable
32
20
*/
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" ) {
36
32
return false ;
37
33
}
34
+ }
38
35
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 ;
47
41
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
+ } ;
49
49
}
50
50
51
51
/**
@@ -54,7 +54,8 @@ export class Telemetry {
54
54
*/
55
55
public async emitEvents ( events : BaseEvent [ ] ) : Promise < void > {
56
56
try {
57
- if ( ! Telemetry . isTelemetryEnabled ( ) ) {
57
+ if ( ! isTelemetryEnabled ( ) ) {
58
+ logger . info ( LogId . telemetryEmitFailure , "telemetry" , `Telemetry is disabled.` ) ;
58
59
return ;
59
60
}
60
61
0 commit comments