ReportBody

Note: This feature is available in Web Workers.

The ReportBody interface of the Reporting API represents the base class for the body of a report.

Note: ReportBody has been changed into an empty dictionary in the latest version of the specification. For historical reasons it remains the base class for most report objects, but in practice these can be considered as stand-alone objects, and this object is not relevant to website developers.

Instance methods

ReportBody.toJSON() Deprecated

A serializer which returns a JSON representation of the ReportBody object.

Description

This interface represents the base class for the body of a report. Individual report types inherit from it, adding specific attributes relevant to the particular report.

The following dictionaries/interfaces inherit from ReportBody:

Examples

In this example we create a new ReportingObserver to observe intervention reports. The InterventionReportBody interface inherits from ReportBody.

js
const options = {
  types: ["intervention"],
  buffered: true,
};

const observer = new ReportingObserver(([firstReport], observer) => {
  console.log(firstReport.type); // intervention
}, options);

Specifications

Specification
Reporting API
# reportbody

Browser compatibility