From bf5ab6e7efe18c0d705cc1b8696053492bbf95b4 Mon Sep 17 00:00:00 2001 From: MohamadJaara Date: Fri, 14 Jun 2024 00:25:39 +0200 Subject: [PATCH] chore: unify external logger code --- app/build.gradle.kts | 24 ++++- .../com/wire/android/ExternalLoggerManager.kt | 91 ------------------- .../navigation/TrackingNavController.kt | 39 -------- .../com/wire/android/util/DataDogLogger.kt | 55 ----------- .../com/wire/android/ExternalLoggerManager.kt | 66 -------------- .../com/wire/android/ExternalLoggerManager.kt | 10 +- .../navigation/TrackingNavController.kt | 0 .../com/wire/android/util/DataDogLogger.kt | 0 .../navigation/TrackingNavController.kt | 22 ----- .../com/wire/android/util/DataDogLogger.kt | 57 ------------ .../com/wire/android/ExternalLoggerManager.kt | 62 ++++--------- .../navigation/TrackingNavController.kt | 22 ----- .../com/wire/android/util/DataDogLogger.kt | 57 ------------ 13 files changed, 47 insertions(+), 458 deletions(-) delete mode 100644 app/src/beta/kotlin/com/wire/android/ExternalLoggerManager.kt delete mode 100644 app/src/beta/kotlin/com/wire/android/navigation/TrackingNavController.kt delete mode 100644 app/src/beta/kotlin/com/wire/android/util/DataDogLogger.kt delete mode 100644 app/src/dev/kotlin/com/wire/android/ExternalLoggerManager.kt rename app/src/{internal => external-logger-enabled}/kotlin/com/wire/android/ExternalLoggerManager.kt (92%) rename app/src/{dev => external-logger-enabled}/kotlin/com/wire/android/navigation/TrackingNavController.kt (100%) rename app/src/{dev => external-logger-enabled}/kotlin/com/wire/android/util/DataDogLogger.kt (100%) delete mode 100644 app/src/internal/kotlin/com/wire/android/navigation/TrackingNavController.kt delete mode 100644 app/src/internal/kotlin/com/wire/android/util/DataDogLogger.kt delete mode 100644 app/src/staging/kotlin/com/wire/android/navigation/TrackingNavController.kt delete mode 100644 app/src/staging/kotlin/com/wire/android/util/DataDogLogger.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c6e1f47e140..1461c70a3ff 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,6 +1,6 @@ import customization.ConfigurationFileImporter import customization.NormalizedFlavorSettings -import scripts.Variants_gradle +import java.util.Properties /* * Wire @@ -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 = @@ -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 @@ -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") diff --git a/app/src/beta/kotlin/com/wire/android/ExternalLoggerManager.kt b/app/src/beta/kotlin/com/wire/android/ExternalLoggerManager.kt deleted file mode 100644 index 0810621f529..00000000000 --- a/app/src/beta/kotlin/com/wire/android/ExternalLoggerManager.kt +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Wire - * Copyright (C) 2024 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ -package com.wire.android - -import android.app.Activity -import android.content.Context -import com.datadog.android.Datadog -import com.datadog.android.DatadogSite -import com.datadog.android.core.configuration.Credentials -import com.datadog.android.privacy.TrackingConsent -import com.datadog.android.rum.GlobalRum -import com.datadog.android.rum.RumMonitor -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.DeviceUtil -import com.wire.android.util.getDeviceIdString -import com.wire.android.util.getGitBuildId -import com.wire.android.util.sha256 -import kotlinx.coroutines.flow.first -import kotlinx.coroutines.runBlocking - -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 environmentName = "internal" - val appVariantName = "com.wire.android.${BuildConfig.FLAVOR}.${BuildConfig.BUILD_TYPE}" - - val configuration = com.datadog.android.core.configuration.Configuration.Builder( - logsEnabled = true, - tracesEnabled = true, - rumEnabled = true, - crashReportsEnabled = true, - ) - .useViewTrackingStrategy( - ActivityViewTrackingStrategy( - trackExtras = true, - componentPredicate = object : ComponentPredicate { - override fun accept(component: Activity): Boolean { - // reject Activities which are hosts of Compose views, so that they are not counted as views - return component !is WireActivity - } - - override fun getViewName(component: Activity): String? = null - } - ) - ) - .trackInteractions() - .trackBackgroundRumEvents(true) - .trackLongTasks(LONG_TASK_THRESH_HOLD_MS) - .useSite(DatadogSite.EU1) - .build() - - val availableMemorySize = DeviceUtil.getAvailableInternalMemorySize() - val totalMemorySize = DeviceUtil.getTotalInternalMemorySize() - val deviceParams = mapOf("available_memory_size" to availableMemorySize, "total_memory_size" to totalMemorySize) - - val credentials = Credentials(clientToken, environmentName, appVariantName, applicationId) - val extraInfo = mapOf( - "encrypted_proteus_storage_enabled" to runBlocking { globalDataStore.isEncryptedProteusStorageEnabled().first() }, - "git_commit_hash" to context.getGitBuildId(), - "device_params" to deviceParams - ) - - Datadog.initialize(context, credentials, configuration, TrackingConsent.GRANTED) - Datadog.setUserInfo(id = context.getDeviceIdString()?.sha256(), extraInfo = extraInfo) - GlobalRum.registerIfAbsent(RumMonitor.Builder().build()) - } -} diff --git a/app/src/beta/kotlin/com/wire/android/navigation/TrackingNavController.kt b/app/src/beta/kotlin/com/wire/android/navigation/TrackingNavController.kt deleted file mode 100644 index a926407b586..00000000000 --- a/app/src/beta/kotlin/com/wire/android/navigation/TrackingNavController.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Wire - * Copyright (C) 2024 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ -package com.wire.android.navigation - -import androidx.compose.runtime.Composable -import androidx.navigation.NavDestination -import androidx.navigation.compose.rememberNavController -import com.datadog.android.compose.ExperimentalTrackingApi -import com.datadog.android.compose.NavigationViewTrackingEffect -import com.datadog.android.rum.tracking.AcceptAllNavDestinations - -@OptIn(ExperimentalTrackingApi::class) -@Composable -fun rememberTrackingAnimatedNavController(nameFromRoute: (String) -> String?) = - rememberNavController().apply { - NavigationViewTrackingEffect( - navController = this, - trackArguments = true, - destinationPredicate = object : AcceptAllNavDestinations() { - override fun getViewName(component: NavDestination): String? = - component.route?.let { nameFromRoute(it) } - } - ) - } diff --git a/app/src/beta/kotlin/com/wire/android/util/DataDogLogger.kt b/app/src/beta/kotlin/com/wire/android/util/DataDogLogger.kt deleted file mode 100644 index 547c9b0fd63..00000000000 --- a/app/src/beta/kotlin/com/wire/android/util/DataDogLogger.kt +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Wire - * Copyright (C) 2024 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -package com.wire.android.util - -import co.touchlab.kermit.LogWriter -import co.touchlab.kermit.Severity -import com.datadog.android.log.Logger -import com.wire.kalium.logger.KaliumLogger - -object DataDogLogger : LogWriter() { - - private val logger = Logger.Builder() - .setNetworkInfoEnabled(true) - .setLogcatLogsEnabled(false) // we already use platformLogWriter() along with DataDogLogger, don't need duplicates in LogCat - .setDatadogLogsEnabled(true) - .setBundleWithTraceEnabled(true) - .setLoggerName("DATADOG") - .build() - - override fun log(severity: Severity, message: String, tag: String, throwable: Throwable?) { - val logInfo = KaliumLogger.LogAttributes.getInfoFromTagString(tag) - val userAccountData = mapOf( - "userId" to logInfo.userClientData?.userId, - "clientId" to logInfo.userClientData?.clientId, - ) - val attributes = mapOf( - "wireAccount" to userAccountData, - "tag" to logInfo.textTag - ) - when (severity) { - Severity.Debug -> logger.d(message, throwable, attributes) - Severity.Info -> logger.i(message, throwable, attributes) - Severity.Warn -> logger.w(message, throwable, attributes) - Severity.Error -> logger.e(message, throwable, attributes) - Severity.Assert, - Severity.Verbose -> logger.v(message, throwable, attributes) - } - } -} diff --git a/app/src/dev/kotlin/com/wire/android/ExternalLoggerManager.kt b/app/src/dev/kotlin/com/wire/android/ExternalLoggerManager.kt deleted file mode 100644 index eca41807a5d..00000000000 --- a/app/src/dev/kotlin/com/wire/android/ExternalLoggerManager.kt +++ /dev/null @@ -1,66 +0,0 @@ -package com.wire.android - -import android.app.Activity -import android.content.Context -import com.datadog.android.Datadog -import com.datadog.android.DatadogSite -import com.datadog.android.core.configuration.Credentials -import com.datadog.android.privacy.TrackingConsent -import com.datadog.android.rum.GlobalRum -import com.datadog.android.rum.RumMonitor -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.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 environmentName = "internal" - val appVariantName = "com.wire.android.${BuildConfig.FLAVOR}.${BuildConfig.BUILD_TYPE}" - - val configuration = com.datadog.android.core.configuration.Configuration.Builder( - logsEnabled = true, - tracesEnabled = true, - rumEnabled = true, - crashReportsEnabled = true, - ) - .useViewTrackingStrategy( - ActivityViewTrackingStrategy( - trackExtras = true, - componentPredicate = object : ComponentPredicate { - override fun accept(component: Activity): Boolean { - // reject Activities which are hosts of Compose views, so that they are not counted as views - return component !is WireActivity - } - - override fun getViewName(component: Activity): String? = null - } - ) - ) - .trackInteractions() - .trackBackgroundRumEvents(true) - .trackLongTasks(LONG_TASK_THRESH_HOLD_MS) - .useSite(DatadogSite.EU1) - .build() - - val credentials = Credentials(clientToken, environmentName, appVariantName, applicationId) - val extraInfo = mapOf( - "encrypted_proteus_storage_enabled" to runBlocking { globalDataStore.isEncryptedProteusStorageEnabled().first() } - ) - - Datadog.initialize(context, credentials, configuration, TrackingConsent.GRANTED) - Datadog.setUserInfo(id = context.getDeviceIdString()?.sha256(), extraInfo = extraInfo) - GlobalRum.registerIfAbsent(RumMonitor.Builder().build()) - } -} diff --git a/app/src/internal/kotlin/com/wire/android/ExternalLoggerManager.kt b/app/src/external-logger-enabled/kotlin/com/wire/android/ExternalLoggerManager.kt similarity index 92% rename from app/src/internal/kotlin/com/wire/android/ExternalLoggerManager.kt rename to app/src/external-logger-enabled/kotlin/com/wire/android/ExternalLoggerManager.kt index 5aca1e45d52..c35cfdf6a44 100644 --- a/app/src/internal/kotlin/com/wire/android/ExternalLoggerManager.kt +++ b/app/src/external-logger-enabled/kotlin/com/wire/android/ExternalLoggerManager.kt @@ -12,10 +12,10 @@ 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 @@ -23,8 +23,12 @@ 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}" diff --git a/app/src/dev/kotlin/com/wire/android/navigation/TrackingNavController.kt b/app/src/external-logger-enabled/kotlin/com/wire/android/navigation/TrackingNavController.kt similarity index 100% rename from app/src/dev/kotlin/com/wire/android/navigation/TrackingNavController.kt rename to app/src/external-logger-enabled/kotlin/com/wire/android/navigation/TrackingNavController.kt diff --git a/app/src/dev/kotlin/com/wire/android/util/DataDogLogger.kt b/app/src/external-logger-enabled/kotlin/com/wire/android/util/DataDogLogger.kt similarity index 100% rename from app/src/dev/kotlin/com/wire/android/util/DataDogLogger.kt rename to app/src/external-logger-enabled/kotlin/com/wire/android/util/DataDogLogger.kt diff --git a/app/src/internal/kotlin/com/wire/android/navigation/TrackingNavController.kt b/app/src/internal/kotlin/com/wire/android/navigation/TrackingNavController.kt deleted file mode 100644 index 1f8cdea0516..00000000000 --- a/app/src/internal/kotlin/com/wire/android/navigation/TrackingNavController.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.wire.android.navigation - -import androidx.compose.runtime.Composable -import androidx.navigation.NavDestination -import com.datadog.android.compose.ExperimentalTrackingApi -import com.datadog.android.compose.NavigationViewTrackingEffect -import com.datadog.android.rum.tracking.AcceptAllNavDestinations -import androidx.navigation.compose.rememberNavController - -@OptIn(ExperimentalTrackingApi::class) -@Composable -fun rememberTrackingAnimatedNavController(nameFromRoute: (String) -> String?) = - rememberNavController().apply { - NavigationViewTrackingEffect( - navController = this, - trackArguments = true, - destinationPredicate = object : AcceptAllNavDestinations() { - override fun getViewName(component: NavDestination): String? = - component.route?.let { nameFromRoute(it) } - } - ) - } diff --git a/app/src/internal/kotlin/com/wire/android/util/DataDogLogger.kt b/app/src/internal/kotlin/com/wire/android/util/DataDogLogger.kt deleted file mode 100644 index 055d776ff8f..00000000000 --- a/app/src/internal/kotlin/com/wire/android/util/DataDogLogger.kt +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Wire - * Copyright (C) 2024 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - * - * - */ - -package com.wire.android.util - -import co.touchlab.kermit.LogWriter -import co.touchlab.kermit.Severity -import com.datadog.android.log.Logger -import com.wire.kalium.logger.KaliumLogger - -object DataDogLogger : LogWriter() { - - private val logger = Logger.Builder() - .setNetworkInfoEnabled(true) - .setLogcatLogsEnabled(false) // we already use platformLogWriter() along with DataDogLogger, don't need duplicates in LogCat - .setDatadogLogsEnabled(true) - .setBundleWithTraceEnabled(true) - .setLoggerName("DATADOG") - .build() - - override fun log(severity: Severity, message: String, tag: String, throwable: Throwable?) { - val logInfo = KaliumLogger.LogAttributes.getInfoFromTagString(tag) - val userAccountData = mapOf( - "userId" to logInfo.userClientData?.userId, - "clientId" to logInfo.userClientData?.clientId, - ) - val attributes = mapOf( - "wireAccount" to userAccountData, - "tag" to logInfo.textTag - ) - when (severity) { - Severity.Debug -> logger.d(message, throwable, attributes) - Severity.Info -> logger.i(message, throwable, attributes) - Severity.Warn -> logger.w(message, throwable, attributes) - Severity.Error -> logger.e(message, throwable, attributes) - Severity.Assert, - Severity.Verbose -> logger.v(message, throwable, attributes) - } - } -} diff --git a/app/src/staging/kotlin/com/wire/android/ExternalLoggerManager.kt b/app/src/staging/kotlin/com/wire/android/ExternalLoggerManager.kt index eca41807a5d..3bfe7e8264d 100644 --- a/app/src/staging/kotlin/com/wire/android/ExternalLoggerManager.kt +++ b/app/src/staging/kotlin/com/wire/android/ExternalLoggerManager.kt @@ -1,3 +1,20 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ package com.wire.android import android.app.Activity @@ -19,48 +36,3 @@ 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 environmentName = "internal" - val appVariantName = "com.wire.android.${BuildConfig.FLAVOR}.${BuildConfig.BUILD_TYPE}" - - val configuration = com.datadog.android.core.configuration.Configuration.Builder( - logsEnabled = true, - tracesEnabled = true, - rumEnabled = true, - crashReportsEnabled = true, - ) - .useViewTrackingStrategy( - ActivityViewTrackingStrategy( - trackExtras = true, - componentPredicate = object : ComponentPredicate { - override fun accept(component: Activity): Boolean { - // reject Activities which are hosts of Compose views, so that they are not counted as views - return component !is WireActivity - } - - override fun getViewName(component: Activity): String? = null - } - ) - ) - .trackInteractions() - .trackBackgroundRumEvents(true) - .trackLongTasks(LONG_TASK_THRESH_HOLD_MS) - .useSite(DatadogSite.EU1) - .build() - - val credentials = Credentials(clientToken, environmentName, appVariantName, applicationId) - val extraInfo = mapOf( - "encrypted_proteus_storage_enabled" to runBlocking { globalDataStore.isEncryptedProteusStorageEnabled().first() } - ) - - Datadog.initialize(context, credentials, configuration, TrackingConsent.GRANTED) - Datadog.setUserInfo(id = context.getDeviceIdString()?.sha256(), extraInfo = extraInfo) - GlobalRum.registerIfAbsent(RumMonitor.Builder().build()) - } -} diff --git a/app/src/staging/kotlin/com/wire/android/navigation/TrackingNavController.kt b/app/src/staging/kotlin/com/wire/android/navigation/TrackingNavController.kt deleted file mode 100644 index 1f8cdea0516..00000000000 --- a/app/src/staging/kotlin/com/wire/android/navigation/TrackingNavController.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.wire.android.navigation - -import androidx.compose.runtime.Composable -import androidx.navigation.NavDestination -import com.datadog.android.compose.ExperimentalTrackingApi -import com.datadog.android.compose.NavigationViewTrackingEffect -import com.datadog.android.rum.tracking.AcceptAllNavDestinations -import androidx.navigation.compose.rememberNavController - -@OptIn(ExperimentalTrackingApi::class) -@Composable -fun rememberTrackingAnimatedNavController(nameFromRoute: (String) -> String?) = - rememberNavController().apply { - NavigationViewTrackingEffect( - navController = this, - trackArguments = true, - destinationPredicate = object : AcceptAllNavDestinations() { - override fun getViewName(component: NavDestination): String? = - component.route?.let { nameFromRoute(it) } - } - ) - } diff --git a/app/src/staging/kotlin/com/wire/android/util/DataDogLogger.kt b/app/src/staging/kotlin/com/wire/android/util/DataDogLogger.kt deleted file mode 100644 index 055d776ff8f..00000000000 --- a/app/src/staging/kotlin/com/wire/android/util/DataDogLogger.kt +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Wire - * Copyright (C) 2024 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - * - * - */ - -package com.wire.android.util - -import co.touchlab.kermit.LogWriter -import co.touchlab.kermit.Severity -import com.datadog.android.log.Logger -import com.wire.kalium.logger.KaliumLogger - -object DataDogLogger : LogWriter() { - - private val logger = Logger.Builder() - .setNetworkInfoEnabled(true) - .setLogcatLogsEnabled(false) // we already use platformLogWriter() along with DataDogLogger, don't need duplicates in LogCat - .setDatadogLogsEnabled(true) - .setBundleWithTraceEnabled(true) - .setLoggerName("DATADOG") - .build() - - override fun log(severity: Severity, message: String, tag: String, throwable: Throwable?) { - val logInfo = KaliumLogger.LogAttributes.getInfoFromTagString(tag) - val userAccountData = mapOf( - "userId" to logInfo.userClientData?.userId, - "clientId" to logInfo.userClientData?.clientId, - ) - val attributes = mapOf( - "wireAccount" to userAccountData, - "tag" to logInfo.textTag - ) - when (severity) { - Severity.Debug -> logger.d(message, throwable, attributes) - Severity.Info -> logger.i(message, throwable, attributes) - Severity.Warn -> logger.w(message, throwable, attributes) - Severity.Error -> logger.e(message, throwable, attributes) - Severity.Assert, - Severity.Verbose -> logger.v(message, throwable, attributes) - } - } -}