From 502d4c19ce58801196dd230531dfbc7109289956 Mon Sep 17 00:00:00 2001 From: Jeremy Rose Date: Thu, 18 Mar 2021 14:15:19 -0700 Subject: [PATCH] feat: allow omitting submitURL when uploadToServer is false (#28105) --- docs/api/crash-reporter.md | 3 ++- lib/browser/api/crash-reporter.ts | 4 ++-- spec-main/api-crash-reporter-spec.ts | 8 +++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/api/crash-reporter.md b/docs/api/crash-reporter.md index c03f8a7e0398..8331bc8d43f5 100644 --- a/docs/api/crash-reporter.md +++ b/docs/api/crash-reporter.md @@ -77,7 +77,8 @@ The `crashReporter` module has the following methods: ### `crashReporter.start(options)` * `options` Object - * `submitURL` String - URL that crash reports will be sent to as POST. + * `submitURL` String (optional) - URL that crash reports will be sent to as + POST. Required unless `uploadToServer` is `false`. * `productName` String (optional) - Defaults to `app.name`. * `companyName` String (optional) _Deprecated_ - Deprecated alias for `{ globalExtra: { _companyName: ... } }`. diff --git a/lib/browser/api/crash-reporter.ts b/lib/browser/api/crash-reporter.ts index 99672c690d8b..16a9b1b5cb0f 100644 --- a/lib/browser/api/crash-reporter.ts +++ b/lib/browser/api/crash-reporter.ts @@ -10,13 +10,13 @@ class CrashReporter { extra = {}, globalExtra = {}, ignoreSystemCrashHandler = false, - submitURL, + submitURL = '', uploadToServer = true, rateLimit = false, compress = true } = options || {}; - if (submitURL == null) throw new Error('submitURL is a required option to crashReporter.start'); + if (uploadToServer && !submitURL) throw new Error('submitURL must be specified when uploadToServer is true'); if (!compress && uploadToServer) { deprecate.log('Sending uncompressed crash reports is deprecated and will be removed in a future version of Electron. Set { compress: true } to opt-in to the new behavior. Crash reports will be uploaded gzipped, which most crash reporting servers support.'); diff --git a/spec-main/api-crash-reporter-spec.ts b/spec-main/api-crash-reporter-spec.ts index 1136d9a522b6..739d5c09a8d9 100644 --- a/spec-main/api-crash-reporter-spec.ts +++ b/spec-main/api-crash-reporter-spec.ts @@ -361,7 +361,13 @@ ifdescribe(!isLinuxOnArm && !process.mas && !process.env.DISABLE_CRASH_REPORTER_ it('requires that the submitURL option be specified', () => { expect(() => { crashReporter.start({} as any); - }).to.throw('submitURL is a required option to crashReporter.start'); + }).to.throw('submitURL must be specified when uploadToServer is true'); + }); + + it('allows the submitURL option to be omitted when uploadToServer is false', () => { + expect(() => { + crashReporter.start({ uploadToServer: false } as any); + }).not.to.throw(); }); it('can be called twice', async () => {