Skip to content

fix(android): [Data Collection 17] Apply user info policy to distinct ID#5833

Draft
adinauer wants to merge 1 commit into
feat/data-collection-session-replay-network-optionsfrom
fix/data-collection-android-installation-id
Draft

fix(android): [Data Collection 17] Apply user info policy to distinct ID#5833
adinauer wants to merge 1 commit into
feat/data-collection-session-replay-network-optionsfrom
fix/data-collection-android-installation-id

Conversation

@adinauer

@adinauer adinauer commented Jul 24, 2026

Copy link
Copy Markdown
Member

PR Stack (Data Collection)


📜 Description

Apply the resolved user information policy when generating Android's default installation-backed distinctId.

Move default distinctId generation out of AndroidOptionsInitializer and run it after the programmatic SentryAndroid.init callback. Generate the installation ID only when no distinct ID is configured and dataCollection.userInfo allows 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 distinctId as an automatic user.id fallback when no scope user exists. The previous unconditional default generation left that SDK-generated identity available even when applications explicitly configured dataCollection.userInfo=false.

Evaluating the policy after the programmatic callback prevents automatic distinctId generation 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:spotlessKotlinCheck
  • git diff --check

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

Add external and Android manifest Data Collection configuration before finalizing the stack.

#skip-changelog

⚠️ Merge this PR using a merge commit (not squash). Only the collection branch is squash-merged into main.

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>
"Error in the 'OptionsConfiguration.configure' callback.",
t);
}
if (options.getDistinctId() == null

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@sentry

sentry Bot commented Jul 24, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.48.0 (1) release

⚙️ sentry-android Build Distribution Settings

@github-actions

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 412.04 ms 489.67 ms 77.63 ms
Size 0 B 0 B 0 B

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant