2015-08-27 15:11:51 +00:00
|
|
|
# crashReporter
|
2013-08-14 22:43:35 +00:00
|
|
|
|
2016-04-21 22:39:12 +00:00
|
|
|
> Submit crash reports to a remote server.
|
2015-08-25 12:01:57 +00:00
|
|
|
|
2016-11-03 17:26:00 +00:00
|
|
|
Process: [Main](../tutorial/quick-start.md#main-process), [Renderer](../tutorial/quick-start.md#renderer-process)
|
|
|
|
|
2015-08-25 12:16:20 +00:00
|
|
|
The following is an example of automatically submitting a crash report to a
|
|
|
|
remote server:
|
2013-08-14 22:43:35 +00:00
|
|
|
|
|
|
|
```javascript
|
2016-07-26 01:39:25 +00:00
|
|
|
const {crashReporter} = require('electron')
|
2015-08-28 17:50:30 +00:00
|
|
|
|
2013-11-14 05:39:44 +00:00
|
|
|
crashReporter.start({
|
|
|
|
productName: 'YourName',
|
|
|
|
companyName: 'YourCompany',
|
2015-11-13 08:03:40 +00:00
|
|
|
submitURL: 'https://your-domain.com/url-to-submit',
|
2013-11-14 05:39:44 +00:00
|
|
|
autoSubmit: true
|
2016-07-26 01:39:25 +00:00
|
|
|
})
|
2013-08-14 22:43:35 +00:00
|
|
|
```
|
|
|
|
|
2016-03-17 13:29:32 +00:00
|
|
|
For setting up a server to accept and process crash reports, you can use
|
|
|
|
following projects:
|
|
|
|
|
|
|
|
* [socorro](https://github.com/mozilla/socorro)
|
2016-05-06 17:09:24 +00:00
|
|
|
* [mini-breakpad-server](https://github.com/electron/mini-breakpad-server)
|
2016-03-17 13:29:32 +00:00
|
|
|
|
2016-10-05 21:10:45 +00:00
|
|
|
Crash reports are saved locally in an application-specific temp directory folder.
|
|
|
|
For a `productName` of `YourName`, crash reports will be stored in a folder
|
|
|
|
named `YourName Crashes` inside the temp directory. You can customize this temp
|
|
|
|
directory location for your app by calling the `app.setPath('temp', '/my/custom/temp')`
|
|
|
|
API before starting the crash reporter.
|
|
|
|
|
2015-08-25 12:01:57 +00:00
|
|
|
## Methods
|
|
|
|
|
2016-11-21 23:42:24 +00:00
|
|
|
The `crashReporter` module has the following methods:
|
2015-08-25 12:01:57 +00:00
|
|
|
|
|
|
|
### `crashReporter.start(options)`
|
2013-11-13 11:12:13 +00:00
|
|
|
|
2016-02-16 04:11:05 +00:00
|
|
|
* `options` Object
|
2016-10-30 10:46:20 +00:00
|
|
|
* `companyName` String (optional)
|
2016-02-16 04:11:05 +00:00
|
|
|
* `submitURL` String - URL that crash reports will be sent to as POST.
|
2016-09-08 18:52:21 +00:00
|
|
|
* `productName` String (optional) - Defaults to `app.getName()`.
|
2016-11-22 08:30:20 +00:00
|
|
|
* `uploadToServer` Boolean (optional) _macOS_ - Whether crash reports should be sent to the server
|
2016-02-16 04:11:05 +00:00
|
|
|
Default is `true`.
|
2016-10-30 10:46:20 +00:00
|
|
|
* `ignoreSystemCrashHandler` Boolean (optional) - Default is `false`.
|
|
|
|
* `extra` Object (optional) - An object you can define that will be sent along with the
|
2016-02-16 04:11:05 +00:00
|
|
|
report. Only string properties are sent correctly, Nested objects are not
|
|
|
|
supported.
|
2014-05-22 12:20:17 +00:00
|
|
|
|
2015-08-27 15:11:51 +00:00
|
|
|
You are required to call this method before using other `crashReporter`
|
2015-08-25 12:16:20 +00:00
|
|
|
APIs.
|
2015-06-05 11:05:55 +00:00
|
|
|
|
2016-06-18 13:26:26 +00:00
|
|
|
**Note:** On macOS, Electron uses a new `crashpad` client, which is different
|
2015-07-23 17:02:45 +00:00
|
|
|
from `breakpad` on Windows and Linux. To enable the crash collection feature,
|
2015-08-25 12:16:20 +00:00
|
|
|
you are required to call the `crashReporter.start` API to initialize `crashpad`
|
|
|
|
in the main process and in each renderer process from which you wish to collect
|
|
|
|
crash reports.
|
2015-05-30 02:03:59 +00:00
|
|
|
|
2015-08-25 12:01:57 +00:00
|
|
|
### `crashReporter.getLastCrashReport()`
|
2014-11-11 12:20:36 +00:00
|
|
|
|
2016-11-08 04:54:34 +00:00
|
|
|
Returns [`CrashReport`](structures/crash-report.md):
|
2016-09-24 23:59:30 +00:00
|
|
|
|
2015-07-23 17:02:45 +00:00
|
|
|
Returns the date and ID of the last crash report. If no crash reports have been
|
|
|
|
sent or the crash reporter has not been started, `null` is returned.
|
2014-11-11 12:20:36 +00:00
|
|
|
|
2015-08-25 12:01:57 +00:00
|
|
|
### `crashReporter.getUploadedReports()`
|
2015-06-05 11:05:55 +00:00
|
|
|
|
2016-11-08 04:54:34 +00:00
|
|
|
Returns [`CrashReport[]`](structures/crash-report.md):
|
2016-09-24 23:59:30 +00:00
|
|
|
|
2015-08-26 23:28:44 +00:00
|
|
|
Returns all uploaded crash reports. Each report contains the date and uploaded
|
|
|
|
ID.
|
2015-06-05 11:05:55 +00:00
|
|
|
|
2016-11-22 08:30:20 +00:00
|
|
|
### `crashReporter.getUploadToServer()` _macOS_
|
2016-11-08 00:12:46 +00:00
|
|
|
|
|
|
|
Returns `Boolean` - Whether reports should be submitted to the server. Set through
|
2016-11-22 08:30:20 +00:00
|
|
|
the `start` method or `setUploadToServer`.
|
2016-11-08 00:12:46 +00:00
|
|
|
|
2016-11-28 23:03:10 +00:00
|
|
|
**Note:** This API can only be used from the main process.
|
2016-11-08 00:39:11 +00:00
|
|
|
|
2016-11-22 08:30:20 +00:00
|
|
|
### `crashReporter.setUploadToServer(uploadToServer)` _macOS_
|
2016-11-08 00:03:57 +00:00
|
|
|
|
2016-11-22 08:30:20 +00:00
|
|
|
* `uploadToServer` Boolean _macOS_ - Whether reports should be submitted to the server
|
2016-11-08 00:03:57 +00:00
|
|
|
|
2016-11-28 23:03:10 +00:00
|
|
|
This would normally be controlled by user preferences. This has no effect if
|
|
|
|
called before `start` is called.
|
2016-11-08 00:03:57 +00:00
|
|
|
|
2016-11-28 23:03:10 +00:00
|
|
|
**Note:** This API can only be used from the main process.
|
2016-11-08 00:39:11 +00:00
|
|
|
|
2016-11-21 23:42:24 +00:00
|
|
|
## Crash Report Payload
|
2014-05-22 12:20:17 +00:00
|
|
|
|
2016-04-22 13:53:26 +00:00
|
|
|
The crash reporter will send the following data to the `submitURL` as
|
|
|
|
a `multipart/form-data` `POST`:
|
2014-05-22 12:20:17 +00:00
|
|
|
|
2015-08-25 12:18:02 +00:00
|
|
|
* `ver` String - The version of Electron.
|
|
|
|
* `platform` String - e.g. 'win32'.
|
|
|
|
* `process_type` String - e.g. 'renderer'.
|
2015-11-12 13:20:09 +00:00
|
|
|
* `guid` String - e.g. '5e1286fc-da97-479e-918b-6bfb0c3d1c72'
|
2015-08-25 12:18:02 +00:00
|
|
|
* `_version` String - The version in `package.json`.
|
2015-08-25 12:16:20 +00:00
|
|
|
* `_productName` String - The product name in the `crashReporter` `options`
|
2015-08-25 12:18:02 +00:00
|
|
|
object.
|
|
|
|
* `prod` String - Name of the underlying product. In this case Electron.
|
2015-08-25 12:16:20 +00:00
|
|
|
* `_companyName` String - The company name in the `crashReporter` `options`
|
2015-08-25 12:18:02 +00:00
|
|
|
object.
|
2016-03-17 13:29:32 +00:00
|
|
|
* `upload_file_minidump` File - The crash report in the format of `minidump`.
|
2016-10-10 14:31:05 +00:00
|
|
|
* All level one properties of the `extra` object in the `crashReporter`
|
|
|
|
`options` object.
|