Skip to content

Commit edd776f

Browse files
fix gcir (#281)
StatsigUser object cannot be properly serialize with one of the most common java json library. Decide to return a map copy of statsigUser instead of the whole object. Atlassian runs into stackoverflow problem when it tries to serialize/deserialize see context: https://statsigconnect.slack.com/archives/C04DH1ZBXLL/p1716874184576309
1 parent 52c1e1b commit edd776f

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/main/kotlin/com/statsig/sdk/ClientInitializeFormatter.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ internal data class ClientInitializeResponse(
1111
@SerializedName("time") var time: Long,
1212
@SerializedName("evaluated_keys") var evaluated_keys: Map<String, Any>,
1313
@SerializedName("hash_used") var hash_used: String,
14-
@SerializedName("user") var user: StatsigUser,
14+
@SerializedName("user") var user: Map<String, Any?>,
1515
@SerializedName("sdkInfo") var sdkInfo: Map<String, String>,
1616
) {
1717

@@ -25,7 +25,7 @@ internal data class ClientInitializeResponse(
2525
map["time"] = time
2626
map["evaluated_keys"] = evaluated_keys
2727
map["hash_used"] = hash_used
28-
map["user"] = user
28+
map["user"] = user.toMap()
2929
map["sdkInfo"] = sdkInfo
3030
return map
3131
}
@@ -126,7 +126,7 @@ internal class ClientInitializeFormatter(
126126
specStore.getLastUpdateTime(),
127127
evaluatedKeys,
128128
this.hash.toString().lowercase(),
129-
user,
129+
user.toMap(),
130130
mutableMapOf<String, String>().apply {
131131
this["sdkType"] = metadata.sdkType
132132
this["sdkVersion"] = metadata.sdkVersion

src/main/kotlin/com/statsig/sdk/StatsigUser.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,20 @@ data class StatsigUser private constructor(
151151

152152
return sb.toString()
153153
}
154+
155+
fun toMap(): Map<String, Any?> {
156+
return mapOf(
157+
"userID" to userID,
158+
"userAgent" to userAgent,
159+
"appVersion" to appVersion,
160+
"country" to country,
161+
"custom" to custom,
162+
"customIDs" to customIDs,
163+
"email" to email,
164+
"ip" to ip,
165+
"locale" to locale,
166+
"statsigEnvironment" to statsigEnvironment,
167+
"privateAttributes" to privateAttributes,
168+
)
169+
}
154170
}

0 commit comments

Comments
 (0)