Skip to content
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

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

Closed
5 tasks done
fredva opened this issue Dec 13, 2019 · 6 comments
Closed
5 tasks done

Comments

@fredva
Copy link

fredva commented Dec 13, 2019

Package + Version

  • @sentry/browser

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
Copy link
Member

HazAT commented Jan 8, 2020

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
Copy link
Contributor

OliverJAsh commented Oct 5, 2020

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:

  • A main Sentry project to catch all uncaught exceptions in our JS code. This Sentry client is to be registered globally so it can report an exception wherever it happens in the code.
    // main-sentry.ts
    Sentry.init({ dsn: mainProjectDsn });
  • Another Sentry project to report all bad (non-2xx) responses from our API. This Sentry client is not to be registered globally, as we only want to report errors to it manually.
    // api-sentry.ts
    const APISentryClient = new Sentry.NodeClient({ dsn: apiProjectDsn });
    export const APISentry = new Sentry.Hub(APISentryClient);

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
Copy link
Contributor

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
Copy link

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

@github-actions
Copy link
Contributor

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 🥀

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 1, 2023
@antonpodolsky
Copy link

antonpodolsky commented Jun 17, 2023

I can confirm that this is a pain point :)

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

6 participants