alife-logger
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -70,3 +70,3 @@ /** ************************* | ||
*/ | ||
that.ver = '1.2.1'; | ||
that.ver = '1.2.2'; | ||
@@ -73,0 +73,0 @@ // ---------- private variables ----------- |
@@ -372,3 +372,3 @@ /** ************************* | ||
var stay = Date.now() - that.sBegin; | ||
if (stay >= 10) { | ||
if (stay >= 2e3) { | ||
data.stay = stay; | ||
@@ -375,0 +375,0 @@ that._lg('health', data, 1); |
@@ -217,3 +217,3 @@ /** | ||
var that = this; | ||
var now = Date.now(); | ||
@@ -220,0 +220,0 @@ // 需要处理手动改地址栏的 hash 后,同时触发 beforeunload 和 hashchange 的问题 |
@@ -15,3 +15,2 @@ | ||
var perfModel = require('../common/perf'); | ||
var BrowserLogger = require('../index'); | ||
var env = require('./env'); | ||
@@ -364,4 +363,3 @@ | ||
} else { | ||
singleton = (env.isH5)? (new BrowserLogger(props)):(new WeexLogger(props)); | ||
singleton = new WeexLogger(props); | ||
util.win && (util.win[key] = singleton); | ||
@@ -368,0 +366,0 @@ } |
@@ -1,1 +0,1 @@ | ||
/** retcode cloud sdk | @version 1.2.1 | @copyright Alibaba Group Holding Limited. */ !function t(e,n,r){function a(o,s){if(!n[o]){if(!e[o]){var c="function"==typeof require&&require;if(!s&&c)return c(o,!0);if(i)return i(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var f=n[o]={exports:{}};e[o][0].call(f.exports,function(t){var n=e[o][1][t];return a(n||t)},f,f.exports,t,e,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)a(r[o]);return a}({1:[function(t,e,n){var r=t("./util"),a=function(t){return this.ver="1.2.1",this._conf=r.ext({},a.dftCon),this.$a5={},this.$a1=[],this.hash=r.seq(),this.$a6(),this.setConfig(t),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){r.$a9(t),this._conf=r.ext({},this._conf,t)},$aa:function(){},$ab:function(){return{}},$a6:function(){this.session=r.uu(),this.sBegin=Date.now()},getConfig:function(t){return t?this._conf[t]:r.ext({},this._conf)},$ac: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();)this.$aa(t);return this},_lg:function(t,e,n){var a=this._conf;return n=n||a.sample,e&&!a.disabled&&a.pid&&this.$ac(n)?(e=r.ext({t:t,times:1/n,page:this.$a7(),tag:a.tag||""},e,this.$ab(),{pid:a.pid,_v:this.ver,sid:this.session,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={};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":10}],2:[function(t,e,n){var r=t("../util"),a=t("../reporter"),i=t("../common/sender"),o=r.win,s=o.document,c=/^(error|api|speed|sum|avg|percent|custom|msg|setPage|setConfig)$/,u=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.$ad=function(t,n){"error"===t?e._health.errcount++:"api"===t&&e._health[n.success?"apisucc":"apifail"]++},e.$ae(),e.$af(),Object.defineProperty&&o.addEventListener&&Object.defineProperty(e,"pipe",{set:e.$ag}),e};u.prototype=r.$ah(a.prototype),r.ext(a._root.dftCon,{uid:null,ignoreUrlPath:[{rule:/^(([\w\.-]+){2,6})(\:\d{4,5})?((\/[\w\.%-]+){2})\/.*$/,target:"$1$3$4"},{rule:/\/([a-z\-_]+)?\d{2,20}/g,target:"/$1**"},/\/$/],ignoreApiPath:{rule:/(\w+)\/\d{2,}/g,target:"$1"},imgUrl:"https://arms-retcode.aliyuncs.com/r.png?",disableHook:!1,autoSendPv:!0,enableSPA:!1,parseHash:function(t){return(t?r.$aj(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(u.prototype,{constructor:u,_super:a,$a2:function(t){var e=this;if(e.hasReady)return t();"complete"===s.readyState?(e.hasReady=!0,t()):r.on(o,"load",function(){e.hasReady=!0,t()},!0)},$a7:function(t){var e=this._conf,n=e.page,a=location;return n&&!t?r.$a8(n,[],n+""):this._initialPage||r.$ai(a.host+a.pathname,e.ignoreUrlPath)},setPage:function(t,e){var n=this,r=n.$ak;if(!1!==e){if(!t||t===r)return n;n.$ak=t,clearTimeout(n.$al),n.$am(1),n.$a6(),n.$al=setTimeout(function(){n.$an()},10)}else n.$ak=t;return n._conf.page=t,n},setConfig:function(t,e){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.$ao(t[a])}},$aa:function(t){i(t,this.getConfig("imgUrl"))},$ag: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.$ag(t)});if("Array"!==r.T(t))return e;var n=t.shift();if(!c.test(n))return e;e[n].apply(e,t)}catch(a){return r.warn("[retcode] error in sendPipe",a),e}},$ap:function(){var t=r.ext({},this._health);t.healthy=t.errcount>0?0:1;var e=Date.now()-this.sBegin;e>=10&&(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.__propt__.constructor(t);return t.page&&e.$an(),e}}),t("./handler")(u,o,s),t("./hook")(u,o),t("./hack")(u,o),u._super=a,u._root=a._root,a.Browser=u,e.exports=u},{"../common/sender":7,"../reporter":9,"../util":10,"./hack":3,"./handler":4,"./hook":5}],3:[function(t,e,n){e.exports=function(e,n){var r=t("../util"),a=n.history||{},i=n.document,o=function(t,e){var r;n.CustomEvent?r=new CustomEvent(t,{detail:e}):((r=i.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,i,s){var c=location.href,u=e.call(a,n,i,s);if(!s||"string"!=typeof s)return u;if(s===c)return u;try{var f=c.split("#"),l=s.split("#"),h=r.$aj(f[0]),p=r.$aj(l[0]),d=f[1]&&f[1].replace(/^\/?(.*)/,"$1"),v=l[1]&&l[1].replace(/^\/?(.*)/,"$1");h!==p?o("historystatechange",p):d!==v&&o("historystatechange",v)}catch(g){r.warn("[retcode] error in "+t+": "+g)}return u},a[t].toString=r.$aq(t))};r.ext(e.prototype,{$ar:function(){return this.$as?this:(s("pushState"),s("replaceState"),this.$as=!0,this)}})}},{"../util":10}],4:[function(t,e,n){e.exports=function(e,n,r){var a=t("../util"),i=t("../common/perf"),o=null,s=r.documentElement,c=n.innerWidth||s.clientWidth||r.body.clientWidth,u=n.innerHeight||s.clientHeight||r.body.clientHeight,f={sr:screen.width+"x"+screen.height,vp:c+"x"+u},l={},h=function(t,e,n,i,o){if(e===undefined){var s,c;if(!l[t]){s=new RegExp(t+"=([^;]+)");try{c=s.exec(r.cookie)}catch(f){return a.warn("[retcode] can not get cookie:",f),null}c&&(l[t]=c[1])}return l[t]}var u=t+"="+e;i&&(u+="; domain="+i),o&&(u+="; path="+o),n&&(u+="; max-age="+n);try{return r.cookie=u,!!r.cookie}catch(f){return a.warn("[retcode] can not set cookie: ",f),!1}},p=function(t){var e=t._conf.uid||h("_nk_")||h("_bl_uid");if(!e){e=a.uu();if(!h("_bl_uid",e,15552e3))return null}return e};return a.ext(e.prototype,{activeErrHandler:function(t){return o&&!t?this:(o=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.$at(t.reason)&&this.error(t.reason),this},$au:function(){var t=this;t.$a2(function(){var e=i();e&&(f.ct=e.ct,e.page=t.$a7(!0),t._lg("perf",e))})},$an:function(){var t=this;t.$a2(function(){var e=function(t){return{uid:p(t),dt:r.title,dl:location.href,dr:r.referrer,dpr:n.devicePixelRatio||1,de:(r.characterSet||r.defaultCharset||"").toLowerCase(),ul:s.lang}}(t);e&&e.uid&&t._lg("pv",e)})},$ab:function(){return f.uid=p(this),f},$am:function(t){var e=Date.now();if(e-this._lastUnload<200)return this;this._lastUnload=e,this.$ap(t),this.$av&&(this._lg("speed",this.$av),this.$av=null,clearTimeout(this.$aw)),this.$a4()},$ao:function(t){var e=this;if(!t^e.$ax)return e;t?(e.$ar(),e.$ax=function(t){var n=e._conf.parseHash(location.hash);n&&e.setPage(n,!1!==t)},e.$ay=function(t){var n=e._conf.parseHash(t.detail);n&&e.setPage(n)},a.on(n,"hashchange",e.$ax),a.on(n,"historystatechange",e.$ay),e.$ax(!1)):(a.off(n,"hashchange",e.$ax),a.off(n,"historystatechange",e.$ay),e.$ax=null,e.$ay=null)},$ae:function(){var t=this;if(t.$az)return t;var e=t._conf;return a.on(n,"beforeunload",function(){t.$am(0)}),t.$ao(e.enableSPA),t.activeErrHandler(!1),t.$az=!0,t}}),a.on(n,"error",function(t){o&&o.errorHandler(t)}).on(n,"unhandledrejection",function(t){o&&o.errorHandler(t)}),e}},{"../common/perf":6,"../util":10}],5:[function(t,e,n){e.exports=function(e,n){var r=t("../util"),a=null,i=function(t,e,n,a,i,o,s){var c=r.J(i)||null,u=r.$a8(e,[c,a],null);if(!u)return!1;var f=u.code||o,l=!("success"in u)||u.success;t.api(n,l,s,f,u.msg)},o="fetch",s="__oFetch_",c="__oXMLHttpRequest_",u="XMLHttpRequest";return r.ext(e.prototype,{removeHook:function(t,e){return a&&(e||this===a)?(n[s]&&(n[o]=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[o]){var t=n[o];n[s]=t,n[o]=function(e,o){var s=1===arguments.length?[arguments[0]]:Array.apply(null,arguments),c=a;if(!c||!c.api)return t.apply(n,s);if(o&&("HEAD"===o.method||"no-cors"===o.mode))return t.apply(n,s);var u=Date.now(),f=c._conf,l=(e&&"string"!=typeof e?e.url:e)||"",h=l;return l=r.$aj(l),r.$b0(l,!0)?(l=r.$ai(l,f.ignoreApiPath),t.apply(n,s).then(function(t){if(!c||!c.api)return t;var e=t.clone(),n=Date.now()-u;return e.ok?e.text().then(function(t){i(c,f.parseResponse,l,h,t,e.status||200,n)}):c.api(l,!1,n,e.status||404,e.statusText),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),t})):t.apply(n,s)},n[o].toString=r.$aq(o)}}(),function(){if("function"==typeof n[u]){var t=n[u];n[c]=t,n[u]=function(e){var n=new t(e),o=a;if(!o||!o.api||!n.addEventListener)return n;var s,c,u,f=n.send,l=n.open,h=o._conf;return n.open=function(t,e){var a=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);l.apply(n,a),u=e||"",c=(c=r.$aj(u))?r.$ai(c,h.ignoreApiPath):""},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;n.responseType&&"text"!==n.responseType?o.api(c,!0,t,e,""):i(o,h.parseResponse,c,u,n.responseText,e,t)}else o.api(c,!1,t,n.status||"FAILED",n.statusText)}}),n},n[u].toString=r.$aq(u)}}()),a=this,this)},$af:function(){return this.$b1?this:(this.getConfig("disableHook")||this.addHook(),this.$b1=!0,this)}}),e}},{"../util":10}],6:[function(t,e,n){var r=t("../util"),a=["","fetchStart","domainLookupStart","domainLookupEnd","connectStart","connectEnd","requestStart","responseStart","responseEnd","","domInteractive","","domContentLoadedEventEnd","","loadEventStart","","msFirstPaint","secureConnectionStart"];e.exports=function(){var t=r.win||{},e=t.performance;if(!e||"object"!=typeof e)return null;var n={},i=e.timing||{},o=1;if("function"==typeof t.PerformanceNavigationTiming){var s=e.getEntriesByType("navigation")[0];s&&(i=s,o=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=i[a[t[1]]],o=i[a[t[0]]];if(2===t||r>0&&o>0){var s=Math.round(o-r);s>=0&&s<36e5&&(n[e]=s)}});var c=t.navigator.connection,u=e.navigation||{};n.ct=c?c.effectiveType||c.type:"";var f=c?c.downlinkMax||c.bandwidth||-1:-1;return f=f>999?999:f,n.bandwidth=f,n.navtype=1===u.type?"Reload":"Other",1===o&&i[a[16]]>0&&i[a[1]]>0&&(n.fpt=i[a[16]]-i[a[1]]),n}},{"../util":10}],7:[function(t,e,n){var r=t("../util"),a="object"==typeof window?window:{},i=a.__oFetch_||a.fetch;i="function"==typeof i?i:undefined,e.exports=function(t,e){"object"==typeof t&&(t=r.serialize(t));var n=e+t;if(i)return i(n,{method:"HEAD",mode:"no-cors"})["catch"](r.noop);if(a.document&&a.document.createElement){var o="__request_hold_"+r.seq(),s=a[o]=new Image;s.onload=s.onerror=function(){a[o]=undefined},s.src=n,s=null}}},{"../util":10}],8:[function(t,e,n){"use strict";function r(t,e){var n=a[o]=new i(t);n.$ag(e);return!1!==n._conf.autoSendPv&&n.$an(),n.$au(),a[s]=!0,n}var a=window,i=a.BrowserLogger=t("./biz.browser/clazz"),o=t("./util").key,s="__hasInitBlSdk";i.singleton=function(t,e){return a[s]?a[o]:r(t,e)};"object"==typeof window&&!!window.navigator&&a[o]&&(i.bl=function(){if(a[s])return a[o];var t={},e=[];return o in a&&(t=a[o].config||{},e=a[o].pipe||[]),r(t,e)}(a.__hasInitBlSdk)),e.exports=i},{"./biz.browser/clazz":2,"./util":10}],9:[function(t,e,n){var r,a=t("./util"),i=t("./base"),o=["api","success","time","code","msg","trace","traceId"],s=function(t,e){var n=t.split("::");return n.length>1?a.ext({group:n[0],key:n[1]},e):a.ext({group:"default_group",key:n[0]},e)};try{r="object"==typeof performance?performance.timing.responseStart:Date.now()}catch(u){r=Date.now()}var c=function(t){return i.call(this,t),this};c.prototype=a.$ah(i.prototype),a.ext(i.dftCon,{startTime:null}),a.ext(c.prototype,{constructor:c,_super:i,sum:function(t,e,n){try{return this._lg("sum",s(t,{val:e||1}),n)}catch(r){a.warn("[retcode] can not get parseStatData: "+r)}},avg:function(t,e,n){try{return this._lg("avg",s(t,{val:e||0}),n)}catch(r){a.warn("[retcode] can not get parseStatData: "+r)}},percent:function(t,e,n,r){try{return this._lg("percent",s(t,{subkey:e,val:n||0}),r)}catch(i){a.warn("[retcode] can not get parseStatData: "+i)}},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 a.warn("[retcode] invalid param e: "+t),this;var n=t.name||"CustomError",r=t.message,i=t.stack||"";e=e||{},i=i&&i.substring(0,1e3);var o={cate:n,msg:r.substring(0,1e3),stack:i,file:e.filename,line:e.lineno,col:e.colno};return this.$ad&&this.$ad("error",o),this._lg("error",o,1)},api:function(t,e,n,r,i){return t?(t="string"==typeof t?{api:t,success:e,time:n,code:r,msg:i}:a.sub(t,o),a.$b0(t.api)?(t=a.ext({code:"",msg:""},t),t.success=t.success?1:0,t.time=+t.time,!t.api||isNaN(t.time)?(a.warn("[retcode] invalid time or api"),this):(this.$ad&&this.$ad("api",t),this._lg("api",t))):this):(a.warn("[retcode] api is null"),this)},speed:function(t,e,n){var i=this,o=this.getConfig("startTime")||r;return/^s(\d|1[0])$/.test(t)?(e="number"!=typeof e?Date.now()-o:e>=o?e-o:e,i.$av=i.$av||{},i.$av[t]=e,clearTimeout(i.$aw),i.$aw=setTimeout(function(){n||(i.$av.page=i.$a7(!0)),i._lg("speed",i.$av),i.$av=null},5e3),i):(a.warn("[retcode] invalid point: "+t),i)}}),c._super=i,c._root=i,i.Reporter=c,e.exports=c},{"./base":1,"./util":10}],10:[function(t,e,n){Date.now=Date.now||function(){return(new Date).getTime()};var r=Date.now(),a=function(){},i={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,$ah: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},$ai: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.$ai(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=parseFloat(e);/^\d+(\.\d+)?%$/.test(e)&&(n/=100),n>0&&n<=1?t.sample=n:delete t.sample}return t},on:function(t,e,n,r){return t.addEventListener?t.addEventListener(e,function a(i){r&&t.removeEventListener(e,a,!1),n.call(this,i)},!1):t.attachEvent&&t.attachEvent("on"+e,function i(a){r&&t.detachEvent("on"+e,i),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 i=0;i<8;i++)r.splice(3*i+2,0,a[i]);return r.join("")},seq:function(){return(r++).toString(36)},encode:function(t){try{t=encodeURIComponent(t)}catch(e){}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]));return e.join("&")},$b0: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},$at:function(t){return!(!t||!t.message)&&!/failed[\w\s]+fetch/i.test(t.message)},$aj:function(t){return t&&"string"==typeof t?t.replace(/^(https?:)?\/\//,"").replace(/\?.*$/,""):""},$aq:function(t){return function(){return t+"() { [native code] }"}}};e.exports=i},{}]},{},[8]); | ||
/** retcode cloud sdk | @version 1.2.2 | @copyright Alibaba Group Holding Limited. */ !function t(e,n,r){function a(o,s){if(!n[o]){if(!e[o]){var c="function"==typeof require&&require;if(!s&&c)return c(o,!0);if(i)return i(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var f=n[o]={exports:{}};e[o][0].call(f.exports,function(t){var n=e[o][1][t];return a(n||t)},f,f.exports,t,e,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)a(r[o]);return a}({1:[function(t,e,n){var r=t("./util"),a=function(t){return this.ver="1.2.2",this._conf=r.ext({},a.dftCon),this.$a5={},this.$a1=[],this.hash=r.seq(),this.$a6(),this.setConfig(t),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){r.$a9(t),this._conf=r.ext({},this._conf,t)},$aa:function(){},$ab:function(){return{}},$a6:function(){this.session=r.uu(),this.sBegin=Date.now()},getConfig:function(t){return t?this._conf[t]:r.ext({},this._conf)},$ac: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();)this.$aa(t);return this},_lg:function(t,e,n){var a=this._conf;return n=n||a.sample,e&&!a.disabled&&a.pid&&this.$ac(n)?(e=r.ext({t:t,times:1/n,page:this.$a7(),tag:a.tag||""},e,this.$ab(),{pid:a.pid,_v:this.ver,sid:this.session,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={};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":10}],2:[function(t,e,n){var r=t("../util"),a=t("../reporter"),i=t("../common/sender"),o=r.win,s=o.document,c=/^(error|api|speed|sum|avg|percent|custom|msg|setPage|setConfig)$/,u=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.$ad=function(t,n){"error"===t?e._health.errcount++:"api"===t&&e._health[n.success?"apisucc":"apifail"]++},e.$ae(),e.$af(),Object.defineProperty&&o.addEventListener&&Object.defineProperty(e,"pipe",{set:e.$ag}),e};u.prototype=r.$ah(a.prototype),r.ext(a._root.dftCon,{uid:null,ignoreUrlPath:[{rule:/^(([\w\.-]+){2,6})(\:\d{4,5})?((\/[\w\.%-]+){2})\/.*$/,target:"$1$3$4"},{rule:/\/([a-z\-_]+)?\d{2,20}/g,target:"/$1**"},/\/$/],ignoreApiPath:{rule:/(\w+)\/\d{2,}/g,target:"$1"},imgUrl:"https://arms-retcode.aliyuncs.com/r.png?",disableHook:!1,autoSendPv:!0,enableSPA:!1,parseHash:function(t){return(t?r.$aj(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(u.prototype,{constructor:u,_super:a,$a2:function(t){var e=this;if(e.hasReady)return t();"complete"===s.readyState?(e.hasReady=!0,t()):r.on(o,"load",function(){e.hasReady=!0,t()},!0)},$a7:function(t){var e=this._conf,n=e.page,a=location;return n&&!t?r.$a8(n,[],n+""):this._initialPage||r.$ai(a.host+a.pathname,e.ignoreUrlPath)},setPage:function(t,e){var n=this,r=n.$ak;if(!1!==e){if(!t||t===r)return n;n.$ak=t,clearTimeout(n.$al),n.$am(1),n.$a6(),n.$al=setTimeout(function(){n.$an()},10)}else n.$ak=t;return n._conf.page=t,n},setConfig:function(t,e){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.$ao(t[a])}},$aa:function(t){i(t,this.getConfig("imgUrl"))},$ag: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.$ag(t)});if("Array"!==r.T(t))return e;var n=t.shift();if(!c.test(n))return e;e[n].apply(e,t)}catch(a){return r.warn("[retcode] error in sendPipe",a),e}},$ap:function(){var t=r.ext({},this._health);t.healthy=t.errcount>0?0:1;var e=Date.now()-this.sBegin;e>=2e3&&(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.__propt__.constructor(t);return t.page&&e.$an(),e}}),t("./handler")(u,o,s),t("./hook")(u,o),t("./hack")(u,o),u._super=a,u._root=a._root,a.Browser=u,e.exports=u},{"../common/sender":7,"../reporter":9,"../util":10,"./hack":3,"./handler":4,"./hook":5}],3:[function(t,e,n){e.exports=function(e,n){var r=t("../util"),a=n.history||{},i=n.document,o=function(t,e){var r;n.CustomEvent?r=new CustomEvent(t,{detail:e}):((r=i.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,i,s){var c=location.href,u=e.call(a,n,i,s);if(!s||"string"!=typeof s)return u;if(s===c)return u;try{var f=c.split("#"),l=s.split("#"),h=r.$aj(f[0]),p=r.$aj(l[0]),d=f[1]&&f[1].replace(/^\/?(.*)/,"$1"),v=l[1]&&l[1].replace(/^\/?(.*)/,"$1");h!==p?o("historystatechange",p):d!==v&&o("historystatechange",v)}catch(g){r.warn("[retcode] error in "+t+": "+g)}return u},a[t].toString=r.$aq(t))};r.ext(e.prototype,{$ar:function(){return this.$as?this:(s("pushState"),s("replaceState"),this.$as=!0,this)}})}},{"../util":10}],4:[function(t,e,n){e.exports=function(e,n,r){var a=t("../util"),i=t("../common/perf"),o=null,s=r.documentElement,c=n.innerWidth||s.clientWidth||r.body.clientWidth,u=n.innerHeight||s.clientHeight||r.body.clientHeight,f={sr:screen.width+"x"+screen.height,vp:c+"x"+u},l={},h=function(t,e,n,i,o){if(e===undefined){var s,c;if(!l[t]){s=new RegExp(t+"=([^;]+)");try{c=s.exec(r.cookie)}catch(f){return a.warn("[retcode] can not get cookie:",f),null}c&&(l[t]=c[1])}return l[t]}var u=t+"="+e;i&&(u+="; domain="+i),o&&(u+="; path="+o),n&&(u+="; max-age="+n);try{return r.cookie=u,!!r.cookie}catch(f){return a.warn("[retcode] can not set cookie: ",f),!1}},p=function(t){var e=t._conf.uid||h("_nk_")||h("_bl_uid");if(!e){e=a.uu();if(!h("_bl_uid",e,15552e3))return null}return e};return a.ext(e.prototype,{activeErrHandler:function(t){return o&&!t?this:(o=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.$at(t.reason)&&this.error(t.reason),this},$au:function(){var t=this;t.$a2(function(){var e=i();e&&(f.ct=e.ct,e.page=t.$a7(!0),t._lg("perf",e))})},$an:function(){var t=this;t.$a2(function(){var e=function(t){return{uid:p(t),dt:r.title,dl:location.href,dr:r.referrer,dpr:n.devicePixelRatio||1,de:(r.characterSet||r.defaultCharset||"").toLowerCase(),ul:s.lang}}(t);e&&e.uid&&t._lg("pv",e)})},$ab:function(){return f.uid=p(this),f},$am:function(t){var e=Date.now();if(e-this._lastUnload<200)return this;this._lastUnload=e,this.$ap(t),this.$av&&(this._lg("speed",this.$av),this.$av=null,clearTimeout(this.$aw)),this.$a4()},$ao:function(t){var e=this;if(!t^e.$ax)return e;t?(e.$ar(),e.$ax=function(t){var n=e._conf.parseHash(location.hash);n&&e.setPage(n,!1!==t)},e.$ay=function(t){var n=e._conf.parseHash(t.detail);n&&e.setPage(n)},a.on(n,"hashchange",e.$ax),a.on(n,"historystatechange",e.$ay),e.$ax(!1)):(a.off(n,"hashchange",e.$ax),a.off(n,"historystatechange",e.$ay),e.$ax=null,e.$ay=null)},$ae:function(){var t=this;if(t.$az)return t;var e=t._conf;return a.on(n,"beforeunload",function(){t.$am(0)}),t.$ao(e.enableSPA),t.activeErrHandler(!1),t.$az=!0,t}}),a.on(n,"error",function(t){o&&o.errorHandler(t)}).on(n,"unhandledrejection",function(t){o&&o.errorHandler(t)}),e}},{"../common/perf":6,"../util":10}],5:[function(t,e,n){e.exports=function(e,n){var r=t("../util"),a=null,i=function(t,e,n,a,i,o,s){var c=r.J(i)||null,u=r.$a8(e,[c,a],null);if(!u)return!1;var f=u.code||o,l=!("success"in u)||u.success;t.api(n,l,s,f,u.msg)},o="fetch",s="__oFetch_",c="__oXMLHttpRequest_",u="XMLHttpRequest";return r.ext(e.prototype,{removeHook:function(t,e){return a&&(e||this===a)?(n[s]&&(n[o]=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[o]){var t=n[o];n[s]=t,n[o]=function(e,o){var s=1===arguments.length?[arguments[0]]:Array.apply(null,arguments),c=a;if(!c||!c.api)return t.apply(n,s);if(o&&("HEAD"===o.method||"no-cors"===o.mode))return t.apply(n,s);var u=Date.now(),f=c._conf,l=(e&&"string"!=typeof e?e.url:e)||"",h=l;return l=r.$aj(l),r.$b0(l,!0)?(l=r.$ai(l,f.ignoreApiPath),t.apply(n,s).then(function(t){if(!c||!c.api)return t;var e=t.clone(),n=Date.now()-u;return e.ok?e.text().then(function(t){i(c,f.parseResponse,l,h,t,e.status||200,n)}):c.api(l,!1,n,e.status||404,e.statusText),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),t})):t.apply(n,s)},n[o].toString=r.$aq(o)}}(),function(){if("function"==typeof n[u]){var t=n[u];n[c]=t,n[u]=function(e){var n=new t(e),o=a;if(!o||!o.api||!n.addEventListener)return n;var s,c,u,f=n.send,l=n.open,h=o._conf;return n.open=function(t,e){var a=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);l.apply(n,a),u=e||"",c=(c=r.$aj(u))?r.$ai(c,h.ignoreApiPath):""},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;n.responseType&&"text"!==n.responseType?o.api(c,!0,t,e,""):i(o,h.parseResponse,c,u,n.responseText,e,t)}else o.api(c,!1,t,n.status||"FAILED",n.statusText)}}),n},n[u].toString=r.$aq(u)}}()),a=this,this)},$af:function(){return this.$b1?this:(this.getConfig("disableHook")||this.addHook(),this.$b1=!0,this)}}),e}},{"../util":10}],6:[function(t,e,n){var r=t("../util"),a=["","fetchStart","domainLookupStart","domainLookupEnd","connectStart","connectEnd","requestStart","responseStart","responseEnd","","domInteractive","","domContentLoadedEventEnd","","loadEventStart","","msFirstPaint","secureConnectionStart"];e.exports=function(){var t=r.win||{},e=t.performance;if(!e||"object"!=typeof e)return null;var n={},i=e.timing||{},o=1;if("function"==typeof t.PerformanceNavigationTiming){var s=e.getEntriesByType("navigation")[0];s&&(i=s,o=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=i[a[t[1]]],o=i[a[t[0]]];if(2===t||r>0&&o>0){var s=Math.round(o-r);s>=0&&s<36e5&&(n[e]=s)}});var c=t.navigator.connection,u=e.navigation||{};n.ct=c?c.effectiveType||c.type:"";var f=c?c.downlinkMax||c.bandwidth||-1:-1;return f=f>999?999:f,n.bandwidth=f,n.navtype=1===u.type?"Reload":"Other",1===o&&i[a[16]]>0&&i[a[1]]>0&&(n.fpt=i[a[16]]-i[a[1]]),n}},{"../util":10}],7:[function(t,e,n){var r=t("../util"),a="object"==typeof window?window:{},i=a.__oFetch_||a.fetch;i="function"==typeof i?i:undefined,e.exports=function(t,e){"object"==typeof t&&(t=r.serialize(t));var n=e+t;if(i)return i(n,{method:"HEAD",mode:"no-cors"})["catch"](r.noop);if(a.document&&a.document.createElement){var o="__request_hold_"+r.seq(),s=a[o]=new Image;s.onload=s.onerror=function(){a[o]=undefined},s.src=n,s=null}}},{"../util":10}],8:[function(t,e,n){"use strict";function r(t,e){var n=a[o]=new i(t);n.$ag(e);return!1!==n._conf.autoSendPv&&n.$an(),n.$au(),a[s]=!0,n}var a=window,i=a.BrowserLogger=t("./biz.browser/clazz"),o=t("./util").key,s="__hasInitBlSdk";i.singleton=function(t,e){return a[s]?a[o]:r(t,e)};"object"==typeof window&&!!window.navigator&&a[o]&&(i.bl=function(){if(a[s])return a[o];var t={},e=[];return o in a&&(t=a[o].config||{},e=a[o].pipe||[]),r(t,e)}(a.__hasInitBlSdk)),e.exports=i},{"./biz.browser/clazz":2,"./util":10}],9:[function(t,e,n){var r,a=t("./util"),i=t("./base"),o=["api","success","time","code","msg","trace","traceId"],s=function(t,e){var n=t.split("::");return n.length>1?a.ext({group:n[0],key:n[1]},e):a.ext({group:"default_group",key:n[0]},e)};try{r="object"==typeof performance?performance.timing.responseStart:Date.now()}catch(u){r=Date.now()}var c=function(t){return i.call(this,t),this};c.prototype=a.$ah(i.prototype),a.ext(i.dftCon,{startTime:null}),a.ext(c.prototype,{constructor:c,_super:i,sum:function(t,e,n){try{return this._lg("sum",s(t,{val:e||1}),n)}catch(r){a.warn("[retcode] can not get parseStatData: "+r)}},avg:function(t,e,n){try{return this._lg("avg",s(t,{val:e||0}),n)}catch(r){a.warn("[retcode] can not get parseStatData: "+r)}},percent:function(t,e,n,r){try{return this._lg("percent",s(t,{subkey:e,val:n||0}),r)}catch(i){a.warn("[retcode] can not get parseStatData: "+i)}},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 a.warn("[retcode] invalid param e: "+t),this;var n=t.name||"CustomError",r=t.message,i=t.stack||"";e=e||{},i=i&&i.substring(0,1e3);var o={cate:n,msg:r.substring(0,1e3),stack:i,file:e.filename,line:e.lineno,col:e.colno};return this.$ad&&this.$ad("error",o),this._lg("error",o,1)},api:function(t,e,n,r,i){return t?(t="string"==typeof t?{api:t,success:e,time:n,code:r,msg:i}:a.sub(t,o),a.$b0(t.api)?(t=a.ext({code:"",msg:""},t),t.success=t.success?1:0,t.time=+t.time,!t.api||isNaN(t.time)?(a.warn("[retcode] invalid time or api"),this):(this.$ad&&this.$ad("api",t),this._lg("api",t))):this):(a.warn("[retcode] api is null"),this)},speed:function(t,e,n){var i=this,o=this.getConfig("startTime")||r;return/^s(\d|1[0])$/.test(t)?(e="number"!=typeof e?Date.now()-o:e>=o?e-o:e,i.$av=i.$av||{},i.$av[t]=e,clearTimeout(i.$aw),i.$aw=setTimeout(function(){n||(i.$av.page=i.$a7(!0)),i._lg("speed",i.$av),i.$av=null},5e3),i):(a.warn("[retcode] invalid point: "+t),i)}}),c._super=i,c._root=i,i.Reporter=c,e.exports=c},{"./base":1,"./util":10}],10:[function(t,e,n){Date.now=Date.now||function(){return(new Date).getTime()};var r=Date.now(),a=function(){},i={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,$ah: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},$ai: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.$ai(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=parseFloat(e);/^\d+(\.\d+)?%$/.test(e)&&(n/=100),n>0&&n<=1?t.sample=n:delete t.sample}return t},on:function(t,e,n,r){return t.addEventListener?t.addEventListener(e,function a(i){r&&t.removeEventListener(e,a,!1),n.call(this,i)},!1):t.attachEvent&&t.attachEvent("on"+e,function i(a){r&&t.detachEvent("on"+e,i),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 i=0;i<8;i++)r.splice(3*i+2,0,a[i]);return r.join("")},seq:function(){return(r++).toString(36)},encode:function(t){try{t=encodeURIComponent(t)}catch(e){}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]));return e.join("&")},$b0: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},$at:function(t){return!(!t||!t.message)&&!/failed[\w\s]+fetch/i.test(t.message)},$aj:function(t){return t&&"string"==typeof t?t.replace(/^(https?:)?\/\//,"").replace(/\?.*$/,""):""},$aq:function(t){return function(){return t+"() { [native code] }"}}};e.exports=i},{}]},{},[8]); |
/** | ||
* Retcode Cloud SDK | ||
* @version 1.2.1 | ||
* @version 1.2.2 | ||
* @author Pluto <huazhi.chz@alibaba-inc.com> | ||
@@ -5,0 +5,0 @@ * @create 2017/06 |
{ | ||
"name": "alife-logger", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "retcode cloud sdk", | ||
@@ -5,0 +5,0 @@ "exports": "__bl", |
Sorry, the diff of this file is too big to display
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
205528
4754