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-middlewareVerified import paths — ran on the pinned version, not inferred.
Shows basic setup: importing rollbar and middleware, creating a Rollbar instance, and applying the middleware with state sanitization keypaths.
Ensure actions conform to FSA pattern (error: true, payload: Error) or set third parameter to true to wrap all actions in try/catch.
Provide either an array of strings (keypaths) or a function (stateSanitizer) as the second argument.
Remember to import and instantiate rollbar separately before passing it to rollbarMiddleware.
Use `import Rollbar from 'rollbar';` or `const Rollbar = require('rollbar').default;` for CommonJS.Ensure Rollbar is instantiated with an accessToken: `const Rollbar = new rollbar({ accessToken: '...' });`Apply redux-thunk or other async middleware before this middleware in the chain.