@@ -46,8 +46,9 @@ export class TelemetryService {
46
46
private readonly _context : vscode . ExtensionContext ;
47
47
private readonly _shouldTrackTelemetry : boolean ; // When tests run the extension, we don't want to track telemetry.
48
48
49
+ private readonly _deviceIdAbortController = new AbortController ( ) ;
50
+
49
51
public deviceId : string | undefined ;
50
- private resolveDeviceId : ( ( value : string ) => void ) | undefined ;
51
52
52
53
constructor (
53
54
storageController : StorageController ,
@@ -119,7 +120,7 @@ export class TelemetryService {
119
120
}
120
121
121
122
deactivate ( ) : void {
122
- this . resolveDeviceId ?. ( 'unknown' ) ;
123
+ this . _deviceIdAbortController . abort ( ) ;
123
124
// Flush on demand to make sure that nothing is left in the queue.
124
125
void this . _segmentAnalytics ?. closeAndFlush ( ) ;
125
126
}
@@ -189,17 +190,6 @@ export class TelemetryService {
189
190
this . track ( new NewConnectionTelemetryEvent ( connectionTelemetryProperties ) ) ;
190
191
}
191
192
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
-
203
193
trackParticipantError ( err : any , command : ParticipantResponseType ) : void {
204
194
let errorCode : string | undefined ;
205
195
let errorName : ParticipantErrorTypes ;
@@ -244,4 +234,11 @@ export class TelemetryService {
244
234
5000 ,
245
235
{ leading : true , trailing : false } ,
246
236
) ;
237
+
238
+ private getDeviceId ( ) : Promise < string > {
239
+ return getDeviceId ( {
240
+ getMachineId : ( ) : Promise < string > => nodeMachineId . machineId ( true ) ,
241
+ abortSignal : this . _deviceIdAbortController . signal ,
242
+ } ) ;
243
+ }
247
244
}
0 commit comments