-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
beforeNavigate isn't called for ReactRouterV6 #5598
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
Comments
Hey, thanks for writing in. Could you enable debug mode by supplying |
That's on page load, which is also the only case beforeNavigate is getting called. When switching routes nothing goes to the console Screen.Recording.2022-08-18.at.12.35.04.mov |
Thank you for the video! This is the logic for how navigations are generated: sentry-javascript/packages/react/src/reactrouterv6.tsx Lines 181 to 205 in 5172a7d
So there's a couple things here: Perhaps we have to adjust the dependency array of the |
@AbhiPrasad Thank you! |
Could you check what is talked about in #5555 could resolve your issue? |
We stuck with the same issue. Hope the solution or fix will be found soon. |
@AbhiPrasad If I understand correctly the we should "Start Transaction" for each route navigation (similar to page load).
Then in other place on my app I did something like
That's in order to attach the network error to the transaction. But I ended up creating a "single" transaction for every network endpoint& request which misses the whole idea of transactions., which feels strongly wrong. When can we expect a solution for something so basic? |
You shouldn't need to do this, we should be automatically creating these transactions. That's the bug that needs to be fixed. I do have some bandwidth to look at this - are you able to share some kind of repro of this problem so I can take a look? |
Mmmm , it's pretty basic. Start create react app, add the react-router integration and have debug true, in the sentry init. I am willing to go on a call, |
Ah ok, was able to reproduce with https://stackblitz.com/edit/github-7tjxzc-gabqis?file=src/App.tsx. Will take a look! |
Ah ok - seems like I fell into the same thing that was addressed here: #5555 (comment) See our docs update: https://github.com/getsentry/sentry-docs/pull/5505/files You have to make sure that I updated the example to move the logic into You can confirm this by turning on debug mode, and searching for the string |
@AbhiPrasad I red trough it and even had a comment in my code. My problem was that I had file called 'sentry.tsx' which contains: export const initSentry =() => { export const SentryRoutes = Sentry.withSentryReactRouterV6Routing(Routes); The init is called in a function so the wrapping of HOC is actually happening first. I highly suggest to create some promise based logic for this |
We might just eliminate this problem entirely by supporting the new APIs in |
Seems like it was solved in 7.15.0 (and we also fixed our code). Therefore closing the issue :) Thanks @AbhiPrasad |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which package are you using?
@sentry/react
SDK Version
7.11.0
Framework Version
React 17.0.2
Link to Sentry event
No response
Steps to Reproduce
Expected Result
console would print the ctx of each navigation
Actual Result
Except pageload - initial navigation , nothing happens.
Also tried to blend into "matchRoutes" function using hoisting.
Also tried to capture the event in "beforeSend"
Seems like the events doesn't go trough there.
Trying to enrich the events with the route context.
The text was updated successfully, but these errors were encountered: