Skip to content

Commit

Permalink
chore: unify external logger code
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamadJaara committed Jun 13, 2024
1 parent 9802134 commit bf5ab6e
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 458 deletions.
24 changes: 23 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import customization.ConfigurationFileImporter
import customization.NormalizedFlavorSettings
import scripts.Variants_gradle
import java.util.Properties

/*
* Wire
Expand Down Expand Up @@ -48,6 +48,7 @@ repositories {

val nonFreeFlavors = setOf("prod", "internal", "staging", "beta", "dev")
val fossFlavors = setOf("fdroid")
val internalFlavors = setOf("internal", "staging", "beta", "dev")
val allFlavors = nonFreeFlavors + fossFlavors

private fun getFlavorsSettings(): NormalizedFlavorSettings =
Expand All @@ -60,6 +61,22 @@ private fun getFlavorsSettings(): NormalizedFlavorSettings =
}

android {
defaultConfig {

val localProperties = Properties()
val localPropertiesFile = rootProject.file("local.properties")
if (localPropertiesFile.exists()) {
localProperties.load(localPropertiesFile.inputStream())
}

val datadogApiKeyKey = "DATADOG_CLIENT_TOKEN"
val apiKey: String? = System.getenv(datadogApiKeyKey) ?: localProperties.getProperty(datadogApiKeyKey)
buildConfigField("String", "DATADOG_CLIENT_TOKEN", apiKey?.let { "\"$it\"" } ?: "null")

val datadogAppId = "DATADOG_APP_ID"
val appId: String? = System.getenv(datadogAppId) ?: localProperties.getProperty(datadogAppId)
buildConfigField("String", datadogAppId, appId?.let { "\"$it\"" } ?: "null")
}
// Most of the configuration is done in the build-logic
// through the Wire Application convention plugin

Expand All @@ -77,6 +94,11 @@ android {
sourceSets {
allFlavors.forEach { flavor ->
getByName(flavor) {
if (flavor in internalFlavors) {
java.srcDirs("src/external-logger-enabled/kotlin")
println("Adding external datadog logger internal sourceSets to '$flavor' flavor")
}

if (flavor in fossFlavors) {
java.srcDirs("src/foss/kotlin", "src/prod/kotlin")
res.srcDirs("src/prod/res")
Expand Down
91 changes: 0 additions & 91 deletions app/src/beta/kotlin/com/wire/android/ExternalLoggerManager.kt

This file was deleted.

This file was deleted.

55 changes: 0 additions & 55 deletions app/src/beta/kotlin/com/wire/android/util/DataDogLogger.kt

This file was deleted.

66 changes: 0 additions & 66 deletions app/src/dev/kotlin/com/wire/android/ExternalLoggerManager.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,23 @@ import com.datadog.android.rum.tracking.ActivityViewTrackingStrategy
import com.datadog.android.rum.tracking.ComponentPredicate
import com.wire.android.datastore.GlobalDataStore
import com.wire.android.ui.WireActivity
import com.wire.android.util.getDeviceIdString
import com.wire.android.util.sha256
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
import com.wire.android.util.getDeviceIdString

private const val LONG_TASK_THRESH_HOLD_MS = 1000L

object ExternalLoggerManager {

fun initDatadogLogger(context: Context, globalDataStore: GlobalDataStore) {

val clientToken = "pub98ad02250435b6082337bb79f66cbc19"
val applicationId = "619af3ef-2fa6-41e2-8bb1-b42041d50802"
val clientToken = BuildConfig.DATADOG_CLIENT_TOKEN
val applicationId = BuildConfig.DATADOG_APP_ID

if(clientToken == null || applicationId == null) {
return
}

val environmentName = "internal"
val appVariantName = "com.wire.android.${BuildConfig.FLAVOR}.${BuildConfig.BUILD_TYPE}"
Expand Down

This file was deleted.

Loading

0 comments on commit bf5ab6e

Please sign in to comment.