Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add partner_id support #16

Merged
merged 1 commit into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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