Skip to content

Commit f963200

Browse files
Merge pull request #20 from statsig-io/release_1.6.2
Release 1.6.2
2 parents 18a207f + 30e6b2c commit f963200

31 files changed

+273
-189
lines changed

.github/workflows/kong.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: KONG
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
kong-branch:
7+
description: "Kong branch name"
8+
type: string
9+
required: false
510
pull_request:
611
branches: [main]
712
push:
@@ -19,7 +24,12 @@ jobs:
1924
runs-on: ubuntu-latest
2025
steps:
2126
- name: Get KONG
22-
run: git clone https://oauth2:[email protected]/statsig-io/kong.git .
27+
run: |
28+
if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then
29+
git clone -b ${{ inputs.kong-branch }} https://oauth2:[email protected]/statsig-io/kong.git .
30+
else
31+
git clone https://oauth2:[email protected]/statsig-io/kong.git .
32+
fi
2333
2434
- name: Install Deps
2535
run: npm install

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ repositories {
2121

2222
configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
2323
verbose.set(true)
24+
disabledRules.set(setOf("no-wildcard-imports"))
2425
}
2526

2627
dependencies {

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.6.1
9+
VERSION_NAME=1.6.2
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/ClientInitializeFormatter.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ internal data class ClientInitializeResponse(
1818
fun toMap(): Map<String, Any> {
1919
val gson = Gson()
2020
val json = gson.toJson(this)
21-
return try {
22-
return gson.fromJson(json, object : TypeToken<Map<String, Any>>() {}.type)
23-
} catch (e: Exception) {
24-
emptyMap()
25-
}
21+
return gson.fromJson(json, object : TypeToken<Map<String, Any>>() {}.type)
2622
}
2723
}
2824

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import java.net.URI
88
import java.net.URLEncoder
99
import java.nio.charset.StandardCharsets
1010

11-
internal class ErrorBoundary(private val apiKey: String, private val options: StatsigOptions) {
11+
internal class ErrorBoundary(private val apiKey: String, private val options: StatsigOptions, private val statsigMetadata: StatsigMetadata) {
1212
internal var uri = URI("https://statsigapi.net/v1/sdk_exception")
1313
private val seen = HashSet<String>()
1414
private val maxInfoLength = 3000
@@ -68,7 +68,7 @@ internal class ErrorBoundary(private val apiKey: String, private val options: St
6868
"tag": "$tag",
6969
"exception": "${ex.javaClass.name}",
7070
"info": "$safeInfo",
71-
"statsigMetadata": ${StatsigMetadata.asJson()}
71+
"statsigMetadata": ${statsigMetadata.asJson()}
7272
}
7373
""".trimIndent()
7474
val req =

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ internal class Evaluator(
3636
private val statsigScope: CoroutineScope,
3737
private val errorBoundary: ErrorBoundary,
3838
private val diagnostics: Diagnostics,
39+
private val statsigMetadata: StatsigMetadata,
3940
) {
4041
private var specStore: SpecStore
4142
private val uaParser: Parser by lazy {
@@ -55,7 +56,7 @@ internal class Evaluator(
5556

5657
init {
5758
CountryLookup.initialize()
58-
specStore = SpecStore(this.network, this.options, StatsigMetadata(), statsigScope, errorBoundary, diagnostics)
59+
specStore = SpecStore(this.network, this.options, statsigMetadata, statsigScope, errorBoundary, diagnostics)
5960
network.setDiagnostics(diagnostics)
6061

6162
statsigScope.launch {

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,8 @@ internal class SpecStore constructor(
263263
this.layerConfigs = newLayerConfigs
264264
this.experimentToLayer = newExperimentToLayer
265265
this.lastUpdateTime = downloadedConfig.time
266-
if (downloadedConfig.sdkKeysToAppIDs != null) {
267-
this.sdkKeysToAppIDs = downloadedConfig.sdkKeysToAppIDs
268-
}
266+
this.sdkKeysToAppIDs = downloadedConfig.sdkKeysToAppIDs ?: mapOf()
267+
269268
if (downloadedConfig.diagnostics != null) {
270269
diagnostics.setSamplingRate(downloadedConfig.diagnostics)
271270
}
@@ -329,7 +328,7 @@ internal class SpecStore constructor(
329328
}
330329

331330
fun getAppIDFromKey(clientSDKKey: String): String? {
332-
return this.sdkKeysToAppIDs.get(clientSDKKey)
331+
return this.sdkKeysToAppIDs[clientSDKKey]
333332
}
334333

335334
private suspend fun initializeSpecs() {

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

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ class Statsig {
1818
serverSecret: String,
1919
options: StatsigOptions,
2020
) {
21-
if (!::statsigServer.isInitialized) { // Quick check without synchronization
21+
if (!isInitialized()) { // Quick check without synchronization
2222
synchronized(this) {
23-
if (!::statsigServer.isInitialized
23+
if (!isInitialized()
2424
) { // Secondary check in case another thread already created the default server
25-
statsigServer = StatsigServer.create(serverSecret, options)
25+
statsigServer = StatsigServer.create()
2626
}
2727
}
28-
statsigServer.initialize()
28+
statsigServer.initialize(serverSecret, options)
2929
}
3030
}
3131

@@ -241,7 +241,7 @@ class Statsig {
241241
/**
242242
* Sets a value to be returned for the given dynamic config/experiment instead of the actual evaluated value.
243243
*
244-
* @param configName The name of the dynamic config or experiment to be overriden
244+
* @param configName The name of the dynamic config or experiment to be overridden
245245
* @param configValue The value that will be returned
246246
*/
247247
@JvmStatic
@@ -359,14 +359,14 @@ class Statsig {
359359
serverSecret: String,
360360
options: StatsigOptions = StatsigOptions(),
361361
): CompletableFuture<Void?> {
362-
if (!::statsigServer.isInitialized) { // Quick check without synchronization
362+
if (!isInitialized()) { // Quick check without synchronization
363363
synchronized(this) {
364-
if (!::statsigServer.isInitialized
364+
if (!isInitialized()
365365
) { // Secondary check in case another thread already created the default server
366-
statsigServer = StatsigServer.create(serverSecret, options)
366+
statsigServer = StatsigServer.create()
367367
}
368368
}
369-
return statsigServer.initializeAsync()
369+
return statsigServer.initializeAsync(serverSecret, options)
370370
}
371371
return CompletableFuture.completedFuture(null)
372372
}
@@ -631,12 +631,17 @@ class Statsig {
631631
runBlocking { statsigServer.shutdown() }
632632
}
633633

634+
@JvmStatic
635+
fun isInitialized(): Boolean {
636+
return ::statsigServer.isInitialized && statsigServer.initialized
637+
}
638+
634639
private fun checkInitialized(): Boolean {
635-
if (!::statsigServer.isInitialized) {
640+
val initialized = isInitialized()
641+
if (!initialized) {
636642
println("Call and wait for initialize to complete before calling SDK methods.")
637-
return false
638643
}
639-
return true
644+
return initialized
640645
}
641646
}
642647
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal data class StatsigEvent(
88
@SerializedName("value") val eventValue: Any? = null,
99
@SerializedName("metadata") var eventMetadata: Map<String, String>? = null,
1010
@SerializedName("user") var user: StatsigUser? = null,
11-
@SerializedName("statsigMetadata") val statsigMetadata: Map<String, String>? = null,
11+
@SerializedName("statsigMetadata") val statsigMetadata: StatsigMetadata? = null,
1212
@SerializedName("secondaryExposures") val secondaryExposures: ArrayList<Map<String, String>>? = arrayListOf(),
1313
@SerializedName("time") val time: Long? = Utils.getTimeInMillis(),
1414
) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ internal fun safeAddEvaluationToEvent(evaluationDetails: EvaluationDetails?, met
3333
internal class StatsigLogger(
3434
private val coroutineScope: CoroutineScope,
3535
private val network: StatsigNetwork,
36-
private val statsigMetadata: Map<String, String>,
36+
private val statsigMetadata: StatsigMetadata,
3737
) {
3838

3939
private val executor = Executors.newSingleThreadExecutor()

0 commit comments

Comments
 (0)