#How to only capture script src errors and not the script host page errors

5 messages · Page 1 of 1 (latest)

lime pawn
#

I am working on a plugin that will be loaded via script tag to the client site. I want to integrate this with Sentry so that it only alerts me about the plugin erros and not the host page errors. I have loaded the plugin to the Wix site and it keeps alerting me about the wix issues. I have tried filtering but checking the frame filename to match the plugin src from the script tag e.g. https://myplugin.solutions.com/ but it still send me wix errors.

beforeSend(event) { const pathFilter = PLUGIN_LOADER_URL; const exception = event?.exception; if (exception) { const values = exception?.values || []; for (const value of values) { const frames = value.stacktrace?.frames || []; for (const frame of frames) { // Check if the filename exists and includes the required path filter if (frame.filename && frame.filename.includes(pathFilter)) { return event; } } } } return null; },

#

How to only capture script src errors and not the script host page errors

solid sky
lime pawn
#

Thanks a lot. Would I be able to use the browser client when loading Sentry via loader? I don't want to bundle in the @sentry/browser code base. This is how I load the sentry const script = document.createElement("script"); const loaderSource = https://js.sentry-cdn.com/${this.dsn}.min.js`;
script.src = loaderSource;
script.setAttribute("crossorigin", "anonymous"); document.head.appendChild(script);`

solid sky
#

I don't think you will be able to do that with the loader script. The loader script loads Sentry globally. This by itself could prevent the client site to use Sentry if they wanted to. The last Sentry.init() that runs would get the errors.