Skip to content

Commit 248d28f

Browse files
authored
chore: bump @mongodb-js/device-id to 0.2.1 (#1051)
1 parent b5c8499 commit 248d28f

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,7 @@
13181318
"@mongodb-js/compass-components": "^1.37.0",
13191319
"@mongodb-js/connection-form": "1.51.0",
13201320
"@mongodb-js/connection-info": "^0.14.0",
1321-
"@mongodb-js/device-id": "^0.2.0",
1321+
"@mongodb-js/device-id": "^0.2.1",
13221322
"@mongodb-js/mongodb-constants": "^0.11.1",
13231323
"@mongosh/browser-runtime-electron": "^3.10.3",
13241324
"@mongosh/i18n": "^2.9.1",

src/telemetry/telemetryService.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)