Authored by 周少峰

error report

... ... @@ -228,6 +228,11 @@ if (isProduction) {
return 1000 * 60 * 60 * 0.5;
}
return Math.min(options.attempt * 100, 1000);
},
report: {
host: 'influxdblog.web.yohoops.org',
port: 8086,
db: 'web-apm'
}
}
});
... ...
... ... @@ -49,8 +49,9 @@ exports.serverError = () => {
return (err, req, res, next) => {
forceNoCache(res);
let uid = req.user.uid || 0;
let udid = req.user.udid || 0;
const uid = req.user ? req.user.uid : 0;
const udid = req.query.udid || req.cookies ? req.cookies._yasvd : 0;
if (req.isApmReport) {
// 上报服务端错误
sender.addMessage({
... ...
... ... @@ -20,6 +20,14 @@
<link rel="dns-prefetch" href="{{this}}">
{{/dnsPrefetch.hosts}}
<script>
window._timeStart = Date.now();
{{#ifand isProduction pc.open.bughd}}
!function(r){function e(i){if(t[i])return t[i].exports;var n=t[i]={exports:{},id:i,loaded:!1};return r[i].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var t={};e.m=r,e.c=t,e.p="",e(0)}([function(r,e,t){var i=t(1),n=t(2),o="_errLog",s={writeError:function(r,e,t,s,p){var c=JSON.parse(i(o)||"[]");c.push({tp:"err",msg:r,sc:e,ln:t,cn:s,pt:location.href,u:n.getUid(),ud:n.getUdid(),rid:n.getReqId(),st:JSON.stringify(p&&p.stack)}),i(o,JSON.stringify(c)),c.length>=5&&this.reportError()},clearError:function(){i(o,"[]")},reportError:function(){var r=this,e=JSON.parse(i(o)||"[]"),t=n.stringify(e);n.report(t,function(){r.clearError()})},init:function(){window.onerror=this.writeError.bind(this),this.reportError()}};s.init(),r.exports=s},function(r,e){r.exports=function(r,e,t){if(void 0===e){var i=null;if(document.cookie)for(var n=document.cookie.split(";"),o=0;o<n.length;o++){var s=(n[o]||"").trim();if(s.substring(0,r.length+1)==r+"="){i=decodeURIComponent(s.substring(r.length+1));break}}return i}t=t||{},null===e&&(e="",t.expires=-1);var p="";if(t.expires&&("number"==typeof t.expires||t.expires.toUTCString)){var c;"number"==typeof t.expires?(c=new Date,c.setTime(c.getTime()+24*t.expires*60*60*1e3)):c=t.expires,p="; expires="+c.toUTCString()}var u=t.path?"; path="+t.path:"",a=t.domain?"; domain="+t.domain:"",f=t.secure?"; secure":"";document.cookie=[r,"=",encodeURIComponent(e),p,u,a,f].join("")}},function(r,e,t){var i=t(1),n={config:{reportUrl:"//badjs.yoho.cn/apm/yas.gif"},stringify:function(r){for(var e=[],t=0;t<r.length;t++){var i=r[t],n=[];for(var o in i)i.hasOwnProperty(o)&&n.push(o+"::"+i[o]);e.push(n.join("$$"))}return e.join("**")},report:function(r,e){if(r){(new Image).src=this.config.reportUrl+"?l="+r+"&t="+(new Date).getTime(),e&&e()}},getUdid:function(){return(i("yohobuy_session")||"").slice(2).split(".")[0]||0},getUid:function(){return(i("_UID")||"").split("::")[1]||0},getReqId:function(){return i("docreqid")||0}};r.exports=n}]);
{{/ifand}}
</script>
{{#if devEnv}}
<link rel="stylesheet" href="//{{devHost}}:5002/base.css">
<link rel="stylesheet" href="//{{devHost}}:5002/{{#if cssModule}}{{cssModule}}.css{{^}}{{module}}.css{{/if}}">
... ... @@ -40,14 +48,6 @@
{{/if}}
{{> footer}}
<script>
window._timeStart = Date.now();
{{#ifand isProduction pc.open.bughd}}
!function(r){function e(i){if(t[i])return t[i].exports;var n=t[i]={exports:{},id:i,loaded:!1};return r[i].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var t={};e.m=r,e.c=t,e.p="",e(0)}([function(r,e,t){var i=t(1),n=t(2),o="_errLog",s={writeError:function(r,e,t,s,p){var c=JSON.parse(i(o)||"[]");c.push({tp:"err",msg:r,sc:e,ln:t,cn:s,pt:location.href,u:n.getUid(),ud:n.getUdid(),rid:n.getReqId(),st:JSON.stringify(p&&p.stack)}),i(o,JSON.stringify(c)),c.length>=5&&this.reportError()},clearError:function(){i(o,"[]")},reportError:function(){var r=this,e=JSON.parse(i(o)||"[]"),t=n.stringify(e);n.report(t,function(){r.clearError()})},init:function(){window.onerror=this.writeError.bind(this),this.reportError()}};s.init(),r.exports=s},function(r,e){r.exports=function(r,e,t){if(void 0===e){var i=null;if(document.cookie)for(var n=document.cookie.split(";"),o=0;o<n.length;o++){var s=(n[o]||"").trim();if(s.substring(0,r.length+1)==r+"="){i=decodeURIComponent(s.substring(r.length+1));break}}return i}t=t||{},null===e&&(e="",t.expires=-1);var p="";if(t.expires&&("number"==typeof t.expires||t.expires.toUTCString)){var c;"number"==typeof t.expires?(c=new Date,c.setTime(c.getTime()+24*t.expires*60*60*1e3)):c=t.expires,p="; expires="+c.toUTCString()}var u=t.path?"; path="+t.path:"",a=t.domain?"; domain="+t.domain:"",f=t.secure?"; secure":"";document.cookie=[r,"=",encodeURIComponent(e),p,u,a,f].join("")}},function(r,e,t){var i=t(1),n={config:{reportUrl:"//badjs.yoho.cn/apm/yas.gif"},stringify:function(r){for(var e=[],t=0;t<r.length;t++){var i=r[t],n=[];for(var o in i)i.hasOwnProperty(o)&&n.push(o+"::"+i[o]);e.push(n.join("$$"))}return e.join("**")},report:function(r,e){if(r){(new Image).src=this.config.reportUrl+"?l="+r+"&t="+(new Date).getTime(),e&&e()}},getUdid:function(){return(i("yohobuy_session")||"").slice(2).split(".")[0]||0},getUid:function(){return(i("_UID")||"").split("::")[1]||0},getReqId:function(){return i("docreqid")||0}};r.exports=n}]);
{{/ifand}}
</script>
{{#if devEnv}}
<script src="//{{devHost}}:5002/libs.js"></script>
<script src="//{{devHost}}:5002/{{module}}.{{page}}.js"></script>
... ...
... ... @@ -55,7 +55,7 @@
"urlencode": "^1.1.0",
"uuid": "^2.0.2",
"yoho-express-session": "^2.0.0",
"yoho-node-lib": "=0.4.7",
"yoho-node-lib": "=0.5.2",
"yoho-zookeeper": "^1.0.8"
},
"devDependencies": {
... ...
... ... @@ -99,6 +99,7 @@ module.exports = (env) => {
path: path.join(__dirname, 'bundle'), // absolute path
filename: '[name].js'
},
devtool: 'hidden-source-map',
module: {
rules: [{
test: /\.vue$/,
... ...
... ... @@ -10,7 +10,7 @@ let baseConfig = require('./webpack.base.config.js');
baseConfig = baseConfig('dev');
_.mergeWith(baseConfig, {
devtool: '#inline-source-map',
devtool: '#cheap-module-source-map',
output: {
publicPath: devInfo.publicPath
},
... ...
... ... @@ -43,7 +43,8 @@ _.mergeWith(baseConfig, {
mangle: {
screw_ie8: false
},
comments: false
comments: false,
sourceMap: true
})
]
}, function customizer(objValue, srcValue) {
... ...