The CrashReport dictionary of the Reporting API represents a crash report.
Note: It is not possible to retrieve crash reports using a ReportingObserver — the reports are only generated when the browser crashes, at which point the observer code isn't available to run.
ageThe age of the report in milliseconds.
typeThe string "crash" indicating that this is a crash report.
urlA string representing the URL of the document that generated the report.
user_agentThe user agent string of the browser that generated the report.
bodyThe body of the report. This is an object with the following properties:
crash_report_api OptionalAn object containing the key-value pairs set via the CrashReportContext.set() method, if any.
is_top_level A boolean indicating whether the crashed document was a top-level document (true) or an embedded document (false).
reason OptionalA string indicating the specific reason why the crash occurred, if known. Possible values are:
oomThe page ran out of memory.
unresponsiveThe page was killed due to being unresponsive.
stack OptionalA string representing the JavaScript call stack at the time of the crash. This is included if the reason is unresponsive, if the Document-Policy value for include-js-call-stacks-in-crash-reports in the document that crashed is true, and if the call stack was able to be recovered from the crashed document.
visibility_state An enumerated value indicating whether the document is visible. This mirrors the value of the Document.visibilityState property. Possible values are:
visibleThe document content is at least partially visible.
The document content is completely hidden.
Crash reports containing arbitrary information can be sent to a server endpoint using the Reporting API . This is useful because we can store detailed diagnostic information throughout the lifetime of an application and use the reports to debug crashes more effectively.
The diagnostic information is stored in a special key-value store that can be manipulated using the document's CrashReportContext object. This is accessed via the Window.crashReport property.
When the browser crashes, the information stored in the key-value store is added to a CrashReport and sent to a reporting server. The reporting server endpoint and its mapping to a particular URL are set using the Reporting-Endpoints header.
crash-reporting server endpoint is defined, crash reports are delivered there. For example:Reporting-Endpoints: crash-reporting="https://example.com/reports"crash-reporting endpoint is not defined, but a default reporting server endpoint is defined, crash reports are delivered there. For example:Reporting-Endpoints: default="https://example.com/reports"Configuring a web page to send a crash report requires that you define a reporting server endpoint using the Reporting-Endpoints header, for example https://example.com/reports, as described earlier.
A typical report structure is as follows:
{
"age": 27,
"type": "crash",
"url": "https://example.com/",
"user_agent": "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0",
"body": {
"sourceFile": "https://example.com/",
"reason": "unresponsive",
"stack": "SomeError: ... at ...",
"is_top_level": true,
"visibility_state": "visible",
"crash_report_api": {
"crash_data_1": "0001",
"crash_data_2": "0002"
}
}
}The report will be sent as a JSON object in a POST request to the endpoint whenever the browser crashes.