Repository navigation
feat: DataCollection.UserInfo now gates the environment username and inferred IP address - #5932
jamescrosswell wants to merge 2 commits into
Conversation
The environment username and the `{{auto}}` IP address now read
`DataCollectionResolver.UserInfo` instead of `SendDefaultPii`. When
`DataCollection` is not configured, `UserInfo` bridges to
`SendDefaultPii`, so behaviour is unchanged.
Refs #5428
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 #5932 +/- ##
==========================================
+ Coverage 77.44% 77.70% +0.25%
==========================================
Files 546 535 -11
Lines 20053 19731 -322
Branches 3962 3934 -28
==========================================
- Hits 15531 15332 -199
+ Misses 3658 3544 -114
+ Partials 864 855 -9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ric-oliv
left a comment
There was a problem hiding this comment.
One small thing about Closes #5428. That issue is the only one tracking the server-name sites in MainSentryEventProcessor and SentryLog, so nothing would track them once it closes. Later, #5437 would deprecate SendDefaultPii, but it's still the only switch for server_name. Could we move those two sites to a follow-up issue?
With UserInfo disabled the enricher skips the whole block, so the old test never exercised the HasUser() check. Running it with UserInfo both on and off, and no username set, catches a dropped HasUser() check or a switch to `Username ??=`. Also note on DataCollectionOptions.UserInfo that the installation ID still fills SentryUser.Id, per getsentry/sentry-docs#20856. Refs #5428 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 Sentry: tests caught 1 of 1 mutants on the changed lines |
So this relates to
.NET is currently the only SDK that withholds the hostname unless SendDefaultPii is on. Most SDKs just send it (the only option to turn it off is to overwrite it). Java and Node have attachServerName and includeServerName options. It feels like that gate would sit well in the new Data Collection options, so I'll check with the other SDK teams what we actually want to do here, rather than just make something up. |
|
@ric-oliv Good catch on 🤖 Addressed by Claude Code |
## DESCRIBE YOUR PR The data collection spec doesn't say whether `userInfo` covers the installation ID that some SDKs generate and send as `user.id`, so SDKs have read it both ways. Java keeps the ID independent of `userInfo` in getsentry/sentry-java#5937, and Cocoa's v10 builds gate it in getsentry/sentry-cocoa#8415. .NET has to pick one in getsentry/sentry-dotnet#5932. This PR adds an "Installation Identifier" section that writes down what Java does: - `dataCollection` options don't gate the installation identifier. It identifies an installation, not a person. - SDKs should generate it at random. They may use an ID the platform provides and scopes to the app, like the console IDs getsentry/sentry-native#2150 allows. They must not use values that identify the device outside the app, like a MAC address or a host name. It also points the `userInfo` row, the "Disable User Identity" example and the technical context examples at the new section. The section adds requirements, so the spec moves to 0.18.0. Why Java's reading: - The spec suggests `userInfo: false` to roughly match `sendDefaultPii: false`, and `sendDefaultPii: false` always sent the installation ID. - Gating only `user.id` doesn't keep the ID on the device, because sessions send the same value as `did`. It would drop the "users affected" counts and protect very little. - Every SDK that has shipped already sends it. Only Cocoa's unreleased v10 builds gate it. I also considered gating it on `userInfo`, the way Cocoa v10 does. That would need a rule for the session `did` too, and it would change behavior in every shipped SDK. For the SDKs, Java already follows this, Cocoa would drop the `SDK_V10` gate before v10 ships, and .NET will follow up on its side. ## IS YOUR CHANGE URGENT? - [ ] Urgent deadline (GA date, etc.): YYYY-MM-DD - [ ] Other deadline: YYYY-MM-DD - [x] No deadline: Not urgent, can wait up to 1 week+
ric-oliv
left a comment
There was a problem hiding this comment.
Looking good! One optional thing: this is the first PR where a category actually changes what gets collected, so two remarks go stale once it merges. SentryOptions.ConfigureDataCollection says "setting a category here has no effect yet", and the DataCollectionOptions class remarks say "setting a category does not yet change what they collect". Both contradict the UserInfo docs now. #5931 doesn't touch them either, so whichever lands first could reword them. Maybe something like this, which won't need updating as each integration moves:
SentryOptions.ConfigureDataCollection:
/// The integrations are still being migrated onto these options. Those that haven't moved yet still follow
/// <see cref="SendDefaultPii"/> and ignore the categories set here.DataCollectionOptions:
/// The integrations are still being migrated onto these options, and those that haven't moved yet ignore these
/// categories; see <see cref="SentryOptions.ConfigureDataCollection"/>.
The core SDK's automatic user info is now governed by the
UserInfodata collection setting instead ofSendDefaultPii.EnricherreadsDataCollectionResolver.UserInfobefore reporting the environment username (IsEnvironmentUser) and the{{auto}}IP address placeholder.Part of #5420 (Phase 2).
Closes #5428
Behaviour
DataCollectionnot configured: unchanged.UserInfobridges toSendDefaultPii.ConfigureDataCollection(...)called:UserInfo(defaulttrue) decides, andSendDefaultPiiis ignored, as the spec requires. An app that callsConfigureDataCollectionwithSendDefaultPii = falseand leavesUserInfoat its default now gets the environment username and{{auto}}IP. This affects only apps that opted into the experimental option shipped in 6.13.0 / 7.0.0.Userdata set by the application is never gated.??=andHasUser()only fill gaps, and a test pins that withUserInfoboth on and off.Notes for review
MainSentryEventProcessor(ServerName = Environment.MachineName) andSentryLog(server.address), but spec 0.16.0 scopesuserInfotouser.id,user.email,user.usernameanduser.ip_addressand says it "does not affect any other data category". Server name is never mentioned, and sentry-java gates the hostname with its ownattachServerNameoption instead. Both call sites stay onSendDefaultPiihere. Add AttachServerName and stop gating the server name on SendDefaultPii #5957 tracks them, with a proposal for a top-levelAttachServerName.User.Idstays ungated.Enricher(non-global mode) andGlobalRootScopeIntegrationsetUser.Id ??= InstallationId.SendDefaultPiihas never gated this, and docs(data-collection): Define the installation identifier sentry-docs#20856 makes it the spec:dataCollectionoptions must not gate the installation identifier. TheUserInfodocs now say so, souser.idshowing up withUserInfo = falsedoesn't look like a bug.SendDefaultPiireads insrc/Sentryare left to their own issues: theSentryClientredact cascade and both failed-request handlers (DataCollection phase 2: migrate redact cascade and HTTP failed-request handler #5429 / DataCollection phase 2: migrate GraphQL instrumentation #5432), andPlatforms/Android/Platforms/Cocoaforwarding to the native SDKs (DataCollection phase 2: propagate to native (Android/Cocoa) #5436).🤖 Generated with Claude Code