fix(nextjs): fix parameterization for root catchall routes #17489
+42
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Next.js SDK has code to parameterize transaction names for frontend URLs. This code wasn't working correctly for catchall routes at the root (e.g.
app/[[...path]]
).The regex generated by
buildRegexForDynamicRoute
in this case was previously^/(?:/(.*))?$
- note that because it starts with a/
and then requires another/
in the optional group, it would only match the full path/
or paths starting with//
. In practice, that meant paths other than/
never matched. As a result, the paths were used verbatim as the transaction name, withsentry.source
set tourl
. Such paths would then go on to trigger our transaction name clusterer due to their high cardinality.This PR fixes the regex generation for root catchall routes so that the routes are parameterized on the frontend as expected. Resulting routes have
sentry.source
set toroute
, meaning that the transaction clusterer is not triggered.