ReportingObserver: ReportingObserver() constructor
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Note: This feature is available inWeb Workers.
TheReportingObserver() constructor of theReporting API creates a newReportingObserver object instance, which can be used to collect andaccess reports.
In this article
Syntax
new ReportingObserver(callback)new ReportingObserver(callback, options)Parameters
callbackA callback function that runs when the observer starts to collect reports (i.e., via
ReportingObserver.observe()). The callback function is given twoparameters:optionsOptionalAn object allowing you to set the options for creating the object. The available options are:
typesAn array of strings representing the types of report to becollected by this observer. Available types include
deprecation,intervention, andcrash(although this last type usuallyisn't retrievable via aReportingObserver). If this option is omitted, all supported types are collected.buffereda boolean that defines whether the reports that weregenerated before the observer was able to be created should be observable(
true) or not (false).
Examples
const options = { types: ["deprecation"], buffered: true,};const observer = new ReportingObserver((reports, observer) => { reportBtn.onclick = () => displayReports(reports);}, options);Specifications
| Specification |
|---|
| Reporting API> # dom-reportingobserver-reportingobserver> |