Skip to content

ref(routes): replace stats nav-v2 redirect with route-level redirects#111703

Closed
priscilawebdev wants to merge 1 commit intomasterfrom
priscila/ref/remove-stats-nav-v2-redirect
Closed

ref(routes): replace stats nav-v2 redirect with route-level redirects#111703
priscilawebdev wants to merge 1 commit intomasterfrom
priscila/ref/remove-stats-nav-v2-redirect

Conversation

@priscilawebdev
Copy link
Copy Markdown
Member

The navigation-sidebar-v2 feature flag is now fully launched, so the OrganizationStatsWrapper component and its useRedirectNavigationV2Routes hook are no longer needed for the stats routes.

Replace the component-based redirect with declarative redirectTo entries in the route definitions, pointing /stats/* paths to their /settings/stats/* equivalents. Delete the now-unused organizationStatsWrapper.tsx file.

The navigation-sidebar-v2 feature flag is now fully launched, so the
OrganizationStatsWrapper component and its useRedirectNavigationV2Routes
hook are no longer needed. Replace with declarative redirectTo entries
in the route definitions, pointing /stats/* to /settings/stats/*.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Mar 27, 2026
@priscilawebdev priscilawebdev marked this pull request as ready for review March 27, 2026 12:17
Comment on lines 813 to 815
{
path: '/stats/',
withOrgPath: true,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: When a route uses both withOrgPath: true and redirectTo, the withOrgPath property is ignored, preventing the creation of organization-prefixed redirect routes and causing 404 errors.
Severity: HIGH

Suggested Fix

Refactor the translateSentryRoute() function to ensure the withOrgPath logic is applied even when redirectTo is present. This likely involves processing withOrgPath to generate both base and organization-prefixed routes before handling the redirectTo property for each generated route.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: static/app/router/routes.tsx#L813-L815

Potential issue: In the `translateSentryRoute()` function, the logic returns early if a
`redirectTo` property is defined on a route. This early return occurs before the logic
that processes `withOrgPath: true` is reached. Consequently, for the new stats redirect
routes, only the non-organization paths (e.g., `/stats/`) are created, while the
organization-prefixed paths (e.g., `/organizations/:orgId/stats/`) are not. Users
navigating to these organization-specific stats paths will encounter a 404 error instead
of being correctly redirected.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: withOrgPath silently ignored on redirectTo routes
    • Replaced withOrgPath redirect entries with explicit customer-domain and /organizations/:orgId/... redirect routes so org-prefixed stats URLs are matched and redirected.
  • ✅ Fixed: Team redirect targets nonexistent org-prefixed settings path
    • Updated the team stats redirect target to /settings/:orgId/stats/issues/, which is the actual existing settings route.

Create PR

Or push these changes by commenting:

@cursor push 09fbce3f22
Preview (09fbce3f22)
diff --git a/static/app/router/routes.tsx b/static/app/router/routes.tsx
--- a/static/app/router/routes.tsx
+++ b/static/app/router/routes.tsx
@@ -812,22 +812,34 @@
     children: [
       {
         path: '/stats/',
-        withOrgPath: true,
+        customerDomainOnlyRoute: true,
         redirectTo: '/settings/stats/',
       },
       {
+        path: '/organizations/:orgId/stats/',
+        redirectTo: '/settings/:orgId/stats/',
+      },
+      {
         path: '/stats/issues/',
-        withOrgPath: true,
+        customerDomainOnlyRoute: true,
         redirectTo: '/settings/stats/issues/',
       },
       {
+        path: '/organizations/:orgId/stats/issues/',
+        redirectTo: '/settings/:orgId/stats/issues/',
+      },
+      {
         path: '/stats/health/',
-        withOrgPath: true,
+        customerDomainOnlyRoute: true,
         redirectTo: '/settings/stats/health/',
       },
       {
+        path: '/organizations/:orgId/stats/health/',
+        redirectTo: '/settings/:orgId/stats/health/',
+      },
+      {
         path: '/organizations/:orgId/stats/team/',
-        redirectTo: '/organizations/:orgId/settings/stats/issues/',
+        redirectTo: '/settings/:orgId/stats/issues/',
       },
     ],
   };

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

{
path: '/organizations/:orgId/stats/team/',
redirectTo: '/organizations/:orgId/stats/issues/',
redirectTo: '/organizations/:orgId/settings/stats/issues/',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

withOrgPath silently ignored on redirectTo routes

High Severity

The withOrgPath: true on the three new redirect routes is silently ignored. In translateSentryRoute, when redirectTo is set, the function returns early on line 66–68 before reaching the withOrgPath dual-route logic. This means /organizations/:orgId/stats/, /organizations/:orgId/stats/issues/, and /organizations/:orgId/stats/health/ will no longer match any route and will 404 instead of redirecting to their /settings/stats/ equivalents. The old OrganizationStatsWrapper worked because it was a component, not a redirectTo, so withOrgPath was processed.

Fix in Cursor Fix in Web

{
path: '/organizations/:orgId/stats/team/',
redirectTo: '/organizations/:orgId/stats/issues/',
redirectTo: '/organizations/:orgId/settings/stats/issues/',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Team redirect targets nonexistent org-prefixed settings path

High Severity

The /organizations/:orgId/stats/team/ redirect now points to /organizations/:orgId/settings/stats/issues/, but no route exists at /organizations/:orgId/settings/.... The settings routes are defined at /settings/:orgId/... (since settingsRoutes uses path: '/settings/' without withOrgPath). Previously, this redirected to /organizations/:orgId/stats/issues/ which was then caught by the OrganizationStatsWrapper and correctly re-routed to /settings/:orgId/stats/issues/. The new target will hit the catch-all RouteNotFound instead.

Fix in Cursor Fix in Web

@github-actions github-actions bot locked and limited conversation to collaborators Apr 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant