From d6d9684332066aaf5345646061651e67a7ea1247 Mon Sep 17 00:00:00 2001 From: Brian Giori Date: Fri, 20 Sep 2024 14:44:11 -0700 Subject: [PATCH] fix: fix assignment config to use batch when configured (#32) --- src/main/kotlin/LocalEvaluationClient.kt | 13 ++++++++++--- src/main/kotlin/ServerZone.kt | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/LocalEvaluationClient.kt b/src/main/kotlin/LocalEvaluationClient.kt index 241c981..7867e28 100644 --- a/src/main/kotlin/LocalEvaluationClient.kt +++ b/src/main/kotlin/LocalEvaluationClient.kt @@ -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)) }, @@ -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 diff --git a/src/main/kotlin/ServerZone.kt b/src/main/kotlin/ServerZone.kt index c5d5dc3..7cd81ed 100644 --- a/src/main/kotlin/ServerZone.kt +++ b/src/main/kotlin/ServerZone.kt @@ -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