Bugsnag-js: Chrome extension

Created on 8 Dec 2014  Â·  5Comments  Â·  Source: bugsnag/bugsnag-js

Hello,

I'm using bugsnag-js for monitoring a chrome extension. Errors are sent, but never displayed in Bugsnag It seems that there is a problem because of 'chrome-extension" into stacks error.

Exemple :

    at generateStacktrace (chrome-extension://nkleeghhjabalfolcphldebmfabofbia/lib/bugsnag.js:489:13)
    at Object.self.notify (chrome-extension://nkleeghhjabalfolcphldebmfabofbia/lib/bugsnag.js:100:19)
    at _init (chrome-extension://nkleeghhjabalfolcphldebmfabofbia/js/content-script/smartbar.js:442:17)
    at Object.callback (chrome-extension://nkleeghhjabalfolcphldebmfabofbia/js/content-script/smartbar.js:322:13)
    at safeCallbackApply (extensions::sendRequest:21:15)
    at handleResponse (extensions::sendRequest:73:7)

As workaround, I do this in bugsnag.js :

function stacktraceFromException(exception) {
    return (exception.stack || exception.backtrace || exception.stacktrace).replace(/chrome-extension:/g, "chromeextension:");
  }

Most helpful comment

Hi @H2go!

A slightly less hacky solution might be to use the existing bugsnag.js, and add the following hook.

Bugsnag.beforeNotify = function (error, metaData) {
    error.stacktrace = error.stacktrace.replace(/chrome-extension:/g, "chromeextension:");
}

Unfortunately we ignore anything that looks like it might be a browser extension on the backend, otherwise people running websites get spurious errors from content scripts. This is unlikely to change soon, but we might be able to add a checkbox to configure it.

All 5 comments

Hi @H2go!

A slightly less hacky solution might be to use the existing bugsnag.js, and add the following hook.

Bugsnag.beforeNotify = function (error, metaData) {
    error.stacktrace = error.stacktrace.replace(/chrome-extension:/g, "chromeextension:");
}

Unfortunately we ignore anything that looks like it might be a browser extension on the backend, otherwise people running websites get spurious errors from content scripts. This is unlikely to change soon, but we might be able to add a checkbox to configure it.

Is this still the unofficially approved way to enable error reporting for a chrome extension?
I have tried removing 'chrome-extension' from the stacktrace, url, context, and projectRoot params, but I'm still not seeing any errors in my project dashboard. I've even forwarded the error notification via my server so I can override the referer header. Are there other params that would cause Bugsnag to ignore the notification?

+1 for chrome extension support =)

We added some docs in #129 that should help people get Chrome extension monitoring set up — if you bump into any other issues, let us know.

For those who end up here and are looking for the current docs, they're now here: https://docs.bugsnag.com/platforms/javascript/faq/#how-can-i-get-error-reports-from-browser-extensions

In case it moves again, here's a screenshot:

Screen Shot 2019-03-21 at 10 18 34

code:

bugsnag({
  beforeSend: function (report) {
    report.stacktrace = report.stacktrace.map(function (frame) {
      frame.file = frame.file.replace(/chrome-extension:/g, 'chrome_extension:')
      return frame
    })
  }
})
Was this page helpful?
0 / 5 - 0 ratings

Related issues

vikrantnegi picture vikrantnegi  Â·  5Comments

mattimatti picture mattimatti  Â·  4Comments

bathos picture bathos  Â·  6Comments

antoinerousseau picture antoinerousseau  Â·  4Comments

waynebloss picture waynebloss  Â·  3Comments