Installation
Basic Usage
Exports
The SDK exports the following:Logging Methods
debug(message, data?, options?)
Log debug-level messages for detailed diagnostic information.
info(message, data?, options?)
Log informational messages about normal operations.
warn(message, data?, options?)
Log warning conditions that might indicate a problem.
error(message, errorOrData?, options?)
Log errors. Accepts either an Error object or a data object.
Error object, the SDK automatically extracts:
errorName— The error’s class name (e.g.TypeError)errorStack— The full stack trace- The error
messageis included in the data
log(entry)
Low-level logging method with full control over the log entry.
Error Handling
When you pass anError object to error(), the SDK extracts structured fields:
Data Object
Thedata parameter accepts any JSON-serializable object:
Tags
Tags help categorize and filter logs. Add them via the options parameter:Flow Tracking
Flows group related logs across a multi-step process with automatic flow IDs and step indexing. See Flows for a conceptual overview.Creating a Flow
Use theflow() method to create a new flow. This is an async operation that creates the flow on the server:
flowId: "checkout-a1b2c3d4"(auto-generated)stepIndex: 0, 1, 2, 3(auto-incrementing)
Flow Properties
Flow Logging Methods
Flows have the same logging methods as the main client:Flow Chaining
Flow methods return the flow for chaining:Real-World Examples
E-commerce Checkout
API Request Lifecycle
Background Job
Flow ID Generation
Flow IDs are generated server-side using the pattern:{name}-{random8chars}
Level Filtering with Flows
When usingminLevel configuration, filtered logs don’t increment the step index:
Raw Format Ingestion
Send pre-formatted log data directly to the ingestion endpoint, bypassing the structured log pipeline. Useful for forwarding logs from external systems (syslog daemons, CSV exports, JSONL streams).ingestRaw(body, format, options?)
| Parameter | Type | Description |
|---|---|---|
body | string | The raw log data |
format | FormatName | One of json, jsonl, syslog, text, csv, obl |
options? | IngestRawOptions | Optional defaults for source, environment, level, dataset |
Content-Type header automatically and retries with exponential backoff on failure.
Examples
CSV:Supported Formats
| Format | Content-Type | Description |
|---|---|---|
json | application/json | JSON array or { logs: [...] } |
jsonl | application/x-ndjson | One JSON object per line |
syslog | application/x-syslog | RFC 5424 / RFC 3164 |
text | text/plain | One log per line |
csv | text/csv | Header row + data rows |
obl | application/x-obl | Open Board Logging |
Client Methods
setUserId(userId)
Set the default user ID for subsequent logs.
setSessionId(sessionId)
Set the default session ID for subsequent logs.
flush()
Immediately send all queued logs.
disconnect()
Flush logs and stop the auto-flush timer.
Method Chaining
All methods returnthis for chaining:
Log Entry Interface
Options Object
All logging methods accept an optionaloptions object: