Skip to content

Commit

Permalink
Merge pull request #175 from superwall/develop
Browse files Browse the repository at this point in the history
1.2.7
  • Loading branch information
ianrumac authored Sep 27, 2024
2 parents c4982b4 + 047861d commit e68604e
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 14 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

The changelog for `Superwall`. Also see the [releases](https://github.com/superwall/Superwall-Android/releases) on GitHub.

## 1.2.7

### Enhancements
- Exposes current configuration status via `Superwall.instance.configurationStatus`

### Fixes
- Fixes issues with Paywall previews not loading

## 1.2.6

### Fixes
Expand Down
22 changes: 22 additions & 0 deletions app/src/main/java/com/superwall/superapp/MainApplication.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.superwall.superapp

import android.app.Activity
import android.os.StrictMode
import android.os.StrictMode.ThreadPolicy
import android.os.StrictMode.VmPolicy
import androidx.appcompat.app.AlertDialog
import com.superwall.sdk.Superwall
import com.superwall.sdk.analytics.superwall.SuperwallEventInfo
Expand Down Expand Up @@ -39,6 +42,25 @@ class MainApplication :

override fun onCreate() {
super.onCreate()
StrictMode.setThreadPolicy(
ThreadPolicy
.Builder()
.detectCustomSlowCalls()
.detectResourceMismatches()
.detectUnbufferedIo() // or .detectAll() for all detectable problems
.penaltyLog()
.build(),
)
StrictMode.setVmPolicy(
VmPolicy
.Builder()
.detectLeakedSqlLiteObjects()
.detectActivityLeaks()
.detectLeakedRegistrationObjects()
.penaltyLog()
.penaltyDeath()
.build(),
)

configureWithAutomaticInitialization()
// configureWithRevenueCatInitialization()
Expand Down
2 changes: 1 addition & 1 deletion superwall/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ plugins {
id("signing")
}

version = "1.2.6"
version = "1.2.7"

android {
compileSdk = 34
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class NetworkMock : SuperwallAPI {
TODO("Not yet implemented")
}

override suspend fun getPaywalls(): Either<List<Paywall>, NetworkError> {
override suspend fun getPaywalls(isForDebugging: Boolean): Either<List<Paywall>, NetworkError> {
TODO("Not yet implemented")
}

Expand Down
19 changes: 19 additions & 0 deletions superwall/src/main/java/com/superwall/sdk/Superwall.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import android.net.Uri
import androidx.work.WorkManager
import com.superwall.sdk.analytics.internal.track
import com.superwall.sdk.analytics.internal.trackable.InternalSuperwallEvent
import com.superwall.sdk.config.models.ConfigState
import com.superwall.sdk.config.models.ConfigurationStatus
import com.superwall.sdk.config.options.SuperwallOptions
import com.superwall.sdk.delegate.SubscriptionStatus
import com.superwall.sdk.delegate.SuperwallDelegate
Expand Down Expand Up @@ -212,6 +214,23 @@ class Superwall(
*/
val subscriptionStatus: StateFlow<SubscriptionStatus> get() = _subscriptionStatus

/**
* A property that indicates current configuration state of the SDK.
*
* This is `ConfigurationStatus.Pending` when the SDK is yet to finish
* configuring. Upon successful configuration, it will change to `ConfigurationStatus.Configured`.
* On failure, it will change to `ConfigurationStatus.Failed`.
*/
val configurationState: ConfigurationStatus
get() =
dependencyContainer.configManager.configState.value.let {
when (it) {
is ConfigState.Retrieved -> ConfigurationStatus.Configured
is ConfigState.Failed -> ConfigurationStatus.Failed
else -> ConfigurationStatus.Pending
}
}

companion object {
/** A variable that is only `true` if ``instance`` is available for use.
* Gets set to `true` immediately after
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.superwall.sdk.config.models

/**
* Derived from ConfigState.kt.
* Represents the current configuration status of the SDK.
* Can be one of:
* - Pending: The configuration process is not yet completed.
* - Configured: The configuration process completed successfully.
* - Failed: The configuration process failed.
* */
sealed class ConfigurationStatus {
object Pending : ConfigurationStatus()

object Configured : ConfigurationStatus()

object Failed : ConfigurationStatus()
}
15 changes: 7 additions & 8 deletions superwall/src/main/java/com/superwall/sdk/debug/DebugView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ import com.superwall.sdk.dependencies.ViewFactory
import com.superwall.sdk.logger.LogLevel
import com.superwall.sdk.logger.LogScope
import com.superwall.sdk.logger.Logger
import com.superwall.sdk.misc.onError
import com.superwall.sdk.misc.then
import com.superwall.sdk.misc.fold
import com.superwall.sdk.models.paywall.Paywall
import com.superwall.sdk.network.Network
import com.superwall.sdk.paywall.manager.PaywallManager
Expand Down Expand Up @@ -528,18 +527,18 @@ class DebugView(

if (paywalls.isEmpty()) {
network
.getPaywalls()
.onError {
.getPaywalls(true)
.fold({
paywalls = it
finishLoadingPreview()
}, {
Logger.debug(
logLevel = LogLevel.error,
scope = LogScope.debugView,
message = "Failed to Fetch Paywalls",
error = it,
)
}.then {
paywalls = it
finishLoadingPreview()
}
})
} else {
finishLoadingPreview()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class BaseHostService(
body = json.encodeToString(confirmableAssignments).toByteArray(),
)

suspend fun paywalls() = get<Paywalls>("paywalls")
suspend fun paywalls(isForDebugging: Boolean = false) = get<Paywalls>(path = "paywalls", isForDebugging = isForDebugging)

suspend fun paywall(identifier: String? = null): Either<Paywall, NetworkError> {
// WARNING: Do not modify anything about this request without considering our cache eviction code
Expand Down
4 changes: 2 additions & 2 deletions superwall/src/main/java/com/superwall/sdk/network/Network.kt
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ open class Network(
},
)

override suspend fun getPaywalls(): Either<List<Paywall>, NetworkError> =
override suspend fun getPaywalls(isForDebugging: Boolean): Either<List<Paywall>, NetworkError> =
baseHostService
.paywalls()
.paywalls(isForDebugging)
.map {
it.paywalls
}.logError("/paywalls")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface SuperwallAPI {
event: EventData? = null,
): Either<Paywall, NetworkError>

suspend fun getPaywalls(): Either<List<Paywall>, NetworkError>
suspend fun getPaywalls(isForDebugging: Boolean = false): Either<List<Paywall>, NetworkError>

suspend fun getGeoInfo(): Either<GeoInfo, NetworkError>

Expand Down

0 comments on commit e68604e

Please sign in to comment.