ReportBody

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The ReportBody interface of the Reporting API represents the body of a report. Individual report types inherit from this interface, adding specific attributes relevant to the particular report.

Reports that inherit from ReportBody

An instance of ReportBody is returned as the value of Report.body. The interface has no constructor.

Methods

ReportBody.toJSON() Experimental

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

Examples

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

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

BCD tables only load in the browser