EventKtTracker

EventKtTracker: Core class that interacts with client

Implements ITracker

Two ways to initialize EventKtTracker:

  • To make network call at library whenever a batch of events is ready

val eventKtTracker = EventKtTracker.init(
context = this,
apiUrl = "Your api url",
apiKey = "Your api key"
)
val eventTracker = EventTracker.Builder().addTracker(eventKtTracker).build()

//Library will add the "x-api-key" = "apiKey sent by client" into the API headers
//API request format sent by library
{
“events”: [
{
“event”: “event 1”,
“parameters”: {
“param1”: “value1”,
“param2”: “value2”
}
},


]
}
  • To send the list of EventNameParam and request body to client whenever a batch of events is ready

val eventKtTracker = EventKtTracker.initWithCallback(
context = this,
directoryName = "Unique name of the directory to store events in disk"
) { jsonBody, eventList ->
// this is a suspend block runs on background thread where client can make the network call
// client need to return the Boolean indicating whether network request is success or false
return@initWithCallback true
}
val eventTracker = EventTracker.Builder().addTracker(eventKtTracker).build()

Parameters

context

Application context

needApiCall

Boolean to decide if library makes api call

apiUrl

API url

apiHeaders

API headers

eventNumThreshold

Threshold value for count of events

eventTimeThreshold

Threshold interval time in milliseconds

eventSizeThreshold

Threshold value for size of events in bytes

cacheScheme

Caching Strategy for memory or disk

logger

Logger interface to log event addition and network results

makeNetworkRequest

Lambda (suspend function) that invokes whenever the batch of events is ready for network call, client passes boolean for successful or failure network call

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override fun track(eventName: String, eventParameters: HashMap<String, Any>)

Validate the event as per eventValidationConfig and track single event, Also check Utils.validateEvent

Link copied to clipboard
open override fun trackAll()

Track all the untracked events immediately, Check EventManager.flushAll