or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

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

0

# Rollbar.js

1

2

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.

3

4

## Package Information

5

6

- **Package Name**: rollbar

7

- **Package Type**: npm

8

- **Language**: JavaScript/TypeScript

9

- **Installation**: `npm install rollbar`

10

11

## Core Imports

12

13

**Server-side (Node.js):**

14

15

```javascript

16

const Rollbar = require('rollbar');

17

```

18

19

**Browser-side (ES6 modules):**

20

21

```javascript

22

import * as Rollbar from 'rollbar';

23

// or

24

const Rollbar = require('rollbar');

25

```

26

27

**Browser (UMD/Script tag):**

28

29

```html

30

<script src="https://cdn.rollbar.com/rollbar.umd.min.js"></script>

31

<!-- Rollbar is available as global variable -->

32

```

33

34

**TypeScript:**

35

36

```typescript

37

import * as Rollbar from 'rollbar';

38

// or

39

import Rollbar = require('rollbar');

40

// Types are included with the package

41

```

42

43

## Basic Usage

44

45

**Server-side initialization:**

46

47

```javascript

48

const Rollbar = require('rollbar');

49

50

const rollbar = new Rollbar({

51

accessToken: 'YOUR_ACCESS_TOKEN',

52

environment: 'production'

53

});

54

55

// Log different severity levels

56

rollbar.info('Application started');

57

rollbar.error(new Error('Something went wrong'));

58

```

59

60

**Browser initialization:**

61

62

```javascript

63

const rollbar = new Rollbar({

64

accessToken: 'YOUR_CLIENT_ACCESS_TOKEN',

65

captureUncaught: true,

66

captureUnhandledRejections: true,

67

environment: 'production'

68

});

69

70

// Automatic error capture is enabled

71

// Manual logging also available

72

rollbar.error('User action failed');

73

```

74

75

## Architecture

76

77

Rollbar.js is built around several key components:

78

79

- **Core Rollbar Class**: Main interface providing logging methods and configuration

80

- **API Module**: Handles communication with Rollbar's servers

81

- **Queue System**: Manages item processing with rate limiting and retry logic

82

- **Telemetry System**: Captures application events and user interactions for debugging context

83

- **Transform Pipeline**: Processes and enriches error data before sending

84

- **Plugin System**: Extensible architecture supporting framework integrations (jQuery, etc.)

85

- **Platform Adapters**: Separate implementations for Node.js, browser, and React Native

86

87

## Capabilities

88

89

### Core Logging

90

91

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

92

93

```typescript { .api }

94

function log(...args: LogArgument[]): LogResult;

95

function debug(...args: LogArgument[]): LogResult;

96

function info(...args: LogArgument[]): LogResult;

97

function warn(...args: LogArgument[]): LogResult;

98

function error(...args: LogArgument[]): LogResult;

99

function critical(...args: LogArgument[]): LogResult;

100

101

type LogArgument = string | Error | object | Callback | Date | any[] | undefined;

102

interface LogResult {

103

uuid: string;

104

}

105

```

106

107

[Core Logging](./core-logging.md)

108

109

### Configuration Management

110

111

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

112

113

```typescript { .api }

114

function configure(options: Configuration): Rollbar;

115

function global(options: Configuration): Rollbar;

116

117

interface Configuration {

118

accessToken?: string;

119

environment?: string;

120

endpoint?: string;

121

enabled?: boolean;

122

captureUncaught?: boolean;

123

captureUnhandledRejections?: boolean;

124

logLevel?: Level;

125

reportLevel?: Level;

126

maxItems?: number;

127

itemsPerMinute?: number;

128

scrubFields?: string[];

129

scrubHeaders?: string[];

130

// ... many more options

131

}

132

```

133

134

[Configuration](./configuration.md)

135

136

### Server-side Integration

137

138

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

139

140

```typescript { .api }

141

function errorHandler(): ExpressErrorHandler;

142

function lambdaHandler<T>(handler: LambdaHandler<T>): LambdaHandler<T>;

143

function wrapCallback(callback: Function): Function;

144

145

type ExpressErrorHandler = (err: any, req: any, res: any, next: Function) => any;

146

type LambdaHandler<T> = (event: T, context: any, callback: Callback) => void | Promise<any>;

147

```

148

149

[Server Integration](./server-integration.md)

150

151

### Browser Integration

152

153

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

154

155

```typescript { .api }

156

function wrap(fn: Function, context?: any, before?: Function): Function;

157

function captureEvent(metadata: object, level: Level): TelemetryEvent;

158

159

interface TelemetryEvent {

160

level: Level;

161

type: string;

162

timestamp_ms: number;

163

body: object;

164

source: string;

165

uuid?: string;

166

}

167

```

168

169

[Browser Integration](./browser-integration.md)

170

171

### Telemetry System

172

173

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

174

175

```typescript { .api }

176

function captureEvent(metadata: object, level: Level): TelemetryEvent;

177

function captureError(err: Error, level: Level, rollbarUUID?: string): TelemetryEvent;

178

function captureLog(message: string, level: Level, rollbarUUID?: string): TelemetryEvent;

179

180

interface AutoInstrumentSettings {

181

network?: boolean;

182

networkResponseHeaders?: boolean | string[];

183

log?: boolean;

184

dom?: boolean;

185

navigation?: boolean;

186

connectivity?: boolean;

187

}

188

```

189

190

[Telemetry](./telemetry.md)

191

192

### React Native Integration

193

194

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

195

196

```typescript { .api }

197

function setPerson(personInfo: PersonInfo): void;

198

function clearPerson(): void;

199

```

200

201

[React Native Integration](./react-native-integration.md)

202

203

## Types

204

205

```typescript { .api }

206

type Level = 'debug' | 'info' | 'warning' | 'error' | 'critical';

207

type MaybeError = Error | undefined | null;

208

type Dictionary = { [key: string]: unknown };

209

210

interface Callback<TResponse = any> {

211

(err: MaybeError, response: TResponse): void;

212

}

213

214

declare class Rollbar {

215

constructor(options?: Configuration);

216

static init(options: Configuration): Rollbar;

217

static setComponents(components: Components): void;

218

219

// All logging methods available as both static and instance methods

220

log(...args: LogArgument[]): LogResult;

221

debug(...args: LogArgument[]): LogResult;

222

info(...args: LogArgument[]): LogResult;

223

warn(...args: LogArgument[]): LogResult;

224

error(...args: LogArgument[]): LogResult;

225

critical(...args: LogArgument[]): LogResult;

226

227

configure(options: Configuration): Rollbar;

228

wait(callback: () => void): void;

229

lastError(): MaybeError;

230

}

231

232

interface Components {

233

telemeter?: TelemeterType;

234

instrumenter?: InstrumenterType;

235

polyfillJSON?: PolyfillJSONType;

236

wrapGlobals?: WrapGlobalsType;

237

scrub?: ScrubType;

238

truncation?: TruncationType;

239

}

240

```