We are trying to switch to sentry right now in our google chrome extension, but we hit the wall right now. We found out that there is probably no possibility to have details of errors in content scripts of extension because of cors. I tried probably everything, and have no idea is there exists any kind of hack or solution to reach good errors stack and message instead of “Script error.”?
@tranotheron – offhand, there are definitely Chrome extensions using Sentry in production.
If you can recreate the error you’re experiencing in a sample application you can share via GitHub, I’d be glad to look into it. But as-is there is not much to go on.
I personally know individual organizations are using it successfully in Chrome Extensions, but I haven’t personally experimented w/ it (yet). I’d just drop it into the extension and see what happens.
Basically, if you run into trouble, and can create a sample application demonstrating the error, I’d be glad to investigate and explore a fix ASAP.
I dug into this, and it sounds like it’s a bug with Chromium and content_scripts where Chrome doesn’t trigger the window.onerror event.
So, this means onerror – the global error event handler – can’t be relied on. So you’ll need to use try/catch … but there’s good news, which is that Raven.js automatically wraps async methods with try/catch for you. So you just need to do:
Raven.context(function () { // wraps in try/catch
startApp();
});
And you shouldn’t have to try/catch anything else. Any error in this execution context will be caught/reported. And in cases where you have async code (e.g. setTimeout or XHR callbacks), it’ll be auto-wrapped by Raven.js.
I use Sentry in my javascript. I use it by doing Sentry.init, but I don’t have the Sentry.context function. How can I use Sentry.context? (I don’t use Raven, i just added the Sentry javascript file to my Chrome extension)