Skip to content

Commit

Permalink
MOB-310: Add tracking to DydxRouter
Browse files Browse the repository at this point in the history
  • Loading branch information
ruixhuang committed Mar 7, 2024
1 parent 8f2c793 commit ab8f25d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
16 changes: 10 additions & 6 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand All @@ -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()
Expand Down
14 changes: 14 additions & 0 deletions v4/core/src/main/java/exchange/dydx/trading/core/DydxRouterImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -66,6 +68,16 @@ class DydxRouterImpl(

val destinationRoute = destination.route
if (destinationRoute != null) {

val trackingData: MutableMap<String, String> = mutableMapOf()
destination.arguments.keys.forEach { key ->
trackingData[key] = arguments?.getString(key) ?: ""
}
tracker.log(
event = destinationRoute,
data = trackingData,
)

if (tabRoutes.contains(destinationRoute)) {
routeQueue.clear()
}
Expand All @@ -85,6 +97,8 @@ class DydxRouterImpl(
}
pendingPresentation = null
}
} else {
Timber.tag(TAG).w("Destination route is null")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -20,10 +21,12 @@ object CoreModule {
fun provideApplicationRouter(
@ApplicationContext androidContext: Context,
appConfig: AppConfig,
tracker: Tracking,
): DydxRouter {
return DydxRouterImpl(
androidContext = androidContext,
appConfig = appConfig,
tracker = tracker,
)
}
}

0 comments on commit ab8f25d

Please sign in to comment.