Header menu logo fable-electron-docs-api

crashReporter Type

⚠ Process Availability: Main ✔ | Renderer ✔ | Utility ❌ | Exported ✔

Submit crash reports to a remote server.Process: Main, Renderer> [!IMPORTANT] If you want to call this API from a renderer process with context isolation enabled, place the API call in your preload script and expose it using the contextBridge API.The following is an example of setting up Electron to automatically submit crash reports to a remote server:const { crashReporter } = require('electron')crashReporter.start({ submitURL: 'https://your-domain.com/url-to-submit' })For setting up a server to accept and process crash reports, you can use following projects:* socorro* mini-breakpad-server> [!NOTE] Electron uses Crashpad, not Breakpad, to collect and upload crashes, but for the time being, the upload protocol is the same.Or use a 3rd party hosted solution:* Backtrace* Sentry* BugSplat* BugsnagCrash reports are stored temporarily before being uploaded in a directory underneath the app's user data directory, called 'Crashpad'. You can override this directory by calling app.setPath('crashDumps', '/path/to/crashes') before starting the crash reporter.Electron uses crashpad to monitor and report crashes.

Static members

Static member Description

crashReporter.addExtraParameter (key, value)

Full Usage: crashReporter.addExtraParameter (key, value)

Parameters:
    key : string
    value : string

Modifiers: inline

Set an extra parameter to be sent with the crash report. The values specified here will be sent in addition to any values set via the extra option when start was called.Parameters added in this fashion (or via the extra parameter to crashReporter.start) are specific to the calling process. Adding extra parameters in the main process will not cause those parameters to be sent along with crashes from renderer or other child processes. Similarly, adding extra parameters in a renderer process will not result in those parameters being sent with crashes that occur in other renderer processes or in the main process.> [!NOTE] Parameters have limits on the length of the keys and values. Key names must be no longer than 39 bytes, and values must be no longer than 20320 bytes. Keys with names longer than the maximum will be silently ignored. Key values longer than the maximum length will be truncated.

key : string
value : string

crashReporter.getLastCrashReport ()

Full Usage: crashReporter.getLastCrashReport ()

Returns: Option<CrashReport>
Modifiers: inline

The date and ID of the 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 uploaded. In the case that there are no uploaded reports, null is returned.> [!NOTE] This method is only available in the main process.

Returns: Option<CrashReport>

crashReporter.getParameters ()

Full Usage: crashReporter.getParameters ()

Returns: Record<string, string>
Modifiers: inline

The current 'extra' parameters of the crash reporter.

Returns: Record<string, string>

crashReporter.getUploadToServer ()

Full Usage: crashReporter.getUploadToServer ()

Returns: bool
Modifiers: inline

Whether reports should be submitted to the server. Set through the start method or setUploadToServer.> [!NOTE] This method is only available in the main process.

Returns: bool

crashReporter.getUploadedReports ()

Full Usage: crashReporter.getUploadedReports ()

Returns: CrashReport[]
Modifiers: inline

Returns all uploaded crash reports. Each report contains the date and uploaded ID.> [!NOTE] This method is only available in the main process.

Returns: CrashReport[]

crashReporter.removeExtraParameter key

Full Usage: crashReporter.removeExtraParameter key

Parameters:
    key : string

Modifiers: inline

Remove an extra parameter from the current set of parameters. Future crashes will not include this parameter.

key : string

crashReporter.setUploadToServer uploadToServer

Full Usage: crashReporter.setUploadToServer uploadToServer

Parameters:
    uploadToServer : bool

Modifiers: inline

This would normally be controlled by user preferences. This has no effect if called before start is called.> [!NOTE] This method is only available in the main process.

uploadToServer : bool

crashReporter.start (?submitURL, ?productName, ?companyName, ?uploadToServer, ?ignoreSystemCrashHandler, ?rateLimit, ?compress, ?extra, ?globalExtra)

Full Usage: crashReporter.start (?submitURL, ?productName, ?companyName, ?uploadToServer, ?ignoreSystemCrashHandler, ?rateLimit, ?compress, ?extra, ?globalExtra)

Parameters:
    ?submitURL : string
    ?productName : string
    ?companyName : string
    ?uploadToServer : bool
    ?ignoreSystemCrashHandler : bool
    ?rateLimit : bool
    ?compress : bool
    ?extra : Record<string, string>
    ?globalExtra : Record<string, string>

Modifiers: inline

This method must be called before using any other crashReporter APIs. Once initialized this way, the crashpad handler collects crashes from all subsequently created processes. The crash reporter cannot be disabled once started.This method should be called as early as possible in app startup, preferably before app.on('ready'). If the crash reporter is not initialized at the time a renderer process is created, then that renderer process will not be monitored by the crash reporter.> [!NOTE] You can test out the crash reporter by generating a crash using process.crash().> [!NOTE] If you need to send additional/updated extra parameters after your first call start you can call addExtraParameter.> [!NOTE] Parameters passed in extra, globalExtra or set with addExtraParameter have limits on the length of the keys and values. Key names 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 longer than the maximum length will be truncated.> [!NOTE] This method is only available in the main process.

?submitURL : string
?productName : string
?companyName : string
?uploadToServer : bool
?ignoreSystemCrashHandler : bool
?rateLimit : bool
?compress : bool
?extra : Record<string, string>
?globalExtra : Record<string, string>

Type something to start searching.