Skip to content

fix(spring): [Data Collection 18] Bind key-value policies - #5834

Draft
adinauer wants to merge 23 commits into
feat/data-collection-session-replay-network-optionsfrom
fix/data-collection-spring-binding
Draft

fix(spring): [Data Collection 18] Bind key-value policies#5834
adinauer wants to merge 23 commits into
feat/data-collection-session-replay-network-optionsfrom
fix/data-collection-spring-binding

Conversation

@adinauer

@adinauer adinauer commented Jul 24, 2026

Copy link
Copy Markdown
Member

PR Stack (Data Collection)


📜 Description

Make KeyValueCollectionBehavior JavaBean-bindable so Spring Boot can configure Data Collection policies for cookies, URL query parameters, and request/response headers.

Add a public no-argument constructor with the default deny-list behavior and setters for mode and terms. The existing off, denyList, and allowList factories remain available, and terms continue to be defensively copied into an immutable list.

💡 Motivation and Context

Spring Boot could bind scalar Data Collection fields but silently ignored nested key-value policies because KeyValueCollectionBehavior only exposed private construction and immutable fields. A scalar property could therefore make the namespace explicit while the requested cookie, query, or header restriction was not applied.

Refs #5666

💚 How did you test it?

  • ./gradlew :sentry:test --tests io.sentry.KeyValueCollectionBehaviorTest :sentry-spring-boot:test --tests 'io.sentry.spring.boot.SentryAutoConfigurationTest.data collection key value properties are applied to SentryOptions' :sentry-spring-boot-jakarta:test --tests 'io.sentry.spring.boot.jakarta.SentryAutoConfigurationTest.data collection key value properties are applied to SentryOptions' :sentry-spring-boot-4:test --tests 'io.sentry.spring.boot4.SentryAutoConfigurationTest.data collection key value properties are applied to SentryOptions'
  • ./gradlew spotlessApply apiDump
  • 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 the remaining external and Android manifest Data Collection configuration paths.

#skip-changelog

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

adinauer and others added 2 commits July 24, 2026 15:00
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>
Make KeyValueCollectionBehavior JavaBean-bindable so Spring Boot properties correctly configure cookie, header, and query policies. Cover binding across all supported Spring Boot generations.

Co-Authored-By: Claude <noreply@anthropic.com>
@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

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 307.58 ms 353.86 ms 46.28 ms
Size 0 B 0 B 0 B

Baseline results on branch: fix/data-collection-android-installation-id

Startup times

Revision Plain With Sentry Diff
fd855e6 412.11 ms 452.96 ms 40.85 ms
9c0d3ce 412.04 ms 489.67 ms 77.63 ms

App size

Revision Plain With Sentry Diff
fd855e6 0 B 0 B 0 B
9c0d3ce 0 B 0 B 0 B

Previous results on branch: fix/data-collection-spring-binding

Startup times

Revision Plain With Sentry Diff
6f6d5e3 307.56 ms 352.77 ms 45.21 ms
62f0348 366.32 ms 435.63 ms 69.31 ms

App size

Revision Plain With Sentry Diff
6f6d5e3 0 B 0 B 0 B
62f0348 0 B 0 B 0 B

adinauer and others added 3 commits August 10, 2026 14:42
…to fix/data-collection-android-installation-id
Use the canonical URL query parameter property name in Spring Boot 2, 3, and 4 binding coverage.

Refs #5666

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


This PR will not appear in the changelog.


🤖 This preview updates automatically when you update the PR.

@lbloder lbloder left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM 👍

…to fix/data-collection-android-installation-id
This reverts commit b27d61d.\n\nKeep generated installation IDs independent of the userInfo policy. Restore\ndefault generation before programmatic configuration so applications can\ncontinue clearing the distinct ID in the configuration callback.\n\nRefs #5666\n\nCo-Authored-By: Claude <noreply@anthropic.com>
@adinauer
adinauer changed the base branch from fix/data-collection-android-installation-id to feat/data-collection-session-replay-network-options September 2, 2026 09:33
Merge the conflict-resolved cookie policy through the remaining stacked branches.

Co-Authored-By: Claude <noreply@anthropic.com>
return mode;
}

public void setMode(final @NotNull Mode mode) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Up until this PR, KeyValueCollectionBehavior was immutable. This is important because DataCollectionResolver holds two static final KeyValueCollectionBehaviors.
This means that users can modify the static singleton which is not a good idea.
I think we should rather keep this class immutable to prevent issues.

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.

3 participants