raven-for-redux
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -20,12 +20,13 @@ "use strict"; | ||
Raven.setDataCallback(function (data, original) { | ||
data.extra.lastAction = actionTransformer(data.extra.lastAction); | ||
data.extra.state = stateTransformer(data.extra.state); | ||
return original ? original(data) : data; | ||
}); | ||
return function (store) { | ||
var lastAction = void 0; | ||
// Record the initial state in case we crash before the first action | ||
// succeeds. | ||
// TODO: This does not currently work. | ||
Raven.setExtraContext({ state: store.getState() }); | ||
Raven.setDataCallback(function (data, original) { | ||
data.extra.lastAction = actionTransformer(lastAction); | ||
data.extra.state = stateTransformer(store.getState()); | ||
return original ? original(data) : data; | ||
}); | ||
return function (next) { | ||
@@ -41,4 +42,15 @@ return function (action) { | ||
lastAction = action; | ||
return next(action); | ||
// Set the action as context in case we crash in the reducer. | ||
var extra = { lastAction: action }; | ||
var returnValue = Raven.context({ extra: extra }, function () { | ||
return next(action); | ||
}); | ||
// Set the last action and state as context in case we crash before | ||
// the next action is dispatched. | ||
Raven.setExtraContext({ | ||
lastAction: action, | ||
state: store.getState() | ||
}); | ||
return returnValue; | ||
}; | ||
@@ -45,0 +57,0 @@ }; |
{ | ||
"name": "raven-for-redux", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Middleware for propagating Redux state/actions to Sentry via Raven.", | ||
@@ -12,3 +12,3 @@ "main": "built/index.js", | ||
"build": "babel index.js --out-dir built/", | ||
"prepublish": "npm run test && npm run build", | ||
"prepublishOnly": "npm run test && npm run build", | ||
"serve-example": "webpack-dev-server --watch --config=example/webpack.config.js" | ||
@@ -39,14 +39,20 @@ }, | ||
"devDependencies": { | ||
"babel-cli": "^6.22.2", | ||
"babel-jest": "^18.0.0", | ||
"babel-cli": "^6.24.1", | ||
"babel-core": "^6.24.1", | ||
"babel-jest": "^21.0.0", | ||
"babel-loader": "^7.0.0", | ||
"babel-preset-env": "^1.5.1", | ||
"babel-preset-es2015": "^6.22.0", | ||
"eslint": "^3.14.1", | ||
"babel-preset-react": "^6.24.1", | ||
"eslint": "^4.1.0", | ||
"eslint-config-hss": "^5.1.0", | ||
"eslint-config-prettier": "^1.0.2", | ||
"eslint-config-prettier": "^2.0.0", | ||
"eslint-plugin-prettier": "^2.0.1", | ||
"jest": "^18.1.0", | ||
"jest-cli": "^18.1.0", | ||
"prettier": "^1.1.0", | ||
"eslint-plugin-react": "^7.0.1", | ||
"jest": "^21.0.0", | ||
"prettier": "^1.7.3", | ||
"raven-js": "^3.12.1", | ||
"react": "^16.0.0", | ||
"redux": "^3.6.0", | ||
"webpack": "^3.0.0", | ||
"webpack-dev-server": "^2.4.1" | ||
@@ -64,2 +70,2 @@ }, | ||
} | ||
} | ||
} |
[![Travis](https://img.shields.io/travis/captbaritone/raven-for-redux.svg)]() [![Codecov](https://img.shields.io/codecov/c/github/captbaritone/raven-for-redux.svg)]() | ||
_Note:_ Raven 3.14.0 has a bug (https://github.com/getsentry/raven-js/issues/925) | ||
_Note:_ Requires Raven >= 3.9.0. Raven 3.14.0 has [a bug](https://github.com/getsentry/raven-js/issues/925) | ||
which this library triggers. | ||
@@ -55,2 +55,3 @@ | ||
exceptions. | ||
3. Allows filtering action breadcrumbs before sending to Sentry | ||
@@ -75,10 +76,13 @@ ## API: `createRavenMiddleware(Raven, [options])` | ||
Raven allows you to attach additional context information to each breadcrumb in | ||
the form of a `data` object. `breadcrubmDataFromAction` allows you to specify | ||
Raven allows you to attach additional context information to each breadcrumb | ||
in the form of a `data` object. `breadcrubmDataFromAction` allows you to specify | ||
a transform function which is passed the `action` object and returns a `data` | ||
object. | ||
object. Which will be logged to Sentry along with the breadcrumb. | ||
The default implementation of this function returns `undefined`, which means no | ||
data is attached. This is because there are __a few gotchas__: | ||
_Ideally_ we could log the entire content of each action. If we could, we | ||
could perfectly replay the user's entire session to see what went wrong. | ||
However, the default implementation of this function returns `undefined`, which means | ||
no data is attached. This is because there are __a few gotchas__: | ||
* 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. | ||
@@ -90,3 +94,3 @@ * Sentry limits the total size of your error report. If you send too much data, | ||
Be careful not to mutate your `action` within this function. | ||
Finally, be careful not to mutate your `action` within this function. | ||
@@ -131,4 +135,18 @@ See the Sentry [Breadcrumb documentation]. | ||
#### `filterBreadcrumbActions` _(Function)_ | ||
Default: `action => true` _(Function)_ | ||
If your app has certain actions that you do not want to send to Sentry, pass | ||
a filter function in this option. If the filter returns a truthy value, the | ||
action will be added as a breadcrumb, otherwise the action will be ignored. | ||
Note: even when the action has been filtered out, it may still be sent to | ||
Sentry as part of the extra data, if it was the last action before an error. | ||
## Changelog | ||
### 1.1.0 | ||
* Add `filterBreadcrumbActions` option. ([#39]) | ||
### 1.0.0 | ||
@@ -148,3 +166,3 @@ | ||
* `actionTransformeri` and `stateTransformer` are only run when reporting an error, rather than on every action. ([#8]) | ||
* `actionTransformer` and `stateTransformer` are only run when reporting an error, rather than on every action. ([#8]) | ||
@@ -160,1 +178,2 @@ | ||
[1def9a7]: https://github.com/captbaritone/raven-for-redux/commit/1def9a747d7b711ad93da531b8ff9d128c352b45 | ||
[#39]: https://github.com/captbaritone/raven-for-redux/pull/39 |
10436
51
174
19