How to use multiple DSNs in Sentry Browser JavaScript

Hello.

I use Sentry Browser JavaScript (v5.6.3) on my web page from cdn. (There are circumstances and npm cannot be used.)
And my page has an external advertisement embedded in it, and that advertisement also seems to use Sentry.

After running “Sentry.init ()” on my web page, the ad is loaded and the ad executes “Sentry.init ()”.
This seems to override the Sentry settings, and errors on my page are being sent to the DSN that the ad is using.

I want to send an error on my page to my DSN, and still send that advertising error to that DSN.

I know this is possible if I create a new Hub (“new Sentry.Hub (new Sentry.BrowserClient ())”) and bind it to window.onerror, but I do this with “Sentry.init ()” Is there no way?

Thanks.

The last Sentry.init() should win actually, so if you call yours after theirs it should work.
For the record, the embedded advertisement should do init :sweat:

1 Like

Sorry for the late reply.
Thanks for your answer.
I solved this problem by creating a new client and resetting it to the hub when an error occurs. (I understand it’s not a good solution …)