or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

browser-integration.mdconfiguration.mdcore-logging.mdindex.mdreact-native-integration.mdserver-integration.mdtelemetry.md
tile.json

tessl/npm-rollbar

JavaScript error tracking and monitoring library for Node.js and browser environments with telemetry, automatic error grouping, and real-time notifications

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/rollbar@2.26.x

To install, run

npx @tessl/cli install tessl/npm-rollbar@2.26.0

index.mddocs/

Rollbar.js

Rollbar.js is a comprehensive JavaScript error tracking and monitoring library supporting both Node.js server-side and browser client-side environments. It provides real-time error tracking with automatic error grouping, telemetry breadcrumbs for debugging context, customizable notifications, and advanced search capabilities for filtering and analyzing errors.

Package Information

  • Package Name: rollbar
  • Package Type: npm
  • Language: JavaScript/TypeScript
  • Installation: npm install rollbar

Core Imports

Server-side (Node.js):

const Rollbar = require('rollbar');

Browser-side (ES6 modules):

import * as Rollbar from 'rollbar';
// or
const Rollbar = require('rollbar');

Browser (UMD/Script tag):

<script src="https://cdn.rollbar.com/rollbar.umd.min.js"></script>
<!-- Rollbar is available as global variable -->

TypeScript:

import * as Rollbar from 'rollbar';
// or
import Rollbar = require('rollbar');
// Types are included with the package

Basic Usage

Server-side initialization:

const Rollbar = require('rollbar');

const rollbar = new Rollbar({
  accessToken: 'YOUR_ACCESS_TOKEN',
  environment: 'production'
});

// Log different severity levels
rollbar.info('Application started');
rollbar.error(new Error('Something went wrong'));

Browser initialization:

const rollbar = new Rollbar({
  accessToken: 'YOUR_CLIENT_ACCESS_TOKEN',
  captureUncaught: true,
  captureUnhandledRejections: true,
  environment: 'production'
});

// Automatic error capture is enabled
// Manual logging also available
rollbar.error('User action failed');

Architecture

Rollbar.js is built around several key components:

  • Core Rollbar Class: Main interface providing logging methods and configuration
  • API Module: Handles communication with Rollbar's servers
  • Queue System: Manages item processing with rate limiting and retry logic
  • Telemetry System: Captures application events and user interactions for debugging context
  • Transform Pipeline: Processes and enriches error data before sending
  • Plugin System: Extensible architecture supporting framework integrations (jQuery, etc.)
  • Platform Adapters: Separate implementations for Node.js, browser, and React Native

Capabilities

Core Logging

Primary error and message logging functionality with multiple severity levels. Supports flexible argument patterns and automatic error enrichment.

function log(...args: LogArgument[]): LogResult;
function debug(...args: LogArgument[]): LogResult;
function info(...args: LogArgument[]): LogResult;
function warn(...args: LogArgument[]): LogResult;
function error(...args: LogArgument[]): LogResult;
function critical(...args: LogArgument[]): LogResult;

type LogArgument = string | Error | object | Callback | Date | any[] | undefined;
interface LogResult {
  uuid: string;
}

Core Logging

Configuration Management

Comprehensive configuration system for customizing behavior, data collection, and filtering across different environments.

function configure(options: Configuration): Rollbar;
function global(options: Configuration): Rollbar;

interface Configuration {
  accessToken?: string;
  environment?: string;
  endpoint?: string;
  enabled?: boolean;
  captureUncaught?: boolean;
  captureUnhandledRejections?: boolean;
  logLevel?: Level;
  reportLevel?: Level;
  maxItems?: number;
  itemsPerMinute?: number;
  scrubFields?: string[];
  scrubHeaders?: string[];
  // ... many more options
}

Configuration

Server-side Integration

Node.js specific features including Express middleware, AWS Lambda integration, and local variable capture.

function errorHandler(): ExpressErrorHandler;
function lambdaHandler<T>(handler: LambdaHandler<T>): LambdaHandler<T>;
function wrapCallback(callback: Function): Function;

type ExpressErrorHandler = (err: any, req: any, res: any, next: Function) => any;
type LambdaHandler<T> = (event: T, context: any, callback: Callback) => void | Promise<any>;

Server Integration

Browser Integration

Browser-specific error handling including global error capture, DOM event telemetry, and function wrapping.

function wrap(fn: Function, context?: any, before?: Function): Function;
function captureEvent(metadata: object, level: Level): TelemetryEvent;

interface TelemetryEvent {
  level: Level;
  type: string;
  timestamp_ms: number;
  body: object;
  source: string;
  uuid?: string;
}

Browser Integration

Telemetry System

Comprehensive telemetry capture for debugging context including user interactions, network requests, and application events.

function captureEvent(metadata: object, level: Level): TelemetryEvent;
function captureError(err: Error, level: Level, rollbarUUID?: string): TelemetryEvent;
function captureLog(message: string, level: Level, rollbarUUID?: string): TelemetryEvent;

interface AutoInstrumentSettings {
  network?: boolean;
  networkResponseHeaders?: boolean | string[];
  log?: boolean;
  dom?: boolean;
  navigation?: boolean;
  connectivity?: boolean;
}

Telemetry

React Native Integration

React Native specific features for person management and enhanced error tracking in mobile applications.

function setPerson(personInfo: PersonInfo): void;
function clearPerson(): void;

React Native Integration

Types

type Level = 'debug' | 'info' | 'warning' | 'error' | 'critical';
type MaybeError = Error | undefined | null;
type Dictionary = { [key: string]: unknown };

interface Callback<TResponse = any> {
  (err: MaybeError, response: TResponse): void;
}

declare class Rollbar {
  constructor(options?: Configuration);
  static init(options: Configuration): Rollbar;
  static setComponents(components: Components): void;
  
  // All logging methods available as both static and instance methods
  log(...args: LogArgument[]): LogResult;
  debug(...args: LogArgument[]): LogResult;
  info(...args: LogArgument[]): LogResult;
  warn(...args: LogArgument[]): LogResult;
  error(...args: LogArgument[]): LogResult;
  critical(...args: LogArgument[]): LogResult;
  
  configure(options: Configuration): Rollbar;
  wait(callback: () => void): void;
  lastError(): MaybeError;
}

interface Components {
  telemeter?: TelemeterType;
  instrumenter?: InstrumenterType;
  polyfillJSON?: PolyfillJSONType;
  wrapGlobals?: WrapGlobalsType;
  scrub?: ScrubType;
  truncation?: TruncationType;
}