The DeprecationReportBody interface of the Reporting API represents the body of a deprecation report.
A deprecation report is generated when a deprecated feature (for example a deprecated API method) is used on a document being observed by a ReportingObserver. In addition to the support of this API, receiving useful deprecation warnings relies on browser vendors adding these warnings for deprecated features.
Constructor
An instance of DeprecationReportBody is returned as the value of Report.body when Report.Type is deprecation. The interface has no constructor.
Instance properties
This interface also inherits properties from ReportBody.
A string representing the feature or API that is deprecated, for example NavigatorGetUserMedia. This can be used to group reports by deprecated feature.
A Date object (rendered as a string) representing the date when the feature is expected to be removed from the current browser. If the date is not known, this property will return null.
A string containing a human-readable description of the deprecation, including information such as what newer feature has superseded it, if any. This typically matches the message a browser will display in its DevTools console when a deprecated feature is used, if one is available.
We then tell it to start observing reports using ReportingObserver.observe(); this tells the observer to start collecting reports in its report queue, and runs the callback function specified inside the constructor:
js
observer.observe();
Because of the event handler we set up inside the ReportingObserver() constructor, we can now click the button to display the report details.
The report details are displayed via the displayReports() function, which takes the observer callback's reports parameter as its parameter:
The reports parameter contains an array of all the reports in the observer's report queue. We loop over each report using a basic for loop, then iterate over each entry of in the report's body (a DeprecationReportBody instance) using a for...in structure, displaying each key/value pair inside a list item.