@@ -31,6 +31,7 @@ export class TelemetryService implements ITelemetryService {
3131 private _commonProperties : Promise < { [ name : string ] : any ; } > ;
3232 private _piiPaths : string [ ] ;
3333 private _userOptIn : boolean ;
34+ private _enabled : boolean ;
3435
3536 private _disposables : IDisposable [ ] = [ ] ;
3637 private _cleanupPatterns : RegExp [ ] = [ ] ;
@@ -43,6 +44,7 @@ export class TelemetryService implements ITelemetryService {
4344 this . _commonProperties = config . commonProperties || Promise . resolve ( { } ) ;
4445 this . _piiPaths = config . piiPaths || [ ] ;
4546 this . _userOptIn = true ;
47+ this . _enabled = true ;
4648
4749 // static cleanup pattern for: `file:///DANGEROUS/PATH/resources/app/Useful/Information`
4850 this . _cleanupPatterns = [ / f i l e : \/ \/ \/ .* ?\/ r e s o u r c e s \/ a p p \/ / gi] ;
@@ -74,13 +76,17 @@ export class TelemetryService implements ITelemetryService {
7476 }
7577 }
7678
79+ setEnabled ( value : boolean ) : void {
80+ this . _enabled = value ;
81+ }
82+
7783 private _updateUserOptIn ( ) : void {
7884 const config = this . _configurationService . getValue < any > ( TELEMETRY_SECTION_ID ) ;
7985 this . _userOptIn = config ? config . enableTelemetry : this . _userOptIn ;
8086 }
8187
8288 get isOptedIn ( ) : boolean {
83- return this . _userOptIn ;
89+ return this . _userOptIn && this . _enabled ;
8490 }
8591
8692 getTelemetryInfo ( ) : Promise < ITelemetryInfo > {
@@ -100,7 +106,7 @@ export class TelemetryService implements ITelemetryService {
100106
101107 publicLog ( eventName : string , data ?: ITelemetryData , anonymizeFilePaths ?: boolean ) : Promise < any > {
102108 // don't send events when the user is optout
103- if ( ! this . _userOptIn ) {
109+ if ( ! this . isOptedIn ) {
104110 return Promise . resolve ( undefined ) ;
105111 }
106112
0 commit comments