Skip to content

Commit 4f89ece

Browse files
committed
Set machineId in shared process (fixes microsoft#20349)
1 parent 6fccb17 commit 4f89ece

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/vs/base/node/id.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@ export function _futureMachineIdExperiment(): string {
9797
return mac.value;
9898
}
9999

100+
let machineId: TPromise<string>;
100101
export function getMachineId(): TPromise<string> {
101-
return new TPromise<string>(resolve => {
102+
return machineId || (machineId = new TPromise<string>(resolve => {
102103
try {
103104
getmac.getMac((error, macAddress) => {
104105
if (!error) {
@@ -111,5 +112,5 @@ export function getMachineId(): TPromise<string> {
111112
errors.onUnexpectedError(err);
112113
resolve(uuid.generateUuid()); // fallback, generate a UUID
113114
}
114-
});
115+
}));
115116
}

src/vs/platform/telemetry/node/commonProperties.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as Platform from 'vs/base/common/platform';
77
import * as os from 'os';
88
import { TPromise } from 'vs/base/common/winjs.base';
99
import * as uuid from 'vs/base/common/uuid';
10+
import { getMachineId } from 'vs/base/node/id';
1011

1112
export function resolveCommonProperties(commit: string, version: string): TPromise<{ [name: string]: string; }> {
1213
const result: { [name: string]: string; } = Object.create(null);
@@ -16,6 +17,7 @@ export function resolveCommonProperties(commit: string, version: string): TPromi
1617
result['version'] = version;
1718
result['common.osVersion'] = os.release();
1819
result['common.platform'] = Platform.Platform[Platform.platform];
20+
const promise = getMachineId().then(value => result['common.machineId'] = value);
1921

2022
// dynamic properties which value differs on each call
2123
let seq = 0;
@@ -35,5 +37,5 @@ export function resolveCommonProperties(commit: string, version: string): TPromi
3537
}
3638
});
3739

38-
return TPromise.as(result);
40+
return promise.then(() => result);
3941
}

0 commit comments

Comments
 (0)