chore: remove deprecated crashReporter APIs (#26695)

This commit is contained in:
Milan Burda 2020-11-26 20:07:40 +01:00 committed by GitHub
parent d0cf16263e
commit 022bafc485
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 21 additions and 85 deletions

View file

@ -128,7 +128,7 @@ must be at most 39 bytes long, and values must be no longer than 127 bytes.
Keys with names longer than the maximum will be silently ignored. Key values Keys with names longer than the maximum will be silently ignored. Key values
longer than the maximum length will be truncated. longer than the maximum length will be truncated.
**Note:** Calling this method from the renderer process is deprecated. **Note:** This method is only available in the main process.
### `crashReporter.getLastCrashReport()` ### `crashReporter.getLastCrashReport()`
@ -137,7 +137,7 @@ last crash report. Only crash reports that have been uploaded will be returned;
even if a crash report is present on disk it will not be returned until it is even if a crash report is present on disk it will not be returned until it is
uploaded. In the case that there are no uploaded reports, `null` is returned. uploaded. In the case that there are no uploaded reports, `null` is returned.
**Note:** Calling this method from the renderer process is deprecated. **Note:** This method is only available in the main process.
### `crashReporter.getUploadedReports()` ### `crashReporter.getUploadedReports()`
@ -146,14 +146,14 @@ Returns [`CrashReport[]`](structures/crash-report.md):
Returns all uploaded crash reports. Each report contains the date and uploaded Returns all uploaded crash reports. Each report contains the date and uploaded
ID. ID.
**Note:** Calling this method from the renderer process is deprecated. **Note:** This method is only available in the main process.
### `crashReporter.getUploadToServer()` ### `crashReporter.getUploadToServer()`
Returns `Boolean` - Whether reports should be submitted to the server. Set through Returns `Boolean` - Whether reports should be submitted to the server. Set through
the `start` method or `setUploadToServer`. the `start` method or `setUploadToServer`.
**Note:** Calling this method from the renderer process is deprecated. **Note:** This method is only available in the main process.
### `crashReporter.setUploadToServer(uploadToServer)` ### `crashReporter.setUploadToServer(uploadToServer)`
@ -162,13 +162,7 @@ the `start` method or `setUploadToServer`.
This would normally be controlled by user preferences. This has no effect if This would normally be controlled by user preferences. This has no effect if
called before `start` is called. called before `start` is called.
**Note:** Calling this method from the renderer process is deprecated. **Note:** This method is only available in the main process.
### `crashReporter.getCrashesDirectory()` _Deprecated_
Returns `String` - The directory where crashes are temporarily stored before being uploaded.
**Note:** This method is deprecated, use `app.getPath('crashDumps')` instead.
### `crashReporter.addExtraParameter(key, value)` ### `crashReporter.addExtraParameter(key, value)`

View file

@ -43,6 +43,18 @@ We [recommend having contextIsolation enabled](https://github.com/electron/elect
For more details see: https://github.com/electron/electron/issues/23506 For more details see: https://github.com/electron/electron/issues/23506
### Removed: `crashReporter.getCrashesDirectory()`
The `crashReporter.getCrashesDirectory` method has been removed. Usage
should be replaced by `app.getPath('crashDumps')`.
```js
// Removed in Electron 12
crashReporter.getCrashesDirectory()
// Replace with
app.getPath('crashDumps')
```
### Removed: `crashReporter` methods in the renderer process ### Removed: `crashReporter` methods in the renderer process
The following `crashReporter` methods are no longer available in the renderer The following `crashReporter` methods are no longer available in the renderer

View file

@ -51,10 +51,6 @@ class CrashReporter {
return binding.getUploadedReports(); return binding.getUploadedReports();
} }
getCrashesDirectory () {
return app.getPath('crashDumps');
}
getUploadToServer () { getUploadToServer () {
if (process.type === 'browser') { if (process.type === 'browser') {
return binding.getUploadToServer(); return binding.getUploadToServer();

View file

@ -1,6 +1,6 @@
import { app } from 'electron/main'; import { app } from 'electron/main';
import type { WebContents } from 'electron/main'; import type { WebContents } from 'electron/main';
import { clipboard, crashReporter, nativeImage } from 'electron/common'; import { clipboard, nativeImage } from 'electron/common';
import * as fs from 'fs'; import * as fs from 'fs';
import { ipcMainInternal } from '@electron/internal/browser/ipc-main-internal'; import { ipcMainInternal } from '@electron/internal/browser/ipc-main-internal';
import * as ipcMainUtils from '@electron/internal/browser/ipc-main-internal-utils'; import * as ipcMainUtils from '@electron/internal/browser/ipc-main-internal-utils';
@ -104,26 +104,6 @@ ipcMainInternal.on(IPC_MESSAGES.BROWSER_PRELOAD_ERROR, function (event, preloadP
event.sender.emit('preload-error', event, preloadPath, error); event.sender.emit('preload-error', event, preloadPath, error);
}); });
ipcMainUtils.handleSync(IPC_MESSAGES.CRASH_REPORTER_GET_LAST_CRASH_REPORT, () => {
return crashReporter.getLastCrashReport();
});
ipcMainUtils.handleSync(IPC_MESSAGES.CRASH_REPORTER_GET_UPLOADED_REPORTS, () => {
return crashReporter.getUploadedReports();
});
ipcMainUtils.handleSync(IPC_MESSAGES.CRASH_REPORTER_GET_UPLOAD_TO_SERVER, () => {
return crashReporter.getUploadToServer();
});
ipcMainUtils.handleSync(IPC_MESSAGES.CRASH_REPORTER_SET_UPLOAD_TO_SERVER, (event, uploadToServer: boolean) => {
return crashReporter.setUploadToServer(uploadToServer);
});
ipcMainUtils.handleSync(IPC_MESSAGES.CRASH_REPORTER_GET_CRASHES_DIRECTORY, () => {
return crashReporter.getCrashesDirectory();
});
ipcMainInternal.handle(IPC_MESSAGES.NATIVE_IMAGE_CREATE_THUMBNAIL_FROM_PATH, async (_, path: string, size: Electron.Size) => { ipcMainInternal.handle(IPC_MESSAGES.NATIVE_IMAGE_CREATE_THUMBNAIL_FROM_PATH, async (_, path: string, size: Electron.Size) => {
return typeUtils.serialize(await nativeImage.createThumbnailFromPath(path, size)); return typeUtils.serialize(await nativeImage.createThumbnailFromPath(path, size));
}); });

View file

@ -5,12 +5,6 @@ export const enum IPC_MESSAGES {
BROWSER_SANDBOX_LOAD = 'BROWSER_SANDBOX_LOAD', BROWSER_SANDBOX_LOAD = 'BROWSER_SANDBOX_LOAD',
BROWSER_WINDOW_CLOSE = 'BROWSER_WINDOW_CLOSE', BROWSER_WINDOW_CLOSE = 'BROWSER_WINDOW_CLOSE',
CRASH_REPORTER_GET_LAST_CRASH_REPORT = 'CRASH_REPORTER_GET_LAST_CRASH_REPORT',
CRASH_REPORTER_GET_UPLOADED_REPORTS = 'CRASH_REPORTER_GET_UPLOADED_REPORTS',
CRASH_REPORTER_GET_UPLOAD_TO_SERVER = 'CRASH_REPORTER_GET_UPLOAD_TO_SERVER',
CRASH_REPORTER_SET_UPLOAD_TO_SERVER = 'CRASH_REPORTER_SET_UPLOAD_TO_SERVER',
CRASH_REPORTER_GET_CRASHES_DIRECTORY = 'CRASH_REPORTER_GET_CRASHES_DIRECTORY',
GUEST_INSTANCE_VISIBILITY_CHANGE = 'GUEST_INSTANCE_VISIBILITY_CHANGE', GUEST_INSTANCE_VISIBILITY_CHANGE = 'GUEST_INSTANCE_VISIBILITY_CHANGE',
GUEST_VIEW_INTERNAL_DESTROY_GUEST = 'GUEST_VIEW_INTERNAL_DESTROY_GUEST', GUEST_VIEW_INTERNAL_DESTROY_GUEST = 'GUEST_VIEW_INTERNAL_DESTROY_GUEST',

View file

@ -1,42 +1,6 @@
import { invokeSync } from '../ipc-renderer-internal-utils';
import { deprecate } from 'electron';
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
const binding = process._linkedBinding('electron_renderer_crash_reporter'); const binding = process._linkedBinding('electron_renderer_crash_reporter');
export default { export default {
start (options: Electron.CrashReporterStartOptions) {
deprecate.log('crashReporter.start is deprecated in the renderer process. Call it from the main process instead.');
for (const [k, v] of Object.entries(options.extra || {})) {
binding.addExtraParameter(k, String(v));
}
},
getLastCrashReport (): Electron.CrashReport | null {
deprecate.log('crashReporter.getLastCrashReport is deprecated in the renderer process. Call it from the main process instead.');
return invokeSync(IPC_MESSAGES.CRASH_REPORTER_GET_LAST_CRASH_REPORT);
},
getUploadedReports () {
deprecate.log('crashReporter.getUploadedReports is deprecated in the renderer process. Call it from the main process instead.');
return invokeSync(IPC_MESSAGES.CRASH_REPORTER_GET_UPLOADED_REPORTS);
},
getUploadToServer () {
deprecate.log('crashReporter.getUploadToServer is deprecated in the renderer process. Call it from the main process instead.');
return invokeSync(IPC_MESSAGES.CRASH_REPORTER_GET_UPLOAD_TO_SERVER);
},
setUploadToServer (uploadToServer: boolean) {
deprecate.log('crashReporter.setUploadToServer is deprecated in the renderer process. Call it from the main process instead.');
return invokeSync(IPC_MESSAGES.CRASH_REPORTER_SET_UPLOAD_TO_SERVER, uploadToServer);
},
getCrashesDirectory () {
deprecate.log('crashReporter.getCrashesDirectory is deprecated in the renderer process. Call it from the main process instead.');
return invokeSync(IPC_MESSAGES.CRASH_REPORTER_GET_CRASHES_DIRECTORY);
},
addExtraParameter (key: string, value: string) { addExtraParameter (key: string, value: string) {
binding.addExtraParameter(key, value); binding.addExtraParameter(key, value);
}, },

View file

@ -523,10 +523,6 @@ ifdescribe(!isLinuxOnArm && !process.mas && !process.env.DISABLE_CRASH_REPORTER_
expect(app.getPath('crashDumps')).to.include(app.getPath('userData')); expect(app.getPath('crashDumps')).to.include(app.getPath('userData'));
}); });
it('matches getCrashesDirectory', async () => {
expect(app.getPath('crashDumps')).to.equal(require('electron').crashReporter.getCrashesDirectory());
});
function crash (processType: string, remotely: Function) { function crash (processType: string, remotely: Function) {
if (processType === 'main') { if (processType === 'main') {
return remotely(() => { return remotely(() => {
@ -565,9 +561,9 @@ ifdescribe(!isLinuxOnArm && !process.mas && !process.env.DISABLE_CRASH_REPORTER_
it('stores crashes in the crash dump directory when uploadToServer: false', async () => { it('stores crashes in the crash dump directory when uploadToServer: false', async () => {
const { remotely } = await startRemoteControlApp(); const { remotely } = await startRemoteControlApp();
const crashesDir = await remotely(() => { const crashesDir = await remotely(() => {
const { crashReporter } = require('electron'); const { crashReporter, app } = require('electron');
crashReporter.start({ submitURL: 'http://127.0.0.1', uploadToServer: false, ignoreSystemCrashHandler: true }); crashReporter.start({ submitURL: 'http://127.0.0.1', uploadToServer: false, ignoreSystemCrashHandler: true });
return crashReporter.getCrashesDirectory(); return app.getPath('crashDumps');
}); });
let reportsDir = crashesDir; let reportsDir = crashesDir;
if (process.platform === 'darwin') { if (process.platform === 'darwin') {
@ -599,7 +595,7 @@ ifdescribe(!isLinuxOnArm && !process.mas && !process.env.DISABLE_CRASH_REPORTER_
const { crashReporter, app } = require('electron'); const { crashReporter, app } = require('electron');
app.setPath('crashDumps', crashesDir); app.setPath('crashDumps', crashesDir);
crashReporter.start({ submitURL: 'http://127.0.0.1', uploadToServer: false, ignoreSystemCrashHandler: true }); crashReporter.start({ submitURL: 'http://127.0.0.1', uploadToServer: false, ignoreSystemCrashHandler: true });
return crashReporter.getCrashesDirectory(); return app.getPath('crashDumps');
}, crashesDir); }, crashesDir);
expect(remoteCrashesDir).to.equal(crashesDir); expect(remoteCrashesDir).to.equal(crashesDir);