How to add Sentry to a chrome extension. Plain and simple.
sentry.js
sentry.js
sentry.js
to your manifest:
"background": {
"scripts": ["background.js", "sentry.js"],
},
"content_scripts": [
{
"js": ["content.js", "sentry.js"],
}
],
Adding Sentry to a background script or a content script looks the same:
window.addEventListener("load", function () {
Sentry.init({
dsn:
"YOUR_DSN_HERE",
tracesSampleRate: 1.0,
});
});
Note: The window.addEventListener
piece is critical here. The page needs to load the script for you to have access to the Sentry
variable.
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
})
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
Sentry.wrap(function () {
})
})