diff --git a/core/analytics/models/src/main/java/com/tangem/core/analytics/models/event/OnboardingAnalyticsEvent.kt b/core/analytics/models/src/main/java/com/tangem/core/analytics/models/event/OnboardingAnalyticsEvent.kt index e449459d0e..6743eccfea 100644 --- a/core/analytics/models/src/main/java/com/tangem/core/analytics/models/event/OnboardingAnalyticsEvent.kt +++ b/core/analytics/models/src/main/java/com/tangem/core/analytics/models/event/OnboardingAnalyticsEvent.kt @@ -3,6 +3,7 @@ package com.tangem.core.analytics.models.event import com.tangem.core.analytics.models.AnalyticsEvent import com.tangem.core.analytics.models.AnalyticsParam import com.tangem.core.analytics.models.AppsFlyerIncludedEvent +import com.tangem.core.analytics.models.getReferralParams sealed class OnboardingAnalyticsEvent( category: String, @@ -55,6 +56,7 @@ sealed class OnboardingAnalyticsEvent( creationType: WalletCreationType = WalletCreationType.NewSeed, seedPhraseLength: Int? = null, passPhraseState: AnalyticsParam.EmptyFull, + referralId: String?, ) : CreateWallet( event = "Wallet Created Successfully", params = buildMap { @@ -64,6 +66,7 @@ sealed class OnboardingAnalyticsEvent( if (seedPhraseLength != null) { put("Seed Phrase Length", seedPhraseLength.toString()) } + putAll(getReferralParams(referralId)) }, ), AppsFlyerIncludedEvent diff --git a/domain/card/src/main/kotlin/com/tangem/domain/card/analytics/IntroductionProcess.kt b/domain/card/src/main/kotlin/com/tangem/domain/card/analytics/IntroductionProcess.kt index b7151afd3d..98114357c7 100644 --- a/domain/card/src/main/kotlin/com/tangem/domain/card/analytics/IntroductionProcess.kt +++ b/domain/card/src/main/kotlin/com/tangem/domain/card/analytics/IntroductionProcess.kt @@ -2,6 +2,7 @@ package com.tangem.domain.card.analytics import com.tangem.core.analytics.models.AnalyticsEvent import com.tangem.core.analytics.models.AnalyticsParam +import com.tangem.core.analytics.models.getReferralParams sealed class IntroductionProcess( event: String, @@ -13,7 +14,14 @@ sealed class IntroductionProcess( class ButtonBuyCards : IntroductionProcess("Button - Buy Cards") class ButtonScanCardLegacy : IntroductionProcess("Button - Scan Card") - class CreateWalletIntroScreenOpened : IntroductionProcess("Create Wallet Intro Screen Opened") + class CreateWalletIntroScreenOpened( + referralId: String?, + ) : IntroductionProcess( + event = "Create Wallet Intro Screen Opened", + params = buildMap { + putAll(getReferralParams(referralId)) + }, + ) class ButtonScanCard( val source: AnalyticsParam.ScreensSources, diff --git a/features/create-wallet-start/impl/build.gradle.kts b/features/create-wallet-start/impl/build.gradle.kts index 987ab1a58b..1578c1916f 100644 --- a/features/create-wallet-start/impl/build.gradle.kts +++ b/features/create-wallet-start/impl/build.gradle.kts @@ -22,6 +22,7 @@ dependencies { implementation(projects.domain.wallets) implementation(projects.domain.models) implementation(projects.domain.hotWallet) + implementation(projects.domain.wallets.models) /** Core modules */ implementation(projects.core.configToggles) diff --git a/features/create-wallet-start/impl/src/main/kotlin/com/tangem/features/createwalletstart/CreateWalletStartModel.kt b/features/create-wallet-start/impl/src/main/kotlin/com/tangem/features/createwalletstart/CreateWalletStartModel.kt index 0760ef5917..9596dcee32 100644 --- a/features/create-wallet-start/impl/src/main/kotlin/com/tangem/features/createwalletstart/CreateWalletStartModel.kt +++ b/features/create-wallet-start/impl/src/main/kotlin/com/tangem/features/createwalletstart/CreateWalletStartModel.kt @@ -20,6 +20,7 @@ import com.tangem.core.ui.R import com.tangem.core.ui.extensions.resourceReference import com.tangem.core.ui.message.DialogMessage import com.tangem.core.ui.message.dialog.Dialogs.hotWalletCreationNotSupportedDialog +import com.tangem.datasource.local.appsflyer.AppsFlyerStore import com.tangem.domain.card.ScanCardProcessor import com.tangem.domain.card.analytics.IntroductionProcess import com.tangem.domain.card.repository.CardSdkConfigRepository @@ -65,6 +66,7 @@ internal class CreateWalletStartModel @Inject constructor( private val trackingContextProxy: TrackingContextProxy, private val analyticsEventHandler: AnalyticsEventHandler, private val hotWalletFeatureToggles: HotWalletFeatureToggles, + private val appsFlyerStore: AppsFlyerStore, ) : Model() { private val params = paramsContainer.require() @@ -133,9 +135,13 @@ internal class CreateWalletStartModel @Inject constructor( ) init { - analyticsEventHandler.send( - event = IntroductionProcess.CreateWalletIntroScreenOpened(), - ) + modelScope.launch { + analyticsEventHandler.send( + event = IntroductionProcess.CreateWalletIntroScreenOpened( + referralId = appsFlyerStore.get()?.refcode, + ), + ) + } } private fun onScanClick() { diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/addexistingwallet/im/port/model/AddExistingWalletImportModel.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/addexistingwallet/im/port/model/AddExistingWalletImportModel.kt index 4245e9f79d..6b0489cab4 100644 --- a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/addexistingwallet/im/port/model/AddExistingWalletImportModel.kt +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/addexistingwallet/im/port/model/AddExistingWalletImportModel.kt @@ -14,6 +14,7 @@ import com.tangem.core.ui.extensions.resourceReference import com.tangem.core.ui.message.SnackbarMessage import com.tangem.core.ui.message.bottomSheetMessage import com.tangem.crypto.bip39.Mnemonic +import com.tangem.datasource.local.appsflyer.AppsFlyerStore import com.tangem.domain.common.wallets.error.SaveWalletError import com.tangem.domain.wallets.builder.HotUserWalletBuilder import com.tangem.domain.wallets.usecase.SaveWalletUseCase @@ -41,6 +42,7 @@ internal class AddExistingWalletImportModel @Inject constructor( private val saveUserWalletUseCase: SaveWalletUseCase, @GlobalUiMessageSender private val uiMessageSender: UiMessageSender, private val analyticsEventHandler: AnalyticsEventHandler, + private val appsFlyerStore: AppsFlyerStore, ) : Model() { private val params: AddExistingWalletImportComponent.Params = paramsContainer.require() @@ -122,6 +124,7 @@ internal class AddExistingWalletImportModel @Inject constructor( } else { AnalyticsParam.EmptyFull.Full }, + referralId = appsFlyerStore.get()?.refcode, ), ) params.callbacks.onWalletImported(userWallet.walletId) diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/createmobilewallet/CreateMobileWalletModel.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/createmobilewallet/CreateMobileWalletModel.kt index d268abddb8..dad097a1fb 100644 --- a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/createmobilewallet/CreateMobileWalletModel.kt +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/createmobilewallet/CreateMobileWalletModel.kt @@ -11,6 +11,7 @@ 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.ui.message.dialog.Dialogs.hotWalletCreationNotSupportedDialog +import com.tangem.datasource.local.appsflyer.AppsFlyerStore import com.tangem.domain.hotwallet.IsHotWalletCreationSupported import com.tangem.domain.wallets.builder.HotUserWalletBuilder import com.tangem.domain.wallets.usecase.SaveWalletUseCase @@ -44,6 +45,7 @@ internal class CreateMobileWalletModel @Inject constructor( private val isHotWalletCreationSupported: IsHotWalletCreationSupported, private val uiMessageSender: UiMessageSender, private val analyticsEventHandler: AnalyticsEventHandler, + private val appsFlyerStore: AppsFlyerStore, ) : Model() { private val params: CreateMobileWalletComponent.Params = paramsContainer.require() @@ -100,6 +102,7 @@ internal class CreateMobileWalletModel @Inject constructor( creationType = OnboardingAnalyticsEvent.CreateWallet.WalletCreationType.NewSeed, seedPhraseLength = SEED_PHRASE_LENGTH, passPhraseState = AnalyticsParam.EmptyFull.Empty, + referralId = appsFlyerStore.get()?.refcode, ), ) diff --git a/features/onboarding-v2/impl/src/main/kotlin/com/tangem/features/onboarding/v2/common/analytics/OnboardingEvent.kt b/features/onboarding-v2/impl/src/main/kotlin/com/tangem/features/onboarding/v2/common/analytics/OnboardingEvent.kt index b8ed2c5101..07da257630 100644 --- a/features/onboarding-v2/impl/src/main/kotlin/com/tangem/features/onboarding/v2/common/analytics/OnboardingEvent.kt +++ b/features/onboarding-v2/impl/src/main/kotlin/com/tangem/features/onboarding/v2/common/analytics/OnboardingEvent.kt @@ -3,6 +3,8 @@ package com.tangem.features.onboarding.v2.common.analytics import com.tangem.core.analytics.models.AnalyticsEvent import com.tangem.core.analytics.models.AnalyticsParam import com.tangem.core.analytics.models.AppsFlyerIncludedEvent +import com.tangem.core.analytics.models.getReferralParams +import kotlin.collections.putAll sealed class OnboardingEvent( category: String, @@ -25,6 +27,7 @@ sealed class OnboardingEvent( creationType: WalletCreationType = WalletCreationType.PrivateKey, seedPhraseLength: Int? = null, passPhraseState: AnalyticsParam.EmptyFull, + referralId: String?, ) : CreateWallet( event = "Wallet Created Successfully", params = buildMap { @@ -33,6 +36,7 @@ sealed class OnboardingEvent( if (seedPhraseLength != null) { put("Seed Phrase Length", seedPhraseLength.toString()) } + putAll(getReferralParams(referralId)) }, ), AppsFlyerIncludedEvent diff --git a/features/onboarding-v2/impl/src/main/kotlin/com/tangem/features/onboarding/v2/multiwallet/impl/child/createwallet/model/MultiWalletCreateWalletModel.kt b/features/onboarding-v2/impl/src/main/kotlin/com/tangem/features/onboarding/v2/multiwallet/impl/child/createwallet/model/MultiWalletCreateWalletModel.kt index 42d2db0372..d777faa37b 100644 --- a/features/onboarding-v2/impl/src/main/kotlin/com/tangem/features/onboarding/v2/multiwallet/impl/child/createwallet/model/MultiWalletCreateWalletModel.kt +++ b/features/onboarding-v2/impl/src/main/kotlin/com/tangem/features/onboarding/v2/multiwallet/impl/child/createwallet/model/MultiWalletCreateWalletModel.kt @@ -9,13 +9,14 @@ 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.ui.extensions.resourceReference +import com.tangem.datasource.local.appsflyer.AppsFlyerStore import com.tangem.domain.card.repository.CardRepository import com.tangem.domain.feedback.GetWalletMetaInfoUseCase import com.tangem.domain.feedback.SendFeedbackEmailUseCase import com.tangem.domain.feedback.models.FeedbackEmailType import com.tangem.domain.models.scan.ScanResponse -import com.tangem.domain.wallets.builder.ColdUserWalletBuilder import com.tangem.domain.models.wallet.UserWallet +import com.tangem.domain.wallets.builder.ColdUserWalletBuilder import com.tangem.domain.wallets.usecase.SaveWalletUseCase import com.tangem.features.onboarding.v2.common.analytics.OnboardingEvent import com.tangem.features.onboarding.v2.impl.R @@ -45,6 +46,7 @@ internal class MultiWalletCreateWalletModel @Inject constructor( private val analyticsHandler: AnalyticsEventHandler, private val coldUserWalletBuilderFactory: ColdUserWalletBuilder.Factory, private val saveWalletUseCase: SaveWalletUseCase, + private val appsFlyerStore: AppsFlyerStore, ) : Model() { private val params = paramsContainer.require() @@ -109,6 +111,7 @@ internal class MultiWalletCreateWalletModel @Inject constructor( analyticsHandler.send( event = OnboardingEvent.CreateWallet.WalletCreatedSuccessfully( passPhraseState = AnalyticsParam.EmptyFull.Empty, + referralId = appsFlyerStore.get()?.refcode, ), ) diff --git a/features/onboarding-v2/impl/src/main/kotlin/com/tangem/features/onboarding/v2/multiwallet/impl/child/seedphrase/model/MultiWalletSeedPhraseModel.kt b/features/onboarding-v2/impl/src/main/kotlin/com/tangem/features/onboarding/v2/multiwallet/impl/child/seedphrase/model/MultiWalletSeedPhraseModel.kt index 3468f7a11c..fc3e5ad044 100644 --- a/features/onboarding-v2/impl/src/main/kotlin/com/tangem/features/onboarding/v2/multiwallet/impl/child/seedphrase/model/MultiWalletSeedPhraseModel.kt +++ b/features/onboarding-v2/impl/src/main/kotlin/com/tangem/features/onboarding/v2/multiwallet/impl/child/seedphrase/model/MultiWalletSeedPhraseModel.kt @@ -18,6 +18,7 @@ import com.tangem.core.ui.R import com.tangem.core.ui.extensions.resourceReference import com.tangem.core.ui.message.SnackbarMessage import com.tangem.crypto.bip39.Mnemonic +import com.tangem.datasource.local.appsflyer.AppsFlyerStore import com.tangem.domain.card.repository.CardRepository import com.tangem.domain.feedback.GetWalletMetaInfoUseCase import com.tangem.domain.feedback.SendFeedbackEmailUseCase @@ -64,6 +65,7 @@ internal class MultiWalletSeedPhraseModel @Inject constructor( private val coldUserWalletBuilderFactory: ColdUserWalletBuilder.Factory, @GlobalUiMessageSender private val uiMessageSender: UiMessageSender, private val analyticsEventHandler: AnalyticsEventHandler, + private val appsFlyerStore: AppsFlyerStore, ) : Model() { private val params = paramsContainer.require() @@ -248,6 +250,7 @@ internal class MultiWalletSeedPhraseModel @Inject constructor( } else { AnalyticsParam.EmptyFull.Full }, + referralId = appsFlyerStore.get()?.refcode, ), ) diff --git a/features/onboarding-v2/impl/src/main/kotlin/com/tangem/features/onboarding/v2/note/impl/child/create/model/OnboardingNoteCreateWalletModel.kt b/features/onboarding-v2/impl/src/main/kotlin/com/tangem/features/onboarding/v2/note/impl/child/create/model/OnboardingNoteCreateWalletModel.kt index b286fead4f..f083fdec7e 100644 --- a/features/onboarding-v2/impl/src/main/kotlin/com/tangem/features/onboarding/v2/note/impl/child/create/model/OnboardingNoteCreateWalletModel.kt +++ b/features/onboarding-v2/impl/src/main/kotlin/com/tangem/features/onboarding/v2/note/impl/child/create/model/OnboardingNoteCreateWalletModel.kt @@ -7,6 +7,7 @@ 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.ui.components.artwork.ArtworkUM +import com.tangem.datasource.local.appsflyer.AppsFlyerStore import com.tangem.domain.card.repository.CardRepository import com.tangem.domain.models.scan.ScanResponse import com.tangem.domain.wallets.builder.ColdUserWalletBuilder @@ -33,6 +34,7 @@ internal class OnboardingNoteCreateWalletModel @Inject constructor( private val coldUserWalletBuilderFactory: ColdUserWalletBuilder.Factory, private val saveWalletUseCase: SaveWalletUseCase, private val analyticsEventHandler: AnalyticsEventHandler, + private val appsFlyerStore: AppsFlyerStore, ) : Model() { private val params = paramsContainer.require() @@ -68,6 +70,7 @@ internal class OnboardingNoteCreateWalletModel @Inject constructor( analyticsEventHandler.send( event = OnboardingEvent.CreateWallet.WalletCreatedSuccessfully( passPhraseState = AnalyticsParam.EmptyFull.Empty, + referralId = appsFlyerStore.get()?.refcode, ), ) createWalletAndNavigateBackWithDone(scanResponse.copy(card = result.data.card)) diff --git a/features/onboarding-v2/impl/src/main/kotlin/com/tangem/features/onboarding/v2/twin/impl/model/OnboardingTwinModel.kt b/features/onboarding-v2/impl/src/main/kotlin/com/tangem/features/onboarding/v2/twin/impl/model/OnboardingTwinModel.kt index 79c8741734..2dbc11a45c 100644 --- a/features/onboarding-v2/impl/src/main/kotlin/com/tangem/features/onboarding/v2/twin/impl/model/OnboardingTwinModel.kt +++ b/features/onboarding-v2/impl/src/main/kotlin/com/tangem/features/onboarding/v2/twin/impl/model/OnboardingTwinModel.kt @@ -15,6 +15,7 @@ import com.tangem.core.decompose.model.ParamsContainer import com.tangem.core.decompose.ui.UiMessageSender import com.tangem.core.ui.extensions.resourceReference import com.tangem.core.ui.extensions.toWrappedList +import com.tangem.datasource.local.appsflyer.AppsFlyerStore import com.tangem.datasource.local.config.issuers.IssuersConfigStorage import com.tangem.domain.card.common.TwinCardNumber import com.tangem.domain.card.common.getTwinCardNumber @@ -63,6 +64,7 @@ internal class OnboardingTwinModel @Inject constructor( private val cardRepository: CardRepository, private val uiMessageSender: UiMessageSender, private val sendFeedbackEmailUseCase: SendFeedbackEmailUseCase, + private val appsFlyerStore: AppsFlyerStore, ) : Model() { private val params = paramsContainer.require() @@ -174,6 +176,7 @@ internal class OnboardingTwinModel @Inject constructor( analyticsEventHandler.send( event = OnboardingEvent.CreateWallet.WalletCreatedSuccessfully( passPhraseState = AnalyticsParam.EmptyFull.Empty, + referralId = appsFlyerStore.get()?.refcode, ), )