@@ -8,16 +8,15 @@ function createRavenMiddleware(Raven, options = {}) {
8
8
stateTransformer = identity ,
9
9
breadcrumbCategory = "redux-action"
10
10
} = 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
+
16
12
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
+ } ) ;
21
20
22
21
return next => action => {
23
22
// Log the action taken to Raven so that we have narrative context in our
@@ -28,17 +27,8 @@ function createRavenMiddleware(Raven, options = {}) {
28
27
data : breadcrumbDataFromAction ( action )
29
28
} ) ;
30
29
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 ) ;
42
32
} ;
43
33
} ;
44
34
}
0 commit comments