Skip to content

Commit

Permalink
fix: fix assignment config to use batch when configured (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
bgiori authored Sep 20, 2024
1 parent 5d375c8 commit d6d9684
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/kotlin/LocalEvaluationClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class LocalEvaluationClient internal constructor(
init(config.assignmentConfiguration.apiKey)
setEventUploadThreshold(config.assignmentConfiguration.eventUploadThreshold)
setEventUploadPeriodMillis(config.assignmentConfiguration.eventUploadPeriodMillis)
useBatchMode(config.assignmentConfiguration.useBatchMode)
setOptions(Options().setMinIdLength(1))
setServerUrl(getEventServerUrl(config, config.assignmentConfiguration))
},
Expand Down Expand Up @@ -213,8 +212,16 @@ private fun getEventServerUrl(
): String {
return if (assignmentConfiguration.serverUrl == LocalEvaluationConfig.Defaults.EVENT_SERVER_URL) {
when (config.serverZone) {
ServerZone.US -> US_EVENT_SERVER_URL
ServerZone.EU -> EU_EVENT_SERVER_URL
ServerZone.US -> if (assignmentConfiguration.useBatchMode) {
US_BATCH_SERVER_URL
} else {
US_EVENT_SERVER_URL
}
ServerZone.EU -> if (assignmentConfiguration.useBatchMode) {
EU_BATCH_SERVER_URL
} else {
EU_EVENT_SERVER_URL
}
}
} else {
assignmentConfiguration.serverUrl
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/ServerZone.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ internal const val US_COHORT_SERVER_URL = "https://cohort-v2.lab.amplitude.com"
internal const val EU_COHORT_SERVER_URL = "https://cohort-v2.lab.eu.amplitude.com"
internal const val US_EVENT_SERVER_URL = "https://api2.amplitude.com/2/httpapi"
internal const val EU_EVENT_SERVER_URL = "https://api.eu.amplitude.com/2/httpapi"
internal const val US_BATCH_SERVER_URL = "https://api2.amplitude.com/batch"
internal const val EU_BATCH_SERVER_URL = "https://api.eu.amplitude.com/batch"

enum class ServerZone {
US, EU
Expand Down

0 comments on commit d6d9684

Please sign in to comment.