Configuration

Every option the Apperio constructor accepts, with its type and default.

This page describes apperio 1.5.2, the current version on npm. Every option is passed to the Apperio constructor.

Minimal setup

TypeScript
import { Apperio } from 'apperio';

const logger = new Apperio({
  apiKey: 'your-api-key',
  projectId: 'your-project-id',
});

apiKey and projectId are required; the constructor throws Apperio: API Key is required. or Apperio: Project ID is required. without them. The constructor also starts the logger, so don’t call init() yourself.

All options

OptionTypeDefaultWhat it does
apiKeystringrequiredYour project’s API key, sent as X-API-Key.
projectIdstringrequiredYour project’s ID.
endpointstringhttps://apperioserver.onrender.com/api/v1Where logs are sent. Leave it alone unless Apperio tells you otherwise.
minLogLevelLogLevelLogLevel.INFOLogs below this level are dropped in the SDK and never sent.
batchSizenumber10Send as soon as this many logs are waiting. The API takes at most 100 logs per request, so keep it at 100 or less.
flushIntervalMsnumber5000Send whatever is waiting this often, in milliseconds.
maxRetriesnumber3Extra attempts when sending fails with a network error or a 5xx response.
retryDelayMsnumber1000Wait before the first retry. It doubles for each later one.
environmentstring'development'Tags every log. Set it to 'production' in production.
serviceNamestring'unknown-service'Tags every log with the part of your system that sent it.
releasestringnoneTags every log with the version of your code.
autoCaptureobjectsee belowWhich browser events are captured automatically.
sanitization{ enabled?, config? }{ enabled: true }PII redaction. See Data sanitization.
offlineOfflineManagerConfig{}The browser’s offline queue. See Delivery and offline.
remoteConfigRemoteConfigOptions{ enabled: false }Fetch some settings from the dashboard. See Delivery and offline.
tracing{ enabled? }{ enabled: false }Trace and span IDs on logs. See Tracing.
replayReplayOptionsfollows the dashboardSession replay, browser only. See Replay options.
enablePatternDetectionbooleantrueLog a warning when the same error repeats or errors spike. See Error tracking.
onPatternDetectedfunctionnoneCalled with each detected pattern.

autoCapture

FieldDefaultCaptures
errorstrueUncaught errors and unhandled promise rejections.
performancetruePage load, resource and paint timing, and Web Vitals.
networkRequeststruefetch and XMLHttpRequest calls.
pageViewstrueThe first page view and every history change.
consoleMessagesfalseconsole.error, warn, log, info and debug calls.
userInteractionsfalseClicks, focus, blur, scrolling and key presses (without the keys).

Fields you leave out keep their defaults. All of these are browser only. Details and log levels are in Auto-instrumentation.

Passing a log level

LogLevel is a TypeScript enum, so in TypeScript import it rather than passing a string:

TypeScript
import { Apperio, LogLevel } from 'apperio';

const logger = new Apperio({
  apiKey: 'your-api-key',
  projectId: 'your-project-id',
  minLogLevel: LogLevel.WARN,
});

In plain JavaScript the string works too: minLogLevel: 'warn'. The levels, lowest first, are trace, debug, info, warn, error and fatal.

A fuller example

src/apperio.ts
import { Apperio, LogLevel } from 'apperio';

export const logger = new Apperio({
  apiKey: 'your-api-key',
  projectId: 'your-project-id',
  environment: 'production',
  serviceName: 'web',
  release: '2.4.1',
  minLogLevel: LogLevel.INFO,
  batchSize: 20,
  flushIntervalMs: 10000,
  autoCapture: {
    consoleMessages: false,
    userInteractions: false,
  },
  replay: {
    enabled: true,
    sampleRate: 0.1,
  },
});

Options with no effect in 1.5.2

These are part of the type, so TypeScript accepts them, but the SDK ignores them. Leave them out:

  • serviceVersion: never sent. Use release.
  • autoCapture.logLevels: auto-captured events always use the levels listed in Auto-instrumentation.
  • tracing.autoTraceNetworkRequests: no spans are created for requests.

Settings in the dashboard

Settings › SDK Config in the dashboard doesn’t change a running SDK unless you turn on remoteConfig, and even then only some of its fields apply. See Remote config.