bugsnag-js icon indicating copy to clipboard operation
bugsnag-js copied to clipboard

Support ReportingObserver reports

Open laukstein opened this issue 6 years ago • 3 comments

Here how Sentry plans ReportingObserver support https://github.com/getsentry/sentry/issues/9285, https://docs.sentry.io/platforms/javascript/#reportingobserver

laukstein avatar Jul 28 '19 07:07 laukstein

Hi @laukstein

Thanks for the suggestion.

We've added support for ReportingObserver to our backlog which would allow reporting on deprecated APIs from browser JS.

This won't be an immediate priority, but we'll provide updates here when we decide to schedule this.

mattdyoung avatar Jul 31 '19 15:07 mattdyoung

Any updates on this? cc: @xander-jones @johnkiely1

amhunt avatar Feb 26 '22 21:02 amhunt

👋 @amhunt afraid not, this isn't something we've had a big calling for and so other priorities have taken its place. However, you could add a call to Bugsnag.notify() in the ReportingObserver callback as follows to get these reports to Bugsnag:

const observer = new ReportingObserver((reports, observer) => {
  for (const report of reports) {
    Bugsnag.notify(new Error(report.body.message), function (event) {
      event.errors[0].errorClass = "ReportingObserver"
      event.addMetadata("report", {
        "type": report.type,
        "url": report.url,
        "body": report.body
      })
    })
  }
});

observer.observe();

image

Worth noting that in this case the reporter's pointing to Bugsnag as the source of the error as I've got network breadcrumbs enabled so Bugsnag's wrapping the fetch() API, turning this off mean the ReportingObserver would then point to jQuery as the fault as I used $.ajax() to run test the deprecation, but in this case if you captured the network breadcrumbs you'd see what was happening at the time this report was fired.

xljones avatar Feb 28 '22 13:02 xljones