Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@apm-insight-web/rangers-mini-sdk

Package Overview
Dependencies
Maintainers
4
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@apm-insight-web/rangers-mini-sdk - npm Package Compare versions

Comparing version 0.4.0 to 0.4.3-alpha.0

cn/index.0.4.3-alpha.0.cn.js

2

cn/index.cjs.js

@@ -1489,3 +1489,3 @@ 'use strict';

function Rangers(options) {
this.version = '0.4.0';
this.version = '0.4.3-alpha.0';
this.Backend = options.Backend;

@@ -1492,0 +1492,0 @@ this.defaultConfig = getDefaultConfig();

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).RangersMiniSDK={})}(this,function(n){"use strict";var o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function t(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var e,r,f,v=function(){return(v=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function i(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var o,r,i=n.call(t),a=[];try{for(;(void 0===e||0<e--)&&!(o=i.next()).done;)a.push(o.value)}catch(t){r={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return a}function a(t,e,n){if(n||2===arguments.length)for(var o,r=0,i=e.length;r<i;r++)!o&&r in e||((o=o||Array.prototype.slice.call(e,0,r))[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))}function u(t){return"object"==typeof t&&null!==t&&"[object Array]"!==Object.prototype.toString.call(t)}n.BreadcrumbType=void 0,(s=n.BreadcrumbType||(n.BreadcrumbType={})).DOM="dom",s.HTTP="http",(e=e||{}).ROUTE="route",(r=r||{}).BATCH="batch",n.ReportEventType=void 0,(s=n.ReportEventType||(n.ReportEventType={})).PAGEVIEW="pageview",s.JS_ERROR="js_error",s.REQUEST="ajax",s.SET_DATA="set_data",s.ON_READY="on_ready",s.FIRST_LOAD="first_load",(s=f=f||{}).DEVICE_ID="device_id",s.FINDER_CONFIG="finder_config",s.TESTER_SDK_VERSION="tester_sdk_version",s.ENV_INFO="env_info",s.NETWORK_STATUS="network_status",s.JS_ERROR="js_error",s.GLOBAL_JS_ERROR="global_js_error",s.APP_SESSION="app_session",s.PAGE_SESSION="page_session",s.REQUEST="request",s.SET_DATA="set_data",s.PAGE_ON_READY="page_on_ready",s.PAGE_FIRST_LOAD="page_first_load";var s=(c.prototype.sendEvent=function(t){t=this.getEventToBeSent(t);t&&this.idleSendEvent(t)},c.prototype.getEventToBeSent=function(t){t=this._modifyEvent(t);if(this._shouldSend(t))return t},c.prototype._modifyEvent=function(t){return t},c.prototype._shouldSend=function(t){return!0},c.prototype._send=function(t){},c.prototype.idleSendEvent=function(t){this._send(t)},c);function c(){}var d,s=(t(p,d=s),Object.defineProperty(p.prototype,"ready",{get:function(){return this.isReady},set:function(t){this.isReady=t,this.isReady&&this._uploadQueue()},enumerable:!1,configurable:!0}),p.prototype._send=function(t){var e=this,t=this.buildParams(t);null!=t&&(this.reportQueue.push(t),this.isReady&&(this.reportQueue.length>=this.batchReportLength&&this._uploadQueue(),this.batchReportTimeout&&clearTimeout(this.batchReportTimeout),this.batchReportTimeout=setTimeout(function(){e._uploadQueue()},this.batchReportWait)))},p.prototype._uploadQueue=function(){var t;this.reportQueue.length&&this.ready&&(t={ev_type:"batch",list:this.reportQueue},this.reportQueue=[],this._request({event:t,type:"post"}))},p.prototype._request=function(t){},p);function p(t){var e,n=d.call(this)||this;return n.reportQueue=[],n.isReady=!0,n.batchReportLength=null!==(e=t.maxBatchReportLength)&&void 0!==e?e:10,n.batchReportWait=null!==(t=t.batchReportWait)&&void 0!==t?t:1e3,n.batchReportTimeout=null,n}function l(){var t=function(){for(var t=new Array(16),e=0,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),t[n]=e>>>((3&n)<<3)&255;return t}();return t[6]=15&t[6]|64,t[8]=63&t[8]|128,function(t){for(var e=[],n=0;n<256;++n)e[n]=(n+256).toString(16).substr(1);var o=0,r=e;return[r[t[o++]],r[t[o++]],r[t[o++]],r[t[o++]],"-",r[t[o++]],r[t[o++]],"-",r[t[o++]],r[t[o++]],"-",r[t[o++]],r[t[o++]],"-",r[t[o++]],r[t[o++]],r[t[o++]],r[t[o++]],r[t[+o]],r[t[15]]].join("")}(t)}function _(e){try{return JSON.stringify(e)}catch(t){return String(e)}}function h(t){return encodeURI(t).split(/%(?:u[0-9A-F]{2})?[0-9A-F]{2}|./).length-1}function y(t){return t?t instanceof ArrayBuffer?t.byteLength:u(t)?h(_(t)):t.length||0:0}var g,S,E,m=l,k="UnhandledRejection",R="RANGERS_MINI_SDK_DEVICE_ID",b="RANGERS_PAGE_SESSION_ID",T="RANGERS_PAGE_TIMING";(A=A=A||{}).TT="tt",A.WX="wx",A.MY="my",A.SWAN="swan",(A=g=g||{}).onLaunch="onLaunch",A.onShow="onShow",A.onHide="onHide",A.onError="onError",A.onUnhandledRejection="onUnhandledRejection",A.onPageNotFound="onPageNotFound",(A=S=S||{}).onLoad="onLoad",A.onShow="onShow",A.onReady="onReady",A.onHide="onHide",A.onUnload="onUnload",A.onPullDownRefresh="onPullDownRefresh",(E=E||{}).request="request";function w(t,e,o){return function(n){return e.forEach(function(t){var e=n[t];n[t]=o(t,e)}),t(n)}}function I(n,t,o){t.forEach(function(t){var e;n[t]&&(e=n[t],Object.defineProperty(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o(t,e).bind(n)}))})}function x(){return{host_platform:"undefined"!=typeof wx?"wx":"undefined"!=typeof tt?"tt":"undefined"!=typeof my?"my":"undefined"!=typeof swan?"swan":O,host_app_name:O,host_app_version:O,platform:O,sdk_version:O,os_name:O,os_version:O,device_brand:O,device_model:O,screen_height:0,screen_width:0,resolution:O,pixel_ratio:0,network_type:O}}var C,O="unknown",A=(D.prototype.init=function(){var e=this;this.transport=this.setupTransport(),this.collectDeviceId(),App=this.hookAppFn(App),Page=this.hookPageFn(Page),Component=this.hookComponentFn(Component),this.hookSdk(),this.sdk.onNetworkStatusChange&&this.sdk.onNetworkStatusChange(function(t){e.callback({ev_type:f.NETWORK_STATUS,data:{network_type:t.networkType}})})},D.prototype.sendEvent=function(t){var e;null!==(e=this.transport)&&void 0!==e&&e.sendEvent(t)},D.prototype.collectEnvInfo=function(){var n=this;Promise.all([new Promise(function(t,e){n.sdk.getSystemInfo({success:t,fail:e})}),new Promise(function(t,e){n.sdk.getNetworkType({success:t,fail:e})})]).then(function(t){var e=i(t,2),t=e[0],e=e[1];t&&e&&n.callback({ev_type:f.ENV_INFO,data:n.normalizeEnvInfo(t,e)})}).catch(function(){n.callback({ev_type:f.ENV_INFO,data:x()})})},D.prototype.collectFinderConfig=function(){var t,e=this;null!==(t=this.options.finderInstance)&&void 0!==t&&t.getToken(function(t){e.callback({ev_type:f.FINDER_CONFIG,data:{user_unique_id:t.user_unique_id,ssid:t.ssid}})})},D.prototype.collectTesterSdkVersion=function(){var t,e=this,n=null===(t=this.options.finderInstance)||void 0===t?void 0:t.getAbSdkVersion();n&&this.callback({ev_type:f.TESTER_SDK_VERSION,data:{ab_sdk_version:n}}),null!==(n=null===(t=this.options.finderInstance)||void 0===t?void 0:t.onAbSdkVersionChange)&&void 0!==n&&n.call(t,function(t){e.callback({ev_type:f.TESTER_SDK_VERSION,data:{ab_sdk_version:t}})})},D.prototype.getStorage=function(t){return this.sdk.getStorageSync(t)},D.prototype.setStorage=function(t,e){return this.sdk.setStorageSync(t,e)},D.prototype.setupTransport=function(){var t,e,n=this;return this.reportUrl=(t=this.options.reportDomain,e=this.options.reportPath,"https://"+t+e),{sendEvent:function(t){n.sdk.request({url:n.reportUrl,method:"POST",data:t})},request:function(t){n.sdk.request(t)}}},D.prototype.hookAppFn=function(t){var s=this,c=this.callback;return w(t,[g.onLaunch,g.onShow,g.onHide,g.onError,g.onUnhandledRejection],function(i,a){return function(t){switch(i){case g.onShow:var e=l();s.appSessionId=e,c({ev_type:f.APP_SESSION,data:{appSessionId:e}});break;case g.onError:c({ev_type:f.GLOBAL_JS_ERROR,data:{name:(r=(o=t).split("\n"))[0],message:r[1],stack:r.slice(1).join("\n"),rawMessage:o}});break;case g.onUnhandledRejection:o=(r=t).promise,r=t.reason,n=String(r),o.catch(function(t){return{name:k,message:String(t),stack:(null==t?void 0:t.stack)||"",rawMessage:n}}).then(function(t){c({ev_type:f.GLOBAL_JS_ERROR,data:t})})}var n,o,r;null!=a&&a.call(this,t)}})},D.prototype.hookPageFn=function(t){return w(t,[S.onLoad,S.onShow,S.onReady],this._pageLifeCycleHandlers())},D.prototype.hookComponentFn=function(t){return e=t,o=[S.onLoad,S.onShow,S.onReady],r=this._pageLifeCycleHandlers(),function(n){return n.methods||(n.methods={}),o.forEach(function(t){var e=n.methods[t];n.methods[t]=r(t,e)}),e(n)};var e,o,r},D.prototype._pageLifeCycleHandlers=function(){var c=this,d=this.callback;return function(a,e){function s(t){try{null!=e&&e.call(this,t)}catch(t){d({ev_type:f.JS_ERROR,data:{name:t.name,message:t.message,stack:t.stack,rawMessage:String(t)},context:c.getContext()})}}return function(t){var e,n=(e=getCurrentPages())[e.length-1].route;switch(a){case S.onLoad:c.pid=n,c.hookSetData(this);var o=Date.now(),r=[c.deviceId,c.appSessionId,c.pid,o].join("|");return c.pageSessionId=r,c.taskTracks[r]={tasks:[],timing:{firstReqStart:o,firstReqEnd:0,firstLoadStart:o,firstLoadEnd:0},ready:!1,ended:!1},d({ev_type:f.PAGE_SESSION,data:{pid:n,pageSessionId:r}}),s.call(this,t),this[b]=r,void(this[T]={onLoadStart:o,onLoadEnd:Date.now(),onShowStart:0,onShowEnd:0,onReadyStart:0,onReadyEnd:0});case S.onShow:var i,r=this[b];return c.pageSessionId=r,d({ev_type:f.PAGE_SESSION,data:{pid:n,pageSessionId:r}}),(i=this[T]).onShowStart=i.onShowStart||Date.now(),s.call(this,t),void(i.onShowEnd=i.onShowEnd||Date.now());case S.onReady:(i=this[T]).onReadyStart=Date.now(),s.call(this,t),i.onReadyEnd=Date.now(),d({ev_type:f.PAGE_ON_READY,data:i});r=c.getTaskTrack();return r.ready=!0,!r.timing.firstReqEnd&&r.tasks.every(function(t){return t.completed||"SET_DATA"===t.type})&&(r.timing.firstReqEnd=r.timing.firstReqStart),void(r.tasks.every(function(t){return t.completed})&&(r.timing.firstLoadEnd=i.onReadyEnd,c.endTrack(r)))}s.call(this,t)}}},D.prototype.hookSdk=function(){this.hookRequest()},D.prototype.hookRequest=function(){var u=this,l=this,h=this.callback;I(this.sdk,[E.request],function(t,i){return function(a){if(u.shouldIgnoreUrl(a.url))return i(a);var s=a.success,o=a.fail,e=a.complete,c=y(null!==(r=a.data)&&void 0!==r?r:""),d=u.addTask("REQUEST"),p=Date.now(),t=u.captureContext(function(t){var e,n,o,r,i=Date.now();h({ev_type:f.REQUEST,data:{req_url:a.url,method:null!==(o=a.method)&&void 0!==o?o:"GET",err_msg:300<=t.statusCode?_(t.data):"",req_status:1,req_start_time:p,req_end_time:i,resp_status:t.statusCode,header:null!==(r=a.header)&&void 0!==r?r:{},req_param:300<=t.statusCode?_(a.data):"",req_size:c,resp_size:(o=t,i=null!==(r=Object.keys(null!==(i=o.header)&&void 0!==i?i:{}).find(function(t){return"content-legth"===t.toLowerCase()}))&&void 0!==r?r:"",null!==(r=o.header)&&void 0!==r&&r[i]?parseInt(o.header[i]):y(o.data)),perf:t.profile?(e=t.profile,n={},["redirectStart","redirectEnd","fetchStart","domainLookupStart","domainLookupEnd","connectStart","connectEnd","SSLconnectionStart","SSLconnectionEnd","requestStart","requestEnd","responseStart","responseEnd","rtt","httpRttEstimate","transportRttEstimate"].forEach(function(t){n[t]=e[t]}),n):{redirectStart:0,redirectEnd:0,fetchStart:0,domainLookupStart:0,domainLookupEnd:0,connectStart:0,connectEnd:0,SSLconnectionStart:0,SSLconnectionEnd:0,requestStart:0,requestEnd:0,responseStart:0,responseEnd:0,rtt:0,httpRttEstimate:0,transportRttEstimate:0}},context:l.capturedContext}),l.taskStack.push(d);try{null!=s&&s.call(this,t)}finally{l.taskStack.pop()}}),n=u.captureContext(function(t){var e,n=Date.now();h({ev_type:f.REQUEST,data:{req_url:a.url,method:null!==(e=a.method)&&void 0!==e?e:"GET",err_msg:null!==(e=t.errMsg)&&void 0!==e?e:"",req_status:0,req_start_time:p,req_end_time:n,resp_status:0,req_param:_(a.data),header:null!==(n=a.header)&&void 0!==n?n:{},req_size:c,resp_size:0,perf:{}},context:l.capturedContext}),l.taskStack.push(d);try{null!=o&&o.call(this,t)}finally{l.taskStack.pop()}}),r=u.captureContext(function(t){l.taskStack.push(d);try{null!=e&&e.call(this,t)}finally{l.taskStack.pop()}l.endTask(d,Date.now())}),r=v(v({},a),{success:t,fail:n,complete:r});return i(r)}})},D.prototype.shouldIgnoreUrl=function(t){return t===this.reportUrl},D.prototype.hookSetData=function(t){var s=this;I(t,["setData"],function(t,e){return function(n,t){var o=this,r=t,i=s.addTask("SET_DATA"),a=Date.now(),t=s.captureContext(function(){var t=Date.now(),e=_(n);s.callback({ev_type:f.SET_DATA,data:{setDataStart:a,setDataEnd:t,setDataSize:h(e),data:e},context:s.capturedContext}),s.taskStack.push(i);try{null!=r&&r.call(o)}catch(t){s.callback({ev_type:f.JS_ERROR,data:{name:t.name,message:t.message,stack:t.stack,rawMessage:String(t)},context:s.getContext()})}finally{s.taskStack.pop()}s.endTask(i,t)});e.call(this,n,t)}})},D.prototype.collectDeviceId=function(){var t=this.getStorage(R);t||(t=l(),this.setStorage(R,t)),this.deviceId=t,this.callback({ev_type:f.DEVICE_ID,data:{deviceId:t}})},D.prototype.getContext=function(){var t;return null!==(t=this.capturedContext)&&void 0!==t?t:this.currentContext()},D.prototype.currentContext=function(){return{pid:this.pid,pageSessionId:this.pageSessionId,context:this.options.context}},D.prototype.captureContext=function(o){var r=this,i=this.getContext();return function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];r.capturedContext=i;try{t=o.apply(this,e)}catch(t){r.callback({ev_type:f.JS_ERROR,data:{name:t.name,message:t.message,stack:t.stack,rawMessage:String(t)},context:i})}finally{r.capturedContext=null}return t}},D.prototype.addTask=function(t){var e=this.getTaskTrack();if(!e||e.ended)return 0;var n=this.taskStack.length&&this.taskStack[this.taskStack.length-1];if(e.ready&&(!n||!e.tasks.some(function(t){return t.id===n})))return 0;var o=e.tasks.length+1;return e.tasks.push({id:o,type:t,completed:!1}),o},D.prototype.endTask=function(t,e){var n=this.getTaskTrack();t<=0||!n||n.ended||((t=n.tasks[t-1]).completed=!0,n.timing.firstReqEnd||"REQUEST"!==t.type||(n.timing.firstReqEnd=e),n.tasks.every(function(t){return t.completed})&&(n.timing.firstLoadEnd=e,this.endTrack(n)))},D.prototype.endTrack=function(t){t.ready&&(t.ended=!0,this.callback({ev_type:f.PAGE_FIRST_LOAD,data:t.timing,context:this.getContext()}))},D.prototype.getTaskTrack=function(){var t=this.getContext().pageSessionId;return this.taskTracks[t]},D);function D(t,e){this.originalAppFn=App,this.originalPageFn=Page,this.reportUrl="",this.deviceId="",this.appSessionId="",this.pageSessionId="",this.capturedContext=null,this.taskStack=[],this.taskTracks={},this.options=t,this.pid=t.pid,this.callback=e}function P(){var t=null!==C&&C.apply(this,arguments)||this;return t.sdk=my,t}var N,L=(t(P,C=A),P.prototype.normalizeEnvInfo=function(t,e){return{host_platform:"my",host_app_name:t.app,host_app_version:t.version,platform:t.platform,sdk_version:t.SDKVersion,os_name:t.platform,os_version:t.system,device_brand:t.brand,device_model:t.model,screen_width:t.screenWidth,screen_height:t.screenHeight,resolution:t.screenWidth+"x"+t.screenHeight,pixel_ratio:t.pixelRatio,network_type:e.networkType}},P);function q(){var t=null!==N&&N.apply(this,arguments)||this;return t.sdk=swan,t}var j,F=(t(q,N=A),q.prototype.normalizeEnvInfo=function(t,e){return{host_platform:"swan",host_app_name:t.host,host_app_version:t.version,platform:t.platform,sdk_version:t.SDKVersion,os_name:t.platform,os_version:t.system,device_brand:t.brand,device_model:t.model,screen_width:t.screenWidth,screen_height:t.screenHeight,resolution:t.screenWidth+"x"+t.screenHeight,pixel_ratio:t.pixelRatio,network_type:e.networkType}},q);function B(){var t=null!==j&&j.apply(this,arguments)||this;return t.sdk=tt,t}var G,U=(t(B,j=A),B.prototype.normalizeEnvInfo=function(t,e){return{host_platform:"tt",host_app_name:t.appName,host_app_version:t.version,platform:t.platform,sdk_version:t.SDKVersion,os_name:t.platform,os_version:t.system,device_brand:t.brand,device_model:t.model,screen_width:t.screenWidth,screen_height:t.screenHeight,resolution:t.screenWidth+"x"+t.screenHeight,pixel_ratio:t.pixelRatio,network_type:e.networkType}},B);function V(){var t=null!==G&&G.apply(this,arguments)||this;return t.sdk=wx,t}var Q=(t(V,G=A),V.prototype.normalizeEnvInfo=function(t,e){return{host_platform:"wx",host_app_name:"Weixin",host_app_version:t.version,platform:t.platform,sdk_version:t.SDKVersion,os_name:t.system.split(" ")[0],os_version:t.system.split(" ")[1],device_brand:t.brand,device_model:t.model,screen_width:t.screenWidth,screen_height:t.screenHeight,resolution:t.screenWidth+"x"+t.screenHeight,pixel_ratio:t.pixelRatio,network_type:e.networkType}},V);var H,A=function(){if("undefined"!=typeof tt)return U;if("undefined"!=typeof my)return L;if("undefined"!=typeof swan)return F;if("undefined"!=typeof wx)return Q;throw new Error("unsupported mini program")}(),W="apmplus.volces.com",M="/monitor_microapp/collect",J="/",K=20,z=10,Y=1e3,X="cannot get context before init";function Z(t,e,n){var o,r,i=Object.assign({},t,e,n),a={};if(i.context&&u(i.context))try{for(var s=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],o=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&o>=t.length?void 0:t)&&t[o++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(Object.keys(i.context)),c=s.next();!c.done;c=s.next()){var d=c.value,p=i.context[d];a[d]="[object String]"===Object.prototype.toString.call(p)?p:_(p)}}catch(t){o={error:t}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return i.context=a,i}function $(t,e){var n=H.call(this,t)||this;n.deviceId="",n.envInfo={},n.appSessionId="",n.pageSessionId="",n.preQueue=[],n.ready=!1,n.config=t,n.pid=t.pid;t=n.config,t=Object.assign({},t);return n.backend=new e(t,n.reportBackendEvent.bind(n)),n.backend.init(),n.breadcrumbs=[],n.sampleHit=(t=n.config.sampleRate,Math.random()<Number(t)),n.backend.collectEnvInfo(),n.config.finderInstance&&(n.backend.collectFinderConfig(),n.backend.collectTesterSdkVersion()),n}var et=(t($,H=s),$.prototype.updateConfig=function(t){var e;this.config=(e=this.config,Object.assign({},e,t)),null!==(t=this.finderConfig)&&void 0!==t&&t.user_unique_id&&(this.config.userId=this.finderConfig.user_unique_id)},$.prototype.reportError=function(t,e){this.reportEvent({ev_type:n.ReportEventType.JS_ERROR,event:{name:t.name,message:t.message,stack:null!==(t=t.stack)&&void 0!==t?t:""},breadcrumbs:a([],i(this.breadcrumbs),!1)},e)},$.prototype.reportEvent=function(t,e){this.ready?H.prototype.sendEvent.call(this,v(v({},t),{context:e})):this.preQueue.push(v(v({},t),{context:e}))},$.prototype.addBreadcrumb=function(t,e){var n=this.config.maxBreadcrumbs,t=v(v({},e),{type:t,timestamp:Date.now()});this.breadcrumbs=0<=n?a(a([],i(this.breadcrumbs),!1),[t],!1).slice(-n):a(a([],i(this.breadcrumbs),!1),[t],!1)},$.prototype.flush=function(){this._uploadQueue()},$.prototype.sendPageView=function(){this.reportEvent({ev_type:n.ReportEventType.PAGEVIEW})},$.prototype.reportBackendEvent=function(t){switch(t.ev_type){case f.ENV_INFO:this.envInfo=t.data,this.unlock();break;case f.DEVICE_ID:this.deviceId=t.data.deviceId;break;case f.FINDER_CONFIG:this.finderConfig=t.data;break;case f.TESTER_SDK_VERSION:this.testerAbSdkVersion=t.data.ab_sdk_version;break;case f.NETWORK_STATUS:this.envInfo&&(this.envInfo=v(v({},this.envInfo),{network_type:t.data.network_type}));break;case f.GLOBAL_JS_ERROR:this.reportEvent({ev_type:n.ReportEventType.JS_ERROR,event:t.data,breadcrumbs:a([],i(this.breadcrumbs),!1)});break;case f.JS_ERROR:this.reportEvent({ev_type:n.ReportEventType.JS_ERROR,event:t.data,breadcrumbs:a([],i(this.breadcrumbs),!1)},t.context);break;case f.APP_SESSION:this.appSessionId=t.data.appSessionId;break;case f.PAGE_SESSION:this.pageSessionId!==t.data.pageSessionId&&(this.addBreadcrumb(n.BreadcrumbType.DOM,{category:e.ROUTE,message:t.data.pid}),this.pid=t.data.pid,this.pageSessionId=t.data.pageSessionId,this.sendPageView());break;case f.REQUEST:this.reportEvent({ev_type:n.ReportEventType.REQUEST,event:t.data},t.context);break;case f.SET_DATA:this.reportEvent({ev_type:n.ReportEventType.SET_DATA,event:t.data},t.context);break;case f.PAGE_ON_READY:this.reportEvent({ev_type:n.ReportEventType.ON_READY,event:t.data});break;case f.PAGE_FIRST_LOAD:this.reportEvent({ev_type:n.ReportEventType.FIRST_LOAD,event:t.data},t.context)}},$.prototype._shouldSend=function(){return this.sampleHit},$.prototype.buildParams=function(t){var e;return v(v({},t),{common:v(v({},this.envInfo),{aid:this.config.aid,pid:null!==(e=null===(e=t.context)||void 0===e?void 0:e.pid)&&void 0!==e?e:this.pid,rangers_sdk_version:this.config.version,timestamp:Date.now(),user_unique_id:this.finderConfig?this.finderConfig.user_unique_id:this.config.userId||this.deviceId,device_id:this.deviceId,session_id:this.config.sessionId,app_session_id:this.appSessionId,page_session_id:null!==(e=null===(e=t.context)||void 0===e?void 0:e.pageSessionId)&&void 0!==e?e:this.pageSessionId,context:null!==(t=null===(t=t.context)||void 0===t?void 0:t.context)&&void 0!==t?t:this.config.context,uuid:null===(t=this.finderConfig)||void 0===t?void 0:t.user_unique_id,ssid:null===(t=this.finderConfig)||void 0===t?void 0:t.ssid,ab_sdk_version:this.testerAbSdkVersion}),context:void 0})},$.prototype._request=function(t){var e;t&&t.event&&(e=t.type,t=t.event,"post"===e&&this.backend.sendEvent({ev_type:r.BATCH,list:t.list}))},$.prototype.unlock=function(){var e=this;this.ready=!0,this.preQueue.forEach(function(t){H.prototype.sendEvent.call(e,t)}),this.preQueue=[]},$);function nt(t){this.version="0.4.0",this.Backend=t.Backend,this.defaultConfig={context:{},maxBatchReportLength:z,batchReportWait:Y,userId:"",sampleRate:1,sessionId:m(),reportDomain:W,reportPath:M,pid:J,maxBreadcrumbs:K,hookPath:!0,hookRequest:!0,enableCapture:!0}}A=new(nt.prototype.init=function(t){if(!this.client){if(null==t||!t.aid)throw new Error("cannot init without aid");this.userConfig=t;t=Z(this.defaultConfig,this.userConfig,{version:this.version});this.client=new et(t,this.Backend)}},nt.prototype.config=function(t){if(!this.userConfig||!this.client)throw new Error("cannot config before init");var e;this.userConfig=(e=this.userConfig,Object.assign({},e,t)),this.updateClientConfig()},nt.prototype.capture=function(t){var e;null!==(e=this.client)&&void 0!==e&&e.reportError(t)},nt.prototype.report=function(t){var e;null!==(e=this.client)&&void 0!==e&&e.reportEvent(t)},nt.prototype.addBreadcrumb=function(t,e){var n;null!==(n=this.client)&&void 0!==n&&n.addBreadcrumb(t,e)},nt.prototype.sendNow=function(){var t;null!==(t=this.client)&&void 0!==t&&t.flush()},Object.defineProperty(nt.prototype,"context",{get:function(){var n=this,o={set:function(t,e){if(!n.userConfig)throw new Error(X);return n.userConfig.context||(n.userConfig.context={}),n.userConfig.context[t]=e,n.updateClientConfig(),o},delete:function(t){if(!n.userConfig)throw new Error(X);return n.userConfig.context&&t in n.userConfig.context&&delete n.userConfig.context[t],n.updateClientConfig(),o},clear:function(){if(!n.userConfig)throw new Error(X);return n.userConfig.context={},n.updateClientConfig(),o},get:function(t){var e;if(!n.userConfig)throw new Error(X);return null===(e=n.userConfig.context)||void 0===e?void 0:e[t]},toObject:function(){if(!n.userConfig)throw new Error(X);return v({},n.userConfig.context)}};return o},enumerable:!1,configurable:!0}),nt.prototype.updateClientConfig=function(){var t;this.userConfig&&this.client&&(t=Z(this.defaultConfig,this.userConfig,{version:this.version}),this.client.updateConfig(t))},nt)({Backend:A});n.default=A,Object.defineProperty(n,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).RangersMiniSDK={})}(this,function(n){"use strict";var o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function t(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var e,r,f,v=function(){return(v=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function i(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var o,r,i=n.call(t),a=[];try{for(;(void 0===e||0<e--)&&!(o=i.next()).done;)a.push(o.value)}catch(t){r={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return a}function a(t,e,n){if(n||2===arguments.length)for(var o,r=0,i=e.length;r<i;r++)!o&&r in e||((o=o||Array.prototype.slice.call(e,0,r))[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))}function u(t){return"object"==typeof t&&null!==t&&"[object Array]"!==Object.prototype.toString.call(t)}n.BreadcrumbType=void 0,(s=n.BreadcrumbType||(n.BreadcrumbType={})).DOM="dom",s.HTTP="http",(e=e||{}).ROUTE="route",(r=r||{}).BATCH="batch",n.ReportEventType=void 0,(s=n.ReportEventType||(n.ReportEventType={})).PAGEVIEW="pageview",s.JS_ERROR="js_error",s.REQUEST="ajax",s.SET_DATA="set_data",s.ON_READY="on_ready",s.FIRST_LOAD="first_load",(s=f=f||{}).DEVICE_ID="device_id",s.FINDER_CONFIG="finder_config",s.TESTER_SDK_VERSION="tester_sdk_version",s.ENV_INFO="env_info",s.NETWORK_STATUS="network_status",s.JS_ERROR="js_error",s.GLOBAL_JS_ERROR="global_js_error",s.APP_SESSION="app_session",s.PAGE_SESSION="page_session",s.REQUEST="request",s.SET_DATA="set_data",s.PAGE_ON_READY="page_on_ready",s.PAGE_FIRST_LOAD="page_first_load";var s=(c.prototype.sendEvent=function(t){t=this.getEventToBeSent(t);t&&this.idleSendEvent(t)},c.prototype.getEventToBeSent=function(t){t=this._modifyEvent(t);if(this._shouldSend(t))return t},c.prototype._modifyEvent=function(t){return t},c.prototype._shouldSend=function(t){return!0},c.prototype._send=function(t){},c.prototype.idleSendEvent=function(t){this._send(t)},c);function c(){}var d,s=(t(p,d=s),Object.defineProperty(p.prototype,"ready",{get:function(){return this.isReady},set:function(t){this.isReady=t,this.isReady&&this._uploadQueue()},enumerable:!1,configurable:!0}),p.prototype._send=function(t){var e=this,t=this.buildParams(t);null!=t&&(this.reportQueue.push(t),this.isReady&&(this.reportQueue.length>=this.batchReportLength&&this._uploadQueue(),this.batchReportTimeout&&clearTimeout(this.batchReportTimeout),this.batchReportTimeout=setTimeout(function(){e._uploadQueue()},this.batchReportWait)))},p.prototype._uploadQueue=function(){var t;this.reportQueue.length&&this.ready&&(t={ev_type:"batch",list:this.reportQueue},this.reportQueue=[],this._request({event:t,type:"post"}))},p.prototype._request=function(t){},p);function p(t){var e,n=d.call(this)||this;return n.reportQueue=[],n.isReady=!0,n.batchReportLength=null!==(e=t.maxBatchReportLength)&&void 0!==e?e:10,n.batchReportWait=null!==(t=t.batchReportWait)&&void 0!==t?t:1e3,n.batchReportTimeout=null,n}function l(){var t=function(){for(var t=new Array(16),e=0,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),t[n]=e>>>((3&n)<<3)&255;return t}();return t[6]=15&t[6]|64,t[8]=63&t[8]|128,function(t){for(var e=[],n=0;n<256;++n)e[n]=(n+256).toString(16).substr(1);var o=0,r=e;return[r[t[o++]],r[t[o++]],r[t[o++]],r[t[o++]],"-",r[t[o++]],r[t[o++]],"-",r[t[o++]],r[t[o++]],"-",r[t[o++]],r[t[o++]],"-",r[t[o++]],r[t[o++]],r[t[o++]],r[t[o++]],r[t[+o]],r[t[15]]].join("")}(t)}function _(e){try{return JSON.stringify(e)}catch(t){return String(e)}}function h(t){return encodeURI(t).split(/%(?:u[0-9A-F]{2})?[0-9A-F]{2}|./).length-1}function y(t){return t?t instanceof ArrayBuffer?t.byteLength:u(t)?h(_(t)):t.length||0:0}var g,S,E,m=l,k="UnhandledRejection",R="RANGERS_MINI_SDK_DEVICE_ID",b="RANGERS_PAGE_SESSION_ID",T="RANGERS_PAGE_TIMING";(A=A=A||{}).TT="tt",A.WX="wx",A.MY="my",A.SWAN="swan",(A=g=g||{}).onLaunch="onLaunch",A.onShow="onShow",A.onHide="onHide",A.onError="onError",A.onUnhandledRejection="onUnhandledRejection",A.onPageNotFound="onPageNotFound",(A=S=S||{}).onLoad="onLoad",A.onShow="onShow",A.onReady="onReady",A.onHide="onHide",A.onUnload="onUnload",A.onPullDownRefresh="onPullDownRefresh",(E=E||{}).request="request";function w(t,e,o){return function(n){return e.forEach(function(t){var e=n[t];n[t]=o(t,e)}),t(n)}}function I(n,t,o){t.forEach(function(t){var e;n[t]&&(e=n[t],Object.defineProperty(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o(t,e).bind(n)}))})}function x(){return{host_platform:"undefined"!=typeof wx?"wx":"undefined"!=typeof tt?"tt":"undefined"!=typeof my?"my":"undefined"!=typeof swan?"swan":O,host_app_name:O,host_app_version:O,platform:O,sdk_version:O,os_name:O,os_version:O,device_brand:O,device_model:O,screen_height:0,screen_width:0,resolution:O,pixel_ratio:0,network_type:O}}var C,O="unknown",A=(D.prototype.init=function(){var e=this;this.transport=this.setupTransport(),this.collectDeviceId(),App=this.hookAppFn(App),Page=this.hookPageFn(Page),Component=this.hookComponentFn(Component),this.hookSdk(),this.sdk.onNetworkStatusChange&&this.sdk.onNetworkStatusChange(function(t){e.callback({ev_type:f.NETWORK_STATUS,data:{network_type:t.networkType}})})},D.prototype.sendEvent=function(t){var e;null!==(e=this.transport)&&void 0!==e&&e.sendEvent(t)},D.prototype.collectEnvInfo=function(){var n=this;Promise.all([new Promise(function(t,e){n.sdk.getSystemInfo({success:t,fail:e})}),new Promise(function(t,e){n.sdk.getNetworkType({success:t,fail:e})})]).then(function(t){var e=i(t,2),t=e[0],e=e[1];t&&e&&n.callback({ev_type:f.ENV_INFO,data:n.normalizeEnvInfo(t,e)})}).catch(function(){n.callback({ev_type:f.ENV_INFO,data:x()})})},D.prototype.collectFinderConfig=function(){var t,e=this;null!==(t=this.options.finderInstance)&&void 0!==t&&t.getToken(function(t){e.callback({ev_type:f.FINDER_CONFIG,data:{user_unique_id:t.user_unique_id,ssid:t.ssid}})})},D.prototype.collectTesterSdkVersion=function(){var t,e=this,n=null===(t=this.options.finderInstance)||void 0===t?void 0:t.getAbSdkVersion();n&&this.callback({ev_type:f.TESTER_SDK_VERSION,data:{ab_sdk_version:n}}),null!==(n=null===(t=this.options.finderInstance)||void 0===t?void 0:t.onAbSdkVersionChange)&&void 0!==n&&n.call(t,function(t){e.callback({ev_type:f.TESTER_SDK_VERSION,data:{ab_sdk_version:t}})})},D.prototype.getStorage=function(t){return this.sdk.getStorageSync(t)},D.prototype.setStorage=function(t,e){return this.sdk.setStorageSync(t,e)},D.prototype.setupTransport=function(){var t,e,n=this;return this.reportUrl=(t=this.options.reportDomain,e=this.options.reportPath,"https://"+t+e),{sendEvent:function(t){n.sdk.request({url:n.reportUrl,method:"POST",data:t})},request:function(t){n.sdk.request(t)}}},D.prototype.hookAppFn=function(t){var s=this,c=this.callback;return w(t,[g.onLaunch,g.onShow,g.onHide,g.onError,g.onUnhandledRejection],function(i,a){return function(t){switch(i){case g.onShow:var e=l();s.appSessionId=e,c({ev_type:f.APP_SESSION,data:{appSessionId:e}});break;case g.onError:c({ev_type:f.GLOBAL_JS_ERROR,data:{name:(r=(o=t).split("\n"))[0],message:r[1],stack:r.slice(1).join("\n"),rawMessage:o}});break;case g.onUnhandledRejection:o=(r=t).promise,r=t.reason,n=String(r),o.catch(function(t){return{name:k,message:String(t),stack:(null==t?void 0:t.stack)||"",rawMessage:n}}).then(function(t){c({ev_type:f.GLOBAL_JS_ERROR,data:t})})}var n,o,r;null!=a&&a.call(this,t)}})},D.prototype.hookPageFn=function(t){return w(t,[S.onLoad,S.onShow,S.onReady],this._pageLifeCycleHandlers())},D.prototype.hookComponentFn=function(t){return e=t,o=[S.onLoad,S.onShow,S.onReady],r=this._pageLifeCycleHandlers(),function(n){return n.methods||(n.methods={}),o.forEach(function(t){var e=n.methods[t];n.methods[t]=r(t,e)}),e(n)};var e,o,r},D.prototype._pageLifeCycleHandlers=function(){var c=this,d=this.callback;return function(a,e){function s(t){try{null!=e&&e.call(this,t)}catch(t){d({ev_type:f.JS_ERROR,data:{name:t.name,message:t.message,stack:t.stack,rawMessage:String(t)},context:c.getContext()})}}return function(t){var e,n=(e=getCurrentPages())[e.length-1].route;switch(a){case S.onLoad:c.pid=n,c.hookSetData(this);var o=Date.now(),r=[c.deviceId,c.appSessionId,c.pid,o].join("|");return c.pageSessionId=r,c.taskTracks[r]={tasks:[],timing:{firstReqStart:o,firstReqEnd:0,firstLoadStart:o,firstLoadEnd:0},ready:!1,ended:!1},d({ev_type:f.PAGE_SESSION,data:{pid:n,pageSessionId:r}}),s.call(this,t),this[b]=r,void(this[T]={onLoadStart:o,onLoadEnd:Date.now(),onShowStart:0,onShowEnd:0,onReadyStart:0,onReadyEnd:0});case S.onShow:var i,r=this[b];return c.pageSessionId=r,d({ev_type:f.PAGE_SESSION,data:{pid:n,pageSessionId:r}}),(i=this[T]).onShowStart=i.onShowStart||Date.now(),s.call(this,t),void(i.onShowEnd=i.onShowEnd||Date.now());case S.onReady:(i=this[T]).onReadyStart=Date.now(),s.call(this,t),i.onReadyEnd=Date.now(),d({ev_type:f.PAGE_ON_READY,data:i});r=c.getTaskTrack();return r.ready=!0,!r.timing.firstReqEnd&&r.tasks.every(function(t){return t.completed||"SET_DATA"===t.type})&&(r.timing.firstReqEnd=r.timing.firstReqStart),void(r.tasks.every(function(t){return t.completed})&&(r.timing.firstLoadEnd=i.onReadyEnd,c.endTrack(r)))}s.call(this,t)}}},D.prototype.hookSdk=function(){this.hookRequest()},D.prototype.hookRequest=function(){var u=this,l=this,h=this.callback;I(this.sdk,[E.request],function(t,i){return function(a){if(u.shouldIgnoreUrl(a.url))return i(a);var s=a.success,o=a.fail,e=a.complete,c=y(null!==(r=a.data)&&void 0!==r?r:""),d=u.addTask("REQUEST"),p=Date.now(),t=u.captureContext(function(t){var e,n,o,r,i=Date.now();h({ev_type:f.REQUEST,data:{req_url:a.url,method:null!==(o=a.method)&&void 0!==o?o:"GET",err_msg:300<=t.statusCode?_(t.data):"",req_status:1,req_start_time:p,req_end_time:i,resp_status:t.statusCode,header:null!==(r=a.header)&&void 0!==r?r:{},req_param:300<=t.statusCode?_(a.data):"",req_size:c,resp_size:(o=t,i=null!==(r=Object.keys(null!==(i=o.header)&&void 0!==i?i:{}).find(function(t){return"content-legth"===t.toLowerCase()}))&&void 0!==r?r:"",null!==(r=o.header)&&void 0!==r&&r[i]?parseInt(o.header[i]):y(o.data)),perf:t.profile?(e=t.profile,n={},["redirectStart","redirectEnd","fetchStart","domainLookupStart","domainLookupEnd","connectStart","connectEnd","SSLconnectionStart","SSLconnectionEnd","requestStart","requestEnd","responseStart","responseEnd","rtt","httpRttEstimate","transportRttEstimate"].forEach(function(t){n[t]=e[t]}),n):{redirectStart:0,redirectEnd:0,fetchStart:0,domainLookupStart:0,domainLookupEnd:0,connectStart:0,connectEnd:0,SSLconnectionStart:0,SSLconnectionEnd:0,requestStart:0,requestEnd:0,responseStart:0,responseEnd:0,rtt:0,httpRttEstimate:0,transportRttEstimate:0}},context:l.capturedContext}),l.taskStack.push(d);try{null!=s&&s.call(this,t)}finally{l.taskStack.pop()}}),n=u.captureContext(function(t){var e,n=Date.now();h({ev_type:f.REQUEST,data:{req_url:a.url,method:null!==(e=a.method)&&void 0!==e?e:"GET",err_msg:null!==(e=t.errMsg)&&void 0!==e?e:"",req_status:0,req_start_time:p,req_end_time:n,resp_status:0,req_param:_(a.data),header:null!==(n=a.header)&&void 0!==n?n:{},req_size:c,resp_size:0,perf:{}},context:l.capturedContext}),l.taskStack.push(d);try{null!=o&&o.call(this,t)}finally{l.taskStack.pop()}}),r=u.captureContext(function(t){l.taskStack.push(d);try{null!=e&&e.call(this,t)}finally{l.taskStack.pop()}l.endTask(d,Date.now())}),r=v(v({},a),{success:t,fail:n,complete:r});return i(r)}})},D.prototype.shouldIgnoreUrl=function(t){return t===this.reportUrl},D.prototype.hookSetData=function(t){var s=this;I(t,["setData"],function(t,e){return function(n,t){var o=this,r=t,i=s.addTask("SET_DATA"),a=Date.now(),t=s.captureContext(function(){var t=Date.now(),e=_(n);s.callback({ev_type:f.SET_DATA,data:{setDataStart:a,setDataEnd:t,setDataSize:h(e),data:e},context:s.capturedContext}),s.taskStack.push(i);try{null!=r&&r.call(o)}catch(t){s.callback({ev_type:f.JS_ERROR,data:{name:t.name,message:t.message,stack:t.stack,rawMessage:String(t)},context:s.getContext()})}finally{s.taskStack.pop()}s.endTask(i,t)});e.call(this,n,t)}})},D.prototype.collectDeviceId=function(){var t=this.getStorage(R);t||(t=l(),this.setStorage(R,t)),this.deviceId=t,this.callback({ev_type:f.DEVICE_ID,data:{deviceId:t}})},D.prototype.getContext=function(){var t;return null!==(t=this.capturedContext)&&void 0!==t?t:this.currentContext()},D.prototype.currentContext=function(){return{pid:this.pid,pageSessionId:this.pageSessionId,context:this.options.context}},D.prototype.captureContext=function(o){var r=this,i=this.getContext();return function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];r.capturedContext=i;try{t=o.apply(this,e)}catch(t){r.callback({ev_type:f.JS_ERROR,data:{name:t.name,message:t.message,stack:t.stack,rawMessage:String(t)},context:i})}finally{r.capturedContext=null}return t}},D.prototype.addTask=function(t){var e=this.getTaskTrack();if(!e||e.ended)return 0;var n=this.taskStack.length&&this.taskStack[this.taskStack.length-1];if(e.ready&&(!n||!e.tasks.some(function(t){return t.id===n})))return 0;var o=e.tasks.length+1;return e.tasks.push({id:o,type:t,completed:!1}),o},D.prototype.endTask=function(t,e){var n=this.getTaskTrack();t<=0||!n||n.ended||((t=n.tasks[t-1]).completed=!0,n.timing.firstReqEnd||"REQUEST"!==t.type||(n.timing.firstReqEnd=e),n.tasks.every(function(t){return t.completed})&&(n.timing.firstLoadEnd=e,this.endTrack(n)))},D.prototype.endTrack=function(t){t.ready&&(t.ended=!0,this.callback({ev_type:f.PAGE_FIRST_LOAD,data:t.timing,context:this.getContext()}))},D.prototype.getTaskTrack=function(){var t=this.getContext().pageSessionId;return this.taskTracks[t]},D);function D(t,e){this.originalAppFn=App,this.originalPageFn=Page,this.reportUrl="",this.deviceId="",this.appSessionId="",this.pageSessionId="",this.capturedContext=null,this.taskStack=[],this.taskTracks={},this.options=t,this.pid=t.pid,this.callback=e}function P(){var t=null!==C&&C.apply(this,arguments)||this;return t.sdk=my,t}var N,L=(t(P,C=A),P.prototype.normalizeEnvInfo=function(t,e){return{host_platform:"my",host_app_name:t.app,host_app_version:t.version,platform:t.platform,sdk_version:t.SDKVersion,os_name:t.platform,os_version:t.system,device_brand:t.brand,device_model:t.model,screen_width:t.screenWidth,screen_height:t.screenHeight,resolution:t.screenWidth+"x"+t.screenHeight,pixel_ratio:t.pixelRatio,network_type:e.networkType}},P);function q(){var t=null!==N&&N.apply(this,arguments)||this;return t.sdk=swan,t}var j,F=(t(q,N=A),q.prototype.normalizeEnvInfo=function(t,e){return{host_platform:"swan",host_app_name:t.host,host_app_version:t.version,platform:t.platform,sdk_version:t.SDKVersion,os_name:t.platform,os_version:t.system,device_brand:t.brand,device_model:t.model,screen_width:t.screenWidth,screen_height:t.screenHeight,resolution:t.screenWidth+"x"+t.screenHeight,pixel_ratio:t.pixelRatio,network_type:e.networkType}},q);function B(){var t=null!==j&&j.apply(this,arguments)||this;return t.sdk=tt,t}var G,U=(t(B,j=A),B.prototype.normalizeEnvInfo=function(t,e){return{host_platform:"tt",host_app_name:t.appName,host_app_version:t.version,platform:t.platform,sdk_version:t.SDKVersion,os_name:t.platform,os_version:t.system,device_brand:t.brand,device_model:t.model,screen_width:t.screenWidth,screen_height:t.screenHeight,resolution:t.screenWidth+"x"+t.screenHeight,pixel_ratio:t.pixelRatio,network_type:e.networkType}},B);function V(){var t=null!==G&&G.apply(this,arguments)||this;return t.sdk=wx,t}var Q=(t(V,G=A),V.prototype.normalizeEnvInfo=function(t,e){return{host_platform:"wx",host_app_name:"Weixin",host_app_version:t.version,platform:t.platform,sdk_version:t.SDKVersion,os_name:t.system.split(" ")[0],os_version:t.system.split(" ")[1],device_brand:t.brand,device_model:t.model,screen_width:t.screenWidth,screen_height:t.screenHeight,resolution:t.screenWidth+"x"+t.screenHeight,pixel_ratio:t.pixelRatio,network_type:e.networkType}},V);var H,A=function(){if("undefined"!=typeof tt)return U;if("undefined"!=typeof my)return L;if("undefined"!=typeof swan)return F;if("undefined"!=typeof wx)return Q;throw new Error("unsupported mini program")}(),W="apmplus.volces.com",M="/monitor_microapp/collect",J="/",K=20,z=10,Y=1e3,X="cannot get context before init";function Z(t,e,n){var o,r,i=Object.assign({},t,e,n),a={};if(i.context&&u(i.context))try{for(var s=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],o=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&o>=t.length?void 0:t)&&t[o++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(Object.keys(i.context)),c=s.next();!c.done;c=s.next()){var d=c.value,p=i.context[d];a[d]="[object String]"===Object.prototype.toString.call(p)?p:_(p)}}catch(t){o={error:t}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return i.context=a,i}function $(t,e){var n=H.call(this,t)||this;n.deviceId="",n.envInfo={},n.appSessionId="",n.pageSessionId="",n.preQueue=[],n.ready=!1,n.config=t,n.pid=t.pid;t=n.config,t=Object.assign({},t);return n.backend=new e(t,n.reportBackendEvent.bind(n)),n.backend.init(),n.breadcrumbs=[],n.sampleHit=(t=n.config.sampleRate,Math.random()<Number(t)),n.backend.collectEnvInfo(),n.config.finderInstance&&(n.backend.collectFinderConfig(),n.backend.collectTesterSdkVersion()),n}var et=(t($,H=s),$.prototype.updateConfig=function(t){var e;this.config=(e=this.config,Object.assign({},e,t)),null!==(t=this.finderConfig)&&void 0!==t&&t.user_unique_id&&(this.config.userId=this.finderConfig.user_unique_id)},$.prototype.reportError=function(t,e){this.reportEvent({ev_type:n.ReportEventType.JS_ERROR,event:{name:t.name,message:t.message,stack:null!==(t=t.stack)&&void 0!==t?t:""},breadcrumbs:a([],i(this.breadcrumbs),!1)},e)},$.prototype.reportEvent=function(t,e){this.ready?H.prototype.sendEvent.call(this,v(v({},t),{context:e})):this.preQueue.push(v(v({},t),{context:e}))},$.prototype.addBreadcrumb=function(t,e){var n=this.config.maxBreadcrumbs,t=v(v({},e),{type:t,timestamp:Date.now()});this.breadcrumbs=0<=n?a(a([],i(this.breadcrumbs),!1),[t],!1).slice(-n):a(a([],i(this.breadcrumbs),!1),[t],!1)},$.prototype.flush=function(){this._uploadQueue()},$.prototype.sendPageView=function(){this.reportEvent({ev_type:n.ReportEventType.PAGEVIEW})},$.prototype.reportBackendEvent=function(t){switch(t.ev_type){case f.ENV_INFO:this.envInfo=t.data,this.unlock();break;case f.DEVICE_ID:this.deviceId=t.data.deviceId;break;case f.FINDER_CONFIG:this.finderConfig=t.data;break;case f.TESTER_SDK_VERSION:this.testerAbSdkVersion=t.data.ab_sdk_version;break;case f.NETWORK_STATUS:this.envInfo&&(this.envInfo=v(v({},this.envInfo),{network_type:t.data.network_type}));break;case f.GLOBAL_JS_ERROR:this.reportEvent({ev_type:n.ReportEventType.JS_ERROR,event:t.data,breadcrumbs:a([],i(this.breadcrumbs),!1)});break;case f.JS_ERROR:this.reportEvent({ev_type:n.ReportEventType.JS_ERROR,event:t.data,breadcrumbs:a([],i(this.breadcrumbs),!1)},t.context);break;case f.APP_SESSION:this.appSessionId=t.data.appSessionId;break;case f.PAGE_SESSION:this.pageSessionId!==t.data.pageSessionId&&(this.addBreadcrumb(n.BreadcrumbType.DOM,{category:e.ROUTE,message:t.data.pid}),this.pid=t.data.pid,this.pageSessionId=t.data.pageSessionId,this.sendPageView());break;case f.REQUEST:this.reportEvent({ev_type:n.ReportEventType.REQUEST,event:t.data},t.context);break;case f.SET_DATA:this.reportEvent({ev_type:n.ReportEventType.SET_DATA,event:t.data},t.context);break;case f.PAGE_ON_READY:this.reportEvent({ev_type:n.ReportEventType.ON_READY,event:t.data});break;case f.PAGE_FIRST_LOAD:this.reportEvent({ev_type:n.ReportEventType.FIRST_LOAD,event:t.data},t.context)}},$.prototype._shouldSend=function(){return this.sampleHit},$.prototype.buildParams=function(t){var e;return v(v({},t),{common:v(v({},this.envInfo),{aid:this.config.aid,pid:null!==(e=null===(e=t.context)||void 0===e?void 0:e.pid)&&void 0!==e?e:this.pid,rangers_sdk_version:this.config.version,timestamp:Date.now(),user_unique_id:this.finderConfig?this.finderConfig.user_unique_id:this.config.userId||this.deviceId,device_id:this.deviceId,session_id:this.config.sessionId,app_session_id:this.appSessionId,page_session_id:null!==(e=null===(e=t.context)||void 0===e?void 0:e.pageSessionId)&&void 0!==e?e:this.pageSessionId,context:null!==(t=null===(t=t.context)||void 0===t?void 0:t.context)&&void 0!==t?t:this.config.context,uuid:null===(t=this.finderConfig)||void 0===t?void 0:t.user_unique_id,ssid:null===(t=this.finderConfig)||void 0===t?void 0:t.ssid,ab_sdk_version:this.testerAbSdkVersion}),context:void 0})},$.prototype._request=function(t){var e;t&&t.event&&(e=t.type,t=t.event,"post"===e&&this.backend.sendEvent({ev_type:r.BATCH,list:t.list}))},$.prototype.unlock=function(){var e=this;this.ready=!0,this.preQueue.forEach(function(t){H.prototype.sendEvent.call(e,t)}),this.preQueue=[]},$);function nt(t){this.version="0.4.3-alpha.0",this.Backend=t.Backend,this.defaultConfig={context:{},maxBatchReportLength:z,batchReportWait:Y,userId:"",sampleRate:1,sessionId:m(),reportDomain:W,reportPath:M,pid:J,maxBreadcrumbs:K,hookPath:!0,hookRequest:!0,enableCapture:!0}}A=new(nt.prototype.init=function(t){if(!this.client){if(null==t||!t.aid)throw new Error("cannot init without aid");this.userConfig=t;t=Z(this.defaultConfig,this.userConfig,{version:this.version});this.client=new et(t,this.Backend)}},nt.prototype.config=function(t){if(!this.userConfig||!this.client)throw new Error("cannot config before init");var e;this.userConfig=(e=this.userConfig,Object.assign({},e,t)),this.updateClientConfig()},nt.prototype.capture=function(t){var e;null!==(e=this.client)&&void 0!==e&&e.reportError(t)},nt.prototype.report=function(t){var e;null!==(e=this.client)&&void 0!==e&&e.reportEvent(t)},nt.prototype.addBreadcrumb=function(t,e){var n;null!==(n=this.client)&&void 0!==n&&n.addBreadcrumb(t,e)},nt.prototype.sendNow=function(){var t;null!==(t=this.client)&&void 0!==t&&t.flush()},Object.defineProperty(nt.prototype,"context",{get:function(){var n=this,o={set:function(t,e){if(!n.userConfig)throw new Error(X);return n.userConfig.context||(n.userConfig.context={}),n.userConfig.context[t]=e,n.updateClientConfig(),o},delete:function(t){if(!n.userConfig)throw new Error(X);return n.userConfig.context&&t in n.userConfig.context&&delete n.userConfig.context[t],n.updateClientConfig(),o},clear:function(){if(!n.userConfig)throw new Error(X);return n.userConfig.context={},n.updateClientConfig(),o},get:function(t){var e;if(!n.userConfig)throw new Error(X);return null===(e=n.userConfig.context)||void 0===e?void 0:e[t]},toObject:function(){if(!n.userConfig)throw new Error(X);return v({},n.userConfig.context)}};return o},enumerable:!1,configurable:!0}),nt.prototype.updateClientConfig=function(){var t;this.userConfig&&this.client&&(t=Z(this.defaultConfig,this.userConfig,{version:this.version}),this.client.updateConfig(t))},nt)({Backend:A});n.default=A,Object.defineProperty(n,"__esModule",{value:!0})});

@@ -1485,3 +1485,3 @@ /*! *****************************************************************************

function Rangers(options) {
this.version = '0.4.0';
this.version = '0.4.3-alpha.0';
this.Backend = options.Backend;

@@ -1488,0 +1488,0 @@ this.defaultConfig = getDefaultConfig();

@@ -1489,3 +1489,3 @@ 'use strict';

function Rangers(options) {
this.version = '0.4.0';
this.version = '0.4.3-alpha.0';
this.Backend = options.Backend;

@@ -1492,0 +1492,0 @@ this.defaultConfig = getDefaultConfig();

{
"name": "@apm-insight-web/rangers-mini-sdk",
"version": "0.4.0",
"version": "0.4.3-alpha.0",
"main": "cn/index.cjs.js",

@@ -12,4 +12,5 @@ "module": "cn/index.esm.js",

"devDependencies": {
"@slardar/sdk-core": "3.6.28",
"@slardar/types": "3.5.13-alpha.1.0"
"@slardar/rollup": "0.0.3-alpha.0",
"@slardar/sdk-core": "3.6.31-alpha.0",
"@slardar/types": "3.5.16-alpha.0"
},

@@ -53,5 +54,6 @@ "publishConfig": {

"test": "ava",
"esm": "tsc -b ./tsconfig.json",
"build": "batch-rollup -d ./rollup",
"cover": "nyc --reporter=json ava && nyc report"
},
"gitHead": "95c5fcddfacdcaf7f0f11177d44dc6deffa5d013"
}
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc