提交 13efa582 编写于 作者: B Benjamin Pasero

telemetry - fix layer breakers

上级 10ca2732
......@@ -125,6 +125,7 @@
*/
process: {
get platform() { return process.platform; },
get arch() { return process.arch; },
get env() { return process.env; },
get versions() { return process.versions; },
get type() { return 'renderer'; },
......
......@@ -14,6 +14,12 @@ export interface ISandboxNodeProcess extends INodeProcess {
*/
readonly platform: 'win32' | 'linux' | 'darwin';
/**
* The process.arch property returns a string identifying the CPU architecture
* on which the Node.js process is running.
*/
readonly arch: string;
/**
* The type will always be Electron renderer.
*/
......
......@@ -214,7 +214,7 @@ class SharedProcessMain extends Disposable {
telemetryService = new TelemetryService({
appender: telemetryAppender,
commonProperties: resolveCommonProperties(fileService, release(), product.commit, product.version, this.configuration.machineId, product.msftInternalDomains, installSourcePath),
commonProperties: resolveCommonProperties(fileService, release(), process.arch, product.commit, product.version, this.configuration.machineId, product.msftInternalDomains, installSourcePath),
sendErrorTelemetry: true,
piiPaths: [appRoot, extensionsPath]
}, configurationService);
......
......@@ -537,7 +537,7 @@ export class CodeApplication extends Disposable {
if (!this.environmentService.isExtensionDevelopment && !this.environmentService.args['disable-telemetry'] && !!product.enableTelemetry) {
const channel = getDelayedChannel(sharedProcessReady.then(client => client.getChannel('telemetryAppender')));
const appender = new TelemetryAppenderClient(channel);
const commonProperties = resolveCommonProperties(this.fileService, release(), product.commit, product.version, machineId, product.msftInternalDomains, this.environmentService.installSourcePath);
const commonProperties = resolveCommonProperties(this.fileService, release(), process.arch, product.commit, product.version, machineId, product.msftInternalDomains, this.environmentService.installSourcePath);
const piiPaths = [this.environmentService.appRoot, this.environmentService.extensionsPath];
const config: ITelemetryServiceConfig = { appender, commonProperties, piiPaths, sendErrorTelemetry: true };
......
......@@ -425,7 +425,7 @@ export async function main(argv: NativeParsedArgs): Promise<void> {
const config: ITelemetryServiceConfig = {
appender: combinedAppender(...appenders),
sendErrorTelemetry: false,
commonProperties: resolveCommonProperties(fileService, release(), product.commit, product.version, stateService.getItem('telemetry.machineId'), product.msftInternalDomains, installSourcePath),
commonProperties: resolveCommonProperties(fileService, release(), process.arch, product.commit, product.version, stateService.getItem('telemetry.machineId'), product.msftInternalDomains, installSourcePath),
piiPaths: [appRoot, extensionsPath]
};
......
......@@ -4,13 +4,15 @@
*--------------------------------------------------------------------------------------------*/
import { IFileService } from 'vs/platform/files/common/files';
import * as Platform from 'vs/base/common/platform';
import * as uuid from 'vs/base/common/uuid';
import { isLinuxSnap, PlatformToString, platform } from 'vs/base/common/platform';
import { platform as nodePlatform, env } from 'vs/base/common/process';
import { generateUuid } from 'vs/base/common/uuid';
import { URI } from 'vs/base/common/uri';
export async function resolveCommonProperties(
fileService: IFileService,
release: string,
arch: string,
commit: string | undefined,
version: string | undefined,
machineId: string | undefined,
......@@ -23,7 +25,7 @@ export async function resolveCommonProperties(
// __GDPR__COMMON__ "common.machineId" : { "endPoint": "MacAddressHash", "classification": "EndUserPseudonymizedInformation", "purpose": "FeatureInsight" }
result['common.machineId'] = machineId;
// __GDPR__COMMON__ "sessionID" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['sessionID'] = uuid.generateUuid() + Date.now();
result['sessionID'] = generateUuid() + Date.now();
// __GDPR__COMMON__ "commitHash" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
result['commitHash'] = commit;
// __GDPR__COMMON__ "version" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
......@@ -31,11 +33,11 @@ export async function resolveCommonProperties(
// __GDPR__COMMON__ "common.platformVersion" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.platformVersion'] = (release || '').replace(/^(\d+)(\.\d+)?(\.\d+)?(.*)/, '$1$2$3');
// __GDPR__COMMON__ "common.platform" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.platform'] = Platform.PlatformToString(Platform.platform);
result['common.platform'] = PlatformToString(platform);
// __GDPR__COMMON__ "common.nodePlatform" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
result['common.nodePlatform'] = process.platform;
result['common.nodePlatform'] = nodePlatform;
// __GDPR__COMMON__ "common.nodeArch" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
result['common.nodeArch'] = process.arch;
result['common.nodeArch'] = arch;
// __GDPR__COMMON__ "common.product" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
result['common.product'] = product || 'desktop';
......@@ -66,7 +68,7 @@ export async function resolveCommonProperties(
}
});
if (Platform.isLinuxSnap) {
if (isLinuxSnap) {
// __GDPR__COMMON__ "common.snap" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.snap'] = 'true';
}
......@@ -84,10 +86,11 @@ export async function resolveCommonProperties(
}
function verifyMicrosoftInternalDomain(domainList: readonly string[]): boolean {
if (!process || !process.env || !process.env['USERDNSDOMAIN']) {
const userDnsDomain = env['USERDNSDOMAIN'];
if (!userDnsDomain) {
return false;
}
const domain = process.env['USERDNSDOMAIN']!.toLowerCase();
const domain = userDnsDomain.toLowerCase();
return domainList.some(msftDomain => domain === msftDomain);
}
......@@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { process } from 'vs/base/parts/sandbox/electron-sandbox/globals';
import { ITelemetryService, ITelemetryInfo, ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
......@@ -39,7 +40,7 @@ export class TelemetryService extends Disposable implements ITelemetryService {
const channel = sharedProcessService.getChannel('telemetryAppender');
const config: ITelemetryServiceConfig = {
appender: new TelemetryAppenderClient(channel),
commonProperties: resolveWorkbenchCommonProperties(storageService, fileService, environmentService.os.release, productService.commit, productService.version, environmentService.machineId, productService.msftInternalDomains, environmentService.installSourcePath, environmentService.remoteAuthority),
commonProperties: resolveWorkbenchCommonProperties(storageService, fileService, environmentService.os.release, process.arch, productService.commit, productService.version, environmentService.machineId, productService.msftInternalDomains, environmentService.installSourcePath, environmentService.remoteAuthority),
piiPaths: [environmentService.appRoot, environmentService.extensionsPath],
sendErrorTelemetry: true
};
......
......@@ -14,6 +14,7 @@ export async function resolveWorkbenchCommonProperties(
storageService: IStorageService,
fileService: IFileService,
release: string,
arch: string,
commit: string | undefined,
version: string | undefined,
machineId: string,
......@@ -21,7 +22,7 @@ export async function resolveWorkbenchCommonProperties(
installSourcePath: string,
remoteAuthority?: string
): Promise<{ [name: string]: string | boolean | undefined }> {
const result = await resolveCommonProperties(fileService, release, commit, version, machineId, msftInternalDomains, installSourcePath, undefined);
const result = await resolveCommonProperties(fileService, release, arch, commit, version, machineId, msftInternalDomains, installSourcePath, undefined);
const instanceId = storageService.get(instanceStorageKey, StorageScope.GLOBAL)!;
const firstSessionDate = storageService.get(firstSessionDateStorageKey, StorageScope.GLOBAL)!;
const lastSessionDate = storageService.get(lastSessionDateStorageKey, StorageScope.GLOBAL)!;
......
......@@ -45,7 +45,7 @@ suite('Telemetry - common properties', function () {
test('default', async function () {
await mkdirp(parentDir);
fs.writeFileSync(installSource, 'my.install.source');
const props = await resolveWorkbenchCommonProperties(testStorageService, testFileService, os.release(), commit, version, 'someMachineId', undefined, installSource);
const props = await resolveWorkbenchCommonProperties(testStorageService, testFileService, os.release(), process.arch, commit, version, 'someMachineId', undefined, installSource);
assert.ok('commitHash' in props);
assert.ok('sessionID' in props);
assert.ok('timestamp' in props);
......@@ -66,7 +66,7 @@ suite('Telemetry - common properties', function () {
assert.ok('common.instanceId' in props, 'instanceId');
assert.ok('common.machineId' in props, 'machineId');
fs.unlinkSync(installSource);
const props_1 = await resolveWorkbenchCommonProperties(testStorageService, testFileService, os.release(), commit, version, 'someMachineId', undefined, installSource);
const props_1 = await resolveWorkbenchCommonProperties(testStorageService, testFileService, os.release(), process.arch, commit, version, 'someMachineId', undefined, installSource);
assert.ok(!('common.source' in props_1));
});
......@@ -74,14 +74,14 @@ suite('Telemetry - common properties', function () {
testStorageService.store('telemetry.lastSessionDate', new Date().toUTCString(), StorageScope.GLOBAL, StorageTarget.MACHINE);
const props = await resolveWorkbenchCommonProperties(testStorageService, testFileService, os.release(), commit, version, 'someMachineId', undefined, installSource);
const props = await resolveWorkbenchCommonProperties(testStorageService, testFileService, os.release(), process.arch, commit, version, 'someMachineId', undefined, installSource);
assert.ok('common.lastSessionDate' in props); // conditional, see below
assert.ok('common.isNewSession' in props);
assert.equal(props['common.isNewSession'], 0);
});
test('values chance on ask', async function () {
const props = await resolveWorkbenchCommonProperties(testStorageService, testFileService, os.release(), commit, version, 'someMachineId', undefined, installSource);
const props = await resolveWorkbenchCommonProperties(testStorageService, testFileService, os.release(), process.arch, commit, version, 'someMachineId', undefined, installSource);
let value1 = props['common.sequence'];
let value2 = props['common.sequence'];
assert.ok(value1 !== value2, 'seq');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册