From ab8f25d931aa60839a5480371c300f42d89aedcc Mon Sep 17 00:00:00 2001 From: Rui Date: Thu, 7 Mar 2024 11:26:27 -0500 Subject: [PATCH] MOB-310: Add tracking to DydxRouter --- settings.gradle | 16 ++++++++++------ .../exchange/dydx/trading/core/DydxRouterImpl.kt | 14 ++++++++++++++ .../exchange/dydx/trading/core/di/CoreModule.kt | 3 +++ 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/settings.gradle b/settings.gradle index a1a0ffaa..faed481d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -20,9 +20,11 @@ dependencyResolutionManagement { def github_token = System.getenv('github_token') name = "GitHubPackages_Cartera" url = uri("https://maven.pkg.github.com/dydxprotocol/cartera-android") - credentials { - username github_username - password github_token + if (github_username != null && github_token != null) { + credentials { + username github_username + password github_token + } } } @@ -31,9 +33,11 @@ dependencyResolutionManagement { def github_token = System.getenv('github_token') name = "GitHubPackages_Abacus" url = uri("https://maven.pkg.github.com/dydxprotocol/v4-abacus") - credentials { - username github_username - password github_token + if (github_username != null && github_token != null) { + credentials { + username github_username + password github_token + } } } // mavenLocal() diff --git a/v4/core/src/main/java/exchange/dydx/trading/core/DydxRouterImpl.kt b/v4/core/src/main/java/exchange/dydx/trading/core/DydxRouterImpl.kt index f799539f..8b89c470 100644 --- a/v4/core/src/main/java/exchange/dydx/trading/core/DydxRouterImpl.kt +++ b/v4/core/src/main/java/exchange/dydx/trading/core/DydxRouterImpl.kt @@ -14,6 +14,7 @@ import exchange.dydx.trading.common.AppConfig import exchange.dydx.trading.common.navigation.DydxRouter import exchange.dydx.trading.common.navigation.DydxRouter.Destination import exchange.dydx.trading.common.navigation.MarketRoutes +import exchange.dydx.trading.integration.analytics.Tracking import kotlinx.coroutines.flow.MutableStateFlow import timber.log.Timber @@ -29,6 +30,7 @@ private const val TAG = "DydxRouterImpl" class DydxRouterImpl( override var androidContext: Context?, private val appConfig: AppConfig, + private val tracker: Tracking, ) : DydxRouter { private lateinit var navHostController: NavHostController @@ -66,6 +68,16 @@ class DydxRouterImpl( val destinationRoute = destination.route if (destinationRoute != null) { + + val trackingData: MutableMap = mutableMapOf() + destination.arguments.keys.forEach { key -> + trackingData[key] = arguments?.getString(key) ?: "" + } + tracker.log( + event = destinationRoute, + data = trackingData, + ) + if (tabRoutes.contains(destinationRoute)) { routeQueue.clear() } @@ -85,6 +97,8 @@ class DydxRouterImpl( } pendingPresentation = null } + } else { + Timber.tag(TAG).w("Destination route is null") } } diff --git a/v4/core/src/main/java/exchange/dydx/trading/core/di/CoreModule.kt b/v4/core/src/main/java/exchange/dydx/trading/core/di/CoreModule.kt index 6a57cb40..23272608 100644 --- a/v4/core/src/main/java/exchange/dydx/trading/core/di/CoreModule.kt +++ b/v4/core/src/main/java/exchange/dydx/trading/core/di/CoreModule.kt @@ -10,6 +10,7 @@ import dagger.hilt.android.scopes.ActivityRetainedScoped import exchange.dydx.trading.common.AppConfig import exchange.dydx.trading.common.navigation.DydxRouter import exchange.dydx.trading.core.DydxRouterImpl +import exchange.dydx.trading.integration.analytics.Tracking @Module @InstallIn(ActivityRetainedComponent::class) @@ -20,10 +21,12 @@ object CoreModule { fun provideApplicationRouter( @ApplicationContext androidContext: Context, appConfig: AppConfig, + tracker: Tracking, ): DydxRouter { return DydxRouterImpl( androidContext = androidContext, appConfig = appConfig, + tracker = tracker, ) } }