getsentry / sentry-javascript

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

Secondary hub does not send useragent and breadcrumbs #2732

Closed artaommahe closed 2 months ago

artaommahe commented 4 years ago

Package + Version

Version:

5.18.0

Description

Main angular application + angular widgets app and there are no breadcrumbs and useragent info for widgets app errors.

Main app sentry is inited like this

const integrations: any[] = [
  // ...
  new Sentry.Integrations.Breadcrumbs({ console: false }),
  new Sentry.Integrations.UserAgent(),
];

const client = new BrowserClient({
  enabled: this.enabled,
  dsn: sentryConfig.dsn,
  release,
  defaultIntegrations: false,
  integrations: () => integrations,
  beforeSend: this.beforeSend,
});

this.hub = new Hub(client);

makeMain(this.hub);

same for the widgets app, but without makeMain call and global integrations (GlobalHandlers and CaptureConsole).

We have breadcrumbs/useragent info for main app errors, but not for widgets app. After more debugging it looks like useragent is only sent when makeMain was called for secondary app (widgets). But as i understand there should be only one main hub on page, so how should we solve this and have breadcrumbs/useragent for each app on page?

HazAT commented 4 years ago

Sorry, was too quick closing this.

Yeah, there can only be one active current (main) hub.

You could do something like this: https://codesandbox.io/s/sentrybrowser-new-client-in-beforesend-e4s68

You have one Sentry.init and depending on the event that reaches beforeSend you can create another client with a different DSN to send it elsewhere.

artaommahe commented 4 years ago

I dont have access to over apps sentry and their dsn value 😕 they are completely independent and are deployed and instantiated separately. Any plans on supporting these integrations for secondary hubs? Currently they (secondary hubs) are supported but some random stuff dont work properly. Micro-frontend/widgets apps are growing now and looks like it's the regular use-case.

HazAT commented 4 years ago

So yeah we already talked about this internally, it's not an easy problem to fix and needs a lot, internal refactoring. We are trying to get this done for v6 of the SDK which potentially ships in Q4 2020.

oleksandr-yefremov commented 3 years ago

Still see this issue in

"@sentry/browser": "6.0.3",
"@sentry/tracing": "6.0.3",

So did this fix make it to v6 or not? I am struggling with Sentry for couple of days now and find it really frustrating that documentation says "all good, you can use Hub with Client for modular reporting", but then it does not work at all and I have to dig into issues on github to find out that I have to call makeMain (not even mentioned in documentation). But then it only works for reported issues, not uncaught exceptions.
This ticket is open without milestone or update. Current ticket has milestone v6 which was not achieved and again no update. And there are many other issues which are hanging high and dry.
I can understand that your architecture was not meant for this use case, but the issues are open for more than a year and it's time to put some commitment and announcement. If you are not gonna fix it, my team will consider moving to another error reporting tool, because Sentry just does not work in non-SPA case.

kamilogorek commented 3 years ago

@oleksandr-yefremov we had to make a v6 release for a new default feature enabling, thus what has been announced as v6, has been renamed to v7. And I can assure you that this issue will be resolved in this version. Thanks for your patience.

oleksandr-yefremov commented 3 years ago

Thanks for the update! What is ETA for v7?

image

kamilogorek commented 3 years ago

Early Q2. There are a lot of improvements that we want to include.

tcaselli commented 3 years ago

Hi there. Is v7 still expected for early Q2 ? It seems status didn't change since February. It would be really nice to have this fix ! image

BenBach commented 3 years ago

Also having the same issue. Using micro frontends with Sentry is currently very difficult.

MickeyKay commented 2 years ago

Just ran into the same challenge myself. Any updates by chance @kamilogorek? Thanks for all the hard work y'all!

satlxq commented 2 years ago

Same issue, Hope it get fixed asap.

seahindeniz commented 2 years ago

Hey @artaommahe, have you tried the following way?

import { BrowserClient, defaultIntegrations, Integrations } from '@sentry/browser';
import type { Integration } from '@sentry/types';

const integrations: Integration[] = [
  ...defaultIntegrations, // You need to add this line in order to have additional tags
  new Integrations.Breadcrumbs({ console: false }),
  new Integrations.UserAgent(),
];

const client = new BrowserClient({
  /// ...
  // defaultIntegrations: false, // You probably don't need this one
  integrations,
  /// ...
});
WillKre commented 2 years ago

And I can assure you that this issue will be resolved in this version. [v7]

Hi @kamilogorek has this been dropped from v7 support? I've upgraded to v7 and am still getting the same issue (no breadcrumbs coming through)

@seahindeniz unfortunately specifying it in Integrations explicitly like your example didn't help either.

mydea commented 2 months ago

Why was this issue closed?

This issue hasn't been touched recently and no longer seems relevant. Hence, we're closing it to maintain a clean and transparent backlog.

Please feel free to leave a comment if you think this issue should be reopened.