Skip to main content
GitHub

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

OptionTypeDefaultDescription
apiKeystringenvAPI key (or RISICARE_API_KEY). Each key is scoped to one project.
endpointstring"https://app.risicare.ai"Gateway endpoint URL
environmentstring"development"Environment name (within-project org)
serviceNamestringundefinedService name (within-project org)
serviceVersionstringundefinedService version for traces
enabledbooleantrueEnable tracing (true if apiKey provided)
traceContentbooleantrueCapture prompts/completions
compressbooleanfalseEnable gzip compression for exports
sampleRatenumber1.0Trace sampling rate (0-1)
batchSizenumber100Spans per batch
batchTimeoutMsnumber1000Milliseconds between flushes
maxQueueSizenumber10000Max queued spans
debugbooleanfalseEnable debug logging
metadataobjectGlobal metadata for all traces

Environment Variable Mapping

ConfigEnvironment Variable
apiKeyRISICARE_API_KEY
endpointRISICARE_ENDPOINT
environmentRISICARE_ENVIRONMENT
enabledRISICARE_TRACING
traceContentRISICARE_TRACE_CONTENT
compressRISICARE_COMPRESS
serviceNameRISICARE_SERVICE_NAME
serviceVersionRISICARE_SERVICE_VERSION
debugRISICARE_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):

  1. Explicit init() parameters
  2. Environment variables
  3. 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
});

Next Steps