fix(core): Hide dataCollection option until supported in React Native#6345
Conversation
The dataCollection option is exposed by @sentry/core but is not yet honored by the native SDKs (iOS/Android) nor by the RN-specific sendDefaultPii gates (IP inference, deep links, navigation params), so setting it would silently have no effect. Omit it from the public options types until full support lands; users should use sendDefaultPii. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog.
🤖 This preview updates automatically when you update the PR. |
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| * @see ReactNativeFrontend for more information. | ||
| */ | ||
|
|
||
| // `dataCollection` is omitted until the option is fully supported in React Native. It is exposed by |
There was a problem hiding this comment.
Bug: The dataCollection option is hidden from TypeScript but can still be passed at runtime. It is ignored by React Native specific logic, which still uses sendDefaultPii, leading to silent misconfiguration.
Severity: MEDIUM
Suggested Fix
To fully prevent usage, the dataCollection property should be explicitly destructured and removed from the options object at runtime in wrapper.ts before the remaining options are passed to initNativeSdk. This ensures it is not passed to the core SDK or native layers, preventing the partial, confusing behavior.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: packages/core/src/js/options.ts#L515
Potential issue: Hiding the `dataCollection` option from TypeScript types using `Omit`
is a compile-time-only change. At runtime, users can still provide this option. The
option is passed to the core SDK but is ignored by React Native-specific data-gating
logic (e.g., for IP addresses, deep links), which continues to read the `sendDefaultPii`
option. This discrepancy can lead to silent failures where a user's data privacy
settings in `dataCollection` are not respected by the React Native layer, causing
unintended data to be sent if `sendDefaultPii` is also configured.
Did we get this right? 👍 / 👎 to inform future reviews.
📢 Type of change
📜 Description
Omits the
dataCollectionoption from the public RN options types (ReactNativeOptions/ReactNativeClientOptions) by adding it to the existingOmit<…>on the inherited@sentry/coreOptions/ClientOptions.dataCollectionwas introduced upstream in@sentry/corev10 as the granular replacement for the (now deprecated)sendDefaultPii, and it is inherited into the RN options type surface automatically with the JS SDK bump to 10.60.0. However, it is not wired up in React Native:sendDefaultPiiacross the bridge; they do not understanddataCollection.sendDefaultPiiand ignore core's resolved data-collection settings — e.g.infer_ipmetadata andaddAutoIpAddressToSession(client.ts), and the URL/route-param gating inreactnavigation.ts,expoRouter.ts, anddeeplink.ts.So a user who set
dataCollectionwould get a silent partial no-op: native and the RN JS gates would not honor it. Hiding it keeps the option surface honest until full support lands. Users should continue to usesendDefaultPii.💡 Motivation and Context
Spotted while reviewing the JS SDK bump to 10.60.0. The bump auto-exposes
dataCollectionin the RN types even though no layer honors it, which would be a silent footgun. This is the low-risk interim move; fulldataCollectionsupport (native + the RN JS gates) is tracked separately and the option will be re-exposed there.💚 How did you test it?
yarn build:sdkpassesyarn api-reportregenerated — only change is theOmitonReactNativeOptions📝 Checklist
sendDefaultPIIis enabled🔮 Next steps
dataCollectiononce the native SDKs and the RN-specificsendDefaultPiigates support it.