Skip to content

Commit f618e50

Browse files
authored
feat: enable appcenter support (microsoft#92295)
* feat: update appcenter config (microsoft#92041) * fix: order of crash reporter initialization (microsoft#92044) * fix: create new guid for crash reporter (microsoft#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
1 parent a02ea6a commit f618e50

6 files changed

Lines changed: 39 additions & 19 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "code-oss-dev",
33
"version": "1.44.0",
4-
"distro": "25a85963f9a02a91afefd34ed1992872c800473a",
4+
"distro": "07db0bb3dc2da82ce33f2871e0093df1b9085d06",
55
"author": {
66
"name": "Microsoft Corporation"
77
},

src/vs/platform/electron/electron-main/electronMainService.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { dirExists } from 'vs/base/node/pfs';
2020
import { URI } from 'vs/base/common/uri';
2121
import { ITelemetryData, ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
2222
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
23+
import { ILogService } from 'vs/platform/log/common/log';
2324

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

@@ -34,7 +35,8 @@ export class ElectronMainService implements IElectronMainService {
3435
@IDialogMainService private readonly dialogMainService: IDialogMainService,
3536
@ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService,
3637
@IEnvironmentService private readonly environmentService: IEnvironmentService,
37-
@ITelemetryService private readonly telemetryService: ITelemetryService
38+
@ITelemetryService private readonly telemetryService: ITelemetryService,
39+
@ILogService private readonly logService: ILogService
3840
) {
3941
}
4042

@@ -392,6 +394,7 @@ export class ElectronMainService implements IElectronMainService {
392394

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

397400
//#endregion

src/vs/platform/product/common/productService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export interface IProductConfiguration {
8989
readonly checksums?: { [path: string]: string; };
9090
readonly checksumFailMoreInfoUrl?: string;
9191

92-
readonly hockeyApp?: {
92+
readonly appCenter?: {
9393
readonly 'win32-ia32': string;
9494
readonly 'win32-x64': string;
9595
readonly 'linux-x64': string;

src/vs/platform/storage/node/storageIpc.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Disposable, IDisposable, dispose } from 'vs/base/common/lifecycle';
1212
import { onUnexpectedError } from 'vs/base/common/errors';
1313
import { ILogService } from 'vs/platform/log/common/log';
1414
import { generateUuid } from 'vs/base/common/uuid';
15-
import { instanceStorageKey, firstSessionDateStorageKey, lastSessionDateStorageKey, currentSessionDateStorageKey } from 'vs/platform/telemetry/common/telemetry';
15+
import { instanceStorageKey, firstSessionDateStorageKey, lastSessionDateStorageKey, currentSessionDateStorageKey, crashReporterIdStorageKey } from 'vs/platform/telemetry/common/telemetry';
1616

1717
type Key = string;
1818
type Value = string;
@@ -54,6 +54,16 @@ export class GlobalStorageDatabaseChannel extends Disposable implements IServerC
5454
this.logService.error(error);
5555
}
5656

57+
// This is unique to the application instance and thereby
58+
// should be written from the main process once.
59+
//
60+
// THIS SHOULD NEVER BE SENT TO TELEMETRY.
61+
//
62+
const crashReporterId = this.storageMainService.get(crashReporterIdStorageKey, undefined);
63+
if (crashReporterId === undefined) {
64+
this.storageMainService.store(crashReporterIdStorageKey, generateUuid());
65+
}
66+
5767
// Apply global telemetry values as part of the initialization
5868
// These are global across all windows and thereby should be
5969
// written from the main process once.

src/vs/platform/telemetry/common/telemetry.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ export const instanceStorageKey = 'telemetry.instanceId';
4545
export const currentSessionDateStorageKey = 'telemetry.currentSessionDate';
4646
export const firstSessionDateStorageKey = 'telemetry.firstSessionDate';
4747
export const lastSessionDateStorageKey = 'telemetry.lastSessionDate';
48+
export const crashReporterIdStorageKey = 'crashReporter.guid';

src/vs/workbench/electron-browser/window.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
import * as nls from 'vs/nls';
77
import { URI } from 'vs/base/common/uri';
88
import * as errors from 'vs/base/common/errors';
9-
import { equals, deepClone, assign } from 'vs/base/common/objects';
9+
import { equals, deepClone } from 'vs/base/common/objects';
1010
import * as DOM from 'vs/base/browser/dom';
1111
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
1212
import { IAction } from 'vs/base/common/actions';
1313
import { IFileService } from 'vs/platform/files/common/files';
1414
import { toResource, IUntitledTextResourceEditorInput, SideBySideEditor, pathsToEditors } from 'vs/workbench/common/editor';
1515
import { IEditorService, IResourceEditorInputType } from 'vs/workbench/services/editor/common/editorService';
16-
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
16+
import { ITelemetryService, crashReporterIdStorageKey } from 'vs/platform/telemetry/common/telemetry';
1717
import { IWindowSettings, IOpenFileRequest, IWindowsConfiguration, IAddFoldersRequest, IRunActionInWindowRequest, IRunKeybindingInWindowRequest, getTitleBarStyle } from 'vs/platform/windows/common/windows';
1818
import { ITitleService } from 'vs/workbench/services/title/common/titleService';
1919
import { IWorkbenchThemeService, VS_HC_THEME } from 'vs/workbench/services/themes/common/workbenchThemeService';
@@ -46,7 +46,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
4646
import { MenubarControl } from '../browser/parts/titlebar/menubarControl';
4747
import { ILabelService } from 'vs/platform/label/common/label';
4848
import { IUpdateService } from 'vs/platform/update/common/update';
49-
import { IStorageService } from 'vs/platform/storage/common/storage';
49+
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
5050
import { IPreferencesService } from '../services/preferences/common/preferences';
5151
import { IMenubarService, IMenubarData, IMenubarMenu, IMenubarKeybinding, IMenubarMenuItemSubmenu, IMenubarMenuItemAction, MenubarMenuItem } from 'vs/platform/menubar/node/menubar';
5252
import { withNullAsUndefined, assertIsDefined } from 'vs/base/common/types';
@@ -104,7 +104,8 @@ export class NativeWindow extends Disposable {
104104
@ITunnelService private readonly tunnelService: ITunnelService,
105105
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService,
106106
@IWorkingCopyService private readonly workingCopyService: IWorkingCopyService,
107-
@IFilesConfigurationService private readonly filesConfigurationService: IFilesConfigurationService
107+
@IFilesConfigurationService private readonly filesConfigurationService: IFilesConfigurationService,
108+
@IStorageService private readonly storageService: IStorageService,
108109
) {
109110
super();
110111

@@ -426,8 +427,8 @@ export class NativeWindow extends Disposable {
426427
this.updateTouchbarMenu();
427428

428429
// Crash reporter (if enabled)
429-
if (!this.environmentService.disableCrashReporter && product.crashReporter && product.hockeyApp && this.configurationService.getValue('telemetry.enableCrashReporter')) {
430-
this.setupCrashReporter(product.crashReporter.companyName, product.crashReporter.productName, product.hockeyApp);
430+
if (!this.environmentService.disableCrashReporter && product.crashReporter && product.appCenter && this.configurationService.getValue('telemetry.enableCrashReporter')) {
431+
this.setupCrashReporter(product.crashReporter.companyName, product.crashReporter.productName, product.appCenter);
431432
}
432433
}
433434

@@ -540,31 +541,36 @@ export class NativeWindow extends Disposable {
540541
}
541542
}
542543

543-
private async setupCrashReporter(companyName: string, productName: string, hockeyAppConfig: typeof product.hockeyApp): Promise<void> {
544-
if (!hockeyAppConfig) {
544+
private async setupCrashReporter(companyName: string, productName: string, appCenterConfig: typeof product.appCenter): Promise<void> {
545+
if (!appCenterConfig) {
545546
return;
546547
}
547548

549+
const appCenterURL = isWindows ? appCenterConfig[process.arch === 'ia32' ? 'win32-ia32' : 'win32-x64']
550+
: isLinux ? appCenterConfig[`linux-x64`] : appCenterConfig.darwin;
551+
const info = await this.telemetryService.getTelemetryInfo();
552+
const crashReporterId = this.storageService.get(crashReporterIdStorageKey, StorageScope.GLOBAL)!;
553+
548554
// base options with product info
549555
const options: CrashReporterStartOptions = {
550556
companyName,
551557
productName,
552-
submitURL: isWindows ? hockeyAppConfig[process.arch === 'ia32' ? 'win32-ia32' : 'win32-x64'] : isLinux ? hockeyAppConfig[`linux-x64`] : hockeyAppConfig.darwin,
558+
submitURL: appCenterURL.concat('&uid=', crashReporterId, '&iid=', crashReporterId, '&sid=', info.sessionId),
553559
extra: {
554560
vscode_version: product.version,
555561
vscode_commit: product.commit || ''
556562
}
557563
};
558564

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

563572
// start crash reporter right here
564573
crashReporter.start(deepClone(options));
565-
566-
// start crash reporter in the main process
567-
return this.electronService.startCrashReporter(options);
568574
}
569575

570576
private onAddFoldersRequest(request: IAddFoldersRequest): void {

0 commit comments

Comments
 (0)