Skip to content

Commit

Permalink
feat: add parner_id (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
qingzhuozhen authored Mar 25, 2022
1 parent 689b114 commit 5e46cb9
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions android/src/main/java/com/amplitude/android/Configuration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ class AndroidContextPlugin : Plugin {
event.appSetId = it
}
}
event.partnerId ?: let {
amplitude.configuration.partnerId ?. let {
event.partnerId = it
}
}
}

companion object {
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/com/amplitude/core/Configuration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ open class EventOptions {
var revenueType: String? = null
var extra: Map<String, Any>? = null
var callback: EventCallBack? = null
var partnerId: String? = null
internal var attempts: Int = 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -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? {
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/com/amplitude/core/utilities/JSONUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 5e46cb9

Please sign in to comment.