Skip to content

Commit

Permalink
♻️ Warn about deprecated DatadogConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
xgouchet committed Feb 17, 2021
1 parent e6964ee commit 8e8d636
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 40 deletions.
2 changes: 1 addition & 1 deletion dd-sdk-android/apiSurface
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>): Builder
fun useEUEndpoints(): Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8e8d636

Please sign in to comment.