Skip to main content

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.
When you pass an Error object, the SDK automatically extracts:
  • errorName — The error’s class name (e.g. TypeError)
  • errorStack — The full stack trace
  • The error message is included in the data

log(entry)

Low-level logging method with full control over the log entry.

Error Handling

When you pass an Error object to error(), the SDK extracts structured fields:

Data Object

The data 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 the flow() method to create a new flow. This is an async operation that creates the flow on the server:
Each log is automatically tagged with:
  • 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 using minLevel configuration, filtered logs don’t increment the step index:
This ensures your step indices remain sequential without gaps.

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?)

Parameters: The SDK sets the correct Content-Type header automatically and retries with exponential backoff on failure.

Examples

CSV:
JSONL:
Plain text:

Supported Formats

See Log Ingestion for full format details.

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 return this for chaining:

Log Entry Interface

Options Object

All logging methods accept an optional options object:
Ready to start logging? Sign up free — send your first log in under 5 minutes.