Title: Manually instantiated Hub with provided client instance, shouldn't require additional bindClient call to setup integrations · Issue #2541 · getsentry/sentry-javascript · GitHub
Open Graph Title: Manually instantiated Hub with provided client instance, shouldn't require additional bindClient call to setup integrations · Issue #2541 · getsentry/sentry-javascript
X Title: Manually instantiated Hub with provided client instance, shouldn't require additional bindClient call to setup integrations · Issue #2541 · getsentry/sentry-javascript
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 aff...
Open Graph 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-javas...
X 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-javas...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/2541
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Manually instantiated Hub with provided client instance, shouldn't require additional bindClient call to setup integrations","articleBody":"\u003c!-- Requirements: please go through this checklist before opening a new issue -->\r\n\r\n- [x] Review the documentation: https://docs.sentry.io/\r\n- [x] Search for existing issues: https://github.com/getsentry/sentry-javascript/issues\r\n- [x] Use the latest release: https://github.com/getsentry/sentry-javascript/releases\r\n- [x] 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\r\n\r\n## Package + Version\r\n\r\n- [x] `@sentry/browser`\r\n- [ ] `@sentry/node`\r\n- [ ] `raven-js`\r\n- [ ] `raven-node` _(raven for node)_\r\n- [ ] other:\r\n\r\n### Version:\r\n\r\n```\r\n5.15.4\r\n```\r\n\r\n## Description\r\nAs per the [Advance Usage docs](https://docs.sentry.io/platforms/javascript/advance-settings/#using-a-client-directly), 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.\r\n\r\nCreating 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.\r\n\r\nThere 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.\r\n\r\nMy code looks like this:\r\n```\r\nconst { Hub, BrowserClient, defaultIntegrations } = Sentry;\r\n\r\nconst client = new BrowserClient({\r\n dsn: process.env.SENTRY_DSN,\r\n environment: process.env.NODE_ENV,\r\n integrations: defaultIntegrations\r\n});\r\n\r\nconst hub = new Hub(client);\r\n\r\n// ...Later\r\n\r\nhub.run((currentHub) => {\r\n currentHub.captureException(error);\r\n});\r\n```\r\n","author":{"url":"https://github.com/NicHaley","@type":"Person","name":"NicHaley"},"datePublished":"2020-04-15T15:47:07Z","url":"https://github.com/getsentry/sentry-javascript/issues/2541"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f1f8774e-2e71-7202-3de6-8602ed00ebde |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9D80:1425F4:1EC3CD:2B1170:6B043857 |
| html-safe-nonce | 2bc37f89243f2e91b534de45d31d72374b70c09f18245f46e680c1db0475a50f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RDgwOjE0MjVGNDoxRUMzQ0Q6MkIxMTcwOjZCMDQzODU3IiwidmlzaXRvcl9pZCI6IjMzODgzOTE0Mzc4MTYzMTM5NDMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9487272df56b2fdb55f65f6040d62cc863a24003e836ee9e7ec6ef741d0b4024 |
| hovercard-subject-tag | issue:600400408 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/2541/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d3030459a152829b0a538e4323e357b895449a0ab428cf3725cf8b1fd2cebb27/getsentry/sentry-javascript/issues/2541 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d3030459a152829b0a538e4323e357b895449a0ab428cf3725cf8b1fd2cebb27/getsentry/sentry-javascript/issues/2541 |
| og:image:alt | 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-javas... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | NicHaley |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9185ccfefd80c1ff2d9ddcdb0cd2becf46b5a1efbbf30741a895e4bb8de25e64 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 06dc448a76fe4751ac1db26524aefa3aa3e889a8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width