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

Parameterized paths not picked up when using react-router-v6 with basename #9061

Closed
3 tasks done
rottbers opened this issue Sep 20, 2023 · 5 comments · Fixed by #9076
Closed
3 tasks done

Parameterized paths not picked up when using react-router-v6 with basename #9061

rottbers opened this issue Sep 20, 2023 · 5 comments · Fixed by #9076

Comments

@rottbers
Copy link

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

Framework Version

React 18

Link to Sentry event

No response

SDK Setup

No response

Steps to Reproduce

Hope another test case is sufficient as reproduction, it's based on the existing ones in reactrouterv6.4.test.tsx:

it('works with parameterized paths and `basename`', () => {
  const [mockStartTransaction] = createInstrumentation();
  const sentryCreateBrowserRouter = wrapCreateBrowserRouter(createMemoryRouter as CreateRouterFunction);

  const router = sentryCreateBrowserRouter(
    [
      {
        path: '/',
        element: <Navigate to="some-org-id/users/some-user-id" />,
      },
      {
        path: ':orgId',
        children: [
          {
            path: 'users',
            children: [
              {
                path: ':userId',
                element: <div>User</div>,
              },
            ],
          },
        ],
      },
    ],
    {
      initialEntries: ['/admin'],
      basename: '/admin',
    },
  );

  // @ts-expect-error router is fine
  render(<RouterProvider router={router} />);

  expect(mockStartTransaction).toHaveBeenCalledTimes(2);
  expect(mockStartTransaction).toHaveBeenLastCalledWith({
    name: '/admin/:orgId/users/:userId',
    op: 'navigation',
    origin: 'auto.navigation.react.reactrouterv6',
    tags: { 'routing.instrumentation': 'react-router-v6' },
    metadata: { source: 'route' },
  });
});

Expected Result

Expect name to contain parameter names (i.e. /admin/:orgId/users/:id)

Actual Result

Name contains the parameter values (e.g. /admin/some-org-id/users/some-user-id)

@AbhiPrasad
Copy link
Member

This fix was released with https://github.com/getsentry/sentry-javascript/releases/tag/7.71.0. Thanks for reporting @rottbers!

@rottbers
Copy link
Author

rottbers commented Oct 5, 2023

This fix was released with https://github.com/getsentry/sentry-javascript/releases/tag/7.71.0. Thanks for reporting @rottbers!

I've tested the fix but unfortunately the parameter values path (e.g. /admin/some-org-id/...) still appears as the transaction name in the sentry dashboard instead the parameter names path (e.g. /admin/:orgId/...)

  • @sentry/react: 7.71.1
  • react-router-dom: 6.14.1

@AbhiPrasad AbhiPrasad reopened this Oct 5, 2023
@AbhiPrasad
Copy link
Member

@onurtemizkan mind taking a look?

@onurtemizkan
Copy link
Collaborator

@rottbers, could you provide us a reproduction? The patch is tested with the new case, so we need to see the specifics to get the root of it.

@getsantry
Copy link

getsantry bot commented Nov 25, 2023

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 remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label Nov 25, 2023
@getsantry getsantry bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants