com.deque.networking.analytics.AmplitudeClient.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of axe-devtools-android-analytics Show documentation
Show all versions of axe-devtools-android-analytics Show documentation
The Axe Devtools Android Analytics Library
The newest version!
package com.deque.networking.analytics
import com.deque.networking.models.DequeRetrofitBuilder
internal class AmplitudeClient(
private val apiKey: String,
private val baseUrl: String
) {
private val amplitudeInterface: AmplitudeInterface = DequeRetrofitBuilder(baseUrl)
.client(AmplitudeInterface::class.java)
private val sessionId by lazy { System.currentTimeMillis() }
suspend fun sendEvent(
eventType: AmplitudeEventType,
eventInfoProps: AmplitudeEventInfoProps? = null,
eventProps: AmplitudeEventProps? = null
): Result {
return amplitudeInterface.sendEvent(
AmplitudeData(
api_key = apiKey,
events = listOf(
AmplitudeEvent(
user_id = AnalyticsService.userId,
event_type = eventType.eventName,
session_id = sessionId,
event_properties = eventProps,
os_name = eventInfoProps?.os_name,
os_version = eventInfoProps?.os_version,
device_brand = eventInfoProps?.device_brand,
device_manufacturer = eventInfoProps?.device_manufacturer,
device_model = eventInfoProps?.device_model,
time = eventInfoProps?.time ?: System.currentTimeMillis()
)
)
)
)
}
}