1

Is there a way to get an export of the store state / actions programmatically in Production that could be imported back into dev tools?

For example I can setup middleware to capture the current state and send that to something like (Trackjs,Sentry, Rollbar) but that lacks all the previous state and actions.

I would like to capture in the same format as exporting from the Redux Dev Tools.

Sample export from Dev Tools

 {"monitorState":{},"actionsById":{"0":{"type":"PERFORM_ACTION","action":{"type":"@@INIT"},"timestamp":1471017239656},"1":{"type":"PERFORM_ACTION","action":{"type":"INCREMENT"},"timestamp":1471017242004}},"nextActionId":2,"stagedActionIds":[0,1],"skippedActionIds":[],"committedState":5,"currentStateIndex":1,"computedStates":[{"state":5},{"state":6}]}
Tim Arney
  • 1,776
  • 2
  • 18
  • 23
  • You could write a [Custom Monitor](https://github.com/gaearon/redux-devtools/issues/3) for redux-devtools. But not sure if it is a good idea to use devtools in production. – Steffen Aug 13 '16 at 20:55

2 Answers2

1

This is currently in development but you can now push action history right in the extension see https://github.com/zalmoxisus/remotedev-server/pull/20

Another option is to save the actions to a JSON file as an array and import them back in.

That's possible as of https://github.com/zalmoxisus/redux-devtools-extension/issues/173

logger.js

let actions = []
export function logActions (stateSanitizer) {
  return store => next => action => {
    actions.push(action)
    return next(action)
  }
}

These actions can be saved to a file or database and can be imported back into the dev tools.

Sample actions

[{
    "type": "INCREMENT"
  }, {
    "type": "DECREMENT"
  }, {
    "type": "DECREMENT"
  }, {
    "type": "DECREMENT"
  }, {
    "type": "DECREMENT"
  }]

I created this repo which demos this in action https://github.com/timarney/redux-trackjs-logger it uses middleware to log the actions when an error happens.

Tim Arney
  • 1,776
  • 2
  • 18
  • 23
0

I maintain a Redux middleware called Raven for Redux which attaches Redux data to Sentry error reports. Currently it adds the following context to each error report:

  1. The complete state object.
  2. The complete last action object.
  3. The type of all actions that lead up to the current state. These are added as "breadcrumbs".

The Sentry blog has a writeup describing it in more detail: https://blog.sentry.io/2016/08/24/redux-middleware-error-logging.html

You can find the middleware as an NPM package here: https://github.com/captbaritone/raven-for-redux

Jordan Eldredge
  • 1,587
  • 1
  • 19
  • 25