2016-08-12 80 views
1

有沒有辦法拿到店裏狀態/動作的出口編程的生產可能被導入回到開發工具?導出/登錄錯誤跟蹤服務

例如,我可以設置中間件來捕獲當前狀態並將它發送到像(Trackjs,Sentry,Rollbar)那樣的東西,但是它缺少所有以前的狀態和操作。

我想以與從Redux 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

你可以寫一個[自定義監視器(HTTPS:/ /github.com/gaearon/redux-devtools/issues/3)for redux-devtools。但不知道在生產中使用devtools是否是個好主意。 – Steffen

回答

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" 
    }] 

我創造了這個回購該演示這個動作https://github.com/timarney/redux-trackjs-logger它使用中間件時發生錯誤記錄的操作。

0

我維護一個名爲Raven for Redux的Redux中間件,它將Redux數據附加到Sentry錯誤報告。目前它爲每個錯誤報告添加了以下上下文:

  1. 完整的狀態對象。
  2. 完整的最後一個操作對象。
  3. type導致當前狀態的所有操作。這些被添加爲「麪包屑」。

哨兵博客有描述比較詳細書面記錄:https://blog.sentry.io/2016/08/24/redux-middleware-error-logging.html

你可以找到中間件作爲NPM包這裏:https://github.com/captbaritone/raven-for-redux