Updated on 2026-08-14

This commit is contained in:
Tangem 2026-06-18 18:29:55 +04:00
parent 86450e506d
commit 28221ee04c
14 changed files with 34 additions and 28 deletions

View file

@ -105,7 +105,7 @@ internal class CardSettingsModel @Inject constructor(
private fun scanCard() = modelScope.launch {
scanCardProcessor.scan(
analyticsSource = com.tangem.core.analytics.models.AnalyticsParam.ScreensSources.Settings,
analyticsSource = com.tangem.core.analytics.models.AnalyticsParam.ScreensSources.CardSettings,
shouldCheckIsAlreadyActivated = false,
allowsRequestAccessCodeFromRepository = true,
)

View file

@ -539,7 +539,7 @@ internal class ChildFactory @Inject constructor(
is AppRoute.CreateHardwareWallet -> {
createComponentChild(
context = context,
params = Unit,
params = CreateHardwareWalletComponent.Params(source = route.source),
componentFactory = createHardwareWalletComponentFactory,
)
}

View file

@ -387,7 +387,9 @@ sealed class AppRoute(val path: String) : Route {
}
@Serializable
object CreateHardwareWallet : AppRoute(path = "/create_hardware_wallet")
data class CreateHardwareWallet(
val source: AnalyticsParam.ScreensSources,
) : AppRoute(path = "/create_hardware_wallet")
@Serializable
data class CreateMobileWallet(

View file

@ -71,6 +71,7 @@ sealed class AnalyticsParam {
@Serializable
enum class ScreensSources(val value: String) {
Settings("Settings"),
CardSettings("Card Settings"),
Main("Main"),
SignIn("Sign In"),
Send("Send"),

View file

@ -100,7 +100,7 @@ internal class CreateWalletSelectionModel @Inject constructor(
}
private fun onHardwareWalletClick() {
router.push(AppRoute.CreateHardwareWallet)
router.push(AppRoute.CreateHardwareWallet(source = AnalyticsParam.ScreensSources.AddNew))
}
private fun onBuyClick() {

View file

@ -189,7 +189,7 @@ internal class CreateWalletStartModel @Inject constructor(
isBiometricsRequestPolicy = shouldSaveAccessCodes,
)
val analyticsSource = AnalyticsParam.ScreensSources.Intro
val analyticsSource = AnalyticsParam.ScreensSources.CreateWalletIntro
scanCardProcessor.scan(
analyticsSource = analyticsSource,

View file

@ -112,7 +112,7 @@ internal class CreateWalletStartModelTest {
}
coVerify {
scanCardProcessor.scan(
analyticsSource = AnalyticsParam.ScreensSources.Intro,
analyticsSource = AnalyticsParam.ScreensSources.CreateWalletIntro,
shouldCheckIsAlreadyActivated = true,
cardId = null,
onProgressStateChange = any(),
@ -141,7 +141,7 @@ internal class CreateWalletStartModelTest {
}
coVerify {
scanCardProcessor.scan(
analyticsSource = AnalyticsParam.ScreensSources.Intro,
analyticsSource = AnalyticsParam.ScreensSources.CreateWalletIntro,
shouldCheckIsAlreadyActivated = true,
cardId = null,
onProgressStateChange = any(),
@ -258,7 +258,7 @@ internal class CreateWalletStartModelTest {
verify { cardSdkConfigRepository.setAccessCodeRequestPolicy(isBiometricsRequestPolicy = true) }
coVerify {
scanCardProcessor.scan(
analyticsSource = AnalyticsParam.ScreensSources.Intro,
analyticsSource = AnalyticsParam.ScreensSources.CreateWalletIntro,
shouldCheckIsAlreadyActivated = true,
cardId = null,
onProgressStateChange = any(),

View file

@ -78,7 +78,6 @@ internal class HomeModel @Inject constructor(
HomeUM(
scanInProgress = false,
stories = getRestrictedStories().toImmutableList(),
onScanClick = ::onScanClick,
onShopClick = ::onShopClick,
onSearchTokensClick = ::onSearchTokensClick,
onGetStartedClick = ::onGetStartedClick,
@ -121,11 +120,6 @@ internal class HomeModel @Inject constructor(
}
}
private fun onScanClick() {
analyticsEventHandler.send(IntroductionProcess.ButtonScanCardLegacy())
scanCard()
}
private fun onShopClick() {
analyticsEventHandler.send(IntroductionProcess.ButtonBuyCards())
analyticsEventHandler.send(Shop.ScreenOpened())

View file

@ -5,7 +5,6 @@ import kotlinx.collections.immutable.ImmutableList
data class HomeUM(
val scanInProgress: Boolean,
val stories: ImmutableList<Stories>,
val onScanClick: () -> Unit,
val onShopClick: () -> Unit,
val onSearchTokensClick: () -> Unit,
val onGetStartedClick: () -> Unit,

View file

@ -1,9 +1,14 @@
package com.tangem.features.hotwallet
import com.tangem.core.analytics.models.AnalyticsParam
import com.tangem.core.decompose.factory.ComponentFactory
import com.tangem.core.ui.decompose.ComposableContentComponent
interface CreateHardwareWalletComponent : ComposableContentComponent {
interface Factory : ComponentFactory<Unit, CreateHardwareWalletComponent>
data class Params(
val source: AnalyticsParam.ScreensSources,
)
interface Factory : ComponentFactory<Params, CreateHardwareWalletComponent>
}

View file

@ -4,11 +4,11 @@ import com.tangem.common.core.TangemError
import com.tangem.common.core.TangemSdkError
import com.tangem.common.routing.AppRoute
import com.tangem.core.analytics.api.AnalyticsEventHandler
import com.tangem.core.analytics.models.AnalyticsParam
import com.tangem.core.analytics.models.Basic
import com.tangem.core.analytics.utils.TrackingContextProxy
import com.tangem.core.decompose.di.ModelScoped
import com.tangem.core.decompose.model.Model
import com.tangem.core.decompose.model.ParamsContainer
import com.tangem.core.decompose.navigation.Router
import com.tangem.core.decompose.ui.UiMessageSender
import com.tangem.core.navigation.url.UrlOpener
@ -27,6 +27,7 @@ import com.tangem.domain.wallets.analytics.WalletSettingsAnalyticEvents
import com.tangem.domain.wallets.builder.ColdUserWalletBuilder
import com.tangem.domain.wallets.usecase.GenerateBuyTangemCardLinkUseCase
import com.tangem.domain.wallets.usecase.SaveWalletUseCase
import com.tangem.features.hotwallet.CreateHardwareWalletComponent
import com.tangem.features.hotwallet.createhardwarewallet.entity.CreateHardwareWalletUM
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import com.tangem.utils.logging.TangemLogger
@ -42,6 +43,7 @@ private const val HIDE_PROGRESS_DELAY = 400L
@Suppress("LongParameterList")
@ModelScoped
internal class CreateHardwareWalletModel @Inject constructor(
paramsContainer: ParamsContainer,
override val dispatchers: CoroutineDispatcherProvider,
private val router: Router,
private val generateBuyTangemCardLinkUseCase: GenerateBuyTangemCardLinkUseCase,
@ -57,6 +59,8 @@ internal class CreateHardwareWalletModel @Inject constructor(
private val analyticsEventHandler: AnalyticsEventHandler,
) : Model() {
private val params = paramsContainer.require<CreateHardwareWalletComponent.Params>()
val uiState: StateFlow<CreateHardwareWalletUM>
field = MutableStateFlow(
CreateHardwareWalletUM(
@ -77,7 +81,7 @@ internal class CreateHardwareWalletModel @Inject constructor(
}
private fun onBuyTangemWalletClick() {
analyticsEventHandler.send(Basic.ButtonBuy(source = AnalyticsParam.ScreensSources.CreateWallet))
analyticsEventHandler.send(Basic.ButtonBuy(source = params.source))
modelScope.launch {
generateBuyTangemCardLinkUseCase
.invoke(GenerateBuyTangemCardLinkUseCase.Source.Upgrade).let { urlOpener.openUrl(it) }
@ -86,7 +90,7 @@ internal class CreateHardwareWalletModel @Inject constructor(
private fun onScanDeviceClick() {
analyticsEventHandler.send(
event = IntroductionProcess.ButtonScanCard(AnalyticsParam.ScreensSources.CreateWallet),
event = IntroductionProcess.ButtonScanCard(params.source),
)
scanCard()
}
@ -100,10 +104,8 @@ internal class CreateHardwareWalletModel @Inject constructor(
isBiometricsRequestPolicy = shouldSaveAccessCodes,
)
val analyticsSource = AnalyticsParam.ScreensSources.Intro
scanCardProcessor.scan(
analyticsSource = analyticsSource,
analyticsSource = params.source,
shouldCheckIsAlreadyActivated = true,
onProgressStateChange = { showProgress ->
if (!showProgress) {
@ -136,7 +138,7 @@ internal class CreateHardwareWalletModel @Inject constructor(
saveWalletUseCase(
userWallet = userWallet,
analyticsSource = AnalyticsParam.ScreensSources.AddNew,
analyticsSource = params.source,
).fold(
ifLeft = { saveWalletError ->
delay(HIDE_PROGRESS_DELAY)
@ -183,7 +185,7 @@ internal class CreateHardwareWalletModel @Inject constructor(
userWalletId = walletId,
unlockMethod = UserWalletsListRepository.UnlockMethod.Scan(
scanResponse = scanResponse,
source = AnalyticsParam.ScreensSources.AddNew,
source = params.source,
),
).onRight {
router.replaceAll(AppRoute.Wallet)

View file

@ -15,7 +15,7 @@ import dagger.assisted.AssistedInject
@Suppress("UnusedPrivateMember")
internal class DefaultCreateHardwareWalletComponent @AssistedInject constructor(
@Assisted private val context: AppComponentContext,
@Assisted private val params: Unit,
@Assisted private val params: CreateHardwareWalletComponent.Params,
) : CreateHardwareWalletComponent, AppComponentContext by context {
private val model: CreateHardwareWalletModel = getOrCreateModel(params)
@ -31,6 +31,9 @@ internal class DefaultCreateHardwareWalletComponent @AssistedInject constructor(
@AssistedFactory
interface Factory : CreateHardwareWalletComponent.Factory {
override fun create(context: AppComponentContext, params: Unit): DefaultCreateHardwareWalletComponent
override fun create(
context: AppComponentContext,
params: CreateHardwareWalletComponent.Params,
): DefaultCreateHardwareWalletComponent
}
}

View file

@ -117,7 +117,7 @@ internal class UpgradeWalletModel @Inject constructor(
tangemSdkManager
.scanProduct(
shouldCheckIsAlreadyActivated = true,
source = AnalyticsParam.ScreensSources.Upgrade,
source = AnalyticsParam.ScreensSources.CreateWallet,
)
.doOnSuccess { scanResponse ->
checkIsWalletSuitableToBeUsedAsUpgrade(scanResponse = scanResponse) {

View file

@ -126,7 +126,7 @@ internal class WalletHardwareBackupModel @Inject constructor(
private fun onCreateNewWalletClick() {
analyticsEventHandler.send(WalletSettingsAnalyticEvents.ButtonCreateNewWallet())
router.push(AppRoute.CreateHardwareWallet)
router.push(AppRoute.CreateHardwareWallet(source = AnalyticsParam.ScreensSources.CreateWallet))
}
private fun onUpgradeCurrentWalletClick() {