Skip to main content

Overview

Client is the main entry point for the Mirador SDK. It handles authentication, plugin registration, sampling, and creates trace builders.

Import

Web SDK:
Node.js SDK:

Constructor

Web SDK:
Node.js SDK:

Parameters

Options

Web SDK:
Node.js SDK:

Examples

Basic initialization:
With custom gateway:
With custom keep-alive interval:
With Web3Plugin:

Sampling

Control what percentage of traces are recorded. Unsampled traces return a NoopTrace that silently discards all operations, so your code doesn’t need any conditional checks. Fixed sample rate:
Custom sampler function:

Lifecycle Callbacks

Register callbacks to observe trace lifecycle events across all traces. See the Lifecycle Callbacks guide for detailed usage patterns and examples.

Methods

trace()

Creates a new trace builder. Web SDK:
Node.js SDK:

Parameters

TraceOptions

Web SDK: Node.js SDK:

Returns

Trace - A trace builder instance (or NoopTrace if the trace is not sampled)

Examples

Web SDK - Basic trace:
Web SDK - With full options:
Node.js SDK - Basic trace:
Node.js SDK - Without stack trace:

Usage Patterns

Single Client Instance

Create one client instance and reuse it: Web SDK:
Node.js SDK:

Multiple Traces

A single client can create multiple concurrent traces: Web SDK:
Node.js SDK:

Environment-Based Configuration

Authentication

The API key is sent with every request in the x-ingest-api-key header. Keep your API key secure:
  • Don’t commit it to version control
  • Use environment variables
  • Consider using different keys for dev/prod

Next Steps

Trace

Trace builder methods

Types

TypeScript type definitions