JavaScript error tracking and monitoring library for Node.js and browser environments with telemetry, automatic error grouping, and real-time notifications
—
Comprehensive configuration system for customizing Rollbar behavior, data collection, filtering, and integration settings across different environments.
Update configuration options for an existing Rollbar instance.
/**
* Update configuration options
* @param options - Configuration options to update
* @returns Updated Rollbar instance for chaining
*/
function configure(options: Configuration): Rollbar;Usage Example:
rollbar.configure({
environment: 'staging',
reportLevel: 'warning',
captureUncaught: false
});Configure global rate limiting and settings that affect all Rollbar instances.
/**
* Configure global settings and rate limiting
* @param options - Global configuration options
* @returns Rollbar instance for chaining
*/
function global(options: Configuration): Rollbar;Initialize and return a global Rollbar instance with configuration.
/**
* Initialize global Rollbar instance
* @param options - Initial configuration options
* @returns Configured Rollbar instance
*/
static function init(options: Configuration): Rollbar;Usage Example:
const rollbar = Rollbar.init({
accessToken: 'YOUR_ACCESS_TOKEN',
environment: 'production',
captureUncaught: true
});interface Configuration {
// Core Settings
accessToken?: string;
environment?: string;
endpoint?: string;
enabled?: boolean;
transmit?: boolean;
// Error Handling
captureUncaught?: boolean;
captureUnhandledRejections?: boolean;
ignoreDuplicateErrors?: boolean;
exitOnUncaughtException?: boolean;
// Logging Levels
logLevel?: Level;
reportLevel?: Level;
uncaughtErrorLevel?: Level;
// Rate Limiting
maxItems?: number;
itemsPerMinute?: number;
maxRetries?: number;
retryInterval?: number | null;
timeout?: number;
// Data Collection
captureIp?: boolean | 'anonymize';
captureEmail?: boolean;
captureUsername?: boolean;
captureDeviceInfo?: boolean;
addErrorContext?: boolean;
// Filtering and Scrubbing
scrubFields?: string[];
scrubHeaders?: string[];
scrubPaths?: string[];
scrubRequestBody?: boolean;
scrubTelemetryInputs?: boolean;
overwriteScrubFields?: boolean;
// Message Filtering
ignoredMessages?: (string | RegExp)[];
checkIgnore?: (isUncaught: boolean, args: LogArgument[], item: Dictionary) => boolean;
// Host Filtering
hostSafeList?: string[];
hostBlockList?: string[];
// Telemetry
maxTelemetryEvents?: number;
filterTelemetry?: (event: TelemetryEvent) => boolean;
includeItemsInTelemetry?: boolean;
telemetryScrubber?: TelemetryScrubber;
// Code Version
codeVersion?: string;
code_version?: string;
version?: string;
// Transform and Hooks
transform?: (data: Dictionary, item: Dictionary) => void | Promise<void>;
onSendCallback?: (isUncaught: boolean, args: LogArgument[], item: Dictionary) => void;
// Server-specific Options
host?: string;
locals?: LocalsOptions;
captureLambdaTimeouts?: boolean;
nodeSourceMaps?: boolean;
addRequestData?: (data: Dictionary, req: Dictionary) => void;
// Browser-specific Options
wrapGlobalEventHandlers?: boolean;
inspectAnonymousErrors?: boolean;
stackTraceLimit?: number;
// Auto-instrumentation
autoInstrument?: boolean | AutoInstrumentSettings;
// Payload Customization
payload?: Payload;
sendConfig?: boolean;
verbose?: boolean;
// File Path Rewriting
rewriteFilenamePatterns?: string[];
}accessToken?: string;Your Rollbar project access token. Required for sending data to Rollbar.
Example:
{
accessToken: 'YOUR_POST_SERVER_ITEM_ACCESS_TOKEN'
}environment?: string;The environment your code is running in (e.g., 'production', 'staging', 'development').
enabled?: boolean;Whether Rollbar is enabled. When false, no data is collected or sent.
interface AutoInstrumentSettings {
network?: boolean;
networkResponseHeaders?: boolean | string[];
networkResponseBody?: boolean;
networkRequestBody?: boolean;
log?: boolean;
dom?: boolean;
navigation?: boolean;
connectivity?: boolean;
contentSecurityPolicy?: boolean;
errorOnContentSecurityPolicy?: boolean;
}Usage Example:
{
autoInstrument: {
network: true,
networkResponseHeaders: ['content-type', 'x-request-id'],
log: true,
dom: true,
navigation: true
}
}interface Payload {
person?: {
id: string | number | null;
username?: string;
email?: string;
[property: string]: any;
};
context?: any;
client?: {
javascript?: {
code_version?: string | number;
source_map_enabled?: boolean;
guess_uncaught_frames?: boolean;
[property: string]: any;
};
[property: string]: any;
};
environment?: string;
server?: {
branch?: string;
host?: string;
root?: string;
[property: string]: any;
};
[property: string]: any;
}interface LocalsSettings {
module: LocalsType;
enabled?: boolean;
uncaughtOnly?: boolean;
depth?: number;
maxProperties?: number;
maxArray?: number;
}
type LocalsOptions = LocalsType | LocalsSettings;type TelemetryScrubber = (description: TelemetryScrubberInput) => boolean;
type TelemetryScrubberInput = DomDescription | null;
interface DomDescription {
tagName: string;
id: string | undefined;
classes: string[] | undefined;
attributes: DomAttribute[];
}
interface DomAttribute {
key: DomAttributeKey;
value: string;
}
type DomAttributeKey = 'type' | 'name' | 'title' | 'alt';{
endpoint: 'api.rollbar.com/api/1/item/',
logLevel: 'debug',
reportLevel: 'debug',
uncaughtErrorLevel: 'error',
maxItems: 0, // unlimited
itemsPerMinute: 60,
enabled: true,
transmit: true,
captureUncaught: true,
captureUnhandledRejections: true,
ignoreDuplicateErrors: true
}{
scrubFields: [
'pw', 'pass', 'passwd', 'password', 'password_confirmation',
'passwordConfirmation', 'confirm_password', 'confirmPassword',
'secret', 'secret_token', 'secretToken', 'secret_key', 'secretKey',
'api_key', 'access_token', 'accessToken', 'authenticity_token',
'oauth_token', 'token', 'user_session_secret'
]
}{
scrubHeaders: [
'authorization', 'www-authorization', 'http_authorization',
'omniauth.auth', 'cookie', 'oauth-access-token', 'x-access-token',
'x_csrf_token', 'http_x_csrf_token', 'x-csrf-token'
]
}const rollbar = new Rollbar({
accessToken: 'YOUR_SERVER_ACCESS_TOKEN',
environment: 'production',
captureUncaught: true,
captureUnhandledRejections: true,
reportLevel: 'warning',
locals: {
enabled: true,
depth: 3
},
payload: {
server: {
host: 'web-server-01',
branch: 'main'
}
}
});const rollbar = new Rollbar({
accessToken: 'YOUR_CLIENT_ACCESS_TOKEN',
environment: 'production',
captureUncaught: true,
captureUnhandledRejections: true,
autoInstrument: {
network: true,
dom: true,
navigation: true
},
payload: {
client: {
javascript: {
source_map_enabled: true,
code_version: '1.2.3'
}
},
person: {
id: '12345',
username: 'alice',
email: 'alice@example.com'
}
}
});Install with Tessl CLI
npx tessl i tessl/npm-rollbar