alife-logger
Advanced tools
Comparing version 1.4.1 to 1.4.2
@@ -10,3 +10,3 @@ var util = require("./util"), pushToQueue = function(t, e) { | ||
}, Base = function(t) { | ||
return this.ver = "1.4.1", this._conf = util.ext({}, Base.dftCon), this.sampleCache = {}, | ||
return this.ver = "1.4.2", this._conf = util.ext({}, Base.dftCon), this.sampleCache = {}, | ||
this.requestQueue = [], this.hash = util.seq(), this.resetSession(), this.setConfig(t), | ||
@@ -13,0 +13,0 @@ this.rip = util.getRandIP(), this.record = 999, this["EagleEye-TraceID"] = this.getTraceId()["EagleEye-TraceID"], |
@@ -7,15 +7,15 @@ module.exports = function(t, e) { | ||
}) : ((a = n.createEvent("HTMLEvents")).initEvent(t, !1, !0), a.detail = r), e.dispatchEvent(a); | ||
}, c = function(t) { | ||
}, o = function(t) { | ||
var e = a[t]; | ||
"function" == typeof e && (a[t] = function(n, c, o) { | ||
var s = location.href, u = e.call(a, n, c, o); | ||
if (!o || "string" != typeof o) return u; | ||
if (o === s) return u; | ||
"function" == typeof e && (a[t] = function(n, o, c) { | ||
var s = 1 === arguments.length ? [ arguments[0] ] : Array.apply(null, arguments), u = location.href, h = e.apply(a, s); | ||
if (!c || "string" != typeof c) return h; | ||
if (c === u) return h; | ||
try { | ||
var h = s.split("#"), l = o.split("#"), p = r.cutUrlSearch(h[0]), f = r.cutUrlSearch(l[0]), v = h[1] && h[1].replace(/^\/?(.*)/, "$1"), y = l[1] && l[1].replace(/^\/?(.*)/, "$1"); | ||
p !== f ? i("historystatechange", f) : v !== y && i("historystatechange", y); | ||
} catch (S) { | ||
r.warn("[retcode] error in " + t + ": " + S); | ||
var l = u.split("#"), p = c.split("#"), y = r.cutUrlSearch(l[0]), f = r.cutUrlSearch(p[0]), v = l[1] && l[1].replace(/^\/?(.*)/, "$1"), S = p[1] && p[1].replace(/^\/?(.*)/, "$1"); | ||
y !== f ? i("historystatechange", f) : v !== S && i("historystatechange", S); | ||
} catch (d) { | ||
r.warn("[retcode] error in " + t + ": " + d); | ||
} | ||
return u; | ||
return h; | ||
}, a[t].toString = r.createFakeToString(t)); | ||
@@ -25,3 +25,3 @@ }; | ||
hackHistoryState: function() { | ||
return this.hasHackedHistoryState ? this : (c("pushState"), c("replaceState"), this.hasHackedHistoryState = !0, | ||
return this.hasHackedHistoryState ? this : (o("pushState"), o("replaceState"), this.hasHackedHistoryState = !0, | ||
this); | ||
@@ -28,0 +28,0 @@ } |
@@ -1,1 +0,1 @@ | ||
/** retcode cloud sdk | @version 1.4.1 | @copyright Alibaba Group Holding Limited. */ !function(){function t(e,n,r){function a(i,s){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!s&&c)return c(i,!0);if(o)return o(i,!0);var u=new Error("Cannot find module '"+i+"'");throw u.code="MODULE_NOT_FOUND",u}var f=n[i]={exports:{}};e[i][0].call(f.exports,function(t){return a(e[i][1][t]||t)},f,f.exports,t,e,n,r)}return n[i].exports}for(var o="function"==typeof require&&require,i=0;i<r.length;i++)a(r[i]);return a}return t}()({1:[function(t,e,n){var r=t("./util"),a=function(t){return this.ver="1.4.1",this._conf=r.ext({},a.dftCon),this.$a5={},this.$a1=[],this.hash=r.seq(),this.$a6(),this.setConfig(t),this.rip=r.getRandIP(),this.record=999,this["EagleEye-TraceID"]=this.getTraceId()["EagleEye-TraceID"],this};a.dftCon={sample:1,tag:""},a.prototype={constructor:a,$a2:function(t){return t()},$a7:function(){var t=this._conf.page;return r.$a8(t,[],t+"")},setPage:function(){},setConfig:function(t){t&&"object"==typeof t&&(r.$a9(t),this._conf=r.ext({},this._conf,t))},$aa:function(){},$ab:function(){},$ac:function(){return{}},$a6:function(){this.session=r.uu(),this.sBegin=Date.now()},getTraceId:function(){var t=this.rip,e=Date.now(),n=r.getSortNum(this.record),a=t+e+n+r.getRandNum(this._conf.pid);return this["EagleEye-TraceID"]=a,this.record=n,{"EagleEye-TraceID":a}},getSessionId:function(){return{"EagleEye-SessionID":this.session}},getConfig:function(t){return t?this._conf[t]:r.ext({},this._conf)},$ad:function(t){return 1===t||("boolean"==typeof this.$a5[t]?this.$a5[t]:(this.$a5[t]=r.pick(t),this.$a5[t]))},$a4:function(){var t;for(clearTimeout(this.$a3),this.$a3=null;t=this.$a1.pop();)"res"===t.t?this.$ab(t,"res"):this.$aa(t);return this},_lg:function(t,e,n){var a=this._conf;return e&&!a.disabled&&a.pid?n&&!this.$ad(n)?this:(e=r.ext({t:t,times:1,page:this.$a7(),tag:a.tag||"",begin:Date.now()},e,this.$ac(),{pid:a.pid,_v:this.ver,sid:this.session,sampling:n||1,z:r.seq()}),function(t,e){var n;"error"===e.t&&(n=t.$a1[0])&&"error"===n.t&&e.msg===n.msg?n.times++:(t.$a1.unshift(e),t.$a2(function(){t.$a3=r.delay(function(){t.$a4()},"error"===e.t?3e3:-1)}))}(this,e)):this},custom:function(t,e){if(!t||"object"!=typeof t)return this;var n=!1,a={begin:Date.now()};return r.each(t,function(t,e){return!(n=e&&e.length<=20)&&r.warn("[retcode] invalid key: "+e),a["x-"+e]=t,n}),n?this._lg("custom",a,e||1):this}},e.exports=a},{"./util":14}],2:[function(t,e,n){var r=t("../util"),a=t("../reporter"),o=t("../common/sender"),i=t("../common/post"),s=r.win,c=s.document,u=/^(error|api|speed|sum|avg|percent|custom|msg|setPage|setConfig)$/,f=function(t){var e=this;return a.call(e,t),e._initialPage=t.page&&r.$a8(t.page,[],t.page+"")||null,e._health={errcount:0,apisucc:0,apifail:0},e.$ae=function(t,n){"error"===t?e._health.errcount++:"api"===t&&e._health[n.success?"apisucc":"apifail"]++},e.$af(),e.$ag(),e.$ah(1e4),Object.defineProperty&&s.addEventListener&&Object.defineProperty(e,"pipe",{set:e.$ai}),e};f.prototype=r.$aj(a.prototype),r.ext(a._root.dftCon,{uid:null,ignoreUrlPath:[{rule:/\/([a-z\-_]+)?\d{2,20}/g,target:"/$1**"},/\/$/],ignoreApiPath:{rule:/(\w+)\/\d{2,}/g,target:"$1"},ignoreUrlCase:!0,imgUrl:"https://arms-retcode.aliyuncs.com/r.png?",disableHook:!1,autoSendPv:!0,enableSPA:!1,enableLinkTrace:!1,sendResource:!0,parseHash:function(t){return(t?r.$al(t.replace(/^#\/?/,"")):"")||"[index]"},parseResponse:function(t){if(!t||"object"!=typeof t)return{};var e=t.code,n=t.msg||t.message||t.subMsg||t.errorMsg||t.ret||t.errorResponse||"";return"object"==typeof n&&(e=e||n.code,n=n.msg||n.message||n.info||n.ret||JSON.stringify(n)),{msg:n,code:e,success:!0}}}),r.ext(f.prototype,{constructor:f,_super:a,$a2:function(t){var e=this;if(e.hasReady)return t();"complete"===c.readyState?(e.hasReady=!0,t()):r.on(s,"load",function(){e.hasReady=!0,t()},!0)},$a7:function(t){var e=this._conf,n=e.page,a=location,o=a.host+a.pathname;return n&&!t?r.$a8(n,[],n+""):this._initialPage||r.$ak(e.ignoreUrlCase?o.toLowerCase():o,e.ignoreUrlPath)},setPage:function(t,e){var n=this,r=n.$am;if(!1!==e){if(!t||t===r)return n;n.$am=t,clearTimeout(n.$an),n.$ao(1),n.$a6(),n.$an=setTimeout(function(){n.$ap()},10)}else n.$am=t;return n._conf.page=t,n},setConfig:function(t,e){if(t&&"object"==typeof t){r.$a9(t);var n=this._conf;if(this._conf=r.ext({},n,t),!e){var a="disableHook";a in t&&n[a]!==t[a]&&(t[a]?this.removeHook():this.addHook()),(a="enableSPA")in t&&n[a]!==t[a]&&this.$aq(t[a])}}},$aa:function(t){o(t,this.getConfig("imgUrl"))},$ab:function(t,e){var n={};n[e]=t[e],delete t[e];var a="";"object"==typeof t&&(a=r.serialize(t)),i(n,this.getConfig("imgUrl")+a+"&post_res=")},$ai:function(t){var e=this;if(!t||!t.length)return e;try{if("Array"===r.T(t[0]))return r.each(t,function(t){return e.$ai(t)});if("Array"!==r.T(t))return e;var n=t.shift();if(!u.test(n))return e;e[n].apply(e,t)}catch(a){return r.warn("[retcode] error in sendPipe",a),e}},$ar:function(){var t=r.ext({},this._health);t.healthy=t.errcount>0?0:1,t.begin=Date.now();var e=t.begin-this.sBegin;t.stay=e,this._lg("health",t,1),this._health={errcount:0,apisucc:0,apifail:0}},createInstance:function(t){t=r.ext({pid:this._conf.pid},t);var e=this.__proto__.constructor(t);return t.page&&e.$ap(),e}}),t("./handler")(f,s,c),t("./fmp")(f,s,c),t("./hook")(f,s),t("./hack")(f,s),f._super=a,f._root=a._root,a.Browser=f,e.exports=f},{"../common/post":9,"../common/sender":11,"../reporter":13,"../util":14,"./fmp":3,"./hack":4,"./handler":5,"./hook":6}],3:[function(t,e,n){var r=t("../util"),a=500;e.exports=function(t,e,n){function o(t,e,n){var r=0,a=t.tagName;if("SCRIPT"!==a&&"STYLE"!==a&&"META"!==a&&"HEAD"!==a){var i=t.children?t.children.length:0;if(i>0)for(var c=t.children,u=i-1;u>=0;u--)r+=o(c[u],e+1,r>0);if(r<=0&&!n){if(!(t.getBoundingClientRect&&t.getBoundingClientRect().top<s))return 0}r+=1+.5*e}return r}function i(t){for(var e=1;e<t.length;e++)if(t[e].score<t[e-1].score)return t.splice(e,1),i(t);return t}var s=e.innerHeight||0,c=[],u=null,f=0;r.ext(t.prototype,{$ah:function(t){var a=this;if(!a._conf||!a._conf.useFmp)return null;if(!e.MutationObserver)return r.warn("[retcode] first meaningful paint can not be retrieved"),a.$as(),null;r.on(e,"beforeunload",function(){a.$at(0,!0)});var i=e.MutationObserver;return(u=new i(function(){!function(t){var e=Date.now()-t,r=n.querySelector("body");if(r){var a=0;a+=o(r,1,!1),c.push({score:a,t:e})}else c.push({score:0,t:e})}(a._startTime)})).observe(document,{childList:!0,subtree:!0}),f=1,a.$a2(function(){a.$at(t)}),u},$at:function(t,e){var n=this;if(u&&f)if(e||!function(t,e){var n=Date.now()-t;return!(n>e||n-(c&&c.length&&c[c.length-1].t||0)>2*a)}(n._startTime,t)){u.disconnect(),f=0,c=i(c);for(var o=null,s=1;s<c.length;s++)if(c[s].t>=c[s-1].t){var l=c[s].score-c[s-1].score;(!o||o.rate<=l)&&(o={t:c[s].t,rate:l})}o&&o.t>0?n.$as({fmp:o.t}):n.$as()}else r.delay(function(){n.$at(t)},a)}})}},{"../util":14}],4:[function(t,e,n){e.exports=function(e,n){var r=t("../util"),a=n.history||{},o=n.document,i=function(t,e){var r;n.CustomEvent?r=new CustomEvent(t,{detail:e}):((r=o.createEvent("HTMLEvents")).initEvent(t,!1,!0),r.detail=e),n.dispatchEvent(r)},s=function(t){var e=a[t];"function"==typeof e&&(a[t]=function(n,o,s){var c=location.href,u=e.call(a,n,o,s);if(!s||"string"!=typeof s)return u;if(s===c)return u;try{var f=c.split("#"),l=s.split("#"),p=r.$al(f[0]),h=r.$al(l[0]),d=f[1]&&f[1].replace(/^\/?(.*)/,"$1"),g=l[1]&&l[1].replace(/^\/?(.*)/,"$1");p!==h?i("historystatechange",h):d!==g&&i("historystatechange",g)}catch(v){r.warn("[retcode] error in "+t+": "+v)}return u},a[t].toString=r.$au(t))};r.ext(e.prototype,{$av:function(){return this.$aw?this:(s("pushState"),s("replaceState"),this.$aw=!0,this)}})}},{"../util":14}],5:[function(t,e,n){e.exports=function(e,n,r){var a=t("../util"),o=t("../common/perf"),i=t("../common/res"),s=null,c=r.documentElement,u=n.innerWidth||c.clientWidth||r.body.clientWidth,f=n.innerHeight||c.clientHeight||r.body.clientHeight,l=n.navigator.connection,p={sr:screen.width+"x"+screen.height,vp:u+"x"+f,ct:l?l.effectiveType||l.type:""},h={},d=function(t,e,n,o,i){if(e===undefined){var s,c;if(!h[t]){s=new RegExp(t+"=([^;]+)");try{c=s.exec(r.cookie)}catch(f){return a.warn("[retcode] can not get cookie:",f),null}c&&(h[t]=c[1])}return h[t]}var u=t+"="+e;o&&(u+="; domain="+o),i&&(u+="; path="+i),n&&(u+="; max-age="+n);try{return r.cookie=u,!!r.cookie}catch(f){return a.warn("[retcode] can not set cookie: ",f),!1}},g=function(t){var e=t._conf.uid||d("_nk_")||d("_bl_uid");if(!e){e=a.uu();if(!d("_bl_uid",e,15552e3))return null}return e};return a.ext(e.prototype,{activeErrHandler:function(t){return s&&!t?this:(s=this,this)},errorHandler:function(t){if(!t)return this;var e=t.type;return"error"===e?this.error(t.error||{message:t.message},t):"unhandledrejection"===e&&a.T(t.reason,"Error")&&a.$ax(t.reason)&&this.error(t.reason),this},$as:function(t){var e=this;e.$a2(function(){var n=o();n&&(n.page=e.$a7(!0),t&&(n=a.ext(n,t)),e._lg("perf",n,e.getConfig("sample")))})},$ay:function(t){var e=this;e.$a2(function(){var n=i();n&&(n.load&&n.load<=2e3||n.load&&n.load<=8e3&&Math.random()>.05||(n.page=e.$a7(!0),n.dl=location.href,t&&(n=a.ext(n,t)),e._lg("res",n,e.getConfig("sample"))))})},$ap:function(){var t=this;t.$a2(function(){var e=function(t){var e=g(t),a=n.devicePixelRatio||1;return{uid:e,dt:r.title,dl:location.href,dr:r.referrer,dpr:a.toFixed(2),de:(r.characterSet||r.defaultCharset||"").toLowerCase(),ul:c.lang,begin:Date.now()}}(t);e&&e.uid&&t._lg("pv",e)})},$ac:function(){return p.uid=g(this),p},$ao:function(t){var e=Date.now();if(e-this._lastUnload<200)return this;this._lastUnload=e,this.$ar(t),this.$az&&(this._lg("speed",this.$az),this.$az=null,clearTimeout(this.$b0)),this.$a4()},$aq:function(t){var e=this;if(!t^e.$b1)return e;t?(e.$av(),e.$b1=function(t){var n=e._conf.parseHash(location.hash);n&&e.setPage(n,!1!==t)},e.$b2=function(t){var n=e._conf.parseHash(t.detail);n&&e.setPage(n)},a.on(n,"hashchange",e.$b1),a.on(n,"historystatechange",e.$b2),e.$b1(!1)):(a.off(n,"hashchange",e.$b1),a.off(n,"historystatechange",e.$b2),e.$b1=null,e.$b2=null)},$af:function(){var t=this;if(t.$b3)return t;var e=t._conf;return a.on(n,"beforeunload",function(){t.$ao(0)}),t.$aq(e.enableSPA),t.activeErrHandler(!1),t.$b3=!0,t}}),a.on(n,"error",function(t){s&&s.errorHandler(t)}).on(n,"unhandledrejection",function(t){s&&s.errorHandler(t)}),e}},{"../common/perf":8,"../common/res":10,"../util":14}],6:[function(t,e,n){e.exports=function(e,n){var r=t("../util"),a=null,o=function(t,e,n,a,o,i,s,c,u,f){var l=r.J(o)||null,p=r.$a8(e,[l,a],null);if(!p)return!1;var h=p.code||i,d=!("success"in p)||p.success;t.api(n,d,s,h,p.msg,c,u,f)},i="fetch",s="__oFetch_",c="__oXMLHttpRequest_",u="XMLHttpRequest";return r.ext(e.prototype,{removeHook:function(t,e){return a&&(e||this===a)?(n[s]&&(n[i]=n[s],delete n[s]),n[c]&&(n[u]=n[c],delete n[c]),a=null,this):this},addHook:function(t){return!t&&a?this:(a||(function(){if("function"==typeof n[i]){var t=n[i];n[s]=t,n[i]=function(e,i){var s=1===arguments.length?[arguments[0]]:Array.apply(null,arguments),c=a;if(!c||!c.api)return t.apply(n,s);if(i&&("HEAD"===i.method||"no-cors"===i.mode))return t.apply(n,s);var u=Date.now(),f=c._conf,l=(e&&"string"!=typeof e?e.url:e)||"",p=l;if(l=r.$al(l),!r.$b4(l,!0))return t.apply(n,s);l=r.$ak(l,f.ignoreApiPath);var h="",d="";if(f.enableLinkTrace){var g="";try{g=location.origin?location.origin:location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")}catch(m){g=""}if(r.checkSameOrigin(p,g)){if(e&&"string"!=typeof e)try{if(s[0].headers&&"function"==typeof s[0].headers.get&&"function"==typeof s[0].headers.append){var v=s[0].headers.get("EagleEye-TraceID"),y=s[0].headers.get("EagleEye-SessionID");v?h=v:(h=c.getTraceId()["EagleEye-TraceID"],s[0].headers.append("EagleEye-TraceID",h)),y?d=y:(d=c.getSessionId()["EagleEye-SessionID"],s[0].headers.append("EagleEye-SessionID",d))}}catch($){r.warn("[retcode] fetch failed to set header, exception is :\n"+$)}i&&(i.headers=i.headers?i.headers:{},i.headers["EagleEye-TraceID"]?h=i.headers["EagleEye-TraceID"]:(h=c.getTraceId()["EagleEye-TraceID"],i.headers["EagleEye-TraceID"]=h),i.headers["EagleEye-SessionID"]?d=i.headers["EagleEye-SessionID"]:(d=c.getTraceId()["EagleEye-SessionID"],i.headers["EagleEye-SessionID"]=d))}}return t.apply(n,s).then(function(t){if(!c||!c.api)return t;var e=t.clone(),n=e.headers;if(n&&"function"==typeof n.get){var r=n.get("content-type");if(r&&!/(text)|(json)/.test(r))return t}var a=Date.now()-u;return e.ok?e.text().then(function(t){o(c,f.parseResponse,l,p,t,e.status||200,a,u,h,d)}):c.api(l,!1,a,e.status||404,e.statusText,u,h,d),t})["catch"](function(t){if(!c||!c.api)throw t;var e=Date.now()-u;throw c.api(l,!1,e,t.name||"Error",t.message,u,h,d),t})},n[i].toString=r.$au(i)}}(),function(){if("function"==typeof n[u]){var t=n[u];n[c]=t,n[u]=function(e){var n=new t(e),i=a;if(!i||!i.api||!n.addEventListener)return n;var s,c,u,f=n.send,l=n.open,p=n.setRequestHeader,h=i._conf,d=i.getConfig("enableLinkTrace"),g="",v="";return n.open=function(t,e){var a=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);if(l.apply(n,a),u=e||"",c=r.$al(u),c=c?r.$ak(c,h.ignoreApiPath):"",d){var o="";try{o=location.origin?location.origin:location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")}catch(s){o=""}r.checkSameOrigin(u,o)&&p&&"function"==typeof p&&(g=i.getTraceId()["EagleEye-TraceID"],p.apply(n,["EagleEye-TraceID",g]),v=i.getSessionId()["EagleEye-SessionID"],p.apply(n,["EagleEye-SessionID",v]))}},n.send=function(){s=Date.now();var t=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);f.apply(n,t)},r.on(n,"readystatechange",function(){if(c&&4===n.readyState){var t=Date.now()-s;if(n.status>=200&&n.status<=299){var e=n.status||200;if("function"==typeof n.getResponseHeader){var r=n.getResponseHeader("Content-Type");if(r&&!/(text)|(json)/.test(r))return}n.responseType&&"text"!==n.responseType?i.api(c,!0,t,e,"",s,g,v):o(i,h.parseResponse,c,u,n.responseText,e,t,s,g,v)}else i.api(c,!1,t,n.status||"FAILED",n.statusText,s,g,v)}}),n},n[u].toString=r.$au(u)}}()),a=this,this)},$ag:function(){return this.$b5?this:(this.getConfig("disableHook")||this.addHook(),this.$b5=!0,this)}}),e}},{"../util":14}],7:[function(t,e,n){n.TIMING_KEYS=["","fetchStart","domainLookupStart","domainLookupEnd","connectStart","connectEnd","requestStart","responseStart","responseEnd","","domInteractive","","domContentLoadedEventEnd","","loadEventStart","","msFirstPaint","secureConnectionStart"]},{}],8:[function(t,e,n){var r=t("../util"),a=t("./constants").TIMING_KEYS;e.exports=function(){var t=r.win||{},e=t.performance;if(!e||"object"!=typeof e)return null;var n={},o=e.timing||{},i=Date.now(),s=1;if("function"==typeof t.PerformanceNavigationTiming){var c=e.getEntriesByType("navigation")[0];c&&(o=c,s=2)}r.each({dns:[3,2],tcp:[5,4],ssl:[5,17],ttfb:[7,6],trans:[8,7],dom:[10,8],res:[14,12],firstbyte:[7,2],fpt:[8,1],tti:[10,1],ready:[12,1],load:[14,1]},function(t,e){var r=o[a[t[1]]],i=o[a[t[0]]];if(2===s||r>0&&i>0){var c=Math.round(i-r);c>=0&&c<36e5&&(n[e]=c)}});var u=t.navigator.connection,f=e.navigation||{};n.ct=u?u.effectiveType||u.type:"";var l=u?u.downlinkMax||u.bandwidth||-1:-1;return l=l>999?999:l,n.bandwidth=l,n.navtype=1===f.type?"Reload":"Other",1===s&&o[a[16]]>0&&o[a[1]]>0&&(n.fpt=o[a[16]]-o[a[1]]),1===s&&o[a[1]]>0?n.begin=o[a[1]]:2===s&&n.load>0?n.begin=i-n.load:n.begin=i,n}},{"../util":14,"./constants":7}],9:[function(t,e,n){var r=t("../util"),a="object"==typeof window?window:{},o=a.__oXMLHttpRequest_||a.XMLHttpRequest;o="function"==typeof o?o:undefined,e.exports=function(t,e){try{var n=new o;n.open("POST",e,!0),n.setRequestHeader("Content-Type","text/plain"),n.send(JSON.stringify(t))}catch(a){r.warn("[retcode] Failed to log, exception is :\n"+a)}}},{"../util":14}],10:[function(t,e,n){var r=t("../util"),a=t("./constants").TIMING_KEYS;e.exports=function(){var t=r.win||{},e=t.performance;if(!e||"object"!=typeof e||"function"!=typeof e.getEntriesByType)return null;var n={},o=e.timing||{},i=e.getEntriesByType("resource")||[];if(n.begin=o[a[1]]||Date.now(),"function"==typeof t.PerformanceNavigationTiming){var s=e.getEntriesByType("navigation")[0];s&&(o=s)}return r.each({dom:[10,8],load:[14,1]},function(t,e){var r=o[a[t[1]]],i=o[a[t[0]]];if(r>0&&i>0){var s=Math.round(i-r);s>=0&&s<36e5&&(n[e]=s)}}),n.res=JSON.stringify(i),n}},{"../util":14,"./constants":7}],11:[function(t,e,n){var r=t("../util"),a="object"==typeof window?window:{},o=a.__oFetch_||a.fetch;o="function"==typeof o?o:undefined,e.exports=function(t,e){var n=-1;"object"==typeof t&&(n=t.z,t=r.serialize(t));var i=e+t;if(o)return o(i,{method:"HEAD",mode:"no-cors"})["catch"](r.noop);if(a.document&&a.document.createElement){var s="__request_hold_"+n,c=a[s]=new Image;c.onload=c.onerror=function(){a[s]=undefined},c.src=i,c=null}}},{"../util":14}],12:[function(t,e,n){"use strict";function r(t,e){var n=a[i]=new o(t);n.$ai(e);var r=n._conf;return!1!==r.autoSendPv&&n.$ap(),r&&r.useFmp||n.$as(),r&&r.sendResource&&n.$ay(),a[s]=!0,n}var a=window,o=a.BrowserLogger=t("./biz.browser/clazz"),i=t("./util").key,s="__hasInitBlSdk";o.singleton=function(t,e){return a[s]?a[i]:r(t,e)};"object"==typeof window&&!!window.navigator&&a[i]&&(o.bl=function(){if(a[s])return a[i];var t={},e=[];return i in a&&(t=a[i].config||{},e=a[i].pipe||[]),r(t,e)}(a.__hasInitBlSdk)),e.exports=o},{"./biz.browser/clazz":2,"./util":14}],13:[function(t,e,n){var r=t("./util"),a=t("./base"),o=["api","success","time","code","msg","trace","traceId","begin","sid","seq"],i=function(t,e){var n=t.split("::");return n.length>1?r.ext({group:n[0],key:n[1]},e):r.ext({group:"default_group",key:n[0]},e)},s=function(t){a.call(this,t);var e;try{e="object"==typeof performance?performance.timing.fetchStart:Date.now()}catch(n){e=Date.now()}return this._startTime=e,this};s.prototype=r.$aj(a.prototype),r.ext(a.dftCon,{startTime:null}),r.ext(s.prototype,{constructor:s,_super:a,sum:function(t,e,n){try{return this._lg("sum",i(t,{val:e||1,begin:Date.now()}),n)}catch(a){r.warn("[retcode] can not get parseStatData: "+a)}},avg:function(t,e,n){try{return this._lg("avg",i(t,{val:e||0,begin:Date.now()}),n)}catch(a){r.warn("[retcode] can not get parseStatData: "+a)}},percent:function(t,e,n,a){try{return this._lg("percent",i(t,{subkey:e,val:n||0,begin:Date.now()}),a)}catch(o){r.warn("[retcode] can not get parseStatData: "+o)}},msg:function(t,e){if(t&&!(t.length>180))return this.custom({msg:t},e)},error:function(t,e){if(!t||"object"!=typeof t||"string"!=typeof t.message)return r.warn("[retcode] invalid param e: "+t),this;var n=t.name||"CustomError",a=t.message,o=t.stack||"";e=e||{},o=o&&o.substring(0,1e3);var i={begin:Date.now(),cate:n,msg:a.substring(0,1e3),stack:o,file:e.filename||"",line:e.lineno||"",col:e.colno||""};return this.$ae&&this.$ae("error",i),this._lg("error",i,1)},api:function(t,e,n,a,i,s,c,u){return t?(t="string"==typeof t?{api:t,success:e,time:n,code:a,msg:i,begin:s,traceId:c,sid:u}:r.sub(t,o),r.$b4(t.api)?(t.code=t.code||"",t.msg=t.msg||"",t.success=t.success?1:0,t.time=+t.time,t.begin=t.begin,t.traceId=t.traceId||"",t.sid=t.sid||"",!t.api||isNaN(t.time)?(r.warn("[retcode] invalid time or api"),this):(this.$ae&&this.$ae("api",t),this._lg("api",t,t.success&&this.getConfig("sample")))):this):(r.warn("[retcode] api is null"),this)},speed:function(t,e,n){var a=this,o=this.getConfig("startTime")||this._startTime;return/^s(\d|1[0])$/.test(t)?(e="number"!=typeof e?Date.now()-o:e>=o?e-o:e,a.$az=a.$az||{},a.$az[t]=e,a.$az.begin=o,clearTimeout(a.$b0),a.$b0=setTimeout(function(){n||(a.$az.page=a.$a7(!0)),a._lg("speed",a.$az),a.$az=null},5e3),a):(r.warn("[retcode] invalid point: "+t),a)}}),s._super=a,s._root=a,a.Reporter=s,e.exports=s},{"./base":1,"./util":14}],14:[function(t,e,n){Date.now=Date.now||function(){return(new Date).getTime()};var r=Date.now(),a=function(){},o={noop:a,warn:function(){var t="object"==typeof console?console.warn:a;try{var e={warn:t};e.warn.call(e)}catch(n){return a}return t}(),key:"__bl",win:"object"==typeof window&&window.document?window:undefined,$aj:function(t){if(Object.create)return Object.create(t);var e=function(){};return e.prototype=t,new e},each:function(t,e){var n=0,r=t.length;if(this.T(t,"Array"))for(;n<r&&!1!==e.call(t[n],t[n],n);n++);else for(n in t)if(!1===e.call(t[n],t[n],n))break;return t},$a8:function(t,e,n){if("function"!=typeof t)return n;try{return t.apply(this,e)}catch(r){return n}},T:function(t,e){var n=Object.prototype.toString.call(t).substring(8).replace("]","");return e?n===e:n},$ak:function(t,e){if(!t)return"";if(!e)return t;var n=this,r=n.T(e);return"Function"===r?n.$a8(e,[t],t):"Array"===r?(this.each(e,function(e){t=n.$ak(t,e)}),t):"Object"===r?t.replace(e.rule,e.target||""):t.replace(e,"")},J:function(t){if(!t||"string"!=typeof t)return t;var e=null;try{e=JSON.parse(t)}catch(n){}return e},pick:function(t){return 1===t||1===Math.ceil(Math.random()*t)},$a9:function(t){if("sample"in t){var e=t.sample,n=e;e&&/^\d+(\.\d+)?%$/.test(e)&&(n=parseInt(100/parseFloat(e))),0<n&&1>n&&(n=parseInt(1/n)),n>=1&&n<=100?t.sample=n:delete t.sample}return t},on:function(t,e,n,r){return t.addEventListener?t.addEventListener(e,function a(o){r&&t.removeEventListener(e,a,!1),n.call(this,o)},!1):t.attachEvent&&t.attachEvent("on"+e,function o(a){r&&t.detachEvent("on"+e,o),n.call(this,a)}),this},off:function(t,e,n){return n?(t.removeEventListener?t.removeEventListener(e,n):t.detachEvent&&t.detachEvent(e,n),this):this},delay:function(t,e){return-1===e?(t(),null):setTimeout(t,e||0)},ext:function(t){for(var e=1,n=arguments.length;e<n;e++){var r=arguments[e];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a])}return t},sub:function(t,e){var n={};return this.each(t,function(t,r){-1!==e.indexOf(r)&&(n[r]=t)}),n},uu:function(){for(var t,e,n=20,r=new Array(n),a=Date.now().toString(36).split("");n-- >0;)e=(t=36*Math.random()|0).toString(36),r[n]=t%3?e:e.toUpperCase();for(var o=0;o<8;o++)r.splice(3*o+2,0,a[o]);return r.join("")},seq:function(){return(r++).toString(36)},encode:function(t,e){try{t=e?encodeURIComponent(t).replace(/\(/g,"%28").replace(/\)/g,"%29"):encodeURIComponent(t)}catch(n){}return t},serialize:function(t){t=t||{};var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&t[n]!==undefined&&e.push(n+"="+this.encode(t[n],"msg"===n));return e.join("&")},$b4:function(t,e){if(!t||"string"!=typeof t)return!1;var n=/arms-retcode[\w-]*\.aliyuncs/.test(t);return!n&&e&&(n=/(\.png)|(\.gif)|(alicdn\.com)/.test(t)),!n},$ax:function(t){return!(!t||!t.message)&&!/failed[\w\s]+fetch/i.test(t.message)},$al:function(t){return t&&"string"==typeof t?t.replace(/^(https?:)?\/\//,"").replace(/\?.*$/,""):""},$au:function(t){return function(){return t+"() { [native code] }"}},checkSameOrigin:function(t,e){if(!e||!t)return!1;if(/^(http|https):\/\//.test(t)){var n=t.split("/");return(t=n[0]+"//"+n[2])===e}return!0},getRandIP:function(){for(var t=[],e=0;e<4;e++){var n=Math.floor(256*Math.random());t[e]=(n>15?"":"0")+n.toString(16)}return t.join("")},getSortNum:function(t){return t?(t+=1)>=1e3&&t<=9999?t:t<1e3?t+1e3:t%1e4+1e3:1e3},getRandNum:function(t){if(t.length<5){for(var e=[],n=0;n<5;n++){var r=Math.floor(16*Math.random());e[n]=r.toString(16)}return e.join("")}return t.substring(t.length-5)}};e.exports=o},{}]},{},[12]); | ||
/** retcode cloud sdk | @version 1.4.2 | @copyright Alibaba Group Holding Limited. */ !function(){function t(e,n,r){function a(i,s){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!s&&c)return c(i,!0);if(o)return o(i,!0);var u=new Error("Cannot find module '"+i+"'");throw u.code="MODULE_NOT_FOUND",u}var f=n[i]={exports:{}};e[i][0].call(f.exports,function(t){return a(e[i][1][t]||t)},f,f.exports,t,e,n,r)}return n[i].exports}for(var o="function"==typeof require&&require,i=0;i<r.length;i++)a(r[i]);return a}return t}()({1:[function(t,e,n){var r=t("./util"),a=function(t){return this.ver="1.4.2",this._conf=r.ext({},a.dftCon),this.$a5={},this.$a1=[],this.hash=r.seq(),this.$a6(),this.setConfig(t),this.rip=r.getRandIP(),this.record=999,this["EagleEye-TraceID"]=this.getTraceId()["EagleEye-TraceID"],this};a.dftCon={sample:1,tag:""},a.prototype={constructor:a,$a2:function(t){return t()},$a7:function(){var t=this._conf.page;return r.$a8(t,[],t+"")},setPage:function(){},setConfig:function(t){t&&"object"==typeof t&&(r.$a9(t),this._conf=r.ext({},this._conf,t))},$aa:function(){},$ab:function(){},$ac:function(){return{}},$a6:function(){this.session=r.uu(),this.sBegin=Date.now()},getTraceId:function(){var t=this.rip,e=Date.now(),n=r.getSortNum(this.record),a=t+e+n+r.getRandNum(this._conf.pid);return this["EagleEye-TraceID"]=a,this.record=n,{"EagleEye-TraceID":a}},getSessionId:function(){return{"EagleEye-SessionID":this.session}},getConfig:function(t){return t?this._conf[t]:r.ext({},this._conf)},$ad:function(t){return 1===t||("boolean"==typeof this.$a5[t]?this.$a5[t]:(this.$a5[t]=r.pick(t),this.$a5[t]))},$a4:function(){var t;for(clearTimeout(this.$a3),this.$a3=null;t=this.$a1.pop();)"res"===t.t?this.$ab(t,"res"):this.$aa(t);return this},_lg:function(t,e,n){var a=this._conf;return e&&!a.disabled&&a.pid?n&&!this.$ad(n)?this:(e=r.ext({t:t,times:1,page:this.$a7(),tag:a.tag||"",begin:Date.now()},e,this.$ac(),{pid:a.pid,_v:this.ver,sid:this.session,sampling:n||1,z:r.seq()}),function(t,e){var n;"error"===e.t&&(n=t.$a1[0])&&"error"===n.t&&e.msg===n.msg?n.times++:(t.$a1.unshift(e),t.$a2(function(){t.$a3=r.delay(function(){t.$a4()},"error"===e.t?3e3:-1)}))}(this,e)):this},custom:function(t,e){if(!t||"object"!=typeof t)return this;var n=!1,a={begin:Date.now()};return r.each(t,function(t,e){return!(n=e&&e.length<=20)&&r.warn("[retcode] invalid key: "+e),a["x-"+e]=t,n}),n?this._lg("custom",a,e||1):this}},e.exports=a},{"./util":14}],2:[function(t,e,n){var r=t("../util"),a=t("../reporter"),o=t("../common/sender"),i=t("../common/post"),s=r.win,c=s.document,u=/^(error|api|speed|sum|avg|percent|custom|msg|setPage|setConfig)$/,f=function(t){var e=this;return a.call(e,t),e._initialPage=t.page&&r.$a8(t.page,[],t.page+"")||null,e._health={errcount:0,apisucc:0,apifail:0},e.$ae=function(t,n){"error"===t?e._health.errcount++:"api"===t&&e._health[n.success?"apisucc":"apifail"]++},e.$af(),e.$ag(),e.$ah(1e4),Object.defineProperty&&s.addEventListener&&Object.defineProperty(e,"pipe",{set:e.$ai}),e};f.prototype=r.$aj(a.prototype),r.ext(a._root.dftCon,{uid:null,ignoreUrlPath:[{rule:/\/([a-z\-_]+)?\d{2,20}/g,target:"/$1**"},/\/$/],ignoreApiPath:{rule:/(\w+)\/\d{2,}/g,target:"$1"},ignoreUrlCase:!0,imgUrl:"https://arms-retcode.aliyuncs.com/r.png?",disableHook:!1,autoSendPv:!0,enableSPA:!1,enableLinkTrace:!1,sendResource:!0,parseHash:function(t){return(t?r.$al(t.replace(/^#\/?/,"")):"")||"[index]"},parseResponse:function(t){if(!t||"object"!=typeof t)return{};var e=t.code,n=t.msg||t.message||t.subMsg||t.errorMsg||t.ret||t.errorResponse||"";return"object"==typeof n&&(e=e||n.code,n=n.msg||n.message||n.info||n.ret||JSON.stringify(n)),{msg:n,code:e,success:!0}}}),r.ext(f.prototype,{constructor:f,_super:a,$a2:function(t){var e=this;if(e.hasReady)return t();"complete"===c.readyState?(e.hasReady=!0,t()):r.on(s,"load",function(){e.hasReady=!0,t()},!0)},$a7:function(t){var e=this._conf,n=e.page,a=location,o=a.host+a.pathname;return n&&!t?r.$a8(n,[],n+""):this._initialPage||r.$ak(e.ignoreUrlCase?o.toLowerCase():o,e.ignoreUrlPath)},setPage:function(t,e){var n=this,r=n.$am;if(!1!==e){if(!t||t===r)return n;n.$am=t,clearTimeout(n.$an),n.$ao(1),n.$a6(),n.$an=setTimeout(function(){n.$ap()},10)}else n.$am=t;return n._conf.page=t,n},setConfig:function(t,e){if(t&&"object"==typeof t){r.$a9(t);var n=this._conf;if(this._conf=r.ext({},n,t),!e){var a="disableHook";a in t&&n[a]!==t[a]&&(t[a]?this.removeHook():this.addHook()),(a="enableSPA")in t&&n[a]!==t[a]&&this.$aq(t[a])}}},$aa:function(t){o(t,this.getConfig("imgUrl"))},$ab:function(t,e){var n={};n[e]=t[e],delete t[e];var a="";"object"==typeof t&&(a=r.serialize(t)),i(n,this.getConfig("imgUrl")+a+"&post_res=")},$ai:function(t){var e=this;if(!t||!t.length)return e;try{if("Array"===r.T(t[0]))return r.each(t,function(t){return e.$ai(t)});if("Array"!==r.T(t))return e;var n=t.shift();if(!u.test(n))return e;e[n].apply(e,t)}catch(a){return r.warn("[retcode] error in sendPipe",a),e}},$ar:function(){var t=r.ext({},this._health);t.healthy=t.errcount>0?0:1,t.begin=Date.now();var e=t.begin-this.sBegin;t.stay=e,this._lg("health",t,1),this._health={errcount:0,apisucc:0,apifail:0}},createInstance:function(t){t=r.ext({pid:this._conf.pid},t);var e=this.__proto__.constructor(t);return t.page&&e.$ap(),e}}),t("./handler")(f,s,c),t("./fmp")(f,s,c),t("./hook")(f,s),t("./hack")(f,s),f._super=a,f._root=a._root,a.Browser=f,e.exports=f},{"../common/post":9,"../common/sender":11,"../reporter":13,"../util":14,"./fmp":3,"./hack":4,"./handler":5,"./hook":6}],3:[function(t,e,n){var r=t("../util"),a=500;e.exports=function(t,e,n){function o(t,e,n){var r=0,a=t.tagName;if("SCRIPT"!==a&&"STYLE"!==a&&"META"!==a&&"HEAD"!==a){var i=t.children?t.children.length:0;if(i>0)for(var c=t.children,u=i-1;u>=0;u--)r+=o(c[u],e+1,r>0);if(r<=0&&!n){if(!(t.getBoundingClientRect&&t.getBoundingClientRect().top<s))return 0}r+=1+.5*e}return r}function i(t){for(var e=1;e<t.length;e++)if(t[e].score<t[e-1].score)return t.splice(e,1),i(t);return t}var s=e.innerHeight||0,c=[],u=null,f=0;r.ext(t.prototype,{$ah:function(t){var a=this;if(!a._conf||!a._conf.useFmp)return null;if(!e.MutationObserver)return r.warn("[retcode] first meaningful paint can not be retrieved"),a.$as(),null;r.on(e,"beforeunload",function(){a.$at(0,!0)});var i=e.MutationObserver;return(u=new i(function(){!function(t){var e=Date.now()-t,r=n.querySelector("body");if(r){var a=0;a+=o(r,1,!1),c.push({score:a,t:e})}else c.push({score:0,t:e})}(a._startTime)})).observe(document,{childList:!0,subtree:!0}),f=1,a.$a2(function(){a.$at(t)}),u},$at:function(t,e){var n=this;if(u&&f)if(e||!function(t,e){var n=Date.now()-t;return!(n>e||n-(c&&c.length&&c[c.length-1].t||0)>2*a)}(n._startTime,t)){u.disconnect(),f=0,c=i(c);for(var o=null,s=1;s<c.length;s++)if(c[s].t>=c[s-1].t){var l=c[s].score-c[s-1].score;(!o||o.rate<=l)&&(o={t:c[s].t,rate:l})}o&&o.t>0?n.$as({fmp:o.t}):n.$as()}else r.delay(function(){n.$at(t)},a)}})}},{"../util":14}],4:[function(t,e,n){e.exports=function(e,n){var r=t("../util"),a=n.history||{},o=n.document,i=function(t,e){var r;n.CustomEvent?r=new CustomEvent(t,{detail:e}):((r=o.createEvent("HTMLEvents")).initEvent(t,!1,!0),r.detail=e),n.dispatchEvent(r)},s=function(t){var e=a[t];"function"==typeof e&&(a[t]=function(n,o,s){var c=1===arguments.length?[arguments[0]]:Array.apply(null,arguments),u=location.href,f=e.apply(a,c);if(!s||"string"!=typeof s)return f;if(s===u)return f;try{var l=u.split("#"),p=s.split("#"),h=r.$al(l[0]),d=r.$al(p[0]),g=l[1]&&l[1].replace(/^\/?(.*)/,"$1"),v=p[1]&&p[1].replace(/^\/?(.*)/,"$1");h!==d?i("historystatechange",d):g!==v&&i("historystatechange",v)}catch(y){r.warn("[retcode] error in "+t+": "+y)}return f},a[t].toString=r.$au(t))};r.ext(e.prototype,{$av:function(){return this.$aw?this:(s("pushState"),s("replaceState"),this.$aw=!0,this)}})}},{"../util":14}],5:[function(t,e,n){e.exports=function(e,n,r){var a=t("../util"),o=t("../common/perf"),i=t("../common/res"),s=null,c=r.documentElement,u=n.innerWidth||c.clientWidth||r.body.clientWidth,f=n.innerHeight||c.clientHeight||r.body.clientHeight,l=n.navigator.connection,p={sr:screen.width+"x"+screen.height,vp:u+"x"+f,ct:l?l.effectiveType||l.type:""},h={},d=function(t,e,n,o,i){if(e===undefined){var s,c;if(!h[t]){s=new RegExp(t+"=([^;]+)");try{c=s.exec(r.cookie)}catch(f){return a.warn("[retcode] can not get cookie:",f),null}c&&(h[t]=c[1])}return h[t]}var u=t+"="+e;o&&(u+="; domain="+o),i&&(u+="; path="+i),n&&(u+="; max-age="+n);try{return r.cookie=u,!!r.cookie}catch(f){return a.warn("[retcode] can not set cookie: ",f),!1}},g=function(t){var e=t._conf.uid||d("_nk_")||d("_bl_uid");if(!e){e=a.uu();if(!d("_bl_uid",e,15552e3))return null}return e};return a.ext(e.prototype,{activeErrHandler:function(t){return s&&!t?this:(s=this,this)},errorHandler:function(t){if(!t)return this;var e=t.type;return"error"===e?this.error(t.error||{message:t.message},t):"unhandledrejection"===e&&a.T(t.reason,"Error")&&a.$ax(t.reason)&&this.error(t.reason),this},$as:function(t){var e=this;e.$a2(function(){var n=o();n&&(n.page=e.$a7(!0),t&&(n=a.ext(n,t)),e._lg("perf",n,e.getConfig("sample")))})},$ay:function(t){var e=this;e.$a2(function(){var n=i();n&&(n.load&&n.load<=2e3||n.load&&n.load<=8e3&&Math.random()>.05||(n.page=e.$a7(!0),n.dl=location.href,t&&(n=a.ext(n,t)),e._lg("res",n,e.getConfig("sample"))))})},$ap:function(){var t=this;t.$a2(function(){var e=function(t){var e=g(t),a=n.devicePixelRatio||1;return{uid:e,dt:r.title,dl:location.href,dr:r.referrer,dpr:a.toFixed(2),de:(r.characterSet||r.defaultCharset||"").toLowerCase(),ul:c.lang,begin:Date.now()}}(t);e&&e.uid&&t._lg("pv",e)})},$ac:function(){return p.uid=g(this),p},$ao:function(t){var e=Date.now();if(e-this._lastUnload<200)return this;this._lastUnload=e,this.$ar(t),this.$az&&(this._lg("speed",this.$az),this.$az=null,clearTimeout(this.$b0)),this.$a4()},$aq:function(t){var e=this;if(!t^e.$b1)return e;t?(e.$av(),e.$b1=function(t){var n=e._conf.parseHash(location.hash);n&&e.setPage(n,!1!==t)},e.$b2=function(t){var n=e._conf.parseHash(t.detail);n&&e.setPage(n)},a.on(n,"hashchange",e.$b1),a.on(n,"historystatechange",e.$b2),e.$b1(!1)):(a.off(n,"hashchange",e.$b1),a.off(n,"historystatechange",e.$b2),e.$b1=null,e.$b2=null)},$af:function(){var t=this;if(t.$b3)return t;var e=t._conf;return a.on(n,"beforeunload",function(){t.$ao(0)}),t.$aq(e.enableSPA),t.activeErrHandler(!1),t.$b3=!0,t}}),a.on(n,"error",function(t){s&&s.errorHandler(t)}).on(n,"unhandledrejection",function(t){s&&s.errorHandler(t)}),e}},{"../common/perf":8,"../common/res":10,"../util":14}],6:[function(t,e,n){e.exports=function(e,n){var r=t("../util"),a=null,o=function(t,e,n,a,o,i,s,c,u,f){var l=r.J(o)||null,p=r.$a8(e,[l,a],null);if(!p)return!1;var h=p.code||i,d=!("success"in p)||p.success;t.api(n,d,s,h,p.msg,c,u,f)},i="fetch",s="__oFetch_",c="__oXMLHttpRequest_",u="XMLHttpRequest";return r.ext(e.prototype,{removeHook:function(t,e){return a&&(e||this===a)?(n[s]&&(n[i]=n[s],delete n[s]),n[c]&&(n[u]=n[c],delete n[c]),a=null,this):this},addHook:function(t){return!t&&a?this:(a||(function(){if("function"==typeof n[i]){var t=n[i];n[s]=t,n[i]=function(e,i){var s=1===arguments.length?[arguments[0]]:Array.apply(null,arguments),c=a;if(!c||!c.api)return t.apply(n,s);if(i&&("HEAD"===i.method||"no-cors"===i.mode))return t.apply(n,s);var u=Date.now(),f=c._conf,l=(e&&"string"!=typeof e?e.url:e)||"",p=l;if(l=r.$al(l),!r.$b4(l,!0))return t.apply(n,s);l=r.$ak(l,f.ignoreApiPath);var h="",d="";if(f.enableLinkTrace){var g="";try{g=location.origin?location.origin:location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")}catch(m){g=""}if(r.checkSameOrigin(p,g)){if(e&&"string"!=typeof e)try{if(s[0].headers&&"function"==typeof s[0].headers.get&&"function"==typeof s[0].headers.append){var v=s[0].headers.get("EagleEye-TraceID"),y=s[0].headers.get("EagleEye-SessionID");v?h=v:(h=c.getTraceId()["EagleEye-TraceID"],s[0].headers.append("EagleEye-TraceID",h)),y?d=y:(d=c.getSessionId()["EagleEye-SessionID"],s[0].headers.append("EagleEye-SessionID",d))}}catch($){r.warn("[retcode] fetch failed to set header, exception is :\n"+$)}i&&(i.headers=i.headers?i.headers:{},i.headers["EagleEye-TraceID"]?h=i.headers["EagleEye-TraceID"]:(h=c.getTraceId()["EagleEye-TraceID"],i.headers["EagleEye-TraceID"]=h),i.headers["EagleEye-SessionID"]?d=i.headers["EagleEye-SessionID"]:(d=c.getTraceId()["EagleEye-SessionID"],i.headers["EagleEye-SessionID"]=d))}}return t.apply(n,s).then(function(t){if(!c||!c.api)return t;var e=t.clone(),n=e.headers;if(n&&"function"==typeof n.get){var r=n.get("content-type");if(r&&!/(text)|(json)/.test(r))return t}var a=Date.now()-u;return e.ok?e.text().then(function(t){o(c,f.parseResponse,l,p,t,e.status||200,a,u,h,d)}):c.api(l,!1,a,e.status||404,e.statusText,u,h,d),t})["catch"](function(t){if(!c||!c.api)throw t;var e=Date.now()-u;throw c.api(l,!1,e,t.name||"Error",t.message,u,h,d),t})},n[i].toString=r.$au(i)}}(),function(){if("function"==typeof n[u]){var t=n[u];n[c]=t,n[u]=function(e){var n=new t(e),i=a;if(!i||!i.api||!n.addEventListener)return n;var s,c,u,f=n.send,l=n.open,p=n.setRequestHeader,h=i._conf,d=i.getConfig("enableLinkTrace"),g="",v="";return n.open=function(t,e){var a=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);if(l.apply(n,a),u=e||"",c=r.$al(u),c=c?r.$ak(c,h.ignoreApiPath):"",d){var o="";try{o=location.origin?location.origin:location.protocol+"//"+location.hostname+(location.port?":"+location.port:"")}catch(s){o=""}r.checkSameOrigin(u,o)&&p&&"function"==typeof p&&(g=i.getTraceId()["EagleEye-TraceID"],p.apply(n,["EagleEye-TraceID",g]),v=i.getSessionId()["EagleEye-SessionID"],p.apply(n,["EagleEye-SessionID",v]))}},n.send=function(){s=Date.now();var t=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);f.apply(n,t)},r.on(n,"readystatechange",function(){if(c&&4===n.readyState){var t=Date.now()-s;if(n.status>=200&&n.status<=299){var e=n.status||200;if("function"==typeof n.getResponseHeader){var r=n.getResponseHeader("Content-Type");if(r&&!/(text)|(json)/.test(r))return}n.responseType&&"text"!==n.responseType?i.api(c,!0,t,e,"",s,g,v):o(i,h.parseResponse,c,u,n.responseText,e,t,s,g,v)}else i.api(c,!1,t,n.status||"FAILED",n.statusText,s,g,v)}}),n},n[u].toString=r.$au(u)}}()),a=this,this)},$ag:function(){return this.$b5?this:(this.getConfig("disableHook")||this.addHook(),this.$b5=!0,this)}}),e}},{"../util":14}],7:[function(t,e,n){n.TIMING_KEYS=["","fetchStart","domainLookupStart","domainLookupEnd","connectStart","connectEnd","requestStart","responseStart","responseEnd","","domInteractive","","domContentLoadedEventEnd","","loadEventStart","","msFirstPaint","secureConnectionStart"]},{}],8:[function(t,e,n){var r=t("../util"),a=t("./constants").TIMING_KEYS;e.exports=function(){var t=r.win||{},e=t.performance;if(!e||"object"!=typeof e)return null;var n={},o=e.timing||{},i=Date.now(),s=1;if("function"==typeof t.PerformanceNavigationTiming){var c=e.getEntriesByType("navigation")[0];c&&(o=c,s=2)}r.each({dns:[3,2],tcp:[5,4],ssl:[5,17],ttfb:[7,6],trans:[8,7],dom:[10,8],res:[14,12],firstbyte:[7,2],fpt:[8,1],tti:[10,1],ready:[12,1],load:[14,1]},function(t,e){var r=o[a[t[1]]],i=o[a[t[0]]];if(2===s||r>0&&i>0){var c=Math.round(i-r);c>=0&&c<36e5&&(n[e]=c)}});var u=t.navigator.connection,f=e.navigation||{};n.ct=u?u.effectiveType||u.type:"";var l=u?u.downlinkMax||u.bandwidth||-1:-1;return l=l>999?999:l,n.bandwidth=l,n.navtype=1===f.type?"Reload":"Other",1===s&&o[a[16]]>0&&o[a[1]]>0&&(n.fpt=o[a[16]]-o[a[1]]),1===s&&o[a[1]]>0?n.begin=o[a[1]]:2===s&&n.load>0?n.begin=i-n.load:n.begin=i,n}},{"../util":14,"./constants":7}],9:[function(t,e,n){var r=t("../util"),a="object"==typeof window?window:{},o=a.__oXMLHttpRequest_||a.XMLHttpRequest;o="function"==typeof o?o:undefined,e.exports=function(t,e){try{var n=new o;n.open("POST",e,!0),n.setRequestHeader("Content-Type","text/plain"),n.send(JSON.stringify(t))}catch(a){r.warn("[retcode] Failed to log, exception is :\n"+a)}}},{"../util":14}],10:[function(t,e,n){var r=t("../util"),a=t("./constants").TIMING_KEYS;e.exports=function(){var t=r.win||{},e=t.performance;if(!e||"object"!=typeof e||"function"!=typeof e.getEntriesByType)return null;var n={},o=e.timing||{},i=e.getEntriesByType("resource")||[];if(n.begin=o[a[1]]||Date.now(),"function"==typeof t.PerformanceNavigationTiming){var s=e.getEntriesByType("navigation")[0];s&&(o=s)}return r.each({dom:[10,8],load:[14,1]},function(t,e){var r=o[a[t[1]]],i=o[a[t[0]]];if(r>0&&i>0){var s=Math.round(i-r);s>=0&&s<36e5&&(n[e]=s)}}),n.res=JSON.stringify(i),n}},{"../util":14,"./constants":7}],11:[function(t,e,n){var r=t("../util"),a="object"==typeof window?window:{},o=a.__oFetch_||a.fetch;o="function"==typeof o?o:undefined,e.exports=function(t,e){var n=-1;"object"==typeof t&&(n=t.z,t=r.serialize(t));var i=e+t;if(o)return o(i,{method:"HEAD",mode:"no-cors"})["catch"](r.noop);if(a.document&&a.document.createElement){var s="__request_hold_"+n,c=a[s]=new Image;c.onload=c.onerror=function(){a[s]=undefined},c.src=i,c=null}}},{"../util":14}],12:[function(t,e,n){"use strict";function r(t,e){var n=a[i]=new o(t);n.$ai(e);var r=n._conf;return!1!==r.autoSendPv&&n.$ap(),r&&r.useFmp||n.$as(),r&&r.sendResource&&n.$ay(),a[s]=!0,n}var a=window,o=a.BrowserLogger=t("./biz.browser/clazz"),i=t("./util").key,s="__hasInitBlSdk";o.singleton=function(t,e){return a[s]?a[i]:r(t,e)};"object"==typeof window&&!!window.navigator&&a[i]&&(o.bl=function(){if(a[s])return a[i];var t={},e=[];return i in a&&(t=a[i].config||{},e=a[i].pipe||[]),r(t,e)}(a.__hasInitBlSdk)),e.exports=o},{"./biz.browser/clazz":2,"./util":14}],13:[function(t,e,n){var r=t("./util"),a=t("./base"),o=["api","success","time","code","msg","trace","traceId","begin","sid","seq"],i=function(t,e){var n=t.split("::");return n.length>1?r.ext({group:n[0],key:n[1]},e):r.ext({group:"default_group",key:n[0]},e)},s=function(t){a.call(this,t);var e;try{e="object"==typeof performance?performance.timing.fetchStart:Date.now()}catch(n){e=Date.now()}return this._startTime=e,this};s.prototype=r.$aj(a.prototype),r.ext(a.dftCon,{startTime:null}),r.ext(s.prototype,{constructor:s,_super:a,sum:function(t,e,n){try{return this._lg("sum",i(t,{val:e||1,begin:Date.now()}),n)}catch(a){r.warn("[retcode] can not get parseStatData: "+a)}},avg:function(t,e,n){try{return this._lg("avg",i(t,{val:e||0,begin:Date.now()}),n)}catch(a){r.warn("[retcode] can not get parseStatData: "+a)}},percent:function(t,e,n,a){try{return this._lg("percent",i(t,{subkey:e,val:n||0,begin:Date.now()}),a)}catch(o){r.warn("[retcode] can not get parseStatData: "+o)}},msg:function(t,e){if(t&&!(t.length>180))return this.custom({msg:t},e)},error:function(t,e){if(!t||"object"!=typeof t||"string"!=typeof t.message)return r.warn("[retcode] invalid param e: "+t),this;var n=t.name||"CustomError",a=t.message,o=t.stack||"";e=e||{},o=o&&o.substring(0,1e3);var i={begin:Date.now(),cate:n,msg:a.substring(0,1e3),stack:o,file:e.filename||"",line:e.lineno||"",col:e.colno||""};return this.$ae&&this.$ae("error",i),this._lg("error",i,1)},api:function(t,e,n,a,i,s,c,u){return t?(t="string"==typeof t?{api:t,success:e,time:n,code:a,msg:i,begin:s,traceId:c,sid:u}:r.sub(t,o),r.$b4(t.api)?(t.code=t.code||"",t.msg=t.msg||"",t.success=t.success?1:0,t.time=+t.time,t.begin=t.begin,t.traceId=t.traceId||"",t.sid=t.sid||"",!t.api||isNaN(t.time)?(r.warn("[retcode] invalid time or api"),this):(this.$ae&&this.$ae("api",t),this._lg("api",t,t.success&&this.getConfig("sample")))):this):(r.warn("[retcode] api is null"),this)},speed:function(t,e,n){var a=this,o=this.getConfig("startTime")||this._startTime;return/^s(\d|1[0])$/.test(t)?(e="number"!=typeof e?Date.now()-o:e>=o?e-o:e,a.$az=a.$az||{},a.$az[t]=e,a.$az.begin=o,clearTimeout(a.$b0),a.$b0=setTimeout(function(){n||(a.$az.page=a.$a7(!0)),a._lg("speed",a.$az),a.$az=null},5e3),a):(r.warn("[retcode] invalid point: "+t),a)}}),s._super=a,s._root=a,a.Reporter=s,e.exports=s},{"./base":1,"./util":14}],14:[function(t,e,n){Date.now=Date.now||function(){return(new Date).getTime()};var r=Date.now(),a=function(){},o={noop:a,warn:function(){var t="object"==typeof console?console.warn:a;try{var e={warn:t};e.warn.call(e)}catch(n){return a}return t}(),key:"__bl",win:"object"==typeof window&&window.document?window:undefined,$aj:function(t){if(Object.create)return Object.create(t);var e=function(){};return e.prototype=t,new e},each:function(t,e){var n=0,r=t.length;if(this.T(t,"Array"))for(;n<r&&!1!==e.call(t[n],t[n],n);n++);else for(n in t)if(!1===e.call(t[n],t[n],n))break;return t},$a8:function(t,e,n){if("function"!=typeof t)return n;try{return t.apply(this,e)}catch(r){return n}},T:function(t,e){var n=Object.prototype.toString.call(t).substring(8).replace("]","");return e?n===e:n},$ak:function(t,e){if(!t)return"";if(!e)return t;var n=this,r=n.T(e);return"Function"===r?n.$a8(e,[t],t):"Array"===r?(this.each(e,function(e){t=n.$ak(t,e)}),t):"Object"===r?t.replace(e.rule,e.target||""):t.replace(e,"")},J:function(t){if(!t||"string"!=typeof t)return t;var e=null;try{e=JSON.parse(t)}catch(n){}return e},pick:function(t){return 1===t||1===Math.ceil(Math.random()*t)},$a9:function(t){if("sample"in t){var e=t.sample,n=e;e&&/^\d+(\.\d+)?%$/.test(e)&&(n=parseInt(100/parseFloat(e))),0<n&&1>n&&(n=parseInt(1/n)),n>=1&&n<=100?t.sample=n:delete t.sample}return t},on:function(t,e,n,r){return t.addEventListener?t.addEventListener(e,function a(o){r&&t.removeEventListener(e,a,!1),n.call(this,o)},!1):t.attachEvent&&t.attachEvent("on"+e,function o(a){r&&t.detachEvent("on"+e,o),n.call(this,a)}),this},off:function(t,e,n){return n?(t.removeEventListener?t.removeEventListener(e,n):t.detachEvent&&t.detachEvent(e,n),this):this},delay:function(t,e){return-1===e?(t(),null):setTimeout(t,e||0)},ext:function(t){for(var e=1,n=arguments.length;e<n;e++){var r=arguments[e];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a])}return t},sub:function(t,e){var n={};return this.each(t,function(t,r){-1!==e.indexOf(r)&&(n[r]=t)}),n},uu:function(){for(var t,e,n=20,r=new Array(n),a=Date.now().toString(36).split("");n-- >0;)e=(t=36*Math.random()|0).toString(36),r[n]=t%3?e:e.toUpperCase();for(var o=0;o<8;o++)r.splice(3*o+2,0,a[o]);return r.join("")},seq:function(){return(r++).toString(36)},encode:function(t,e){try{t=e?encodeURIComponent(t).replace(/\(/g,"%28").replace(/\)/g,"%29"):encodeURIComponent(t)}catch(n){}return t},serialize:function(t){t=t||{};var e=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&t[n]!==undefined&&e.push(n+"="+this.encode(t[n],"msg"===n));return e.join("&")},$b4:function(t,e){if(!t||"string"!=typeof t)return!1;var n=/arms-retcode[\w-]*\.aliyuncs/.test(t);return!n&&e&&(n=/(\.png)|(\.gif)|(alicdn\.com)/.test(t)),!n},$ax:function(t){return!(!t||!t.message)&&!/failed[\w\s]+fetch/i.test(t.message)},$al:function(t){return t&&"string"==typeof t?t.replace(/^(https?:)?\/\//,"").replace(/\?.*$/,""):""},$au:function(t){return function(){return t+"() { [native code] }"}},checkSameOrigin:function(t,e){if(!e||!t)return!1;if(/^(http|https):\/\//.test(t)){var n=t.split("/");return(t=n[0]+"//"+n[2])===e}return!0},getRandIP:function(){for(var t=[],e=0;e<4;e++){var n=Math.floor(256*Math.random());t[e]=(n>15?"":"0")+n.toString(16)}return t.join("")},getSortNum:function(t){return t?(t+=1)>=1e3&&t<=9999?t:t<1e3?t+1e3:t%1e4+1e3:1e3},getRandNum:function(t){if(t.length<5){for(var e=[],n=0;n<5;n++){var r=Math.floor(16*Math.random());e[n]=r.toString(16)}return e.join("")}return t.substring(t.length-5)}};e.exports=o},{}]},{},[12]); |
{ | ||
"name": "alife-logger", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"description": "retcode cloud sdk", | ||
@@ -5,0 +5,0 @@ "exports": "__bl", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
98546