Commit bb06a062d8a3688ab412ffdcd77e511afc3aea76

Authored by wangfan
1 parent 71f63ad0

rollbar

Showing 2 changed files with 47 additions and 40 deletions
... ... @@ -9,40 +9,7 @@ const api_timeout = 2000; //接口超时时间,默认2s
import api from './api.url'
import uri_dc from './uri'
const server_host = uri_dc.HOST__LINE;
/**
* @param data
* @param status started, succeeded (default), failed, or timed_out
*/
function rollbar(data) {
// let raw=JSON.stringify(data)
// let trace={
// frames:[data],
// exception:{class:raw},
// }
let param={
access_token: '83bd2afd09b8402b943cb1894a84ec51',
data:{
body:{
//trace:trace,
// trace_chain:[trace],
message:{
body:data,
},
// crash_report:{
// raw:raw
// },
},
}
}
wx.request({
url: 'https://api.rollbar.com/api/1/item/',
method: 'POST',
data: param,
header: {
//'content-type': 'application/x-www-form-urlencoded'
},
})
}
import rollbar from './rollbar'
/**
*
* @param act
... ... @@ -122,11 +89,7 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr
cache(cache_key, res.data, cachetime);//.then().catch();
}
if (res.data.ret !== 200) {
try {
res.data.msg = res.data.msg.replace('非法请求:', '');
} catch (e) {
console.log('res-fail', res, e);
}
res.data.msg = res.data.msg.replace('非法请求:', '');
}
}
success(res.data);
... ... @@ -137,7 +100,8 @@ function rpc(host = '', act, data = {}, fouce = false, header = {}, silence = tr
formids: formids.toString(),
operator: operator,
post_data:cache_key,
response:res
response:res,
catch:JSON.stringify(e),
})
}
... ...
/**
* @param data
* @param status started, succeeded (default), failed, or timed_out
*/
function rollbar(data,title='') {
let pages=getCurrentPages();
let p=pages[pages.length-1];
let body_msg=p.route+'?'+JSON.stringify(p.options);
title=title?title:data.response
let param={
access_token: '83bd2afd09b8402b943cb1894a84ec51',
data:{
body:{
message:{
body:title,
route: body_msg,
},
"request": {
"method": "POST",
"headers": {
// Header names should be formatted like they are in HTTP.
openid: data.openid,
formids: data.formids,
operator: data.operator,
},
"body": data.post_data,
},
exception:data.exception,
context:data.response,
title: title,
},
}
}
wx.request({
url: 'https://api.rollbar.com/api/1/item/',
method: 'POST',
data: param,
header: {
//'content-type': 'application/x-www-form-urlencoded'
},
})
}
export default rollbar;
\ No newline at end of file
... ...