Skip to content

Commit

Permalink
3.3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
DeKaN committed Nov 14, 2023
2 parents 4e90cf7 + bea8918 commit 190b8c2
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 19 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Piano Analytics SDK for Android

## v3.3.5
* 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
* Updated dependencies:
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion piano-analytics/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=3.3.4
VERSION_NAME=3.3.5
GROUP=io.piano.android
POM_NAME=Analytics
POM_ARTIFACT_ID=analytics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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")
Expand Down

0 comments on commit 190b8c2

Please sign in to comment.