Skip to content

React Native SDK: expose private APIs via public methods #7881

@alwx

Description

@alwx

Problem Statement

⚠️ All the analysis is based on this PR #7598 and not on the code that's currently in main branch.

That was all detected as part of the ongoing initiative to migrate to SPM.

To fully decouple from <Sentry/PrivateSentrySDKOnly.h> and the ${PODS_ROOT}/Sentry/Sources/Sentry/include header search path (both are required to be done to consume sentry-cocoa as an xcframework or via SPM binaryTarget) we need

  1. 22 missing APIs to be exposed publicly (see list below) either via PrivateSentrySDKOnly.h or any other way (@philprime had an idea of introducing SentrySDK.internal.<api>)
  2. locally vendor sentry_formatHexAddress* helpers (done here: Locally vendor sentry_formatHexAddress* helpers sentry-react-native#6112) — simply because those are general 1-2 line functions and it makes no sense to expose them publicly
  3. SentryDefines.h macros (SENTRY_NO_INIT, etc.) are reachable from the new ObjC wrapper headers

Here are the missing APIs:

  1. +[PrivateSentrySDKOnly optionsWithDictionary:didFailWithError:] (used at RNSentrySDK.m:63 and RNSentryStart.m:50 to construct SentryOptions from a JS-side options dictionary)
  2. +[PrivateSentrySDKOnly addSdkPackage:version:] (used at RNSentryStart.m:26)
  3. PrivateSentrySDKOnly.appStartMeasurementHybridSDKMode (used at RNSentryStart.m:217)
  4. PrivateSentrySDKOnly.framesTrackingMeasurementHybridSDKMode (used at RNSentryStart.m:221)
  5. PrivateSentrySDKOnly.currentScreenFrames (+ .total, .frozen, .slow) (used at SentryScreenFramesWrapper.m:10, 18, 26, 34)
  6. PrivateSentrySDKOnly.isFramesTrackingRunning (used at RNSentry.mm:523)
  7. +[PrivateSentrySDKOnly appStartMeasurementWithSpans] (used at RNSentry.mm:497)
  8. class SentryAppStartMeasurement (used at RNSentry.mm:22 as #import)
  9. +[PrivateSentrySDKOnly startProfilerForTrace:] (used at RNSentry.mm:975)
  10. +[PrivateSentrySDKOnly discardProfilerForTrace:] (used at RNSentry.mm:989, 1001, 1078, 1090)
  11. +[PrivateSentrySDKOnly collectProfileBetween:and:forTrace:] (used at RNSentry.mm:1021)
  12. +[PrivateSentrySDKOnly envelopeWithData:] (used at RNSentry.mm:575)
  13. +[PrivateSentrySDKOnly captureScreenshots] (used at RNSentry.mm:598)
  14. +[PrivateSentrySDKOnly captureViewHierarchy] (used at RNSentry.mm:631)
  15. +[PrivateSentrySDKOnly getExtraContext] (used at RNSentry.mm:407, 459)
  16. +[PrivateSentrySDKOnly setCurrentScreen:] (used at RNSentry.mm:722)
  17. +[PrivateSentrySDKOnly setRedactContainerClass:] (used at RNSentryReplay.mm:72)
  18. +[PrivateSentrySDKOnly setIgnoreContainerClass:] (used at RNSentryReplay.mm:73)
  19. +[PrivateSentrySDKOnly configureSessionReplayWith:screenshotProvider:] (used at RNSentryReplayBreadcrumbConverterHelper.m:12)
  20. +[PrivateSentrySDKOnly getReplayIntegration] (used at RNSentry.mm:819-823)
  21. +[PrivateSentrySDKOnly captureReplay] (used at RNSentry.mm:840)
  22. +[PrivateSentrySDKOnly getReplayId] (used at RNSentry.mm:841, 858, 948)

Extra information:

  • The new public SentryOptions has no public initializer at all — no +new, no -init…, no dict-based factory. The only construction path is SentryObjCSDK.startWithConfigureOptions:. As a workaround, we can manually iterate our JS dict inside the configure block and set each property individually.

Solution Brainstorm

No response

Are you willing to submit a PR?

No response

Metadata

Metadata

Assignees

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions