Updated on 2026-08-14
This commit is contained in:
parent
9fce3e758d
commit
e208c99e28
3 changed files with 59 additions and 1 deletions
|
|
@ -0,0 +1,28 @@
|
|||
package com.tangem.tap.domain.userWalletList.repository.implementation
|
||||
|
||||
import com.tangem.common.core.TangemError
|
||||
import com.tangem.core.analytics.models.Basic
|
||||
import com.tangem.domain.wallets.legacy.UserWalletsListError
|
||||
import com.tangem.utils.converter.Converter
|
||||
|
||||
object BiometricFailReasonConverter : Converter<TangemError, Basic.BiometryFailed.BiometricFailReason> {
|
||||
|
||||
override fun convert(value: TangemError): Basic.BiometryFailed.BiometricFailReason {
|
||||
if (value !is UserWalletsListError) {
|
||||
return Basic.BiometryFailed.BiometricFailReason.Other(value.customMessage)
|
||||
}
|
||||
return when (value) {
|
||||
UserWalletsListError.AllKeysInvalidated ->
|
||||
Basic.BiometryFailed.BiometricFailReason.AllKeysInvalidated
|
||||
UserWalletsListError.BiometricsAuthenticationDisabled ->
|
||||
Basic.BiometryFailed.BiometricFailReason.BiometricsAuthenticationDisabled
|
||||
is UserWalletsListError.BiometricsAuthenticationLockout ->
|
||||
if (value.isPermanent) {
|
||||
Basic.BiometryFailed.BiometricFailReason.AuthenticationLockoutPermanent
|
||||
} else {
|
||||
Basic.BiometryFailed.BiometricFailReason.AuthenticationLockout
|
||||
}
|
||||
else -> Basic.BiometryFailed.BiometricFailReason.Other(value.customMessage)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,9 @@ import com.tangem.common.*
|
|||
import com.tangem.common.authentication.storage.AuthenticatedStorage
|
||||
import com.tangem.common.core.TangemSdkError
|
||||
import com.tangem.common.services.secure.SecureStorage
|
||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
import com.tangem.core.analytics.models.AnalyticsParam
|
||||
import com.tangem.core.analytics.models.Basic
|
||||
import com.tangem.domain.wallets.legacy.UserWalletsListError
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.tap.domain.userWalletList.model.UserWalletEncryptionKey
|
||||
|
|
@ -19,6 +22,7 @@ internal class BiometricUserWalletsKeysRepository(
|
|||
moshi: Moshi,
|
||||
private val authenticatedStorage: AuthenticatedStorage,
|
||||
private val secureStorage: SecureStorage,
|
||||
private val analyticsEventHandler: AnalyticsEventHandler,
|
||||
) : UserWalletsKeysRepository {
|
||||
|
||||
private val encryptionKeyAdapter: JsonAdapter<UserWalletEncryptionKey> = moshi.adapter(
|
||||
|
|
@ -32,7 +36,7 @@ internal class BiometricUserWalletsKeysRepository(
|
|||
return withContext(Dispatchers.IO) {
|
||||
getAllInternal()
|
||||
.mapFailure { error ->
|
||||
when (error) {
|
||||
val mappedError = when (error) {
|
||||
is TangemSdkError.AuthenticationLockout ->
|
||||
UserWalletsListError.BiometricsAuthenticationLockout(isPermanent = false)
|
||||
is TangemSdkError.AuthenticationPermanentLockout ->
|
||||
|
|
@ -43,6 +47,13 @@ internal class BiometricUserWalletsKeysRepository(
|
|||
UserWalletsListError.BiometricsAuthenticationDisabled
|
||||
else -> error
|
||||
}
|
||||
analyticsEventHandler.send(
|
||||
Basic.BiometryFailed(
|
||||
source = AnalyticsParam.ScreensSources.SignIn,
|
||||
reason = BiometricFailReasonConverter.convert(mappedError),
|
||||
),
|
||||
)
|
||||
mappedError
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,4 +78,23 @@ sealed class Basic(
|
|||
AnalyticsParam.SOURCE to source.value,
|
||||
),
|
||||
)
|
||||
|
||||
class BiometryFailed(
|
||||
source: AnalyticsParam.ScreensSources,
|
||||
reason: BiometricFailReason,
|
||||
) : Basic(
|
||||
event = "Biometry Failed",
|
||||
params = mapOf(
|
||||
AnalyticsParam.SOURCE to source.value,
|
||||
"Reason" to reason.value,
|
||||
),
|
||||
) {
|
||||
sealed class BiometricFailReason(val value: String) {
|
||||
data object AuthenticationLockout : BiometricFailReason("BiometricsAuthenticationLockout")
|
||||
data object AuthenticationLockoutPermanent : BiometricFailReason("BiometricsAuthenticationLockoutPermanent")
|
||||
data object BiometricsAuthenticationDisabled : BiometricFailReason("BiometricsAuthenticationDisabled")
|
||||
data object AllKeysInvalidated : BiometricFailReason("AllKeysInvalidated")
|
||||
data class Other(val reason: String) : BiometricFailReason(reason)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue