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

Navigation transactions not triggering for hash router #9592

Closed
3 tasks done
AbhiPrasad opened this issue Nov 17, 2023 · 5 comments
Closed
3 tasks done

Navigation transactions not triggering for hash router #9592

AbhiPrasad opened this issue Nov 17, 2023 · 5 comments
Assignees
Labels
Package: react Issues related to the Sentry React SDK Type: Bug

Comments

@AbhiPrasad
Copy link
Member

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.73.0

Framework Version

No response

Link to Sentry event

No response

SDK Setup

Using React Router v6 instrumentation + hash router

Steps to Reproduce

enable sdk. See SDK is only generating pageloads not navigations

Expected Result

Sentry generates transactions for navigations

Actual Result

location seems to be changing just fine.

image

@AbhiPrasad AbhiPrasad self-assigned this Nov 17, 2023
@github-actions github-actions bot added the Package: react Issues related to the Sentry React SDK label Nov 17, 2023
@AbhiPrasad
Copy link
Member Author

@onurtemizkan can you dig into this when you get time?

@onurtemizkan
Copy link
Collaborator

@AbhiPrasad, I have just tried to reproduce the issue, and it looks like both usages of wrapping HashRouter are working fine with the latest versions of Sentry SDK and React Router.

One thing I suspect that may cause this behaviour is, initialising the SDK, but not instrumenting the hash router/routes properly.

The pageload transactions start on Sentry.init when we call reactRouterV6Instrumentation (so this part seems to be configured properly)

https://docs.sentry.io/platforms/javascript/guides/react/features/react-router/#usage-with-react-router-64-data-api

For the rest of the functionality:

// We can instrument `createHashRouter` with `Sentry.wrapCreateBrowserRouter(...)`
const sentryCreateHashRouter =
  Sentry.wrapCreateBrowserRouter(createHashRouter);

const router = sentryCreateHashRouter([
  // ...
]);

or

const SentryRoutes = Sentry.withSentryReactRouterV6Routing(Routes);

ReactDOM.render(
  <HashRouter>
    <SentryRoutes>
      <Route path="/" element={<div>Home</div>} />
    </SentryRoutes>
  </HashRouter>
);

are needed.

Could you let me know if that's the case?

@AbhiPrasad
Copy link
Member Author

The user was using SentryRoutes. The tricky part of this problem was that it worked locally, but not in prod environments. I'm not sure why.

@onurtemizkan
Copy link
Collaborator

Interesting, I'll try to reproduce this on a deployed app 👍

@onurtemizkan
Copy link
Collaborator

I'm still not able to reproduce the issue on an app deployed to Vercel: https://react-router-v6-sentry-trial-gjq5.vercel.app/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: react Issues related to the Sentry React SDK Type: Bug
Projects
None yet
Development

No branches or pull requests

2 participants