Overview
Client is the main entry point for the Mirador SDK. It handles authentication, plugin registration, sampling, and creates trace builders.
Import
Web SDK:Constructor
Web SDK:Parameters
Options
Web SDK:Examples
Basic initialization:Sampling
Control what percentage of traces are recorded. Unsampled traces return aNoopTrace that silently discards all operations, so your code doesn’t need any conditional checks.
Fixed sample rate:
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: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:Usage Patterns
Single Client Instance
Create one client instance and reuse it: Web SDK:Multiple Traces
A single client can create multiple concurrent traces: Web SDK:Environment-Based Configuration
Authentication
The API key is sent with every request in thex-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