Skip to content

Commit 03f948d

Browse files
authored
Merge pull request #13 from statsig-io/pubcallback
Send back json string of config specs from rulesUpdatedCallback
2 parents 1f4ed96 + f2baf17 commit 03f948d

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RELEASE_SIGNING_ENABLED=true
66

77
GROUP=com.statsig.serversdk
88
POM_ARTIFACT_ID=serversdk
9-
VERSION_NAME=1.2.0
9+
VERSION_NAME=1.2.1
1010

1111
POM_NAME=Statsig Server SDK
1212
POM_DESCRIPTION=A feature gating and a/b testing library for statsig

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package com.statsig.sdk
22

33
import java.util.Properties
44

5-
private const val VERSION = "1.2.0"
5+
private const val VERSION = "1.2.1"
66

77
internal class StatsigMetadata {
88
companion object {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.statsig.sdk
22

33
import com.google.gson.Gson
4+
import com.google.gson.GsonBuilder
5+
import com.google.gson.ToNumberPolicy
46
import kotlinx.coroutines.CoroutineExceptionHandler
57
import kotlinx.coroutines.CoroutineScope
68
import kotlinx.coroutines.CoroutineStart
@@ -171,6 +173,8 @@ private class StatsigServerImpl(serverSecret: String, private val options: Stats
171173
}
172174
}
173175

176+
private val gson = GsonBuilder().setObjectToNumberStrategy(ToNumberPolicy.LONG_OR_DOUBLE).create()
177+
174178
override val errorBoundary = ErrorBoundary(serverSecret, options)
175179
private val coroutineExceptionHandler =
176180
CoroutineExceptionHandler { _, ex ->
@@ -204,7 +208,7 @@ private class StatsigServerImpl(serverSecret: String, private val options: Stats
204208
return
205209
}
206210
try {
207-
val configString = configSpecs.toString()
211+
val configString = gson.toJson(configSpecs)
208212
options.rulesUpdatedCallback?.accept(configString)
209213
} catch (e: Exception) {}
210214
}

src/test/java/com/statsig/sdk/StatsigE2ETest.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ class StatsigE2ETest {
376376
bootstrapValues = downloadConfigSpecsResponse,
377377
rulesUpdatedCallback = {
378378
bootstrap_callback_count++
379+
val specs = gson.fromJson(it, APIDownloadedConfigs::class.java)
380+
assert(gson.toJson(specs) == gson.toJson(gson.fromJson(downloadConfigSpecsResponse, APIDownloadedConfigs::class.java)))
379381
}
380382
).apply {
381383
api = server.url("/v1").toString()
@@ -385,7 +387,11 @@ class StatsigE2ETest {
385387
} else {
386388
options = StatsigOptions(
387389
bootstrapValues = downloadConfigSpecsResponse,
388-
rulesUpdatedCallback = { bootstrap_callback_count++ }
390+
rulesUpdatedCallback = {
391+
bootstrap_callback_count++
392+
val specs = gson.fromJson(it, APIDownloadedConfigs::class.java)
393+
assert(gson.toJson(specs) == gson.toJson(gson.fromJson(downloadConfigSpecsResponse, APIDownloadedConfigs::class.java)))
394+
}
389395
).apply {
390396
api = server.url("/v1").toString()
391397
}

0 commit comments

Comments
 (0)