From dae45a7f159417a42587647555b3ff72bcbdceae Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 12 Mar 2025 10:38:36 +0200 Subject: [PATCH] Updated on 2026-08-14 --- .../factory/express/ExpressStatusFactory.kt | 51 ++++++++++++------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/express/ExpressStatusFactory.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/express/ExpressStatusFactory.kt index 636fa5cc1f..77c9dc1404 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/express/ExpressStatusFactory.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/express/ExpressStatusFactory.kt @@ -9,6 +9,7 @@ import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.tokens.model.CryptoCurrencyStatus import com.tangem.domain.tokens.model.analytics.TokenExchangeAnalyticsEvent import com.tangem.domain.tokens.model.analytics.TokenOnrampAnalyticsEvent +import com.tangem.domain.tokens.model.analytics.TokenScreenAnalyticsEvent import com.tangem.domain.wallets.models.UserWalletId import com.tangem.feature.swap.domain.models.domain.ExchangeStatus import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsState @@ -116,19 +117,28 @@ internal class ExpressStatusFactory @AssistedInject constructor( } fun getStateWithExpressStatusBottomSheet(expressState: ExpressTransactionStateUM): TokenDetailsState { - val analyticEvent = when (expressState) { - is ExchangeUM -> TokenExchangeAnalyticsEvent.CexTxStatusOpened( - cryptoCurrency.symbol, + val analyticEvents = when (expressState) { + is ExchangeUM -> listOfNotNull( + TokenExchangeAnalyticsEvent.CexTxStatusOpened( + cryptoCurrency.symbol, + ), + maybeGetLongTimeExchangeNotificationShowEvent( + expressState = expressState, + currentStateNotification = null, + isBottomSheetShown = true, + ), ) - is ExpressTransactionStateUM.OnrampUM -> TokenOnrampAnalyticsEvent.OnrampStatusOpened( - tokenSymbol = cryptoCurrency.symbol, - provider = expressState.providerName, - fiatCurrency = expressState.fromCurrencyCode, + is ExpressTransactionStateUM.OnrampUM -> listOf( + TokenOnrampAnalyticsEvent.OnrampStatusOpened( + tokenSymbol = cryptoCurrency.symbol, + provider = expressState.providerName, + fiatCurrency = expressState.fromCurrencyCode, + ), ) else -> return currentStateProvider() } - analyticsEventsHandler.send(analyticEvent) + analyticEvents.forEach { analyticsEventsHandler.send(it) } return currentStateProvider().copy( bottomSheetConfig = TangemBottomSheetConfig( @@ -146,10 +156,11 @@ internal class ExpressStatusFactory @AssistedInject constructor( val bottomSheetConfig = state.bottomSheetConfig val currentConfig = bottomSheetConfig?.content as? ExpressStatusBottomSheetConfig ?: return bottomSheetConfig - sendLongTimeExchangeNotificationShowEvent( + maybeGetLongTimeExchangeNotificationShowEvent( expressState = expressState, currentStateNotification = (currentConfig.value as? ExchangeUM)?.notification, - ) + isBottomSheetShown = bottomSheetConfig.isShown, + )?.let { analyticsEventsHandler.send(it) } return bottomSheetConfig.copy( content = if (currentConfig.value != expressState) { @@ -172,21 +183,23 @@ internal class ExpressStatusFactory @AssistedInject constructor( } } - private fun sendLongTimeExchangeNotificationShowEvent( + private fun maybeGetLongTimeExchangeNotificationShowEvent( expressState: ExpressTransactionStateUM, currentStateNotification: ExchangeStatusNotification?, - ) { + isBottomSheetShown: Boolean, + ): TokenScreenAnalyticsEvent? { val newState = expressState as? ExchangeUM val newStateNotification = newState?.notification - if (currentStateNotification !is ExchangeStatusNotification.LongTimeExchange && - newStateNotification is ExchangeStatusNotification.LongTimeExchange + return if (currentStateNotification !is ExchangeStatusNotification.LongTimeExchange && + newStateNotification is ExchangeStatusNotification.LongTimeExchange && + isBottomSheetShown ) { - analyticsEventsHandler.send( - TokenExchangeAnalyticsEvent.LongTimeTransaction( - token = cryptoCurrency.symbol, - provider = newState.provider.name, - ), + TokenExchangeAnalyticsEvent.LongTimeTransaction( + token = cryptoCurrency.symbol, + provider = newState.provider.name, ) + } else { + null } }