{"id":18761,"library":"rollbar-redux-middleware","title":"rollbar-redux-middleware","description":"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.","status":"active","version":"0.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/rollbar/rollbar-redux-middleware","tags":["javascript","redux","rollbar","middleware","react"],"install":[{"cmd":"npm install rollbar-redux-middleware","lang":"bash","label":"npm"},{"cmd":"yarn add rollbar-redux-middleware","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollbar-redux-middleware","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required peer dependency for the Rollbar client instance.","package":"rollbar","optional":false},{"reason":"Required peer dependency for Redux middleware.","package":"redux","optional":false}],"imports":[{"note":"Default export is a function. CJS require works but ESM is preferred.","wrong":"const rollbarMiddleware = require('rollbar-redux-middleware');","symbol":"rollbarMiddleware","correct":"import rollbarMiddleware from 'rollbar-redux-middleware';"}],"quickstart":{"code":"import { createStore, applyMiddleware } from 'redux';\nimport rollbar from 'rollbar';\nimport rollbarMiddleware from 'rollbar-redux-middleware';\n\nconst Rollbar = new rollbar({ accessToken: process.env.ROLLBAR_ACCESS_TOKEN ?? '' });\n\nconst initialState = { user: { name: 'Alice' } };\nconst rootReducer = (state = initialState, action) => state;\n\nconst rollbarRedux = rollbarMiddleware(Rollbar, ['user.name']);\n\nconst store = createStore(\n  rootReducer,\n  initialState,\n  applyMiddleware(rollbarRedux)\n);\n\nstore.dispatch({ type: 'TEST' });\nconsole.log('Middleware configured. Errors will be reported to Rollbar.');","lang":"javascript","description":"Shows basic setup: importing rollbar and middleware, creating a Rollbar instance, and applying the middleware with state sanitization keypaths."},"warnings":[{"fix":"Ensure actions conform to FSA pattern (error: true, payload: Error) or set third parameter to true to wrap all actions in try/catch.","message":"Assumes action is a Flux Standard Action with error: true to report errors; other error patterns are ignored unless try/catch wrapping is enabled.","severity":"gotcha","affected_versions":"*"},{"fix":"Provide either an array of strings (keypaths) or a function (stateSanitizer) as the second argument.","message":"The second parameter to rollbarMiddleware can be either an array of keypaths or a function; passing a non-array, non-function will cause unexpected behavior.","severity":"gotcha","affected_versions":"*"},{"fix":"Remember to import and instantiate rollbar separately before passing it to rollbarMiddleware.","message":"The rollbar instance must be passed as the first argument; it is not imported internally.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use `import Rollbar from 'rollbar';` or `const Rollbar = require('rollbar').default;` for CommonJS.","cause":"rollbar package may be imported incorrectly; rollbar v2+ uses default export.","error":"TypeError: rollbar is not a constructor"},{"fix":"Ensure Rollbar is instantiated with an accessToken: `const Rollbar = new rollbar({ accessToken: '...' });`","cause":"The Rollbar instance passed to rollbarMiddleware is not properly configured or undefined.","error":"Cannot read property 'apply' of undefined"},{"fix":"Apply redux-thunk or other async middleware before this middleware in the chain.","cause":"The middleware does not handle async actions like thunks; it expects plain FSA objects.","error":"Actions must be plain objects. Use custom middleware for async actions."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}