Skip to content

Instantly share code, notes, and snippets.

@jpmedley
Forked from ebidel/reporting_observer.js
Created July 24, 2018 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpmedley/7546875bc6e8b2d79704c79c62919e67 to your computer and use it in GitHub Desktop.
Save jpmedley/7546875bc6e8b2d79704c79c62919e67 to your computer and use it in GitHub Desktop.
Using a ReportingObserver to watch for deprecation warnings on page.
/**
* @author ebidel@ (Eric Bidelman)
* License Apache-2.0
*/
// Drop this in the DevTools console:
(new ReportingObserver((reports, observer) => {
console.warn('This page is using deprecated APIs or features:');
const deprecations = reports.map(report => {
return {
url: report.url,
message: report.body.message,
lineNumber: report.body.lineNumber || '-',
colNumber: report.body.columnNumber || '-',
anticipatedRemoval: report.body.anticipatedRemoval ? (new Date(report.body.anticipatedRemoval)).toLocaleDateString() : '-',
};
});
console.table(deprecations);
}, {types: ['deprecation'], buffered: true})).observe();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment