diff --git a/CHANGELOG.md b/CHANGELOG.md index a179e82555..dd75e4be4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ - `sentry-android-okhttp` has been removed in favor of `sentry-okhttp`, removing android dependency from the module ([#3510](https://github.com/getsentry/sentry-java/pull/3510)) +### Fixes + +- Parse and use `send-default-pii` and `max-request-body-size` from `sentry.properties` ([#3534](https://github.com/getsentry/sentry-java/pull/3534)) + ## 8.0.0-alpha.2 ### Behavioural Changes diff --git a/sentry/api/sentry.api b/sentry/api/sentry.api index 68ad64144f..52d6c2f329 100644 --- a/sentry/api/sentry.api +++ b/sentry/api/sentry.api @@ -461,6 +461,7 @@ public final class io/sentry/ExternalOptions { public fun isEnableBackpressureHandling ()Ljava/lang/Boolean; public fun isEnablePrettySerializationOutput ()Ljava/lang/Boolean; public fun isEnabled ()Ljava/lang/Boolean; + public fun isSendDefaultPii ()Ljava/lang/Boolean; public fun isSendModules ()Ljava/lang/Boolean; public fun setCron (Lio/sentry/SentryOptions$Cron;)V public fun setDebug (Ljava/lang/Boolean;)V @@ -482,6 +483,7 @@ public final class io/sentry/ExternalOptions { public fun setProxy (Lio/sentry/SentryOptions$Proxy;)V public fun setRelease (Ljava/lang/String;)V public fun setSendClientReports (Ljava/lang/Boolean;)V + public fun setSendDefaultPii (Ljava/lang/Boolean;)V public fun setSendModules (Ljava/lang/Boolean;)V public fun setServerName (Ljava/lang/String;)V public fun setTag (Ljava/lang/String;Ljava/lang/String;)V diff --git a/sentry/src/main/java/io/sentry/ExternalOptions.java b/sentry/src/main/java/io/sentry/ExternalOptions.java index 99eaacdd24..aa5aa43937 100644 --- a/sentry/src/main/java/io/sentry/ExternalOptions.java +++ b/sentry/src/main/java/io/sentry/ExternalOptions.java @@ -49,6 +49,7 @@ public final class ExternalOptions { private @Nullable List ignoredCheckIns; private @Nullable Boolean sendModules; + private @Nullable Boolean sendDefaultPii; private @Nullable Boolean enableBackpressureHandling; private @Nullable SentryOptions.Cron cron; @@ -131,6 +132,7 @@ public final class ExternalOptions { propertiesProvider.getBooleanProperty("enable-pretty-serialization-output")); options.setSendModules(propertiesProvider.getBooleanProperty("send-modules")); + options.setSendDefaultPii(propertiesProvider.getBooleanProperty("send-default-pii")); options.setIgnoredCheckIns(propertiesProvider.getList("ignored-checkins")); @@ -421,6 +423,14 @@ public void setSendModules(final @Nullable Boolean sendModules) { this.sendModules = sendModules; } + public @Nullable Boolean isSendDefaultPii() { + return sendDefaultPii; + } + + public void setSendDefaultPii(final @Nullable Boolean sendDefaultPii) { + this.sendDefaultPii = sendDefaultPii; + } + @ApiStatus.Experimental public void setIgnoredCheckIns(final @Nullable List ignoredCheckIns) { this.ignoredCheckIns = ignoredCheckIns; diff --git a/sentry/src/main/java/io/sentry/SentryOptions.java b/sentry/src/main/java/io/sentry/SentryOptions.java index b8e54952c8..7e24e81dce 100644 --- a/sentry/src/main/java/io/sentry/SentryOptions.java +++ b/sentry/src/main/java/io/sentry/SentryOptions.java @@ -2688,6 +2688,12 @@ public void merge(final @NotNull ExternalOptions options) { if (options.isEnableBackpressureHandling() != null) { setEnableBackpressureHandling(options.isEnableBackpressureHandling()); } + if (options.getMaxRequestBodySize() != null) { + setMaxRequestBodySize(options.getMaxRequestBodySize()); + } + if (options.isSendDefaultPii() != null) { + setSendDefaultPii(options.isSendDefaultPii()); + } if (options.getCron() != null) { if (getCron() == null) { diff --git a/sentry/src/test/java/io/sentry/ExternalOptionsTest.kt b/sentry/src/test/java/io/sentry/ExternalOptionsTest.kt index 04c181b194..fd5b363219 100644 --- a/sentry/src/test/java/io/sentry/ExternalOptionsTest.kt +++ b/sentry/src/test/java/io/sentry/ExternalOptionsTest.kt @@ -286,6 +286,13 @@ class ExternalOptionsTest { } } + @Test + fun `creates options with sendDefaultPii set to true`() { + withPropertiesFile("send-default-pii=true") { options -> + assertTrue(options.isSendDefaultPii == true) + } + } + private fun withPropertiesFile(textLines: List = emptyList(), logger: ILogger = mock(), fn: (ExternalOptions) -> Unit) { // create a sentry.properties file in temporary folder val temporaryFolder = TemporaryFolder() diff --git a/sentry/src/test/java/io/sentry/SentryOptionsTest.kt b/sentry/src/test/java/io/sentry/SentryOptionsTest.kt index b474d4e4e0..c11eafdc5a 100644 --- a/sentry/src/test/java/io/sentry/SentryOptionsTest.kt +++ b/sentry/src/test/java/io/sentry/SentryOptionsTest.kt @@ -1,5 +1,6 @@ package io.sentry +import io.sentry.SentryOptions.RequestSize import io.sentry.util.StringUtils import org.mockito.kotlin.mock import java.io.File @@ -371,6 +372,8 @@ class SentryOptionsTest { externalOptions.isSendModules = false externalOptions.ignoredCheckIns = listOf("slug1", "slug-B") externalOptions.isEnableBackpressureHandling = false + externalOptions.maxRequestBodySize = SentryOptions.RequestSize.MEDIUM + externalOptions.isSendDefaultPii = true externalOptions.cron = SentryOptions.Cron().apply { defaultCheckinMargin = 10L defaultMaxRuntime = 30L @@ -415,6 +418,8 @@ class SentryOptionsTest { assertEquals(40L, options.cron?.defaultFailureIssueThreshold) assertEquals(50L, options.cron?.defaultRecoveryThreshold) assertEquals("America/New_York", options.cron?.defaultTimezone) + assertTrue(options.isSendDefaultPii) + assertEquals(RequestSize.MEDIUM, options.maxRequestBodySize) } @Test