提交 21b0b982 编写于 作者: B Benjamin Pasero

debt - get rid of crash reporter service

上级 176b65a4
......@@ -676,7 +676,6 @@
"./vs/workbench/services/configurationResolver/common/configurationResolverSchema.ts",
"./vs/workbench/services/configurationResolver/common/configurationResolverUtils.ts",
"./vs/workbench/services/contextview/electron-browser/contextmenuService.ts",
"./vs/workbench/services/crashReporter/electron-browser/crashReporterService.ts",
"./vs/workbench/services/decorations/browser/decorations.ts",
"./vs/workbench/services/decorations/browser/decorationsService.ts",
"./vs/workbench/services/decorations/test/browser/decorationsService.test.ts",
......
......@@ -624,3 +624,18 @@ configurationRegistry.registerConfiguration({
}
});
// Configuration: Telemetry
configurationRegistry.registerConfiguration({
'id': 'telemetry',
'order': 110,
title: nls.localize('telemetryConfigurationTitle', "Telemetry"),
'type': 'object',
'properties': {
'telemetry.enableCrashReporter': {
'type': 'boolean',
'description': nls.localize('telemetry.enableCrashReporting', "Enable crash reports to be sent to a Microsoft online service. \nThis option requires restart to take effect."),
'default': true,
'tags': ['usesOnlineServices']
}
}
});
\ No newline at end of file
......@@ -53,7 +53,6 @@ import { IExtensionService } from 'vs/workbench/services/extensions/common/exten
import { WorkbenchModeServiceImpl } from 'vs/workbench/services/mode/common/workbenchModeService';
import { IModeService } from 'vs/editor/common/services/modeService';
import { IUntitledEditorService, UntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
import { ICrashReporterService, NullCrashReporterService, CrashReporterService } from 'vs/workbench/services/crashReporter/electron-browser/crashReporterService';
import { getDelayedChannel, IPCClient } from 'vs/base/parts/ipc/node/ipc';
import { connect as connectNet } from 'vs/base/parts/ipc/node/ipc.net';
import { ExtensionManagementChannelClient } from 'vs/platform/extensionManagement/node/extensionManagementIpc';
......@@ -319,12 +318,6 @@ export class Shell extends Disposable {
serviceCollection.set(ITelemetryService, this.telemetryService);
this._register(configurationTelemetry(this.telemetryService, this.configurationService));
let crashReporterService = NullCrashReporterService;
if (!this.environmentService.disableCrashReporter && product.crashReporter && product.hockeyApp) {
crashReporterService = instantiationService.createInstance(CrashReporterService);
}
serviceCollection.set(ICrashReporterService, crashReporterService);
serviceCollection.set(IDialogService, instantiationService.createInstance(DialogService));
const lifecycleService = instantiationService.createInstance(LifecycleService);
......
......@@ -6,7 +6,7 @@
import * as nls from 'vs/nls';
import { URI } from 'vs/base/common/uri';
import * as errors from 'vs/base/common/errors';
import * as objects from 'vs/base/common/objects';
import { equals, deepClone, assign } from 'vs/base/common/objects';
import * as DOM from 'vs/base/browser/dom';
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { IAction, Action } from 'vs/base/common/actions';
......@@ -24,7 +24,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
import { IResourceInput } from 'vs/platform/editor/common/editor';
import { KeyboardMapperFactory } from 'vs/workbench/services/keybinding/electron-browser/keybindingService';
import { Themable } from 'vs/workbench/common/theme';
import { ipcRenderer as ipc, webFrame } from 'electron';
import { ipcRenderer as ipc, webFrame, crashReporter } from 'electron';
import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing';
import { IMenuService, MenuId, IMenu, MenuItemAction, ICommandAction } from 'vs/platform/actions/common/actions';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
......@@ -34,11 +34,13 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { LifecyclePhase, ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { IWorkspaceFolderCreationData } from 'vs/platform/workspaces/common/workspaces';
import { IIntegrityService } from 'vs/platform/integrity/common/integrity';
import { AccessibilitySupport, isRootUser, isWindows, isMacintosh } from 'vs/base/common/platform';
import { AccessibilitySupport, isRootUser, isWindows, isMacintosh, isLinux } from 'vs/base/common/platform';
import product from 'vs/platform/node/product';
import pkg from 'vs/platform/node/package';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { EditorServiceImpl } from 'vs/workbench/browser/parts/editor/editor';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
const TextInputActions: IAction[] = [
new Action('undo', nls.localize('undo', "Undo"), undefined, true, () => Promise.resolve(document.execCommand('undo'))),
......@@ -79,7 +81,8 @@ export class ElectronWindow extends Themable {
@IFileService private readonly fileService: IFileService,
@IMenuService private readonly menuService: IMenuService,
@ILifecycleService private readonly lifecycleService: ILifecycleService,
@IIntegrityService private readonly integrityService: IIntegrityService
@IIntegrityService private readonly integrityService: IIntegrityService,
@IEnvironmentService private readonly environmentService: IEnvironmentService
) {
super(themeService);
......@@ -297,6 +300,11 @@ export class ElectronWindow extends Themable {
// Touchbar menu (if enabled)
this.updateTouchbarMenu();
// Crash reporter (if enabled)
if (!this.environmentService.disableCrashReporter && product.crashReporter && product.hockeyApp && this.configurationService.getValue('telemetry.enableCrashReporter')) {
this.setupCrashReporter();
}
}
private updateTouchbarMenu(): void {
......@@ -354,12 +362,40 @@ export class ElectronWindow extends Themable {
}
// Only update if the actions have changed
if (!objects.equals(this.lastInstalledTouchedBar, items)) {
if (!equals(this.lastInstalledTouchedBar, items)) {
this.lastInstalledTouchedBar = items;
this.windowService.updateTouchBar(items);
}
}
private setupCrashReporter(): void {
// base options with product info
const options = {
companyName: product.crashReporter.companyName,
productName: product.crashReporter.productName,
submitURL: isWindows ? product.hockeyApp[`win32-${process.arch}`] : isLinux ? product.hockeyApp[`linux-${process.arch}`] : product.hockeyApp.darwin,
extra: {
vscode_version: pkg.version,
vscode_commit: product.commit
}
};
// mixin telemetry info
this.telemetryService.getTelemetryInfo()
.then(info => {
assign(options.extra, {
vscode_sessionId: info.sessionId
});
// start crash reporter right here
crashReporter.start(deepClone(options));
// start crash reporter in the main process
return this.windowsService.startCrashReporter(options);
});
}
private onAddFoldersRequest(request: IAddFoldersRequest): void {
// Buffer all pending requests
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vs/nls';
import { assign, deepClone } from 'vs/base/common/objects';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { crashReporter } from 'electron';
import product from 'vs/platform/node/product';
import pkg from 'vs/platform/node/package';
import * as os from 'os';
import { isWindows, isMacintosh, isLinux } from 'vs/base/common/platform';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IConfigurationRegistry, Extensions } from 'vs/platform/configuration/common/configurationRegistry';
import { Registry } from 'vs/platform/registry/common/platform';
export const ICrashReporterService = createDecorator<ICrashReporterService>('crashReporterService');
export const TELEMETRY_SECTION_ID = 'telemetry';
export interface ICrashReporterConfig {
enableCrashReporter: boolean;
}
const configurationRegistry = Registry.as<IConfigurationRegistry>(Extensions.Configuration);
configurationRegistry.registerConfiguration({
'id': TELEMETRY_SECTION_ID,
'order': 110,
title: nls.localize('telemetryConfigurationTitle', "Telemetry"),
'type': 'object',
'properties': {
'telemetry.enableCrashReporter': {
'type': 'boolean',
'description': nls.localize('telemetry.enableCrashReporting', "Enable crash reports to be sent to a Microsoft online service. \nThis option requires restart to take effect."),
'default': true,
'tags': ['usesOnlineServices']
}
}
});
export interface ICrashReporterService {
_serviceBrand: any;
getChildProcessStartOptions(processName: string): Electron.CrashReporterStartOptions | undefined; // TODO
}
export const NullCrashReporterService: ICrashReporterService = {
_serviceBrand: undefined,
getChildProcessStartOptions(processName: string) { return undefined; }
};
export class CrashReporterService implements ICrashReporterService {
_serviceBrand: any;
private options: Electron.CrashReporterStartOptions;
private isEnabled: boolean;
constructor(
@ITelemetryService private readonly telemetryService: ITelemetryService,
@IWindowsService private readonly windowsService: IWindowsService,
@IConfigurationService configurationService: IConfigurationService
) {
const config = configurationService.getValue<ICrashReporterConfig>(TELEMETRY_SECTION_ID);
this.isEnabled = !!config.enableCrashReporter;
if (this.isEnabled) {
this.startCrashReporter();
}
}
private startCrashReporter(): void {
// base options with product info
this.options = {
companyName: product.crashReporter.companyName,
productName: product.crashReporter.productName,
submitURL: this.getSubmitURL(),
extra: {
vscode_version: pkg.version,
vscode_commit: product.commit
}
};
// mixin telemetry info
this.telemetryService.getTelemetryInfo()
.then(info => {
assign(this.options.extra, {
vscode_sessionId: info.sessionId
});
// start crash reporter right here
crashReporter.start(deepClone(this.options));
// start crash reporter in the main process
return this.windowsService.startCrashReporter(this.options);
});
}
private getSubmitURL(): string {
if (isWindows) {
return product.hockeyApp[`win32-${process.arch}`];
} else if (isMacintosh) {
return product.hockeyApp.darwin;
} else if (isLinux) {
return product.hockeyApp[`linux-${process.arch}`];
}
throw new Error('Unknown platform');
}
getChildProcessStartOptions(name: string): Electron.CrashReporterStartOptions | undefined {
// Experimental crash reporting support for child processes on Mac only for now
if (this.isEnabled && isMacintosh) {
const childProcessOptions = deepClone(this.options);
(<any>childProcessOptions.extra).processName = name;
childProcessOptions.crashesDirectory = os.tmpdir();
return childProcessOptions;
}
return undefined;
}
}
......@@ -34,7 +34,6 @@ import { IWindowService, IWindowsService } from 'vs/platform/windows/common/wind
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { IInitData } from 'vs/workbench/api/node/extHost.protocol';
import { MessageType, createMessageOfType, isMessageOfType } from 'vs/workbench/services/extensions/common/extensionHostProtocol';
import { ICrashReporterService } from 'vs/workbench/services/crashReporter/electron-browser/crashReporterService';
import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
export interface IExtensionHostStarter {
......@@ -101,7 +100,6 @@ export class ExtensionHostProcessWorker implements IExtensionHostStarter {
@ILifecycleService private readonly _lifecycleService: ILifecycleService,
@IEnvironmentService private readonly _environmentService: IEnvironmentService,
@ITelemetryService private readonly _telemetryService: ITelemetryService,
@ICrashReporterService private readonly _crashReporterService: ICrashReporterService,
@ILogService private readonly _logService: ILogService,
@ILabelService private readonly _labelService: ILabelService
) {
......@@ -196,7 +194,7 @@ export class ExtensionHostProcessWorker implements IExtensionHostStarter {
}
}
const crashReporterOptions = this._crashReporterService.getChildProcessStartOptions('extensionHost');
const crashReporterOptions = undefined; // TODO@electron pass this in as options to the extension host after verifying this actually works
if (crashReporterOptions) {
opts.env.CRASH_REPORTER_START_OPTIONS = JSON.stringify(crashReporterOptions);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册