Title: Revamp the Integrations API · Issue #4790 · getsentry/sentry-javascript · GitHub
Open Graph Title: Revamp the Integrations API · Issue #4790 · getsentry/sentry-javascript
X Title: Revamp the Integrations API · Issue #4790 · getsentry/sentry-javascript
Description: Official Sentry SDKs for JavaScript. Contribute to getsentry/sentry-javascript development by creating an account on GitHub.
Open Graph Description: Official Sentry SDKs for JavaScript. Contribute to getsentry/sentry-javascript development by creating an account on GitHub.
X Description: Official Sentry SDKs for JavaScript. Contribute to getsentry/sentry-javascript development by creating an account on GitHub.
Opengraph URL: https://github.com/getsentry/sentry-javascript
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Revamp the Integrations API","articleBody":"### Problem Statement\r\n\r\n### Warning: This is a WIP brainstorming doc\r\n\r\nSimilar to work done in https://github.com/getsentry/sentry-javascript/issues/4660 for the transports, we can update things for the integrations also.\r\n\r\n### Solution Brainstorm\r\n\r\nIn this ideal world, we would like to pass in the hub directly to the integration. \r\n\r\nSomething like\r\n\r\n```ts\r\ninterface NewIntegration {\r\n name: string;\r\n setup(hub: Hub): void;\r\n}\r\n```\r\n\r\nThe issue here is that this does not work in the node SDK, which relies on storing the hub on the domain. A new hub is constructed for every, but it re-uses the client, so the integrations will only be setup once. This means that they only get a reference to the original hub, not the new hub that comes from each domain.\r\n\r\nhttps://github.com/getsentry/sentry-javascript/blob/37b14bf2273801fa40d4aea22ab925d7753a0a40/packages/hub/src/hub.ts#L601\r\n\r\nWe could have two different hub modes though. In the first hub mode, there is some async storage that stores the hub (domains, async hooks, zonejs etc.) - so `getCurrentHub` returns the hub thats stored in async storage. In the second hub mode, `getCurrentHub` just returns the hub that originally created the client + passed in integrations.\r\n\r\n```ts\r\ninterface NewIntegration {\r\n name: string;\r\n // does different things based on environment.\r\n setup(getCurrentHub: () => Hub): void;\r\n}\r\n```\r\n\r\nI recognize this is kind of confusing though, so would appreciate and suggestions for a better API here. Struggling to generate ideas beyond this.\r\n\r\nOne important thing to note is event processors. We'll need to add event processors to hubs to make this change happen. In addition, we can change the event processor API so that (optionally) we give it the name of the integration that created it. This allows for easier debugging and logging, so users can understand if an event processor dropped an event, why it happened.\r\n\r\n```ts\r\ntype addEventProcessor = (processor: EventProcessor, name?: string) => void;\r\n```\r\n\r\n","author":{"url":"https://github.com/AbhiPrasad","@type":"Person","name":"AbhiPrasad"},"datePublished":"2022-03-25T17:19:17Z","url":"https://github.com/getsentry/sentry-javascript/issues/4790"}
| 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 | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:730f0ac4-f873-57eb-a3c3-f8c0fdfdebf6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CB52:311933:925898:C82E99:6B0481E1 |
| html-safe-nonce | 4aa77f4c7ee6d2afb374340bfd3acfb8238b5cc5c32b42270cd2146741ad1ae1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQjUyOjMxMTkzMzo5MjU4OTg6QzgyRTk5OjZCMDQ4MUUxIiwidmlzaXRvcl9pZCI6IjU5NzgzNDcxODIyMDA0ODg0MTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | cfe3e31f7ebbf494c6717550db54f4af3c9b75903a842808e287b068dc54dfeb |
| hovercard-subject-tag | repository:3328572 |
| 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/getsentry/sentry-javascript/issues/4790 |
| twitter:image | https://repository-images.githubusercontent.com/3328572/1b73c77d-6488-4ece-9e12-e61d9eb2ac2b |
| twitter:card | summary_large_image |
| og:image | https://repository-images.githubusercontent.com/3328572/1b73c77d-6488-4ece-9e12-e61d9eb2ac2b |
| og:image:alt | Official Sentry SDKs for JavaScript. Contribute to getsentry/sentry-javascript development by creating an account on GitHub. |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0366ddfb372682a32e92a5d86155cb08fa83e5bbe79953a968789f2f7e24c511 |
| turbo-cache-control | no-cache |
| 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 | ed3f2e01f6b7672780c586c8af0e72726374d7b6 |
| 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