Updated on 2026-08-14
This commit is contained in:
parent
a9dfa54eec
commit
9647e6caa3
31 changed files with 302 additions and 40 deletions
|
|
@ -11,8 +11,11 @@ android {
|
|||
|
||||
dependencies {
|
||||
|
||||
/** Project - Domain */
|
||||
implementation(projects.domain.analytics)
|
||||
implementation(projects.domain.wallets.models)
|
||||
|
||||
/** Project - Analytics */
|
||||
implementation(projects.core.analytics)
|
||||
implementation(projects.core.analytics.models)
|
||||
|
||||
/** Project - Data */
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
package com.tangem.data.analytics
|
||||
|
||||
import com.tangem.core.analytics.repository.AnalyticsRepository
|
||||
import com.tangem.datasource.local.preferences.AppPreferencesStore
|
||||
import com.tangem.datasource.local.preferences.PreferencesKeys
|
||||
import com.tangem.datasource.local.preferences.utils.getObjectListSync
|
||||
import com.tangem.datasource.local.preferences.utils.getObjectMap
|
||||
import com.tangem.domain.analytics.model.WalletBalanceState
|
||||
import com.tangem.domain.analytics.repository.AnalyticsRepository
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
|
||||
internal class DefaultAnalyticsRepository(
|
||||
private val appPreferencesStore: AppPreferencesStore,
|
||||
|
|
@ -18,10 +21,30 @@ internal class DefaultAnalyticsRepository(
|
|||
|
||||
override suspend fun setIsEventSent(eventId: String) {
|
||||
appPreferencesStore.editData { mutablePreferences ->
|
||||
val sentEvents = mutablePreferences.getObject<List<String>>(PreferencesKeys.SENT_ONE_TIME_EVENTS_KEY)
|
||||
val sentEvents = mutablePreferences.getObjectList<String>(PreferencesKeys.SENT_ONE_TIME_EVENTS_KEY)
|
||||
val updatedSentEvents = sentEvents.orEmpty() + eventId
|
||||
|
||||
mutablePreferences.setObject(PreferencesKeys.SENT_ONE_TIME_EVENTS_KEY, updatedSentEvents)
|
||||
mutablePreferences.setObjectList(PreferencesKeys.SENT_ONE_TIME_EVENTS_KEY, updatedSentEvents)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun getWalletBalanceState(userWalletId: UserWalletId): WalletBalanceState? {
|
||||
val walletsBalanceState = appPreferencesStore.getObjectMap<WalletBalanceState>(
|
||||
key = PreferencesKeys.WALLETS_BALANCES_STATES_KEY,
|
||||
)
|
||||
|
||||
return walletsBalanceState[userWalletId.stringValue]
|
||||
}
|
||||
|
||||
override suspend fun setWalletBalanceState(userWalletId: UserWalletId, balanceState: WalletBalanceState) {
|
||||
appPreferencesStore.editData {
|
||||
val walletsBalanceState = it.getObjectMap<WalletBalanceState>(
|
||||
key = PreferencesKeys.WALLETS_BALANCES_STATES_KEY,
|
||||
)
|
||||
val updatedWalletsBalanceState = walletsBalanceState.orEmpty()
|
||||
.plus(pair = userWalletId.stringValue to balanceState)
|
||||
|
||||
it.setObjectMap(PreferencesKeys.WALLETS_BALANCES_STATES_KEY, updatedWalletsBalanceState)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package com.tangem.data.analytics.di
|
||||
|
||||
import com.tangem.core.analytics.repository.AnalyticsRepository
|
||||
import com.tangem.data.analytics.DefaultAnalyticsRepository
|
||||
import com.tangem.datasource.local.preferences.AppPreferencesStore
|
||||
import com.tangem.domain.analytics.repository.AnalyticsRepository
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue