Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions superwall/src/main/java/com/superwall/sdk/misc/Scopes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Converters {
fun sanitizeMap(map: Map<String, Any>): Map<String, Any> =
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
}
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion version.env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SUPERWALL_VERSION=2.7.7
SUPERWALL_VERSION=2.7.8
Loading