TopStats SDK
Swift analytics SDK
Foundation-only - URLSession, JSONSerialization, a serial DispatchQueue for the flush loop - so it runs on macOS and Linux server-side Swift alike. Installable now: SPM straight from the repo URL, no registry wait.
Install
.package(url: "https://github.com/top-stats/analytics-swift-sdk", branch: "master")Capture your first event
let client = TopStatsClient(apiKey: ProcessInfo.processInfo.environment["TOPSTATS_API_KEY"]!,
defaultSource: "api")
client.capture("route_completed", properties: ["km": 12.4],
context: CaptureContext(actor: "rider-7"))
client.shutdown()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.
- The serial queue is the concurrency design: no locks in user-visible paths, no lost wakeups.
- capture never throws; problems surface through the error handler.