Integrations don't work when using Sentry Client directly
See original GitHub issue- 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
Package + Version
-
@sentry/browser
-
@sentry/node
-
raven-js
-
raven-node
(raven for node) - other:
Version:
5.9.1
Description
I followed instruction how to use Sentry Client directly: https://github.com/getsentry/sentry-docs/blob/master/src/collections/_documentation/platforms/javascript/advance-settings.md.
My Sentry initialization looks like this:
const options = {
dsn: "MY_SENTRY_DSN",
release: "x.x.x",
environment: "production",
integrations: [...Sentry.defaultIntegrations],
};
const client = new Sentry.BrowserClient(options);
this.hub = new Sentry.Hub(client);
...
...
// later in code
this.hub.captureMessage("Hello");
Bug Integrations don’t work, they don’t enhance event
Reason
– On every event, integration’s globalEventProcessor called (e.g UserAgent integration): source code
– Sentry looks if current hub has integration (e.g UserAgent): source code
– Sentry looks for current hub: source code
– Sentry checks if there is window.__SENTRY__.hub
and fails: source code
– Sentry creates new hub without client passed as parameter to Hub constructor: source code
– hub.getIntegration
method returns null cause there is no client: source code
– integration skipped cause hub doesn’t have current integration 😦
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top GitHub Comments
Closing as this seems to be solved.
That is correct. In order for global handlers to work with integrations as well, there has to be initialized global instance as well.