Skip to content

feat: DataCollection now configures the native Android SDK, and UserInfo the native Cocoa SDK - #5960

Open
jamescrosswell wants to merge 1 commit into
mainfrom
ai/dc-5436-native-dd61b7
Open

jamescrosswell wants to merge 1 commit into
mainfrom
ai/dc-5436-native-dd61b7

Conversation

@jamescrosswell

Copy link
Copy Markdown
Collaborator

When an app calls ConfigureDataCollection(...), the native SDKs now follow it too.

  • Android: every category .NET has goes onto sentry-java's DataCollection: UserInfo, Cookies, HttpHeaders.Request / .Response, UrlQueryParams (mode and terms), HttpBodies (each of the four body types), and GraphQL.Document / .Variables.
  • iOS and Mac Catalyst: the resolved UserInfo goes to Cocoa as sendDefaultPii. sentry-cocoa 9.x has no data collection option to map onto (see the notes), and user info is the only thing 9.x gates on sendDefaultPii.

Apps that never call ConfigureDataCollection see no change. Both platforms forward only SendDefaultPii, as before, and Java's DataCollection is left unset.

Part of #5420 (Phase 2).

Closes #5436

Behaviour

  • Not configured: unchanged. Android forwards SendDefaultPii and Java's DataCollection.isExplicitlyConfigured() stays false. Cocoa gets SendDefaultPii.
  • ConfigureDataCollection(...) called: Android still forwards SendDefaultPii, but Java's resolver ignores it for every category this sets. Cocoa gets UserInfo as sendDefaultPii. So an app that opts in with the spec defaults and SendDefaultPii = false now gets userInfo = true natively too: both native SDKs infer the IP address for native events, and Cocoa adds the installation ID as the user ID on native logs and metrics.

Notes for review

  • sentry-cocoa 9.x doesn't ship dataCollection, so there was nothing to bind. It arrived in 9.22.0 (feat: Add dataCollection option and types sentry-cocoa#8369) and went behind the SDK_V10 compile flag in 9.23.0 (ref(data-collection)!: gate APIs to SDK V10 sentry-cocoa#8435). In 9.35.0 the SentryObjCDataCollection* headers, SentryObjCOptions.dataCollection and the Swift SentryDataCollection core are all inside #if SDK_V10. build-sentry-cocoa.sh doesn't define it, and nm finds no DataCollection symbol in the framework we ship. patch-cocoa-bindings.cs and the generated bindings are unchanged. Defining SDK_V10 would switch the whole Cocoa SDK to its next major.
    • In 9.x, sendDefaultPii gates three things: IP inference (SentrySdkInfo) and the installation-ID user on logs (SentryClient) and on metrics (SentryMetricsIntegration). V10 replaces each of those reads with dataCollection.userInfo, so forwarding UserInfo there is what V10 would do.
    • Nothing else has a 9.x counterpart. Cocoa's own NSURLSession failed-request capture (on when CaptureFailedRequests is) applies its fixed header and URL sanitising, whatever Cookies, HttpHeaders or UrlQueryParams say. Binding the real types can follow once the Cocoa SDK we ship is V10.
  • userInfo is always set explicitly on Android. In sentry-java, setting any DataCollection field makes an unset userInfo resolve to true. A test covers UserInfo = false with SendDefaultPii = true.
  • Java categories with no .NET counterpart keep Java's defaults once configured. filePaths resolves to true. It gates file paths on spans from SentryFileInputStream / SentryFileOutputStream. databaseQueryData also resolves to true, and nothing in sentry-java 8.64.0 reads it. The mapping updates Java's DataCollection in place rather than replacing it, so values set through AndroidManifest.xml metadata survive. DatabaseQueryData isn't mapped from .NET, because ref: remove the experimental DataCollectionOptions.DatabaseQueryData until .NET collects query data #5933 removes it.
  • GenAI has no Java or Cocoa counterpart. It only gates Sentry.Extensions.AI, which is managed code.
  • Session Replay is untouched (DataCollection: Session Replay must not be gated by DataCollection (spec 0.10.0) #5852). On both platforms a test sets non-default replay options, applies a DataCollection with every category off, and checks that the replay options haven't changed.
  • Like every other native option, the native SDKs read this once, in SentrySdk.Init. Later changes to DataCollection reach only the managed integrations.
  • The Android installation-ID fallback for user.id / device.id isn't governed by data collection in sentry-java, so this doesn't change it.

🤖 Generated with Claude Code

When an app calls ConfigureDataCollection, map the configured categories
onto sentry-java's DataCollection, setting userInfo explicitly so Java
doesn't default it to true. sentry-cocoa 9.x only ships dataCollection in
SDK V10, so Cocoa gets the resolved UserInfo as sendDefaultPii, which is
the only thing 9.x gates on it. Apps that don't opt in still forward only
SendDefaultPii.

Refs #5436

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.70%. Comparing base (04c1c8d) to head (41a378c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5960   +/-   ##
=======================================
  Coverage   77.70%   77.70%           
=======================================
  Files         535      535           
  Lines       19731    19731           
  Branches     3934     3934           
=======================================
  Hits        15332    15332           
  Misses       3544     3544           
  Partials      855      855           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jamescrosswell

jamescrosswell commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator Author

sentry-cocoa 9.x doesn't ship dataCollection, so there was nothing to bind. It arrived in 9.22.0 (getsentry/sentry-cocoa#8369) and went behind the SDK_V10 compile flag in 9.23.0 (getsentry/sentry-cocoa#8435).

@ric-oliv sentry-cocoa v10 hasn't been released yet. So I think we look at applying the .NET data collections to the cocoa ones whenever v10 is released and when we bump to that.

@jamescrosswell
jamescrosswell marked this pull request as ready for review November 18, 2026 06:57
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 18, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DataCollection phase 2: propagate to native (Android/Cocoa)

1 participant