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

React Router - Support Lazy-Loaded Routes #15040

Closed
onurtemizkan opened this issue Jan 16, 2025 · 3 comments
Closed

React Router - Support Lazy-Loaded Routes #15040

onurtemizkan opened this issue Jan 16, 2025 · 3 comments
Labels
Feature: Tracing Package: react Issues related to the Sentry React SDK Package: react-router Issues related to the Sentry React Router SDK

Comments

@onurtemizkan
Copy link
Collaborator

Problem Statement

Ref: #15027

In the current version, lazy-loaded routes in the React Router are not parameterized correctly in the SDK.

We are able to parameterize up to the deepest non-lazily loaded route, and no further as we are not able to reach the full routes tree.

Solution Brainstorm

We can investigate whether we can implement a solution using the currently-unstable "Fog of War" on React Router 7 to get the full routes tree and whether we can traverse it and create parameterized transactions.

  • React Router Implementation - Link
  • React Router API Reference - Link
@peteragarclover
Copy link

As a simple escape hatch solution which could be helpful in the short term (or possibly generally), how about exposing a configuration option to allow people to provide a custom implementation of getNormalizedName() that doesn't rely on the entire routes collection to be populated?

E.g. A naive implementation could be similar to the documented javascript browser tracing integration: https://docs.sentry.io/platforms/javascript/tracing/instrumentation/automatic-instrumentation/#beforestartspan

          // You could use your UI's routing library to find the matching
          // route template here. We don't have one right now, so do some basic
          // parameter replacements.
          name: location.pathname
            .replace(/\/[a-f0-9]{32}/g, "/<hash>")
            .replace(/\/\d+/g, "/<digits>"),

I believe that at least for our use case this should be sufficient to normalize all our routes, so it might be generally useful 🤷

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Jan 17, 2025
@andreiborza
Copy link
Member

@peteragarclover thanks for sharing that, we'll look into that.

@onurtemizkan
Copy link
Collaborator Author

@peteragarclover, @andreiborza - This issue should be resolved by #15039

@peteragarclover, please let us know if there are any further issues after trying the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Tracing Package: react Issues related to the Sentry React SDK Package: react-router Issues related to the Sentry React Router SDK
Projects
Archived in project
Development

No branches or pull requests

3 participants