TopStats SDK
Ruby analytics SDK
Pure-stdlib Ruby (net/http, JSON) with a background flusher thread and keyword-argument capture. The rails package adds one Rack middleware covering Rails and Sinatra with real route templates, auto-wired by a Railtie.
Install
gem install topstats-analytics # RubyGems soon; bundle from the repo todayCapture your first event
client = TopStats::Client.new(ENV.fetch("TOPSTATS_API_KEY"),
default_source: "api")
client.capture("import_finished", { "rows" => 3200 },
actor: "org-12", actor_label: "Acme")
client.shutdownBehaviour 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.
- Puma cluster mode needs no fork hooks - the flusher thread starts lazily in the worker that captures.
- capture never raises; failures reach the on_error handler.