前端数据上报 堆栈信息收集

 

 

 

onError: function(e) {
let msg = e.toString();
// ReferenceError - JavaScript | MDN https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError
try {

msg += ' fileName ' + e.fileName;
msg += ' lineNumber ' + e.lineNumber;
msg += ' columnNumber ' + e.columnNumber;
try{
msg += ' stack ' + e.stack;
}catch(e){};

} catch(e){};
// Error.prototype - JavaScript | MDN https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Error/prototypeLL
let now = new Date();
let id_ = now.getTime() + Math.random();
let url = 'http://es.io/blackhole/test/' + id_;
let header = {};
header['Access-Control-Allow-Origin'] = '*'; // Access-Control-Allow-Credentials
return new Promise((resolve, reject) => {
uni.request({
url,
method: 'PUT',
dataType: 'json',
header,
data: { stack: msg, time: now },
success: res => {},
fail: err => {}
});
});
},

 

posted @ 2017-11-02 11:09  papering  阅读(202)  评论(0编辑  收藏  举报