
Thin abstraction layer for analytics events: single event shape and track API, pluggable handlers with build-time snapshotting, synchronous ordered delivery, no core dependencies, immutable trackers.
A thin abstraction layer for analytics events in Kotlin Multiplatform.
tracker owns two things: the shape of an event and the act of reporting it.
Product code reports once; one or more handlers decide
where the event goes. No SDK types leak into your features, and the core has no
dependencies.
Analytics code tends to spread across the codebase — a Firebase call in one
feature, a custom endpoint in another. tracker keeps that boundary in one place:
(event, parameters)
Tracker.track
TrackHandler
Maven Central publication is in progress; the first release will be
0.1.0.
commonMain.dependencies {
implementation("com.shenghaiyang:tracker:0.1.0")
}val tracker = buildTracker {
addHandler(TrackHandler { event, parameters ->
println("$event $parameters")
})
}
tracker.track("app_open")
tracker.track(
"purchase",
mapOf("value" to 9.99, "currency" to "CNY"),
)The same thing with the builder:
val tracker = TrackerBuilder()
.addHandler(ConsoleHandler())
.addHandler(MyAnalyticsHandler())
.build()class MyAnalyticsHandler : TrackHandler {
override fun onTrack(event: String, parameters: Map<String, Any?>) {
MyAnalyticsSdk.log(event, parameters)
}
}Parameters are passed through untouched. Common value types are String,
Boolean, Int, Long, Float, Double, and null; each handler maps them
to whatever its backend accepts.
build() snapshots the registered handlers; later addHandler calls do not
affect an existing tracker.| Module | Purpose |
|---|---|
tracker |
Core abstraction: Tracker, TrackHandler, TrackerBuilder
|
tracker-firebase |
Firebase Analytics implementation (planned) |
./kotlin build
./kotlin test -m trackerThis project is licensed under the Apache License, Version 2.0.
Copyright (c) 2026 shenghaiyang.
A thin abstraction layer for analytics events in Kotlin Multiplatform.
tracker owns two things: the shape of an event and the act of reporting it.
Product code reports once; one or more handlers decide
where the event goes. No SDK types leak into your features, and the core has no
dependencies.
Analytics code tends to spread across the codebase — a Firebase call in one
feature, a custom endpoint in another. tracker keeps that boundary in one place:
(event, parameters)
Tracker.track
TrackHandler
Maven Central publication is in progress; the first release will be
0.1.0.
commonMain.dependencies {
implementation("com.shenghaiyang:tracker:0.1.0")
}val tracker = buildTracker {
addHandler(TrackHandler { event, parameters ->
println("$event $parameters")
})
}
tracker.track("app_open")
tracker.track(
"purchase",
mapOf("value" to 9.99, "currency" to "CNY"),
)The same thing with the builder:
val tracker = TrackerBuilder()
.addHandler(ConsoleHandler())
.addHandler(MyAnalyticsHandler())
.build()class MyAnalyticsHandler : TrackHandler {
override fun onTrack(event: String, parameters: Map<String, Any?>) {
MyAnalyticsSdk.log(event, parameters)
}
}Parameters are passed through untouched. Common value types are String,
Boolean, Int, Long, Float, Double, and null; each handler maps them
to whatever its backend accepts.
build() snapshots the registered handlers; later addHandler calls do not
affect an existing tracker.| Module | Purpose |
|---|---|
tracker |
Core abstraction: Tracker, TrackHandler, TrackerBuilder
|
tracker-firebase |
Firebase Analytics implementation (planned) |
./kotlin build
./kotlin test -m trackerThis project is licensed under the Apache License, Version 2.0.
Copyright (c) 2026 shenghaiyang.