Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse and use send-default-pii and max-request-body-size from sentry.properties #3534

Merged
merged 3 commits into from
Jul 2, 2024
Merged
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 @@ -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
Expand Down
2 changes: 2 additions & 0 deletions sentry/api/sentry.api
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions sentry/src/main/java/io/sentry/ExternalOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public final class ExternalOptions {
private @Nullable List<String> ignoredCheckIns;

private @Nullable Boolean sendModules;
private @Nullable Boolean sendDefaultPii;
private @Nullable Boolean enableBackpressureHandling;

private @Nullable SentryOptions.Cron cron;
Expand Down Expand Up @@ -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"));

Expand Down Expand Up @@ -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<String> ignoredCheckIns) {
this.ignoredCheckIns = ignoredCheckIns;
Expand Down
6 changes: 6 additions & 0 deletions sentry/src/main/java/io/sentry/SentryOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 7 additions & 0 deletions sentry/src/test/java/io/sentry/ExternalOptionsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = emptyList(), logger: ILogger = mock(), fn: (ExternalOptions) -> Unit) {
// create a sentry.properties file in temporary folder
val temporaryFolder = TemporaryFolder()
Expand Down
5 changes: 5 additions & 0 deletions sentry/src/test/java/io/sentry/SentryOptionsTest.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading