diff --git a/packages/tracing-internal/src/node/integrations/express.ts b/packages/tracing-internal/src/node/integrations/express.ts index 8b3bcb52fcf4..165494563eb7 100644 --- a/packages/tracing-internal/src/node/integrations/express.ts +++ b/packages/tracing-internal/src/node/integrations/express.ts @@ -1,6 +1,12 @@ /* eslint-disable max-lines */ import type { Hub, Integration, PolymorphicRequest, Transaction } from '@sentry/types'; -import { extractPathForTransaction, getNumberOfUrlSegments, isRegExp, logger } from '@sentry/utils'; +import { + extractPathForTransaction, + getNumberOfUrlSegments, + isRegExp, + logger, + stripUrlQueryAndFragment, +} from '@sentry/utils'; import { shouldDisableAutoInstrumentation } from './utils/node-utils'; @@ -335,7 +341,7 @@ function instrumentRouter(appOrRouter: ExpressRouter): void { if (urlLength === routeLength) { if (!req._hasParameters) { if (req._reconstructedRoute !== req.originalUrl) { - req._reconstructedRoute = req.originalUrl; + req._reconstructedRoute = req.originalUrl ? stripUrlQueryAndFragment(req.originalUrl) : req.originalUrl; } }