Skip to content

Commit

Permalink
fix: create new guid for crash reporter
Browse files Browse the repository at this point in the history
This id should never be sent to telemetry for
GDPR reasons, hence we don't reuse any of existing
persistent ids like instanceId etc.
  • Loading branch information
deepak1556 committed Mar 6, 2020
1 parent 1235855 commit e2f9746
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/vs/platform/electron/electron-main/electronMainService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ import { AddFirstParameterToFunctions } from 'vs/base/common/types';
import { IDialogMainService } from 'vs/platform/dialogs/electron-main/dialogs';
import { dirExists } from 'vs/base/node/pfs';
import { URI } from 'vs/base/common/uri';
import { ITelemetryData, ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { ITelemetryData, ITelemetryService, crashReporterIdStorageKey } from 'vs/platform/telemetry/common/telemetry';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IStorageMainService } from 'vs/platform/storage/node/storageMainService';
import { ILogService } from 'vs/platform/log/common/log';

export interface IElectronMainService extends AddFirstParameterToFunctions<IElectronService, Promise<any> /* only methods, not events */, number | undefined /* window ID */> { }
Expand All @@ -36,7 +37,8 @@ export class ElectronMainService implements IElectronMainService {
@ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService,
@IEnvironmentService private readonly environmentService: IEnvironmentService,
@ITelemetryService private readonly telemetryService: ITelemetryService,
@ILogService private readonly logService: ILogService
@ILogService private readonly logService: ILogService,
private storageMainService: IStorageMainService
) {
}

Expand Down Expand Up @@ -397,6 +399,10 @@ export class ElectronMainService implements IElectronMainService {
this.logService.trace('ElectronMainService#crashReporter', JSON.stringify(options));
}

async getCrashReporterId(): Promise<string> {
return this.storageMainService.get(crashReporterIdStorageKey)!;
}

//#endregion

private windowById(windowId: number | undefined): ICodeWindow | undefined {
Expand Down
1 change: 1 addition & 0 deletions src/vs/platform/electron/node/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export interface IElectronService {
openDevTools(options?: OpenDevToolsOptions): Promise<void>;
toggleDevTools(): Promise<void>;
startCrashReporter(options: CrashReporterStartOptions): Promise<void>;
getCrashReporterId(): Promise<string>;

// Connectivity
resolveProxy(url: string): Promise<string | undefined>;
Expand Down
12 changes: 11 additions & 1 deletion src/vs/platform/storage/node/storageIpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Disposable, IDisposable, dispose } from 'vs/base/common/lifecycle';
import { onUnexpectedError } from 'vs/base/common/errors';
import { ILogService } from 'vs/platform/log/common/log';
import { generateUuid } from 'vs/base/common/uuid';
import { instanceStorageKey, firstSessionDateStorageKey, lastSessionDateStorageKey, currentSessionDateStorageKey } from 'vs/platform/telemetry/common/telemetry';
import { instanceStorageKey, firstSessionDateStorageKey, lastSessionDateStorageKey, currentSessionDateStorageKey, crashReporterIdStorageKey } from 'vs/platform/telemetry/common/telemetry';

type Key = string;
type Value = string;
Expand Down Expand Up @@ -54,6 +54,16 @@ export class GlobalStorageDatabaseChannel extends Disposable implements IServerC
this.logService.error(error);
}

// This is unique to the application instance and thereby
// should be written from the main process once.
//
// THIS SHOULD NEVER BE SENT TO TELEMETRY.
//
const crashReporterId = this.storageMainService.get(crashReporterIdStorageKey, undefined);
if (crashReporterId === undefined) {
this.storageMainService.store(crashReporterIdStorageKey, generateUuid());
}

// Apply global telemetry values as part of the initialization
// These are global across all windows and thereby should be
// written from the main process once.
Expand Down
1 change: 1 addition & 0 deletions src/vs/platform/telemetry/common/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ export const instanceStorageKey = 'telemetry.instanceId';
export const currentSessionDateStorageKey = 'telemetry.currentSessionDate';
export const firstSessionDateStorageKey = 'telemetry.firstSessionDate';
export const lastSessionDateStorageKey = 'telemetry.lastSessionDate';
export const crashReporterIdStorageKey = 'crashReporter.guid';
3 changes: 2 additions & 1 deletion src/vs/workbench/electron-browser/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,12 +544,13 @@ export class ElectronWindow extends Disposable {
const appCenterURL = isWindows ? appCenterConfig[process.arch === 'ia32' ? 'win32-ia32' : 'win32-x64']
: isLinux ? appCenterConfig[`linux-x64`] : appCenterConfig.darwin;
const info = await this.telemetryService.getTelemetryInfo();
const crashReporterId = await this.electronService.getCrashReporterId();

// base options with product info
const options: CrashReporterStartOptions = {
companyName,
productName,
submitURL: appCenterURL.concat('&uid=', info.machineId, '&iid=', info.instanceId),
submitURL: appCenterURL.concat('&uid=', crashReporterId, '&iid=', crashReporterId, '&sid=', info.sessionId),
extra: {
vscode_version: product.version,
vscode_commit: product.commit || ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ export class TestElectronService implements IElectronService {
async openDevTools(options?: Electron.OpenDevToolsOptions | undefined): Promise<void> { }
async toggleDevTools(): Promise<void> { }
async startCrashReporter(options: Electron.CrashReporterStartOptions): Promise<void> { }
async getCrashReporterId(): Promise<string> { return ''; }
async resolveProxy(url: string): Promise<string | undefined> { return undefined; }
}

Expand Down

0 comments on commit e2f9746

Please sign in to comment.