Skip to main content
The Seer TypeScript SDK provides a lightweight client for logging retrieval events from Node.js and browser environments.
Seer is currently in private beta. Email ben@seersearch.com to request access and receive SDK installation instructions.

Installation

The SDK supports both CommonJS and ES modules:

Quick Start


Configuration

Environment Variables

Constructor Options


SeerClient API

log()

Log a retrieval event.
Returns:
  • fireAndForget=true (default): void, no await needed, event is queued
  • fireAndForget=false: Promise<string | null>, await to get record_id

flush()

Wait for all queued events to be sent.

stats()

Get client statistics.
Returns a ClientStats object:

close()

Shutdown client gracefully (flushes remaining events).

Context Format

Passages can be simple strings or objects with metadata:

Function Wrapper

Use wrapWithSeerTrace to automatically log function calls:

Wrapper Parameters


Fire-and-Forget vs Synchronous

Fire-and-Forget (Default)

Events are queued and sent asynchronously in the background. No await needed, just call log() and continue.
Note: Auto-flush happens on normal exit. Call flush() explicitly before process.exit() or in worker threads.

Synchronous (Get Record ID)

If you need the record_id back, use synchronous mode. The log() call returns a Promise that resolves to the record ID.
  • Fire-and-forget (99% of cases): For logging where you don’t need the ID back. No performance impact on your application.
  • Synchronous: When you need to correlate the record_id with other systems or ensure the event was received before continuing.

OpenTelemetry Integration

The SDK automatically captures OTEL trace context when available:

Manual Trace IDs

Span Name Patterns

Span names are used for filtering in the UI:

Ground Truth (Accuracy Testing)

Include expected results for accuracy measurement:

Convenience Function

For simple cases, use the global seerLog:
Creates a global SeerClient on first call (fire-and-forget mode).

Error Handling

The SDK is designed to be non-blocking and fail gracefully:
  • Queue overflow: Events are dropped (logged to console)
  • Network errors: Retried with exponential backoff, then dropped
  • Invalid API key: Warning logged, event sent (server rejects)
Check client.stats() for failure counts.

TypeScript Types

The SDK exports all types for use in your application:

Examples

  • Basic usage
  • OpenTelemetry integration
  • Express middleware

See Also