Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. ReportingObserver
  4. ReportingObserver()

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.

Syntax

js
new ReportingObserver(callback)new ReportingObserver(callback, options)

Parameters

callback

A callback function that runs when the observer starts to collect reports (i.e., viaReportingObserver.observe()). The callback function is given twoparameters:

reports

A sequence ofReport objects representingthe reports collected in the observer's report queue. This is probably the mostcommon way to retrieve the reports.

observer

A reference to the sameReportingObserverobject, allowing for recursive report collection, etc.

optionsOptional

An object allowing you to set the options for creating the object. The available options are:

types

An array of strings representing the types of report to becollected by this observer. Available types includedeprecation,intervention, andcrash (although this last type usuallyisn't retrievable via aReportingObserver). If this option is omitted, all supported types are collected.

buffered

a boolean that defines whether the reports that weregenerated before the observer was able to be created should be observable(true) or not (false).

Examples

js
const options = {  types: ["deprecation"],  buffered: true,};const observer = new ReportingObserver((reports, observer) => {  reportBtn.onclick = () => displayReports(reports);}, options);

Specifications

Specification
Reporting API
# dom-reportingobserver-reportingobserver

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp