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

Routes not parameterized for React Router v5 #13901

Open
3 tasks done
strewhella opened this issue Oct 8, 2024 · 1 comment
Open
3 tasks done

Routes not parameterized for React Router v5 #13901

strewhella opened this issue Oct 8, 2024 · 1 comment
Labels
Package: react Issues related to the Sentry React SDK Waiting for: Community

Comments

@strewhella
Copy link

strewhella commented Oct 8, 2024

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/*

@github-actions github-actions bot added the Package: react Issues related to the Sentry React SDK label Oct 8, 2024
@Lms24
Copy link
Member

Lms24 commented Oct 8, 2024

Hey @strewhella thanks for writing in! We'd like to look into fixing this but right now we don't have enough information. For instance, we don't know how you define your routes (using <SentryRoute>). Can you provide a concrete example route, ideally in the form of a minimal reproduction example (e.g. stackblitz, GH repo, etc) of a route that doesn't get parameterized correctly? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: react Issues related to the Sentry React SDK Waiting for: Community
Projects
Status: Waiting for: Community
Development

No branches or pull requests

2 participants