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
| Option | Type | Description |
|---|---|---|
projectId | string | Your project's unique identifier from the Apperio dashboard |
apiKey | string | API key for authenticating requests (found in project settings) |
Optional Options
| Option | Default | Description |
|---|---|---|
environment | "production" | Environment tag attached to all log entries |
service | undefined | Optional service name for multi-service architectures |
apiEndpoint | Production URL | Override 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:
| Setting | Default | What It Captures |
|---|---|---|
errors | true | window.onerror and unhandledrejection events |
performance | true | PerformanceObserver entries (LCP, FID, CLS, TTFB, INP) |
network | true | XMLHttpRequest and Fetch API calls with timing data |
console | false | Intercepts console.log, console.warn, console.error |
pageviews | true | Page load events and History API navigation |
interactions | false | Click 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:
| Preset | Patterns Detected | Best For |
|---|---|---|
| STRICT | All 10+ patterns including partial matches | Healthcare, finance, and highly regulated industries |
| BALANCED | Common PII: emails, SSNs, credit cards, API keys | Most applications (default) |
| LENIENT | Only 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:
| Option | Default | Description |
|---|---|---|
batchSize | 10 | Number of logs to accumulate before sending a batch |
flushInterval | 5000 | Maximum time (ms) between batch sends |
maxRetries | 3 | Number of retry attempts for failed requests |
maxBufferSize | 1000 | Maximum 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",
},
});