Updated on 2026-08-14
This commit is contained in:
parent
912510da57
commit
724748ee8c
16 changed files with 203 additions and 58 deletions
|
|
@ -30,8 +30,14 @@ sealed class AnalyticsParam {
|
|||
}
|
||||
|
||||
sealed class OnOffState(val value: String) {
|
||||
|
||||
object On : OnOffState("On")
|
||||
object Off : OnOffState("Off")
|
||||
|
||||
companion object {
|
||||
|
||||
operator fun invoke(value: Boolean): OnOffState = if (value) On else Off
|
||||
}
|
||||
}
|
||||
|
||||
sealed class UserCode(val value: String) {
|
||||
|
|
|
|||
|
|
@ -89,5 +89,12 @@ sealed class Settings(
|
|||
event = "App Theme Switched",
|
||||
params = mapOf("State" to theme.value),
|
||||
)
|
||||
|
||||
object EnableBiometrics : AppSettings(event = "Notice - Enable Biometric")
|
||||
|
||||
class HideBalanceChanged(state: AnalyticsParam.OnOffState) : AppSettings(
|
||||
event = "Hide Balance Changed",
|
||||
params = mapOf("State" to state.value),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -58,6 +58,7 @@ internal class AppSettingsViewModel(
|
|||
private fun buildItems(state: AppSettingsState): ImmutableList<AppSettingsScreenState.Item> {
|
||||
val items = buildList {
|
||||
if (state.needEnrollBiometrics) {
|
||||
Analytics.send(Settings.AppSettings.EnableBiometrics)
|
||||
itemsFactory.createEnrollBiometricsCard(onClick = ::enrollBiometrics).let(::add)
|
||||
}
|
||||
|
||||
|
|
@ -165,6 +166,9 @@ internal class AppSettingsViewModel(
|
|||
}
|
||||
|
||||
private fun onFlipToHideBalanceToggled(enable: Boolean) {
|
||||
val param = AnalyticsParam.OnOffState(enable)
|
||||
Analytics.send(Settings.AppSettings.HideBalanceChanged(param))
|
||||
|
||||
store.dispatch(DetailsAction.AppSettings.ChangeBalanceHiding(hideBalance = enable))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,5 +62,33 @@ sealed class WalletScreenAnalyticsEvent {
|
|||
object NoticeScanYourCardTapped : MainScreen(event = "Notice - Scan Your Card Tapped")
|
||||
object NoticeWalletLocked : MainScreen(event = "Notice - Wallet Locked")
|
||||
object WalletUnlockTapped : MainScreen(event = "Button - Wallet Unlock Tapped")
|
||||
|
||||
object NetworksUnreachable : MainScreen(event = "Notice - Networks Unreachable")
|
||||
|
||||
object MissingAddresses : MainScreen(event = "Notice - Missing Addresses")
|
||||
|
||||
object CardSignedTransactions : MainScreen(event = "Notice - Card Signed Transactions")
|
||||
|
||||
object HowDoYouLikeTangem : MainScreen(event = "Notice - How Do You Like Tangem")
|
||||
|
||||
object ProductSampleCard : MainScreen(event = "Notice - Product Sample Card")
|
||||
|
||||
object TestnetCard : MainScreen(event = "Notice - Testnet Card")
|
||||
|
||||
object DemoCard : MainScreen(event = "Notice - Demo Card")
|
||||
|
||||
object DevelopmentCard : MainScreen(event = "Notice - Development Card")
|
||||
|
||||
object WalletUnlock : MainScreen(event = "Notice - Wallet Unlock")
|
||||
|
||||
object BackupYourWallet : MainScreen(event = "Notice - Backup Your Wallet")
|
||||
|
||||
object UnlockAllWithFaceID : MainScreen(event = "Button - Unlock All With Face ID")
|
||||
|
||||
object UnlockWithCardScan : MainScreen(event = "Button - Unlock With Card Scan")
|
||||
|
||||
object EditWalletTapped : MainScreen(event = "Button - Edit Wallet Tapped")
|
||||
|
||||
object DeleteWalletTapped : MainScreen(event = "Button - Delete Wallet Tapped")
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,8 @@ import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
|||
import com.tangem.domain.tokens.model.NetworkGroup
|
||||
import com.tangem.domain.tokens.model.TokenList
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.WalletScreenAnalyticsEvent
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.WalletScreenAnalyticsEvent.Basic
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.WalletScreenAnalyticsEvent.MainScreen
|
||||
import dagger.hilt.android.scopes.ViewModelScoped
|
||||
import java.math.BigDecimal
|
||||
import javax.inject.Inject
|
||||
|
|
@ -23,58 +24,45 @@ internal class TokenListAnalyticsSender @Inject constructor(
|
|||
) {
|
||||
|
||||
suspend fun send(userWallet: UserWallet, maybeTokenList: Either<TokenListError, TokenList>) {
|
||||
val tokenList = (maybeTokenList as? Either.Right)?.value ?: return
|
||||
val tokenList = maybeTokenList.getOrElse { return }
|
||||
|
||||
sendBalanceLoadedEventIfNeeded(tokenList)
|
||||
sendToppedUpEventIfNeeded(tokenList, userWallet)
|
||||
if (tokenList.totalFiatBalance is TokenList.FiatBalance.Loading) return
|
||||
|
||||
val currenciesStatuses = getCurrenciesStatuses(tokenList)
|
||||
|
||||
sendBalanceLoadedEventIfNeeded(tokenList.totalFiatBalance, currenciesStatuses)
|
||||
sendToppedUpEventIfNeeded(userWallet, tokenList.totalFiatBalance, currenciesStatuses)
|
||||
sendUnreachableNetworksEventIfNeeded(currenciesStatuses)
|
||||
sendMissedAddressesEventIfNeeded(currenciesStatuses)
|
||||
}
|
||||
|
||||
private fun sendBalanceLoadedEventIfNeeded(tokenList: TokenList) {
|
||||
createCardBalanceState(tokenList)?.let { balanceState ->
|
||||
analyticsEventHandler.send(event = WalletScreenAnalyticsEvent.Basic.BalanceLoaded(balanceState))
|
||||
private fun getCurrenciesStatuses(tokenList: TokenList): List<CryptoCurrencyStatus> = when (tokenList) {
|
||||
is TokenList.Empty -> emptyList()
|
||||
is TokenList.GroupedByNetwork -> tokenList.groups.flatMap(NetworkGroup::currencies)
|
||||
is TokenList.Ungrouped -> tokenList.currencies
|
||||
}
|
||||
|
||||
private fun sendBalanceLoadedEventIfNeeded(
|
||||
fiatBalance: TokenList.FiatBalance,
|
||||
currenciesStatuses: List<CryptoCurrencyStatus>,
|
||||
) {
|
||||
createCardBalanceState(fiatBalance, currenciesStatuses)?.let { balanceState ->
|
||||
analyticsEventHandler.send(Basic.BalanceLoaded(balanceState))
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun sendToppedUpEventIfNeeded(tokenList: TokenList, userWallet: UserWallet) {
|
||||
val balanceState = tokenList.toWalletBalanceState() ?: return
|
||||
|
||||
val isWalletToppedUp = checkIsWalletToppedUpUseCase(userWallet.walletId, balanceState)
|
||||
.getOrElse { return }
|
||||
|
||||
if (isWalletToppedUp) {
|
||||
val walletType = if (userWallet.isMultiCurrency) {
|
||||
AnalyticsParam.WalletType.MultiCurrency
|
||||
} else {
|
||||
// For single currency wallets with token list, e.g. Noodle
|
||||
val currency = when (tokenList) {
|
||||
is TokenList.Empty -> return
|
||||
is TokenList.GroupedByNetwork -> tokenList.groups.first().currencies.first()
|
||||
is TokenList.Ungrouped -> tokenList.currencies.first()
|
||||
}
|
||||
|
||||
AnalyticsParam.WalletType.SingleCurrency(currency.currency.name)
|
||||
}
|
||||
|
||||
analyticsEventHandler.send(WalletScreenAnalyticsEvent.Basic.WalletToppedUp(userWallet.walletId, walletType))
|
||||
}
|
||||
}
|
||||
|
||||
private fun createCardBalanceState(tokenList: TokenList): AnalyticsParam.CardBalanceState? {
|
||||
return when (val fiatBalance = tokenList.totalFiatBalance) {
|
||||
is TokenList.FiatBalance.Failed -> fiatBalance.toCardBalanceState(tokenList)
|
||||
is TokenList.FiatBalance.Loaded -> fiatBalance.toCardBalanceState()
|
||||
private fun createCardBalanceState(
|
||||
fiatBalance: TokenList.FiatBalance,
|
||||
currenciesStatuses: List<CryptoCurrencyStatus>,
|
||||
): AnalyticsParam.CardBalanceState? {
|
||||
return when (fiatBalance) {
|
||||
is TokenList.FiatBalance.Failed -> getCardBalanceState(currenciesStatuses)
|
||||
is TokenList.FiatBalance.Loaded -> getCardBalanceState(fiatBalance)
|
||||
is TokenList.FiatBalance.Loading -> null
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("UnusedReceiverParameter")
|
||||
private fun TokenList.FiatBalance.Failed.toCardBalanceState(tokenList: TokenList): AnalyticsParam.CardBalanceState {
|
||||
val currenciesStatuses = when (tokenList) {
|
||||
is TokenList.Empty -> emptyList()
|
||||
is TokenList.GroupedByNetwork -> tokenList.groups.flatMap(NetworkGroup::currencies)
|
||||
is TokenList.Ungrouped -> tokenList.currencies
|
||||
}
|
||||
|
||||
private fun getCardBalanceState(currenciesStatuses: List<CryptoCurrencyStatus>): AnalyticsParam.CardBalanceState {
|
||||
return when {
|
||||
currenciesStatuses.isEmpty() -> AnalyticsParam.CardBalanceState.Empty
|
||||
currenciesStatuses.any { it.value is CryptoCurrencyStatus.NoQuote } -> {
|
||||
|
|
@ -84,19 +72,43 @@ internal class TokenListAnalyticsSender @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun TokenList.FiatBalance.Loaded.toCardBalanceState(): AnalyticsParam.CardBalanceState {
|
||||
return if (amount > BigDecimal.ZERO) {
|
||||
private fun getCardBalanceState(fiatBalance: TokenList.FiatBalance.Loaded): AnalyticsParam.CardBalanceState {
|
||||
return if (fiatBalance.amount > BigDecimal.ZERO) {
|
||||
AnalyticsParam.CardBalanceState.Full
|
||||
} else {
|
||||
AnalyticsParam.CardBalanceState.Empty
|
||||
}
|
||||
}
|
||||
|
||||
private fun TokenList.toWalletBalanceState(): WalletBalanceState? {
|
||||
return when (val balance = totalFiatBalance) {
|
||||
private suspend fun sendToppedUpEventIfNeeded(
|
||||
userWallet: UserWallet,
|
||||
fiatBalance: TokenList.FiatBalance,
|
||||
currenciesStatuses: List<CryptoCurrencyStatus>,
|
||||
) {
|
||||
val balanceState = getWalletBalanceState(fiatBalance) ?: return
|
||||
|
||||
val isWalletToppedUp = checkIsWalletToppedUpUseCase(userWallet.walletId, balanceState)
|
||||
.getOrElse { return }
|
||||
|
||||
if (isWalletToppedUp) {
|
||||
val walletType = if (userWallet.isMultiCurrency) {
|
||||
AnalyticsParam.WalletType.MultiCurrency
|
||||
} else {
|
||||
// For single currency wallets with token list, e.g. Noodle
|
||||
val currency = currenciesStatuses.firstOrNull() ?: return
|
||||
|
||||
AnalyticsParam.WalletType.SingleCurrency(currency.currency.name)
|
||||
}
|
||||
|
||||
analyticsEventHandler.send(Basic.WalletToppedUp(userWallet.walletId, walletType))
|
||||
}
|
||||
}
|
||||
|
||||
private fun getWalletBalanceState(fiatBalance: TokenList.FiatBalance): WalletBalanceState? {
|
||||
return when (fiatBalance) {
|
||||
is TokenList.FiatBalance.Failed -> WalletBalanceState.Error
|
||||
is TokenList.FiatBalance.Loaded -> {
|
||||
if (balance.amount > BigDecimal.ZERO) {
|
||||
if (fiatBalance.amount > BigDecimal.ZERO) {
|
||||
WalletBalanceState.ToppedUp
|
||||
} else {
|
||||
WalletBalanceState.Empty
|
||||
|
|
@ -105,4 +117,22 @@ internal class TokenListAnalyticsSender @Inject constructor(
|
|||
is TokenList.FiatBalance.Loading -> null
|
||||
}
|
||||
}
|
||||
|
||||
private fun sendUnreachableNetworksEventIfNeeded(currenciesStatuses: List<CryptoCurrencyStatus>) {
|
||||
val hasUnreachableCurrencies = currenciesStatuses.any { it.value is CryptoCurrencyStatus.Unreachable }
|
||||
|
||||
if (hasUnreachableCurrencies) {
|
||||
analyticsEventHandler.send(MainScreen.NetworksUnreachable)
|
||||
}
|
||||
}
|
||||
|
||||
private fun sendMissedAddressesEventIfNeeded(currenciesStatuses: List<CryptoCurrencyStatus>) {
|
||||
val hasCurrenciesWithMissedDerivation = currenciesStatuses.any {
|
||||
it.value is CryptoCurrencyStatus.MissedDerivation
|
||||
}
|
||||
|
||||
if (hasCurrenciesWithMissedDerivation) {
|
||||
analyticsEventHandler.send(MainScreen.MissingAddresses)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.analytics.utils
|
||||
|
||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.WalletScreenAnalyticsEvent.MainScreen
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletNotification
|
||||
import dagger.hilt.android.scopes.ViewModelScoped
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import javax.inject.Inject
|
||||
|
||||
@ViewModelScoped
|
||||
internal class WalletWarningsAnalyticsSender @Inject constructor(
|
||||
private val analyticsEventHandler: AnalyticsEventHandler,
|
||||
) {
|
||||
|
||||
fun send(warnings: ImmutableList<WalletNotification>) {
|
||||
val analyticsEvents = warnings.mapNotNull { warning ->
|
||||
when (warning) {
|
||||
is WalletNotification.Critical.DevCard -> MainScreen.DevelopmentCard
|
||||
is WalletNotification.Informational.DemoCard -> MainScreen.DemoCard
|
||||
is WalletNotification.RateApp -> MainScreen.HowDoYouLikeTangem
|
||||
is WalletNotification.Warning.NumberOfSignedHashesIncorrect -> MainScreen.CardSignedTransactions
|
||||
is WalletNotification.Warning.TestNetCard -> MainScreen.TestnetCard
|
||||
is WalletNotification.UnlockWallets -> MainScreen.WalletUnlock
|
||||
is WalletNotification.Critical.FailedCardValidation -> MainScreen.ProductSampleCard
|
||||
is WalletNotification.Warning.MissingBackup -> MainScreen.BackupYourWallet
|
||||
is WalletNotification.Informational.MissingAddresses,
|
||||
is WalletNotification.Informational.NoAccount,
|
||||
is WalletNotification.Warning.LowSignatures,
|
||||
is WalletNotification.Warning.NetworksUnreachable,
|
||||
is WalletNotification.Warning.SomeNetworksUnreachable,
|
||||
-> null
|
||||
}
|
||||
}
|
||||
|
||||
analyticsEvents.forEach { event ->
|
||||
analyticsEventHandler.send(event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import com.tangem.domain.redux.ReduxStateHolder
|
|||
import com.tangem.domain.tokens.GetTokenListUseCase
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.TokenListAnalyticsSender
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.WalletWarningsAnalyticsSender
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.GetMultiWalletWarningsFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletWithFundsChecker
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.WalletStateController
|
||||
|
|
@ -20,6 +21,7 @@ internal class MultiWalletContentLoader(
|
|||
private val stateHolder: WalletStateController,
|
||||
private val clickIntents: WalletClickIntentsV2,
|
||||
private val tokenListAnalyticsSender: TokenListAnalyticsSender,
|
||||
private val walletWarningsAnalyticsSender: WalletWarningsAnalyticsSender,
|
||||
private val walletWithFundsChecker: WalletWithFundsChecker,
|
||||
private val getTokenListUseCase: GetTokenListUseCase,
|
||||
private val getSelectedAppCurrencyUseCase: GetSelectedAppCurrencyUseCase,
|
||||
|
|
@ -43,6 +45,7 @@ internal class MultiWalletContentLoader(
|
|||
stateHolder = stateHolder,
|
||||
clickIntents = clickIntents,
|
||||
getMultiWalletWarningsFactory = getMultiWalletWarningsFactory,
|
||||
walletWarningsAnalyticsSender = walletWarningsAnalyticsSender,
|
||||
),
|
||||
WalletConnectNetworksSubscriber(
|
||||
userWallet = userWallet,
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.tangem.domain.redux.ReduxStateHolder
|
|||
import com.tangem.domain.tokens.GetTokenListUseCase
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.TokenListAnalyticsSender
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.WalletWarningsAnalyticsSender
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.GetMultiWalletWarningsFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletWithFundsChecker
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.WalletStateController
|
||||
|
|
@ -22,6 +23,7 @@ internal class MultiWalletContentLoaderFactory @Inject constructor(
|
|||
private val getTokenListUseCase: GetTokenListUseCase,
|
||||
private val getSelectedAppCurrencyUseCase: GetSelectedAppCurrencyUseCase,
|
||||
private val reduxStateHolder: ReduxStateHolder,
|
||||
private val walletWarningsAnalyticsSender: WalletWarningsAnalyticsSender,
|
||||
) {
|
||||
|
||||
fun create(userWallet: UserWallet, clickIntents: WalletClickIntentsV2): WalletContentLoader {
|
||||
|
|
@ -35,6 +37,7 @@ internal class MultiWalletContentLoaderFactory @Inject constructor(
|
|||
getSelectedAppCurrencyUseCase = getSelectedAppCurrencyUseCase,
|
||||
getMultiWalletWarningsFactory = getMultiWalletWarningsFactory,
|
||||
reduxStateHolder = reduxStateHolder,
|
||||
walletWarningsAnalyticsSender = walletWarningsAnalyticsSender,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ import com.tangem.domain.tokens.GetPrimaryCurrencyStatusUpdatesUseCase
|
|||
import com.tangem.domain.txhistory.usecase.GetTxHistoryItemsCountUseCase
|
||||
import com.tangem.domain.txhistory.usecase.GetTxHistoryItemsUseCase
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.WalletWarningsAnalyticsSender
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.GetSingleWalletWarningsFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.WalletStateController
|
||||
import com.tangem.feature.wallet.presentation.wallet.subscribers.*
|
||||
|
|
@ -27,6 +28,7 @@ internal class SingleWalletContentLoader(
|
|||
private val txHistoryItemsUseCase: GetTxHistoryItemsUseCase,
|
||||
private val getSelectedAppCurrencyUseCase: GetSelectedAppCurrencyUseCase,
|
||||
private val analyticsEventHandler: AnalyticsEventHandler,
|
||||
private val walletWarningsAnalyticsSender: WalletWarningsAnalyticsSender,
|
||||
) : WalletContentLoader(id = userWallet.walletId) {
|
||||
|
||||
override fun create(): List<WalletSubscriber> {
|
||||
|
|
@ -51,6 +53,7 @@ internal class SingleWalletContentLoader(
|
|||
stateHolder = stateHolder,
|
||||
clickIntents = clickIntents,
|
||||
getSingleWalletWarningsFactory = getSingleWalletWarningsFactory,
|
||||
walletWarningsAnalyticsSender = walletWarningsAnalyticsSender,
|
||||
),
|
||||
TxHistorySubscriber(
|
||||
userWallet = userWallet,
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.tangem.domain.tokens.GetPrimaryCurrencyStatusUpdatesUseCase
|
|||
import com.tangem.domain.txhistory.usecase.GetTxHistoryItemsCountUseCase
|
||||
import com.tangem.domain.txhistory.usecase.GetTxHistoryItemsUseCase
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.WalletWarningsAnalyticsSender
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.GetSingleWalletWarningsFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.WalletStateController
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
|
|
@ -26,6 +27,7 @@ internal class SingleWalletContentLoaderFactory @Inject constructor(
|
|||
private val txHistoryItemsUseCase: GetTxHistoryItemsUseCase,
|
||||
private val getSelectedAppCurrencyUseCase: GetSelectedAppCurrencyUseCase,
|
||||
private val analyticsEventHandler: AnalyticsEventHandler,
|
||||
private val walletWarningsAnalyticsSender: WalletWarningsAnalyticsSender,
|
||||
) {
|
||||
|
||||
fun create(userWallet: UserWallet, clickIntents: WalletClickIntentsV2, isRefresh: Boolean): WalletContentLoader {
|
||||
|
|
@ -42,6 +44,7 @@ internal class SingleWalletContentLoaderFactory @Inject constructor(
|
|||
txHistoryItemsUseCase = txHistoryItemsUseCase,
|
||||
getSelectedAppCurrencyUseCase = getSelectedAppCurrencyUseCase,
|
||||
analyticsEventHandler = analyticsEventHandler,
|
||||
walletWarningsAnalyticsSender = walletWarningsAnalyticsSender,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase
|
|||
import com.tangem.domain.tokens.GetCardTokensListUseCase
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.TokenListAnalyticsSender
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.WalletWarningsAnalyticsSender
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.GetMultiWalletWarningsFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletWithFundsChecker
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.WalletStateController
|
||||
|
|
@ -18,6 +19,7 @@ internal class SingleWalletWithTokenContentLoader(
|
|||
private val clickIntents: WalletClickIntentsV2,
|
||||
private val stateHolder: WalletStateController,
|
||||
private val tokenListAnalyticsSender: TokenListAnalyticsSender,
|
||||
private val walletWarningsAnalyticsSender: WalletWarningsAnalyticsSender,
|
||||
private val walletWithFundsChecker: WalletWithFundsChecker,
|
||||
private val getMultiWalletWarningsFactory: GetMultiWalletWarningsFactory,
|
||||
private val getCardTokensListUseCase: GetCardTokensListUseCase,
|
||||
|
|
@ -40,6 +42,7 @@ internal class SingleWalletWithTokenContentLoader(
|
|||
stateHolder = stateHolder,
|
||||
clickIntents = clickIntents,
|
||||
getMultiWalletWarningsFactory = getMultiWalletWarningsFactory,
|
||||
walletWarningsAnalyticsSender = walletWarningsAnalyticsSender,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,12 +4,15 @@ import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase
|
|||
import com.tangem.domain.tokens.GetCardTokensListUseCase
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.TokenListAnalyticsSender
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.WalletWarningsAnalyticsSender
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.GetMultiWalletWarningsFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.WalletWithFundsChecker
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.WalletStateController
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntentsV2
|
||||
import javax.inject.Inject
|
||||
|
||||
// TODO: Refactor
|
||||
@Suppress("LongParameterList")
|
||||
internal class SingleWalletWithTokenContentLoaderFactory @Inject constructor(
|
||||
private val stateHolder: WalletStateController,
|
||||
private val tokenListAnalyticsSender: TokenListAnalyticsSender,
|
||||
|
|
@ -17,6 +20,7 @@ internal class SingleWalletWithTokenContentLoaderFactory @Inject constructor(
|
|||
private val getMultiWalletWarningsFactory: GetMultiWalletWarningsFactory,
|
||||
private val getCardTokensListUseCase: GetCardTokensListUseCase,
|
||||
private val getSelectedAppCurrencyUseCase: GetSelectedAppCurrencyUseCase,
|
||||
private val walletWarningsAnalyticsSender: WalletWarningsAnalyticsSender,
|
||||
) {
|
||||
|
||||
fun create(userWallet: UserWallet, clickIntents: WalletClickIntentsV2): SingleWalletWithTokenContentLoader {
|
||||
|
|
@ -29,6 +33,7 @@ internal class SingleWalletWithTokenContentLoaderFactory @Inject constructor(
|
|||
getMultiWalletWarningsFactory = getMultiWalletWarningsFactory,
|
||||
getCardTokensListUseCase = getCardTokensListUseCase,
|
||||
getSelectedAppCurrencyUseCase = getSelectedAppCurrencyUseCase,
|
||||
walletWarningsAnalyticsSender = walletWarningsAnalyticsSender,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.subscribers
|
||||
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.WalletWarningsAnalyticsSender
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.GetMultiWalletWarningsFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletNotification
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.WalletStateController
|
||||
|
|
@ -18,16 +19,16 @@ internal class MultiWalletWarningsSubscriber(
|
|||
private val stateHolder: WalletStateController,
|
||||
private val clickIntents: WalletClickIntentsV2,
|
||||
private val getMultiWalletWarningsFactory: GetMultiWalletWarningsFactory,
|
||||
private val walletWarningsAnalyticsSender: WalletWarningsAnalyticsSender,
|
||||
) : WalletSubscriber() {
|
||||
|
||||
override fun create(coroutineScope: CoroutineScope): Flow<ImmutableList<WalletNotification>> {
|
||||
return getMultiWalletWarningsFactory.create(clickIntents)
|
||||
.conflate()
|
||||
.distinctUntilChanged()
|
||||
.onEach {
|
||||
stateHolder.update(
|
||||
SetWarningsTransformer(userWalletId = userWalletId, warnings = it),
|
||||
)
|
||||
.onEach { warnings ->
|
||||
stateHolder.update(SetWarningsTransformer(userWalletId, warnings))
|
||||
walletWarningsAnalyticsSender.send(warnings)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.subscribers
|
||||
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.WalletWarningsAnalyticsSender
|
||||
import com.tangem.feature.wallet.presentation.wallet.domain.GetSingleWalletWarningsFactory
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.components.WalletNotification
|
||||
import com.tangem.feature.wallet.presentation.wallet.state2.WalletStateController
|
||||
|
|
@ -20,6 +21,7 @@ internal class SingleWalletNotificationsSubscriber(
|
|||
private val userWalletId: UserWalletId,
|
||||
private val stateHolder: WalletStateController,
|
||||
private val getSingleWalletWarningsFactory: GetSingleWalletWarningsFactory,
|
||||
private val walletWarningsAnalyticsSender: WalletWarningsAnalyticsSender,
|
||||
private val clickIntents: WalletClickIntentsV2,
|
||||
) : WalletSubscriber() {
|
||||
|
||||
|
|
@ -27,10 +29,9 @@ internal class SingleWalletNotificationsSubscriber(
|
|||
return getSingleWalletWarningsFactory.create(clickIntents)
|
||||
.conflate()
|
||||
.distinctUntilChanged()
|
||||
.onEach {
|
||||
stateHolder.update(
|
||||
SetWarningsTransformer(userWalletId = userWalletId, warnings = it),
|
||||
)
|
||||
.onEach { warnings ->
|
||||
stateHolder.update(SetWarningsTransformer(userWalletId, warnings))
|
||||
walletWarningsAnalyticsSender.send(warnings)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,11 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.viewmodels.intents
|
||||
|
||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
import com.tangem.core.navigation.AppScreen
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.domain.wallets.usecase.DeleteWalletUseCase
|
||||
import com.tangem.domain.wallets.usecase.UpdateWalletUseCase
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.WalletScreenAnalyticsEvent.MainScreen
|
||||
import com.tangem.feature.wallet.presentation.wallet.loaders.WalletScreenContentLoader
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletAlertState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletEvent
|
||||
|
|
@ -25,16 +27,21 @@ internal interface WalletCardClickIntents {
|
|||
fun onDeleteAfterConfirmationClick(userWalletId: UserWalletId)
|
||||
}
|
||||
|
||||
// TODO: Refactor
|
||||
@Suppress("LongParameterList")
|
||||
internal class WalletCardClickIntentsImplementor @Inject constructor(
|
||||
private val stateHolder: WalletStateController,
|
||||
private val walletEventSender: WalletEventSender,
|
||||
private val walletScreenContentLoader: WalletScreenContentLoader,
|
||||
private val updateWalletUseCase: UpdateWalletUseCase,
|
||||
private val deleteWalletUseCase: DeleteWalletUseCase,
|
||||
private val analyticsEventHandler: AnalyticsEventHandler,
|
||||
private val dispatchers: CoroutineDispatcherProvider,
|
||||
) : BaseWalletClickIntents(), WalletCardClickIntents {
|
||||
|
||||
override fun onRenameClick(userWalletId: UserWalletId, name: String) {
|
||||
analyticsEventHandler.send(MainScreen.EditWalletTapped)
|
||||
|
||||
viewModelScope.launch(dispatchers.main) {
|
||||
updateWalletUseCase(userWalletId = userWalletId, update = { it.copy(name) })
|
||||
}
|
||||
|
|
@ -51,6 +58,8 @@ internal class WalletCardClickIntentsImplementor @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onDeleteAfterConfirmationClick(userWalletId: UserWalletId) {
|
||||
analyticsEventHandler.send(MainScreen.DeleteWalletTapped)
|
||||
|
||||
viewModelScope.launch(dispatchers.main) {
|
||||
walletScreenContentLoader.cancel(userWalletId)
|
||||
deleteWalletUseCase(userWalletId)
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ internal class WalletWarningsClickIntentsImplementer @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onUnlockWalletClick() {
|
||||
analyticsEventHandler.send(MainScreen.NoticeWalletLocked)
|
||||
analyticsEventHandler.send(MainScreen.UnlockAllWithFaceID)
|
||||
|
||||
viewModelScope.launch(dispatchers.main) {
|
||||
unlockWalletsUseCase(throwIfNotAllWalletsUnlocked = true)
|
||||
|
|
@ -254,7 +254,7 @@ internal class WalletWarningsClickIntentsImplementer @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onScanToUnlockWalletClick() {
|
||||
analyticsEventHandler.send(event = MainScreen.WalletUnlockTapped)
|
||||
analyticsEventHandler.send(MainScreen.UnlockWithCardScan)
|
||||
|
||||
viewModelScope.launch(dispatchers.main) {
|
||||
scanCardToUnlockWalletClickHandler(walletId = stateHolder.getSelectedWalletId())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue