JS Configuration
Configure the Risicare JavaScript SDK.
Complete configuration reference for the JavaScript/TypeScript SDK.
RisicareConfig Interface
interface RisicareConfig {
// Required
apiKey?: string; // Each key is scoped to one project
// Optional
endpoint?: string;
environment?: string; // Within-project organization
serviceName?: string; // Within-project organization
serviceVersion?: string;
enabled?: boolean;
traceContent?: boolean;
compress?: boolean;
sampleRate?: number;
batchSize?: number;
batchTimeoutMs?: number;
maxQueueSize?: number;
debug?: boolean;
metadata?: Record<string, unknown>;
}Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | env | API key (or RISICARE_API_KEY). Each key is scoped to one project. |
endpoint | string | "https://app.risicare.ai" | Gateway endpoint URL |
environment | string | "development" | Environment name (within-project org) |
serviceName | string | undefined | Service name (within-project org) |
serviceVersion | string | undefined | Service version for traces |
enabled | boolean | true | Enable tracing (true if apiKey provided) |
traceContent | boolean | true | Capture prompts/completions |
compress | boolean | false | Enable gzip compression for exports |
sampleRate | number | 1.0 | Trace sampling rate (0-1) |
batchSize | number | 100 | Spans per batch |
batchTimeoutMs | number | 1000 | Milliseconds between flushes |
maxQueueSize | number | 10000 | Max queued spans |
debug | boolean | false | Enable debug logging |
metadata | object | Global metadata for all traces |
Environment Variable Mapping
| Config | Environment Variable |
|---|---|
apiKey | RISICARE_API_KEY |
endpoint | RISICARE_ENDPOINT |
environment | RISICARE_ENVIRONMENT |
enabled | RISICARE_TRACING |
traceContent | RISICARE_TRACE_CONTENT |
compress | RISICARE_COMPRESS |
serviceName | RISICARE_SERVICE_NAME |
serviceVersion | RISICARE_SERVICE_VERSION |
debug | RISICARE_DEBUG |
Runtime Control
Enable/Disable
import { enable, disable, isEnabled } from 'risicare';
// Check status
if (isEnabled()) {
console.log('Tracing is active');
}
// Disable temporarily
disable();
// Re-enable
enable();Flush and Shutdown
import { flush, shutdown } from 'risicare';
// Force export pending spans
await flush();
// Graceful shutdown
await shutdown();Configuration Precedence
Configuration is resolved in order (highest priority first):
- Explicit
init()parameters - Environment variables
- Default values
Advanced Configuration
Custom Endpoint
For self-hosted deployments:
init({
apiKey: 'rsk-...',
endpoint: 'https://your-risicare-instance.com',
});Sampling
Control trace sampling rate:
init({
apiKey: 'rsk-...',
sampleRate: 0.1, // Sample 10% of traces
});