question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Manually instantiated Hub with provided client instance, shouldn't require additional bindClient call to setup integrations

See original GitHub issue

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 https://github.com/getsentry/sentry-javascript/issues/2329, however it was resolved by using hub.run(...). This does not work for me.

There was another thread https://github.com/getsentry/sentry-javascript/issues/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);
});

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
NicHaleycommented, May 20, 2020

Thanks @mcaballeropinto and @kamilogorek. The above makes sense. I am using the Client directly, and leveraging setupIntegrations should give me most of what I need for the time being.

1reaction
kamilogorekcommented, May 20, 2020

Thanks for the feedback @mcaballeropinto. @NicHaley the comments above are correct. You need to manually bind the client to the new hub as well hub.bindClient(client). This looks like an oversight on our end, as it’s a very rarely used feature. I’ll rename this issue to more descriptive one and mark it as a bug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

sentry - Go Packages
CaptureEvent calls the method of a same name on currently bound Client instance passing it a top-level Scope. Returns EventID if successfully, or...
Read more >
Case API - ServiceNow Docs
The Case API provides endpoints that enable you to retrieve and update Customer Service Management (CSM) case records.
Read more >
Unified API - Sentry Developer Documentation
client : A client is an object that is configured once and can be bound to the hub. The user can then auto...
Read more >
Blog | GFunnel Business®
Complimentary Promotions take the form of funds, credits, or creative hours added to the Client's account to offset marketing costs under the Service ......
Read more >
Net8 Administrator's Guide, Release 8.0 - Oracle Help Center
required by Net8, and a review of the Oracle Net8 Assistant, a tool that is provided to automate client configuration using a graphical...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found