Middleware for propagating Redux state/actions to Sentry via Raven.
npm install raven-for-redux _Note:_ Requires Raven >= 3.9.0. Raven 3.14.0 has a bug
which this library triggers.
Logs the type of each dispatched action to Raven as "breadcrumbs" and attaches
your last action and current Redux state as additional context.
Inspired by [redux-raven-middleware] but with a slightly different approach.
npm install --save raven-for-redux
``JavaScript
// store.js
import Raven from "raven-js"; // Or, you might already have this as window.Raven.
import { createStore, applyMiddleware } from "redux";
import createRavenMiddleware from "raven-for-redux";
import { reducer } from "./my_reducer";
Raven.config("
export default createStore(
reducer,
applyMiddleware(
// Middlewares, like redux-thunk that intercept or emit actions shouldraven-for-redux
// precede .`
createRavenMiddleware(Raven, {
// Optionally pass some options here.
})
)
);
For a working example, see the example directory.
has TypeScript bindings available through DefinitelyTyped. Please note the import style below, as it differs from the JavaScript example and is required for these typings.
`TypeScript
import * as Raven from "raven-js";
import * as createRavenMiddleware from "raven-for-redux";
import { applyMiddleware, createStore } from "redux";//... (same as JavaScript example, but now with proper typings)
`Improvements
This library makes, what I think are, a few improvements over
redux-raven-middlware:1. Raven is injected rather than being setup inside the middleware. This allows
for more advanced configuration of Raven, as well as cases where Raven has
already been initialized. For example, if you include Raven as its own