@@ -8,16 +8,15 @@ function createRavenMiddleware(Raven, options = {}) {
88 stateTransformer = identity ,
99 breadcrumbCategory = "redux-action"
1010 } = options ;
11- Raven . setDataCallback ( ( data , original ) => {
12- data . extra . lastAction = actionTransformer ( data . extra . lastAction ) ;
13- data . extra . state = stateTransformer ( data . extra . state ) ;
14- return original ? original ( data ) : data ;
15- } ) ;
11+
1612 return store => {
17- // Record the initial state in case we crash before the first action
18- // succeeds.
19- // TODO: This does not currently work.
20- Raven . setExtraContext ( { state : store . getState ( ) } ) ;
13+ let lastAction ;
14+
15+ Raven . setDataCallback ( ( data , original ) => {
16+ data . extra . lastAction = actionTransformer ( lastAction ) ;
17+ data . extra . state = stateTransformer ( store . getState ( ) ) ;
18+ return original ? original ( data ) : data ;
19+ } ) ;
2120
2221 return next => action => {
2322 // Log the action taken to Raven so that we have narrative context in our
@@ -28,17 +27,8 @@ function createRavenMiddleware(Raven, options = {}) {
2827 data : breadcrumbDataFromAction ( action )
2928 } ) ;
3029
31- // Set the action as context in case we crash in the reducer.
32- const extra = { lastAction : action } ;
33- const returnValue = Raven . context ( { extra } , ( ) => next ( action ) ) ;
34-
35- // Set the last action and state as context in case we crash before
36- // the next action is dispatched.
37- Raven . setExtraContext ( {
38- lastAction : action ,
39- state : store . getState ( )
40- } ) ;
41- return returnValue ;
30+ lastAction = action ;
31+ return next ( action ) ;
4232 } ;
4333 } ;
4434}
0 commit comments