From c06ce2b556769c63629fde8e77859ae4c2811074 Mon Sep 17 00:00:00 2001 From: Ilya Shulgin Date: Tue, 29 Oct 2024 15:44:39 +0200 Subject: [PATCH] AND-8919 Added sending staking domain error to amplitude. --- .../tangem/data/staking/DefaultStakingErrorResolver.kt | 4 ++-- .../domain/staking/analytics/StakingAnalyticsEvent.kt | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/data/staking/src/main/java/com/tangem/data/staking/DefaultStakingErrorResolver.kt b/data/staking/src/main/java/com/tangem/data/staking/DefaultStakingErrorResolver.kt index 59f650e5ee..e6bcd058c8 100644 --- a/data/staking/src/main/java/com/tangem/data/staking/DefaultStakingErrorResolver.kt +++ b/data/staking/src/main/java/com/tangem/data/staking/DefaultStakingErrorResolver.kt @@ -26,8 +26,8 @@ internal class DefaultStakingErrorResolver( is StakingError.StakeKitUnknownError -> { analyticsEventHandler.send(StakingAnalyticsEvent.StakeKitApiUnknownError(error)) } - else -> { - // intentionally do nothing + is StakingError.DomainError -> { + analyticsEventHandler.send(StakingAnalyticsEvent.DomainError(error)) } } diff --git a/domain/staking/src/main/java/com/tangem/domain/staking/analytics/StakingAnalyticsEvent.kt b/domain/staking/src/main/java/com/tangem/domain/staking/analytics/StakingAnalyticsEvent.kt index 7fbd04f22f..7efa373d1f 100644 --- a/domain/staking/src/main/java/com/tangem/domain/staking/analytics/StakingAnalyticsEvent.kt +++ b/domain/staking/src/main/java/com/tangem/domain/staking/analytics/StakingAnalyticsEvent.kt @@ -136,6 +136,15 @@ sealed class StakingAnalyticsEvent( }, ) + data class DomainError( + val stakeKitDomainError: StakingError.DomainError, + ) : StakingAnalyticsEvent( + event = "App Errors", + params = buildMap { + addIfValueIsNotNull(AnalyticsParam.ERROR_DESCRIPTION, stakeKitDomainError.message) + }, + ) + fun MutableMap.addIfValueIsNotNull(key: String, value: Any?) { if (value != null) { put(key, value.toString())