Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@
"@mongodb-js/compass-components": "^1.37.0",
"@mongodb-js/connection-form": "1.51.0",
"@mongodb-js/connection-info": "^0.14.0",
"@mongodb-js/device-id": "^0.2.0",
"@mongodb-js/device-id": "^0.2.1",
"@mongodb-js/mongodb-constants": "^0.11.1",
"@mongosh/browser-runtime-electron": "^3.10.3",
"@mongosh/i18n": "^2.9.1",
Expand Down
23 changes: 10 additions & 13 deletions src/telemetry/telemetryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ export class TelemetryService {
private readonly _context: vscode.ExtensionContext;
private readonly _shouldTrackTelemetry: boolean; // When tests run the extension, we don't want to track telemetry.

private readonly _deviceIdAbortController = new AbortController();

public deviceId: string | undefined;
private resolveDeviceId: ((value: string) => void) | undefined;

constructor(
storageController: StorageController,
Expand Down Expand Up @@ -119,7 +120,7 @@ export class TelemetryService {
}

deactivate(): void {
this.resolveDeviceId?.('unknown');
this._deviceIdAbortController.abort();
// Flush on demand to make sure that nothing is left in the queue.
void this._segmentAnalytics?.closeAndFlush();
}
Expand Down Expand Up @@ -189,17 +190,6 @@ export class TelemetryService {
this.track(new NewConnectionTelemetryEvent(connectionTelemetryProperties));
}

private async getDeviceId(): Promise<string> {
const { value: deviceId, resolve: resolveDeviceId } = getDeviceId({
getMachineId: (): Promise<string> => nodeMachineId.machineId(true),
isNodeMachineId: true,
});

this.resolveDeviceId = resolveDeviceId;

return deviceId;
}

trackParticipantError(err: any, command: ParticipantResponseType): void {
let errorCode: string | undefined;
let errorName: ParticipantErrorTypes;
Expand Down Expand Up @@ -244,4 +234,11 @@ export class TelemetryService {
5000,
{ leading: true, trailing: false },
);

private getDeviceId(): Promise<string> {
return getDeviceId({
getMachineId: (): Promise<string> => nodeMachineId.machineId(true),
abortSignal: this._deviceIdAbortController.signal,
});
}
}