Analytics: simpler API

This commit is contained in:
Benoit Marty 2021-11-24 12:09:15 +01:00 committed by Benoit Marty
parent 869b5ad55b
commit a8108f2e17
4 changed files with 7 additions and 7 deletions

View file

@ -37,7 +37,7 @@ interface VectorAnalytics {
/**
* Store the fact that the user has been asked for their consent
*/
suspend fun setDidAskUserConsent(didAskUserConsent: Boolean)
suspend fun setDidAskUserConsent()
/**
* Return a Flow of String, used for analytics Id

View file

@ -52,8 +52,8 @@ class DefaultVectorAnalytics @Inject constructor(
return analyticsStore.didAskUserConsentFlow
}
override suspend fun setDidAskUserConsent(didAskUserConsent: Boolean) {
analyticsStore.setDidAskUserConsent(didAskUserConsent)
override suspend fun setDidAskUserConsent() {
analyticsStore.setDidAskUserConsent()
}
override fun getAnalyticsId(): Flow<String> {

View file

@ -61,9 +61,9 @@ class AnalyticsStore @Inject constructor(
}
}
suspend fun setDidAskUserConsent(newDidAskUserConsent: Boolean) {
suspend fun setDidAskUserConsent() {
context.dataStore.edit { settings ->
settings[didAskUserConsent] = newDidAskUserConsent
settings[didAskUserConsent] = true
}
}

View file

@ -65,7 +65,7 @@ class AnalyticsConsentViewModel @AssistedInject constructor(
analytics.setUserConsent(action.userConsent)
if (!action.userConsent) {
// User explicitly changed the default value, let's avoid reverting to the default value
analytics.setDidAskUserConsent(true)
analytics.setDidAskUserConsent()
}
}
}
@ -73,7 +73,7 @@ class AnalyticsConsentViewModel @AssistedInject constructor(
private fun handleOnScreenLeft() {
// Whatever the state of the box, consider the user acknowledge it
viewModelScope.launch {
analytics.setDidAskUserConsent(true)
analytics.setDidAskUserConsent()
}
}
}