Skip to content

Commit f50a16f

Browse files
adinauerclaude
andcommitted
chore: Merge data collection stack updates
Merge the fallback behavior isolation fix from the preceding Data Collection branch. Co-Authored-By: Claude <noreply@anthropic.com>
2 parents 8eb768a + 021509d commit f50a16f

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

‎sentry/src/main/java/io/sentry/DataCollectionResolver.java‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
@ApiStatus.Internal
1010
public final class DataCollectionResolver {
1111

12-
private static final @NotNull KeyValueCollectionBehavior OFF = KeyValueCollectionBehavior.off();
13-
private static final @NotNull KeyValueCollectionBehavior EMPTY_DENY_LIST =
14-
KeyValueCollectionBehavior.denyList();
15-
1612
private final @NotNull SentryOptions options;
1713

1814
DataCollectionResolver(final @NotNull SentryOptions options) {
@@ -67,9 +63,11 @@ public boolean isGraphqlVariablesWithLegacyAlways() {
6763
return cookies;
6864
}
6965
if (isDataCollectionConfigured()) {
70-
return EMPTY_DENY_LIST;
66+
return KeyValueCollectionBehavior.denyList();
7167
}
72-
return options.isSendDefaultPii() ? EMPTY_DENY_LIST : OFF;
68+
return options.isSendDefaultPii()
69+
? KeyValueCollectionBehavior.denyList()
70+
: KeyValueCollectionBehavior.off();
7371
}
7472

7573
public @NotNull KeyValueCollectionBehavior getUrlQueryParams() {
@@ -124,7 +122,7 @@ private boolean explicitOrDefault(
124122

125123
private @NotNull KeyValueCollectionBehavior explicitOrEmptyDenyList(
126124
final @Nullable KeyValueCollectionBehavior explicit) {
127-
return explicit != null ? explicit : EMPTY_DENY_LIST;
125+
return explicit != null ? explicit : KeyValueCollectionBehavior.denyList();
128126
}
129127

130128
private boolean isHttpBodyEnabled(

‎sentry/src/test/java/io/sentry/DataCollectionResolverTest.kt‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,17 @@ class DataCollectionResolverTest {
233233
assertThat(options.dataCollectionResolver.cookies).isEqualTo(KeyValueCollectionBehavior.off())
234234
}
235235

236+
@Test
237+
fun `mutating one fallback key-value behavior does not affect other getters`() {
238+
val resolver = SentryOptions().apply { dataCollection.setUserInfo(true) }.dataCollectionResolver
239+
240+
resolver.cookies.terms = listOf("custom-cookie")
241+
242+
assertThat(resolver.urlQueryParams.terms).doesNotContain("custom-cookie")
243+
assertThat(resolver.httpRequestHeaders.terms).doesNotContain("custom-cookie")
244+
assertThat(resolver.httpResponseHeaders.terms).doesNotContain("custom-cookie")
245+
}
246+
236247
@Test
237248
fun `cookies use default deny list when unset and sendDefaultPii is true`() {
238249
val options = SentryOptions().apply { isSendDefaultPii = true }

0 commit comments

Comments
 (0)