Skip to content

Commit

Permalink
classify common properties
Browse files Browse the repository at this point in the history
  • Loading branch information
kieferrm committed Sep 4, 2017
1 parent f425782 commit 7d5ece3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/vs/code/electron-browser/sharedProcessMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ function main(server: Server, initData: ISharedProcessInitData): void {
const config: ITelemetryServiceConfig = {
appender,
commonProperties: resolveCommonProperties(product.commit, pkg.version)
// __GDPR__COMMON__ "common.machineId" : { "endPoint": "none", "classification": "SystemMetaData", "purpose": "FeatureInsight" }
.then(result => Object.defineProperty(result, 'common.machineId', {
get: () => storageService.get(machineIdStorageKey),
enumerable: true
Expand Down
1 change: 1 addition & 0 deletions src/vs/code/electron-main/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ export class CodeApplication {
const channel = getDelayedChannel<ITelemetryAppenderChannel>(this.sharedProcessClient.then(c => c.getChannel('telemetryAppender')));
const appender = new TelemetryAppenderClient(channel);
const commonProperties = resolveCommonProperties(product.commit, pkg.version)
// __GDPR__COMMON__ "common.machineId" : { "endPoint": "none", "classification": "SystemMetaData", "purpose": "FeatureInsight" }
.then(result => Object.defineProperty(result, 'common.machineId', {
get: () => this.storageService.getItem(machineIdStorageKey),
enumerable: true
Expand Down
10 changes: 10 additions & 0 deletions src/vs/platform/telemetry/node/commonProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,36 @@ export const machineIdIpcChannel = 'vscode:machineId';
export function resolveCommonProperties(commit: string, version: string): TPromise<{ [name: string]: string; }> {
const result: { [name: string]: string; } = Object.create(null);

// __GDPR__COMMON__ "sessionID" : { "endPoint": "none", "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['sessionID'] = uuid.generateUuid() + Date.now();
// __GDPR__COMMON__ "commitHash" : { "endPoint": "none", "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['commitHash'] = commit;
// __GDPR__COMMON__ "version" : { "endPoint": "none", "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['version'] = version;
// __GDPR__COMMON__ "common.osVersion" : { "endPoint": "none", "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.osVersion'] = os.release();
// __GDPR__COMMON__ "common.platfrom" : { "endPoint": "none", "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.platform'] = Platform.Platform[Platform.platform];
// __GDPR__COMMON__ "common.nodePlatform" : { "endPoint": "none", "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.nodePlatform'] = process.platform;
// __GDPR__COMMON__ "common.nodeArch" : { "endPoint": "none", "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.nodeArch'] = process.arch;

// dynamic properties which value differs on each call
let seq = 0;
const startTime = Date.now();
Object.defineProperties(result, {
// __GDPR__COMMON__ "timestamp" : { "endPoint": "none", "classification": "SystemMetaData", "purpose": "FeatureInsight" }
'timestamp': {
get: () => new Date(),
enumerable: true
},
// __GDPR__COMMON__ "common.timesincesessionstart" : { "endPoint": "none", "classification": "SystemMetaData", "purpose": "FeatureInsight" }
'common.timesincesessionstart': {
get: () => Date.now() - startTime,
enumerable: true
},
// __GDPR__COMMON__ "common.sequence" : { "endPoint": "none", "classification": "SystemMetaData", "purpose": "FeatureInsight" }
'common.sequence': {
get: () => seq++,
enumerable: true
Expand Down
10 changes: 10 additions & 0 deletions src/vs/platform/telemetry/node/workbenchCommonProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,35 @@ const SQM_KEY: string = '\\Software\\Microsoft\\SQMClient';

export function resolveWorkbenchCommonProperties(storageService: IStorageService, commit: string, version: string): TPromise<{ [name: string]: string }> {
return resolveCommonProperties(commit, version).then(result => {
// __GDPR__COMMON__ "common.version.shell" : { "endPoint": "none", "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.version.shell'] = process.versions && (<any>process).versions['electron'];
// __GDPR__COMMON__ "common.version.renderer" : { "endPoint": "none", "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.version.renderer'] = process.versions && (<any>process).versions['chrome'];
// __GDPR__COMMON__ "common.osVersion" : { "endPoint": "none", "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.osVersion'] = os.release();

const lastSessionDate = storageService.get('telemetry.lastSessionDate');
const firstSessionDate = storageService.get('telemetry.firstSessionDate') || new Date().toUTCString();
storageService.store('telemetry.firstSessionDate', firstSessionDate);
storageService.store('telemetry.lastSessionDate', new Date().toUTCString());

// __GDPR__COMMON__ "common.firstSessionDate" : { "endPoint": "none", "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.firstSessionDate'] = firstSessionDate;
// __GDPR__COMMON__ "common.lastSessionDate" : { "endPoint": "none", "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.lastSessionDate'] = lastSessionDate;
// __GDPR__COMMON__ "common.isNewSession" : { "endPoint": "none", "classification": "SystemMetaData", "purpose": "FeatureInsight" }
result['common.isNewSession'] = !lastSessionDate ? '1' : '0';

const promises: TPromise<any>[] = [];
// __GDPR__COMMON__ "common.instanceId" : { "endPoint": "none", "classification": "EndUserPseudonymizedInformation", "purpose": "FeatureInsight" }
promises.push(getOrCreateInstanceId(storageService).then(value => result['common.instanceId'] = value));
// __GDPR__COMMON__ "common.machineId" : { "endPoint": "none", "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));
}

Expand Down

0 comments on commit 7d5ece3

Please sign in to comment.