getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
7.94k stars 1.56k forks source link

Breadcrumbs integration doesn't work when creating a client and hub manually #2356

Closed fredva closed 1 year ago

fredva commented 4 years ago

Package + Version

Version:

5.10.2

Description

Reproducible demo: https://github.com/fredva/sentry-issue-mwe Example event in our Sentry account: https://sentry.io/organizations/spacemaker-ai/issues/1385873171/?project=1488702&query=is%3Aunresolved

We have a large frontend application with several Sentry clients reporting to different Sentry DSNs. These clients are set up as described in the docs: https://docs.sentry.io/platforms/javascript/advance-settings/#dealing-with-integrations

The default breadcrumbs integration does not seem to be working when configuring Sentry this way. The reproducible demo demonstrates that these crumbs are missing from the event when configuring Sentry as above. When configuring Sentry the default way, the crumbs are present in the event.

We might be missing something – please let me know if there are ay configuration options I am missing our using wrong. If not, this might be a possible bug in the JS SDK.

HazAT commented 4 years ago

Sorry for the late response here and thank you for providing the repro case 🥇

So this is not a bug I would say it's a limitation 😬

Let me explain how it works:

At the of when we add a breadcrumb, there must be a client bound to the current hub https://github.com/getsentry/sentry-javascript/blob/master/packages/browser/src/integrations/breadcrumbs.ts#L97

so just doing this: hub.run(h => h.captureMessage("test-message-hub")); for the capture call is not enough. You need to make your hub the main (current) one by calling

import { makeMain } from "@sentry/hub";

makeMain(hub1);

The breadcrumbs are not stored globally in the integration, they are stored on the current hub.

I hope the explanation makes sense.

I am not sure though if you can fix the problem with that knowledge on your side. If I understood you correctly you would expect that the integration internally stores the breadcrumbs and then dispatches them to the currently active hub/client?

OliverJAsh commented 4 years ago

If I understood you correctly you would expect that the integration internally stores the breadcrumbs and then dispatches them to the currently active hub/client?

@HazAT We are also running into this problem, so maybe I can help unblock this issue by answering your question.

For context, this is how we would like to use Sentry in our Node application:

When we tried this, it worked as intended however the breadcrumbs were missing from the errors reported to our "API Sentry" project.

We really need breadcrumbs for all errors reported to Sentry, especially for the ones sent to our API Sentry project, so we can see the network request which resulted in the error.

Therefore my expectation is that breadcrumbs should appear any time we send an error to Sentry.

github-actions[bot] commented 2 years ago

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

artaommahe commented 2 years ago

still an issue for us (microfrontends, custom elements and all that stuff)

github-actions[bot] commented 1 year ago

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

antonpodolsky commented 1 year ago

I can confirm that this is a pain point :)