Skip to content

Sentry integration does not attach tracing headers to axios XHR requests when used with react-query #8183

@damian-broniowski

Description

@damian-broniowski

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/react

SDK Version

7.52.1

Framework Version

18.2.0

Link to Sentry event

No response

SDK Setup

  Sentry.init({
    dsn: process.env.SENTRY_DSN,
    integrations: [
      new BrowserTracing({
        routingInstrumentation: Sentry.reactRouterV6Instrumentation(
          React.useEffect,
          useLocation,
          useNavigationType,
          createRoutesFromChildren,
          matchRoutes,
        ),
        tracePropagationTargets: [/api\.([^.]+)\.trajector\.cloud/],
      }),
    ],

    tracesSampleRate: 1,
    environment: process.env.NODE_ENV,
    release: process.env.VERSION,
  });

Steps to Reproduce

Use axios with react-query.

useQuery({
    queryKey: [queryKeys.FeatureFlags],
    queryFn: apiRoutes.auth.getFeatureFlags,
    suspense: true,
  });

Expected Result

XHR request to API server should contain sentry headers for distributed tracing

Actual Result

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: browserIssues related to the Sentry Browser SDK

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions