Skip to content

Commit

Permalink
always expose init details
Browse files Browse the repository at this point in the history
  • Loading branch information
kenny-statsig committed Oct 3, 2024
1 parent 4438baf commit e9a402f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
18 changes: 6 additions & 12 deletions src/main/java/com/statsig/androidsdk/StatsigClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
}
Expand Down Expand Up @@ -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))
},
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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)
}

Expand Down

0 comments on commit e9a402f

Please sign in to comment.