Updated on 2026-08-14

This commit is contained in:
Tangem 2025-12-19 21:58:34 +05:00
parent 2db9958dd1
commit 7b9cf3f4e1
2 changed files with 49 additions and 34 deletions

View file

@ -121,6 +121,8 @@ internal class WalletModel @Inject constructor(
private var expressTxStatusTaskScheduler = SingleTaskScheduler<Unit>()
init {
trackScreenOpened()
updateMarketToggle()
suggestToOpenMarkets()
@ -139,9 +141,7 @@ internal class WalletModel @Inject constructor(
}
fun onResume() {
modelScope.launch(dispatchers.main) {
suggestToEnableBiometrics()
}
suggestToEnableBiometrics()
}
private fun updateMarketToggle() {
@ -178,13 +178,15 @@ internal class WalletModel @Inject constructor(
walletScreenContentLoader.cancelAll()
}
private suspend fun suggestToEnableBiometrics() {
if (shouldShowAskBiometryBottomSheet()) {
delay(timeMillis = 1_800)
private fun suggestToEnableBiometrics() {
modelScope.launch(dispatchers.main) {
if (shouldShowAskBiometryBottomSheet()) {
delay(timeMillis = 1_800)
innerWalletRouter.dialogNavigation.activate(
configuration = WalletDialogConfig.AskForBiometry,
)
innerWalletRouter.dialogNavigation.activate(
configuration = WalletDialogConfig.AskForBiometry,
)
}
}
}
@ -202,6 +204,42 @@ internal class WalletModel @Inject constructor(
}
}
private fun trackScreenOpened() {
if (hotWalletFeatureToggles.isHotWalletEnabled) {
modelScope.launch {
userWalletsListRepository
.selectedUserWalletSync()
?.let { selectedWallet ->
val hasMobileWallet = userWalletsListRepository.userWalletsSync()
.any { it is UserWallet.Hot }
val accountsCount = if (isAccountsModeEnabledUseCase.invokeSync()) {
singleAccountListSupplier(selectedWallet.walletId)
.first()
.accounts
.size
} else {
null
}
val result = getAppThemeModeUseCase().firstOrNull()
val theme = result?.getOrElse { AppThemeMode.FOLLOW_SYSTEM } ?: AppThemeMode.FOLLOW_SYSTEM
analyticsEventsHandler.send(
WalletScreenAnalyticsEvent.MainScreen.ScreenOpened(
hasMobileWallet = hasMobileWallet,
accountsCount = accountsCount,
theme = theme.value,
isImported = selectedWallet.isImported(),
),
)
}
}
} else {
analyticsEventsHandler.send(
WalletScreenAnalyticsEvent.MainScreen.ScreenOpenedLegacy(),
)
}
}
private suspend fun shouldShowAskBiometryBottomSheet(): Boolean {
return if (hotWalletFeatureToggles.isHotWalletEnabled) {
userWalletsListRepository.userWalletsSync().any { it is UserWallet.Cold } &&
@ -289,31 +327,6 @@ internal class WalletModel @Inject constructor(
.onEach { selectedWallet ->
trackingContextProxy.setContext(selectedWallet)
if (hotWalletFeatureToggles.isHotWalletEnabled) {
modelScope.launch {
val hasMobileWallet = userWalletsListRepository.userWalletsSync()
.any { it is UserWallet.Hot }
val accountsCount = if (isAccountsModeEnabledUseCase.invokeSync()) {
singleAccountListSupplier(selectedWallet.walletId)
.first()
.accounts
.size
} else {
null
}
val result = getAppThemeModeUseCase().firstOrNull()
val theme = result?.getOrElse { AppThemeMode.FOLLOW_SYSTEM } ?: AppThemeMode.FOLLOW_SYSTEM
analyticsEventsHandler.send(
WalletScreenAnalyticsEvent.MainScreen.ScreenOpened(
hasMobileWallet = hasMobileWallet,
accountsCount = accountsCount,
theme = theme.value,
isImported = selectedWallet.isImported(),
),
)
}
}
if (selectedWallet.isMultiCurrency) {
selectedWalletAnalyticsSender.send(selectedWallet)
}

View file

@ -51,6 +51,8 @@ sealed class WalletScreenAnalyticsEvent {
params: Map<String, String> = mapOf(),
) : AnalyticsEvent(category = "Main Screen", event = event, params = params) {
class ScreenOpenedLegacy : MainScreen(event = "Screen opened")
data class ScreenOpened(
private val hasMobileWallet: Boolean,
private val accountsCount: Int?,