Skip to content

fix(nextjs): Set parameterized transaction name for non-transaction events#19316

Merged
chargome merged 6 commits intodevelopfrom
cg/turbo-tx-parameterization
Feb 13, 2026
Merged

fix(nextjs): Set parameterized transaction name for non-transaction events#19316
chargome merged 6 commits intodevelopfrom
cg/turbo-tx-parameterization

Conversation

@chargome
Copy link
Member

@chargome chargome commented Feb 13, 2026

Calls to Sentry.captureException() inside a Next.js App Router route handler, lead to unparameterized transaction names

  • This happens because non-transaction events read their transaction from the isolation scope's transactionName, which is set to the raw URL by httpServerIntegration. On turbopack, the webpack wrapping loader doesn't run, so wrapRouteHandlerWithSentry (which sets the parameterized name on the current scope) is never called.
  • The fix updates handleOnSpanStart to also set the parameterized route on the isolation scope when hoisting the next.route attribute to the root span. This ensures manually captured events get the parameterized route regardless of bundler.
  • Adds E2E tests for route handler errors (throw), captureException, and captureMessage with parameterized routes in the nextjs-16 test app.

closes #19312

@chargome chargome self-assigned this Feb 13, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 13, 2026

Codecov Results 📊


Generated by Codecov Action

@github-actions
Copy link
Contributor

Codecov Results 📊

✅ Patch coverage is 100.00%. Project has 14 uncovered lines.
✅ Project coverage is 83.13%. Comparing base (base) to head (head).

Files with missing lines (2)
File Patch % Lines
mute.js 79.10% ⚠️ 14 Missing and 7 partials
etoa.js 100.00% ⚠️ 1 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    60.31%    83.13%   +22.82%
==========================================
  Files          756         2      -754
  Lines        41847        83    -41764
  Branches      7996        57     -7939
==========================================
+ Hits         25248        69    -25179
- Misses       16599        14    -16585
- Partials        82         8       -74

Generated by Codecov Action

@chargome chargome changed the title test(nextjs): Add parameterization tests for errors in route handlers fix(nextjs): Set parameterized transaction name for non-transaction events Feb 13, 2026
@chargome chargome marked this pull request as ready for review February 13, 2026 10:29
@chargome chargome requested a review from logaretm February 13, 2026 10:29
Copy link
Member

@andreiborza andreiborza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

handled: false,
type: 'auto.function.nextjs.on_request_error',
});
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test uses conditional instead of separate test cases

Low Severity

The test at line 69 uses if (process.env.TEST_ENV === 'development') to conditionally run assertions for nextjs context and mechanism. Per the project review rules, conditionals within a single test case are discouraged — the recommendation is to split the test into separate test cases for each environment path. This ensures both paths are always visible in test results and avoids silently skipping assertions.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

@chargome chargome merged commit 337f538 into develop Feb 13, 2026
68 checks passed
@chargome chargome deleted the cg/turbo-tx-parameterization branch February 13, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Context transaction name is not parametrized anymore

2 participants