Init or stop posthog based on user consent

This commit is contained in:
yostyle 2023-06-23 15:57:25 +02:00
parent c9f432051b
commit 3b4bff61e9
3 changed files with 10 additions and 9 deletions

View file

@ -115,15 +115,16 @@ class DefaultAnalyticsService @Inject constructor(
}
private fun initOrStop() {
userConsent?.let { _userConsent ->
when (_userConsent) {
userConsent?.let { userConsent ->
when (userConsent) {
true -> {
analyticsProviders.onEach { it.init() }
pendingUserProperties?.let {
analyticsProviders.onEach { provider -> provider.updateUserProperties(it) }
pendingUserProperties = null
}
}
false -> {}
false -> analyticsProviders.onEach { it.stop() }
}
}
}