Configure the Overseer SDK

Configuration

Complete guide to configuring the Overseer SDK.

Basic Configuration

import { init } from '@codmir/overseer';

init({
  // Required
  dsn: 'https://your-project.codmir.com/overseer',
  apiKey: 'osk_...',
  service: 'my-app',
  environment: 'production',
  
  // Optional
  release: '1.0.0',
  enabled: true,
  debug: false,
});

All Options

Core Options

OptionTypeDefaultDescription
dsnstringRequiredOverseer endpoint URL
servicestringRequiredService/app name for grouping
environmentstringRequiredEnvironment name
releasestring-App version for release tracking
enabledbooleantrueEnable/disable the SDK
debugbooleanfalseEnable debug console logging

Sampling

OptionTypeDefaultDescription
errorSampleRatenumber1Percentage of errors to capture (0-1)
tracesSampleRatenumber1Percentage of transactions to trace (0-1)

Session Replay

OptionTypeDefaultDescription
enableReplaybooleantrueEnable session replay
replaySampleRatenumber0.1Percentage of sessions to record (0-1)
replayOnErrorSampleRatenumber1.0Percentage of error sessions to record (0-1)

Privacy

OptionTypeDefaultDescription
maskAllInputsbooleanfalseMask all form input values
maskSelectorsstring[][]CSS selectors to mask content

Performance

OptionTypeDefaultDescription
enablePerformancebooleantrueEnable performance tracking

Transport

OptionTypeDefaultDescription
maxBatchSizenumber50Max events per batch
flushIntervalnumber5000Flush interval in ms

Environment-Based Config

import { init } from '@codmir/overseer';

const isProduction = process.env.NODE_ENV === 'production';

init({
  dsn: process.env.NEXT_PUBLIC_OVERSEER_DSN,
  apiKey: process.env.NEXT_PUBLIC_OVERSEER_KEY,
  service: 'my-app',
  environment: process.env.NODE_ENV,
  
  // Less sampling in development
  errorSampleRate: isProduction ? 1 : 0.5,
  replaySampleRate: isProduction ? 0.1 : 0,
  
  // Debug in development
  debug: !isProduction,
  
  // Only enable in production
  enabled: isProduction,
});

Filtering Events

Use beforeSend to filter or modify events:

init({
  dsn: '...',
  apiKey: 'osk_...',
  service: 'my-app',
  environment: 'production',
  
  beforeSend(event) {
    // Skip hydration errors
    if (event.message?.includes('Hydration')) {
      return null;
    }
    
    // Skip chunk load errors
    if (event.message?.includes('ChunkLoadError')) {
      return null;
    }
    
    // Sanitize sensitive data
    if (event.extra?.password) {
      delete event.extra.password;
    }
    
    // Modify event
    event.tags = {
      ...event.tags,
      customTag: 'value',
    };
    
    return event;
  },
});

Privacy Configuration

Mask sensitive content in session replay:

init({
  dsn: '...',
  apiKey: 'osk_...',
  service: 'my-app',
  environment: 'production',
  
  // Mask all form inputs
  maskAllInputs: true,
  
  // Mask specific elements
  maskSelectors: [
    '.credit-card',
    '[data-sensitive]',
    '#ssn-input',
  ],
});

Next.js Configuration

// instrumentation-client.ts
import * as Overseer from '@codmir/overseer/nextjs';

Overseer.init({
  dsn: process.env.NEXT_PUBLIC_OVERSEER_DSN,
  apiKey: process.env.NEXT_PUBLIC_OVERSEER_KEY,
  environment: process.env.NODE_ENV,
  release: process.env.NEXT_PUBLIC_APP_VERSION,
  
  // Next.js specific
  replaysSessionSampleRate: 0.1,
  replaysOnErrorSampleRate: 1.0,
  
  beforeSend(event) {
    // Filter framework noise
    if (event.message?.includes('Text content does not match')) {
      return null;
    }
    return event;
  },
});

Disabling in Tests

// jest.setup.ts or vitest.setup.ts
import { init } from '@codmir/overseer';

init({
  dsn: 'test',
  apiKey: 'osk_...',
  service: 'test',
  environment: 'test',
  enabled: false, // Disable in tests
});