raven-for-redux
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -7,2 +7,5 @@ "use strict"; | ||
var getUndefined = function getUndefined() {}; | ||
var filter = function filter() { | ||
return true; | ||
}; | ||
function createRavenMiddleware(Raven) { | ||
@@ -19,15 +22,16 @@ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
_options$breadcrumbCa = options.breadcrumbCategory, | ||
breadcrumbCategory = _options$breadcrumbCa === undefined ? "redux-action" : _options$breadcrumbCa; | ||
breadcrumbCategory = _options$breadcrumbCa === undefined ? "redux-action" : _options$breadcrumbCa, | ||
_options$filterBreadc = options.filterBreadcrumbActions, | ||
filterBreadcrumbActions = _options$filterBreadc === undefined ? filter : _options$filterBreadc; | ||
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) { | ||
// Record the initial state in case we crash before the first action | ||
// succeeds. | ||
// TODO: This does not currently work. | ||
Raven.setExtraContext({ state: store.getState() }); | ||
var lastAction = void 0; | ||
Raven.setDataCallback(function (data, original) { | ||
data.extra.lastAction = actionTransformer(lastAction); | ||
data.extra.state = stateTransformer(store.getState()); | ||
return original ? original(data) : data; | ||
}); | ||
return function (next) { | ||
@@ -37,21 +41,12 @@ return function (action) { | ||
// error report. | ||
Raven.captureBreadcrumb({ | ||
category: breadcrumbCategory, | ||
message: action.type, | ||
data: breadcrumbDataFromAction(action) | ||
}); | ||
if (filterBreadcrumbActions(action)) { | ||
Raven.captureBreadcrumb({ | ||
category: breadcrumbCategory, | ||
message: action.type, | ||
data: breadcrumbDataFromAction(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; | ||
lastAction = action; | ||
return next(action); | ||
}; | ||
@@ -62,2 +57,2 @@ }; | ||
module.exports = createRavenMiddleware; | ||
module.exports = createRavenMiddleware; |
{ | ||
"name": "raven-for-redux", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Middleware for propagating Redux state/actions to Sentry via Raven.", | ||
@@ -40,3 +40,3 @@ "main": "built/index.js", | ||
"babel-core": "^6.24.1", | ||
"babel-jest": "^21.0.0", | ||
"babel-jest": "^21.2.0", | ||
"babel-loader": "^7.0.0", | ||
@@ -51,4 +51,4 @@ "babel-preset-env": "^1.5.1", | ||
"eslint-plugin-react": "^7.0.1", | ||
"jest": "^21.0.0", | ||
"prettier": "^1.7.3", | ||
"jest": "^21.2.1", | ||
"prettier": "^1.7.4", | ||
"raven-js": "^3.12.1", | ||
@@ -55,0 +55,0 @@ "react": "^16.0.0", |
@@ -144,3 +144,3 @@ [![Travis](https://img.shields.io/travis/captbaritone/raven-for-redux.svg)]() [![Codecov](https://img.shields.io/codecov/c/github/captbaritone/raven-for-redux.svg)]() | ||
### 1.1.0 | ||
### 1.1.1 | ||
@@ -147,0 +147,0 @@ * Add `filterBreadcrumbActions` option. ([#39]) |
10135
46