Updated on 2026-08-14

This commit is contained in:
Tangem 2026-01-27 15:55:41 +03:00
parent b4b35916d9
commit a54b701503
3 changed files with 17 additions and 13 deletions

View file

@ -3,14 +3,14 @@ package com.tangem.core.analytics.api
import com.tangem.core.analytics.models.AnalyticsEvent
import java.util.concurrent.ConcurrentHashMap
class ResettableOneTimeEventSender(val analyticsEventHandler: AnalyticsEventHandler) {
class ResettableOneTimeEventSender(private val analyticsEventHandler: AnalyticsEventHandler) {
private val sentEvents = ConcurrentHashMap<String, AnalyticsEvent>()
fun sendEventOnce(key: String, event: AnalyticsEvent) {
if (sentEvents[key] != null) return
analyticsEventHandler.send(event)
sentEvents[key] = event
if (sentEvents.putIfAbsent(key, event) == null) {
analyticsEventHandler.send(event)
}
}
fun reset(key: String) {

View file

@ -52,15 +52,15 @@ internal class FeeSelectorLogic @AssistedInject constructor(
private val feeSelectorCheckReloadTrigger: FeeSelectorCheckReloadTrigger,
private val feeSelectorAlertFactory: FeeSelectorAlertFactory,
private val analyticsEventHandler: AnalyticsEventHandler,
private val sendFeatureToggles: SendFeatureToggles,
private val getSingleCryptoCurrencyStatusUseCase: GetSingleCryptoCurrencyStatusUseCase,
private val getUserWalletUseCase: GetUserWalletUseCase,
private val getAvailableFeeTokensUseCase: GetAvailableFeeTokensUseCase,
private val isGaslessFeeSupportedForNetwork: IsGaslessFeeSupportedForNetwork,
sendFeatureToggles: SendFeatureToggles,
isGaslessFeeSupportedForNetwork: IsGaslessFeeSupportedForNetwork,
) : FeeSelectorIntents {
private var appCurrency: AppCurrency = AppCurrency.Default
val uiState = MutableStateFlow<FeeSelectorUM>(params.state)
val uiState = MutableStateFlow(params.state)
val isGaslessEnabled = sendFeatureToggles.isGaslessTransactionsEnabled &&
params.onLoadFeeExtended != null &&
@ -81,8 +81,8 @@ internal class FeeSelectorLogic @AssistedInject constructor(
}
}
private fun loadFee() {
if (uiState.value is FeeSelectorUM.Error) {
private fun loadFee(isReload: Boolean = false) {
if (uiState.value is FeeSelectorUM.Error && !isReload) {
return
}
@ -119,7 +119,10 @@ internal class FeeSelectorLogic @AssistedInject constructor(
override fun onFeeItemSelected(feeItem: FeeItem) {
if (feeItem is FeeItem.Custom) {
analyticsEventHandler.send(
CommonSendFeeAnalyticEvents.CustomFeeButtonClicked(categoryName = params.analyticsCategoryName),
CommonSendFeeAnalyticEvents.CustomFeeButtonClicked(
categoryName = params.analyticsCategoryName,
blockchain = params.cryptoCurrencyStatus.currency.network.name,
),
)
}
uiState.update(FeeItemSelectedTransformer(feeItem))
@ -154,6 +157,7 @@ internal class FeeSelectorLogic @AssistedInject constructor(
feeType = feeSelectorUM.toAnalyticType(),
source = params.analyticsSendSource,
feeToken = feeSelectorUM.feeExtraInfo.feeCryptoCurrencyStatus.currency.symbol,
blockchain = params.cryptoCurrencyStatus.currency.network.name,
),
)
val isCustomFeeEdited = feeSelectorUM.selectedFeeItem.fee.amount.value != feeSelectorUM.fees.normal.amount.value
@ -178,7 +182,7 @@ internal class FeeSelectorLogic @AssistedInject constructor(
if (data.isRemoveSuggestedFee) {
uiState.update(FeeSelectorRemoveSuggestedTransformer)
}
loadFee()
loadFee(isReload = true)
}
.launchIn(modelScope)
}
@ -216,7 +220,7 @@ internal class FeeSelectorLogic @AssistedInject constructor(
},
ifLeft = { feeError ->
feeSelectorCheckReloadTrigger.callbackCheckResult(false)
feeSelectorAlertFactory.getFeeUnreachableErrorState(::loadFee)
feeSelectorAlertFactory.getFeeUnreachableErrorState { loadFee(isReload = true) }
},
)
}

View file

@ -396,6 +396,6 @@ internal class NotificationsModel @Inject constructor(
companion object {
const val TRON_FEE_NOTIFICATION_MAX_SHOW_COUNT = 3
private const val EXCEEDS_BALANCE_EVENT = "EXCEED_BALANCE_EVENT"
private const val EXCEEDS_BALANCE_EVENT = "EXCEEDS_BALANCE_EVENT"
}
}