diff --git a/android/src/main/java/com/amplitude/android/Configuration.kt b/android/src/main/java/com/amplitude/android/Configuration.kt index aa6f378a..d40af8a3 100644 --- a/android/src/main/java/com/amplitude/android/Configuration.kt +++ b/android/src/main/java/com/amplitude/android/Configuration.kt @@ -18,6 +18,7 @@ class Configuration( storageProvider: StorageProvider = FileStorageProvider(), loggerProvider: LoggerProvider = AndroidLoggerProvider(), minIdLength: Int? = null, + partnerId: String? = null, callback: EventCallBack? = null, val useAdvertisingIdForDeviceId: Boolean = false, val useAppSetIdForDeviceId: Boolean = false, @@ -27,8 +28,8 @@ class Configuration( val locationListening: Boolean = true, val flushEventsOnClose: Boolean = true, val minTimeBetweenSessionsMillis: Long = MIN_TIME_BETWEEN_SESSIONS_MILLIS, - val trackingSessionEvents: Boolean = true -) : Configuration(apiKey, flushQueueSize, flushIntervalMillis, instanceName, optOut, storageProvider, loggerProvider, minIdLength, callback) { + val trackingSessionEvents: Boolean = true, +) : Configuration(apiKey, flushQueueSize, flushIntervalMillis, instanceName, optOut, storageProvider, loggerProvider, minIdLength, partnerId, callback) { companion object { const val MIN_TIME_BETWEEN_SESSIONS_MILLIS: Long = 5 * 60 * 1000 } diff --git a/android/src/main/java/com/amplitude/android/plugins/AndroidContextPlugin.kt b/android/src/main/java/com/amplitude/android/plugins/AndroidContextPlugin.kt index 854bb1a7..6a340362 100644 --- a/android/src/main/java/com/amplitude/android/plugins/AndroidContextPlugin.kt +++ b/android/src/main/java/com/amplitude/android/plugins/AndroidContextPlugin.kt @@ -103,6 +103,11 @@ class AndroidContextPlugin : Plugin { event.appSetId = it } } + event.partnerId ?: let { + amplitude.configuration.partnerId ?. let { + event.partnerId = it + } + } } companion object { diff --git a/core/src/main/java/com/amplitude/core/Configuration.kt b/core/src/main/java/com/amplitude/core/Configuration.kt index 864d5005..9828c26f 100644 --- a/core/src/main/java/com/amplitude/core/Configuration.kt +++ b/core/src/main/java/com/amplitude/core/Configuration.kt @@ -15,6 +15,7 @@ open class Configuration( val storageProvider: StorageProvider = InMemoryStorageProvider(), val loggerProvider: LoggerProvider = ConsoleLoggerProvider(), val minIdLength: Int? = null, + val partnerId: String? = null, val callback: EventCallBack? = null, val flushMaxRetries: Int = FLUSH_MAX_RETRIES ) { diff --git a/core/src/main/java/com/amplitude/core/events/EventOptions.kt b/core/src/main/java/com/amplitude/core/events/EventOptions.kt index d59465c6..94caca27 100644 --- a/core/src/main/java/com/amplitude/core/events/EventOptions.kt +++ b/core/src/main/java/com/amplitude/core/events/EventOptions.kt @@ -40,5 +40,6 @@ open class EventOptions { var revenueType: String? = null var extra: Map? = null var callback: EventCallBack? = null + var partnerId: String? = null internal var attempts: Int = 0 } diff --git a/core/src/main/java/com/amplitude/core/platform/plugins/ContextPlugin.kt b/core/src/main/java/com/amplitude/core/platform/plugins/ContextPlugin.kt index b19e0d4f..735fafc9 100644 --- a/core/src/main/java/com/amplitude/core/platform/plugins/ContextPlugin.kt +++ b/core/src/main/java/com/amplitude/core/platform/plugins/ContextPlugin.kt @@ -24,6 +24,11 @@ class ContextPlugin : Plugin { event.library = Constants.SDK_LIBRARY + "/" + Constants.SDK_VERSION event.userId = amplitude.store.userId event.deviceId = amplitude.store.deviceId + event.partnerId ?: let { + amplitude.configuration.partnerId ?. let { + event.partnerId = it + } + } } override fun execute(event: BaseEvent): BaseEvent? { diff --git a/core/src/main/java/com/amplitude/core/utilities/JSONUtil.kt b/core/src/main/java/com/amplitude/core/utilities/JSONUtil.kt index 59d3971f..985513f5 100644 --- a/core/src/main/java/com/amplitude/core/utilities/JSONUtil.kt +++ b/core/src/main/java/com/amplitude/core/utilities/JSONUtil.kt @@ -46,6 +46,7 @@ object JSONUtil { eventJSON.addValue("session_id", event.sessionId) eventJSON.addValue("insert_id", event.insertId) eventJSON.addValue("library", event.library) + eventJSON.addValue("partner_id", event.partnerId) return eventJSON } @@ -187,6 +188,7 @@ internal fun JSONObject.toBaseEvent(): BaseEvent { event.sessionId = this.getLong("session_id") event.insertId = this.optString("insert_id", null) event.library = if (this.has("library")) this.getString("library") else null + event.partnerId = this.optString("partner_id", null) return event }