@@ -46,8 +46,9 @@ export class TelemetryService {
4646 private readonly _context : vscode . ExtensionContext ;
4747 private readonly _shouldTrackTelemetry : boolean ; // When tests run the extension, we don't want to track telemetry.
4848
49+ private readonly _deviceIdAbortController = new AbortController ( ) ;
50+
4951 public deviceId : string | undefined ;
50- private resolveDeviceId : ( ( value : string ) => void ) | undefined ;
5152
5253 constructor (
5354 storageController : StorageController ,
@@ -119,7 +120,7 @@ export class TelemetryService {
119120 }
120121
121122 deactivate ( ) : void {
122- this . resolveDeviceId ?. ( 'unknown' ) ;
123+ this . _deviceIdAbortController . abort ( ) ;
123124 // Flush on demand to make sure that nothing is left in the queue.
124125 void this . _segmentAnalytics ?. closeAndFlush ( ) ;
125126 }
@@ -189,17 +190,6 @@ export class TelemetryService {
189190 this . track ( new NewConnectionTelemetryEvent ( connectionTelemetryProperties ) ) ;
190191 }
191192
192- private async getDeviceId ( ) : Promise < string > {
193- const { value : deviceId , resolve : resolveDeviceId } = getDeviceId ( {
194- getMachineId : ( ) : Promise < string > => nodeMachineId . machineId ( true ) ,
195- isNodeMachineId : true ,
196- } ) ;
197-
198- this . resolveDeviceId = resolveDeviceId ;
199-
200- return deviceId ;
201- }
202-
203193 trackParticipantError ( err : any , command : ParticipantResponseType ) : void {
204194 let errorCode : string | undefined ;
205195 let errorName : ParticipantErrorTypes ;
@@ -244,4 +234,11 @@ export class TelemetryService {
244234 5000 ,
245235 { leading : true , trailing : false } ,
246236 ) ;
237+
238+ private getDeviceId ( ) : Promise < string > {
239+ return getDeviceId ( {
240+ getMachineId : ( ) : Promise < string > => nodeMachineId . machineId ( true ) ,
241+ abortSignal : this . _deviceIdAbortController . signal ,
242+ } ) ;
243+ }
247244}
0 commit comments