diff --git a/src/main/java/com/statsig/androidsdk/StatsigClient.kt b/src/main/java/com/statsig/androidsdk/StatsigClient.kt index f075466..4939917 100644 --- a/src/main/java/com/statsig/androidsdk/StatsigClient.kt +++ b/src/main/java/com/statsig/androidsdk/StatsigClient.kt @@ -96,13 +96,11 @@ class StatsigClient() : LifecycleEventListener { } }, recover = { logEndDiagnosticsWhenException(ContextType.INITIALIZE, it) - if (isInitialized()) { - try { - val initDetails = InitializationDetails(System.currentTimeMillis() - initTime, false, InitializeResponse.FailedInitializeResponse(InitializeFailReason.InternalError, it)) - callback?.onStatsigInitialize(initDetails) - } catch (e: Exception) { - throw ExternalException(e.message) - } + try { + val initDetails = InitializationDetails(System.currentTimeMillis() - initTime, false, InitializeResponse.FailedInitializeResponse(InitializeFailReason.InternalError, it)) + callback?.onStatsigInitialize(initDetails) + } catch (e: Exception) { + throw ExternalException(e.message) } }) } @@ -138,11 +136,7 @@ class StatsigClient() : LifecycleEventListener { }, { logEndDiagnosticsWhenException(ContextType.INITIALIZE, it) - if (isInitialized()) { - return@captureAsync InitializationDetails(System.currentTimeMillis() - initTime, false, InitializeResponse.FailedInitializeResponse(InitializeFailReason.InternalError, it)) - } else { - return@captureAsync null - } + return@captureAsync InitializationDetails(System.currentTimeMillis() - initTime, false, InitializeResponse.FailedInitializeResponse(InitializeFailReason.InternalError, it)) }, ) } diff --git a/src/test/java/com/statsig/androidsdk/StatsigInitializationFailureTest.kt b/src/test/java/com/statsig/androidsdk/StatsigInitializationFailureTest.kt index 6510114..63e4fef 100644 --- a/src/test/java/com/statsig/androidsdk/StatsigInitializationFailureTest.kt +++ b/src/test/java/com/statsig/androidsdk/StatsigInitializationFailureTest.kt @@ -188,7 +188,7 @@ class StatsigInitializationFailureTest { throw Exception("Unsuccessful setup") } initDetails = client.initialize(app, "client-key", StatsigUser("test_user")) - assert(initDetails == null) + assert(initDetails?.failureDetails?.exception?.message === "Unsuccessful setup") assert(client.isInitialized() === false) } @@ -199,7 +199,7 @@ class StatsigInitializationFailureTest { } client.initializeAsync(app, "client-key", StatsigUser("test_user"), callback) initializationCountdown.await(3, TimeUnit.SECONDS) - assert(initDetails == null) + assert(initDetails?.failureDetails?.exception?.message === "Unsuccessful setup") assert(client.isInitialized() === false) }