Node SDK · BufferedRecorder
The default recorder buffers events in memory and flushes in batches:
const rec = es.newRecorder({ bufferSize: 2000, flushInterval: 2_000 });
// or
const rec = recorder.create(projectId, apiKey, { bufferSize: 2000 });
Options
| Option | Default | Purpose |
|---|---|---|
bufferSize |
1000 |
Capacity of the in-memory event buffer. |
flushSize |
100 |
Event count that triggers an immediate flush. |
flushInterval |
5000 |
Max ms between flushes when the size threshold isn't reached. |
flushTimeout |
30000 |
Per-flush timeout (ms) for HTTP calls. |
overflowPolicy |
"drop-newest" |
Behavior when buffer is full: "drop-newest", "block", or "error". |
drainTimeout |
30000 |
Max ms close() waits for in-flight events. |
requestTimeout |
10000 |
Per-request HTTP timeout (ms). |
logger |
console |
Logger for diagnostics (overflow warnings, flush errors). |
baseUrl |
production | Override the ingestion endpoint (tests, staging). |
fetch |
global | Custom fetch implementation. |
autoIdempotencyKey |
off | Copy event.id into event.idempotencyKey when the latter is empty. |
Overflow policies
"drop-newest" // drop the incoming event, log a warning (default)
"block" // wait for space, abort signal, or close()
"error" // throw BufferFullError
Close & flush
close()flushes pending events and waits up todrainTimeoutfor the final HTTP call. ThrowsDrainTimeoutErrorif the deadline is hit. Call once on shutdown.flush()drains buffered events at call time. Useful in tests and for graceful shutdown that needs to observe drain success.