Instance properties
age-
The age of the report in milliseconds.
type-
The string
"crash"indicating that this is a deprecation 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:
reasonExperimental Optional-
A string indicating the specfic 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. is_top_levelExperimental-
A boolean indicating whether the crashed document was a top-level document (
true) or an embedded document (false). 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.
crash_report_apiExperimental Optional-
An object containing the key-value pairs set via the
CrashReportContext.set()method, if any.
Description
The Crash Reporting API extension to the Reporting API specifies a mechanism allowing arbitrary information to be recorded and made available in crash reports. This is useful because we can store detailed diagnostic information throughout the lifetime of an application and use the crash reports to debug crashes more effectively.
The information is stored in a special key-value store, manipulated using the document's CrashReportContext object, which 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 the default reporting server endpoint, if it is defined. The reporting server endpoint and its mapping to a particular URL are set using the Reporting-Endpoints header.
Note:
It is not possible to retrieve CrashReports using a ReportingObserver — the reports are only generated when the browser crashes, at which point the observer code isn't available to run.
Examples
>Sending a report to a reporting endpoint
Configuring a web page to send a crash report requires that you set a default reporting server endpoint using the Reporting-Endpoints header, for example https://example.com/default.
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.