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.4 to 0.0.5

cn/index.0.0.5.cn.js

2

cn/index.cjs.js

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

function Rangers(options) {
this.version = '0.0.4';
this.version = '0.0.5';
this.Backend = options.Backend;

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

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).RangersMiniSDK={})}(this,function(t){"use strict";var o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function e(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var n,r,a,i=function(){return(i=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,r,i=n.call(e),s=[];try{for(;(void 0===t||0<t--)&&!(o=i.next()).done;)s.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return s}function c(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(s(arguments[t]));return e}function u(){var e=function(){for(var e=new Array(16),t=0,n=0;n<16;n++)0==(3&n)&&(t=4294967296*Math.random()),e[n]=t>>>((3&n)<<3)&255;return e}();return e[6]=15&e[6]|64,e[8]=63&e[8]|128,function(e){for(var t=[],n=0;n<256;++n)t[n]=(n+256).toString(16).substr(1);var o=0;return[t[e[o++]],t[e[o++]],t[e[o++]],t[e[o++]],"-",t[e[o++]],t[e[o++]],"-",t[e[o++]],t[e[o++]],"-",t[e[o++]],t[e[o++]],"-",t[e[o++]],t[e[o++]],t[e[o++]],t[e[o++]],t[e[+o]],t[e[15]]].join("")}(e)}(P=t.BreadcrumbType||(t.BreadcrumbType={})).DOM="dom",P.HTTP="http",(n=n||{}).ROUTE="route",(r=r||{}).BATCH="batch",(_=t.ReportEventType||(t.ReportEventType={})).PAGEVIEW="pageview",_.JS_ERROR="js_error",(P=a=a||{}).DEVICE_ID="device_id",P.FINDER_CONFIG="finder_config",P.ENV_INFO="env_info",P.PATH="path",P.NETWORK_STATUS="network_status",P.JS_ERROR="js_error";var p,d,f=u,h="RANGERS_MINI_SDK_DEVICE_ID";(_={}).TT="tt",_.WX="wx",_.MY="my",_.SWAN="swan",(P=p=p||{}).onLaunch="onLaunch",P.onShow="onShow",P.onHide="onHide",P.onError="onError",P.onUnhandledRejection="onUnhandledRejection",P.onPageNotFound="onPageNotFound",(_=d=d||{}).onLoad="onLoad",_.onShow="onShow",_.onReady="onReady",_.onHide="onHide",_.onUnload="onUnload",_.onPullDownRefresh="onPullDownRefresh",(P={}).onError="onError",P.onUnhandledRejection="onUnhandledRejection";function l(e,t,o){return function(n){return t.forEach(function(e){var t=n[e];n[e]=o(e,t)}),e(n)}}function v(){return{host_platform:"undefined"!=typeof wx?"wx":"undefined"!=typeof tt?"tt":"undefined"!=typeof my?"my":"undefined"!=typeof swan?"swan":y,host_app_name:y,host_app_version:y,platform:y,sdk_version:y,os_name:y,os_version:y,device_brand:y,device_model:y,screen_height:0,screen_width:0,resolution:y,pixel_ratio:0,network_type:y}}var y="unknown",_=(g.prototype.init=function(){var t=this;this.transport=this.setupTransport(),App=this.hookAppFn(App),Page=this.hookPageFn(Page),this.collectDeviceId(),this.sdk.onNetworkStatusChange&&this.sdk.onNetworkStatusChange(function(e){t.callback({ev_type:a.NETWORK_STATUS,data:{network_type:e.networkType}})})},g.prototype.sendEvent=function(e){var t;null!==(t=this.transport)&&void 0!==t&&t.sendEvent(e)},g.prototype.collectEnvInfo=function(){var n=this;Promise.all([new Promise(function(e,t){n.sdk.getSystemInfo({success:e,fail:t})}),new Promise(function(e,t){n.sdk.getNetworkType({success:e,fail:t})})]).then(function(e){var t=s(e,2),e=t[0],t=t[1];e&&t&&n.callback({ev_type:a.ENV_INFO,data:n.normalizeEnvInfo(e,t)})}).catch(function(){n.callback({ev_type:a.ENV_INFO,data:v()})})},g.prototype.collectFinderConfig=function(){var t=this;this.options.finderInstance&&this.options.finderInstance.getToken(function(e){t.callback({ev_type:a.FINDER_CONFIG,data:{user_unique_id:e.user_unique_id}})})},g.prototype.getStorage=function(e){return this.sdk.getStorageSync(e)},g.prototype.setStorage=function(e,t){return this.sdk.setStorageSync(e,t)},g.prototype.setupTransport=function(){var e,t,n=this,o=(e=this.options.reportDomain,t=this.options.reportPath,"https://"+e+t);return{sendEvent:function(e){n.sdk.request({url:o,method:"POST",data:e})},request:function(e){n.sdk.request(e)}}},g.prototype.hookAppFn=function(e){var s=this.callback;return l(e,[p.onLaunch,p.onShow,p.onHide,p.onError,p.onPageNotFound,p.onUnhandledRejection],function(r,i){return function(e){switch(r){case p.onError:s({ev_type:a.JS_ERROR,data:{name:(o=(n=e).split("\n"))[0],message:o[1],stack:o.slice(1).join("\n"),rawMessage:n}});break;case p.onUnhandledRejection:n=(o=e).promise,o=o.reason,t=String(o),n.catch(function(e){return{name:"UnhandledRejection",message:String(e),stack:(null==e?void 0:e.stack)||"",rawMessage:t}}).then(function(e){s({ev_type:a.JS_ERROR,data:e})})}var t,n,o;null!=i&&i.call(this,e)}})},g.prototype.hookPageFn=function(e){var r=this.callback;return l(e,[d.onLoad,d.onShow,d.onReady,d.onHide,d.onUnload,d.onPullDownRefresh],function(n,o){return function(e){var t;n===d.onShow&&(t=(t=getCurrentPages())[t.length-1].route,r({ev_type:a.PATH,data:{pid:t}})),null!=o&&o.call(this,e)}})},g.prototype.collectDeviceId=function(){var e=this.getStorage(h);e||(e=u(),this.setStorage(h,e)),this.callback({ev_type:a.DEVICE_ID,data:{deviceId:e}})},g);function g(e,t){this.originalAppFn=App,this.originalPageFn=Page,this.options=e,this.callback=t}var m,b=(e(w,m=_),w.prototype.normalizeEnvInfo=function(e,t){return{host_platform:"my",host_app_name:e.app,host_app_version:e.version,platform:e.platform,sdk_version:e.SDKVersion,os_name:e.platform,os_version:e.system,device_brand:e.brand,device_model:e.model,screen_width:e.screenWidth,screen_height:e.screenHeight,resolution:e.screenWidth+"x"+e.screenHeight,pixel_ratio:e.pixelRatio,network_type:t.networkType}},w);function w(){var e=null!==m&&m.apply(this,arguments)||this;return e.sdk=my,e}var E,k=(e(R,E=_),R.prototype.normalizeEnvInfo=function(e,t){return{host_platform:"swan",host_app_name:e.host,host_app_version:e.version,platform:e.platform,sdk_version:e.SDKVersion,os_name:e.platform,os_version:e.system,device_brand:e.brand,device_model:e.model,screen_width:e.screenWidth,screen_height:e.screenHeight,resolution:e.screenWidth+"x"+e.screenHeight,pixel_ratio:e.pixelRatio,network_type:t.networkType}},R);function R(){var e=null!==E&&E.apply(this,arguments)||this;return e.sdk=swan,e}var S,C=(e(I,S=_),I.prototype.normalizeEnvInfo=function(e,t){return{host_platform:"tt",host_app_name:e.appName,host_app_version:e.version,platform:e.platform,sdk_version:e.SDKVersion,os_name:e.platform,os_version:e.system,device_brand:e.brand,device_model:e.model,screen_width:e.screenWidth,screen_height:e.screenHeight,resolution:e.screenWidth+"x"+e.screenHeight,pixel_ratio:e.pixelRatio,network_type:t.networkType}},I);function I(){var e=null!==S&&S.apply(this,arguments)||this;return e.sdk=tt,e}var x,T=(e(O,x=_),O.prototype.normalizeEnvInfo=function(e,t){return{host_platform:"wx",host_app_name:"Weixin",host_app_version:e.version,platform:e.platform,sdk_version:e.SDKVersion,os_name:e.system.split(" ")[0],os_version:e.system.split(" ")[1],device_brand:e.brand,device_model:e.model,screen_width:e.screenWidth,screen_height:e.screenHeight,resolution:e.screenWidth+"x"+e.screenHeight,pixel_ratio:e.pixelRatio,network_type:t.networkType}},O);function O(){var e=null!==x&&x.apply(this,arguments)||this;return e.sdk=wx,e}var P=function(){if("undefined"!=typeof tt)return C;if("undefined"!=typeof my)return b;if("undefined"!=typeof swan)return k;if("undefined"!=typeof wx)return T;throw new Error("unsupported mini program")}();function j(e){return"object"==typeof e&&null!==e&&(e=e,"[object Array]"!==Object.prototype.toString.call(e))}N.prototype.sendEvent=function(e){e=this.getEventToBeSent(e);e&&this.idleSendEvent(e)},N.prototype.getEventToBeSent=function(e){e=this._modifyEvent(e);if(this._shouldSend(e))return e},N.prototype._modifyEvent=function(e){return e},N.prototype._shouldSend=function(e){return!0},N.prototype._send=function(e){},N.prototype.idleSendEvent=function(e){this._send(e)},_=N;function N(){}var D,_=(e(A,D=_),Object.defineProperty(A.prototype,"ready",{get:function(){return this.isReady},set:function(e){this.isReady=e,this.isReady&&this._uploadQueue()},enumerable:!1,configurable:!0}),A.prototype._send=function(e){var t=this,e=this.buildParams(e);null!=e&&(this.reportQueue.push(e),this.isReady&&(this.reportQueue.length>=this.batchReportLength&&this._uploadQueue(),this.batchReportTimeout&&clearTimeout(this.batchReportTimeout),this.batchReportTimeout=setTimeout(function(){t._uploadQueue()},this.batchReportWait)))},A.prototype._uploadQueue=function(){var e;this.reportQueue.length&&this.ready&&(e={ev_type:"batch",list:this.reportQueue},this.reportQueue=[],this._request({event:e,type:"post"}))},A.prototype._request=function(e){},A);function A(e){var t,n=D.call(this)||this;return n.reportQueue=[],n.isReady=!0,n.batchReportLength=null!==(t=e.maxBatchReportLength)&&void 0!==t?t:10,n.batchReportWait=null!==(e=e.batchReportWait)&&void 0!==e?e:1e3,n.batchReportTimeout=null,n}var B="tbm.snssdk.com",F="/monitor_microapp/collect",H="/",W=20,V=10,Q=1e3,U="cannot get context before init";function q(e,t,n){var o,r,i=Object.assign({},e,t,n),s={};if(i.context&&j(i.context))try{for(var a=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],o=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(Object.keys(i.context)),c=a.next();!c.done;c=a.next()){var u=c.value,p=i.context[u];s[u]=(u=p,"[object String]"===Object.prototype.toString.call(u)?p:function(t){try{return JSON.stringify(t)}catch(e){return String(t)}}(p))}}catch(e){o={error:e}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i.context=s,i}var L,K=(e(M,L=_),M.prototype.updateConfig=function(e){var t;this.config=(t=this.config,e=e,Object.assign({},t,e)),this.finderConfig&&(this.config.userId=this.finderConfig.user_unique_id)},M.prototype.reportError=function(e){this.reportEvent({ev_type:t.ReportEventType.JS_ERROR,event:{name:e.name,message:e.message,stack:null!==(e=e.stack)&&void 0!==e?e:""},breadcrumbs:c(this.breadcrumbs)})},M.prototype.reportEvent=function(e){this.ready?L.prototype.sendEvent.call(this,e):this.preQueue.push(e)},M.prototype.addBreadcrumb=function(e,t){var n=this.config.maxBreadcrumbs,e=i(i({},t),{type:e,timestamp:Date.now()});this.breadcrumbs=0<=n?c(this.breadcrumbs,[e]).slice(-n):c(this.breadcrumbs,[e])},M.prototype.flush=function(){this._uploadQueue()},M.prototype.sendPageView=function(){this.reportEvent({ev_type:t.ReportEventType.PAGEVIEW})},M.prototype.reportBackendEvent=function(e){switch(e.ev_type){case a.ENV_INFO:this.envInfo=e.data,this.unlock();break;case a.DEVICE_ID:this.deviceId=e.data.deviceId;break;case a.FINDER_CONFIG:this.finderConfig=e.data;break;case a.NETWORK_STATUS:this.envInfo&&(this.envInfo=i(i({},this.envInfo),{network_type:e.data.network_type}));break;case a.PATH:this.pid!==e.data.pid&&(this.addBreadcrumb(t.BreadcrumbType.DOM,{category:n.ROUTE,message:e.data.pid}),this.pid=e.data.pid,this.sendPageView());break;case a.JS_ERROR:this.reportEvent({ev_type:t.ReportEventType.JS_ERROR,event:e.data,breadcrumbs:c(this.breadcrumbs)})}},M.prototype.buildParams=function(e){return i(i({},e),{common:i(i({},this.envInfo),{aid:this.config.aid,pid: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,context:this.config.context})})},M.prototype._request=function(e){var t;e&&e.event&&(t=e.type,e=e.event,"post"===t&&this.backend.sendEvent({ev_type:r.BATCH,list:e.list}))},M.prototype.unlock=function(){var t=this;this.ready=!0,this.preQueue.forEach(function(e){L.prototype.sendEvent.call(t,e)}),this.preQueue=[]},M);function M(e,t){var n=L.call(this,e)||this;n.finderConfig=null,n.deviceId="",n.envInfo={},n.preQueue=[],n.ready=!1,n.config=e,n.pid=e.pid;e=n.config,e=Object.assign({},e);return n.backend=new t(e,n.reportBackendEvent.bind(n)),n.backend.init(),n.breadcrumbs=[],n.backend.collectEnvInfo(),n.config.finderInstance&&n.backend.collectFinderConfig(),n}function J(e){this.version="0.0.4",this.Backend=e.Backend,this.defaultConfig={context:{},maxBatchReportLength:V,batchReportWait:Q,userId:"",sessionId:f(),reportDomain:B,reportPath:F,pid:H,maxBreadcrumbs:W,hookPath:!0,hookRequest:!0,enableCapture:!0}}P=new(J.prototype.init=function(e){if(!this.client){if(null==e||!e.aid)throw new Error("cannot init without aid");this.userConfig=e;e=q(this.defaultConfig,this.userConfig,{version:this.version});this.client=new K(e,this.Backend)}},J.prototype.config=function(e){if(!this.userConfig||!this.client)throw new Error("cannot config before init");var t;this.userConfig=(t=this.userConfig,e=e,Object.assign({},t,e)),this.updateClientConfig()},J.prototype.capture=function(e){var t;null!==(t=this.client)&&void 0!==t&&t.reportError(e)},J.prototype.report=function(e){var t;null!==(t=this.client)&&void 0!==t&&t.reportEvent(e)},J.prototype.addBreadcrumb=function(e,t){var n;null!==(n=this.client)&&void 0!==n&&n.addBreadcrumb(e,t)},J.prototype.sendNow=function(){var e;null!==(e=this.client)&&void 0!==e&&e.flush()},Object.defineProperty(J.prototype,"context",{get:function(){var n=this,o={set:function(e,t){if(!n.userConfig)throw new Error(U);return n.userConfig.context||(n.userConfig.context={}),n.userConfig.context[e]=t,n.updateClientConfig(),o},delete:function(e){if(!n.userConfig)throw new Error(U);return n.userConfig.context&&e in n.userConfig.context&&delete n.userConfig.context[e],n.updateClientConfig(),o},clear:function(){if(!n.userConfig)throw new Error(U);return n.userConfig.context={},n.updateClientConfig(),o},get:function(e){var t;if(!n.userConfig)throw new Error(U);return null===(t=n.userConfig.context)||void 0===t?void 0:t[e]},toObject:function(){if(!n.userConfig)throw new Error(U);return i({},n.userConfig.context)}};return o},enumerable:!1,configurable:!0}),J.prototype.updateClientConfig=function(){var e;this.userConfig&&this.client&&(e=q(this.defaultConfig,this.userConfig,{version:this.version}),this.client.updateConfig(e))},J)({Backend:P});t.default=P,Object.defineProperty(t,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).RangersMiniSDK={})}(this,function(t){"use strict";var o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function e(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var n,r,a,i=function(){return(i=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,r,i=n.call(e),s=[];try{for(;(void 0===t||0<t--)&&!(o=i.next()).done;)s.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return s}function c(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(s(arguments[t]));return e}function u(){var e=function(){for(var e=new Array(16),t=0,n=0;n<16;n++)0==(3&n)&&(t=4294967296*Math.random()),e[n]=t>>>((3&n)<<3)&255;return e}();return e[6]=15&e[6]|64,e[8]=63&e[8]|128,function(e){for(var t=[],n=0;n<256;++n)t[n]=(n+256).toString(16).substr(1);var o=0;return[t[e[o++]],t[e[o++]],t[e[o++]],t[e[o++]],"-",t[e[o++]],t[e[o++]],"-",t[e[o++]],t[e[o++]],"-",t[e[o++]],t[e[o++]],"-",t[e[o++]],t[e[o++]],t[e[o++]],t[e[o++]],t[e[+o]],t[e[15]]].join("")}(e)}(P=t.BreadcrumbType||(t.BreadcrumbType={})).DOM="dom",P.HTTP="http",(n=n||{}).ROUTE="route",(r=r||{}).BATCH="batch",(_=t.ReportEventType||(t.ReportEventType={})).PAGEVIEW="pageview",_.JS_ERROR="js_error",(P=a=a||{}).DEVICE_ID="device_id",P.FINDER_CONFIG="finder_config",P.ENV_INFO="env_info",P.PATH="path",P.NETWORK_STATUS="network_status",P.JS_ERROR="js_error";var p,d,f=u,h="RANGERS_MINI_SDK_DEVICE_ID";(_={}).TT="tt",_.WX="wx",_.MY="my",_.SWAN="swan",(P=p=p||{}).onLaunch="onLaunch",P.onShow="onShow",P.onHide="onHide",P.onError="onError",P.onUnhandledRejection="onUnhandledRejection",P.onPageNotFound="onPageNotFound",(_=d=d||{}).onLoad="onLoad",_.onShow="onShow",_.onReady="onReady",_.onHide="onHide",_.onUnload="onUnload",_.onPullDownRefresh="onPullDownRefresh",(P={}).onError="onError",P.onUnhandledRejection="onUnhandledRejection";function l(e,t,o){return function(n){return t.forEach(function(e){var t=n[e];n[e]=o(e,t)}),e(n)}}function v(){return{host_platform:"undefined"!=typeof wx?"wx":"undefined"!=typeof tt?"tt":"undefined"!=typeof my?"my":"undefined"!=typeof swan?"swan":y,host_app_name:y,host_app_version:y,platform:y,sdk_version:y,os_name:y,os_version:y,device_brand:y,device_model:y,screen_height:0,screen_width:0,resolution:y,pixel_ratio:0,network_type:y}}var y="unknown",_=(g.prototype.init=function(){var t=this;this.transport=this.setupTransport(),App=this.hookAppFn(App),Page=this.hookPageFn(Page),this.collectDeviceId(),this.sdk.onNetworkStatusChange&&this.sdk.onNetworkStatusChange(function(e){t.callback({ev_type:a.NETWORK_STATUS,data:{network_type:e.networkType}})})},g.prototype.sendEvent=function(e){var t;null!==(t=this.transport)&&void 0!==t&&t.sendEvent(e)},g.prototype.collectEnvInfo=function(){var n=this;Promise.all([new Promise(function(e,t){n.sdk.getSystemInfo({success:e,fail:t})}),new Promise(function(e,t){n.sdk.getNetworkType({success:e,fail:t})})]).then(function(e){var t=s(e,2),e=t[0],t=t[1];e&&t&&n.callback({ev_type:a.ENV_INFO,data:n.normalizeEnvInfo(e,t)})}).catch(function(){n.callback({ev_type:a.ENV_INFO,data:v()})})},g.prototype.collectFinderConfig=function(){var t=this;this.options.finderInstance&&this.options.finderInstance.getToken(function(e){t.callback({ev_type:a.FINDER_CONFIG,data:{user_unique_id:e.user_unique_id}})})},g.prototype.getStorage=function(e){return this.sdk.getStorageSync(e)},g.prototype.setStorage=function(e,t){return this.sdk.setStorageSync(e,t)},g.prototype.setupTransport=function(){var e,t,n=this,o=(e=this.options.reportDomain,t=this.options.reportPath,"https://"+e+t);return{sendEvent:function(e){n.sdk.request({url:o,method:"POST",data:e})},request:function(e){n.sdk.request(e)}}},g.prototype.hookAppFn=function(e){var s=this.callback;return l(e,[p.onLaunch,p.onShow,p.onHide,p.onError,p.onPageNotFound,p.onUnhandledRejection],function(r,i){return function(e){switch(r){case p.onError:s({ev_type:a.JS_ERROR,data:{name:(o=(n=e).split("\n"))[0],message:o[1],stack:o.slice(1).join("\n"),rawMessage:n}});break;case p.onUnhandledRejection:n=(o=e).promise,o=o.reason,t=String(o),n.catch(function(e){return{name:"UnhandledRejection",message:String(e),stack:(null==e?void 0:e.stack)||"",rawMessage:t}}).then(function(e){s({ev_type:a.JS_ERROR,data:e})})}var t,n,o;null!=i&&i.call(this,e)}})},g.prototype.hookPageFn=function(e){var r=this.callback;return l(e,[d.onLoad,d.onShow,d.onReady,d.onHide,d.onUnload,d.onPullDownRefresh],function(n,o){return function(e){var t;n===d.onShow&&(t=(t=getCurrentPages())[t.length-1].route,r({ev_type:a.PATH,data:{pid:t}})),null!=o&&o.call(this,e)}})},g.prototype.collectDeviceId=function(){var e=this.getStorage(h);e||(e=u(),this.setStorage(h,e)),this.callback({ev_type:a.DEVICE_ID,data:{deviceId:e}})},g);function g(e,t){this.originalAppFn=App,this.originalPageFn=Page,this.options=e,this.callback=t}var m,b=(e(w,m=_),w.prototype.normalizeEnvInfo=function(e,t){return{host_platform:"my",host_app_name:e.app,host_app_version:e.version,platform:e.platform,sdk_version:e.SDKVersion,os_name:e.platform,os_version:e.system,device_brand:e.brand,device_model:e.model,screen_width:e.screenWidth,screen_height:e.screenHeight,resolution:e.screenWidth+"x"+e.screenHeight,pixel_ratio:e.pixelRatio,network_type:t.networkType}},w);function w(){var e=null!==m&&m.apply(this,arguments)||this;return e.sdk=my,e}var E,k=(e(R,E=_),R.prototype.normalizeEnvInfo=function(e,t){return{host_platform:"swan",host_app_name:e.host,host_app_version:e.version,platform:e.platform,sdk_version:e.SDKVersion,os_name:e.platform,os_version:e.system,device_brand:e.brand,device_model:e.model,screen_width:e.screenWidth,screen_height:e.screenHeight,resolution:e.screenWidth+"x"+e.screenHeight,pixel_ratio:e.pixelRatio,network_type:t.networkType}},R);function R(){var e=null!==E&&E.apply(this,arguments)||this;return e.sdk=swan,e}var S,C=(e(I,S=_),I.prototype.normalizeEnvInfo=function(e,t){return{host_platform:"tt",host_app_name:e.appName,host_app_version:e.version,platform:e.platform,sdk_version:e.SDKVersion,os_name:e.platform,os_version:e.system,device_brand:e.brand,device_model:e.model,screen_width:e.screenWidth,screen_height:e.screenHeight,resolution:e.screenWidth+"x"+e.screenHeight,pixel_ratio:e.pixelRatio,network_type:t.networkType}},I);function I(){var e=null!==S&&S.apply(this,arguments)||this;return e.sdk=tt,e}var x,T=(e(O,x=_),O.prototype.normalizeEnvInfo=function(e,t){return{host_platform:"wx",host_app_name:"Weixin",host_app_version:e.version,platform:e.platform,sdk_version:e.SDKVersion,os_name:e.system.split(" ")[0],os_version:e.system.split(" ")[1],device_brand:e.brand,device_model:e.model,screen_width:e.screenWidth,screen_height:e.screenHeight,resolution:e.screenWidth+"x"+e.screenHeight,pixel_ratio:e.pixelRatio,network_type:t.networkType}},O);function O(){var e=null!==x&&x.apply(this,arguments)||this;return e.sdk=wx,e}var P=function(){if("undefined"!=typeof tt)return C;if("undefined"!=typeof my)return b;if("undefined"!=typeof swan)return k;if("undefined"!=typeof wx)return T;throw new Error("unsupported mini program")}();function j(e){return"object"==typeof e&&null!==e&&(e=e,"[object Array]"!==Object.prototype.toString.call(e))}N.prototype.sendEvent=function(e){e=this.getEventToBeSent(e);e&&this.idleSendEvent(e)},N.prototype.getEventToBeSent=function(e){e=this._modifyEvent(e);if(this._shouldSend(e))return e},N.prototype._modifyEvent=function(e){return e},N.prototype._shouldSend=function(e){return!0},N.prototype._send=function(e){},N.prototype.idleSendEvent=function(e){this._send(e)},_=N;function N(){}var D,_=(e(A,D=_),Object.defineProperty(A.prototype,"ready",{get:function(){return this.isReady},set:function(e){this.isReady=e,this.isReady&&this._uploadQueue()},enumerable:!1,configurable:!0}),A.prototype._send=function(e){var t=this,e=this.buildParams(e);null!=e&&(this.reportQueue.push(e),this.isReady&&(this.reportQueue.length>=this.batchReportLength&&this._uploadQueue(),this.batchReportTimeout&&clearTimeout(this.batchReportTimeout),this.batchReportTimeout=setTimeout(function(){t._uploadQueue()},this.batchReportWait)))},A.prototype._uploadQueue=function(){var e;this.reportQueue.length&&this.ready&&(e={ev_type:"batch",list:this.reportQueue},this.reportQueue=[],this._request({event:e,type:"post"}))},A.prototype._request=function(e){},A);function A(e){var t,n=D.call(this)||this;return n.reportQueue=[],n.isReady=!0,n.batchReportLength=null!==(t=e.maxBatchReportLength)&&void 0!==t?t:10,n.batchReportWait=null!==(e=e.batchReportWait)&&void 0!==e?e:1e3,n.batchReportTimeout=null,n}var B="tbm.snssdk.com",F="/monitor_microapp/collect",H="/",W=20,V=10,Q=1e3,U="cannot get context before init";function q(e,t,n){var o,r,i=Object.assign({},e,t,n),s={};if(i.context&&j(i.context))try{for(var a=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],o=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(Object.keys(i.context)),c=a.next();!c.done;c=a.next()){var u=c.value,p=i.context[u];s[u]=(u=p,"[object String]"===Object.prototype.toString.call(u)?p:function(t){try{return JSON.stringify(t)}catch(e){return String(t)}}(p))}}catch(e){o={error:e}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i.context=s,i}var L,K=(e(M,L=_),M.prototype.updateConfig=function(e){var t;this.config=(t=this.config,e=e,Object.assign({},t,e)),this.finderConfig&&(this.config.userId=this.finderConfig.user_unique_id)},M.prototype.reportError=function(e){this.reportEvent({ev_type:t.ReportEventType.JS_ERROR,event:{name:e.name,message:e.message,stack:null!==(e=e.stack)&&void 0!==e?e:""},breadcrumbs:c(this.breadcrumbs)})},M.prototype.reportEvent=function(e){this.ready?L.prototype.sendEvent.call(this,e):this.preQueue.push(e)},M.prototype.addBreadcrumb=function(e,t){var n=this.config.maxBreadcrumbs,e=i(i({},t),{type:e,timestamp:Date.now()});this.breadcrumbs=0<=n?c(this.breadcrumbs,[e]).slice(-n):c(this.breadcrumbs,[e])},M.prototype.flush=function(){this._uploadQueue()},M.prototype.sendPageView=function(){this.reportEvent({ev_type:t.ReportEventType.PAGEVIEW})},M.prototype.reportBackendEvent=function(e){switch(e.ev_type){case a.ENV_INFO:this.envInfo=e.data,this.unlock();break;case a.DEVICE_ID:this.deviceId=e.data.deviceId;break;case a.FINDER_CONFIG:this.finderConfig=e.data;break;case a.NETWORK_STATUS:this.envInfo&&(this.envInfo=i(i({},this.envInfo),{network_type:e.data.network_type}));break;case a.PATH:this.pid!==e.data.pid&&(this.addBreadcrumb(t.BreadcrumbType.DOM,{category:n.ROUTE,message:e.data.pid}),this.pid=e.data.pid,this.sendPageView());break;case a.JS_ERROR:this.reportEvent({ev_type:t.ReportEventType.JS_ERROR,event:e.data,breadcrumbs:c(this.breadcrumbs)})}},M.prototype.buildParams=function(e){return i(i({},e),{common:i(i({},this.envInfo),{aid:this.config.aid,pid: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,context:this.config.context})})},M.prototype._request=function(e){var t;e&&e.event&&(t=e.type,e=e.event,"post"===t&&this.backend.sendEvent({ev_type:r.BATCH,list:e.list}))},M.prototype.unlock=function(){var t=this;this.ready=!0,this.preQueue.forEach(function(e){L.prototype.sendEvent.call(t,e)}),this.preQueue=[]},M);function M(e,t){var n=L.call(this,e)||this;n.finderConfig=null,n.deviceId="",n.envInfo={},n.preQueue=[],n.ready=!1,n.config=e,n.pid=e.pid;e=n.config,e=Object.assign({},e);return n.backend=new t(e,n.reportBackendEvent.bind(n)),n.backend.init(),n.breadcrumbs=[],n.backend.collectEnvInfo(),n.config.finderInstance&&n.backend.collectFinderConfig(),n}function J(e){this.version="0.0.5",this.Backend=e.Backend,this.defaultConfig={context:{},maxBatchReportLength:V,batchReportWait:Q,userId:"",sessionId:f(),reportDomain:B,reportPath:F,pid:H,maxBreadcrumbs:W,hookPath:!0,hookRequest:!0,enableCapture:!0}}P=new(J.prototype.init=function(e){if(!this.client){if(null==e||!e.aid)throw new Error("cannot init without aid");this.userConfig=e;e=q(this.defaultConfig,this.userConfig,{version:this.version});this.client=new K(e,this.Backend)}},J.prototype.config=function(e){if(!this.userConfig||!this.client)throw new Error("cannot config before init");var t;this.userConfig=(t=this.userConfig,e=e,Object.assign({},t,e)),this.updateClientConfig()},J.prototype.capture=function(e){var t;null!==(t=this.client)&&void 0!==t&&t.reportError(e)},J.prototype.report=function(e){var t;null!==(t=this.client)&&void 0!==t&&t.reportEvent(e)},J.prototype.addBreadcrumb=function(e,t){var n;null!==(n=this.client)&&void 0!==n&&n.addBreadcrumb(e,t)},J.prototype.sendNow=function(){var e;null!==(e=this.client)&&void 0!==e&&e.flush()},Object.defineProperty(J.prototype,"context",{get:function(){var n=this,o={set:function(e,t){if(!n.userConfig)throw new Error(U);return n.userConfig.context||(n.userConfig.context={}),n.userConfig.context[e]=t,n.updateClientConfig(),o},delete:function(e){if(!n.userConfig)throw new Error(U);return n.userConfig.context&&e in n.userConfig.context&&delete n.userConfig.context[e],n.updateClientConfig(),o},clear:function(){if(!n.userConfig)throw new Error(U);return n.userConfig.context={},n.updateClientConfig(),o},get:function(e){var t;if(!n.userConfig)throw new Error(U);return null===(t=n.userConfig.context)||void 0===t?void 0:t[e]},toObject:function(){if(!n.userConfig)throw new Error(U);return i({},n.userConfig.context)}};return o},enumerable:!1,configurable:!0}),J.prototype.updateClientConfig=function(){var e;this.userConfig&&this.client&&(e=q(this.defaultConfig,this.userConfig,{version:this.version}),this.client.updateConfig(e))},J)({Backend:P});t.default=P,Object.defineProperty(t,"__esModule",{value:!0})});

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

function Rangers(options) {
this.version = '0.0.4';
this.version = '0.0.5';
this.Backend = options.Backend;

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

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

function Rangers(options) {
this.version = '0.0.4';
this.version = '0.0.5';
this.Backend = options.Backend;

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

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

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

"devDependencies": {
"@slardar/sdk-core": "3.6.6",
"@slardar/types": "3.5.5"
"@slardar/sdk-core": "3.6.7",
"@slardar/types": "3.5.6"
},

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

},
"gitHead": "33adcfc81342eca1bd98012422cabf1ecabaf6fa"
"gitHead": "9493fb4d321223a4d28371c7ea8478073b47abff"
}
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