提交 0e65ec4d 编写于 作者: K kieferrm

fixes #36956

上级 c14729f0
......@@ -3,16 +3,13 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as winreg from 'winreg';
import * as os from 'os';
import { TPromise } from 'vs/base/common/winjs.base';
import * as errors from 'vs/base/common/errors';
import * as uuid from 'vs/base/common/uuid';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { getMachineId } from 'vs/base/node/id';
import { resolveCommonProperties, machineIdStorageKey } from '../node/commonProperties';
const SQM_KEY: string = '\\Software\\Microsoft\\SQMClient';
export function resolveWorkbenchCommonProperties(storageService: IStorageService, commit: string, version: string, source: string): TPromise<{ [name: string]: string }> {
return resolveCommonProperties(commit, version, source).then(result => {
......@@ -41,13 +38,6 @@ export function resolveWorkbenchCommonProperties(storageService: IStorageService
// __GDPR__COMMON__ "common.machineId" : { "classification": "EndUserPseudonymizedInformation", "purpose": "FeatureInsight" }
promises.push(getOrCreateMachineId(storageService).then(value => result['common.machineId'] = value));
if (process.platform === 'win32') {
// __GDPR__COMMON__ "common.sqm.userid" : { "endPoint": "SqmUserId", "classification": "EndUserPseudonymizedInformation", "purpose": "FeatureInsight" }
promises.push(getSqmUserId(storageService).then(value => result['common.sqm.userid'] = value));
// __GDPR__COMMON__ "common.sqm.machineid" : { "endPoint": "SqmMachineId", "classification": "EndUserPseudonymizedInformation", "purpose": "FeatureInsight" }
promises.push(getSqmMachineId(storageService).then(value => result['common.sqm.machineid'] = value));
}
return TPromise.join(promises).then(() => result);
});
}
......@@ -70,56 +60,3 @@ export function getOrCreateMachineId(storageService: IStorageService): TPromise<
return result;
});
}
function getSqmUserId(storageService: IStorageService): TPromise<string> {
const sqmUserId = storageService.get('telemetry.sqm.userId');
if (sqmUserId) {
return TPromise.as(sqmUserId);
}
return getWinRegKeyData(SQM_KEY, 'UserId', winreg.HKCU).then(result => {
if (result) {
storageService.store('telemetry.sqm.userId', result);
return result;
}
return undefined;
});
}
function getSqmMachineId(storageService: IStorageService): TPromise<string> {
let sqmMachineId = storageService.get('telemetry.sqm.machineId');
if (sqmMachineId) {
return TPromise.as(sqmMachineId);
}
return getWinRegKeyData(SQM_KEY, 'MachineId', winreg.HKLM).then(result => {
if (result) {
storageService.store('telemetry.sqm.machineId', result);
return result;
}
return undefined;
});
}
function getWinRegKeyData(key: string, name: string, hive: string): TPromise<string> {
return new TPromise<string>((resolve, reject) => {
if (process.platform === 'win32') {
try {
const reg = new winreg({ hive, key });
reg.get(name, (e, result) => {
if (e || !result) {
reject(null);
} else {
resolve(result.value);
}
});
} catch (err) {
errors.onUnexpectedError(err);
reject(err);
}
} else {
resolve(null);
}
}).then(undefined, err => {
// we only want success
return undefined;
});
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册