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
2 changes: 1 addition & 1 deletion .github/badges/jacoco.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The changelog for `Superwall`. Also see the [releases](https://github.com/superw

## Fixes
- Fix `device.appVersionPadded` and `device.sdkVersionPadded` emitting non-ASCII digits on devices whose default locale uses a non-Latin numbering system (e.g. `ar-EG`, `fa-IR`, `bn-BD`), which caused audience-rule version comparisons to misbucket affected users.
- Ensures timeout applies to HttpUrlConnection for enrichment and subscription API's

## 2.7.12

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class EnrichmentService(
"enrich",
retryCount = maxRetry,
body = factory.json().encodeToString(enrichmentRequest).toByteArray(),
timeout = timeout
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.superwall.sdk.network
import kotlinx.serialization.Serializable
import java.net.URI
import java.util.*
import kotlin.time.Duration

data class URLQueryItem(
val name: String,
Expand All @@ -16,6 +17,7 @@ class NetworkRequestData<Response>(
var requestId: String = UUID.randomUUID().toString(),
var isForDebugging: Boolean = false,
val factory: suspend (isForDebugging: Boolean, requestId: String) -> Map<String, String>,
val timeout: Duration?
Comment thread
ianrumac marked this conversation as resolved.
) where Response : @Serializable Any {
enum class HttpMethod(
val method: String,
Expand Down Expand Up @@ -51,5 +53,6 @@ class NetworkRequestData<Response>(
requestId = requestId,
isForDebugging = isForDebugging,
factory = factory,
timeout = timeout
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.superwall.sdk.network.NetworkRequestData.HttpMethod
import com.superwall.sdk.network.session.CustomHttpUrlConnection
import kotlinx.serialization.Serializable
import java.util.UUID
import kotlin.time.Duration

abstract class NetworkService {
abstract val customHttpUrlConnection: CustomHttpUrlConnection
Expand All @@ -23,6 +24,7 @@ abstract class NetworkService {
isForDebugging: Boolean = false,
requestId: String = UUID.randomUUID().toString(),
retryCount: Int = NetworkConsts.retryCount(),
timeout: Duration? = null
): Either<T, NetworkError> where T : @Serializable Any =
customHttpUrlConnection.request(
buildRequestData = {
Expand All @@ -37,6 +39,7 @@ abstract class NetworkService {
),
method = HttpMethod.GET,
factory = this::makeHeaders,
timeout = timeout
)
},
retryCount = retryCount,
Expand All @@ -48,6 +51,7 @@ abstract class NetworkService {
body: ByteArray? = null,
requestId: String = UUID.randomUUID().toString(),
retryCount: Int = 6,
timeout: Duration? = null
): Either<T, NetworkError> where T : @Serializable Any =
customHttpUrlConnection.request<T>(
buildRequestData = {
Expand All @@ -62,6 +66,7 @@ abstract class NetworkService {
),
method = HttpMethod.POST,
factory = this::makeHeaders,
timeout = timeout
)
},
retryCount = retryCount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ class RequestExecutor(
if (components?.bodyData != null) {
connection.doInput = true
}
connection.connectTimeout = timeout?.inWholeMilliseconds?.toInt()?:0
connection.readTimeout = timeout?.inWholeMilliseconds?.toInt()?:0
Comment thread
ianrumac marked this conversation as resolved.
Comment thread
ianrumac marked this conversation as resolved.

if (components?.bodyData != null) {
val outputStream = connection.outputStream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.superwall.sdk.store.testmode.models.SuperwallProductsResponse
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonElement
import kotlin.time.Duration.Companion.seconds

class SubscriptionService(
override val host: String,
Expand Down Expand Up @@ -58,6 +59,7 @@ class SubscriptionService(
attributionProps,
),
).toByteArray(),
timeout = 10.seconds
)

suspend fun webEntitlementsByUserId(
Expand All @@ -66,12 +68,14 @@ class SubscriptionService(
) = get<WebEntitlements>(
"users/${userId?.value ?: deviceId.value}/entitlements",
queryItems = listOf(URLQueryItem("deviceId", deviceId.value)),
timeout = 5.seconds
)

suspend fun webEntitlementsByDeviceId(deviceId: DeviceVendorId) =
get<WebEntitlements>(
"users/${deviceId.value}/entitlements",
queryItems = listOf(URLQueryItem("deviceId", deviceId.value)),
timeout = 5.seconds
)

suspend fun getProducts() = get<SuperwallProductsResponse>("products")
Expand Down