TopStats SDK
PHP analytics SDK
PHP has no background threads, so this SDK is honest about it: events buffer in memory and flush on the batch threshold, on an explicit flush(), and in __destruct. Under Octane the buffer survives across requests and batching genuinely pays off. The Laravel package wires it into terminable middleware.
Install
composer require topstats/analytics # Packagist soon; VCS repo works todayCapture your first event
$client = new \TopStats\Analytics\TopStats(getenv('TOPSTATS_API_KEY'));
$client->capture('invoice_sent', ['total' => 42], ['actor' => 'user-9']);
$client->flush();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 constructor is the only throwing path; capture reports every problem through onError instead.
- Requests use PHP streams - no curl extension requirement.