Closed
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/react
SDK Version
7.56.0
Framework Version
React 18
Link to Sentry event
No response
SDK Setup
Sentry.init({
dsn:
'MYDSN',
integrations: [
new Sentry.BrowserTracing({
beforeNavigate: (context) => {
console.log("Navigating");
console.log(context);
return context;
},
// Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled
tracePropagationTargets: ["graphql"],
// See docs for support of different versions of variation of react router
// https://docs.sentry.io/platforms/javascript/guides/react/configuration/integrations/react-router/
routingInstrumentation: Sentry.reactRouterV6Instrumentation(
React.useEffect,
useLocation,
useNavigationType,
createRoutesFromChildren,
matchRoutes
),
}),
new Sentry.Replay({
networkDetailAllowUrls: ["graphql"],
maskAllText: false,
maskAllInputs: false,
blockAllMedia: false
})
],
tracesSampleRate: 1.0,
replaysSessionSampleRate: 1.0,
replaysOnErrorSampleRate: 1.0,
environment: config.EnvironmentName
});
Steps to Reproduce
Setup React Router 6 like this:
const sentryCreateBrowserRouter = Sentry.wrapCreateBrowserRouter(createBrowserRouter);
const router = suppressRouter
? null
: sentryCreateBrowserRouter(
createRoutesFromChildren(
<Route
path="/"
element={RootElement}
<Fragment>
<Route
path="/stuff"
element={<Stuff />} />
<Route path="/" element={<Home />} />
</Fragment>
</Route>
) ,
{
basename: "/myapp"
}
);
Expected Result
Sentry would correctly hook into React Router and create transactions when navigating on the site even when basename is specified for React Router
Actual Result
Only the home page is captured all other navigations are ignored. If you comment out the option element where it has basename then everything works correctly. However, because of the way we are hosting multiple sites together I need to use the basename option.
This also means that the sentry-trace header is not attached to any requests that are not on the homepage.
Metadata
Metadata
Assignees
Type
Projects
Status
Waiting for: Product Owner