TopStats SDK
Kotlin analytics SDK
Kotlin-first rather than a thin Java wrapper: default arguments instead of builders, data classes for context and flags, jackson-module-kotlin under the hood. The jvm-web module adds a Ktor plugin with route-template request analytics.
Install
// Maven Central soon; today: mvn install from the repo
gg.topstats:analytics-kotlinCapture your first event
val client = TopStatsClient(
apiKey = System.getenv("TOPSTATS_API_KEY"),
defaultSource = "api",
)
client.capture("sync_finished", mapOf("items" to 87),
CaptureContext(actor = "tenant-5"))
client.close()Behaviour you can rely on
- Capture never throws into your code and never blocks on the network - a bounded queue buffers and a background loop batches.
- Retries only 429, 5xx and network failures, with jittered backoff honouring Retry-After; your API key never appears in error output.
- AutoCloseable: use it in a use-block or close() on shutdown to flush the tail.
- Level-triggered flusher signalling - the lost-wakeup class of bug is designed out.