var YouZanHummer=function(t){"use strict";var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,r)};function r(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var n=function(){return(n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r=200}}},P=new(function(){function t(){this._enable=!1}return t.prototype.setEnable=function(){return this._enable=!0,this},t.prototype.setUnable=function(){return this._enable=!1,this},t.prototype.info=function(){for(var t=[],e=0;e=6)return;t.data.events=t.data.events.concat(r.data.events)}else t=r}if(t){var n=this.adapter.request(t);n.id=t.id||"none",n.retry=this.retry,this.executeTask(n)}}}},t.prototype.executeTask=function(t){var e=this.executeList.push(t.id)-1,r=this;t.then((function(){P.info("Report: "+t.id+" success"),r.executeList.splice(e,1),r.next()})).catch((function(){P.info("Report: "+t.id+" fail"),r.executeList.splice(e,1),r.again(t)}))},t.prototype.again=function(t){t.retry<=0||(t.retry--,P.info("Queue: "+t.id+" retry again, retry count is "+t.retry),this.executeTask(t))},t}(),F=function(){function t(t){this.unityList=[],this.unityName=t}return t.prototype.add=function(t){return P.info(this.unityName+": "+(t.name||"unknown"+this.unityName)+" is attached"),this.unityList.push(t),this.unityList.length-1},t.prototype.use=function(t,e){for(var r=this,n=Promise.resolve(t),i=t,a=o(this.unityList,[function(){return t}]);a.length;){var s=a.shift();if(!i)return Promise.reject(H(this.unityName+": no return value, discard "+t.id+" event"));if(i=s(!0===i?t:i,e),n=Promise.resolve(i),i instanceof Promise){n=i;break}}for(var u=function(){var o=a.shift();n=n.then((function(n){return n?o(!0===n?t:n,e):Promise.reject(H(r.unityName+": no return value, discard "+t.id+" event"))}))};a.length;)u();return n},t.prototype.remove=function(t){var e=this.unityList[t];e&&(P.info(this.unityName+": "+(e.name||"unknown"+this.unityName)+" is unload"),this.unityList[t]=null)},t.prototype.clear=function(){P.info("sdk: uninstall "+this.unityName+"Manager"),this.unityList=[]},t}();function z(t,e){if(t.id=k(),t.captureTime=Date.now(),t.user=e.store.getUser(),t.extra=n(n({},t.extra||{}),e.store.getExtra()||{}),t.biz=e.store.getBiz(),t.type||(t.type="error"),"per"===t.type)return t.hash=0,t;var r=t.exception;if(!r)return t;r.type||(r.type=s.UNKNOWN_ERROR);var o,i,a=e.options.issueRules,u=void 0===a?[]:a,c=r.message,p=r.stack.split("\n").find((function(t){return/\.js:\d+:\d+/.test(t)}))||"";return t.hash=function(t){for(var e=5381,r=0,n=t.length;ro?(P.info("Event discard due to per sample options, per sample is "+o),!1):!("error"===t.type&&Math.random()>n)||(P.info("Event discard due to error sample options, error sample is "+n),!1)}function G(t,e){if("error"!==t.type)return!0;var r=e.store;return r.get(""+t.hash)?(P.info("Event discard due to hash duplicated",t),!1):(r.set(""+t.hash,!0),!0)}var Z=function(){function t(t){this.captors=[],this.control=t}return t.prototype.run=function(){this.captors.forEach((function(t){t&&t.onLoad&&t.onLoad()}))},t.prototype.update=function(){this.captors.forEach((function(t){t&&t.update&&t.update()}))},t.prototype.add=function(t){if(t.control||(t.control=this.control),this.control.getOptions().enable&&t.install(),t.constructor){var e=t.constructor.name||"unknown";P.info("Captor: "+e+" is attached")}return this.captors.push(t)},t.prototype.remove=function(t){this.captors[t]&&(P.info("Captor: "+(t||"unknown captor")+" is unload"),this.captors[t]=null)},t.prototype.clear=function(){P.info("sdk: uninstall CaptorManager"),this.captors.forEach((function(t){t&&t.uninstall&&t.uninstall()})),this.captors=[]},t}(),$=function(){function t(t){this.control=t}return t.prototype.skynetURL=function(t){var e=this.control;return e.getOptions().url+"?appKey="+e.getOptions().appKey+"&__hummer__=1"},t.prototype.createRequestData=function(t){var e;return{data:{plat:{yai:"fe-monitor",st:"js",sv:"0.0.0"},user:{login_sign:t.user.mobile?1:0,uuid:t.user.uuid,uid:t.user.uid,m:t.user.mobile},context:{},env:{app_name:this.control.getOptions().appKey,net:t.system.net,node_env:null===(e=t.env)||void 0===e?void 0:e.nodeEnv},events:[this.transformEvent(t)]},header:{"Content-type":"text/plain; charset=UTF-8"}}},t.prototype.transformEvent=function(t){var e,r,n,o,i,a,s,u,c,p,l,f,h={l:t.level,ct:t.captureTime,skn:t.sdk.name,skv:t.sdk.version,t:t.type,sta:t.system.app,std:t.system.model,stap:t.system.appPlatform,stv:t.system.appVersion,stp:t.system.platform,stm:t.system.mpSdkVersion,bk:t.biz.kdtId,bn:t.biz.shopName,bv:t.biz.mpVersion,path:t.route.path,st:t.baseTime,df:null===(e=t.per)||void 0===e?void 0:e.df,pn:null===(r=t.per)||void 0===r?void 0:r.pn,dp:null===(n=t.per)||void 0===n?void 0:n.dp,est:null===(o=t.per)||void 0===o?void 0:o.es,fr:null===(i=t.per)||void 0===i?void 0:i.fr,fp:null===(a=t.per)||void 0===a?void 0:a.fp,fcp:null===(s=t.per)||void 0===s?void 0:s.fcp,lcp:null===(u=t.per)||void 0===u?void 0:u.lcp};if((null===(c=t.per)||void 0===c?void 0:c.al)&&(h.al=t.per.al),(null===(p=t.per)||void 0===p?void 0:p.rt)&&(h.rt=t.per.rt),(null===(l=t.per)||void 0===l?void 0:l.navigation)&&(h.navigation=t.per.navigation),t.exception&&(h.et=t.exception.type,h.em=t.exception.message,h.es=t.exception.source,h.ek=t.exception.stack,h.h=t.hash),t.extra)try{var d=JSON.stringify(t.extra);h.ea=d.substr(0,300)}catch(t){}return{durl:t.route.url,ei:t.type,en:"per"===t.type?"性能数据":"错误数据",et:"custom",params:h,ts:(new Date).getTime(),st:t.captureTime,si:t.biz.kdtId,rurl:null!==(f=t.rurl)&&void 0!==f?f:""}},t}();function tt(t,e){return new Promise((function(r){return setTimeout((function(){r(t)}),e.options.debounce+100)}))}function et(t,e){return e.adapter.createUid().then((function(e){return t.user&&(t.user.uuid=e),t}))}var rt=function(){function t(t,e){this.running=!1,this.ignore=!1,this.options=t,this.adapter=e,this.processorManager=new F("Processor"),this.filterManager=new F("Filter"),this.store=new D,this.app=new $(this),this.queue=new B({maxExecuteNumber:t.maxExecuteNumber,retry:t.retry},e),this.captorManager=new Z(this),t.debug&&(P.setEnable(),P.info("sdk: init succeed, with options:",this.options)),this.install()}return t.prototype.getOptions=function(){return this.options},t.prototype.setOptions=function(t){return P.info("sdk: set options",t),this.options=N(this.options,t),t.enable?this.ready():0===t.enable&&this.running?this.uninstall():void 0},t.prototype.captureException=function(t,e){var r=this;this.adapter.exceptionEvent(t).then((function(t){return e&&(t.exception=N(t.exception,e)),r.disposeEvent(t)}))},t.prototype.captureMessage=function(t,e){var r=this;this.adapter.exceptionMessage(t,e).then((function(t){return r.disposeEvent(t)}))},t.prototype.captureEvent=function(t){return P.info("Event: captureEvent",t),this.disposeEvent(t)},t.prototype.ignoreNextEvent=function(){this.ignore=!0},t.prototype.ready=function(){this.running||0===this.options.enable||(this.running=!0,this.captorManager.run(),this.queue.run(),P.info("sdk: is onLoaded ready to work"))},t.prototype.update=function(){this.captorManager.update()},t.prototype.install=function(){var t=this;this.processorManager.add(Q),this.processorManager.add(tt),this.processorManager.add(z),this.processorManager.add(V),this.processorManager.add(et),this.filterManager.add(G),this.filterManager.add(Y),this.filterManager.add(J),this.adapter.onLoad((function(){t.ready()}))},t.prototype.uninstall=function(){P.info("sdk: begin uninstall..."),this.captorManager.clear(),this.queue.clear(),this.processorManager.clear(),this.filterManager.clear(),this.store.clear(),this.running=!1},t.prototype.disposeEvent=function(t){var e=this;return this.ignore&&"error"===t.type?(P.warn("ignore Event, Event is ",t),void(this.ignore=!1)):this.processorManager.use(t,this).then((function(t){return e.filterManager.use(t,e)})).then((function(t){return e.createRequest(t),!0})).catch((function(t){P.error(t)}))},t.prototype.createRequest=function(t){var e=n({id:t.id,url:this.app.skynetURL(t),method:"POST"},this.app.createRequestData(t));P.info("Event: report",t),this.queue.add(e)},t}(),nt=function(){function t(){}return t.init=function(t,e){this.control=new rt(N(j,t),e)},t.setOptions=function(t){this.control.setOptions(t)},t.createInitError=function(){return!!this.control||(P.rawError(new Error("Please call Hummer.init first")),!1)},t.setEnv=function(t){if(this.createInitError())return this.control.store.setUser(t).setBiz(t),this.instance},t.setExtra=function(t){if(this.createInitError())return this.control.store.setExtra(t),this.instance},t.capture=function(t,e){if(this.createInitError())return f(t)?this.control.captureException(t,e):this.control.captureMessage(t,(null==e?void 0:e.level)||c.ERROR)},t.captureEvent=function(t){this.createInitError()&&this.control.captureEvent(t)},t.addProcessor=function(t){return this.createInitError()?this.control.processorManager.add(t):-1},t.removeProcessor=function(t){this.control.processorManager.remove(t)},t.addFilter=function(t){return this.createInitError()?this.control.filterManager.add(t):-1},t.removeFilter=function(t){this.createInitError()&&this.control.filterManager.remove(t)},t.addCaptor=function(t){return this.createInitError()?this.control.captorManager.add(t):-1},t.removeCaptor=function(t){this.createInitError()&&this.control.captorManager.remove(t)},t}(),ot=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.uuid="",e}return r(e,t),e.prototype.createUid=function(){var t,e;return this.uuid||(this.uuid=(t="yz_log_uuid",((e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)")))?decodeURIComponent(e[3]):null)||k())),Promise.resolve(this.uuid)},e.prototype.getSystemInfo=function(){var t,e=a().navigator,r=e.connection,n=e.userAgent;if(r&&r.effectiveType)t=r.effectiveType;else if(/MicroMessenger/i.test(n)){var o=n.match(/NetType\/([\w.]+)/i);t=o?o[1]:""}var i={net:t||"unknown",platform:p.WEB,app:"web"};return Promise.resolve(i)},e.prototype.getRoute=function(){var t=a().location,e=t.pathname,r=t.href,n=e.split("/"),o=n.pop()||"";return o.search(/[0-9]/)>-1?n.push(":alias"):n.push(o),{url:r,path:n.join("/")}},e.prototype.request=function(t){return new Promise((function(e,r){var n=t.method,o=t.url,i=t.data,a=void 0===i?null:i,s=t.timeout,u=t.header,c=new XMLHttpRequest;c.open(n,o,!0),s&&(c.timeout=s),c.onreadystatechange=function(){4===c.readyState&&0!==c.status&&(200!==c.status?r(H("Request Error")):e({status:c.status}))},c.onerror=function(){r(H("Network Error"))},c.ontimeout=function(){r(H("Timeout of "+s+" ms exceeded"))},u&&Object.keys(u).forEach((function(t){c.setRequestHeader(t,u[t])})),c.send(JSON.stringify(a))}))},e.prototype.onLoad=function(t){a().addEventListener("load",(function(){t()}),!1)},e.prototype.onLoaded=function(){},e}(q),it=["EventTarget","Window","Node","ApplicationCache","AudioTrackList","ChannelMergerNode","CryptoOperation","EventSource","FileReader","HTMLUnknownElement","IDBDatabase","IDBRequest","IDBTransaction","KeyOperation","MediaController","MessagePort","ModalWindow","Notification","SVGElementInstance","Screen","TextTrack","TextTrackCue","TextTrackList","WebSocket","WebSocketWorker","Worker","XMLHttpRequest","XMLHttpRequestEventTarget","XMLHttpRequestUpload"],at=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.uninstall=function(){},e.prototype.install=function(){var t=this.control.options,e=t.error;t.enableError&&(e.onError&&this.installOnError(),e.onReject&&this.installOnPromiseReject(),e.requestAnimationFrame&&this.installRequestAnimationFrameError(),e.eventTarget&&it.forEach(this.wrapEventTarget.bind(this)))},e.prototype.installOnError=function(){var t=this.control,e=window.onerror;window.onerror=function(){for(var r=[],n=0;n