diff --git a/CHANGELOG.md b/CHANGELOG.md index 4824ed6..219084e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Piano Analytics SDK for Android +## v3.4.1 +* Fixed bug with prefs for new `PianoConsents` mode + ## v3.4.0 * Updated to Kotlin 1.9 * Added support for `PianoConsents` diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 72d7883..27a8791 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] # Plugins kotlin = "1.9.23" -android = "8.3.2" +android = "8.4.2" binaryCompatibility = "0.14.0" versionUpdater = "0.51.0" ktlint = "12.1.0" diff --git a/piano-analytics/gradle.properties b/piano-analytics/gradle.properties index a7642cf..107ab6a 100644 --- a/piano-analytics/gradle.properties +++ b/piano-analytics/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=3.4.0 +VERSION_NAME=3.4.1 GROUP=io.piano.android POM_NAME=Analytics POM_ARTIFACT_ID=analytics diff --git a/piano-analytics/src/main/java/io/piano/android/analytics/PrivacyModesStorage.kt b/piano-analytics/src/main/java/io/piano/android/analytics/PrivacyModesStorage.kt index fec2996..c7d1f2a 100644 --- a/piano-analytics/src/main/java/io/piano/android/analytics/PrivacyModesStorage.kt +++ b/piano-analytics/src/main/java/io/piano/android/analytics/PrivacyModesStorage.kt @@ -22,13 +22,19 @@ public class PrivacyModesStorage internal constructor( prefsStorage.privacyStorageFilter = ::isFeatureAllowed } private fun isFeatureAllowed(privacyStorageFeature: PrivacyStorageFeature): Boolean { - val isNotForbidden = PrivacyStorageFeature.ALL !in cachedMode.forbiddenStorageFeatures || - privacyStorageFeature !in cachedMode.forbiddenStorageFeatures - val isAllowed = PrivacyStorageFeature.ALL in cachedMode.allowedStorageFeatures || - privacyStorageFeature in cachedMode.allowedStorageFeatures + val privacyMode = if (consentsEnabled) consentsCurrentMode else cachedMode + val isNotForbidden = PrivacyStorageFeature.ALL !in privacyMode.forbiddenStorageFeatures || + privacyStorageFeature !in privacyMode.forbiddenStorageFeatures + val isAllowed = PrivacyStorageFeature.ALL in privacyMode.allowedStorageFeatures || + privacyStorageFeature in privacyMode.allowedStorageFeatures return isNotForbidden && isAllowed } + private val consentsCurrentMode + get() = pianoConsents?.let { + it.consents[it.productsToPurposesMapping[Product.PA]]?.mode + }?.toPrivacyMode() ?: PrivacyMode.NO_CONSENT + /** * All registered privacy modes. Add a [PrivacyMode] instance into [allModes] for registering it */ @@ -49,9 +55,7 @@ public class PrivacyModesStorage internal constructor( public var currentMode: PrivacyMode = configuration.defaultPrivacyMode get() { if (consentsEnabled) { - return pianoConsents?.let { - it.consents[it.productsToPurposesMapping[Product.PA]]?.mode - }?.toPrivacyMode() ?: PrivacyMode.NO_CONSENT + return consentsCurrentMode } if (field != PrivacyMode.NO_CONSENT && field != PrivacyMode.NO_STORAGE) { if (prefsStorage.privacyExpirationTimestamp in 1..System.currentTimeMillis()) {