Merge branch 'feature/web-apm' into 'master'
Feature/web apm See merge request !977
Showing
11 changed files
with
58 additions
and
33 deletions
@@ -485,7 +485,7 @@ module.exports = class extends global.yoho.BaseModel { | @@ -485,7 +485,7 @@ module.exports = class extends global.yoho.BaseModel { | ||
485 | }); | 485 | }); |
486 | } | 486 | } |
487 | 487 | ||
488 | - return this.post({ | 488 | + return this.get({ |
489 | data: apiParams, | 489 | data: apiParams, |
490 | api: global.yoho.API | 490 | api: global.yoho.API |
491 | }); | 491 | }); |
@@ -11,8 +11,8 @@ const isProduction = process.env.NODE_ENV === 'production'; | @@ -11,8 +11,8 @@ const isProduction = process.env.NODE_ENV === 'production'; | ||
11 | const isTest = process.env.NODE_ENV === 'test'; | 11 | const isTest = process.env.NODE_ENV === 'test'; |
12 | 12 | ||
13 | const domains = { | 13 | const domains = { |
14 | - api: 'http://api-test3.yohops.com:9999/', | ||
15 | - service: 'http://api-test3.yohops.com:9999/', | 14 | + api: 'http://api.yoho.cn/', |
15 | + service: 'http://service.yoho.cn/', | ||
16 | liveApi: 'http://testapi.live.yohops.com:9999/', | 16 | liveApi: 'http://testapi.live.yohops.com:9999/', |
17 | singleApi: 'http://api-test3.yohops.com:9999/', | 17 | singleApi: 'http://api-test3.yohops.com:9999/', |
18 | imSocket: 'ws://socket.yohobuy.com:10240', | 18 | imSocket: 'ws://socket.yohobuy.com:10240', |
@@ -30,6 +30,11 @@ module.exports = { | @@ -30,6 +30,11 @@ module.exports = { | ||
30 | assetUrl: '//127.0.0.1:5001', | 30 | assetUrl: '//127.0.0.1:5001', |
31 | testCode: 'yoho4946abcdef#$%&!@', | 31 | testCode: 'yoho4946abcdef#$%&!@', |
32 | domains: domains, | 32 | domains: domains, |
33 | + report: { | ||
34 | + host: '10.66.0.139', | ||
35 | + port: 8086, | ||
36 | + db: 'web-apm' | ||
37 | + }, | ||
33 | subDomains: { | 38 | subDomains: { |
34 | host: '.m.yohobuy.com', | 39 | host: '.m.yohobuy.com', |
35 | default: '//m.yohobuy.com', | 40 | default: '//m.yohobuy.com', |
@@ -194,6 +199,11 @@ if (isProduction) { | @@ -194,6 +199,11 @@ if (isProduction) { | ||
194 | } | 199 | } |
195 | return Math.min(options.attempt * 100, 1000); | 200 | return Math.min(options.attempt * 100, 1000); |
196 | } | 201 | } |
202 | + }, | ||
203 | + report: { | ||
204 | + host: 'influxdblog.web.yohoops.org', | ||
205 | + port: 8086, | ||
206 | + db: 'web-apm' | ||
197 | } | 207 | } |
198 | }); | 208 | }); |
199 | } else if (isTest) { | 209 | } else if (isTest) { |
@@ -5,6 +5,8 @@ | @@ -5,6 +5,8 @@ | ||
5 | const headerModel = require('../models/header'); | 5 | const headerModel = require('../models/header'); |
6 | const logger = global.yoho.logger; | 6 | const logger = global.yoho.logger; |
7 | const helpers = global.yoho.helpers; | 7 | const helpers = global.yoho.helpers; |
8 | +const sender = global.yoho.apmSender; | ||
9 | +const hostname = require('os').hostname(); | ||
8 | 10 | ||
9 | const forceNoCache = (res) => { | 11 | const forceNoCache = (res) => { |
10 | if (res && !res.finished) { | 12 | if (res && !res.finished) { |
@@ -49,6 +51,29 @@ exports.notFound = () => { | @@ -49,6 +51,29 @@ exports.notFound = () => { | ||
49 | exports.serverError = () => { | 51 | exports.serverError = () => { |
50 | return (err, req, res, next) => { | 52 | return (err, req, res, next) => { |
51 | forceNoCache(res); | 53 | forceNoCache(res); |
54 | + const uid = req.user ? req.user.uid : 0; | ||
55 | + const udid = req.query.udid || req.cookies ? req.cookies._yasvd : 0; | ||
56 | + | ||
57 | + if (req.isApmReport) { | ||
58 | + // 上报服务端错误 | ||
59 | + sender.addMessage({ | ||
60 | + measurement: 'error-report', | ||
61 | + tags: { | ||
62 | + app: global.yoho.config.appName, // 应用名称 | ||
63 | + hostname, | ||
64 | + type: 'server', | ||
65 | + route: `[${req.method}]${req.route.path}`, // 请求路由 | ||
66 | + reqID: req.reqID, | ||
67 | + uid, | ||
68 | + udid, | ||
69 | + code: err.code || 500 | ||
70 | + }, | ||
71 | + fields: { | ||
72 | + message: err.message, | ||
73 | + stack: err.stack | ||
74 | + } | ||
75 | + }); | ||
76 | + } | ||
52 | 77 | ||
53 | if (err && err.code === 401) { | 78 | if (err && err.code === 401) { |
54 | logger.warn(`401 warn info:client_type=${req.query.client_type},req.user=${JSON.stringify(req.user)},req.query=${JSON.stringify(req.query)},cookies=${JSON.stringify(req.cookies)}`); // eslint-disable-line | 79 | logger.warn(`401 warn info:client_type=${req.query.client_type},req.user=${JSON.stringify(req.user)},req.query=${JSON.stringify(req.query)},cookies=${JSON.stringify(req.cookies)}`); // eslint-disable-line |
@@ -10,7 +10,8 @@ const captchaPolicy = require('./policies/captcha'); | @@ -10,7 +10,8 @@ const captchaPolicy = require('./policies/captcha'); | ||
10 | const IP_WHITE_LIST = [ | 10 | const IP_WHITE_LIST = [ |
11 | '106.38.38.146', | 11 | '106.38.38.146', |
12 | '218.94.75.58', | 12 | '218.94.75.58', |
13 | - '218.94.75.50' | 13 | + '218.94.75.50', |
14 | + '218.94.77.166' | ||
14 | ]; | 15 | ]; |
15 | 16 | ||
16 | const limiter = (rule, policy, context) => { | 17 | const limiter = (rule, policy, context) => { |
@@ -22,6 +22,15 @@ | @@ -22,6 +22,15 @@ | ||
22 | <link rel="dns-prefetch" href="{{this}}"> | 22 | <link rel="dns-prefetch" href="{{this}}"> |
23 | {{/dnsPrefetch.hosts}} | 23 | {{/dnsPrefetch.hosts}} |
24 | 24 | ||
25 | + <script> | ||
26 | + window._timeStart = new Date().getTime(); | ||
27 | + window._yohoAppName = 'yohobuywap-node'; | ||
28 | + | ||
29 | + {{#ifand isProduction wap.open.bughd}} | ||
30 | + !function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")});var n=r(13),i=r(14);n.init(),i.init()},function(e,t){e.exports=function(e,t,r){if("undefined"==typeof t){var n=null;if(document.cookie)for(var i=document.cookie.split(";"),o=0;o<i.length;o++){var a=(i[o]||"").trim();if(a.substring(0,e.length+1)==e+"="){n=decodeURIComponent(a.substring(e.length+1));break}}return n}r=r||{},null===t&&(t="",r.expires=-1);var d="";if(r.expires&&("number"==typeof r.expires||r.expires.toUTCString)){var s;"number"==typeof r.expires?(s=new Date,s.setTime(s.getTime()+24*r.expires*60*60*1e3)):s=r.expires,d="; expires="+s.toUTCString()}var u=r.path?"; path="+r.path:"",p=r.domain?"; domain="+r.domain:"",c=r.secure?"; secure":"";document.cookie=[e,"=",encodeURIComponent(t),d,u,p,c].join("")}},,function(e,t,r){var n=r(1),i=window._yohoAppName||"unknown",o={config:{reportUrl:"//badjs.yoho.cn/apm/yas.gif"},stringify:function(e){for(var t=[],r=0;r<e.length;r++){var n=e[r],i=[];for(var o in n)n.hasOwnProperty(o)&&i.push(o+"::"+n[o]);t.push(i.join("$$"))}return t.join("**")},report:function(e,t){if(e){var r=new Image;r.src=this.config.reportUrl+"?s="+i+"&l="+e+"&t="+(new Date).getTime(),t&&t()}},getUdid:function(){var e=(n("yohobuy_session")||"").slice(2).split(".")[0];return e||0},getUid:function(){var e=(n("_UID")||"").split("::")[1];return e||0},getReqId:function(){return n("docreqid")||0}};e.exports=o},,,,,,,,,,function(e,t,r){var n=r(1),i=r(3),o="_errLog",a={writeError:function(e,t,r,a,d){var s=JSON.parse(n(o)||"[]");s.push({tp:"err",msg:e,sc:t,ln:r,cn:a,pt:location.href,u:i.getUid(),ud:i.getUdid(),rid:i.getReqId(),st:JSON.stringify(d&&d.stack)}),n(o,JSON.stringify(s)),s.length>=5&&this.reportError()},clearError:function(){n(o,"[]")},reportError:function(){var e=this,t=JSON.parse(n(o)||"[]"),r=i.stringify(t);i.report(r,function(){e.clearError()})},init:function(){var e=this;window.onerror=function(t,r,n,i,o){e.writeError(t,r,n,i,o)},this.reportError()}};e.exports=a},function(e,t,r){function n(e){var t=e.offsetTop;return null!==e.offsetParent&&(t+=n(e.offsetParent)),t}var i=r(3),o=window.screen.height,a=[],d=!1,s=!1,u=0,p=setInterval(function(){var e,t;if(d){if(a.length)for(e=0;e<a.length;e++){if(t=a[e],!t.complete){s=!1;break}s=!0}else s=!0;s&&(u=(new Date).getTime()-_timeStart,clearInterval(p))}else{var r=document.body.querySelector("img")||[];for(e=0;e<r.length;e++){t=r[e];var i=n(t);if(i>o){d=!0;break}i<=o&&!t.hasPushed&&(t.hasPushed=1,a.push(t))}}},0),c={reportTime:function(e){var t=i.stringify(e);i.report(t)},addEvent:function(){var e=this,t=[],r=location.href,n=i.getUid(),o=i.getUdid(),a=i.getReqId(),c=window.performance&&window.performance.timing.navigationStart||0;_timeStart=window._timeStart||0,document.addEventListener&&document.addEventListener("DOMContentLoaded",function(e){t.push({tp:"dcl",t:(new Date).getTime()-_timeStart,pt:r,u:n,ud:o,rid:a});var i=document.body.querySelector("img")||[];i.length||(d=!0)},!1),window.addEventListener&&window.addEventListener("load",function(i){t.push({tp:"ld",t:(new Date).getTime()-_timeStart,pt:r,u:n,ud:o,rid:a}),s=!0,d=!0,p&&clearInterval(p),u&&t.push({tp:"fs",t:u,pt:r,u:n,ud:o,rid:a}),t.push({tp:"pf",dcl:(window.performance&&window.performance.timing.domComplete||0)-c,ld:(window.performance&&window.performance.timing.loadEventStart||0)-c,pt:r,u:n,ud:o,rid:a}),e.reportTime(t)},!1)},init:function(){this.addEvent()}};e.exports=c}]); | ||
31 | + {{/ifand}} | ||
32 | + </script> | ||
33 | + | ||
25 | {{!-- Android机器页面不再受到用户字体缩放强制改变大小 'http://m.blog.csdn.net/article/details?id=51275080' --}} | 34 | {{!-- Android机器页面不再受到用户字体缩放强制改变大小 'http://m.blog.csdn.net/article/details?id=51275080' --}} |
26 | <script type="text/javascript"> | 35 | <script type="text/javascript"> |
27 | var isWechat = /micromessenger/i.test(navigator.userAgent || ''); | 36 | var isWechat = /micromessenger/i.test(navigator.userAgent || ''); |
@@ -97,20 +106,6 @@ | @@ -97,20 +106,6 @@ | ||
97 | {{#if nodownload}} | 106 | {{#if nodownload}} |
98 | <input type="hidden" id="no-download" value="no-download"> | 107 | <input type="hidden" id="no-download" value="no-download"> |
99 | {{/if}} | 108 | {{/if}} |
100 | - {{#ifand isProduction wap.open.bughd}} | ||
101 | - <script type="text/javascript" src="//cdn.yoho.cn/tool/bj-report-tryjs.min.js?t={{startTime}}" crossOrigin="anonymous"></script> | ||
102 | - <script type="text/javascript"> | ||
103 | - if (BJ_REPORT && BJ_REPORT.init) { | ||
104 | - BJ_REPORT.init({ | ||
105 | - id: 2, | ||
106 | - url: "//badjs.yoho.cn/badjs", | ||
107 | - ignore: [/Script error/i], | ||
108 | - offlineLog: false, | ||
109 | - offlineLogAuto: false | ||
110 | - }); | ||
111 | - } | ||
112 | - </script> | ||
113 | - {{/ifand}} | ||
114 | {{#wechatShare}} | 109 | {{#wechatShare}} |
115 | <script type="text/javascript" src="//res.wx.qq.com/open/js/jweixin-1.1.0.js"></script> | 110 | <script type="text/javascript" src="//res.wx.qq.com/open/js/jweixin-1.1.0.js"></script> |
116 | {{/wechatShare}} | 111 | {{/wechatShare}} |
@@ -121,18 +116,11 @@ | @@ -121,18 +116,11 @@ | ||
121 | <script src="//{{devHost}}:5001/{{module}}.{{page}}.js"></script> | 116 | <script src="//{{devHost}}:5001/{{module}}.{{page}}.js"></script> |
122 | {{^}} | 117 | {{^}} |
123 | <script>var STATIC_RESOURCE_PATH = '//cdn.yoho.cn/m-yohobuy-node/assets';</script> | 118 | <script>var STATIC_RESOURCE_PATH = '//cdn.yoho.cn/m-yohobuy-node/assets';</script> |
124 | - <script src="//cdn.yoho.cn/m-yohobuy-node/{{version}}/libs.js?t={{startTime}}"></script> | ||
125 | - {{#ifand isProduction wap.open.bughd}} | ||
126 | - <script> | ||
127 | - if (BJ_REPORT && BJ_REPORT.tryJs) { | ||
128 | - BJ_REPORT.tryJs().spyAll(); | ||
129 | - } | ||
130 | - </script> | ||
131 | - {{/ifand}} | ||
132 | - <script src="//cdn.yoho.cn/m-yohobuy-node/{{version}}/{{module}}.{{page}}.js?t={{startTime}}"></script> | 119 | + <script src="//cdn.yoho.cn/m-yohobuy-node/{{version}}/libs.js?t={{startTime}}" crossorigin="anonymous"></script> |
120 | + <script src="//cdn.yoho.cn/m-yohobuy-node/{{version}}/{{module}}.{{page}}.js?t={{startTime}}" crossorigin="anonymous"></script> | ||
133 | {{/if}} | 121 | {{/if}} |
134 | {{#loadJs}} | 122 | {{#loadJs}} |
135 | - <script type="text/javascript" src="{{src}}"></script> | 123 | + <script type="text/javascript" src="{{src}}" crossorigin="anonymous"></script> |
136 | {{/loadJs}} | 124 | {{/loadJs}} |
137 | {{#unless devEnv}} | 125 | {{#unless devEnv}} |
138 | {{> analysis}} | 126 | {{> analysis}} |
@@ -12,7 +12,7 @@ | @@ -12,7 +12,7 @@ | ||
12 | a.async = 1; | 12 | a.async = 1; |
13 | a.src = j; | 13 | a.src = j; |
14 | m.parentNode.insertBefore(a, m); | 14 | m.parentNode.insertBefore(a, m); |
15 | - }(window, document, 'script', (document.location.protocol === 'https:' ? 'https:' : 'http:') + '//cdn.yoho.cn/yas-jssdk/2.4.2/yas.js', '_yas')); | 15 | + }(window, document, 'script', (document.location.protocol === 'https:' ? 'https:' : 'http:') + '//cdn.yoho.cn/yas-jssdk/2.4.6/yas.js', '_yas')); |
16 | 16 | ||
17 | var _hmt = _hmt || []; | 17 | var _hmt = _hmt || []; |
18 | 18 | ||
@@ -56,7 +56,7 @@ | @@ -56,7 +56,7 @@ | ||
56 | uid = uid === 0 ? '' : uid; | 56 | uid = uid === 0 ? '' : uid; |
57 | window._ozuid = uid; // 暴露ozuid | 57 | window._ozuid = uid; // 暴露ozuid |
58 | if (window._yas) { | 58 | if (window._yas) { |
59 | - window._yas(1 * new Date(), '2.4.2', 'yohobuy_m', uid, '', ''); | 59 | + window._yas(1 * new Date(), '2.4.6', 'yohobuy_m', uid, '', ''); |
60 | } | 60 | } |
61 | 61 | ||
62 | setTimeout(function() { | 62 | setTimeout(function() { |
package-lock.json
0 → 100644
This diff could not be displayed because it is too large.
1 | { | 1 | { |
2 | "name": "m-yohobuy-node", | 2 | "name": "m-yohobuy-node", |
3 | - "version": "6.1.2", | 3 | + "version": "6.1.3", |
4 | "private": true, | 4 | "private": true, |
5 | "description": "A New Yohobuy Project With Express", | 5 | "description": "A New Yohobuy Project With Express", |
6 | "repository": { | 6 | "repository": { |
@@ -73,7 +73,7 @@ | @@ -73,7 +73,7 @@ | ||
73 | "xml2js": "^0.4.19", | 73 | "xml2js": "^0.4.19", |
74 | "yoho-express-session": "^2.0.0", | 74 | "yoho-express-session": "^2.0.0", |
75 | "yoho-md5": "^2.0.0", | 75 | "yoho-md5": "^2.0.0", |
76 | - "yoho-node-lib": "=0.3.6", | 76 | + "yoho-node-lib": "=0.5.3", |
77 | "yoho-zookeeper": "^1.0.8" | 77 | "yoho-zookeeper": "^1.0.8" |
78 | }, | 78 | }, |
79 | "devDependencies": { | 79 | "devDependencies": { |
@@ -56,6 +56,7 @@ module.exports = (env) => { | @@ -56,6 +56,7 @@ module.exports = (env) => { | ||
56 | path: path.join(__dirname, 'bundle'), // absolute path | 56 | path: path.join(__dirname, 'bundle'), // absolute path |
57 | filename: '[name].js' | 57 | filename: '[name].js' |
58 | }, | 58 | }, |
59 | + devtool: 'hidden-source-map', | ||
59 | module: { | 60 | module: { |
60 | rules: [{ | 61 | rules: [{ |
61 | test: /\.vue$/, | 62 | test: /\.vue$/, |
@@ -13,7 +13,6 @@ Object.keys(baseConfig.entry).forEach(function(name) { | @@ -13,7 +13,6 @@ Object.keys(baseConfig.entry).forEach(function(name) { | ||
13 | }); | 13 | }); |
14 | 14 | ||
15 | module.exports = merge(baseConfig, { | 15 | module.exports = merge(baseConfig, { |
16 | - devtool: '#cheap-module-source-map', | ||
17 | output: { | 16 | output: { |
18 | publicPath: devInfo.publicPath | 17 | publicPath: devInfo.publicPath |
19 | }, | 18 | }, |
@@ -30,6 +30,7 @@ module.exports = merge(baseConfig, { | @@ -30,6 +30,7 @@ module.exports = merge(baseConfig, { | ||
30 | }), | 30 | }), |
31 | new webpack.optimize.UglifyJsPlugin({ | 31 | new webpack.optimize.UglifyJsPlugin({ |
32 | parallel: true, | 32 | parallel: true, |
33 | + sourceMap: true, | ||
33 | uglifyOptions: { | 34 | uglifyOptions: { |
34 | compress: { | 35 | compress: { |
35 | warnings: false | 36 | warnings: false |
-
Please register or login to post a comment