Skip to main content

Configuration Options

The Solute SDK can be configured with a variety of options to customize its behavior.

Basic Configuration

import { SoluteClient } from '@solute-ai/sdk';

const solute = new SoluteClient({
  apiKey: 'your_api_key',        // Required
  host: 'https://api.solute.dev', // Optional
});

Configuration Reference

Required Options

apiKey
string
required
Your Solute API key. Get this from your Solute dashboard.

Optional Options

host
string
default:"https://api.solute.dev"
The API host URL. Defaults to https://api.solute.dev.
debug
boolean
default:"false"
Enable debug logging. Useful for development. Logs all events and API calls to the console.
disabled
boolean
default:"false"
Disable the SDK entirely. All methods will be no-ops. Useful for testing or feature flags.
autoPageViews
boolean
default:"true"
Automatically track page views on route changes (browser only).
capturePageViewOnInit
boolean
default:"true"
Capture a page view event when the SDK initializes.
capturePII
boolean
default:"true"
Capture personally identifiable information (PII) in events. Set to false for GDPR compliance.
sessionTimeout
number
default:"1800000"
Session timeout in milliseconds. Defaults to 30 minutes (1800000ms). A new session is created after this period of inactivity.
userId
string
Pre-set the user ID. Useful if you already know the user ID at initialization time.
anonymousId
string
Pre-set the anonymous ID. Usually auto-generated, but can be set for consistency.
onError
(error: Error) => void
Error handler callback. Called when errors occur during event tracking or API calls.

Storage Configuration

storage.type
'localStorage' | 'cookie' | 'memory'
default:"'localStorage'"
Storage backend to use. localStorage for browser, cookie for cross-domain tracking, memory for server-side or testing.
storage.prefix
string
default:"'solute_'"
Prefix for all storage keys. Useful to avoid conflicts with other libraries.
const solute = new SoluteClient({
  apiKey: 'your_api_key',
  storage: {
    type: 'localStorage',
    prefix: 'solute_',
  },
});

Queue Configuration

queue.maxQueueSize
number
default:"1000"
Maximum number of events to queue before dropping old events. Prevents memory issues.
queue.flushInterval
number
default:"10000"
Automatic flush interval in milliseconds. Events are sent to the API every N milliseconds. Defaults to 10 seconds.
queue.flushAt
number
default:"20"
Number of events to accumulate before automatically flushing. Events are sent when this many events are queued.
queue.maxBatchSize
number
default:"100"
Maximum number of events to send in a single batch request.
const solute = new SoluteClient({
  apiKey: 'your_api_key',
  queue: {
    maxQueueSize: 1000,
    flushInterval: 10000,  // 10 seconds
    flushAt: 20,           // Flush at 20 events
    maxBatchSize: 100,
  },
});

Feature Flags Configuration

featureFlags.enabled
boolean
default:"true"
Enable feature flags and A/B testing functionality.
featureFlags.refreshInterval
number
default:"300000"
Feature flags refresh interval in milliseconds. Defaults to 5 minutes (300000ms).
featureFlags.trackExposure
boolean
default:"true"
Automatically track exposure events when feature flags are evaluated.
const solute = new SoluteClient({
  apiKey: 'your_api_key',
  featureFlags: {
    enabled: true,
    refreshInterval: 300000,  // 5 minutes
    trackExposure: true,
  },
});

HTTP Configuration

http.timeout
number
default:"10000"
Request timeout in milliseconds. Defaults to 10 seconds.
http.maxRetries
number
default:"3"
Maximum number of retry attempts for failed requests.
http.retryDelay
number
default:"1000"
Initial retry delay in milliseconds. Uses exponential backoff.
http.headers
Record<string, string>
Additional HTTP headers to include in all requests.
const solute = new SoluteClient({
  apiKey: 'your_api_key',
  http: {
    timeout: 10000,
    maxRetries: 3,
    retryDelay: 1000,
    headers: {
      'X-Custom-Header': 'value',
    },
  },
});

Complete Example

import { SoluteClient } from '@solute-ai/sdk';

const solute = new SoluteClient({
  // Required
  apiKey: process.env.SOLUTE_API_KEY!,
  
  // Optional
  host: 'https://api.solute.dev',
  debug: process.env.NODE_ENV === 'development',
  disabled: false,
  
  // Session
  sessionTimeout: 30 * 60 * 1000, // 30 minutes
  
  // Storage
  storage: {
    type: 'localStorage',
    prefix: 'solute_',
  },
  
  // Queue
  queue: {
    maxQueueSize: 1000,
    flushInterval: 10000,
    flushAt: 20,
    maxBatchSize: 100,
  },
  
  // Feature Flags
  featureFlags: {
    enabled: true,
    refreshInterval: 5 * 60 * 1000, // 5 minutes
    trackExposure: true,
  },
  
  // HTTP
  http: {
    timeout: 10000,
    maxRetries: 3,
    retryDelay: 1000,
  },
  
  // Error handling
  onError: (error) => {
    console.error('Solute SDK error:', error);
  },
});

Next Steps