TopStats SDK
Go analytics library
Idiomatic Go with functional options and no dependencies - the module path is the install. Capture never blocks on the network; a background goroutine drains a bounded queue. The go-web module adds net/http middleware plus Gin, Echo and Fiber adapters.
Install
go get github.com/top-stats/analytics-go-sdkCapture your first event
client, err := topstats.New(os.Getenv("TOPSTATS_API_KEY"),
topstats.WithDefaultSource("api"))
client.Capture("payment_settled", map[string]any{"cents": 4200},
topstats.WithActor("acct_9"))
client.Shutdown(ctx) // flushes the tailBehaviour 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.
- Bounded drop-oldest queue: sustained overload drops analytics, never goodput.
- Flag evaluation is a direct request-response call with a context, separate from the buffered capture path.