Last active
August 29, 2015 14:10
-
-
Save jessicard/cb3792fd22a603c028df to your computer and use it in GitHub Desktop.
Content Scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In your extension's index.html you'll also need to include Bugsnag and disable auto-notification: | |
// <script src="bugsnag-2.min.js" data-apiKey="your-api-key" data-autoNotify="false"> | |
// You can then add try/catch blocks in your content scripts, and pass any errors back up to your extension: | |
// Inside your content script | |
try { | |
// Some code in your content scripts | |
} catch(e) { | |
var exceptionObj = {stack: e.stack, message: e.message, name: e.name}; | |
chrome.runtime.sendMessage("extension-id", {type: "error", exception: exceptionObj}); | |
} | |
// Then in your extension code you could listen for this message and notify Bugsnag: | |
// Inside your extension | |
chrome.runtime.onMessage.addListener(function (message) { | |
if(message.type == "error") { | |
Bugsnag.notifyException(message.exception); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment