Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
- Only the name and no-arg constructor of `SentryAndroidOptions` are kept, instead of every member of every `SentryOptions` subclass.
- `sentry-android-ndk` no longer keeps native methods of all `io.sentry.**` classes. `sentry-native-ndk` still keeps its own.
- If your code reaches any of these by name through JNI, reflection, or bindings, add your own keep rules for exactly what it uses.
- Remove the deprecated `sendDefaultPii` option from Java APIs, properties and environment variables, Android manifest metadata, and Spring annotations ([#6793](https://github.com/getsentry/sentry-java/pull/6793))
- Configure automatically collected data with `dataCollection` instead. See the Data Collection documentation for [Android](https://docs.sentry.io/platforms/android/configuration/options/#dataCollection), [Java](https://docs.sentry.io/platforms/java/configuration/options/#dataCollection), and [Spring Boot](https://docs.sentry.io/platforms/java/guides/spring-boot/configuration/options/#dataCollection). `DataCollection.forceDataCollection()` is also removed because the defaults now apply automatically.
- When no `dataCollection` setting is specified, user information, database query data, file paths, GraphQL documents and variables, and HTTP request and response bodies are enabled. Cookies, URL query parameters, and HTTP headers use their default deny lists.
- Logback raw message templates and parameters are controlled only by `includeUnencodedMessage` when an encoder is configured.
- The Spring Boot 3 integrations are tested against Spring Boot 3.4 and newer. Spring Boot 3.2 and 3.3 are no longer supported ([#6656](https://github.com/getsentry/sentry-java/pull/6656))
- Remove the deprecated `io.sentry.android.core.LoadClass`. Use `io.sentry.util.LoadClass` instead ([#6594](https://github.com/getsentry/sentry-java/pull/6594))
- `SentryOptions.getIgnoredErrors()`, `getIgnoredTransactions()`, `getIgnoredCheckIns()` and `getIgnoredSpanOrigins()` now return `List<String>` instead of `List<FilterString>`, matching their setters ([#6489](https://github.com/getsentry/sentry-java/pull/6489))
Expand Down
33 changes: 33 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
# Migrating from 8.x to 9.x

## Replace `sendDefaultPii` with Data Collection

Version 9 removes `sendDefaultPii` from the Java API, external configuration, Android manifest metadata, and Spring's `@EnableSentry` annotation. Configure each category through `dataCollection` instead.

When no Data Collection setting is specified, the SDK now uses these defaults:

- User information, database query data, file paths, GraphQL documents and variables, and HTTP request and response bodies are enabled.
- Cookies, URL query parameters, and HTTP request and response headers are collected with their default deny lists.

Explicit settings still take precedence. If you relied on `sendDefaultPii=false` and want to disable these categories, configure them directly:

```java
Sentry.init(options -> {
DataCollection dataCollection = options.getDataCollection();
dataCollection.setUserInfo(false);
dataCollection.setDatabaseQueryData(false);
dataCollection.setFilePaths(false);
dataCollection.setCookies(KeyValueCollectionBehavior.off());
dataCollection.setUrlQueryParams(KeyValueCollectionBehavior.off());
dataCollection.setHttpBodies(java.util.Collections.emptySet());
dataCollection.getHttpHeaders().setRequest(KeyValueCollectionBehavior.off());
dataCollection.getHttpHeaders().setResponse(KeyValueCollectionBehavior.off());
dataCollection.getGraphql().setDocument(false);
dataCollection.getGraphql().setVariables(false);
});
```

`DataCollection.forceDataCollection()` is also removed because the documented defaults now apply automatically.

For Logback, use `includeUnencodedMessage` to control whether events include the original message template and parameters when an encoder is configured. OpenTelemetry-derived HTTP headers now follow `dataCollection.httpHeaders.request`.

# Migrating from `sentry-java` to `sentry-android`

#### Docs
Expand Down
4 changes: 2 additions & 2 deletions REVIEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ rule file in [`.cursor/rules/`](.cursor/rules) for the area the diff touches (`a
- Real secrets, tokens, or DSNs in code, logs, or configs. Obviously-fake DSNs in tests, samples,
and docs are expected — do not flag those.
- New code that collects user-identifiable data (headers, cookies, request/response bodies, URL
query strings, IPs, usernames, file paths, device identifiers) must be gated behind
`options.isSendDefaultPii()`, and must not be on by default otherwise.
query strings, IPs, usernames, file paths, device identifiers) must use the corresponding
`DataCollectionResolver` policy and follow the documented defaults.
- Debug flags, verbose logging, or sampling overrides accidentally left enabled in production
defaults.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ final class ManifestMetadataReader {
static final String COLLECT_ADDITIONAL_CONTEXT = "io.sentry.additional-context";
static final String COLLECT_EXTERNAL_STORAGE_CONTEXT = "io.sentry.external-storage-context";

static final String SEND_DEFAULT_PII = "io.sentry.send-default-pii";

static final String DATA_COLLECTION_USER_INFO = "io.sentry.data-collection.user-info";
static final String DATA_COLLECTION_HTTP_BODIES = "io.sentry.data-collection.http-bodies";
static final String DATA_COLLECTION_COOKIES = "io.sentry.data-collection.cookies";
Expand Down Expand Up @@ -564,9 +562,6 @@ static void applyMetadata(
sdkInfo.setVersion(readStringNotNull(metadata, logger, SDK_VERSION, sdkInfo.getVersion()));
options.setSdkVersion(sdkInfo);

options.setSendDefaultPii(
readBool(metadata, logger, SEND_DEFAULT_PII, options.isSendDefaultPii()));

// sdkInfo.addIntegration();

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,9 @@ class ApplicationExitInfoEventProcessorTest {
populateScopeCache: Boolean = false,
populateOptionsCache: Boolean = false,
replayErrorSampleRate: Double? = null,
isSendDefaultPii: Boolean = true,
): ApplicationExitInfoEventProcessor {
options.cacheDirPath = dir.newFolder().absolutePath
options.environment = "release"
options.isSendDefaultPii = isSendDefaultPii
options.addScopeObserver(PersistingScopeObserver(options))

whenever(buildInfo.sdkInfoVersion).thenReturn(currentSdk)
Expand Down Expand Up @@ -248,7 +246,7 @@ class ApplicationExitInfoEventProcessorTest {
fixture.options.dataCollection.setUserInfo(true)
val hint = HintUtils.createWithTypeCheckHint(AbnormalExitHint())

val processed = processEvent(hint, isSendDefaultPii = false)
val processed = processEvent(hint)

assertNotNull(processed.contexts.device!!.id)
}
Expand Down Expand Up @@ -370,17 +368,18 @@ class ApplicationExitInfoEventProcessorTest {
}

@Test
fun `when backfillable event is enrichable, does not backfill user ip`() {
fun `when user info is disabled, does not backfill user ip`() {
fixture.options.dataCollection.setUserInfo(false)
val hint = HintUtils.createWithTypeCheckHint(BackfillableHint())
val processed = processEvent(hint, isSendDefaultPii = false, populateScopeCache = true)
val processed = processEvent(hint, populateScopeCache = true)
assertNull(processed.user!!.ipAddress)
}

@Test
fun `when user info is disabled, does not backfill automatic user data`() {
fixture.options.dataCollection.setUserInfo(false)
val hint = HintUtils.createWithTypeCheckHint(BackfillableHint())
val processed = processEvent(hint, isSendDefaultPii = true, populateScopeCache = true)
val processed = processEvent(hint, populateScopeCache = true)

assertEquals("bot", processed.user!!.username)
assertEquals("bot@me.com", processed.user!!.id)
Expand All @@ -391,7 +390,7 @@ class ApplicationExitInfoEventProcessorTest {
fun `when user info is enabled, backfills automatic user data`() {
fixture.options.dataCollection.setUserInfo(true)
val hint = HintUtils.createWithTypeCheckHint(BackfillableHint())
val processed = processEvent(hint, isSendDefaultPii = false, populateScopeCache = true)
val processed = processEvent(hint, populateScopeCache = true)

assertEquals("bot", processed.user!!.username)
assertEquals("bot@me.com", processed.user!!.id)
Expand Down Expand Up @@ -1214,7 +1213,6 @@ class ApplicationExitInfoEventProcessorTest {
tmpDir,
populateScopeCache = false,
populateOptionsCache = false,
isSendDefaultPii = false,
)

val hintTimestamp = System.currentTimeMillis()
Expand Down Expand Up @@ -1271,7 +1269,6 @@ class ApplicationExitInfoEventProcessorTest {
tmpDir,
populateScopeCache = false,
populateOptionsCache = false,
isSendDefaultPii = false,
)
fixture.persistOptions(PROGUARD_UUID_FILENAME, "previous-uuid")
setLastUpdateTime(2_000)
Expand Down Expand Up @@ -1441,7 +1438,6 @@ class ApplicationExitInfoEventProcessorTest {
hint: Hint,
populateScopeCache: Boolean = false,
populateOptionsCache: Boolean = false,
isSendDefaultPii: Boolean = true,
configureEvent: SentryEvent.() -> Unit = {},
): SentryEvent {
val original = SentryEvent().apply(configureEvent)
Expand All @@ -1451,7 +1447,6 @@ class ApplicationExitInfoEventProcessorTest {
tmpDir,
populateScopeCache = populateScopeCache,
populateOptionsCache = populateOptionsCache,
isSendDefaultPii = isSendDefaultPii,
)
return processor.process(original, hint)!!
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ class DefaultAndroidEventProcessorTest {

lateinit var sentryTracer: SentryTracer

fun getSut(context: Context, isSendDefaultPii: Boolean = false): DefaultAndroidEventProcessor {
options.isSendDefaultPii = isSendDefaultPii
fun getSut(context: Context): DefaultAndroidEventProcessor {
whenever(scopes.options).thenReturn(options)
sentryTracer = SentryTracer(TransactionContext("", ""), scopes)
return DefaultAndroidEventProcessor(context, buildInfo, options)
Expand Down Expand Up @@ -269,16 +268,8 @@ class DefaultAndroidEventProcessorTest {
}

@Test
fun `when event user data does not have ip address set, sets no ip address if sendDefaultPii is false`() {
val sut = fixture.getSut(context, isSendDefaultPii = false)
val event = SentryEvent().apply { user = User() }
sut.process(event, Hint())
assertNotNull(event.user) { assertNull(it.ipAddress) }
}

@Test
fun `when event user data does not have ip address set, sets {{auto}} if sendDefaultPii is true`() {
val sut = fixture.getSut(context, isSendDefaultPii = true)
fun `when event user data does not have ip address set, sets {{auto}} by default`() {
val sut = fixture.getSut(context)
val event = SentryEvent().apply { user = User() }
sut.process(event, Hint())
assertNotNull(event.user) { assertEquals("{{auto}}", it.ipAddress) }
Expand All @@ -287,7 +278,7 @@ class DefaultAndroidEventProcessorTest {
@Test
fun `when user info is disabled, sets installation id but not automatic ip`() {
fixture.options.dataCollection.setUserInfo(false)
val sut = fixture.getSut(context, isSendDefaultPii = true)
val sut = fixture.getSut(context)
val event = SentryEvent().apply { user = User() }

sut.process(event, Hint())
Expand All @@ -301,7 +292,7 @@ class DefaultAndroidEventProcessorTest {
@Test
fun `when user info is enabled, sets automatic user data`() {
fixture.options.dataCollection.setUserInfo(true)
val sut = fixture.getSut(context, isSendDefaultPii = false)
val sut = fixture.getSut(context)
val event = SentryEvent().apply { user = User() }

sut.process(event, Hint())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1482,37 +1482,14 @@ class ManifestMetadataReaderTest {
}

@Test
fun `applyMetadata reads send default pii and keep default value if not found`() {
// Arrange
val context = fixture.getContext()

// Act
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)

// Assert
assertFalse(fixture.options.isSendDefaultPii)
}

@Test
fun `applyMetadata reads send default pii to options`() {
// Arrange
val bundle = bundleOf(ManifestMetadataReader.SEND_DEFAULT_PII to true)
val context = fixture.getContext(metaData = bundle)

// Act
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)

// Assert
assertTrue(fixture.options.isSendDefaultPii)
}

@Test
fun `applyMetadata preserves legacy data collection when metadata is absent`() {
fun `applyMetadata uses data collection defaults when metadata is absent`() {
val context = fixture.getContext()

ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)

assertThat(fixture.options.dataCollectionResolver.isDataCollectionConfigured()).isFalse()
assertThat(fixture.options.dataCollectionResolver.isUserInfo).isTrue()
assertThat(fixture.options.dataCollectionResolver.cookies)
.isEqualTo(KeyValueCollectionBehavior.denyList())
}

@Test
Expand Down Expand Up @@ -1605,32 +1582,14 @@ class ManifestMetadataReaderTest {
assertThat(fixture.options.dataCollection.httpBodies).isEmpty()
}

@Test
fun `applyMetadata data collection takes precedence over send default pii`() {
val bundle =
bundleOf(
ManifestMetadataReader.SEND_DEFAULT_PII to false,
ManifestMetadataReader.DATA_COLLECTION_COOKIES + ".mode" to "off",
)
val context = fixture.getContext(metaData = bundle)

ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)

assertThat(fixture.options.isSendDefaultPii).isFalse()
assertThat(fixture.options.dataCollectionResolver.isDataCollectionConfigured()).isTrue()
assertThat(fixture.options.dataCollectionResolver.isUserInfo).isTrue()
assertThat(fixture.options.dataCollectionResolver.cookies)
.isEqualTo(KeyValueCollectionBehavior.off())
}

@Test
fun `applyMetadata ignores invalid data collection body type`() {
val bundle = bundleOf(ManifestMetadataReader.DATA_COLLECTION_HTTP_BODIES to "invalid")
val context = fixture.getContext(metaData = bundle)

ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)

assertThat(fixture.options.dataCollectionResolver.isDataCollectionConfigured()).isFalse()
assertThat(fixture.options.dataCollection.httpBodies).isNull()
}

@Test
Expand All @@ -1640,7 +1599,7 @@ class ManifestMetadataReaderTest {

ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)

assertThat(fixture.options.dataCollectionResolver.isDataCollectionConfigured()).isFalse()
assertThat(fixture.options.dataCollection.cookies).isNull()
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,6 @@
android:name="io.sentry.attach-view-hierarchy"
android:value="true" />

<!-- how to enable the send default pii-->
<meta-data
android:name="io.sentry.send-default-pii"
android:value="true" />

<!-- how to disable sentry -->
<!-- <meta-data android:name="io.sentry.enabled" android:value="false" /> -->

Expand Down
2 changes: 1 addition & 1 deletion sentry-apollo-3/detekt-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ID>CyclomaticComplexMethod:SentryApollo3HttpInterceptor.kt$SentryApollo3HttpInterceptor$private fun captureEvent( request: HttpRequest, response: HttpResponse, operationName: String?, operationType: String?, )</ID>
<ID>LongMethod:SentryApollo3HttpInterceptor.kt$SentryApollo3HttpInterceptor$private fun captureEvent( request: HttpRequest, response: HttpResponse, operationName: String?, operationType: String?, )</ID>
<ID>LongParameterList:SentryApollo3HttpInterceptor.kt$SentryApollo3HttpInterceptor$( span: ISpan?, request: HttpRequest, response: HttpResponse?, statusCode: Int?, operationName: String?, operationType: String?, operationId: String?, )</ID>
<ID>LongParameterList:SentryApollo3InterceptorClientErrors.kt$SentryApollo3InterceptorClientErrors.Fixture$( captureFailedRequests: Boolean = DEFAULT_CAPTURE_FAILED_REQUESTS, failedRequestTargets: List&lt;String> = listOf(DEFAULT_PROPAGATION_TARGETS), httpStatusCode: Int = 200, responseBody: String = responseBodyOk, sendDefaultPii: Boolean = false, includeCookies: Boolean = sendDefaultPii, socketPolicy: SocketPolicy = SocketPolicy.KEEP_OPEN, configureOptions: SentryOptions.() -> Unit = {}, )</ID>
<ID>LongParameterList:SentryApollo3InterceptorClientErrors.kt$SentryApollo3InterceptorClientErrors.Fixture$( captureFailedRequests: Boolean = DEFAULT_CAPTURE_FAILED_REQUESTS, failedRequestTargets: List&lt;String> = listOf(DEFAULT_PROPAGATION_TARGETS), httpStatusCode: Int = 200, responseBody: String = responseBodyOk, includeCookies: Boolean = false, socketPolicy: SocketPolicy = SocketPolicy.KEEP_OPEN, configureOptions: SentryOptions.() -> Unit = {}, )</ID>
<ID>MaxLineLength:LaunchDetailsQuery.kt$LaunchDetailsQuery.Companion$"query LaunchDetails(${'$'}id: ID!) { launch(id: ${'$'}id) { id site mission { name missionPatch(size: LARGE) } rocket { name type } } }"</ID>
<ID>MaxLineLength:SentryApollo3InterceptorTest.kt$SentryApollo3InterceptorTest$"thirdPartyBaggage=someValue,secondThirdPartyBaggage=secondValue; property;propertyKey=propertyValue,anotherThirdPartyBaggage=anotherValue"</ID>
<ID>MaxLineLength:SentryApollo3InterceptorTest.kt$SentryApollo3InterceptorTest.Fixture$"secondThirdPartyBaggage=secondValue; property;propertyKey=propertyValue,anotherThirdPartyBaggage=anotherValue"</ID>
Expand Down
Loading
Loading