From 13bd274bce977a89b3a577a7ce355eafecc69f5c Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 18 Jul 2024 20:58:30 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../core/analytics/models/AnalyticsParam.kt | 1 + .../push-notifications/api/build.gradle.kts | 3 ++ .../PushNotificationAnalyticEvents.kt | 32 +++++++++++++++++++ .../push-notifications/impl/build.gradle.kts | 5 ++- .../viewmodel/PushNotificationViewModel.kt | 10 ++++++ .../WalletPushPermissionClickIntents.kt | 11 +++++++ 6 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 features/push-notifications/api/src/main/java/com/tangem/features/pushnotifications/api/analytics/PushNotificationAnalyticEvents.kt diff --git a/core/analytics/models/src/main/java/com/tangem/core/analytics/models/AnalyticsParam.kt b/core/analytics/models/src/main/java/com/tangem/core/analytics/models/AnalyticsParam.kt index c7c73612f8..093769910b 100644 --- a/core/analytics/models/src/main/java/com/tangem/core/analytics/models/AnalyticsParam.kt +++ b/core/analytics/models/src/main/java/com/tangem/core/analytics/models/AnalyticsParam.kt @@ -65,6 +65,7 @@ sealed class AnalyticsParam { data object Intro : ScreensSources("Introduction") data object MyWallets : ScreensSources("My Wallets") data object Token : ScreensSources("Token") + data object Stories : ScreensSources("Stories") } sealed class TxSentFrom(val value: String) { diff --git a/features/push-notifications/api/build.gradle.kts b/features/push-notifications/api/build.gradle.kts index 4335917f36..8fd2b5a11b 100644 --- a/features/push-notifications/api/build.gradle.kts +++ b/features/push-notifications/api/build.gradle.kts @@ -12,4 +12,7 @@ dependencies { /** AndroidX */ implementation(deps.androidx.fragment.ktx) + + /** Core */ + implementation(projects.core.analytics.models) } \ 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 new file mode 100644 index 0000000000..d3c8a94ed5 --- /dev/null +++ b/features/push-notifications/api/src/main/java/com/tangem/features/pushnotifications/api/analytics/PushNotificationAnalyticEvents.kt @@ -0,0 +1,32 @@ +package com.tangem.features.pushnotifications.api.analytics + +import com.tangem.core.analytics.models.AnalyticsEvent +import com.tangem.core.analytics.models.AnalyticsParam + +sealed class PushNotificationAnalyticEvents( + event: String, + params: Map = mapOf(), +) : AnalyticsEvent(category = "Push", event = event, params = params) { + + data class ButtonAllow( + val source: AnalyticsParam.ScreensSources, + ) : PushNotificationAnalyticEvents( + event = "Button - Allow", + params = mapOf( + AnalyticsParam.SOURCE to source.value, + ), + ) + + data class ButtonLater( + val source: AnalyticsParam.ScreensSources, + ) : PushNotificationAnalyticEvents( + event = "Button - Later", + params = mapOf( + AnalyticsParam.SOURCE to source.value, + ), + ) + + data object ButtonCancel : PushNotificationAnalyticEvents( + event = "Button - Cancel", + ) +} \ No newline at end of file diff --git a/features/push-notifications/impl/build.gradle.kts b/features/push-notifications/impl/build.gradle.kts index 7cf8d0915d..a9965b5681 100644 --- a/features/push-notifications/impl/build.gradle.kts +++ b/features/push-notifications/impl/build.gradle.kts @@ -29,9 +29,8 @@ dependencies { implementation(projects.core.ui) implementation(projects.core.featuretoggles) implementation(projects.core.navigation) - - /** Common modules */ - implementation(projects.common.routing) + implementation(projects.core.analytics) + implementation(projects.core.analytics.models) /** Common modules */ implementation(projects.common.routing) diff --git a/features/push-notifications/impl/src/main/java/com/tangem/features/pushnotifications/impl/presentation/viewmodel/PushNotificationViewModel.kt b/features/push-notifications/impl/src/main/java/com/tangem/features/pushnotifications/impl/presentation/viewmodel/PushNotificationViewModel.kt index 20a8932b43..fcba5aa01c 100644 --- a/features/push-notifications/impl/src/main/java/com/tangem/features/pushnotifications/impl/presentation/viewmodel/PushNotificationViewModel.kt +++ b/features/push-notifications/impl/src/main/java/com/tangem/features/pushnotifications/impl/presentation/viewmodel/PushNotificationViewModel.kt @@ -2,11 +2,14 @@ package com.tangem.features.pushnotifications.impl.presentation.viewmodel import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.tangem.core.analytics.api.AnalyticsEventHandler +import com.tangem.core.analytics.models.AnalyticsParam import com.tangem.core.navigation.settings.SettingsManager import com.tangem.domain.settings.DelayPermissionRequestUseCase import com.tangem.domain.settings.NeverRequestPermissionUseCase import com.tangem.domain.settings.NeverToInitiallyAskPermissionUseCase import com.tangem.domain.settings.SetFirstTimeAskingPermissionUseCase +import com.tangem.features.pushnotifications.api.analytics.PushNotificationAnalyticEvents import com.tangem.features.pushnotifications.api.utils.PUSH_PERMISSION import com.tangem.features.pushnotifications.impl.navigation.DefaultPushNotificationsRouter import dagger.hilt.android.lifecycle.HiltViewModel @@ -22,9 +25,13 @@ internal class PushNotificationViewModel @Inject constructor( private val neverToInitiallyAskPermissionUseCase: NeverToInitiallyAskPermissionUseCase, private val router: DefaultPushNotificationsRouter, private val settingsManager: SettingsManager, + private val analyticHandler: AnalyticsEventHandler, ) : ViewModel(), PushNotificationsClickIntents { override fun onAskLater() { + analyticHandler.send( + PushNotificationAnalyticEvents.ButtonLater(AnalyticsParam.ScreensSources.Stories), + ) viewModelScope.launch { delayPermissionRequestUseCase(PUSH_PERMISSION) setFirstTimeAskingPermissionUseCase(PUSH_PERMISSION) @@ -40,6 +47,9 @@ internal class PushNotificationViewModel @Inject constructor( } override fun onAllowedPermission() { + analyticHandler.send( + PushNotificationAnalyticEvents.ButtonAllow(AnalyticsParam.ScreensSources.Stories), + ) viewModelScope.launch { neverRequestPermissionUseCase(PUSH_PERMISSION) neverToInitiallyAskPermissionUseCase(PUSH_PERMISSION) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/intents/WalletPushPermissionClickIntents.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/intents/WalletPushPermissionClickIntents.kt index 398d076811..16994a8a7a 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/intents/WalletPushPermissionClickIntents.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/intents/WalletPushPermissionClickIntents.kt @@ -1,8 +1,11 @@ package com.tangem.feature.wallet.presentation.wallet.viewmodels.intents +import com.tangem.core.analytics.api.AnalyticsEventHandler +import com.tangem.core.analytics.models.AnalyticsParam import com.tangem.domain.settings.DelayPermissionRequestUseCase import com.tangem.domain.settings.NeverRequestPermissionUseCase import com.tangem.domain.settings.SetFirstTimeAskingPermissionUseCase +import com.tangem.features.pushnotifications.api.analytics.PushNotificationAnalyticEvents import com.tangem.features.pushnotifications.api.utils.PUSH_PERMISSION import dagger.hilt.android.scopes.ViewModelScoped import kotlinx.coroutines.launch @@ -24,6 +27,7 @@ internal class WalletPushPermissionClickIntentsImplementor @Inject constructor( private val setFirstTimeAskingPermissionUseCase: SetFirstTimeAskingPermissionUseCase, private val neverRequestPermissionUseCase: NeverRequestPermissionUseCase, private val delayPermissionRequestUseCase: DelayPermissionRequestUseCase, + private val analyticsEventHandler: AnalyticsEventHandler, ) : BaseWalletClickIntents(), WalletPushPermissionClickIntents { override fun onRequestPushPermission() { @@ -34,17 +38,24 @@ internal class WalletPushPermissionClickIntentsImplementor @Inject constructor( override fun onDelayAskPushPermission() { viewModelScope.launch { + analyticsEventHandler.send( + PushNotificationAnalyticEvents.ButtonLater(AnalyticsParam.ScreensSources.Main), + ) delayPermissionRequestUseCase(PUSH_PERMISSION) } } override fun onDenyPushPermission() { + analyticsEventHandler.send(PushNotificationAnalyticEvents.ButtonCancel) viewModelScope.launch { neverRequestPermissionUseCase(PUSH_PERMISSION) } } override fun onAllowPushPermission() { + analyticsEventHandler.send( + PushNotificationAnalyticEvents.ButtonAllow(AnalyticsParam.ScreensSources.Main), + ) viewModelScope.launch { neverRequestPermissionUseCase(PUSH_PERMISSION) }