I'm working on a Chrome extension for the first time and trying to integrate Bugsnag js error reporting.
I found a lot of useful information, but I don't understand how to actually load bugsnag into the extension. (e.g. in the background script, content script, a background.html page or somewhere else). Do you write code to insert the script tag into the page?
Bugsnag setup docs suggest configuring
<script src="//d2wy8f7a9ursnm.cloudfront.net/bugsnag-2.min.js"
data-apikey="YOUR-API-KEY-HERE"></script>
I tried adding that to a background.html
page, but no luck. I also tried adding the cloudfront script to content and background scripts in the extension, but had trouble loading it.
Uncaught ReferenceError: Bugsnag is not defined
Similarly, where's the best place to put reference to the bugsnag script and modify the Bugsnag object (e.g.
Bugsnag.beforeNotify = function (error, metaData) {
error.stacktrace = error.stacktrace.replace(/chrome-extension:/g, "chromeextension:");
}
to permit extension errors to reach bugsnag, as suggested here.
Realize it's a pretty basic setup question but have had some trouble finding a direction for this specific use case. Thanks for any suggestion!