From 3bd991dbd31a0564362f59163210f077658d028a Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Mon, 13 Nov 2023 17:27:45 +0400 Subject: [PATCH 1/3] Decreased default offline storage lifetime for events --- CHANGELOG.md | 3 +++ gradle/libs.versions.toml | 4 ++-- piano-analytics/gradle.properties | 2 +- .../src/main/java/io/piano/android/analytics/Configuration.kt | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 618da9c..9d07bf9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Piano Analytics SDK for Android +## v3.3.5-SNAPSHOT +* Decreased default offline storage lifetime for events + ## v3.3.4 * Added limit for event storage * Updated dependencies: diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9a0d687..08b9e80 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] # Plugins kotlin = "1.8.22" -android = "8.1.2" +android = "8.1.3" versionUpdater = "0.49.0" ktlint = "11.6.1" dokka = "1.8.20" @@ -26,7 +26,7 @@ viewBindingProperty = "1.5.9" junit = "4.13.2" androidxTestCore = "1.5.0" mockitoKotlin = "2.2.0" -mockitoCore = "5.6.0" +mockitoCore = "5.7.0" [plugins] android-library = { id = "com.android.library", version.ref = "android" } diff --git a/piano-analytics/gradle.properties b/piano-analytics/gradle.properties index 1166862..4bf2fe7 100644 --- a/piano-analytics/gradle.properties +++ b/piano-analytics/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=3.3.4 +VERSION_NAME=3.3.5-SNAPSHOT GROUP=io.piano.android POM_NAME=Analytics POM_ARTIFACT_ID=analytics diff --git a/piano-analytics/src/main/java/io/piano/android/analytics/Configuration.kt b/piano-analytics/src/main/java/io/piano/android/analytics/Configuration.kt index ee8d6f7..adbe6e9 100644 --- a/piano-analytics/src/main/java/io/piano/android/analytics/Configuration.kt +++ b/piano-analytics/src/main/java/io/piano/android/analytics/Configuration.kt @@ -218,7 +218,7 @@ class Configuration private constructor( const val DEFAULT_PATH = "event" const val MIN_SESSION_BACKGROUND_DURATION = 2 const val DEFAULT_SESSION_BACKGROUND_DURATION = 30 - const val DEFAULT_EVENTS_OFFLINE_STORAGE_LIFETIME = 30 + const val DEFAULT_EVENTS_OFFLINE_STORAGE_LIFETIME = 7 const val DEFAULT_PRIVACY_STORAGE_LIFETIME = 395 const val DEFAULT_VISITOR_STORAGE_LIFETIME = 395 const val DEFAULT_USER_STORAGE_LIFETIME = 395 From 1a6aa2fc6c7c0194423b23d550fd42b92d3da028 Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Mon, 13 Nov 2023 17:28:08 +0400 Subject: [PATCH 2/3] Fixed bug with cyclic read/save current privacy mode after its expiration --- CHANGELOG.md | 1 + .../android/analytics/PrivacyModesStorage.kt | 34 +++++++++++-------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d07bf9..4b727cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## v3.3.5-SNAPSHOT * Decreased default offline storage lifetime for events +* Fixed bug with cyclic read/save current privacy mode after its expiration ## v3.3.4 * Added limit for event storage 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 dfbb447..21f3e63 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 @@ -15,13 +15,25 @@ class PrivacyModesStorage internal constructor( prefsStorage.privacyStorageFilter = ::isFeatureAllowed } private fun isFeatureAllowed(privacyStorageFeature: PrivacyStorageFeature): Boolean { - val isNotForbidden = PrivacyStorageFeature.ALL !in currentMode.forbiddenStorageFeatures || - privacyStorageFeature !in currentMode.forbiddenStorageFeatures - val isAllowed = PrivacyStorageFeature.ALL in currentMode.allowedStorageFeatures || - privacyStorageFeature in currentMode.allowedStorageFeatures + val isNotForbidden = PrivacyStorageFeature.ALL !in cachedMode.forbiddenStorageFeatures || + privacyStorageFeature !in cachedMode.forbiddenStorageFeatures + val isAllowed = PrivacyStorageFeature.ALL in cachedMode.allowedStorageFeatures || + privacyStorageFeature in cachedMode.allowedStorageFeatures return isNotForbidden && isAllowed } + /** + * All registered privacy modes. Add a [PrivacyMode] instance into [allModes] for registering it + */ + @Suppress("unused", "MemberVisibilityCanBePrivate") // Public API. + val allModes = mutableSetOf( + PrivacyMode.NO_CONSENT, + PrivacyMode.NO_STORAGE, + PrivacyMode.OPTIN, + PrivacyMode.OPTOUT, + PrivacyMode.EXEMPT + ) + /** * Current privacy visitor mode */ @@ -37,27 +49,19 @@ class PrivacyModesStorage internal constructor( } ?: configuration.defaultPrivacyMode } } + cachedMode = field return field } set(value) { require(value in allModes) { "Privacy mode ${value.visitorMode} is not registered." } + cachedMode = value field = value updatePrefs(value) } - /** - * All registered privacy modes. Add a [PrivacyMode] instance into [allModes] for registering it - */ - @Suppress("unused", "MemberVisibilityCanBePrivate") // Public API. - val allModes = mutableSetOf( - PrivacyMode.NO_CONSENT, - PrivacyMode.NO_STORAGE, - PrivacyMode.OPTIN, - PrivacyMode.OPTOUT, - PrivacyMode.EXEMPT - ) + private var cachedMode: PrivacyMode = currentMode // for mocking in tests @Suppress("NOTHING_TO_INLINE") From bea891846a9bac308fb4f132c936f82399a420bf Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Tue, 14 Nov 2023 13:01:14 +0400 Subject: [PATCH 3/3] Prepare release --- CHANGELOG.md | 2 +- piano-analytics/gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b727cf..051464d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Piano Analytics SDK for Android -## v3.3.5-SNAPSHOT +## v3.3.5 * Decreased default offline storage lifetime for events * Fixed bug with cyclic read/save current privacy mode after its expiration diff --git a/piano-analytics/gradle.properties b/piano-analytics/gradle.properties index 4bf2fe7..769d580 100644 --- a/piano-analytics/gradle.properties +++ b/piano-analytics/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=3.3.5-SNAPSHOT +VERSION_NAME=3.3.5 GROUP=io.piano.android POM_NAME=Analytics POM_ARTIFACT_ID=analytics