Skip to content

refactor(ios): remove dead SentrySDKWrapper init surface#6059

Merged
antonis merged 5 commits intomainfrom
antonis/cleanup-sentrysdkwrapper-deadcode
Apr 29, 2026
Merged

refactor(ios): remove dead SentrySDKWrapper init surface#6059
antonis merged 5 commits intomainfrom
antonis/cleanup-sentrysdkwrapper-deadcode

Conversation

@antonis
Copy link
Copy Markdown
Contributor

@antonis antonis commented Apr 28, 2026

📢 Type of change

  • Refactoring

📜 Description

SentrySDKWrapper.createOptionsWithDictionary:isSessionReplayEnabled:error: and friends became unreachable from production when v8 moved init to RNSentryStart in #5582 (sub-PR #4442), but were left in place along with their parallel XCTest suite. Those dead-code tests are the reason two bugs shipped in every 8.x release until we noticed them — #5611's author added profiling parsing to SentrySDKWrapper because the tests there made it look like the live surface, and the tests kept passing while the live RNSentryStart path silently dropped the option (#6012, #6014).

This PR removes the dead surface so the same mistake can't recur:

packages/core/ios/SentrySDKWrapper.{h,m} — delete:

  • + createOptionsWithDictionary:isSessionReplayEnabled:error:
  • + setupWithDictionary:isSessionReplayEnabled:error:
  • + startWithOptions: (only callsite was the deleted setupWithDictionary:)
  • + enableAutoSessionTracking (zero callers in packages/core/)
  • + enableWatchdogTerminationTracking (zero callers in packages/core/)
  • the now-orphaned getURLFromDSN: helper and unused imports

Kept (still called 18 times from RNSentry.mm): configureScope:, crash, close, crashedLastRun, debug, releaseName.

packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m — 22 SentrySDKWrapper-based tests deleted (each had an existing RNSentryStart-based equivalent: spotlight, native crash handling, auto-perf tracing, breadcrumb filtering, CPP exceptions v2, testRemovesPerformanceProperties, etc.). 15 still-relevant tests migrated to RNSentryStart-based equivalents under the existing #pragma mark - RNSentryStart Tests block:

  • enableLogs enabled / disabled (2)
  • beforeBreadcrumb keeps-when-no-devServer edge case (1)
  • ignoreErrors family (5)
  • beforeSend JS-exception / CPP-exception filtering (2) — these now also call [RNSentryStart updateWithReactFinals:] so the full two-layer beforeSend chain is exercised, which is stronger coverage than the old tests (the wrapped outer filter wasn't in the old SentrySDKWrapper path).
  • enableSessionReplayInUnreliableEnvironment Default / WithErrorSampleRate / WithSessionSampleRate / WithSessionSampleRates / Disabled (5) — drops the explicit isSessionReplayEnabled: parameter; RNSentryStart.createOptionsWithDictionary: computes it internally via [RNSentryReplay updateOptions:] on its mutable copy, driven by the same replays*SampleRate keys the fixtures already pass.

#import "SentrySDKWrapper.h" removed from the test file. Class RNSentryInitNativeSdkTests retained (could be renamed in a follow-up since it's no longer init-only, but that's bikeshed). Tests for setEventOriginTag, fetchNativeStackFramesBy, and user creation that don't touch SentrySDKWrapper are unmodified.

Net diff: −582 lines.

💡 Motivation and Context

Closes #6015. Companion to #6012 and #6014, which fixed two real bugs caused by code being added to this dead surface. The cleanup removes the conditions that allowed those bugs to ship undetected — the tests on the dead path will no longer make the wrong file look "tested."

SentrySDKWrapper.h is not in s.public_header_files in packages/core/RNSentry.podspec (only RNSentry.h, RNSentrySDK.h, RNSentryStart.h, RNSentryVersion.h, RNSentryBreadcrumb.h, RNSentryReplay.h, RNSentryReplayBreadcrumbConverter.h, Replay/RNSentryReplayMask.h, Replay/RNSentryReplayUnmask.h, RNSentryTimeToDisplay.h are). The deleted methods are not exposed to downstream Swift/Obj-C consumers, so no API break.

💚 How did you test it?

  • Searched the entire repo (samples, performance-tests, expo plugin, Swift test suites, sample apps' AppDelegate.swift) for any reference to the deleted methods or to SentrySDKWrapper.setupWithDictionary — zero hits.
  • Grepped CHANGELOG / README / MIGRATION / CONTRIBUTING / CLAUDE.md for the deleted symbols — only matches are user-facing SentryOptions.enableAutoSessionTracking / enableWatchdogTerminationTracking documentation, which is unrelated to the deleted accessor wrappers.
  • Verified the 22 deletions are duplicate-of-existing by spot-checking pairs (e.g., testCreateOptionsWithDictionaryRemovesPerformancePropertiestestStartWithDictionaryRemovesPerformanceProperties): semantically equivalent, both pin the user-visible behavior.
  • Verified the 15 migrations preserve coverage: replay tests still drive RNSentryReplay.updateOptions: via the same dict keys; beforeSend filter tests now exercise the full prepareOptions + updateWithReactFinals chain.
  • Local: yarn build, yarn test (211 passing), yarn circularDepCheck, ./scripts/clang-format.sh lint, yarn lint (full suite — oxlint, prettier, lerna, android, kotlin, clang, swift) all clean. Cocoa XCTest run is delegated to CI (local has a pre-existing fmt-pod / Xcode 22 compatibility issue unrelated to this change).

📝 Checklist

  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing
  • No breaking changes

🔮 Next steps

`SentrySDKWrapper.createOptionsWithDictionary:isSessionReplayEnabled:error:`
(and `setupWithDictionary:`, `startWithOptions:`, `enableAutoSessionTracking`,
`enableWatchdogTerminationTracking`) became dead when v8 moved init to
`RNSentryStart` (#5582 / #4442). The dead methods had a parallel test suite
that kept passing, which is exactly how the bugs in #6012 and #6014 shipped:
new code was added to `SentrySDKWrapper` because the tests there made it look
like the live surface.

Delete the dead methods, migrate the still-relevant test coverage to
`RNSentryStart`-based tests, drop duplicate tests already pinned on
`RNSentryStart`. `SentrySDKWrapper.h` is not in the podspec's
`public_header_files`, so no downstream consumers are affected. The kept
methods (`configureScope:`, `crash`, `close`, `crashedLastRun`, `debug`,
`releaseName`) continue to be used from `RNSentry.mm`.

Closes #6015.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sentry
Copy link
Copy Markdown

sentry Bot commented Apr 28, 2026

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
Sentry RN io.sentry.reactnative.sample 8.9.2 (85) Release

⚙️ sentry-react-native Build Distribution Settings

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

iOS (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1217.57 ms 1214.21 ms -3.37 ms
Size 3.38 MiB 4.78 MiB 1.39 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
7ac3378+dirty 1213.37 ms 1218.15 ms 4.78 ms
4b87b12+dirty 1212.90 ms 1222.09 ms 9.19 ms
890d145+dirty 1223.59 ms 1231.37 ms 7.78 ms
0d9949d+dirty 1211.38 ms 1219.67 ms 8.29 ms
04207c4+dirty 1191.27 ms 1189.78 ms -1.48 ms
3ce5254+dirty 1219.93 ms 1221.90 ms 1.96 ms
4953e94+dirty 1212.06 ms 1214.83 ms 2.77 ms
2c735cc+dirty 1229.67 ms 1221.50 ms -8.17 ms
a50b33d+dirty 1197.74 ms 1197.17 ms -0.57 ms
df5d108+dirty 1225.90 ms 1220.14 ms -5.76 ms

App size

Revision Plain With Sentry Diff
7ac3378+dirty 3.38 MiB 4.76 MiB 1.38 MiB
4b87b12+dirty 3.38 MiB 4.77 MiB 1.39 MiB
890d145+dirty 3.38 MiB 4.77 MiB 1.38 MiB
0d9949d+dirty 3.38 MiB 4.76 MiB 1.38 MiB
04207c4+dirty 3.38 MiB 4.76 MiB 1.38 MiB
3ce5254+dirty 3.38 MiB 4.76 MiB 1.38 MiB
4953e94+dirty 3.38 MiB 4.73 MiB 1.35 MiB
2c735cc+dirty 3.38 MiB 4.74 MiB 1.35 MiB
a50b33d+dirty 3.38 MiB 4.73 MiB 1.35 MiB
df5d108+dirty 3.38 MiB 4.73 MiB 1.35 MiB

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

iOS (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1219.26 ms 1224.71 ms 5.45 ms
Size 3.38 MiB 4.78 MiB 1.39 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
7ac3378+dirty 1202.35 ms 1198.31 ms -4.04 ms
4b87b12+dirty 1199.49 ms 1199.78 ms 0.29 ms
890d145+dirty 1212.98 ms 1220.10 ms 7.12 ms
0d9949d+dirty 1203.94 ms 1202.27 ms -1.67 ms
04207c4+dirty 1228.55 ms 1226.04 ms -2.51 ms
3ce5254+dirty 1217.70 ms 1224.69 ms 6.99 ms
4953e94+dirty 1217.41 ms 1223.53 ms 6.12 ms
2c735cc+dirty 1223.33 ms 1224.38 ms 1.04 ms
a50b33d+dirty 1207.11 ms 1212.10 ms 5.00 ms
df5d108+dirty 1207.34 ms 1210.50 ms 3.16 ms

App size

Revision Plain With Sentry Diff
7ac3378+dirty 3.38 MiB 4.76 MiB 1.38 MiB
4b87b12+dirty 3.38 MiB 4.77 MiB 1.39 MiB
890d145+dirty 3.38 MiB 4.77 MiB 1.38 MiB
0d9949d+dirty 3.38 MiB 4.76 MiB 1.38 MiB
04207c4+dirty 3.38 MiB 4.76 MiB 1.38 MiB
3ce5254+dirty 3.38 MiB 4.76 MiB 1.38 MiB
4953e94+dirty 3.38 MiB 4.73 MiB 1.35 MiB
2c735cc+dirty 3.38 MiB 4.74 MiB 1.35 MiB
a50b33d+dirty 3.38 MiB 4.73 MiB 1.35 MiB
df5d108+dirty 3.38 MiB 4.73 MiB 1.35 MiB

@antonis antonis removed the ready-to-merge Triggers the full CI test suite label Apr 28, 2026
The migration in the previous commit added a `testStart…KeepsBreadcrumbWhenDevServerUrlIsNotPassed…`
method that already existed in the `RNSentryStart Tests` block. Compile failed
in CI with "Duplicate declaration of method". The earlier
`@interface RNSentryStart Tests` already covers this scenario; the migrated
copy is redundant.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
antonis and others added 3 commits April 28, 2026 15:08
…Message

Warden flagged the migrated tests using `[SentryException alloc]` and
`[SentryMessage alloc]` without `init`. Both classes have `SENTRY_NO_INIT`
and require designated initializers (`initWithValue:type:` and
`initWithFormatted:`), so the alloc-only pattern is undefined behavior —
property assignments happened to work via zero-initialized memory but
the test could crash or behave inconsistently and mask real regressions.

The pattern was inherited from the original SentrySDKWrapper-based tests
this PR migrated; same fix applied across all 12 occurrences.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ysdkwrapper-deadcode

# Conflicts:
#	packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m
#	packages/core/ios/SentrySDKWrapper.h
#	packages/core/ios/SentrySDKWrapper.m
@antonis antonis added the ready-to-merge Triggers the full CI test suite label Apr 28, 2026
@antonis antonis marked this pull request as ready for review April 28, 2026 15:01
Copy link
Copy Markdown
Collaborator

@lucas-zimerman lucas-zimerman left a comment

Choose a reason for hiding this comment

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

LGTM!

@antonis antonis merged commit 3b471f5 into main Apr 29, 2026
109 of 134 checks passed
@antonis antonis deleted the antonis/cleanup-sentrysdkwrapper-deadcode branch April 29, 2026 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Triggers the full CI test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delete abandoned SentrySDKWrapper init surface and migrate tests to RNSentryStart

2 participants