-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[react-router-6] Nested Routers produce wrong parametrized URL #5997
Comments
thanks for raising this issue! The team will take a look at it and try to get back to you. repro steps much appreciated 🙏 |
Thanks for reporting this @tirli. I was able to debug the reproduction, and indeed the problem seems to be the use of Descendant Routes. I have tried two scenarios to figure out how we can support this pattern. 1 - When you only use
|
Reading this through I think this is tricky to make work with our current API. Might be worthwhile to just try working on #5872, and then say that for nested routers to work you need to use the |
I agree, this would end up quite hacky even if we change our API. Haven't tried, but |
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you label it "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
@onurtemizkan, not sure what is the status of this. I see that all mentioned issues are resolved, and PRs are merged. Should it work now? |
@tirli - As discussed, we attempted to support this pattern while working on React Router 6.4, but unfortunately it was not included with the initial implementation for the reasons discussed in #6172, specifically:
I still think there should be a way to support this, but it needs more investigation. Adding |
I have the same issue with only one SentryRoutes on the root and a lot of nested routes, willing to keep real ids. I ended up overwriting transaction name in beforeSendTransaction with window.location.pathname. It feels really hacky and not a good practice at all, but at least all the transactions have now a correct name in Sentry. |
Adding a +1 here. I'm encountering this with I have a router with a nested wildcard/splat subrouter: <SentryRouter>
<Route path="/objects/:objectSlug/*" element={<ObjectRoutes />} />
</SentryRouter> and <SentryRoutes>
<Route path="/items" element={<ObjectItems />}/>
<!-- others snipped for brevity -->
</SentryRoutes> All detected navigate transactions for the nested |
I feel like this is something we should support. Shouldn't be too hard to do 🤞 |
Thanks for the update! We're aware that this still needs to be addressed from our end. We just currently have to prioritize other tasks. If anyone wants to help our with this in the meantime, PRs are always welcome :) |
I wonder if remix-run/react-router#11113 will improve the ease of fixing this at some point... |
I was working on a potential fix for this recently, when I noticed our production environment of Sentry started reporting the routes correctly on 10/18. Seems this might be resolved? Here's a screenshot showing the routes: Before we got |
I checked again, but unfortunately, the original issue still exists. I'll give this another try to find a way. |
@onurtemizkan dang! I actually have a branch that I think I solved this with in a fork. I didn't open the PR as I thought it was resolved. I can open that PR if that helps and you can take a look. Here's the PR: #14076 |
Based on @grahamhency's work at #14076. Sets correct transaction names when wildcards are used in React Router 6 routes. This does not fix the usage of the descendant routes (#5997), which we should try to address separately.
@onurtemizkan what do we need to do to get descendant routes working? |
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.16
Framework Version
React 18
Link to Sentry event
https://sentry.io/organizations/astraea/issues/3684294425/?project=5995515&query=is%3Aunresolved
Steps to Reproduce
I have quite a complex router so I recreated a small part of it here with repro steps in the readme: https://github.com/tirli/repro-sentry-react-router
I'm pretty sure several nested
SentryRoutes
are to blame here but I cannot rewrite my usage of the router :( Also, I've seen a lot of similar issues that are blaming the wrong order of sentry init and router usage so I checked this case and I feel like it's not the problem hereExpected Result
http://localhost:5173/monitor/projects/:projectId/:siteId
in error detailsActual Result
http://localhost:5173/monitor/projects/someProjectId/someSiteId
The text was updated successfully, but these errors were encountered: