标签:uuid text ice ... yar context 修改 设备 from
// 需要安装的库
yarn add raven-js --save
yarn add raven-for-redux --save
// 在创建store的地方
import * as Raven from "raven-js";
import * as createRavenMiddleware from "raven-for-redux";
Raven.config("dns", {
release: `${版本号}`
}).install();
// 捕获saga抛出的异常
const onError = (error: Error) => {
Raven.captureException(error);
}
// 修改saga的middleware
const sagaMiddleware = createSagaMiddleware({
onError
});
const composedEnhancers = compose(
applyMiddleware(
...
createRavenMiddleware(Raven, {
getUserContext(state){
// 设置用户信息,用于上报识别
let userContext = [
"device_id": localStorage.getItem("device_id")
];
if(localStorage.getItem("uid")){
userContext["uid"] = localStorage.getItem("uid");
userContext["key"] = localStorage.getItem("key");
userContext["time"] = localStorage.getItem("time");
}
}
})
)
);
// 打开页面时,需要设置设备标识
localStorage.setItem("device_id", uuid);
// 在用户登录后,需要记录uid key time
localStorage.setItem("uid", uid);
localStorage.setItem("key", key);
localStorage.setItem("time", time);
标签:uuid text ice ... yar context 修改 设备 from
原文地址:https://www.cnblogs.com/unreal-feather/p/10324813.html