Sentry in embedded script (Unified Browser JS SDK)

Hi everyone,

I have the exact same issue than this: Sentry in embedded script, but with the new Unified Browser Javascript SDK.

Basically, my app is meant to be embedded on any webpage by users, by simply pasting a script tag. The issue is that Sentry reports errors from the user’s code and external to my app. Is there a way to namespace Sentry so that it only reports events originating from my code?

Thanks a lot in advance,


Not really, you could always go with and use our SDK as a simple Client capturing only stuff you catch yourself with captureException and not use the global error handler.

But I am not really sure if that is what you want?!

Thank you for you answer! If there’s a way to make sure that all exceptions end up in that custom handler, that could be a solution.

So I would probably need to turn off the automated global handler, which I guess is doable?
Then in my (React) app, I have a ErrorBoundary at the top, so most likely, all errors will end up caught there?

Finally, is there any plans to bring a more standard way of doing this to Sentry? It seems from the similar question I linked that the legacy SDK let one namespace events and only catch events in your namespace, unless I read the answer wrong?

This really is not an easy task since we never can tell when a global error is triggered by your plugin or the parent app using it.

With the unified API we introduced a package called @sentry/minimal but it does the “opposite”. So let’s say you add @sentry/minimal you can use Sentry in your lib and only if the user uses Sentry in their parent app, they would also get your special Sentry capture calls.

So, currently there is no other way than disabling the globalHandler and handle the capture by yourself.

Alright, I’ll look into that, thanks again!

Hey all – is this still the latest guidance for wrapping embedded scripts/widgets/components with Sentry? Any pointers for how to get the most out of Sentry with embedded widgets?