EventKT - Track it all
Khush Panchal
Posted on January 27, 2024
An Android tracking library that efficiently group events and implements disk caching to safeguard against crashes, providing insightful analytics for app performance and user behaviour.
About EventKT
An innovative In-house SDK designed to seamlessly integrate with your Android application and provide comprehensive tracking capabilities right out of the box.
Why use EventKT?
- Efficient Event Tracking by grouping events and making API call at specified intervals.
- High Customization of grouping intervals, defining custom event thresholds, or configuring network-related settings.
- Event Caching Mechanism to ensure the reliability of your data by incorporating in memory and disk caching.
- Fully Kotlin and User-Friendly ensuring that integrating analytics into your app is a straightforward process.
- Integration with Third-Party Trackers that allows you to use both in-house analytics and other popular trackers simultaneously.
- Networking Flexibility by providing the option for clients to opt out of automatic networking and instead get callbacks with list of events.
High level design
- ITracker — Interface containing track methods. Implemented by EventKtTracker (Main core class of EventKT library), FirebaseTracker, MixpanelTracker, AmplitudeTracker.
- EventTracker — Core class interacting with the client. Manages all trackers and delegates calls to specific trackers. Adds base parameters to each event before delegating the tracking call to individual trackers.
- EventKtTracker — The central class of the library, serving as the starting point for the entire framework. Initiates and creates all dependencies required by the library. Has access to EventManager.
- EventManager — Manages events, handles grouping logic, network state, and interactions with caching and networking classes. Manages the state of each event, providing a transactional approach to safeguard against crashes.
- IGroupEventListener — Interface containing onEventGrouped method which gets invoked every time a group of events are ready for network call.
- NetworkCallManager — Library makes the POST API call with help of API URL and API key passed by client.
- ClientCallbackProvider — Library invokes the lambda function and client can make the network call itself.
- ICacheScheme — Interface containing various methods related to storage of events in memory and disk.
- InMemoryCacheManager — Responsible for keeping the list of events in the memory.
- FileCacheManager — Responsible for keeping the list of events in the disk to safeguard from crashes. It keep itself in sync with memory.
Usage
//Add dependency with latest version
implementation 'com.github.khushpanchal.EventKT:eventkt:0.1.0'
//Initialize on Application onCreate()
class MainApplication : Application() {
lateinit var eventTracker: EventTracker
override fun onCreate() {
super.onCreate()
eventTracker = EventTracker.Builder().addTracker(
EventKtTracker.init(
context = this,
apiUrl = "your API URL",
apiKey = "your API Key"
)
).build()
}
}
//To use
val parameters = hashMapOf<String, Any>()
parameters["eventSpecificKey1"] = "eventSpecificValue1"
parameters["eventSpecificKey2"] = "eventSpecificValue2"
eventTracker.track("appOpen", parameters)
Extensions
EventKT extends its functionality by providing integration with third-party analytics trackers, allowing clients to leverage the unique capabilities of Firebase, Mixpanel, and Amplitude. Clients can easily add these extensions to the library to include additional tracking methods along with it’s own in house sdk.
- Firebase
//Add dependency with latest version
implementation 'com.github.khushpanchal.EventKT:eventkt-firebase:0.1.0'
Add firebase to your project. Add firebase project
val firebaseTracker = FirebaseTracker.init(this) // initialize the firebase
val eventTracker = EventTracker.Builder().addTracker(firebaseTracker).build() // add firebase tracker while creating EventTracker in application onCreate()
- Mixpanel
//Add dependency with latest version
implementation 'com.github.khushpanchal.EventKT:eventkt-mixpanel:0.1.0'
Get a unique token from mixpanel. Get token from mixpanel
val mixpanelTracker = MixpanelTracker.init(this, "your unique token")
val eventTracker = EventTracker.Builder().addTracker(mixpanelTracker).build() // add mixpanel tracker while creating EventTracker in application onCreate()
- Amplitude
//Add dependency with latest version
implementation 'com.github.khushpanchal.EventKT:eventkt-amplitude:0.1.0'
Get a unique API key from amplitude. Get API Key from amplitude
val amplitudeTracker = AmplitudeTracker.init(this, "your unique API key")
val eventTracker = EventTracker.Builder().addTracker(amplitudeTracker).build() // add amplitude tracker while creating EventTracker in application onCreate()
EventKT provides lot more features with plenty of customization options, check out the below links for more information:
Github Project: https://github.com/khushpanchal/EventKT
Full API reference: https://khushpanchal.github.io/EventKT/
Contact Me
Linkedin: https://www.linkedin.com/in/khush-panchal-241098170/
Posted on January 27, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.