Support Sentry SDK v9 and v10 in node renderer integration#2434
Support Sentry SDK v9 and v10 in node renderer integration#2434alexeyr-ci2 merged 1 commit intomasterfrom
Conversation
WalkthroughWidened Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR updates Sentry SDK compatibility from v7-v8 to v5-v10 by replacing the direct Key changes:
The approach is clean and maintains type safety without introducing additional dependencies. Confidence Score: 5/5
Important Files Changed
Flowchartflowchart TD
A[Sentry Integration v7-v8] --> B{Type Dependency Issue}
B --> C[sentry/types no longer transitive in v9+]
C --> D[Solution: Type Extraction]
D --> E[Parameters typeof Sentry.startSpan]
E --> F[UnitOfWorkOptions Interface]
F --> G[Supports Sentry v5-v10]
H[Peer Dependency] --> I[Update range to v5-v10]
I --> G
J[Root package.json] --> K[Keep devDep at v7]
K --> L[Prevents breaking sentry6 integration]
Last reviewed commit: aee5fde |
size-limit report 📦
|
aee5fde to
ff81d95
Compare
- Replace `@sentry/types` import with `Parameters<typeof Sentry.startSpan>[0]` to avoid depending on `@sentry/types`, which is no longer a transitive dependency of `@sentry/node` in v9+ - Widen `@sentry/node` peer dependency from `<9.0.0` to `<11.0.0` - Add note about test assertion that needs updating for Sentry v10
8ae3f41 to
3dd19c6
Compare
PR Review: Support Sentry SDK v9 and v10 in node renderer integrationOverall this is a clean, well-scoped change. The approach is sound and the breadth of the diff is appropriately minimal. What's good
Observation: test comment is fragile future-debtThe comment added to // Note: Sentry v10 no longer sets report.tags.transaction automatically.
// Remove this assertion when upgrading devDependency.
expect(report.tags.transaction).toBe(spanName);Since the PR description says this assertion will fail when the devDependency is upgraded to v10, and there's no linked issue or TODO tracker, it's likely to surface as a confusing test failure in the future. Consider opening a GitHub issue for tracking the devDependency upgrade and referencing it in the comment (e.g. Minor: lower peer-dep bound may be over-broad (pre-existing)The SummaryThe core change is correct and elegantly minimal. No blockers — the observations above are improvements to consider as follow-ups. |
| const report = reports[0]!; | ||
| // Note: Sentry v10 no longer sets report.tags.transaction automatically. | ||
| // Remove this assertion when upgrading devDependency. | ||
| expect(report.tags.transaction).toBe(spanName); |
There was a problem hiding this comment.
This comment documents known v10 breakage but is easy to overlook when upgrading. Consider referencing a GitHub issue here so it doesn't get lost:
| expect(report.tags.transaction).toBe(spanName); | |
| // TODO: Sentry v10 no longer sets report.tags.transaction automatically. | |
| // Remove this assertion when upgrading devDependency (open a tracking issue). | |
| expect(report.tags.transaction).toBe(spanName); |
Alternatively, open a follow-up issue now and reference its number so the cleanup is tracked.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/react-on-rails-pro-node-renderer/src/integrations/sentry.ts`:
- Line 13: The current property type uses Parameters<typeof Sentry.startSpan>[0]
which breaks TS for `@sentry/node` v5–6 where startSpan doesn't exist; update the
declaration (sentry?: ...) to either narrow the peer dependency to ">=7.0.0
<11.0.0" or make the type compatible with older Sentry by widening it (e.g., use
a safe union/alias like unknown | Sentry.SpanLike or a conditional/fallback type
that falls back to any/unknown when Sentry.startSpan is not present) so
TypeScript consumers on v5–6 no longer error; refer to the existing symbol
sentry and the Sentry.startSpan reference when making the change.
In `@packages/react-on-rails-pro-node-renderer/tests/shared/tracing.test.ts`:
- Around line 49-51: The test currently assumes report.tags.transaction exists
and asserts expect(report.tags.transaction).toBe(spanName); — change this to
first check for the tag's existence on report (e.g., if (report.tags &&
'transaction' in report.tags) ...) and only then assert equality to spanName;
otherwise skip or assert undefined/absent to support Sentry v8+ span-centric
behavior, updating the assertion around the report and spanName symbols.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
CHANGELOG.mdpackage.jsonpackages/react-on-rails-pro-node-renderer/package.jsonpackages/react-on-rails-pro-node-renderer/src/integrations/sentry.tspackages/react-on-rails-pro-node-renderer/tests/shared/tracing.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/react-on-rails-pro-node-renderer/package.json
- CHANGELOG.md
| declare module '../shared/tracing.js' { | ||
| interface UnitOfWorkOptions { | ||
| sentry?: StartSpanOptions; | ||
| sentry?: Parameters<typeof Sentry.startSpan>[0]; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# Find and read the package.json for the sentry integration
find . -name "package.json" -path "*react-on-rails-pro-node-renderer*" | head -5Repository: shakacode/react_on_rails
Length of output: 124
🏁 Script executed:
# Search for peer dependency declarations related to sentry
rg -A5 -B5 "@sentry/node" --type json | head -50Repository: shakacode/react_on_rails
Length of output: 3720
🏁 Script executed:
# Check the actual file context around line 13
cat -n packages/react-on-rails-pro-node-renderer/src/integrations/sentry.ts | head -30Repository: shakacode/react_on_rails
Length of output: 930
🌐 Web query:
Sentry @sentry/node startSpan API availability version history 5 6 7 8 9 10
💡 Result:
@sentry/node startSpan(...) API availability (major versions 5 → 10)
@sentry/node major |
Sentry.startSpan(...) available? |
Notes / what to use instead |
|---|---|---|
| 5.x | No | Manual tracing guidance was Sentry.startTransaction() + transaction.startChild(); older hub.startSpan existed for some APM-era/manual instrumentation but was being moved away from in favor of startTransaction workflows. [1] |
| 6.x | No | Public manual tracing is still centered on Sentry.startTransaction() (and span children off the transaction). Example reports/issues for @sentry/node 6.18.2 discuss startTransaction usage rather than startSpan. [2] |
| 7.x | Yes | Sentry.startSpan is present (e.g., exported by @sentry/node at least as early as 7.91.0). [3] In later 7.x, Sentry began deprecating the old model (startTransaction, span.startChild) in favor of startSpan, startSpanManual, startInactiveSpan. [4] |
| 8.x | Yes | New tracing model is the headline change in v8; startSpan/startSpanManual/startInactiveSpan are the primary manual APIs, and Sentry notes these APIs were already available in 7.x to allow incremental migration. [5] |
| 9.x | Yes | startSpan remains part of the public API surface (it’s exported from @sentry/core in v9 and re-exported by SDKs). Example: @sentry/browser 9.23.0 exports startSpan from @sentry/core (same core surface that @sentry/node builds on). [6] |
| 10.x | Yes | @sentry/node continues to re-export startSpan, startSpanManual, and startInactiveSpan from @sentry/core (example: @sentry/node 10.26.0 type entrypoint). [7] |
Practical takeaway
- If you’re on @sentry/node 5 or 6: you generally don’t have
Sentry.startSpan—usestartTransaction+startChild. [1][2] - If you’re on 7+:
Sentry.startSpanis available (and is the forward path). [3][5]
Sources:
[1] (newreleases.io)
[2] (github.com)
[3] (app.unpkg.com)
[4] (docs.sentry.dev)
[5] (docs.sentry.io)
[6] (app.unpkg.com)
[7] (app.unpkg.com)
Citations:
- 1: https://newreleases.io/project/npm/%40sentry/node/release/5.16.0?utm_source=openai
- 2: startTransaction method no longer returning transaction getsentry/sentry-javascript#4731
- 3: https://app.unpkg.com/%40sentry/node%407.91.0/files/cjs/index.js.map?utm_source=openai
- 4: https://docs.sentry.dev/platforms/javascript/migration/v7-to-v8/v7-deprecations/?utm_source=openai
- 5: https://docs.sentry.io/platforms/javascript/guides/tanstackstart-react/migration/v7-to-v8/v8-new-performance-api?utm_source=openai
- 6: https://app.unpkg.com/%40sentry/browser%409.23.0/files/build/npm/types/index.d.ts?utm_source=openai
- 7: https://app.unpkg.com/%40sentry/node%4010.26.0/files/build/types/index.d.ts?utm_source=openai
Update type to support Sentry 5–6 compatibility or narrow the peer dependency range.
Sentry.startSpan does not exist in @sentry/node versions 5 and 6—it was introduced in v7. The peer range >=5.0.0 <11.0.0 includes 5 and 6, so TypeScript consumers on those versions will fail type-checking. Either:
- Narrow the peer dependency to
>=7.0.0 <11.0.0, or - Use a conditional type or fallback to support the broader range.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/react-on-rails-pro-node-renderer/src/integrations/sentry.ts` at line
13, The current property type uses Parameters<typeof Sentry.startSpan>[0] which
breaks TS for `@sentry/node` v5–6 where startSpan doesn't exist; update the
declaration (sentry?: ...) to either narrow the peer dependency to ">=7.0.0
<11.0.0" or make the type compatible with older Sentry by widening it (e.g., use
a safe union/alias like unknown | Sentry.SpanLike or a conditional/fallback type
that falls back to any/unknown when Sentry.startSpan is not present) so
TypeScript consumers on v5–6 no longer error; refer to the existing symbol
sentry and the Sentry.startSpan reference when making the change.
| // Note: Sentry v10 no longer sets report.tags.transaction automatically. | ||
| // Remove this assertion when upgrading devDependency. | ||
| expect(report.tags.transaction).toBe(spanName); |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
🧩 Analysis chain
🏁 Script executed:
cd packages/react-on-rails-pro-node-renderer && find . -type f -name "tracing.test.ts"Repository: shakacode/react_on_rails
Length of output: 1730
🏁 Script executed:
# Search for test file to understand its full context
rg -l "tracing.test.ts" --type tsRepository: shakacode/react_on_rails
Length of output: 50
🏁 Script executed:
# Check if the file exists and read it
cat packages/react-on-rails-pro-node-renderer/tests/shared/tracing.test.ts 2>/dev/null | head -100Repository: shakacode/react_on_rails
Length of output: 2218
🌐 Web query:
Sentry @sentry/node v10 release notes tags.transaction automatic
💡 Result:
- @sentry/node v10 (10.0.0) release notes: there’s no mention of any change related to
tags.transactionor “automatictransactiontag” behavior; v10 is primarily an OpenTelemetry v2 upgrade plus other unrelated breaking changes. [1] - What
tags.transactionis: it’s an Ownership Rules matcher type which matches against the event’stransactiontag (shown in rule examples astags.transaction:/checkout/:page ...). [2] - Where it comes from / “automatic”: the JavaScript/Node SDKs generally attach a transaction name to events via the scope (the scope’s “transaction name” is “attached to future events”, and SDKs often set it automatically during navigations/requests). [3] Also, errors are tied to the currently active span when one exists, which is the typical way the SDK knows what transaction it’s in. [4]
Sources: [1] [2] [3] [4]
🌐 Web query:
Sentry v7 vs v10 transaction tags behavior changelog
💡 Result:
For Sentry JavaScript SDKs (the @sentry/* v7 → v10 line), “transaction tags” behavior effectively changed as Sentry moved from a transaction-centric model to a span-centric (OpenTelemetry-based) model.
What changed (v7 → v10), chronologically
v7 (late v7.x): “transaction APIs” start getting deprecated
- The classic performance API
startTransaction()(andhub.startTransaction()) was deprecated in v7 and slated for removal, in favor of the newer span APIs (startSpan,startSpanManual,startInactiveSpan). This is the start of the shift away from treating “transactions” as the primary object you enrich. [1] - In practice, this is when patterns like
getActiveTransaction()?.setTag(...)start becoming “the old way”.
v8+: transactions become “conceptually gone” in the SDK → tags move to span attributes
- With the OpenTelemetry-based model, you “operate on spans” and Sentry may still group spans into a transaction in the UI, but that grouping is transparent and not the primary SDK surface anymore. [2]
- As a result, “additional data / tags” you attach during execution is often visible on spans rather than on the “transaction” summary the way it used to be. Sentry explicitly calls this out: the product focus moved to showing data per-span instead of per-transaction. [2]
v10: no new “transaction tags” semantics (mostly dependency upgrade)
- The v9 → v10 migration is described as primarily upgrading OpenTelemetry dependencies to v2 with minimal breaking changes, i.e., it does not reintroduce transaction-tag behavior from old v7 patterns. [3]
Practical implication (“behavior changelog” in one line)
- v7 (old model): you could think “transaction + transaction tags”.
- v8–v10 (current model): think “root span + span attributes”; “transaction tags” are no longer a first-class concept, and the UI increasingly emphasizes span-level data. [2]
Sources: v7 deprecations / tracing API changes [1], Sentry support note on spans vs transactions display behavior [2], v9→v10 migration scope [3].
References:
[1] Deprecations in 7.x (v7→v8) https://docs.sentry.dev/platforms/javascript/migration/v7-to-v8/v7-deprecations/
[2] Sentry Help Center: “Why is additional data showing on spans but not on transactions?” https://sentry.zendesk.com/hc/en-us/articles/25981252414875-Why-is-additional-data-showing-on-spans-but-not-on-transactions
[3] v9→v10 migration guide (example: SvelteKit, but describes SDK v10 focus) https://docs.sentry.io/platforms/javascript/guides/sveltekit/migration/v9-to-v10
Make the assertion conditional to handle Sentry's span-centric model in v8+.
The comment correctly identifies that newer Sentry versions (v8+, including v10) have moved from a transaction-centric to a span-centric (OpenTelemetry-based) architecture. In this model, tags.transaction is no longer a first-class concept on events. Rather than deferring this with a TODO, conditionally check for the tag's presence now:
Proposed test update
- // Note: Sentry v10 no longer sets report.tags.transaction automatically.
- // Remove this assertion when upgrading devDependency.
- expect(report.tags.transaction).toBe(spanName);
+ // In Sentry v8+, the SDK uses a span-centric model; transaction tags may be absent.
+ if (report.tags?.transaction !== undefined) {
+ expect(report.tags.transaction).toBe(spanName);
+ }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/react-on-rails-pro-node-renderer/tests/shared/tracing.test.ts`
around lines 49 - 51, The test currently assumes report.tags.transaction exists
and asserts expect(report.tags.transaction).toBe(spanName); — change this to
first check for the tag's existence on report (e.g., if (report.tags &&
'transaction' in report.tags) ...) and only then assert equality to spanName;
otherwise skip or assert undefined/absent to support Sentry v8+ span-centric
behavior, updating the assertion around the report and spanName symbols.
AbanoubGhadban
left a comment
There was a problem hiding this comment.
Reviewed thoroughly — approving.
The core change is correct. Replacing import { StartSpanOptions } from '@sentry/types' with Parameters<typeof Sentry.startSpan>[0] eliminates the dependency on a package that's no longer transitively available in Sentry v9+. I verified locally that the emitted .d.ts preserves the Parameters<...> expression and resolves against @sentry/node (not @sentry/types), so customers on v9/v10 get correct types.
CodeRabbit's "Critical" about v5/v6 breakage is a false positive — sentry.ts was never usable with v5/v6 (it calls Sentry.startSpan() at runtime, which doesn't exist in those versions). Those users use sentry6.ts. The peer dep range covers both integration files.
Two small requests before merge:
- Link the issue: Add "Closes #2294" to the PR body so it auto-closes.
- Test TODO tracking: The comment at
tracing.test.ts:48-49about removing thereport.tags.transactionassertion when upgrading to v10 — consider opening a follow-up issue and referencing it in the comment so it doesn't get lost.
Neither is a blocker.
## Summary - Replace `@sentry/types` import with `Parameters<typeof Sentry.startSpan>[0]` to avoid depending on `@sentry/types`, which is no longer a transitive dependency of `@sentry/node` in v9+ - Widen `@sentry/node` peer dependency from `<9.0.0` to `<11.0.0` - Add note about test assertion that needs updating when devDependency is upgraded to Sentry v10 Closes #2294. ## Test plan - [x] TypeScript type check passes with current v7 devDependency - [x] `tests/shared/tracing.test.ts` passes - [x] Manually verified type check and tracing tests pass with Sentry v10 devDependency 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Broadened Sentry integration peer dependency compatibility. * Added root-level metadata entries in the package manifest. * **Improvements** * Improved type handling for Sentry configuration options. * **Tests** * Added clarifying comments in tracing tests about Sentry version behavior. * **Documentation** * Added changelog note describing Sentry SDK compatibility updates. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Alexey Romanov <[email protected]>
Summary
@sentry/typesimport withParameters<typeof Sentry.startSpan>[0]to avoid depending on@sentry/types, which is no longer a transitive dependency of@sentry/nodein v9+@sentry/nodepeer dependency from<9.0.0to<11.0.0Closes #2294.
Test plan
tests/shared/tracing.test.tspasses🤖 Generated with Claude Code
Summary by CodeRabbit
Chores
Improvements
Tests
Documentation