Skip to content

FR: use multiple browser client AND utilize useragent integartion #2919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
4 of 9 tasks
daisy1754 opened this issue Sep 17, 2020 · 3 comments
Closed
4 of 9 tasks

FR: use multiple browser client AND utilize useragent integartion #2919

daisy1754 opened this issue Sep 17, 2020 · 3 comments

Comments

@daisy1754
Copy link

Package + Version

  • @sentry/browser
  • @sentry/node
  • raven-js
  • raven-node (raven for node)
  • other:

Version:

5.21.4

Description

We want to embed sentry in the JS library. Our client may already using sentry on their site so our library initialize its own browser client like below:

client = new Sentry.BrowserClient({
        dsn: sentryReportingURL,
        release: version,
        environment: process.env.NODE_ENV,
        integrations: Sentry.defaultIntegrations,
    });

// later
client.captureException(e);

We noticed userAgent is missing in sentry and found closed issue #1764 and https://github.com/getsentry/sentry-javascript/blob/master/packages/browser/src/integrations/useragent.ts#L24

Looks like userAgent integration depends on so we cannot send userAgent without using currenthub. We don't want to override currentHub because we are library and not override any of client's state.

Can UserAgent integration and other default integration not depend on currentHub?

@kamilogorek
Copy link
Contributor

Hi @daisy1754 can you give this code a try?

const client = new Sentry.BrowserClient({
  dsn: sentryReportingURL,
  release: version,
  environment: process.env.NODE_ENV,
  integrations: Sentry.defaultIntegrations,
});
const hub = new Sentry.Hub(client);

hub.run(() => hub.captureException(e));

@daisy1754
Copy link
Author

@kamilogorek it worked, thanks for help!

@daisy1754
Copy link
Author

just following up I had to revert above because of #2622

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants