Skip to content

Routes not parameterized for React Router v5 #13901

@sighmun

Description

@sighmun

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

8.33.1

Framework Version

18.2.0

Link to Sentry event

No response

Reproduction Example/SDK Setup

Similar to the issues reported in:

we're seeing traces reported in Sentry often without parameterization. After finding the above issues, I updated our version of the SDK to latest (8.33.1), but that hasn't resolved the problem. We see a mixture of traces reported, and I haven't been able to figure out why it's sometimes parameterized correctly, sometimes with asterixes (*), and sometimes not parameterized at all, though I can confirm that we've only been seeing :id style parameterization instead of asterix-style * since upgrading the Sentry SDK from v7 to v8.

Below is our init config, and each of our Routes are using the wrapped SentryRoute component. We're also using the latest react-router-dom 5.3.4.

import {
  getCurrentScope,
  init,
  reactRouterV5BrowserTracingIntegration,
  User,
  withSentryRouting,
} from '@sentry/react';
import { Route } from 'react-router-dom';
import getClientId from 'xo/client-id';
import { env, STAGE } from '../app/env';
import history from '../hooks/history';

export const SentryRoute = withSentryRouting(Route as any);

if (!env.REACT_APP_STORYBOOK) {
  init({
    enabled: !!env.REACT_APP_SENTRY_DSN,
    dsn: env.REACT_APP_SENTRY_DSN,
    environment: STAGE,
    integrations: [
      reactRouterV5BrowserTracingIntegration({
        history,
      }),
    ],
    sendDefaultPii: false,
    release: env.REACT_APP_COMMIT_FRONTEND,
    initialScope: {
      user: {
        clientId: getClientId(),
      },
    },
    replaysOnErrorSampleRate: 0.05,
    tracesSampleRate: 1,
  });
}

Steps to Reproduce

Followed steps specified in https://docs.sentry.io/platforms/javascript/guides/react/features/react-router/#parameterized-transaction-names to setup routing instrumentation in React app with React Router v5

Expected Result

Traces in sentry.io always appear in the form one of /fixed-root/:id when rendered with a SentryRoute component

Actual Result

Traces in sentry.io can appear in the form one of:
a. /fixed-root/the-actual-id
b. /fixed-root/:id
c. /fixed-root/*

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugPackage: reactIssues related to the Sentry React SDK

    Projects

    Status

    Waiting for: Community

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions