Skip to content

Commit b419081

Browse files
author
Benjamin Pasero
authored
reuse telemetry constants (microsoft#92099)
1 parent ffcd280 commit b419081

3 files changed

Lines changed: 8 additions & 16 deletions

File tree

src/vs/code/electron-main/app.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
2626
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
2727
import { IURLService } from 'vs/platform/url/common/url';
2828
import { URLHandlerChannelClient, URLHandlerRouter } from 'vs/platform/url/common/urlIpc';
29-
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
29+
import { ITelemetryService, machineIdKey, trueMachineIdKey } from 'vs/platform/telemetry/common/telemetry';
3030
import { NullTelemetryService, combinedAppender, LogAppender } from 'vs/platform/telemetry/common/telemetryUtils';
3131
import { TelemetryAppenderClient } from 'vs/platform/telemetry/node/telemetryIpc';
3232
import { TelemetryService, ITelemetryServiceConfig } from 'vs/platform/telemetry/common/telemetryService';
@@ -79,10 +79,6 @@ import { parseArgs, OPTIONS } from 'vs/platform/environment/node/argv';
7979
import { coalesce } from 'vs/base/common/arrays';
8080

8181
export class CodeApplication extends Disposable {
82-
83-
private static readonly MACHINE_ID_KEY = 'telemetry.machineId';
84-
private static readonly TRUE_MACHINE_ID_KEY = 'telemetry.trueMachineId';
85-
8682
private windowsMainService: IWindowsMainService | undefined;
8783
private dialogMainService: IDialogMainService | undefined;
8884

@@ -407,21 +403,21 @@ export class CodeApplication extends Disposable {
407403

408404
// We cache the machineId for faster lookups on startup
409405
// and resolve it only once initially if not cached
410-
let machineId = this.stateService.getItem<string>(CodeApplication.MACHINE_ID_KEY);
406+
let machineId = this.stateService.getItem<string>(machineIdKey);
411407
if (!machineId) {
412408
machineId = await getMachineId();
413409

414-
this.stateService.setItem(CodeApplication.MACHINE_ID_KEY, machineId);
410+
this.stateService.setItem(machineIdKey, machineId);
415411
}
416412

417413
// Check if machineId is hashed iBridge Device
418414
let trueMachineId: string | undefined;
419415
if (isMacintosh && machineId === '6c9d2bc8f91b89624add29c0abeae7fb42bf539fa1cdb2e3e57cd668fa9bcead') {
420-
trueMachineId = this.stateService.getItem<string>(CodeApplication.TRUE_MACHINE_ID_KEY);
416+
trueMachineId = this.stateService.getItem<string>(trueMachineIdKey);
421417
if (!trueMachineId) {
422418
trueMachineId = await getMachineId();
423419

424-
this.stateService.setItem(CodeApplication.TRUE_MACHINE_ID_KEY, trueMachineId);
420+
this.stateService.setItem(trueMachineIdKey, trueMachineId);
425421
}
426422
}
427423

src/vs/platform/telemetry/browser/workbenchCommonProperties.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,11 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
7-
8-
export const instanceStorageKey = 'telemetry.instanceId';
9-
export const currentSessionDateStorageKey = 'telemetry.currentSessionDate';
10-
export const firstSessionDateStorageKey = 'telemetry.firstSessionDate';
11-
export const lastSessionDateStorageKey = 'telemetry.lastSessionDate';
12-
export const machineIdKey = 'telemetry.machineId';
13-
147
import * as Platform from 'vs/base/common/platform';
158
import * as uuid from 'vs/base/common/uuid';
169
import { cleanRemoteAuthority } from 'vs/platform/telemetry/common/telemetryUtils';
1710
import { mixin } from 'vs/base/common/objects';
11+
import { firstSessionDateStorageKey, lastSessionDateStorageKey, machineIdKey } from 'vs/platform/telemetry/common/telemetry';
1812

1913
export async function resolveWorkbenchCommonProperties(
2014
storageService: IStorageService,

src/vs/platform/telemetry/common/telemetry.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,6 @@ export const instanceStorageKey = 'telemetry.instanceId';
4545
export const currentSessionDateStorageKey = 'telemetry.currentSessionDate';
4646
export const firstSessionDateStorageKey = 'telemetry.firstSessionDate';
4747
export const lastSessionDateStorageKey = 'telemetry.lastSessionDate';
48+
export const machineIdKey = 'telemetry.machineId';
49+
export const trueMachineIdKey = 'telemetry.trueMachineId';
4850
export const crashReporterIdStorageKey = 'crashReporter.guid';

0 commit comments

Comments
 (0)