{"library":"redux-raven-middleware","title":"Redux Sentry Middleware (Legacy)","description":"Redux middleware for sending error reports to Sentry through raven-js. This package, currently at version 1.2.0, was last published in January 2017, making it effectively abandoned. It automatically intercepts JavaScript errors that occur during action dispatch, capturing the error, the action that caused it, and the entire Redux application state for detailed crash reports. A key differentiating feature at the time was its deep integration with Redux state for context. However, its core dependency, `raven-js`, was officially deprecated by Sentry in Q2 2020 in favor of the modern `@sentry/browser` SDK. This means while the middleware itself may technically still function with older Sentry setups, it relies on a legacy library that no longer receives updates and lacks many features of the current Sentry ecosystem. Users should consider migrating to `redux-sentry-middleware` or a custom solution built with `@sentry/browser` for modern Sentry integration.","language":"javascript","status":"abandoned","last_verified":"Thu Apr 23","install":{"commands":["npm install redux-raven-middleware"],"cli":null},"imports":["import RavenMiddleware from 'redux-raven-middleware';","import { applyMiddleware } from 'redux';","import { createStore } from 'redux';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { applyMiddleware, createStore } from 'redux';\nimport RavenMiddleware from 'redux-raven-middleware';\n\n// A dummy reducer for demonstration purposes\nconst initialState = { count: 0 };\nfunction rootReducer(state = initialState, action) {\n  switch (action.type) {\n    case 'INCREMENT':\n      // Intentionally cause an error for testing Sentry integration\n      if (action.fail) {\n        throw new Error('Simulated Redux error!');\n      }\n      return { ...state, count: state.count + 1 };\n    default:\n      return state;\n  }\n}\n\n// Replace 'YOUR_SENTRY_DSN' with your actual DSN, ideally from environment variables\nconst SENTRY_DSN = process.env.SENTRY_DSN ?? 'https://examplePublicKey@o0.ingest.sentry.io/0';\n\nconst createStoreWithMiddleware = applyMiddleware(\n  RavenMiddleware(SENTRY_DSN, {\n    // Optional Sentry configuration\n    environment: process.env.NODE_ENV || 'development',\n  }, {\n    // Optional middleware configuration\n    actionTransformer: action => {\n      // Prevent sensitive data from being sent to Sentry\n      if (action.type === 'LOGIN' && action.payload && action.payload.password) {\n        return { ...action, payload: { ...action.payload, password: '[REDACTED]' } };\n      }\n      return action;\n    },\n    stateTransformer: state => {\n      // Limit the size of the state sent to Sentry to avoid 'Request too large' errors\n      return { sensitiveData: '[REDACTED]', count: state.count };\n    },\n    logger: console.warn // Use console.warn instead of console.error for internal logs\n  })\n)(createStore);\n\nconst store = createStoreWithMiddleware(rootReducer);\n\nconsole.log('Initial state:', store.getState());\nstore.dispatch({ type: 'INCREMENT' });\nconsole.log('State after increment:', store.getState());\n\ntry {\n  store.dispatch({ type: 'INCREMENT', fail: true });\n} catch (e) {\n  console.error('Caught expected error from Redux dispatch:', e.message);\n  // Sentry would have captured this error via the middleware\n}\n\n// To run this, ensure 'raven-js' is installed: npm install raven-js\n// Set SENTRY_DSN environment variable or replace placeholder.\n","lang":"javascript","description":"Demonstrates setting up `redux-raven-middleware` with `applyMiddleware`, including options for transforming actions and state, and intentionally triggering an error to show Sentry integration.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}