diag - introduce crash-reporter-directory to enable crash reporter for local folder
This commit is contained in:
parent
dbb786567f
commit
3fab5de0b1
19
src/main.js
19
src/main.js
|
@ -32,6 +32,22 @@ const args = parseCLIArgs();
|
||||||
const userDataPath = getUserDataPath(args);
|
const userDataPath = getUserDataPath(args);
|
||||||
app.setPath('userData', userDataPath);
|
app.setPath('userData', userDataPath);
|
||||||
|
|
||||||
|
// Set temp directory based on crash-reporter-directory CLI argument
|
||||||
|
// The crash reporter will store crashes in temp folder so we need
|
||||||
|
// to change that location accordingly.
|
||||||
|
const crashReporterDirectory = args['crash-reporter-directory'];
|
||||||
|
if (crashReporterDirectory) {
|
||||||
|
if (!fs.existsSync(crashReporterDirectory)) {
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(crashReporterDirectory);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`The path '${crashReporterDirectory}' specified for --crash-reporter-directory does not seem to exist or cannot be created.`);
|
||||||
|
app.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
app.setPath('temp', crashReporterDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
// Set logs path before app 'ready' event if running portable
|
// Set logs path before app 'ready' event if running portable
|
||||||
// to ensure that no 'logs' folder is created on disk at a
|
// to ensure that no 'logs' folder is created on disk at a
|
||||||
// location outside of the portable directory
|
// location outside of the portable directory
|
||||||
|
@ -329,7 +345,8 @@ function parseCLIArgs() {
|
||||||
'user-data-dir',
|
'user-data-dir',
|
||||||
'locale',
|
'locale',
|
||||||
'js-flags',
|
'js-flags',
|
||||||
'max-memory'
|
'max-memory',
|
||||||
|
'crash-reporter-directory'
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,7 @@ export interface ParsedArgs {
|
||||||
'install-source'?: string;
|
'install-source'?: string;
|
||||||
'disable-updates'?: boolean;
|
'disable-updates'?: boolean;
|
||||||
'disable-crash-reporter'?: boolean;
|
'disable-crash-reporter'?: boolean;
|
||||||
|
'crash-reporter-directory'?: string;
|
||||||
'skip-add-to-recently-opened'?: boolean;
|
'skip-add-to-recently-opened'?: boolean;
|
||||||
'max-memory'?: string;
|
'max-memory'?: string;
|
||||||
'file-write'?: boolean;
|
'file-write'?: boolean;
|
||||||
|
@ -177,6 +178,7 @@ export const OPTIONS: OptionDescriptions<Required<ParsedArgs>> = {
|
||||||
'disable-telemetry': { type: 'boolean' },
|
'disable-telemetry': { type: 'boolean' },
|
||||||
'disable-updates': { type: 'boolean' },
|
'disable-updates': { type: 'boolean' },
|
||||||
'disable-crash-reporter': { type: 'boolean' },
|
'disable-crash-reporter': { type: 'boolean' },
|
||||||
|
'crash-reporter-directory': { type: 'string' },
|
||||||
'disable-user-env-probe': { type: 'boolean' },
|
'disable-user-env-probe': { type: 'boolean' },
|
||||||
'skip-add-to-recently-opened': { type: 'boolean' },
|
'skip-add-to-recently-opened': { type: 'boolean' },
|
||||||
'unity-launch': { type: 'boolean' },
|
'unity-launch': { type: 'boolean' },
|
||||||
|
|
|
@ -253,6 +253,7 @@ export class EnvironmentService implements INativeEnvironmentService {
|
||||||
|
|
||||||
get disableUpdates(): boolean { return !!this._args['disable-updates']; }
|
get disableUpdates(): boolean { return !!this._args['disable-updates']; }
|
||||||
get disableCrashReporter(): boolean { return !!this._args['disable-crash-reporter']; }
|
get disableCrashReporter(): boolean { return !!this._args['disable-crash-reporter']; }
|
||||||
|
get crashReporterDirectory(): string | undefined { return this._args['crash-reporter-directory']; }
|
||||||
|
|
||||||
get driverHandle(): string | undefined { return this._args['driver']; }
|
get driverHandle(): string | undefined { return this._args['driver']; }
|
||||||
get driverVerbose(): boolean { return !!this._args['driver-verbose']; }
|
get driverVerbose(): boolean { return !!this._args['driver-verbose']; }
|
||||||
|
|
|
@ -426,8 +426,20 @@ export class NativeWindow extends Disposable {
|
||||||
this.updateTouchbarMenu();
|
this.updateTouchbarMenu();
|
||||||
|
|
||||||
// Crash reporter (if enabled)
|
// Crash reporter (if enabled)
|
||||||
if (!this.environmentService.disableCrashReporter && product.crashReporter && product.appCenter && this.configurationService.getValue('telemetry.enableCrashReporter')) {
|
if (!this.environmentService.disableCrashReporter && this.configurationService.getValue('telemetry.enableCrashReporter')) {
|
||||||
this.setupCrashReporter(product.crashReporter.companyName, product.crashReporter.productName, product.appCenter);
|
const companyName = product.crashReporter?.companyName || 'Microsoft';
|
||||||
|
const productName = product.crashReporter?.productName || product.nameShort;
|
||||||
|
|
||||||
|
// With appCenter enabled, crashes will be uploaded
|
||||||
|
if (product.appCenter) {
|
||||||
|
this.setupCrashReporter(companyName, productName, product.appCenter, undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
// With a provided crash reporter directory, crashes
|
||||||
|
// will be stored only locally in that folder
|
||||||
|
else if (this.environmentService.crashReporterDirectory) {
|
||||||
|
this.setupCrashReporter(companyName, productName, undefined, this.environmentService.crashReporterDirectory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,13 +552,14 @@ export class NativeWindow extends Disposable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async setupCrashReporter(companyName: string, productName: string, appCenterConfig: typeof product.appCenter): Promise<void> {
|
private async setupCrashReporter(companyName: string, productName: string, appCenter: typeof product.appCenter, crashesDirectory: undefined): Promise<void>;
|
||||||
if (!appCenterConfig) {
|
private async setupCrashReporter(companyName: string, productName: string, appCenter: undefined, crashesDirectory: string): Promise<void>;
|
||||||
return;
|
private async setupCrashReporter(companyName: string, productName: string, appCenter: typeof product.appCenter | undefined, crashesDirectory: string | undefined): Promise<void> {
|
||||||
|
let submitURL: string | undefined = undefined;
|
||||||
|
if (appCenter) {
|
||||||
|
submitURL = isWindows ? appCenter[process.arch === 'ia32' ? 'win32-ia32' : 'win32-x64'] : isLinux ? appCenter[`linux-x64`] : appCenter.darwin;
|
||||||
}
|
}
|
||||||
|
|
||||||
const appCenterURL = isWindows ? appCenterConfig[process.arch === 'ia32' ? 'win32-ia32' : 'win32-x64']
|
|
||||||
: isLinux ? appCenterConfig[`linux-x64`] : appCenterConfig.darwin;
|
|
||||||
const info = await this.telemetryService.getTelemetryInfo();
|
const info = await this.telemetryService.getTelemetryInfo();
|
||||||
const crashReporterId = this.storageService.get(crashReporterIdStorageKey, StorageScope.GLOBAL)!;
|
const crashReporterId = this.storageService.get(crashReporterIdStorageKey, StorageScope.GLOBAL)!;
|
||||||
|
|
||||||
|
@ -554,11 +567,14 @@ export class NativeWindow extends Disposable {
|
||||||
const options: CrashReporterStartOptions = {
|
const options: CrashReporterStartOptions = {
|
||||||
companyName,
|
companyName,
|
||||||
productName,
|
productName,
|
||||||
submitURL: appCenterURL.concat('&uid=', crashReporterId, '&iid=', crashReporterId, '&sid=', info.sessionId),
|
submitURL: (submitURL?.concat('&uid=', crashReporterId, '&iid=', crashReporterId, '&sid=', info.sessionId)) || '',
|
||||||
extra: {
|
extra: {
|
||||||
vscode_version: product.version,
|
vscode_version: product.version,
|
||||||
vscode_commit: product.commit || ''
|
vscode_commit: product.commit || ''
|
||||||
}
|
},
|
||||||
|
|
||||||
|
// If `crashesDirectory` is specified, we do not upload
|
||||||
|
uploadToServer: !crashesDirectory,
|
||||||
};
|
};
|
||||||
|
|
||||||
// start crash reporter in the main process first.
|
// start crash reporter in the main process first.
|
||||||
|
|
|
@ -18,6 +18,7 @@ export interface INativeWorkbenchEnvironmentService extends IWorkbenchEnvironmen
|
||||||
readonly configuration: INativeEnvironmentConfiguration;
|
readonly configuration: INativeEnvironmentConfiguration;
|
||||||
|
|
||||||
readonly disableCrashReporter: boolean;
|
readonly disableCrashReporter: boolean;
|
||||||
|
readonly crashReporterDirectory?: string;
|
||||||
|
|
||||||
readonly cliPath: string;
|
readonly cliPath: string;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue