{"id":13816132,"url":"https://github.com/vidit-sh/redux-sentry-middleware","last_synced_at":"2026-02-13T06:22:48.158Z","repository":{"id":33983376,"uuid":"151614107","full_name":"vidit-sh/redux-sentry-middleware","owner":"vidit-sh","description":"Redux middleware for propagating Redux state/actions to use with new @sentry/browser and @sentry/node.","archived":false,"fork":false,"pushed_at":"2023-01-06T01:36:10.000Z","size":366,"stargazers_count":79,"open_issues_count":15,"forks_count":16,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-11T09:03:04.184Z","etag":null,"topics":["raven","redux","redux-middleware","sentry"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vidit-sh.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-04T17:59:02.000Z","updated_at":"2022-10-05T07:54:54.000Z","dependencies_parsed_at":"2023-01-15T03:48:41.794Z","dependency_job_id":null,"html_url":"https://github.com/vidit-sh/redux-sentry-middleware","commit_stats":null,"previous_names":["viditisonline/redux-sentry-middleware"],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vidit-sh%2Fredux-sentry-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vidit-sh%2Fredux-sentry-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vidit-sh%2Fredux-sentry-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vidit-sh%2Fredux-sentry-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vidit-sh","download_url":"https://codeload.github.com/vidit-sh/redux-sentry-middleware/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244282969,"owners_count":20428103,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["raven","redux","redux-middleware","sentry"],"created_at":"2024-08-04T05:00:35.462Z","updated_at":"2026-02-13T06:22:43.137Z","avatar_url":"https://github.com/vidit-sh.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/vidit-sh/redux-sentry-middleware.svg?branch=master)](https://travis-ci.org/vidit-sh/redux-sentry-middleware)\n[![Latest Version](https://img.shields.io/npm/v/redux-sentry-middleware.svg)](https://www.npmjs.com/package/redux-sentry-middleware)\n[![Downloads per month](https://img.shields.io/npm/dm/redux-sentry-middleware.svg)](https://www.npmjs.com/package/redux-sentry-middleware)\n\n# Sentry Middleware for Redux\n\nLogs the type of each dispatched action to Sentry as \"breadcrumbs\" and attaches\nyour last action and current Redux state as additional context.\n\nIt's a rewrite of [raven-for-redux](https://github.com/captbaritone/raven-for-redux) but with new Sentry unified APIs.\n\n## Installation\n\n    npm install --save redux-sentry-middleware\n\n## Usage\n\n```JavaScript\n// store.js\n\nimport * as Sentry from \"@sentry/browser\"; \n// For usage with node \n// import * as Sentry from \"@sentry/node\";\n\nimport { createStore, applyMiddleware } from \"redux\";\nimport createSentryMiddleware from \"redux-sentry-middleware\";\n\nimport { reducer } from \"./my_reducer\";\n\nSentry.init({\n  dsn: '\u003cyour dsn\u003e'\n});\n\n\nexport default createStore(\n    reducer,\n    applyMiddleware(\n        // Middlewares, like `redux-thunk` that intercept or emit actions should\n        // precede `redux-sentry-middleware`.\n        createSentryMiddleware(Sentry, {\n            // Optionally pass some options here.\n        })\n    )\n);\n```\n\n## API: `createSentryMiddleware(Sentry, [options])`\n\n### Arguments\n\n* `Sentry` _(Sentry Object)_: A configured and \"installed\"\n  [Sentry] object.\n* [`options`] _(Object)_: See below for detailed documentation.\n\n### Options\n\nWhile the default configuration should work for most use cases, middleware can be configured by providing an options object with any of the following\noptional keys.\n\n#### `breadcrumbDataFromAction` _(Function)_\n\nDefault: `action =\u003e undefined`\n\nSentry allows you to attach additional context information to each breadcrumb\nin the form of a `data` object. `breadcrumbDataFromAction` allows you to specify\na transform function which is passed the `action` object and returns a `data`\nobject. Which will be logged to Sentry along with the breadcrumb.\n\n_Ideally_ we could log the entire content of each action. If we could, we\ncould perfectly replay the user's entire session to see what went wrong.\n\nHowever, the default implementation of this function returns `undefined`, which means\nno data is attached. This is because there are __a few gotchas__:\n\n* The data object must be \"flat\". In other words, each value of the object must be a string. The values may not be arrays or other objects.\n* Sentry limits the total size of your error report. If you send too much data,\n  the error will not be recorded. If you are going to attach data to your\n  breadcrumbs, be sure you understand the way it will affect the total size\n  of your report.\n\nFinally, be careful not to mutate your `action` within this function.\n\nSee the Sentry [Breadcrumb documentation].\n\n#### `actionTransformer` _(Function)_\n\nDefault: `action =\u003e action`\n\nIn some cases your actions may be extremely large, or contain sensitive data.\nIn those cases, you may want to transform your action before sending it to\nSentry. This function allows you to do so. It is passed the last dispatched\n`action` object, and should return a serializable value.\n\nBe careful not to mutate your `action` within this function.\n\nIf you have specified a [`beforeSend`] when you configured Sentry, note that\n`actionTransformer` will be applied _before_ your specified `beforeSend`.\n\n#### `stateTransformer` _(Function)_\n\nDefault: `state =\u003e state`\n\nIn some cases your state may be extremely large, or contain sensitive data.\nIn those cases, you may want to transform your state before sending it to\nSentry. This function allows you to do so. It is passed the current state\nobject, and should return a serializable value.\n\nBe careful not to mutate your `state` within this function.\n\nIf you have specified a [` beforeSend`] when you configured Raven, note that\n`stateTransformer` will be applied _before_ your specified `beforeSend`.\n\n#### `breadcrumbCategory` _(String)_\n\nDefault: `\"redux-action\"`\n\nEach breadcrumb is assigned a category. By default all action breadcrumbs are\ngiven the category `\"redux-action\"`. If you would prefer a different category\nname, specify it here.\n\n#### `filterBreadcrumbActions` _(Function)_\n\nDefault: `action =\u003e true`\n\nIf your app has certain actions that you do not want to send to Sentry, pass\na filter function in this option. If the filter returns a truthy value, the\naction will be added as a breadcrumb, otherwise the action will be ignored.\nNote: even when the action has been filtered out, it may still be sent to\nSentry as part of the extra data, if it was the last action before an error.\n\n#### `getUserContext` _(Optional Function)_\n\nSignature: `state =\u003e userContext`\n\nSentry allows you to associcate a [user context] with each error report.\n`getUserContext` allows you to define a mapping from your Redux `state` to\nthe user context. When `getUserContext` is specified, the result of\n`getUserContext` will be used to derive the user context before sending an\nerror report. Be careful not to mutate your `state` within this function.\n\nIf you have specified a [`beforeSend`] when you configured Raven, note that\n`getUserContext` will be applied _before_ your specified `beforeSend`.\nWhen a `getUserContext` function is given, it will override any previously\nset user context.\n\n#### `getTags` _(Optional Function)_\n\nSignature: `state =\u003e tags`\n\nSentry allows you to associate [tags] with each report.\n`getTags` allows you to define a mapping from your Redux `state` to\nan object of tags (key → value). Be careful not to mutate your `state`\nwithin this function.\n\n#### `breadcrumbMessageFromAction` _(Function)_\n\nDefault: `action =\u003e action.type`\n\n`breadcrumbMessageFromAction` allows you to specify a transform function which is passed the `action` object and returns a `string` that will be used as the message of the breadcrumb.\n\nBy default `breadcrumbMessageFromAction` returns `action.type`.\n\nFinally, be careful not to mutate your `action` within this function.\n\nSee the Sentry [Breadcrumb documentation](https://docs.sentry.io/enriching-error-data/breadcrumbs/?platform=javascript).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvidit-sh%2Fredux-sentry-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvidit-sh%2Fredux-sentry-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvidit-sh%2Fredux-sentry-middleware/lists"}