Updated on 2026-08-14

This commit is contained in:
Tangem 2024-10-08 17:49:35 +04:00
parent e592b59734
commit 5006ccd343
4 changed files with 35 additions and 14 deletions

View file

@ -10,7 +10,11 @@ import com.tangem.tap.common.analytics.converters.ParamCardCurrencyConverter
import com.tangem.tap.common.analytics.events.AnalyticsParam
import com.tangem.tap.common.analytics.events.IntroductionProcess
import com.tangem.tap.common.analytics.events.MainScreen
import com.tangem.tap.common.extensions.inject
import com.tangem.tap.features.demo.DemoHelper
import com.tangem.tap.proxy.redux.DaggerGraphState
import com.tangem.tap.store
import kotlinx.coroutines.runBlocking
/**
[REDACTED_AUTHOR]
@ -19,6 +23,8 @@ class CardContextInterceptor(
private val scanResponse: ScanResponse,
) : ParamsInterceptor {
private val walletsRepository = store.inject(DaggerGraphState::walletsRepository)
private val userWalletId = UserWalletIdBuilder.scanResponse(scanResponse).build()
override fun id(): String = CardContextInterceptor.id()
@ -33,7 +39,7 @@ class CardContextInterceptor(
override fun intercept(params: MutableMap<String, String>) {
val card = scanResponse.card
params[AnalyticsParam.BATCH] = card.batchId
params[AnalyticsParam.PRODUCT_TYPE] = getProductType(scanResponse)
params[AnalyticsParam.PRODUCT_TYPE] = getProductType()
params[AnalyticsParam.FIRMWARE] = card.firmwareVersion.stringValue
if (userWalletId != null) {
params[AnalyticsParam.USER_WALLET_ID] = userWalletId.stringValue
@ -44,7 +50,13 @@ class CardContextInterceptor(
}
}
private fun getProductType(scanResponse: ScanResponse): String {
private fun getProductType(): String {
if (scanResponse.productType != ProductType.Ring && userWalletId != null) {
val isWalletWithRing = runBlocking { walletsRepository.isWalletWithRing(userWalletId) }
if (isWalletWithRing) return "Ring"
}
return when (scanResponse.productType) {
ProductType.Note -> "Note"
ProductType.Twins -> "Twin"
@ -53,18 +65,18 @@ class CardContextInterceptor(
ProductType.Ring -> "Ring"
ProductType.Start2Coin -> "Start2Coin"
ProductType.Visa -> "VISA"
else -> if (DemoHelper.isDemoCard(scanResponse)) {
if (DemoHelper.isTestDemoCard(scanResponse)) {
"Demo Test"
} else {
when (scanResponse.card.cardId.substring(0..1)) {
"AC" -> "Demo Wallet"
"AB" -> "Demo Note"
else -> "Demo Other"
}
}
} else {
"Other"
else -> if (DemoHelper.isDemoCard(scanResponse)) getDemoCardProductType() else "Other"
}
}
private fun getDemoCardProductType(): String {
return if (DemoHelper.isTestDemoCard(scanResponse)) {
"Demo Test"
} else {
when (scanResponse.card.cardId.substring(0..1)) {
"AC" -> "Demo Wallet"
"AB" -> "Demo Note"
else -> "Demo Other"
}
}
}

View file

@ -187,6 +187,7 @@ class OnboardingWalletFragment :
when {
state.wallet2State != null -> {
seedPhraseStateHandler.newState(this, state, seedPhraseViewModel)
seedPhraseViewModel.setCardArtworkUri(cardArtworkUri = state.walletImages.primaryCardImage.toString())
updateWalletImagesState(state.walletImages)
}
else -> {