-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
- Review the documentation: https://docs.sentry.io/
- Search for existing issues: https://github.com/getsentry/sentry-javascript/issues
- Use the latest release: https://github.com/getsentry/sentry-javascript/releases
- Provide a link to the affected event from your Sentry account: https://sentry.io/organizations/ada/issues/1612951359/?environment=development&project=1410309&query=is%3Aunresolved
Package + Version
-
@sentry/browser -
@sentry/node -
raven-js -
raven-node(raven for node) - other:
Version:
5.15.4
Description
As per the Advance Usage docs, I am trying to manage several instances of Sentry. I am developing a widget and would like to use Sentry without it conflicting with the host page.
Creating new instances BrowserClient and Hub classes seems to be a great way to do that, but I can't get it to work with my integrations. I found a similar issue #2329, however it was resolved by using hub.run(...). This does not work for me.
There was another thread #1764 as well, but the provided solution involves setting the new hub to the current global hub with getCurrentHub().bindClient(client);. This works, but it seems to defeat the point of what I'm trying to accomplish since I don't want to modify any globals that might interfere with the host page.
My code looks like this:
const { Hub, BrowserClient, defaultIntegrations } = Sentry;
const client = new BrowserClient({
dsn: process.env.SENTRY_DSN,
environment: process.env.NODE_ENV,
integrations: defaultIntegrations
});
const hub = new Hub(client);
// ...Later
hub.run((currentHub) => {
currentHub.captureException(error);
});