Repository navigation
feat: DataCollection now configures the native Android SDK, and UserInfo the native Cocoa SDK - #5960
jamescrosswell wants to merge 4 commits into
Conversation
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 Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5960 +/- ##
==========================================
- Coverage 77.70% 77.69% -0.01%
==========================================
Files 535 535
Lines 19731 19727 -4
Branches 3934 3932 -2
==========================================
- Hits 15332 15327 -5
- Misses 3544 3545 +1
Partials 855 855 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
@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. |
There was a problem hiding this comment.
Good to approve, with optional comments
Maps the resolved .NET DataCollection onto sentry-java's DataCollection and forwards UserInfo to Cocoa's sendDefaultPii. That matches what sentry-cocoa 9.35.0 gates on sendDefaultPii (SentryClient.m, SentrySdkInfo.swift, SentryMetricsIntegration.swift) and what V10 would map to userInfo. Unconfigured apps behave as before.
- Optional:
Closes #5436will close the issue, but the issue also asks for the full Cocoa mapping (bindings and categories beyonduserInfo), which this PR defers until a V10 Cocoa SDK is shipped. ConsiderPart of #5436, or open a follow-up issue, so the Cocoa work stays tracked. - Optional: on Android, once
ConfigureDataCollectionis called, Java'sfilePathsresolves totrue(DataCollectionResolver.isFilePathsin sentry-java 8.64.0). Before this PR it followedSendDefaultPii. An app withSendDefaultPii = falsethat opts in with restrictive settings now gets file paths onSentryFileInputStream/SentryFileOutputStreamspans, and .NET has no option to turn that off. It follows the spec, but consider calling it out in theConfigureDataCollectionremarks or the release note (manifest metadata is the only way to control it). - Optional: the PR title is the changelog entry. Consider having it, or the docs, mention the visible native behaviour change: with spec defaults and
SendDefaultPii = false, native IP inference and, on Cocoa, the installation-ID user on logs and metrics become enabled.
This is an automated preliminary review.
…llection sentry-java's filePaths category follows SendDefaultPii until data collection is configured, then defaults to true. .NET has no counterpart, so the manifest metadata is the only way to turn it off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The dependency updater bumps sentry-cocoa across majors. A 10.0 bump would compile once DataCollection was dropped from the bindings and the SendDefaultPii line deleted, silently enabling user info on iOS, since Cocoa 10's userInfo defaults to true. The build now fails until the CONTRIBUTING checklist for that major is done and SentryCocoaSupportedMajor is raised. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 38adb4d. Configure here.
Matches how the project already reads the submodule's .git file, so the check doesn't depend on MSBuild's working directory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Mutation testing breaks the lines a PR changes on purpose, one mutation at a time, and checks that a test fails each time. A changed line no test runs fails the check, and a mutant that survives the tests only warns. Full report Stryker didn't finish, so not every changed line was checked. The job log has the details. |

When an app calls
ConfigureDataCollection(...), the native SDKs now follow it too.DataCollection:UserInfo,Cookies,HttpHeaders.Request/.Response,UrlQueryParams(mode and terms),HttpBodies(each of the four body types), andGraphQL.Document/.Variables.UserInfogoes to Cocoa assendDefaultPii. 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 onsendDefaultPii.Apps that never call
ConfigureDataCollectionsee no change. Both platforms forward onlySendDefaultPii, as before, and Java'sDataCollectionis left unset.Part of #5420 (Phase 2).
Closes #5436
Behaviour
SendDefaultPiiand Java'sDataCollection.isExplicitlyConfigured()staysfalse. Cocoa getsSendDefaultPii.ConfigureDataCollection(...)called: Android still forwardsSendDefaultPii, but Java's resolver ignores it for every category this sets. Cocoa getsUserInfoassendDefaultPii. So an app that opts in with the spec defaults andSendDefaultPii = falsenow getsuserInfo = truenatively 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
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 theSDK_V10compile flag in 9.23.0 (ref(data-collection)!: gate APIs to SDK V10 sentry-cocoa#8435). In 9.35.0 theSentryObjCDataCollection*headers,SentryObjCOptions.dataCollectionand the SwiftSentryDataCollectioncore are all inside#if SDK_V10.build-sentry-cocoa.shdoesn't define it, andnmfinds noDataCollectionsymbol in the framework we ship.patch-cocoa-bindings.csand the generated bindings are unchanged. DefiningSDK_V10would switch the whole Cocoa SDK to its next major.sendDefaultPiigates three things: IP inference (SentrySdkInfo) and the installation-ID user on logs (SentryClient) and on metrics (SentryMetricsIntegration). V10 replaces each of those reads withdataCollection.userInfo, so forwardingUserInfothere is what V10 would do.NSURLSessionfailed-request capture (on whenCaptureFailedRequestsis) applies its fixed header and URL sanitising, whateverCookies,HttpHeadersorUrlQueryParamssay.Sentry.Bindings.Cocoanow fails the build when the submodule's major (read fromVersioning.xcconfig) differs fromSentryCocoaSupportedMajor(9), or can't be read. The dependency-update workflow opens a PR for 10.0.0 as soon as it's tagged, and that PR stops on this check. The error points to a new CONTRIBUTING section that lists what 10 needs: thedataCollectionmapping and the other V10 breaks we use.SentryObjCOptions.DataCollectionwithRemovePropertyand delete theSendDefaultPiiline. Cocoa 10'suserInfodefaults totrue, so apps withSendDefaultPii = falsewould quietly start getting IP inference.userInfois always set explicitly on Android. In sentry-java, setting anyDataCollectionfield makes an unsetuserInforesolve totrue. A test coversUserInfo = falsewithSendDefaultPii = true.filePathsgates file paths on spans fromSentryFileInputStream/SentryFileOutputStream. Before this PR it followedSendDefaultPii. OnceConfigureDataCollectionis called it resolves totrue, even withSendDefaultPii = falseand every .NET category restricted. That only shows up withNative.EnableTracingon and Java code that uses those streams. TheConfigureDataCollectionremarks now say so, and name theio.sentry.data-collection.file-pathsmanifest key that turns it off.databaseQueryDataalso resolves totrue, and nothing in sentry-java 8.64.0 reads it. The mapping updates Java'sDataCollectionin place rather than replacing it, so values set throughAndroidManifest.xmlmetadata survive.DatabaseQueryDataisn't mapped from .NET, because ref: remove the experimental DataCollectionOptions.DatabaseQueryData until .NET collects query data #5933 removes it.GenAIhas no Java or Cocoa counterpart. It only gatesSentry.Extensions.AI, which is managed code.DataCollectionwith every category off, and checks that the replay options haven't changed.SentrySdk.Init. Later changes toDataCollectionreach only the managed integrations.user.id/device.idisn't governed by data collection in sentry-java, so this doesn't change it.🤖 Generated with Claude Code