Commit 37b3e1ab by 程默

添加全局js异常监控上报

parent 163775df
<script>
// let mpAnalytics=require('../node_modules/mayi-analytics/dist/');
export default {
created () {
// NODE_ENV
let extConfig = wx.getExtConfigSync? wx.getExtConfigSync(): {}
if (process.env.NODE_ENV=="development") {
created() {
// NODE_ENV
let extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {};
if (process.env.NODE_ENV == "development") {
extConfig={mixid:'antgood'}
}
this.$store.commit("setExtConfig", extConfig.mixid);
// if (wx.getExtConfig) {
// wx.getExtConfig({
// success : (res) => {
// if(res.errMsg == 'getExtConfig: ok'){
// this.$store.commit("setExtConfig", res.extConfig.mixid);
// }
// }
// })
// }
// 调用API从本地缓存中获取数据
/*
* 平台 api 差异的处理方式: api 方法统一挂载到 mpvue 名称空间, 平台判断通过 mpvuePlatform 特征字符串
......@@ -27,24 +17,43 @@ export default {
* 支付宝(蚂蚁):mpvue === my, mpvuePlatform === 'my'
*/
let logs
if (mpvuePlatform === 'my') {
logs = mpvue.getStorageSync({key: 'logs'}).data || []
logs.unshift(Date.now())
let logs;
if (mpvuePlatform === "my") {
logs = mpvue.getStorageSync({ key: "logs" }).data || [];
logs.unshift(Date.now());
mpvue.setStorageSync({
key: 'logs',
key: "logs",
data: logs
})
});
} else {
logs = mpvue.getStorageSync('logs') || []
logs.unshift(Date.now())
mpvue.setStorageSync('logs', logs)
logs = mpvue.getStorageSync("logs") || [];
logs.unshift(Date.now());
mpvue.setStorageSync("logs", logs);
}
},
log () {
console.log(`log at:${Date.now()}`)
onError(err) {
console.log(err, "js异常捕获");
wx.request({
url: "https://analytics.mayi888.cn/ma.gif",
data: {
e: "mp_error",
logInfo: {
err
}
},
method: "GET",
success: function(res) {
console.log("上报成功", res);
},
fail: function(res) {
console.log("上报失败", res);
}
});
},
log() {
console.log(`log at:${Date.now()}`);
}
}
};
</script>
<style>
......@@ -66,5 +75,5 @@ export default {
}
@import url("../static/font/iconfont.css");
@import url('../static/css/common.scss');
@import url("../static/css/common.scss");
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment