CrashReport
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.
Instance properties
age-
The age of the report in milliseconds.
type-
The string
"crash"indicating that this is a crash report. url-
A string representing the URL of the document that generated the report.
user_agent-
The user agent string of the browser that generated the report.
body-
The body of the report. This is an object with the following properties:
crash_report_apiExperimental Optional-
An object containing the key-value pairs set via the
CrashReportContext.set()method, if any. is_top_levelExperimental-
A boolean indicating whether the crashed document was a top-level document (
true) or an embedded document (false). reasonExperimental Optional-
A string indicating the specific reason why the crash occurred, if known. Possible values are:
oom-
The page ran out of memory.
unresponsive-
The page was killed due to being unresponsive.
stackExperimental Optional-
A string representing the JavaScript call stack at the time of the crash. This is included if the
reasonisunresponsive, if theDocument-Policyvalue forinclude-js-call-stacks-in-crash-reportsin the document that crashed istrue, and if the call stack was able to be recovered from the crashed document. visibility_stateExperimental-
An enumerated value indicating whether the document is visible. This mirrors the value of the
Document.visibilityStateproperty. Possible values are:visible-
The document content is at least partially visible.
-
The document content is completely hidden.
Description
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.
- If a
crash-reportingserver endpoint is defined, crash reports are delivered there. For example:httpReporting-Endpoints: crash-reporting="https://example.com/reports" - If a
crash-reportingendpoint is not defined, but adefaultreporting server endpoint is defined, crash reports are delivered there. For example:httpReporting-Endpoints: default="https://example.com/reports" - If neither endpoint is defined, crash reports are not delivered.
Examples
>Sending a report to a reporting endpoint
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.