Skip to content

Commit

Permalink
feat: enable appcenter support (#92295)
Browse files Browse the repository at this point in the history
* feat: update appcenter config (#92041)

* fix: order of crash reporter initialization (#92044)

* fix: create new guid for crash reporter (#92180)

This id should never be sent to telemetry for
GDPR reasons, hence we don't reuse any of existing
persistent ids like instanceId etc.

* chore: update distro
  • Loading branch information
deepak1556 authored Mar 9, 2020
1 parent a02ea6a commit f618e50
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "code-oss-dev",
"version": "1.44.0",
"distro": "25a85963f9a02a91afefd34ed1992872c800473a",
"distro": "07db0bb3dc2da82ce33f2871e0093df1b9085d06",
"author": {
"name": "Microsoft Corporation"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { dirExists } from 'vs/base/node/pfs';
import { URI } from 'vs/base/common/uri';
import { ITelemetryData, ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { ILogService } from 'vs/platform/log/common/log';

export interface IElectronMainService extends AddFirstParameterToFunctions<IElectronService, Promise<unknown> /* only methods, not events */, number | undefined /* window ID */> { }

Expand All @@ -34,7 +35,8 @@ export class ElectronMainService implements IElectronMainService {
@IDialogMainService private readonly dialogMainService: IDialogMainService,
@ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService,
@IEnvironmentService private readonly environmentService: IEnvironmentService,
@ITelemetryService private readonly telemetryService: ITelemetryService
@ITelemetryService private readonly telemetryService: ITelemetryService,
@ILogService private readonly logService: ILogService
) {
}

Expand Down Expand Up @@ -392,6 +394,7 @@ export class ElectronMainService implements IElectronMainService {

async startCrashReporter(windowId: number | undefined, options: CrashReporterStartOptions): Promise<void> {
crashReporter.start(options);
this.logService.trace('ElectronMainService#crashReporter', JSON.stringify(options));
}

//#endregion
Expand Down
2 changes: 1 addition & 1 deletion src/vs/platform/product/common/productService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export interface IProductConfiguration {
readonly checksums?: { [path: string]: string; };
readonly checksumFailMoreInfoUrl?: string;

readonly hockeyApp?: {
readonly appCenter?: {
readonly 'win32-ia32': string;
readonly 'win32-x64': string;
readonly 'linux-x64': string;
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';
36 changes: 21 additions & 15 deletions src/vs/workbench/electron-browser/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import * as nls from 'vs/nls';
import { URI } from 'vs/base/common/uri';
import * as errors from 'vs/base/common/errors';
import { equals, deepClone, assign } from 'vs/base/common/objects';
import { equals, deepClone } from 'vs/base/common/objects';
import * as DOM from 'vs/base/browser/dom';
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { IAction } from 'vs/base/common/actions';
import { IFileService } from 'vs/platform/files/common/files';
import { toResource, IUntitledTextResourceEditorInput, SideBySideEditor, pathsToEditors } from 'vs/workbench/common/editor';
import { IEditorService, IResourceEditorInputType } from 'vs/workbench/services/editor/common/editorService';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { ITelemetryService, crashReporterIdStorageKey } from 'vs/platform/telemetry/common/telemetry';
import { IWindowSettings, IOpenFileRequest, IWindowsConfiguration, IAddFoldersRequest, IRunActionInWindowRequest, IRunKeybindingInWindowRequest, getTitleBarStyle } from 'vs/platform/windows/common/windows';
import { ITitleService } from 'vs/workbench/services/title/common/titleService';
import { IWorkbenchThemeService, VS_HC_THEME } from 'vs/workbench/services/themes/common/workbenchThemeService';
Expand Down Expand Up @@ -46,7 +46,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { MenubarControl } from '../browser/parts/titlebar/menubarControl';
import { ILabelService } from 'vs/platform/label/common/label';
import { IUpdateService } from 'vs/platform/update/common/update';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { IPreferencesService } from '../services/preferences/common/preferences';
import { IMenubarService, IMenubarData, IMenubarMenu, IMenubarKeybinding, IMenubarMenuItemSubmenu, IMenubarMenuItemAction, MenubarMenuItem } from 'vs/platform/menubar/node/menubar';
import { withNullAsUndefined, assertIsDefined } from 'vs/base/common/types';
Expand Down Expand Up @@ -104,7 +104,8 @@ export class NativeWindow extends Disposable {
@ITunnelService private readonly tunnelService: ITunnelService,
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService,
@IWorkingCopyService private readonly workingCopyService: IWorkingCopyService,
@IFilesConfigurationService private readonly filesConfigurationService: IFilesConfigurationService
@IFilesConfigurationService private readonly filesConfigurationService: IFilesConfigurationService,
@IStorageService private readonly storageService: IStorageService,
) {
super();

Expand Down Expand Up @@ -426,8 +427,8 @@ export class NativeWindow extends Disposable {
this.updateTouchbarMenu();

// Crash reporter (if enabled)
if (!this.environmentService.disableCrashReporter && product.crashReporter && product.hockeyApp && this.configurationService.getValue('telemetry.enableCrashReporter')) {
this.setupCrashReporter(product.crashReporter.companyName, product.crashReporter.productName, product.hockeyApp);
if (!this.environmentService.disableCrashReporter && product.crashReporter && product.appCenter && this.configurationService.getValue('telemetry.enableCrashReporter')) {
this.setupCrashReporter(product.crashReporter.companyName, product.crashReporter.productName, product.appCenter);
}
}

Expand Down Expand Up @@ -540,31 +541,36 @@ export class NativeWindow extends Disposable {
}
}

private async setupCrashReporter(companyName: string, productName: string, hockeyAppConfig: typeof product.hockeyApp): Promise<void> {
if (!hockeyAppConfig) {
private async setupCrashReporter(companyName: string, productName: string, appCenterConfig: typeof product.appCenter): Promise<void> {
if (!appCenterConfig) {
return;
}

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 = this.storageService.get(crashReporterIdStorageKey, StorageScope.GLOBAL)!;

// base options with product info
const options: CrashReporterStartOptions = {
companyName,
productName,
submitURL: isWindows ? hockeyAppConfig[process.arch === 'ia32' ? 'win32-ia32' : 'win32-x64'] : isLinux ? hockeyAppConfig[`linux-x64`] : hockeyAppConfig.darwin,
submitURL: appCenterURL.concat('&uid=', crashReporterId, '&iid=', crashReporterId, '&sid=', info.sessionId),
extra: {
vscode_version: product.version,
vscode_commit: product.commit || ''
}
};

// mixin telemetry info
const info = await this.telemetryService.getTelemetryInfo();
assign(options.extra, { vscode_sessionId: info.sessionId });
// start crash reporter in the main process first.
// On windows crashpad excepts a name pipe for the client to connect,
// this pipe is created by crash reporter initialization from the main process,
// changing this order of initialization will cause issues.
// For more info: https://chromium.googlesource.com/crashpad/crashpad/+/HEAD/doc/overview_design.md#normal-registration
await this.electronService.startCrashReporter(options);

// start crash reporter right here
crashReporter.start(deepClone(options));

// start crash reporter in the main process
return this.electronService.startCrashReporter(options);
}

private onAddFoldersRequest(request: IAddFoldersRequest): void {
Expand Down

0 comments on commit f618e50

Please sign in to comment.