Updated on 2026-08-14
This commit is contained in:
parent
e326873ac1
commit
16b8957165
10 changed files with 120 additions and 7 deletions
|
|
@ -0,0 +1,38 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.analytics.utils
|
||||
|
||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
import com.tangem.core.decompose.di.ModelScoped
|
||||
import com.tangem.domain.pay.model.MainScreenCustomerInfo
|
||||
import com.tangem.domain.pay.model.OrderStatus
|
||||
import com.tangem.domain.tangempay.TangemPayAnalyticsEvents
|
||||
import com.tangem.feature.wallet.presentation.wallet.utils.ScreenLifecycleProvider
|
||||
import javax.inject.Inject
|
||||
|
||||
@ModelScoped
|
||||
internal class WalletTangemPayAnalyticsEventSender @Inject constructor(
|
||||
private val analyticsEventHandler: AnalyticsEventHandler,
|
||||
private val screenLifecycleProvider: ScreenLifecycleProvider,
|
||||
) {
|
||||
|
||||
private val sentEvents = mutableSetOf<TangemPayAnalyticsEvents>()
|
||||
|
||||
fun send(customerInfo: MainScreenCustomerInfo) {
|
||||
if (screenLifecycleProvider.isBackgroundState.value) return
|
||||
|
||||
val cardInfo = customerInfo.info.cardInfo
|
||||
val productInstance = customerInfo.info.productInstance
|
||||
|
||||
// TODO: TangemPay refactor analytics
|
||||
// when statement copied from TangemPayUpdateInfoStateTransformer. Be careful when editing
|
||||
val event = when {
|
||||
customerInfo.orderStatus == OrderStatus.CANCELED -> return // ignore cancelled state on analytics
|
||||
!customerInfo.info.isKycApproved -> return // ignore kyc not approved state on analytics
|
||||
cardInfo != null && productInstance != null -> TangemPayAnalyticsEvents.MainScreenOpened
|
||||
else -> TangemPayAnalyticsEvents.IssuingBannerDisplayed
|
||||
}
|
||||
|
||||
if (sentEvents.add(event)) {
|
||||
analyticsEventHandler.send(event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -46,6 +46,8 @@ internal class TangemPayUpdateInfoStateTransformer(
|
|||
private fun createInitialState(): TangemPayState {
|
||||
val cardInfo = value?.info?.cardInfo
|
||||
val productInstance = value?.info?.productInstance
|
||||
|
||||
// when statement copied to WalletTangemPayAnalyticsEventSender. Be careful when editing.
|
||||
return when {
|
||||
value == null -> TangemPayState.Empty
|
||||
value.orderStatus == OrderStatus.CANCELED -> createCancelledState(onIssuingFailed)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.tangem.domain.visa.model.TangemPayCardFrozenState
|
|||
import com.tangem.feature.wallet.child.wallet.model.TangemPayMainInfoManager
|
||||
import com.tangem.feature.wallet.child.wallet.model.intents.WalletClickIntents
|
||||
import com.tangem.feature.wallet.presentation.router.InnerWalletRouter
|
||||
import com.tangem.feature.wallet.presentation.wallet.analytics.utils.WalletTangemPayAnalyticsEventSender
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletStateController
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.transformers.TangemPayHiddenStateTransformer
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.transformers.TangemPayRefreshNeededStateTransformer
|
||||
|
|
@ -21,6 +22,7 @@ import kotlinx.coroutines.CoroutineScope
|
|||
import kotlinx.coroutines.flow.*
|
||||
import timber.log.Timber
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
internal class TangemPayMainSubscriber @AssistedInject constructor(
|
||||
@Assisted private val userWallet: UserWallet,
|
||||
private val stateController: WalletStateController,
|
||||
|
|
@ -28,6 +30,7 @@ internal class TangemPayMainSubscriber @AssistedInject constructor(
|
|||
private val innerWalletRouter: InnerWalletRouter,
|
||||
private val cardDetailsRepository: TangemPayCardDetailsRepository,
|
||||
private val tangemPayMainInfoManager: TangemPayMainInfoManager,
|
||||
private val analytics: WalletTangemPayAnalyticsEventSender,
|
||||
) : WalletSubscriber() {
|
||||
|
||||
override fun create(coroutineScope: CoroutineScope): Flow<*> {
|
||||
|
|
@ -63,7 +66,10 @@ internal class TangemPayMainSubscriber @AssistedInject constructor(
|
|||
)
|
||||
}
|
||||
}
|
||||
}.onRight { data -> updateTangemPay(data, userWalletId) }
|
||||
}.onRight { data ->
|
||||
updateTangemPay(data, userWalletId)
|
||||
analytics.send(customerInfo = data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue