diff --git a/CHANGELOG.md b/CHANGELOG.md index 436a53b7..74728a8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ The changelog for `Superwall`. Also see the [releases](https://github.com/superwall/Superwall-Android/releases) on GitHub. +## 2.7.8 + +## Fixes +- Fix serialization issue with R8 and dates +- Fix scope cancellation for test mode ## 2.7.7 diff --git a/superwall/src/main/java/com/superwall/sdk/misc/Scopes.kt b/superwall/src/main/java/com/superwall/sdk/misc/Scopes.kt index dea2d7b5..4659a6da 100644 --- a/superwall/src/main/java/com/superwall/sdk/misc/Scopes.kt +++ b/superwall/src/main/java/com/superwall/sdk/misc/Scopes.kt @@ -6,6 +6,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Deferred import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job +import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.async import kotlinx.coroutines.launch import kotlin.coroutines.CoroutineContext @@ -24,14 +25,14 @@ class IOScope( overrideWithContext: CoroutineContext = Dispatchers.IO, ) : CoroutineScope, SuperwallScope { - override val coroutineContext: CoroutineContext = overrideWithContext + exceptionHandler + override val coroutineContext: CoroutineContext = SupervisorJob() + overrideWithContext + exceptionHandler } class MainScope( overrideWithContext: CoroutineContext = Dispatchers.Main, ) : CoroutineScope, SuperwallScope { - override val coroutineContext: CoroutineContext = overrideWithContext + exceptionHandler + override val coroutineContext: CoroutineContext = SupervisorJob() + overrideWithContext + exceptionHandler } internal fun SuperwallScope.launchWithTracking(block: suspend CoroutineScope.() -> Unit): Job = diff --git a/superwall/src/main/java/com/superwall/sdk/storage/core_data/Converters.kt b/superwall/src/main/java/com/superwall/sdk/storage/core_data/Converters.kt index d7ab8eb6..bf304885 100644 --- a/superwall/src/main/java/com/superwall/sdk/storage/core_data/Converters.kt +++ b/superwall/src/main/java/com/superwall/sdk/storage/core_data/Converters.kt @@ -48,7 +48,7 @@ class Converters { fun sanitizeMap(map: Map): Map = map.filterValues { value -> when (value) { - is String, is Number, is Boolean, is List<*>, is Map<*, *> -> true + is String, is Number, is Boolean, is Date, is List<*>, is Map<*, *> -> true else -> false } } @@ -97,7 +97,15 @@ fun Any?.convertToJsonElement(): JsonElement = }, ) - else -> throw IllegalArgumentException("Unsupported type: ${this!!::class}") + else -> { + // Fallback: handle Date by Java class check in case R8 optimizes away the + // instanceof check above. Any other unknown types are converted to null. + if (Date::class.java.isInstance(this)) { + JsonPrimitive((this as Date).time) + } else { + JsonNull + } + } } // Helper function to convert JsonElement back to basic types diff --git a/version.env b/version.env index 7d5eb34b..3e4c8c88 100644 --- a/version.env +++ b/version.env @@ -1 +1 @@ -SUPERWALL_VERSION=2.7.7 +SUPERWALL_VERSION=2.7.8