diff --git a/dd-sdk-android/apiSurface b/dd-sdk-android/apiSurface index d68075d1d2..eeeddb0146 100644 --- a/dd-sdk-android/apiSurface +++ b/dd-sdk-android/apiSurface @@ -80,7 +80,7 @@ enum com.datadog.android.core.configuration.BatchSize - LARGE class com.datadog.android.core.configuration.Configuration class Builder - constructor(Boolean = false, Boolean = false, Boolean = false, Boolean = false) + constructor(Boolean, Boolean, Boolean, Boolean) fun build(): Configuration fun setFirstPartyHosts(List): Builder fun useEUEndpoints(): Builder diff --git a/dd-sdk-android/src/main/kotlin/com/datadog/android/DatadogConfig.kt b/dd-sdk-android/src/main/kotlin/com/datadog/android/DatadogConfig.kt index 658369bd57..372663ed3c 100644 --- a/dd-sdk-android/src/main/kotlin/com/datadog/android/DatadogConfig.kt +++ b/dd-sdk-android/src/main/kotlin/com/datadog/android/DatadogConfig.kt @@ -12,6 +12,7 @@ import com.datadog.android.core.configuration.Configuration import com.datadog.android.core.configuration.Credentials import com.datadog.android.core.configuration.UploadFrequency import com.datadog.android.core.internal.utils.devLogger +import com.datadog.android.core.internal.utils.warnDeprecated import com.datadog.android.event.EventMapper import com.datadog.android.plugin.DatadogPlugin import com.datadog.android.plugin.Feature @@ -171,6 +172,15 @@ private constructor( constructor(clientToken: String, envName: String, applicationId: String) : this(clientToken, envName, UUID.fromString(applicationId)) + init { + warnDeprecated( + "DatadogConfig.Builder", + "1.8.0", + "1.10.0", + "Configuration()" + ) + } + private var logsConfig: FeatureConfig = FeatureConfig( clientToken, applicationId, diff --git a/dd-sdk-android/src/main/kotlin/com/datadog/android/core/configuration/Configuration.kt b/dd-sdk-android/src/main/kotlin/com/datadog/android/core/configuration/Configuration.kt index d6f00c0f29..5e961d3d5f 100644 --- a/dd-sdk-android/src/main/kotlin/com/datadog/android/core/configuration/Configuration.kt +++ b/dd-sdk-android/src/main/kotlin/com/datadog/android/core/configuration/Configuration.kt @@ -87,17 +87,17 @@ internal constructor( /** * A Builder class for a [Configuration]. - * @param logsEnabled whether Logs are tracked and sent to Datadog (default: false) - * @param tracesEnabled whether Spans are tracked and sent to Datadog (default: false) - * @param crashReportsEnabled whether crashes are tracked and sent to Datadog (default: false) - * @param rumEnabled whether RUM events are tracked and sent to Datadog (default: false) + * @param logsEnabled whether Logs are tracked and sent to Datadog + * @param tracesEnabled whether Spans are tracked and sent to Datadog + * @param crashReportsEnabled whether crashes are tracked and sent to Datadog + * @param rumEnabled whether RUM events are tracked and sent to Datadog */ @Suppress("TooManyFunctions") class Builder( - val logsEnabled: Boolean = false, - val tracesEnabled: Boolean = false, - val crashReportsEnabled: Boolean = false, - val rumEnabled: Boolean = false + val logsEnabled: Boolean, + val tracesEnabled: Boolean, + val crashReportsEnabled: Boolean, + val rumEnabled: Boolean ) { private var logsConfig: Feature.Logs = DEFAULT_LOGS_CONFIG private var tracesConfig: Feature.Tracing = DEFAULT_TRACING_CONFIG diff --git a/dd-sdk-android/src/test/kotlin/com/datadog/android/DatadogConfigBuilderTest.kt b/dd-sdk-android/src/test/kotlin/com/datadog/android/DatadogConfigBuilderTest.kt index 2d566e1f85..c183b8a9dd 100644 --- a/dd-sdk-android/src/test/kotlin/com/datadog/android/DatadogConfigBuilderTest.kt +++ b/dd-sdk-android/src/test/kotlin/com/datadog/android/DatadogConfigBuilderTest.kt @@ -28,6 +28,7 @@ import com.nhaarman.mockitokotlin2.any import com.nhaarman.mockitokotlin2.anyOrNull import com.nhaarman.mockitokotlin2.eq import com.nhaarman.mockitokotlin2.mock +import com.nhaarman.mockitokotlin2.reset import com.nhaarman.mockitokotlin2.verify import com.nhaarman.mockitokotlin2.verifyZeroInteractions import fr.xgouchet.elmyr.Forge @@ -1135,11 +1136,13 @@ internal class DatadogConfigBuilderTest { @Test fun `M do nothing W enabling RUM { APP_ID not provided }`() { + // GIVEN + val configBuilder = DatadogConfig.Builder(fakeClientToken, fakeEnvName) + reset(mockDevLogHandler) + // WHEN - val config = - DatadogConfig.Builder(fakeClientToken, fakeEnvName) - .setRumEnabled(true) - .build() + val config = configBuilder.setRumEnabled(true).build() + // THEN assertThat(config.rumConfig).isNull() verify(mockDevLogHandler).handleLog( @@ -1150,11 +1153,13 @@ internal class DatadogConfigBuilderTest { @Test fun `M not send any warning W disabling RUM { APP_ID not provided }`() { + // GIVEN + val configBuilder = DatadogConfig.Builder(fakeClientToken, fakeEnvName) + reset(mockDevLogHandler) + // WHEN - val config = - DatadogConfig.Builder(fakeClientToken, fakeEnvName) - .setRumEnabled(false) - .build() + val config = configBuilder.setRumEnabled(false).build() + // THEN assertThat(config.rumConfig).isNull() verifyZeroInteractions(mockDevLogHandler) diff --git a/dd-sdk-android/src/test/kotlin/com/datadog/android/core/configuration/ConfigurationBuilderTest.kt b/dd-sdk-android/src/test/kotlin/com/datadog/android/core/configuration/ConfigurationBuilderTest.kt index a834829473..032b5960e2 100644 --- a/dd-sdk-android/src/test/kotlin/com/datadog/android/core/configuration/ConfigurationBuilderTest.kt +++ b/dd-sdk-android/src/test/kotlin/com/datadog/android/core/configuration/ConfigurationBuilderTest.kt @@ -76,29 +76,6 @@ internal class ConfigurationBuilderTest { ) } - @Test - fun `𝕄 disable all features by default 𝕎 build()`() { - // Given - val builder = Configuration.Builder() - - // When - val config = builder.build() - - // Then - assertThat(config.coreConfig).isEqualTo( - Configuration.Core( - needsClearTextHttp = false, - firstPartyHosts = emptyList(), - batchSize = BatchSize.MEDIUM, - uploadFrequency = UploadFrequency.AVERAGE - ) - ) - assertThat(config.logsConfig).isNull() - assertThat(config.tracesConfig).isNull() - assertThat(config.crashReportConfig).isNull() - assertThat(config.rumConfig).isNull() - } - @Test fun `𝕄 use sensible defaults 𝕎 build()`() { // When