From af04a0909517d258a6591ee562acc1affdde1d7a Mon Sep 17 00:00:00 2001 From: Tangem Date: Fri, 6 Jun 2025 15:32:48 +0400 Subject: [PATCH] Updated on 2026-08-14 --- .../PushNotificationAnalyticEvents.kt | 18 ++++++++++++++++++ features/tokendetails/impl/build.gradle.kts | 1 + .../DefaultTokenDetailsDeepLinkHandler.kt | 5 +++++ .../model/WalletSettingsModel.kt | 7 ++++++- 4 files changed, 30 insertions(+), 1 deletion(-) 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 fecdc9bb3d..7977e16e18 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 @@ -43,4 +43,22 @@ sealed class PushNotificationAnalyticEvents( AnalyticsParam.STATE to if (isAllowed) "Allow" else "Cancel", ), ) + + data class NotificationOpened( + val type: String, + ) : PushNotificationAnalyticEvents( + event = "Push Notification Opened", + params = mapOf( + AnalyticsParam.TYPE to type, + ), + ) + + data class NotificationsEnabled( + val isEnabled: Boolean, + ) : PushNotificationAnalyticEvents( + event = "Push Toggle Clicked", + params = mapOf( + AnalyticsParam.STATE to if (isEnabled) "On" else "Off", + ), + ) } \ No newline at end of file diff --git a/features/tokendetails/impl/build.gradle.kts b/features/tokendetails/impl/build.gradle.kts index 035f337fa2..b2913e9228 100644 --- a/features/tokendetails/impl/build.gradle.kts +++ b/features/tokendetails/impl/build.gradle.kts @@ -99,6 +99,7 @@ dependencies { implementation(projects.features.staking.api) implementation(projects.features.markets.api) implementation(projects.features.onramp.api) + implementation(projects.features.pushNotifications.api) implementation(projects.features.swap.api) implementation(projects.features.txhistory.api) diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/deeplink/DefaultTokenDetailsDeepLinkHandler.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/deeplink/DefaultTokenDetailsDeepLinkHandler.kt index 4b8988a101..41456e71f5 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/deeplink/DefaultTokenDetailsDeepLinkHandler.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/deeplink/DefaultTokenDetailsDeepLinkHandler.kt @@ -3,6 +3,7 @@ package com.tangem.feature.tokendetails.deeplink import arrow.core.getOrElse import com.tangem.common.routing.AppRoute import com.tangem.common.routing.AppRouter +import com.tangem.core.analytics.api.AnalyticsEventHandler import com.tangem.core.deeplink.DeeplinkConst.NETWORK_ID_KEY import com.tangem.core.deeplink.DeeplinkConst.TOKEN_ID_KEY import com.tangem.core.deeplink.DeeplinkConst.TYPE_KEY @@ -12,6 +13,7 @@ import com.tangem.domain.tokens.FetchCurrencyStatusUseCase import com.tangem.domain.tokens.GetCryptoCurrenciesUseCase import com.tangem.domain.wallets.models.UserWalletId import com.tangem.domain.wallets.usecase.GetSelectedWalletSyncUseCase +import com.tangem.features.pushnotifications.api.analytics.PushNotificationAnalyticEvents import com.tangem.features.tokendetails.deeplink.TokenDetailsDeepLinkHandler import dagger.assisted.Assisted import dagger.assisted.AssistedFactory @@ -29,6 +31,7 @@ internal class DefaultTokenDetailsDeepLinkHandler @AssistedInject constructor( private val getSelectedWalletSyncUseCase: GetSelectedWalletSyncUseCase, private val getCryptoCurrenciesUseCase: GetCryptoCurrenciesUseCase, private val fetchCurrencyStatusUseCase: FetchCurrencyStatusUseCase, + private val analyticsEventHandler: AnalyticsEventHandler, ) : TokenDetailsDeepLinkHandler { init { @@ -70,6 +73,8 @@ internal class DefaultTokenDetailsDeepLinkHandler @AssistedInject constructor( return@launch } + analyticsEventHandler.send(PushNotificationAnalyticEvents.NotificationOpened(type.name)) + appRouter.push( AppRoute.CurrencyDetails( userWalletId = userWalletId, diff --git a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt index c841e7acb9..ebe302c2e7 100644 --- a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt +++ b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt @@ -37,6 +37,7 @@ import com.tangem.feature.walletsettings.entity.WalletSettingsUM import com.tangem.feature.walletsettings.impl.R import com.tangem.feature.walletsettings.utils.ItemsBuilder import com.tangem.features.nft.NFTFeatureToggles +import com.tangem.features.pushnotifications.api.analytics.PushNotificationAnalyticEvents import com.tangem.utils.coroutines.CoroutineDispatcherProvider import kotlinx.collections.immutable.PersistentList import kotlinx.collections.immutable.persistentListOf @@ -226,6 +227,7 @@ internal class WalletSettingsModel @Inject constructor( } } else { setNotificationsEnabledUseCase(params.userWalletId, false) + analyticsEventHandler.send(PushNotificationAnalyticEvents.NotificationsEnabled(false)) } } } @@ -239,6 +241,7 @@ internal class WalletSettingsModel @Inject constructor( } private fun onPushNotificationPermissionGranted(isGranted: Boolean) { + analyticsEventHandler.send(PushNotificationAnalyticEvents.PermissionStatus(isGranted)) state.update { value -> value.copy( requestPushNotificationsPermission = false, @@ -246,7 +249,9 @@ internal class WalletSettingsModel @Inject constructor( } if (isGranted) { modelScope.launch { - setNotificationsEnabledUseCase(params.userWalletId, true) + setNotificationsEnabledUseCase(params.userWalletId, true).onRight { + analyticsEventHandler.send(PushNotificationAnalyticEvents.NotificationsEnabled(true)) + } } } else { val message = DialogMessage(