Skip to content

Commit

Permalink
logging for updateuser with values (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
xinlili-statsig authored Apr 30, 2024
1 parent eb3270a commit b5e6108
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
4 changes: 0 additions & 4 deletions src/main/java/com/statsig/androidsdk/Diagnostics.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ internal class Diagnostics(private var isDisabled: Boolean) {
)
}

fun clearAllContext() {
this.markers = mutableMapOf()
}

fun markStart(key: KeyType, step: StepType? = null, additionalMarker: Marker? = null, overrideContext: ContextType? = null): Boolean {
val context = overrideContext ?: this.diagnosticsContext
if (this.isDisabled && context === ContextType.API_CALL) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/statsig/androidsdk/StatsigClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ class StatsigClient() : LifecycleEventListener {
val functionName = "updateUserAsync"
enforceInitialized(functionName)
errorBoundary.capture({
diagnostics.markStart(KeyType.OVERALL, overrideContext = ContextType.UPDATE_USER)
if (values != null) {
updateUserWithValuesImpl(user, values)
callback?.onStatsigUpdateUser()
Expand Down Expand Up @@ -425,6 +426,7 @@ class StatsigClient() : LifecycleEventListener {
suspend fun updateUser(user: StatsigUser?, values: Map<String, Any>? = null) {
enforceInitialized("updateUser")
errorBoundary.captureAsync {
diagnostics.markStart(KeyType.OVERALL, overrideContext = ContextType.UPDATE_USER)
if (values != null) {
updateUserWithValuesImpl(user, values)
} else {
Expand Down Expand Up @@ -779,13 +781,13 @@ class StatsigClient() : LifecycleEventListener {
val normalizedUser = normalizeUser(user)
this.user = normalizedUser
this.store.bootstrap(values, this.user)
logEndDiagnostics(true, ContextType.UPDATE_USER, null)
}

private suspend fun updateUserImpl() {
withContext(dispatcherProvider.io) {
errorBoundary.captureAsync(
{
diagnostics.markStart(KeyType.OVERALL, overrideContext = ContextType.UPDATE_USER)
val sinceTime = store.getLastUpdateTime(this@StatsigClient.user)
val previousDerivedFields = store.getPreviousDerivedFields(this@StatsigClient.user)
val initResponse = statsigNetwork.initialize(
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/statsig/androidsdk/StatsigLogger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ internal class StatsigLogger(

fun onUpdateUser() {
this.loggedExposures = ConcurrentHashMap()
diagnostics.clearAllContext()
diagnostics.clearContext(ContextType.API_CALL)
}

suspend fun flush() {
Expand Down

0 comments on commit b5e6108

Please sign in to comment.