EventTracker

Core class that interacts with the client

Contains a list of all the trackers

  • To initialize and add trackers:-

Initialize respective Trackers and build inside application onCreate()

val eventTracker =
EventTracker.Builder()
.addTracker(EventKtTracker.init(...)) //Need to add dependency for eventkt
.addTracker(FirebaseTracker.init(this)) //Need to add dependency for eventkt-firebase
.addTracker(MixpanelTracker.init(this, "Add your mixpanel token")) //Need to add dependency for eventkt-mixpanel
.addTracker(AmplitudeTracker.init(this, "Add your amplitude API key")) //Need to add dependency for eventkt-amplitude
.build()
  • To add base parameters:-

eventTracker.addBaseParams(
hashMapOf(
Pair("BaseKey1", "BaseValue1"),
Pair("BaseKey2", "BaseValue2")
)
)
eventTracker.addBaseParam("time", System.currentTimeMillis())
  • To use:-

val parameters = hashMapOf<String, Any>()
parameters["eventSpecificKey1"] = "eventSpecificValue1"
parameters["eventSpecificKey2"] = "eventSpecificValue2"

eventTracker.track("appOpen", parameters)
  • To track some events for specific Tracker:-

Say to track event "XYZ" for EventKtTracker only

Initialize and pass the EventKtTracker to EventTracker.Builder from outside

Use same instance of EventKtTracker passed in EventTracker.Builder and track

val eventKtTracker = EventKtTracker.init(...)
val eventTracker =
EventTracker.Builder()
.addTracker(eventKtTracker)
.//add other trackers and build

eventKtTracker.track("XYZ",
hashMapOf<String, Any>().apply {
putAll(eventTracker.getBaseParams()) //add base parameters to event specific parameters before track
}
)

Throws

If initialize without any tracker in the list

Types

Link copied to clipboard
class Builder

Builder class to build the instance of EventTracker

Functions

Link copied to clipboard

Add base param

Link copied to clipboard

Add base params

Link copied to clipboard
Link copied to clipboard

Remove base param

Link copied to clipboard

Remove base params

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

Add base parameters to each event and delegate call to each tracker in the trackerList.

Link copied to clipboard

Immediately Track all the events