有没有办法让生产中的商店状态/操作以编程方式导出导回到开发工具中?
例如,我可以设置中间件来捕获当前状态并将其发送到类似(Trackjs,Sentry,Rollbar)但缺少所有先前的状态和操作。
我想捕获的格式与从Redux Dev Tools导出的格式相同。
从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}]}
答案 0 :(得分:1)
目前正在开发中,但您现在可以在扩展程序中直接推送操作历史记录,请参阅https://github.com/zalmoxisus/remotedev-server/pull/20
另一种选择是将操作保存为JSON文件作为数组并将其重新导入。
从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)
}
}
这些操作可以保存到文件或数据库中,并可以导回到开发工具中。
示例动作
[{
"type": "INCREMENT"
}, {
"type": "DECREMENT"
}, {
"type": "DECREMENT"
}, {
"type": "DECREMENT"
}, {
"type": "DECREMENT"
}]
我创建了这个repo,它在行动https://github.com/timarney/redux-trackjs-logger中演示它,它使用中间件来记录错误发生时的动作。
答案 1 :(得分:0)
我维护一个名为Raven for Redux的Redux中间件,它将Redux数据附加到Sentry错误报告中。目前,它为每个错误报告添加了以下上下文:
type
。这些被添加为"面包屑"。Sentry博客有一篇详细描述它的文章:https://blog.sentry.io/2016/08/24/redux-middleware-error-logging.html
您可以在此处找到中间件作为NPM包:https://github.com/captbaritone/raven-for-redux