{"id":13610386,"url":"https://github.com/khushpanchal/EventKT","last_synced_at":"2025-04-12T22:33:39.142Z","repository":{"id":218970262,"uuid":"747822660","full_name":"khushpanchal/EventKT","owner":"khushpanchal","description":"🚀 EventKT is 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. 🚀 ","archived":false,"fork":false,"pushed_at":"2024-02-11T16:12:44.000Z","size":599,"stargazers_count":54,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-07T16:43:22.253Z","etag":null,"topics":["analytics","analytics-tracking","android","android-library","androiddev","kotlin","product","sdk"],"latest_commit_sha":null,"homepage":"https://khushpanchal.github.io/EventKT/","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/khushpanchal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-01-24T17:56:18.000Z","updated_at":"2024-08-07T08:45:44.000Z","dependencies_parsed_at":"2024-01-24T19:35:14.453Z","dependency_job_id":"4a9ed1c2-73bd-4f19-9f26-952c260d8548","html_url":"https://github.com/khushpanchal/EventKT","commit_stats":null,"previous_names":["khushpanchal/eventkt"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khushpanchal%2FEventKT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khushpanchal%2FEventKT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khushpanchal%2FEventKT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/khushpanchal%2FEventKT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/khushpanchal","download_url":"https://codeload.github.com/khushpanchal/EventKT/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248641979,"owners_count":21138311,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analytics","analytics-tracking","android","android-library","androiddev","kotlin","product","sdk"],"created_at":"2024-08-01T19:01:44.231Z","updated_at":"2025-04-12T22:33:38.842Z","avatar_url":"https://github.com/khushpanchal.png","language":"Kotlin","funding_links":[],"categories":["Kotlin"],"sub_categories":[],"readme":"[![](https://jitpack.io/v/khushpanchal/EventKT.svg)](https://jitpack.io/#khushpanchal/EventKT)\n[![](https://androidweekly.net/issues/issue-609/badge)](https://androidweekly.net/issues/issue-609)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"950\" src=\"https://raw.githubusercontent.com/khushpanchal/EventKT/master/assets/banner.jpeg\" \u003e\n\u003c/p\u003e\n\n# Table of Contents\n\n- [About EventKT](#about-eventkt)\n- [Why use EventKT?](#why-use-eventkt)\n- [How EventKT works?](#how-eventkt-works)\n    - [Understanding a Single Event](#understanding-single-event)\n    - [High level design](#high-level-design)\n- [How to use EventKT?](#how-to-use-eventkt)\n    - [Installation](#installation)\n    - [Initialization](#initialization)\n    - [Usage](#usage)\n- [Customizing EventKT](#customizing-eventkt)\n- [EventKT extensions](#eventkt-extensions)\n    - [Firebase](#firebase)\n    - [Mixpanel](#mixpanel)\n    - [Amplitude](#amplitude)\n- [Contact Me](#contact-me)\n\n\u003ca name=\"about-eventkt\"\u003e\u003c/a\u003e\n# About EventKT\n\nEventKT is an **Android analytics library** created using Kotlin. With EventKT you can easily keep track of what users are doing in your app and send that info to your server. It's designed to give you really useful insights about how users engage with your app, how well your product is doing, and how it affects your business.\n\nIn the world of EventKT, an \"event\" is just any action or thing users do in your app. It could be clicking a button, filling out a form, or anything that shows users are interested. EventKT keeps a close eye on these actions, helping you understand patterns, see how users move through your app, and figure out important business stuff. It's like having a complete picture of how well your product is performing.\n\n### [Get Started - Check out Full API Reference Site](https://khushpanchal.github.io/EventKT/)\n\n\u003ca name=\"why-use-eventkt\"\u003e\u003c/a\u003e\n# Why use EventKT?\n\n- **Efficient Event Tracking** - EventKT operates on the principle of optimizing event tracking by grouping events. Rather than making individual API calls for each event, the library groups a set of events and initiates a single API call at specified intervals.\n  \n- **Customization** - EventKT is highly customizable like grouping intervals, defining custom event thresholds, or configuring network-related settings.\n  \n- **Event Caching Mechanism** - Ensuring the reliability of your data, EventKT incorporates a two-tier caching mechanism. Events are cached both in memory and on disk, providing resilience in scenarios such as app crashes or forceful terminations. With EventKT, you can rest assured that your valuable event data is never lost.\n  \n- **Fully Kotlin and User-Friendly** - Completely built in Kotlin, EventKT leverages the expressive and concise syntax of the language. EventKT is designed with simplicity in mind. Its user-friendly interface ensures that integrating analytics into your app is a straightforward process.\n  \n- **Integration with Third-Party Trackers** - EventKT extends its functionality through easy integration with third-party analytics trackers. This allows you to use both in-house analytics and other popular trackers simultaneously, providing a complete view of your app's performance.\n  \n- **Networking Flexibility** - EventKT provides the option for clients to opt out of automatic networking. Instead, clients can choose to receive a group of events at their preferred intervals and handle the network calls independently.\n\nWith its focus on efficiency, flexibility, and seamless integration, EventKT stands as a versatile and powerful analytics solution for Android developers.\n\n\u003ca name=\"how-eventkt-works\"\u003e\u003c/a\u003e\n# How EventKT works?\n\n\u003ca name=\"understanding-single-event\"\u003e\u003c/a\u003e\n### Understanding a Single Event\n\nIn the realm of EventKT, a single event is composed of two crucial components:\n\n**Event Name**: The identifier for the specific user action or behavior.\n\n**Parameters**: Key-value pairs associated with the event, providing contextual information.\n\nIn addition to the event-specific components, there are also Base Parameters which are key-value pairs included with every event, enriching the data collected.\n\n\u003ca name=\"high-level-design\"\u003e\u003c/a\u003e\n### High level design\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"500\" alt = \"High level design\" src=https://raw.githubusercontent.com/khushpanchal/EventKT/master/assets/high-level-design.jpeg \u003e\n\u003c/p\u003e\n\n- **ITracker** - Interface containing track methods. Implemented by EventKtTracker (Main core class of EventKT library), FirebaseTracker, MixpanelTracker, AmplitudeTracker.\n  \n- **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.\n  \n- **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.\n  \n- **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.\n  \n- **IGroupEventListener** - Interface containing onEventGrouped method which gets invoked every time a group of events are ready for network call.\n  \n  - **NetworkCallManager** - Library makes the POST API call with help of API URL and API key passed by client.\n    \n  - **ClientCallbackProvider** - Library invokes the lambda function and client can make the network call itself.\n    \n- **ICacheScheme** - Interface containing various methods related to storage of events in memory and disk.\n  \n  - **InMemoryCacheManager** - Responsible for keeping the list of events in the memory.\n    \n  - **FileCacheManager** - Responsible for keeping the list of events in the disk to safeguard from crashes. It keep itself in sync with memory.\n\n\u003ca name=\"how-to-use-eventkt\"\u003e\u003c/a\u003e\n# How to use EventKT?\n\n\u003ca name=\"installation\"\u003e\u003c/a\u003e\n### Installation\n\nTo integrate EventKT library into your Android project, follow these simple steps:\n\n1. Update your settings.gradle file with the following dependency.\n   \n```Groovy\ndependencyResolutionManagement {\n  repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)\n  repositories {\n    google()\n    mavenCentral()\n    maven { url 'https://jitpack.io' } // this one\n  }\n}\n```\n\n2. Update your module level build.gradle file with the following dependency.\n   \n```Groovy\ndependencies {\n  implementation 'com.github.khushpanchal.EventKT:eventkt:0.1.0'\n}\n```\n\n\u003ca name=\"initialization\"\u003e\u003c/a\u003e\n### Initialization\n\nTwo ways of initialization:\n\n1. Pass unique API key and API URL while initialization and library makes the API call at appropriate intervals.\n   \n  - API contract used by library.\n    \n```\n{\n “events”: [\n  {\n   “event”: “event 1”,\n   “parameters”: {\n    “param1”: “value1”,\n    “param2”: “value2”\n   }\n  },\n  …\n  …\n ]\n}\n```\n\n  - Library will add the below header in POST API call.\n    \n``` \n\"x-api-key\" = \"apiKey sent by client\"\n```\n\n  - To initialize.\n    \n```Kotlin\nclass MainApplication : Application() {\n\n  lateinit var eventTracker: EventTracker\n\n  override fun onCreate() {\n    super.onCreate()\n    eventTracker = EventTracker.Builder().addTracker(\n      EventKtTracker.init(\n        context = this, \n        apiUrl = \"your API URL\",\n        apiKey = \"your API Key\"\n      )\n    ).build()\n  }\n}\n```\n\n2. Pass the unique directory name and library will give timely callback with list of events, and client can make network call.\n   \n```Kotlin\nclass MainApplication : Application() {\n\n  lateinit var eventTracker: EventTracker\n\n  override fun onCreate() {\n    super.onCreate()\n    eventTracker = EventTracker.Builder().addTracker(\n      EventKtTracker.initWithCallback(\n        context = this,\n        directoryName = \"unique directory name\", // library will use this for storing event, so it should be unique\n      ) { jsonBody, eventList -\u003e\n         // this executes on background and client need to send boolean if network call succeeds\n         // every time a group is ready, make network call\n         return@initWithCallback true // it is compulsory to return boolean\n      }\n    ).build()\n  }\n}\n```\n\n\u003ca name=\"usage\"\u003e\u003c/a\u003e\n### Usage\n\n1. To add base parameters (includes with all the event).\n   \n```Kotlin\neventTracker.addBaseParams(\n  hashMapOf(\n    Pair(\"BaseKey1\", \"BaseValue1\"),\n    Pair(\"BaseKey2\", \"BaseValue2\")\n  )\n) //multiple parameter\neventTracker.addBaseParam(\"time\", System.currentTimeMillis()) //single parameter\n```\n\n2. To track a event.\n   \n```Kotlin\nval parameters = hashMapOf\u003cString, Any\u003e()\nparameters[\"eventSpecificKey1\"] = \"eventSpecificValue1\"\nparameters[\"eventSpecificKey2\"] = \"eventSpecificValue2\"\neventTracker.track(\"appOpen\", parameters)\n```\n\n\u003ca name=\"customizing-eventkt\"\u003e\u003c/a\u003e\n# Customizing EventKT\n\n1. Deciding when to flush all events to network.\n   \n- By default library flushes after every 10 events.\n     \n- There are three ways to customize the event flushing:\n     \n  - Count based - Set the count of events as threshold.\n      \n```Kotlin\nEventKtTracker.init(... // or EventKtTracker.initWithCallback(...\n  eventThreshold = listOf(EventThreshold.NumBased(15)) // flushing occurs after every 15 events\n  ...\n)\n```\n      \n  - Time based - Set the interval as threshold.\n      \n```Kotlin\nEventKtTracker.init(... // or EventKtTracker.initWithCallback(...\n  eventThreshold = listOf(EventThreshold.TimeBased(15000L)) // flushing occurs every 15 seconds\n  ...\n)\n```\n      \n   - Size based - Set the size of events as threshold.\n      \n```Kotlin\nEventKtTracker.init(... // or EventKtTracker.initWithCallback(...\n  eventThreshold = listOf(EventThreshold.SizeBased(3072)) // flushing occurs every time total event size exceeds 3kb (3072 bytes)\n  ...\n)\n```\n      \n- Client can also set multiple ways in list, library will flush events whenever any threshold occurs.\n     \n2. Adding headers to include in api call.\n   \n- Client can add additional headers which will be included in api call.\n     \n```Kotlin\nEventKtTracker.init(...\n  apiHeaders = hashMapOf(\"headerKey1\" to \"headerValue1\", \"headerKey2\" to \"headerValue2\")\n  ...\n)\n```\n      \n3. Setting custom Disk caching logic.\n   \n- Client can set custom logic to cache the events in disk. By default library caches events in File system.\n     \n- To set custom caching logic, create a class that extends InMemoryCacheManager, and override appropriate methods from ICacheScheme and sync disk with memory.\n     \n```Kotlin\nclass MyCacheManager : InMemoryCacheManager() {...}\nEventKtTracker.init(... // or EventKtTracker.initWithCallback(...\n  cacheScheme = MyCacheManager()\n  ...\n)\n```\n   \n4. Setting custom limits to validate event.\n\n- Client can set custom event limits that include length of event name, length of parameter keys, length of parameter values, no. of parameters associated with each event.\n  \n```Kotlin\nEventKtTracker.init(... // or EventKtTracker.initWithCallback(...\n  eventValidationConfig = EventValidationConfig(\n    maxNameLength = 100, // Default = 120\n    maxKeyLength = 100, // Default = 120\n    maxValueLength = 500, // Default = 512\n    maxParameters = 200 // Default = 2565\n  )\n  ...\n)\n```\n\n5. Enable or disable logs.\n\n- Client can enable or disable logs. Currently logs are added at following positions: 1. whenever event is sent to library, 2. whenevent list of events sent to network, 3. whenever network is successful or failed.\n\n```Kotlin\nEventKtTracker.init(... // or EventKtTracker.initWithCallback(...\n  enableLogs = true // Default = false (set as BuildConfig.DEBUG)\n  ...\n)\n```\n\n6. Setting custom logger.\n\n- Client can set the custom logger as well.\n  \n```Kotlin\nclass MyLogger: Logger {\n  override fun log(tag: String?, msg: String?, tr: Throwable?, type: LogType) {\n    //log the message here\n  }\n}\nEventKtTracker.init(... // or EventKtTracker.initWithCallback(...\n  logger = MyLogger() \n  ...\n)\n```\n\n\u003ca name=\"eventkt-extension\"\u003e\u003c/a\u003e\n# EventKT extensions\n\nEventKT 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.\n\n\u003ca name=\"firebase\"\u003e\u003c/a\u003e\n1. Firebase\n\n- Add following dependency at module level build.gradle file\n     \n```Groovy\ndependencies {\n  implementation 'com.github.khushpanchal.EventKT:eventkt-firebase:0.1.0'\n}\n```\n\n- Add firebase to your project. [Add firebase project](https://firebase.google.com/docs/android/setup)\n     \n```Kotlin\n  val firebaseTracker = FirebaseTracker.init(this) // initialize the firebase\n  val eventTracker = EventTracker.Builder().addTracker(firebaseTracker).build() // add firebase tracker while creating EventTracker in application onCreate()\n```\n\n\u003ca name=\"mixpanel\"\u003e\u003c/a\u003e\n2. Mixpanel\n   \n- Add following dependency at module level build.gradle file\n     \n```Groovy\ndependencies {\n  implementation 'com.github.khushpanchal.EventKT:eventkt-mixpanel:0.1.0'\n}\n```\n   \n- Get a unique token from mixpanel. [Get token from mixpanel](https://docs.mixpanel.com/docs/tracking-methods/sdks/android)\n     \n```Kotlin\n  val mixpanelTracker = MixpanelTracker.init(this, \"your unique token\")\n  val eventTracker = EventTracker.Builder().addTracker(mixpanelTracker).build() // add mixpanel tracker while creating EventTracker in application onCreate()\n```\n\n\u003ca name=\"amplitude\"\u003e\u003c/a\u003e\n3. Amplitude\n   \n- Add following dependency at module level build.gradle file\n     \n```Groovy\ndependencies {\n  implementation 'com.github.khushpanchal.EventKT:eventkt-amplitude:0.1.0'\n}\n```\n   \n- Get a unique API key from amplitude. [Get API Key from amplitude](https://www.docs.developers.amplitude.com/analytics/find-api-credentials/)\n     \n```Kotlin\n  val amplitudeTracker = AmplitudeTracker.init(this, \"your unique API key\")\n  val eventTracker = EventTracker.Builder().addTracker(amplitudeTracker).build() // add amplitude tracker while creating EventTracker in application onCreate()\n```\n\nFor more info, check [EventKT Reference documentation](https://khushpanchal.github.io/EventKT/index.html).\n\n\u003ca name=\"contact-me\"\u003e\u003c/a\u003e\n# Contact Me\n\n- [LinkedIn](https://www.linkedin.com/in/khush-panchal-241098170/)\n- [Twitter](https://twitter.com/KhushPanchal15)\n- [Gmail](mailto:khush.panchal123@gmail.com)\n\n## If this project helps you, show love ❤️ by putting a ⭐ on [this](https://github.com/khushpanchal/EventKT) project ✌️\n\n## License\n\n```\n   Copyright (C) 2024 Khush Panchal\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n```\n\n## Blog\n\nCheck out the blog: https://medium.com/@khush.panchal123/eventkt-track-it-all-1ab20888f985\n\n## Contribute to the project\n\nFeel free to provide feedback, report an issue, or contribute to EventKT. Head over to [GitHub repository](https://github.com/khushpanchal/EventKT), create an issue or find the pending issue. All pull requests are welcome 😄\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhushpanchal%2FEventKT","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkhushpanchal%2FEventKT","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkhushpanchal%2FEventKT/lists"}