Configuration

Complete reference for all Apperio SDK configuration options.

Full Configuration

The Apperio.init() method accepts a configuration object with the following shape:

TypeScript
interface LoggerConfig {
  class="syntax-comment">// Required
  projectId: string;
  apiKey: string;

  class="syntax-comment">// Optional - General
  environment?: string;          class="syntax-comment">// default: class="syntax-string">"production"
  service?: string;              class="syntax-comment">// Service/app name tag
  apiEndpoint?: string;          class="syntax-comment">// default: class="syntax-string">"https://apperioserver.onrender.com/api/v1"
  logLevel?: LogLevel;           class="syntax-comment">// Minimum level to capture: class="syntax-string">"trace" | class="syntax-string">"debug" | class="syntax-string">"info" | class="syntax-string">"warn" | class="syntax-string">"error" | class="syntax-string">"fatal"

  class="syntax-comment">// Optional - Batching
  batchSize?: number;            class="syntax-comment">// default: class="syntax-number">10
  flushInterval?: number;        class="syntax-comment">// default: class="syntax-number">5000 (ms)
  maxRetries?: number;           class="syntax-comment">// default: class="syntax-number">3
  maxBufferSize?: number;        class="syntax-comment">// default: class="syntax-number">1000

  class="syntax-comment">// Optional - Auto-capture
  autoCapture?: {
    errors?: boolean;            class="syntax-comment">// default: true
    performance?: boolean;       class="syntax-comment">// default: true
    network?: boolean;           class="syntax-comment">// default: true
    console?: boolean;           class="syntax-comment">// default: false
    pageviews?: boolean;         class="syntax-comment">// default: true
    interactions?: boolean;      class="syntax-comment">// default: false
  };

  class="syntax-comment">// Optional - Data sanitization
  sanitization?: {
    enabled?: boolean;           class="syntax-comment">// default: true
    preset?: class="syntax-string">"STRICT" | class="syntax-string">"BALANCED" | class="syntax-string">"LENIENT";  class="syntax-comment">// default: class="syntax-string">"BALANCED"
    customRules?: SanitizationRule[];
  };
}

Required Options

OptionTypeDescription
projectIdstringYour project's unique identifier from the Apperio dashboard
apiKeystringAPI key for authenticating requests (found in project settings)

Optional Options

OptionDefaultDescription
environment"production"Environment tag attached to all log entries
serviceundefinedOptional service name for multi-service architectures
apiEndpointProduction URLOverride the API endpoint for self-hosted or local development
logLevel"trace"Minimum severity level to capture. Logs below this level are discarded.

Auto-Capture Settings

Auto-capture controls which browser events the SDK instruments automatically. Each can be toggled independently:

SettingDefaultWhat It Captures
errorstruewindow.onerror and unhandledrejection events
performancetruePerformanceObserver entries (LCP, FID, CLS, TTFB, INP)
networktrueXMLHttpRequest and Fetch API calls with timing data
consolefalseIntercepts console.log, console.warn, console.error
pageviewstruePage load events and History API navigation
interactionsfalseClick events on elements and form submissions

Info

Console capture is disabled by default to avoid recursive loops (the SDK itself uses console methods internally). Enable it only if you need to track console output from your application.

Sanitization Presets

The SDK includes built-in PII detection and redaction. Three presets control the aggressiveness of sanitization:

PresetPatterns DetectedBest For
STRICTAll 10+ patterns including partial matchesHealthcare, finance, and highly regulated industries
BALANCEDCommon PII: emails, SSNs, credit cards, API keysMost applications (default)
LENIENTOnly high-confidence matches (full SSNs, credit cards)Internal tools with low PII risk
TypeScript
Apperio.init({
  projectId: class="syntax-string">"...",
  apiKey: class="syntax-string">"...",
  sanitization: {
    enabled: true,
    preset: class="syntax-string">"STRICT",
    customRules: [
      {
        pattern: /INTERNAL-\d{class="syntax-number">6}/g,
        replacement: class="syntax-string">"[INTERNAL_ID]",
        description: class="syntax-string">"Redact internal reference numbers",
      },
    ],
  },
});

Batching Configuration

Fine-tune how the SDK batches and delivers log entries:

OptionDefaultDescription
batchSize10Number of logs to accumulate before sending a batch
flushInterval5000Maximum time (ms) between batch sends
maxRetries3Number of retry attempts for failed requests
maxBufferSize1000Maximum logs held in memory (oldest dropped when exceeded)

Configuration Examples

Development

TypeScript
Apperio.init({
  projectId: class="syntax-string">"dev-project",
  apiKey: class="syntax-string">"dev-key",
  environment: class="syntax-string">"development",
  apiEndpoint: class="syntax-string">"http:class="syntax-comment">//localhost:class="syntax-number">5000/api/v1",
  logLevel: class="syntax-string">"trace",            class="syntax-comment">// Capture everything
  autoCapture: {
    errors: true,
    performance: true,
    network: true,
    console: true,              class="syntax-comment">// Capture console in dev
    pageviews: true,
    interactions: true,         class="syntax-comment">// Track clicks in dev
  },
});

Production

TypeScript
Apperio.init({
  projectId: process.env.APPERIO_PROJECT_ID,
  apiKey: process.env.APPERIO_API_KEY,
  environment: class="syntax-string">"production",
  service: class="syntax-string">"web-app",
  logLevel: class="syntax-string">"info",             class="syntax-comment">// Skip trace/debug in prod
  batchSize: class="syntax-number">20,                class="syntax-comment">// Larger batches for efficiency
  flushInterval: class="syntax-number">10000,         class="syntax-comment">// Less frequent flushes
  autoCapture: {
    errors: true,
    performance: true,
    network: true,
    console: false,             class="syntax-comment">// Skip console in prod
    pageviews: true,
    interactions: false,
  },
  sanitization: {
    enabled: true,
    preset: class="syntax-string">"STRICT",
  },
});