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
3
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.0.15 to 0.0.16

cn/index.0.0.16.cn.js

2

cn/index.cjs.js

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

function Rangers(options) {
this.version = '0.0.15';
this.version = '0.0.16';
this.Backend = options.Backend;

@@ -1430,0 +1430,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)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function t(t,e){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(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(i(arguments[e]));return t}function u(t){return"object"==typeof t&&null!==t&&(t=t,"[object Array]"!==Object.prototype.toString.call(t))}(d=n.BreadcrumbType||(n.BreadcrumbType={})).DOM="dom",d.HTTP="http",(e=e||{}).ROUTE="route",(r=r||{}).BATCH="batch",(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",(d=f=f||{}).DEVICE_ID="device_id",d.FINDER_CONFIG="finder_config",d.ENV_INFO="env_info",d.NETWORK_STATUS="network_status",d.JS_ERROR="js_error",d.GLOBAL_JS_ERROR="global_js_error",d.APP_SESSION="app_session",d.PAGE_SESSION="page_session",d.REQUEST="request",d.SET_DATA="set_data",d.PAGE_ON_READY="page_on_ready",d.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 p,d=(t(h,p=s),Object.defineProperty(h.prototype,"ready",{get:function(){return this.isReady},set:function(t){this.isReady=t,this.isReady&&this._uploadQueue()},enumerable:!1,configurable:!0}),h.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)))},h.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"}))},h.prototype._request=function(t){},h);function h(t){var e,n=p.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;return[e[t[o++]],e[t[o++]],e[t[o++]],e[t[o++]],"-",e[t[o++]],e[t[o++]],"-",e[t[o++]],e[t[o++]],"-",e[t[o++]],e[t[o++]],"-",e[t[o++]],e[t[o++]],e[t[o++]],e[t[o++]],e[t[+o]],e[t[15]]].join("")}(t)}function _(e){try{return JSON.stringify(e)}catch(t){return String(e)}}function y(t){return encodeURI(t).split(/%(?:u[0-9A-F]{2})?[0-9A-F]{2}|./).length-1}function g(t){return t?t instanceof ArrayBuffer?t.byteLength:u(t)?y(_(t)):t.length||0:0}var S,m,E,k=l,R="RANGERS_MINI_SDK_DEVICE_ID",b="RANGERS_PAGE_SESSION_ID",w="RANGERS_PAGE_TIMING";(s={}).TT="tt",s.WX="wx",s.MY="my",s.SWAN="swan",(s=S=S||{}).onLaunch="onLaunch",s.onShow="onShow",s.onHide="onHide",s.onError="onError",s.onUnhandledRejection="onUnhandledRejection",s.onPageNotFound="onPageNotFound",(s=m=m||{}).onLoad="onLoad",s.onShow="onShow",s.onReady="onReady",s.onHide="onHide",s.onUnload="onUnload",s.onPullDownRefresh="onPullDownRefresh",(E=E||{}).request="request";function T(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:!1,configurable:!1,writable:!1,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":C,host_app_name:C,host_app_version:C,platform:C,sdk_version:C,os_name:C,os_version:C,device_brand:C,device_model:C,screen_height:0,screen_width:0,resolution:C,pixel_ratio:0,network_type:C}}var C="unknown",s=(O.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}})})},O.prototype.sendEvent=function(t){var e;null!==(e=this.transport)&&void 0!==e&&e.sendEvent(t)},O.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()})})},O.prototype.collectFinderConfig=function(){var e=this;this.options.finderInstance&&this.options.finderInstance.getToken(function(t){e.callback({ev_type:f.FINDER_CONFIG,data:{user_unique_id:t.user_unique_id}})})},O.prototype.getStorage=function(t){return this.sdk.getStorageSync(t)},O.prototype.setStorage=function(t,e){return this.sdk.setStorageSync(t,e)},O.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)}}},O.prototype.hookAppFn=function(t){var s=this,c=this.callback;return T(t,[S.onLaunch,S.onShow,S.onHide,S.onError,S.onUnhandledRejection],function(i,a){return function(t){switch(i){case S.onShow:var e=l();s.appSessionId=e,c({ev_type:f.APP_SESSION,data:{appSessionId:e}});break;case S.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 S.onUnhandledRejection:o=(r=t).promise,r=r.reason,n=String(r),o.catch(function(t){return{name:"UnhandledRejection",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)}})},O.prototype.hookPageFn=function(t){return T(t,[m.onLoad,m.onShow,m.onReady],this._pageLifeCycleHandlers())},O.prototype.hookComponentFn=function(t){return e=t,o=[m.onLoad,m.onShow,m.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},O.prototype._pageLifeCycleHandlers=function(){var c=this,p=this.callback;return function(a,e){function s(t){try{null!=e&&e.call(this,t)}catch(t){p({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 m.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},p({ev_type:f.PAGE_SESSION,data:{pid:n,pageSessionId:r}}),s.call(this,t),this[b]=r,void(this[w]={onLoadStart:o,onLoadEnd:Date.now(),onShowStart:0,onShowEnd:0,onReadyStart:0,onReadyEnd:0});case m.onShow:var i,r=this[b];return c.pageSessionId=r,p({ev_type:f.PAGE_SESSION,data:{pid:n,pageSessionId:r}}),(i=this[w]).onShowStart=i.onShowStart||Date.now(),s.call(this,t),void(i.onShowEnd=i.onShowEnd||Date.now());case m.onReady:(i=this[w]).onReadyStart=Date.now(),s.call(this,t),i.onReadyEnd=Date.now(),p({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)}}},O.prototype.hookSdk=function(){this.hookRequest()},O.prototype.hookRequest=function(){var u=this,h=this,l=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=g(null!==(r=a.data)&&void 0!==r?r:""),p=u.addTask("REQUEST"),d=Date.now(),t=u.captureContext(function(t){var e,n,o,r,i=Date.now();l({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:d,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]):g(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):{}},context:h.capturedContext}),h.taskStack.push(p);try{null!=s&&s.call(this,t)}finally{h.taskStack.pop()}}),n=u.captureContext(function(t){var e,n=Date.now();l({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:d,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:h.capturedContext}),h.taskStack.push(p);try{null!=o&&o.call(this,t)}finally{h.taskStack.pop()}}),r=u.captureContext(function(t){h.taskStack.push(p);try{null!=e&&e.call(this,t)}finally{h.taskStack.pop()}h.endTask(p,Date.now())}),r=v(v({},a),{success:t,fail:n,complete:r});return i(r)}})},O.prototype.shouldIgnoreUrl=function(t){return t===this.reportUrl},O.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:y(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)}})},O.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}})},O.prototype.getContext=function(){var t;return null!==(t=this.capturedContext)&&void 0!==t?t:this.currentContext()},O.prototype.currentContext=function(){return{pid:this.pid,pageSessionId:this.pageSessionId,context:this.options.context}},O.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}},O.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},O.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)))},O.prototype.endTrack=function(t){t.ready&&(t.ended=!0,this.callback({ev_type:f.PAGE_FIRST_LOAD,data:t.timing,context:this.getContext()}))},O.prototype.getTaskTrack=function(){var t=this.getContext().pageSessionId;return this.taskTracks[t]},O);function O(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}var A,D=(t(P,A=s),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 P(){var t=null!==A&&A.apply(this,arguments)||this;return t.sdk=my,t}var N,L=(t(q,N=s),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 q(){var t=null!==N&&N.apply(this,arguments)||this;return t.sdk=swan,t}var j,F=(t(G,j=s),G.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}},G);function G(){var t=null!==j&&j.apply(this,arguments)||this;return t.sdk=tt,t}var U,B=(t(Q,U=s),Q.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}},Q);function Q(){var t=null!==U&&U.apply(this,arguments)||this;return t.sdk=wx,t}var s=function(){if("undefined"!=typeof tt)return F;if("undefined"!=typeof my)return D;if("undefined"!=typeof swan)return L;if("undefined"!=typeof wx)return B;throw new Error("unsupported mini program")}(),W="tbm.snssdk.com",H="/monitor_microapp/collect",V="/",J=20,M=10,z=1e3,K="cannot get context before init";function Y(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 p=c.value,d=i.context[p];a[p]=(p=d,"[object String]"===Object.prototype.toString.call(p)?d:_(d))}}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}var X,Z=(t($,X=d),$.prototype.updateConfig=function(t){var e;this.config=(e=this.config,t=t,Object.assign({},e,t)),this.finderConfig&&(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(this.breadcrumbs)},e)},$.prototype.reportEvent=function(t,e){this.ready?X.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(this.breadcrumbs,[t]).slice(-n):a(this.breadcrumbs,[t])},$.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.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(this.breadcrumbs)});break;case f.JS_ERROR:this.reportEvent({ev_type:n.ReportEventType.JS_ERROR,event:t.data,breadcrumbs:a(this.breadcrumbs)},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.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}),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){X.prototype.sendEvent.call(e,t)}),this.preQueue=[]},$);function $(t,e){var n=X.call(this,t)||this;n.finderConfig=null,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.backend.collectEnvInfo(),n.config.finderInstance&&n.backend.collectFinderConfig(),n}function et(t){this.version="0.0.15",this.Backend=t.Backend,this.defaultConfig={context:{},maxBatchReportLength:M,batchReportWait:z,userId:"",sessionId:k(),reportDomain:W,reportPath:H,pid:V,maxBreadcrumbs:J,hookPath:!0,hookRequest:!0,enableCapture:!0}}s=new(et.prototype.init=function(t){if(!this.client){if(null==t||!t.aid)throw new Error("cannot init without aid");this.userConfig=t;t=Y(this.defaultConfig,this.userConfig,{version:this.version});this.client=new Z(t,this.Backend)}},et.prototype.config=function(t){if(!this.userConfig||!this.client)throw new Error("cannot config before init");var e;this.userConfig=(e=this.userConfig,t=t,Object.assign({},e,t)),this.updateClientConfig()},et.prototype.capture=function(t){var e;null!==(e=this.client)&&void 0!==e&&e.reportError(t)},et.prototype.report=function(t){var e;null!==(e=this.client)&&void 0!==e&&e.reportEvent(t)},et.prototype.addBreadcrumb=function(t,e){var n;null!==(n=this.client)&&void 0!==n&&n.addBreadcrumb(t,e)},et.prototype.sendNow=function(){var t;null!==(t=this.client)&&void 0!==t&&t.flush()},Object.defineProperty(et.prototype,"context",{get:function(){var n=this,o={set:function(t,e){if(!n.userConfig)throw new Error(K);return n.userConfig.context||(n.userConfig.context={}),n.userConfig.context[t]=e,n.updateClientConfig(),o},delete:function(t){if(!n.userConfig)throw new Error(K);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(K);return n.userConfig.context={},n.updateClientConfig(),o},get:function(t){var e;if(!n.userConfig)throw new Error(K);return null===(e=n.userConfig.context)||void 0===e?void 0:e[t]},toObject:function(){if(!n.userConfig)throw new Error(K);return v({},n.userConfig.context)}};return o},enumerable:!1,configurable:!0}),et.prototype.updateClientConfig=function(){var t;this.userConfig&&this.client&&(t=Y(this.defaultConfig,this.userConfig,{version:this.version}),this.client.updateConfig(t))},et)({Backend:s});n.default=s,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)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function t(t,e){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(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(i(arguments[e]));return t}function u(t){return"object"==typeof t&&null!==t&&(t=t,"[object Array]"!==Object.prototype.toString.call(t))}(d=n.BreadcrumbType||(n.BreadcrumbType={})).DOM="dom",d.HTTP="http",(e=e||{}).ROUTE="route",(r=r||{}).BATCH="batch",(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",(d=f=f||{}).DEVICE_ID="device_id",d.FINDER_CONFIG="finder_config",d.ENV_INFO="env_info",d.NETWORK_STATUS="network_status",d.JS_ERROR="js_error",d.GLOBAL_JS_ERROR="global_js_error",d.APP_SESSION="app_session",d.PAGE_SESSION="page_session",d.REQUEST="request",d.SET_DATA="set_data",d.PAGE_ON_READY="page_on_ready",d.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 p,d=(t(h,p=s),Object.defineProperty(h.prototype,"ready",{get:function(){return this.isReady},set:function(t){this.isReady=t,this.isReady&&this._uploadQueue()},enumerable:!1,configurable:!0}),h.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)))},h.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"}))},h.prototype._request=function(t){},h);function h(t){var e,n=p.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;return[e[t[o++]],e[t[o++]],e[t[o++]],e[t[o++]],"-",e[t[o++]],e[t[o++]],"-",e[t[o++]],e[t[o++]],"-",e[t[o++]],e[t[o++]],"-",e[t[o++]],e[t[o++]],e[t[o++]],e[t[o++]],e[t[+o]],e[t[15]]].join("")}(t)}function _(e){try{return JSON.stringify(e)}catch(t){return String(e)}}function y(t){return encodeURI(t).split(/%(?:u[0-9A-F]{2})?[0-9A-F]{2}|./).length-1}function g(t){return t?t instanceof ArrayBuffer?t.byteLength:u(t)?y(_(t)):t.length||0:0}var S,m,E,k=l,R="RANGERS_MINI_SDK_DEVICE_ID",b="RANGERS_PAGE_SESSION_ID",w="RANGERS_PAGE_TIMING";(s={}).TT="tt",s.WX="wx",s.MY="my",s.SWAN="swan",(s=S=S||{}).onLaunch="onLaunch",s.onShow="onShow",s.onHide="onHide",s.onError="onError",s.onUnhandledRejection="onUnhandledRejection",s.onPageNotFound="onPageNotFound",(s=m=m||{}).onLoad="onLoad",s.onShow="onShow",s.onReady="onReady",s.onHide="onHide",s.onUnload="onUnload",s.onPullDownRefresh="onPullDownRefresh",(E=E||{}).request="request";function T(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:!1,configurable:!1,writable:!1,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":C,host_app_name:C,host_app_version:C,platform:C,sdk_version:C,os_name:C,os_version:C,device_brand:C,device_model:C,screen_height:0,screen_width:0,resolution:C,pixel_ratio:0,network_type:C}}var C="unknown",s=(O.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}})})},O.prototype.sendEvent=function(t){var e;null!==(e=this.transport)&&void 0!==e&&e.sendEvent(t)},O.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()})})},O.prototype.collectFinderConfig=function(){var e=this;this.options.finderInstance&&this.options.finderInstance.getToken(function(t){e.callback({ev_type:f.FINDER_CONFIG,data:{user_unique_id:t.user_unique_id}})})},O.prototype.getStorage=function(t){return this.sdk.getStorageSync(t)},O.prototype.setStorage=function(t,e){return this.sdk.setStorageSync(t,e)},O.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)}}},O.prototype.hookAppFn=function(t){var s=this,c=this.callback;return T(t,[S.onLaunch,S.onShow,S.onHide,S.onError,S.onUnhandledRejection],function(i,a){return function(t){switch(i){case S.onShow:var e=l();s.appSessionId=e,c({ev_type:f.APP_SESSION,data:{appSessionId:e}});break;case S.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 S.onUnhandledRejection:o=(r=t).promise,r=r.reason,n=String(r),o.catch(function(t){return{name:"UnhandledRejection",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)}})},O.prototype.hookPageFn=function(t){return T(t,[m.onLoad,m.onShow,m.onReady],this._pageLifeCycleHandlers())},O.prototype.hookComponentFn=function(t){return e=t,o=[m.onLoad,m.onShow,m.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},O.prototype._pageLifeCycleHandlers=function(){var c=this,p=this.callback;return function(a,e){function s(t){try{null!=e&&e.call(this,t)}catch(t){p({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 m.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},p({ev_type:f.PAGE_SESSION,data:{pid:n,pageSessionId:r}}),s.call(this,t),this[b]=r,void(this[w]={onLoadStart:o,onLoadEnd:Date.now(),onShowStart:0,onShowEnd:0,onReadyStart:0,onReadyEnd:0});case m.onShow:var i,r=this[b];return c.pageSessionId=r,p({ev_type:f.PAGE_SESSION,data:{pid:n,pageSessionId:r}}),(i=this[w]).onShowStart=i.onShowStart||Date.now(),s.call(this,t),void(i.onShowEnd=i.onShowEnd||Date.now());case m.onReady:(i=this[w]).onReadyStart=Date.now(),s.call(this,t),i.onReadyEnd=Date.now(),p({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)}}},O.prototype.hookSdk=function(){this.hookRequest()},O.prototype.hookRequest=function(){var u=this,h=this,l=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=g(null!==(r=a.data)&&void 0!==r?r:""),p=u.addTask("REQUEST"),d=Date.now(),t=u.captureContext(function(t){var e,n,o,r,i=Date.now();l({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:d,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]):g(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):{}},context:h.capturedContext}),h.taskStack.push(p);try{null!=s&&s.call(this,t)}finally{h.taskStack.pop()}}),n=u.captureContext(function(t){var e,n=Date.now();l({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:d,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:h.capturedContext}),h.taskStack.push(p);try{null!=o&&o.call(this,t)}finally{h.taskStack.pop()}}),r=u.captureContext(function(t){h.taskStack.push(p);try{null!=e&&e.call(this,t)}finally{h.taskStack.pop()}h.endTask(p,Date.now())}),r=v(v({},a),{success:t,fail:n,complete:r});return i(r)}})},O.prototype.shouldIgnoreUrl=function(t){return t===this.reportUrl},O.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:y(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)}})},O.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}})},O.prototype.getContext=function(){var t;return null!==(t=this.capturedContext)&&void 0!==t?t:this.currentContext()},O.prototype.currentContext=function(){return{pid:this.pid,pageSessionId:this.pageSessionId,context:this.options.context}},O.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}},O.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},O.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)))},O.prototype.endTrack=function(t){t.ready&&(t.ended=!0,this.callback({ev_type:f.PAGE_FIRST_LOAD,data:t.timing,context:this.getContext()}))},O.prototype.getTaskTrack=function(){var t=this.getContext().pageSessionId;return this.taskTracks[t]},O);function O(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}var A,D=(t(P,A=s),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 P(){var t=null!==A&&A.apply(this,arguments)||this;return t.sdk=my,t}var N,L=(t(q,N=s),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 q(){var t=null!==N&&N.apply(this,arguments)||this;return t.sdk=swan,t}var j,F=(t(G,j=s),G.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}},G);function G(){var t=null!==j&&j.apply(this,arguments)||this;return t.sdk=tt,t}var U,B=(t(Q,U=s),Q.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}},Q);function Q(){var t=null!==U&&U.apply(this,arguments)||this;return t.sdk=wx,t}var s=function(){if("undefined"!=typeof tt)return F;if("undefined"!=typeof my)return D;if("undefined"!=typeof swan)return L;if("undefined"!=typeof wx)return B;throw new Error("unsupported mini program")}(),W="tbm.snssdk.com",H="/monitor_microapp/collect",V="/",J=20,M=10,z=1e3,K="cannot get context before init";function Y(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 p=c.value,d=i.context[p];a[p]=(p=d,"[object String]"===Object.prototype.toString.call(p)?d:_(d))}}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}var X,Z=(t($,X=d),$.prototype.updateConfig=function(t){var e;this.config=(e=this.config,t=t,Object.assign({},e,t)),this.finderConfig&&(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(this.breadcrumbs)},e)},$.prototype.reportEvent=function(t,e){this.ready?X.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(this.breadcrumbs,[t]).slice(-n):a(this.breadcrumbs,[t])},$.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.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(this.breadcrumbs)});break;case f.JS_ERROR:this.reportEvent({ev_type:n.ReportEventType.JS_ERROR,event:t.data,breadcrumbs:a(this.breadcrumbs)},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.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}),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){X.prototype.sendEvent.call(e,t)}),this.preQueue=[]},$);function $(t,e){var n=X.call(this,t)||this;n.finderConfig=null,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.backend.collectEnvInfo(),n.config.finderInstance&&n.backend.collectFinderConfig(),n}function et(t){this.version="0.0.16",this.Backend=t.Backend,this.defaultConfig={context:{},maxBatchReportLength:M,batchReportWait:z,userId:"",sessionId:k(),reportDomain:W,reportPath:H,pid:V,maxBreadcrumbs:J,hookPath:!0,hookRequest:!0,enableCapture:!0}}s=new(et.prototype.init=function(t){if(!this.client){if(null==t||!t.aid)throw new Error("cannot init without aid");this.userConfig=t;t=Y(this.defaultConfig,this.userConfig,{version:this.version});this.client=new Z(t,this.Backend)}},et.prototype.config=function(t){if(!this.userConfig||!this.client)throw new Error("cannot config before init");var e;this.userConfig=(e=this.userConfig,t=t,Object.assign({},e,t)),this.updateClientConfig()},et.prototype.capture=function(t){var e;null!==(e=this.client)&&void 0!==e&&e.reportError(t)},et.prototype.report=function(t){var e;null!==(e=this.client)&&void 0!==e&&e.reportEvent(t)},et.prototype.addBreadcrumb=function(t,e){var n;null!==(n=this.client)&&void 0!==n&&n.addBreadcrumb(t,e)},et.prototype.sendNow=function(){var t;null!==(t=this.client)&&void 0!==t&&t.flush()},Object.defineProperty(et.prototype,"context",{get:function(){var n=this,o={set:function(t,e){if(!n.userConfig)throw new Error(K);return n.userConfig.context||(n.userConfig.context={}),n.userConfig.context[t]=e,n.updateClientConfig(),o},delete:function(t){if(!n.userConfig)throw new Error(K);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(K);return n.userConfig.context={},n.updateClientConfig(),o},get:function(t){var e;if(!n.userConfig)throw new Error(K);return null===(e=n.userConfig.context)||void 0===e?void 0:e[t]},toObject:function(){if(!n.userConfig)throw new Error(K);return v({},n.userConfig.context)}};return o},enumerable:!1,configurable:!0}),et.prototype.updateClientConfig=function(){var t;this.userConfig&&this.client&&(t=Y(this.defaultConfig,this.userConfig,{version:this.version}),this.client.updateConfig(t))},et)({Backend:s});n.default=s,Object.defineProperty(n,"__esModule",{value:!0})});

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

function Rangers(options) {
this.version = '0.0.15';
this.version = '0.0.16';
this.Backend = options.Backend;

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

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

function Rangers(options) {
this.version = '0.0.15';
this.version = '0.0.16';
this.Backend = options.Backend;

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

{
"name": "@apm-insight-web/rangers-mini-sdk",
"version": "0.0.15",
"version": "0.0.16",
"main": "cn/index.cjs.js",

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

"devDependencies": {
"@slardar/sdk-core": "3.6.16",
"@slardar/types": "3.5.8"
"@slardar/sdk-core": "3.6.17",
"@slardar/types": "3.5.9"
},

@@ -55,3 +55,3 @@ "publishConfig": {

},
"gitHead": "05380b5f73d947142bcbfed1bc1e9cbeb7388fa2"
"gitHead": "50ea734b4f6a717058c47e3abda8e6267c20c17a"
}
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