# Delivery and diagnostics

Understand bounded queues, retries, persistence, sampling, and dropped events.


## Bounded delivery

The SDK batches events rather than sending one request for every signal. Default flushing is every five seconds; the browser batch setting defaults to 50 events. Transport batches are bounded to about 48 KB. In-memory queues are bounded so a prolonged collector outage cannot grow indefinitely.

Retryable delivery honors backoff and `Retry-After`. Invalid or revoked credentials can stop delivery rather than creating an endless retry loop. Successful sendBeacon submission means the browser accepted the handoff; it is not an end-to-end receipt guarantee.

## Sampling

`sampleRate` applies to non-error events. Error sampling is not applied by that option. However, privacy filters, capacity limits, oversize rejection, monthly quotas, and offline expiry can still prevent errors from being retained.

```ts title="Server delivery"
import { init, getDiagnostics, flush } from '@everock/sdk/node';
init({
  publicKey: process.env.EVEROCK_PUBLIC_KEY!,
  endpoint: process.env.EVEROCK_ENDPOINT!,
  sampleRate: 0.25,
  transport: { requestTimeoutMs: 5000, maxAttempts: 3 },
});
console.log(getDiagnostics());
await flush();
```

## Persistence

Browser IndexedDB and Node disk journals can preserve pending sanitized events when available. Node retains up to 10,000 pending events or 24 MB by default. Browsers retain up to 1,000 events or 5 MB. Both expire pending events after 24 hours and drop the oldest when a storage limit is reached. The in-memory send buffer holds 1,000 events. An event evicted from that buffer can still be delivered from the journal. Set `persistence: false` to opt out. Edge runtimes require an explicit durable adapter.

Diagnostics expose attempts, failures, last status, queued events, drops by reason, and persistence counters. A zero queue alone does not prove that every event was accepted.

## Shutdown

Await `flush()` or `shutdown()` before a process or invocation ends. The Node shutdown path restores instrumentation. See [troubleshooting](/docs/operations/troubleshooting) and [usage](/docs/platform/usage).
