Skip to content

Replays are not capturing network requests (possibly due to Authorization header) #16028

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

Closed
billyvg opened this issue Apr 10, 2025 · 7 comments
Closed

Comments

@billyvg
Copy link
Member

billyvg commented Apr 10, 2025

Description

This came in from a user in Discover where their fetch requests are not being captured even though it's seemingly configured correctly. After some debugging the user noticed that the requests with an Authorization header were not being captured and a test request without the header was able to be captured.

Copy link
Member

mydea commented Apr 11, 2025

Are there more details on this, e.g. their exact SDK setup, and an example request (headers, url & body, possibly?) that is/is not captured?

@mydea mydea added Bug Package: replay Issues related to the Sentry Replay SDK labels Apr 11, 2025 — with Linear
@billyvg
Copy link
Member Author

billyvg commented Apr 11, 2025

The user is working on a minimal repro. Below is the config.

Sentry.init({
  debug: true,
  environment: envName(import.meta.env.VITE_REGEN_ENDPOINT),
  dsn: import.meta.env.VITE_SENTRY_DSN,
  tunnel: import.meta.env.VITE_SENTRY_TUNNEL,
  integrations: [
    Sentry.browserTracingIntegration(),
    Sentry.reactRouterV6BrowserTracingIntegration({
      useEffect: React.useEffect,
      useLocation,
      useNavigationType,
      createRoutesFromChildren,
      matchRoutes,
    }),
    Sentry.replayIntegration({
      maskAllInputs: false,
      maskAllText: false,
      blockAllMedia: false,
      networkDetailAllowUrls: [
        window.location.origin,
        import.meta.env.VITE_REGEN_ENDPOINT,
      ],
      _experiments: {
        traceInternals: true,
        captureExceptions: true,
      },
    }),
    Sentry.replayCanvasIntegration(),
  ],
  transport: Sentry.makeBrowserOfflineTransport(Sentry.makeFetchTransport),
  // Tracing
  tracesSampleRate: 1.0, //  Capture 100% of the transactions
  // Set `tracePropagationTargets` to control which URLs distributed
  // tracing should be enabled for
  tracePropagationTargets: [
    new RegExp(`^${import.meta.env.VITE_REGEN_ENDPOINT}`),
  ],
  // Session Replay
  // 1.0 sets the sample rate to 100%. May want the `replaysSessionSampleRate`
  // to be lower in production (e.g. 10%, or 0.1)
  replaysSessionSampleRate: 1.0,
  replaysOnErrorSampleRate: 1.0,
});

@mydea
Copy link
Member

mydea commented Apr 14, 2025

they have duplicate browserTracingINtegrations (they should remove browserTracingIntegration and only leave reactRouterV6BrowserTracingIntegration in there!). Possibly this is the cause here... 🤔

@mydea
Copy link
Member

mydea commented Apr 14, 2025

#16040 maybe fixes this?

Copy link
Member

mydea commented Apr 14, 2025

Billy, let us know if removing the duplicate integration fixes the problem, then we can close this issue. Else, the problem may be elsewhere!

@mydea mydea added the Replays label Apr 14, 2025 — with Linear
@cwinters8
Copy link

I'm the user who reported the issue via Discord and was debugging with @billyvg. On Friday, my coworker and I figured out the issue: We are using a generated hey-api client to make HTTP requests to our API, and hey-api was wrapping fetch before Sentry had a chance to, so any API requests made by that client could never be caught by the Sentry SDK. Moving Sentry.init above the initialization for the hey-api client fixed the problem, and now the HTTP requests to our API are being captured in replays.

Thanks for the help on this!

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Apr 15, 2025
@billyvg
Copy link
Member Author

billyvg commented Apr 15, 2025

Glad you were able to resolve this!

@billyvg billyvg closed this as completed Apr 15, 2025
@stephanie-anderson stephanie-anderson removed the Package: replay Issues related to the Sentry Replay SDK label Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

4 participants