diff --git a/features/common-features/impl/src/main/java/com/tangem/features/commonfeatures/impl/managefunds/model/ManageFundsModel.kt b/features/common-features/impl/src/main/java/com/tangem/features/commonfeatures/impl/managefunds/model/ManageFundsModel.kt index 94b88e2469..d287b7b093 100644 --- a/features/common-features/impl/src/main/java/com/tangem/features/commonfeatures/impl/managefunds/model/ManageFundsModel.kt +++ b/features/common-features/impl/src/main/java/com/tangem/features/commonfeatures/impl/managefunds/model/ManageFundsModel.kt @@ -7,6 +7,7 @@ import com.tangem.common.routing.AppRouter import com.tangem.common.ui.markets.action.CryptoCurrencyData import com.tangem.common.ui.markets.action.TokenActionsBSContentUM import com.tangem.core.analytics.api.AnalyticsEventHandler +import com.tangem.core.analytics.models.AnalyticsEvent import com.tangem.core.analytics.models.AnalyticsParam import com.tangem.core.analytics.models.event.TransferAnalyticsEvent import com.tangem.core.decompose.di.ModelScoped @@ -23,6 +24,7 @@ import com.tangem.domain.models.account.filterCryptoPortfolio import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.currency.CryptoCurrencyStatus import com.tangem.domain.models.wallet.UserWallet +import com.tangem.domain.tokens.model.analytics.TokenScreenAnalyticsEvent import com.tangem.domain.wallets.usecase.GetUserWalletUseCase import com.tangem.features.commonfeatures.api.managefunds.ManageFundsComponent import com.tangem.features.commonfeatures.api.addtoportfolio.AvailableToAddData @@ -153,12 +155,7 @@ internal class ManageFundsModel @Inject constructor( override fun onQuickActionClick(action: TokenActionsBSContentUM.Action, shouldDismiss: Boolean) { val event = when (flowType) { - ManageFundsComponent.FlowType.AddFunds -> when (action) { - TokenActionsBSContentUM.Action.Buy -> ManageFundsAnalyticsEvent.ButtonBuy() - TokenActionsBSContentUM.Action.Exchange -> ManageFundsAnalyticsEvent.ButtonSwap() - TokenActionsBSContentUM.Action.Receive -> ManageFundsAnalyticsEvent.ButtonReceive() - else -> null - } + ManageFundsComponent.FlowType.AddFunds -> addFundsQuickActionEvent(action) ManageFundsComponent.FlowType.Transfer -> when (action) { TokenActionsBSContentUM.Action.Send -> TransferAnalyticsEvent.ButtonSend() TokenActionsBSContentUM.Action.Exchange -> TransferAnalyticsEvent.ButtonSwap() @@ -173,6 +170,51 @@ internal class ManageFundsModel @Inject constructor( } } + private fun addFundsQuickActionEvent(action: TokenActionsBSContentUM.Action): AnalyticsEvent? { + val request = tokenActionsTrigger.value + return if (launchMode is ManageFundsComponent.LaunchMode.TokenActionsOnly && request != null) { + tokenScreenQuickActionEvent(action, request) + } else { + when (action) { + TokenActionsBSContentUM.Action.Buy -> ManageFundsAnalyticsEvent.ButtonBuy() + TokenActionsBSContentUM.Action.Exchange -> ManageFundsAnalyticsEvent.ButtonSwap() + TokenActionsBSContentUM.Action.Receive -> ManageFundsAnalyticsEvent.ButtonReceive() + else -> null + } + } + } + + private fun tokenScreenQuickActionEvent( + action: TokenActionsBSContentUM.Action, + request: TokenActionsRequest, + ): AnalyticsEvent? { + val token = request.status.currency.symbol + val blockchain = request.status.currency.network.name + val derivationIndex = request.account.account + .takeUnless { it.isMainAccount } + ?.derivationIndex?.value + return when (action) { + TokenActionsBSContentUM.Action.Buy -> TokenScreenAnalyticsEvent.ButtonWithParams.ButtonBuy( + token = token, + blockchain = blockchain, + status = TokenScreenAnalyticsEvent.AVAILABLE, + derivationIndex = derivationIndex, + ) + TokenActionsBSContentUM.Action.Exchange -> TokenScreenAnalyticsEvent.ButtonWithParams.ButtonExchange( + token = token, + status = TokenScreenAnalyticsEvent.AVAILABLE, + blockchain = blockchain, + derivationIndex = derivationIndex, + ) + TokenActionsBSContentUM.Action.Receive -> TokenScreenAnalyticsEvent.ButtonWithParams.ButtonReceive( + token = token, + status = TokenScreenAnalyticsEvent.AVAILABLE, + blockchain = blockchain, + ) + else -> null + } + } + fun buildAvailableToAddDataForChooser(): AvailableToAddData { val byWallet = filteredEntries.value.groupBy { it.userWallet.walletId } return AvailableToAddData( diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/alloffers/model/AllOffersModel.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/alloffers/model/AllOffersModel.kt index a5a43d679f..68af29753f 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/alloffers/model/AllOffersModel.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/alloffers/model/AllOffersModel.kt @@ -76,6 +76,7 @@ internal class AllOffersModel @Inject constructor( analyticsEventHandler.send( event = OnrampAnalyticsEvent.OnPaymentMethodChosen(paymentMethod = method.methodConfig.method.name), ) + analyticsEventHandler.send(OnrampAnalyticsEvent.ProvidersScreenOpened()) } } diff --git a/features/send/impl/src/main/java/com/tangem/features/send/send/DefaultSendComponent.kt b/features/send/impl/src/main/java/com/tangem/features/send/send/DefaultSendComponent.kt index dc13b7b071..d8a597bbea 100644 --- a/features/send/impl/src/main/java/com/tangem/features/send/send/DefaultSendComponent.kt +++ b/features/send/impl/src/main/java/com/tangem/features/send/send/DefaultSendComponent.kt @@ -50,7 +50,6 @@ import dagger.assisted.AssistedInject import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.filterIsInstance -import kotlinx.coroutines.launch @Suppress("LargeClass") internal class DefaultSendComponent @AssistedInject constructor( @@ -91,49 +90,47 @@ internal class DefaultSendComponent @AssistedInject constructor( lifecycle = lifecycle, mode = ObserveLifecycleMode.CREATE_DESTROY, ) { stack -> - componentScope.launch { - when (val activeComponent = stack.active.instance) { - is SendConfirmComponent -> { - val fromCurrency = params.currency - val fromDerivationIndex = model.accountFlow.value?.derivationIndex?.value - .takeIf { model.isAccountModeFlow.value } - analyticsEventHandler.send( - CommonSendAnalyticEvents.ConfirmationScreenOpened( - categoryName = model.analyticCategoryName, - source = model.analyticsSendSource, - sendBlockchain = fromCurrency.network.name, - sendToken = fromCurrency.symbol, - fromDerivationIndex = fromDerivationIndex, - toDerivationIndex = null, - type = model.consumeEntryType(), - ), - ) - if (model.currentRoute.value.isEditMode) { - activeComponent.updateState(model.uiState.value) - } - } - is SendAmountComponent -> { - analyticsEventHandler.send( - CommonSendAnalyticEvents.AmountScreenOpened( - categoryName = model.analyticCategoryName, - source = model.analyticsSendSource, - type = model.consumeEntryType(), - ), - ) - activeComponent.updateState(model.uiState.value.amountUM) - } - is DefaultSendDestinationComponent -> { - analyticsEventHandler.send( - CommonSendAnalyticEvents.AddressScreenOpened( - categoryName = model.analyticCategoryName, - source = model.analyticsSendSource, - ), - ) - activeComponent.updateState(model.uiState.value.destinationUM) + when (val activeComponent = stack.active.instance) { + is SendConfirmComponent -> { + val fromCurrency = params.currency + val fromDerivationIndex = model.accountFlow.value?.derivationIndex?.value + .takeIf { model.isAccountModeFlow.value } + analyticsEventHandler.send( + CommonSendAnalyticEvents.ConfirmationScreenOpened( + categoryName = model.analyticCategoryName, + source = model.analyticsSendSource, + sendBlockchain = fromCurrency.network.name, + sendToken = fromCurrency.symbol, + fromDerivationIndex = fromDerivationIndex, + toDerivationIndex = null, + type = model.consumeEntryType(), + ), + ) + if (model.currentRoute.value.isEditMode) { + activeComponent.updateState(model.uiState.value) } } - model.currentRoute.emit(stack.active.configuration) + is SendAmountComponent -> { + analyticsEventHandler.send( + CommonSendAnalyticEvents.AmountScreenOpened( + categoryName = model.analyticCategoryName, + source = model.analyticsSendSource, + type = model.consumeEntryType(), + ), + ) + activeComponent.updateState(model.uiState.value.amountUM) + } + is DefaultSendDestinationComponent -> { + analyticsEventHandler.send( + CommonSendAnalyticEvents.AddressScreenOpened( + categoryName = model.analyticCategoryName, + source = model.analyticsSendSource, + ), + ) + activeComponent.updateState(model.uiState.value.destinationUM) + } } + model.currentRoute.value = stack.active.configuration } } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletContentClickIntents.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletContentClickIntents.kt index 0e34ecf2d4..5e42b531bf 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletContentClickIntents.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletContentClickIntents.kt @@ -339,15 +339,19 @@ internal class WalletContentClickIntentsImplementor @Inject constructor( } override fun onNFTClick(userWallet: UserWallet) { - val selectedWallet = stateHolder.getSelectedWallet() as? WalletState.MultiCurrency.Content ?: return - when (val state = selectedWallet.nftState) { + val nftState = if (stateHolder.value.isRedesignEnabled) { + stateHolder.getSelectedWalletUM().nftState + } else { + (stateHolder.getSelectedWallet() as? WalletState.MultiCurrency.Content)?.nftState + } + when (nftState) { is WalletNFTItemUM.Content -> { analyticsEventHandler.send( NFTAnalyticsEvent.NFTListScreenOpened( state = AnalyticsParam.EmptyFull.Full, - allAssetsCount = state.allAssetsCount, - collectionsCount = state.collectionsCount, - noCollectionAssetsCount = state.noCollectionAssetsCount, + allAssetsCount = nftState.allAssetsCount, + collectionsCount = nftState.collectionsCount, + noCollectionAssetsCount = nftState.noCollectionAssetsCount, ), ) } @@ -364,6 +368,7 @@ internal class WalletContentClickIntentsImplementor @Inject constructor( is WalletNFTItemUM.Failed, is WalletNFTItemUM.Hidden, is WalletNFTItemUM.Loading, + null, -> Unit }