fix(android): [Data Collection 17] Apply user info policy to distinct ID#5833
Draft
adinauer wants to merge 1 commit into
Draft
Conversation
Generate the default Android installation ID after programmatic configuration and only when the resolved user information policy allows it. Preserve custom distinct IDs and keep legacy behavior when Data Collection is absent. Refs #5666 Co-Authored-By: Claude <noreply@anthropic.com>
This was referenced Jul 24, 2026
adinauer
commented
Jul 24, 2026
| "Error in the 'OptionsConfiguration.configure' callback.", | ||
| t); | ||
| } | ||
| if (options.getDistinctId() == null |
Member
Author
There was a problem hiding this comment.
Moving this here no longer allows customers to override it in the options configuration callback passed to init since it used to run before but now is set afterwards. It can still be removed via beforeSend. Is that OK?
📲 Install BuildsAndroid
|
Contributor
Performance metrics 🚀
|
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Stack (Data Collection)
📜 Description
Apply the resolved user information policy when generating Android's default installation-backed
distinctId.Move default
distinctIdgeneration out ofAndroidOptionsInitializerand run it after the programmaticSentryAndroid.initcallback. Generate the installation ID only when no distinct ID is configured anddataCollection.userInfoallows automatic identity collection.Existing runtime gates in Android event, exit-info, device-context, and hybrid scope enrichment remain unchanged.
💡 Motivation and Context
Android logs and metrics use
distinctIdas an automaticuser.idfallback when no scope user exists. The previous unconditional default generation left that SDK-generated identity available even when applications explicitly configureddataCollection.userInfo=false.Evaluating the policy after the programmatic callback prevents automatic
distinctIdgeneration for opted-out applications while preserving custom IDs and the legacy absent-Data-Collection behavior.Refs #5666
💚 How did you test it?
./gradlew spotlessApply apiDump./gradlew :sentry-android-core:testDebugUnitTest --tests='io.sentry.android.core.AndroidOptionsInitializerTest' --tests='io.sentry.android.core.ApplicationExitInfoEventProcessorTest' --tests='io.sentry.android.core.DeviceInfoUtilTest'./gradlew :sentry-android-core:apiCheck :sentry-android-core:spotlessJavaCheck :sentry-android-core:spotlessKotlinCheckgit diff --check📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
Add external and Android manifest Data Collection configuration before finalizing the stack.
#skip-changelog