Updated on 2026-08-14
This commit is contained in:
parent
21a3e1edce
commit
93f7f4b424
7 changed files with 58 additions and 20 deletions
|
|
@ -43,7 +43,10 @@ import com.tangem.domain.settings.*
|
|||
import com.tangem.domain.tokens.*
|
||||
import com.tangem.domain.tokens.error.TokenListError
|
||||
import com.tangem.domain.tokens.legacy.TradeCryptoAction
|
||||
import com.tangem.domain.tokens.model.*
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
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.tokens.models.analytics.TokenReceiveAnalyticsEvent
|
||||
import com.tangem.domain.tokens.models.analytics.TokenScreenAnalyticsEvent
|
||||
import com.tangem.domain.txhistory.usecase.GetExplorerTransactionUrlUseCase
|
||||
|
|
@ -1118,7 +1121,7 @@ internal class WalletViewModel @Inject constructor(
|
|||
uiState = stateFactory.getStateByTokensList(maybeTokenList.getTokenListWithWallet(wallet))
|
||||
|
||||
maybeTokenList.onRight {
|
||||
analyticsEventsHandler.sendBalanceLoadedEvent(fiatBalance = it.totalFiatBalance)
|
||||
analyticsEventsHandler.sendBalanceLoadedEvent(it)
|
||||
checkMultiWalletWithFunds(it)
|
||||
}
|
||||
|
||||
|
|
@ -1221,15 +1224,31 @@ internal class WalletViewModel @Inject constructor(
|
|||
|
||||
maybeCryptoCurrencyStatus.onRight { status ->
|
||||
val fiatAmount = status.value.fiatAmount
|
||||
analyticsEventsHandler.send(
|
||||
event = WalletScreenAnalyticsEvent.Basic.BalanceLoaded(
|
||||
balance = when {
|
||||
fiatAmount == null -> AnalyticsParam.CardBalanceState.BlockchainError
|
||||
|
||||
val cardBalanceState = when (status.value) {
|
||||
is CryptoCurrencyStatus.Loaded,
|
||||
is CryptoCurrencyStatus.NoAccount,
|
||||
is CryptoCurrencyStatus.NoAmount,
|
||||
-> {
|
||||
when {
|
||||
fiatAmount == null -> null
|
||||
fiatAmount.isZero() -> AnalyticsParam.CardBalanceState.Empty
|
||||
else -> AnalyticsParam.CardBalanceState.Full
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
is CryptoCurrencyStatus.NoQuote -> AnalyticsParam.CardBalanceState.NoRate
|
||||
is CryptoCurrencyStatus.Unreachable -> AnalyticsParam.CardBalanceState.BlockchainError
|
||||
is CryptoCurrencyStatus.MissedDerivation,
|
||||
is CryptoCurrencyStatus.Loading,
|
||||
is CryptoCurrencyStatus.Custom,
|
||||
-> null
|
||||
}
|
||||
|
||||
cardBalanceState?.let {
|
||||
analyticsEventsHandler.send(
|
||||
event = WalletScreenAnalyticsEvent.Basic.BalanceLoaded(balance = it),
|
||||
)
|
||||
}
|
||||
|
||||
singleWalletCryptoCurrencyStatus = status
|
||||
|
||||
|
|
@ -1261,7 +1280,7 @@ internal class WalletViewModel @Inject constructor(
|
|||
uiState = stateFactory.getStateByTokensList(maybeTokenList.getTokenListWithWallet(wallet))
|
||||
|
||||
maybeTokenList.onRight { tokenList ->
|
||||
analyticsEventsHandler.sendBalanceLoadedEvent(tokenList.totalFiatBalance)
|
||||
analyticsEventsHandler.sendBalanceLoadedEvent(tokenList)
|
||||
checkMultiWalletWithFunds(tokenList)
|
||||
}
|
||||
|
||||
|
|
@ -1275,9 +1294,23 @@ internal class WalletViewModel @Inject constructor(
|
|||
.saveIn(tokensJobHolder)
|
||||
}
|
||||
|
||||
private fun AnalyticsEventHandler.sendBalanceLoadedEvent(fiatBalance: TokenList.FiatBalance) {
|
||||
val cardBalanceState = when (fiatBalance) {
|
||||
is TokenList.FiatBalance.Failed -> AnalyticsParam.CardBalanceState.BlockchainError
|
||||
private fun AnalyticsEventHandler.sendBalanceLoadedEvent(tokenList: TokenList) {
|
||||
val cardBalanceState = when (val fiatBalance = tokenList.totalFiatBalance) {
|
||||
is TokenList.FiatBalance.Failed -> {
|
||||
val currenciesStatuses = when (tokenList) {
|
||||
is TokenList.Empty -> emptyList()
|
||||
is TokenList.GroupedByNetwork -> tokenList.groups.flatMap(NetworkGroup::currencies)
|
||||
is TokenList.Ungrouped -> tokenList.currencies
|
||||
}
|
||||
|
||||
when {
|
||||
currenciesStatuses.isEmpty() -> AnalyticsParam.CardBalanceState.Empty
|
||||
currenciesStatuses.any { it.value is CryptoCurrencyStatus.NoQuote } -> {
|
||||
AnalyticsParam.CardBalanceState.NoRate
|
||||
}
|
||||
else -> AnalyticsParam.CardBalanceState.BlockchainError
|
||||
}
|
||||
}
|
||||
is TokenList.FiatBalance.Loaded -> {
|
||||
if (fiatBalance.amount > BigDecimal.ZERO) {
|
||||
AnalyticsParam.CardBalanceState.Full
|
||||
|
|
@ -1287,7 +1320,7 @@ internal class WalletViewModel @Inject constructor(
|
|||
null
|
||||
}
|
||||
}
|
||||
else -> null
|
||||
TokenList.FiatBalance.Loading -> null
|
||||
}
|
||||
|
||||
cardBalanceState?.let {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue