Skip to content

Commit 9554aa4

Browse files
committed
run alternative machine id experiment, microsoft#16151
1 parent fb70b84 commit 9554aa4

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

src/vs/base/node/id.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,37 @@ import * as crypto from 'crypto';
88
import { TPromise } from 'vs/base/common/winjs.base';
99
import * as errors from 'vs/base/common/errors';
1010
import * as uuid from 'vs/base/common/uuid';
11+
import { networkInterfaces } from 'os';
12+
13+
14+
const mac = new class {
15+
16+
private _value: string;
17+
18+
get value(): string {
19+
if (this._value === void 0) {
20+
this._initValue();
21+
}
22+
return this._value;
23+
}
24+
25+
private _initValue(): void {
26+
this._value = null;
27+
const interfaces = networkInterfaces();
28+
for (let key in interfaces) {
29+
for (const i of interfaces[key]) {
30+
if (!i.internal) {
31+
this._value = crypto.createHash('sha256').update(i.mac, 'utf8').digest('hex');
32+
return;
33+
}
34+
}
35+
}
36+
}
37+
};
38+
39+
export function _futureMachineIdExperiment(): string {
40+
return mac.value;
41+
}
1142

1243
export function getMachineId(): TPromise<string> {
1344
return new TPromise<string>(resolve => {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
99
import * as errors from 'vs/base/common/errors';
1010
import * as uuid from 'vs/base/common/uuid';
1111
import { IStorageService } from 'vs/platform/storage/common/storage';
12-
import { getMachineId } from 'vs/base/node/id';
12+
import { getMachineId, _futureMachineIdExperiment } from 'vs/base/node/id';
1313
import { resolveCommonProperties } from '../node/commonProperties';
1414

1515
const SQM_KEY: string = '\\Software\\Microsoft\\SQMClient';
@@ -32,6 +32,7 @@ export function resolveWorkbenchCommonProperties(storageService: IStorageService
3232
const promises: TPromise<any>[] = [];
3333
promises.push(getOrCreateInstanceId(storageService).then(value => result['common.instanceId'] = value));
3434
promises.push(getOrCreateMachineId(storageService).then(value => result['common.machineId'] = value));
35+
result['common.machineIdExperiment'] = _futureMachineIdExperiment();
3536

3637
if (process.platform === 'win32') {
3738
promises.push(getSqmUserId(storageService).then(value => result['common.sqm.userid'] = value));

0 commit comments

Comments
 (0)