Registry / observability / rollbar-redux-middleware

rollbar-redux-middleware

JSON →
library0.2.0jsnpmunverified

Redux middleware that integrates with Rollbar error reporting. Version 0.2.0 is the current stable release. It assumes Flux Standard Action (FSA) actions where errors are indicated by an error: true flag and the payload contains the Error object. It automatically includes the Redux store state with reported errors and provides state sanitization via keypaths or a custom sanitizer function. Additionally, it offers an option to wrap all dispatched actions in a try/catch block. Differentiators: simplifies attaching Redux state to Rollbar errors and offers flexible state redaction compared to manual integration.

npm install rollbar-redux-middleware
INSTALL
IMPORT
SIG · ROLLBAR-REDUX-MIDD
R
rollbar-redux-middleware
observabilityjavascriptv0.2.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

rollbarMiddleware
✓ import rollbarMiddleware from 'rollbar-redux-middleware';
✗ const rollbarMiddleware = require('rollbar-redux-middleware');
Default export is a function. CJS require works but ESM is preferred.

Shows basic setup: importing rollbar and middleware, creating a Rollbar instance, and applying the middleware with state sanitization keypaths.

import { createStore, applyMiddleware } from 'redux'; import rollbar from 'rollbar'; import rollbarMiddleware from 'rollbar-redux-middleware'; const Rollbar = new rollbar({ accessToken: process.env.ROLLBAR_ACCESS_TOKEN ?? '' }); const initialState = { user: { name: 'Alice' } }; const rootReducer = (state = initialState, action) => state; const rollbarRedux = rollbarMiddleware(Rollbar, ['user.name']); const store = createStore( rootReducer, initialState, applyMiddleware(rollbarRedux) ); store.dispatch({ type: 'TEST' }); console.log('Middleware configured. Errors will be reported to Rollbar.');
Debug
Known issues
gotchaAssumes action is a Flux Standard Action with error: true to report errors; other error patterns are ignored unless try/catch wrapping is enabled.
fix
Ensure actions conform to FSA pattern (error: true, payload: Error) or set third parameter to true to wrap all actions in try/catch.
affects: *
gotchaThe second parameter to rollbarMiddleware can be either an array of keypaths or a function; passing a non-array, non-function will cause unexpected behavior.
fix
Provide either an array of strings (keypaths) or a function (stateSanitizer) as the second argument.
affects: *
gotchaThe rollbar instance must be passed as the first argument; it is not imported internally.
fix
Remember to import and instantiate rollbar separately before passing it to rollbarMiddleware.
affects: *
Errors
Common errors & fixes
TypeError: rollbar is not a constructor
rollbar package may be imported incorrectly; rollbar v2+ uses default export.
fix
Use `import Rollbar from 'rollbar';` or `const Rollbar = require('rollbar').default;` for CommonJS.
Cannot read property 'apply' of undefined
The Rollbar instance passed to rollbarMiddleware is not properly configured or undefined.
fix
Ensure Rollbar is instantiated with an accessToken: `const Rollbar = new rollbar({ accessToken: '...' });`
Actions must be plain objects. Use custom middleware for async actions.
The middleware does not handle async actions like thunks; it expects plain FSA objects.
fix
Apply redux-thunk or other async middleware before this middleware in the chain.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
rollbarrequiredRequired peer dependency for the Rollbar client instance.
reduxrequiredRequired peer dependency for Redux middleware.
Agent activity
19 hits · last 30 days
node
14
OpenAI (training)
3
Resources
rollbar-redux-middleware — npm install rollbar-redux-middleware · libregistry