diff --git a/app/src/main/java/com/tangem/tap/routing/utils/ChildFactory.kt b/app/src/main/java/com/tangem/tap/routing/utils/ChildFactory.kt index dd4108f2e0..82979df7ee 100644 --- a/app/src/main/java/com/tangem/tap/routing/utils/ChildFactory.kt +++ b/app/src/main/java/com/tangem/tap/routing/utils/ChildFactory.kt @@ -384,6 +384,7 @@ internal class ChildFactory @Inject constructor( context = context, params = PushNotificationsParams( modelCallbacks = PushNotificationsModelCallbacksStub(), + source = route.source, ), componentFactory = pushNotificationsComponentFactory, ) diff --git a/common/routing/src/main/kotlin/com/tangem/common/routing/AppRoute.kt b/common/routing/src/main/kotlin/com/tangem/common/routing/AppRoute.kt index 77a7b1f113..682378bf51 100644 --- a/common/routing/src/main/kotlin/com/tangem/common/routing/AppRoute.kt +++ b/common/routing/src/main/kotlin/com/tangem/common/routing/AppRoute.kt @@ -1,6 +1,7 @@ package com.tangem.common.routing import android.os.Bundle +import com.tangem.common.routing.AppRoute.ManageTokens.Source import com.tangem.common.routing.bundle.RouteBundleParams import com.tangem.common.routing.bundle.bundle import com.tangem.common.routing.entity.SerializableIntent @@ -185,7 +186,15 @@ sealed class AppRoute(val path: String) : Route { ) : AppRoute(path = "/staking/${userWalletId.stringValue}/${cryptoCurrencyId.value}/$yieldId") @Serializable - data object PushNotification : AppRoute(path = "/push_notification") + data class PushNotification( + val source: Source, + ) : AppRoute(path = "/push_notification") { + enum class Source { + Stories, + Main, + Onboarding, + } + } @Serializable data class WalletSettings( diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/addexistingwallet/root/routing/AddExistingWalletChildFactory.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/addexistingwallet/root/routing/AddExistingWalletChildFactory.kt index 26321ced04..a07186b664 100644 --- a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/addexistingwallet/root/routing/AddExistingWalletChildFactory.kt +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/addexistingwallet/root/routing/AddExistingWalletChildFactory.kt @@ -1,5 +1,6 @@ package com.tangem.features.hotwallet.addexistingwallet.root.routing +import com.tangem.common.routing.AppRoute import com.tangem.core.decompose.context.AppComponentContext import com.tangem.core.ui.decompose.ComposableContentComponent import com.tangem.features.hotwallet.addexistingwallet.im.port.AddExistingWalletImportComponent @@ -51,6 +52,7 @@ internal class AddExistingWalletChildFactory @Inject constructor( context = childContext, params = PushNotificationsParams( modelCallbacks = PushNotificationsModelCallbacksStub(), + source = AppRoute.PushNotification.Source.Onboarding, ), ) AddExistingWalletRoute.SetupFinished -> MobileWalletSetupFinishedComponent( diff --git a/features/push-notifications/api/src/main/java/com/tangem/features/pushnotifications/api/PushNotificationsParams.kt b/features/push-notifications/api/src/main/java/com/tangem/features/pushnotifications/api/PushNotificationsParams.kt index 27bc4d7131..9e347a47ba 100644 --- a/features/push-notifications/api/src/main/java/com/tangem/features/pushnotifications/api/PushNotificationsParams.kt +++ b/features/push-notifications/api/src/main/java/com/tangem/features/pushnotifications/api/PushNotificationsParams.kt @@ -1,6 +1,9 @@ package com.tangem.features.pushnotifications.api +import com.tangem.common.routing.AppRoute + data class PushNotificationsParams( val isBottomSheet: Boolean = false, val modelCallbacks: PushNotificationsModelCallbacks, + val source: AppRoute.PushNotification.Source, ) \ No newline at end of file diff --git a/features/push-notifications/api/src/main/java/com/tangem/features/pushnotifications/api/analytics/PushNotificationAnalyticEvents.kt b/features/push-notifications/api/src/main/java/com/tangem/features/pushnotifications/api/analytics/PushNotificationAnalyticEvents.kt index 7977e16e18..8ffec6c23c 100644 --- a/features/push-notifications/api/src/main/java/com/tangem/features/pushnotifications/api/analytics/PushNotificationAnalyticEvents.kt +++ b/features/push-notifications/api/src/main/java/com/tangem/features/pushnotifications/api/analytics/PushNotificationAnalyticEvents.kt @@ -53,6 +53,15 @@ sealed class PushNotificationAnalyticEvents( ), ) + data class NotificationsScreenOpened( + val source: AnalyticsParam.ScreensSources, + ) : PushNotificationAnalyticEvents( + event = "Push Notification Screen Opened", + params = mapOf( + AnalyticsParam.SOURCE to source.value, + ), + ) + data class NotificationsEnabled( val isEnabled: Boolean, ) : PushNotificationAnalyticEvents( diff --git a/features/push-notifications/impl/src/main/java/com/tangem/features/pushnotifications/impl/model/PushNotificationsModel.kt b/features/push-notifications/impl/src/main/java/com/tangem/features/pushnotifications/impl/model/PushNotificationsModel.kt index ebf625c1ee..dab4f52d73 100644 --- a/features/push-notifications/impl/src/main/java/com/tangem/features/pushnotifications/impl/model/PushNotificationsModel.kt +++ b/features/push-notifications/impl/src/main/java/com/tangem/features/pushnotifications/impl/model/PushNotificationsModel.kt @@ -37,6 +37,11 @@ internal class PushNotificationsModel @Inject constructor( ) : Model(), PushNotificationsClickIntents { val params: PushNotificationsParams = paramsContainer.require() + val source = when (params.source) { + AppRoute.PushNotification.Source.Stories -> AnalyticsParam.ScreensSources.Stories + AppRoute.PushNotification.Source.Main -> AnalyticsParam.ScreensSources.Main + AppRoute.PushNotification.Source.Onboarding -> AnalyticsParam.ScreensSources.Onboarding + } private val _state = MutableStateFlow( PushNotificationsUM( @@ -44,6 +49,10 @@ internal class PushNotificationsModel @Inject constructor( ), ) + init { + analyticHandler.send(PushNotificationAnalyticEvents.NotificationsScreenOpened(source)) + } + val state = _state.asStateFlow() override fun onAllowClick() { @@ -52,9 +61,7 @@ internal class PushNotificationsModel @Inject constructor( notificationsRepository.setUserAllowToSubscribeOnPushNotifications(true) } } - analyticHandler.send( - PushNotificationAnalyticEvents.ButtonAllow(AnalyticsParam.ScreensSources.Stories), - ) + analyticHandler.send(PushNotificationAnalyticEvents.ButtonAllow(source)) } override fun onLaterClick() { @@ -63,9 +70,7 @@ internal class PushNotificationsModel @Inject constructor( notificationsRepository.setUserAllowToSubscribeOnPushNotifications(false) } } - analyticHandler.send( - PushNotificationAnalyticEvents.ButtonLater(AnalyticsParam.ScreensSources.Stories), - ) + analyticHandler.send(PushNotificationAnalyticEvents.ButtonLater(source)) modelScope.launch { neverRequestPermissionUseCase(PUSH_PERMISSION) neverToInitiallyAskPermissionUseCase(PUSH_PERMISSION) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/WalletComponent.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/WalletComponent.kt index 07a629a880..8ee7b2c6c2 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/WalletComponent.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/WalletComponent.kt @@ -7,6 +7,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.arkivanov.decompose.extensions.compose.subscribeAsState import com.arkivanov.decompose.router.slot.childSlot import com.arkivanov.decompose.router.slot.dismiss +import com.tangem.common.routing.AppRoute import com.tangem.core.decompose.context.AppComponentContext import com.tangem.core.decompose.context.child import com.tangem.core.decompose.context.childByContext @@ -74,6 +75,7 @@ internal class WalletComponent @AssistedInject constructor( params = PushNotificationsParams( isBottomSheet = true, modelCallbacks = model.askForPushNotificationsModelCallbacks, + source = AppRoute.PushNotification.Source.Main, ), ) }