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

@arms/rum-miniapp

Package Overview
Dependencies
Maintainers
5
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arms/rum-miniapp - npm Package Compare versions

Comparing version 0.0.20 to 0.0.22

2

lib/collector/exception/index.d.ts

@@ -9,3 +9,3 @@ import { ICollector, IContext, RumEvent } from '@arms/rum-core';

hackOrigin(): void;
sendError(error: any): void;
errorHandle: (error: any, source?: string) => void;
/**

@@ -12,0 +12,0 @@ * 根据stack获取Error信息

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

"use strict";exports.__esModule=!0,exports["default"]=void 0;var _rumCore=require("@arms/rum-core"),_view=require("../../utils/view"),ExceptionCollector=exports["default"]=/*#__PURE__*/function(){function a(){this.name="exception-collector",this.ctx=void 0,this.sendEvent=void 0,this.origin={app:App,consoleError:console.error}}var b=a.prototype;return b.setup=function setup(a,b){this.ctx=a,this.sendEvent=b,this.hackOrigin()},b.hackOrigin=function hackOrigin(){var a=this,b=this.ctx.getConfig(),c=b.collectors,d=void 0===c?{}:c;!1!==d.jsError&&(App=function App(b){b||(b={}),(0,_rumCore.interceptFunction)(b,"onError",function(b){a.sendError(b)}),a.origin.app(b)}),!1!==d.consoleError&&(0,_rumCore.interceptFunction)(console,"error",function(b){a.sendError(b)})},b.sendError=function sendError(a){var b,c,d,e,f,g,h=(0,_view.getCurView)(this.ctx);if(a instanceof Object)b=a.name,c=a.message,d=a.filename||a.fileName,e=a.stack,f=a.lineno||a.lineNumber,g=a.colno||a.columnNumber;else if("string"==typeof a){e=a;var i=this.getErrorByStack(a);i&&(b=i.name,c=i.message)}b&&c&&this.sendEvent({event_type:_rumCore.RumEventType.EXCEPTION,source:"event",type:"error",name:b,message:c,file:d,stack:e,line:f,column:g,times:1,view:h})}/**
"use strict";exports.__esModule=!0,exports["default"]=void 0;var _rumCore=require("@arms/rum-core"),_view=require("../../utils/view"),ExceptionCollector=exports["default"]=/*#__PURE__*/function(){function a(){var a=this;this.name="exception-collector",this.ctx=void 0,this.sendEvent=void 0,this.origin={app:App,consoleError:console.error},this.errorHandle=function(b,c){void 0===c&&(c="");var d,e,f,g,h,i,j=(0,_view.getCurView)(a.ctx);if(b instanceof Object)d=b.name,e=b.message,f=b.filename||b.fileName,g=b.stack,h=b.lineno||b.lineNumber,i=b.colno||b.columnNumber;else if("string"==typeof b){g=b;var k=a.getErrorByStack(b);k&&(d=k.name,e=k.message)}d&&e&&a.sendEvent({event_type:_rumCore.RumEventType.EXCEPTION,source:c,type:"error",name:d,message:e,file:f,stack:g,line:h,column:i,times:1,view:j})}}var b=a.prototype;return b.setup=function setup(a,b){this.ctx=a,this.sendEvent=b,this.hackOrigin()},b.hackOrigin=function hackOrigin(){var a=this,b=this.ctx.getConfig(),c=b.collectors,d=void 0===c?{}:c;!1!==d.jsError&&(App=function App(b){b||(b={}),["onError","onUnhandledRejection","onPageNotFound","onLazyLoadError"].forEach(function(c){(0,_rumCore.interceptFunction)(b,c,function(b){b.reason&&b.reason instanceof Error&&(b=b.reason),a.errorHandle(b,c)})}),a.origin.app(b)}),!1!==d.consoleError&&(0,_rumCore.interceptFunction)(console,"error",function(b){a.errorHandle(b,"console.error")})},b.getErrorByStack=/**
* 根据stack获取Error信息

@@ -6,2 +6,2 @@ * TODO: 增加基于Stack解析filename和lineNumber的能力

* @returns
*/,b.getErrorByStack=function getErrorByStack(a){void 0===a&&(a="");var b=a.split("\n");if(!(2>b.length))for(var c=1;c<b.length;c++)if(b[c].trim().startsWith("at ")){var d=b[c-1],e=d.indexOf(": ");return{name:d.substring(0,e),message:d.substring(e+2)}}},b.destroy=function destroy(){var a=this.origin;a.app&&(App=a.app),a.consoleError&&(console.error=a.consoleError)},a}();
*/function getErrorByStack(a){void 0===a&&(a="");var b=a.split("\n");if(!(2>b.length))for(var c=1;c<b.length;c++)if(b[c].trim().startsWith("at ")){var d=b[c-1],e=d.indexOf(": ");return{name:d.substring(0,e),message:d.substring(e+2)}}},b.destroy=function destroy(){var a=this.origin;a.app&&(App=a.app),a.consoleError&&(console.error=a.consoleError)},a}();

@@ -1,2 +0,3 @@

"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=!0,exports["default"]=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends")),_rumCore=require("@arms/rum-core"),_platform=_interopRequireDefault(require("../../utils/platform")),_url=require("../../utils/url"),_base=require("../../utils/base"),_view=require("../../utils/view"),_uuid=require("../../utils/uuid"),ApiCollector=exports["default"]=/*#__PURE__*/function(){function a(){this.name="api-collector",this.ctx=void 0,this.sendEvent=void 0,this.origin={request:_platform["default"].request,httpRequest:_platform["default"].httpRequest}}var b=a.prototype;return b.setup=function setup(a,b){var c=this,d=a.getConfig(),e=d.collectors,f=void 0===e?{}:e;!1===f.api||(this.ctx=a,this.sendEvent=b,Object.keys(this.origin).forEach(function(a){return c.hackRequest(a)}))},b.injectTracing=function injectTracing(a,b){var c=this.ctx.getConfig(),d=c.tracing,e=c.pid,f=(0,_rumCore.parseTracingOptions)(d),g=f.enable,h=f.allowedUrls,i=f.sample,j=f.tracestate,k=f.baggage;if(g){var l=(0,_rumCore.generateTraceId)(),m=(0,_rumCore.generateSpanId)(),n=(0,_rumCore.performDraw)(i),o=(0,_uuid.getSessionID)(),p=void 0===j||j?"rum=v2&miniapp&"+e+"&"+o:void 0,q=void 0!==k&&k?"rum=v2,appType=miniapp,pid="+e+",sid="+o:void 0,r=(0,_rumCore.find)(h,function(b){return(0,_rumCore.matchList)([b.match],a.url)});if(r){var s=(0,_rumCore.makeTracingHeaders)(l,m,n,r.propagatorTypes,p,q);n&&(a.trace_id=l,a.trace_data=JSON.stringify({spanId:m,sample:i,header:s})),b(s)}}},b.hackRequest=function hackRequest(a){var b=this;a in _platform["default"]&&Object.defineProperty(_platform["default"],a,{configurable:!0,enumerable:!0,writable:!0,value:function value(){for(var c=arguments.length,d=Array(c),e=0;e<c;e++)d[e]=arguments[e];return d[0]=b.rebuildRequestOptions(d[0]),b.origin[a].apply(this,d)}})},b.rebuildRequestOptions=function rebuildRequestOptions(a){var b=this,c=a.url,d=a.success,e=a.fail,f=(0,_base.getCurrentTime)();// SDK自己的请求不监控 & 过滤不需要监控的url
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=!0,exports["default"]=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends")),_rumCore=require("@arms/rum-core"),_platform=_interopRequireWildcard(require("../../utils/platform")),_url=require("../../utils/url"),_base=require("../../utils/base"),_view=require("../../utils/view"),_uuid=require("../../utils/uuid");function _getRequireWildcardCache(a){if("function"!=typeof WeakMap)return null;var b=new WeakMap,c=new WeakMap;return(_getRequireWildcardCache=function(a){return a?c:b})(a)}function _interopRequireWildcard(b,c){if(!c&&b&&b.__esModule)return b;if(null===b||"object"!=typeof b&&"function"!=typeof b)return{default:b};var d=_getRequireWildcardCache(c);if(d&&d.has(b))return d.get(b);var e={__proto__:null},f=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in b)if("default"!=a&&Object.prototype.hasOwnProperty.call(b,a)){var g=f?Object.getOwnPropertyDescriptor(b,a):null;g&&(g.get||g.set)?Object.defineProperty(e,a,g):e[a]=b[a]}return e["default"]=b,d&&d.set(b,e),e}var ApiCollector=exports["default"]=/*#__PURE__*/function(){function a(){this.name="api-collector",this.ctx=void 0,this.sendEvent=void 0,this.origin={request:_platform["default"].request,httpRequest:_platform["default"].httpRequest}}var b=a.prototype;return b.setup=function setup(a,b){var c=this,d=a.getConfig(),e=d.collectors,f=void 0===e?{}:e;!1===f.api||(this.ctx=a,this.sendEvent=b,Object.keys(this.origin).forEach(function(a){return c.hackRequest(a)}))},b.injectTracing=function injectTracing(a,b){var c,d=this.ctx.getConfig(),e=d.tracing,f=d.pid,g=d.version,h=void 0===g?"1.0.0":g,i=(0,_rumCore.parseTracingOptions)(e),j=i.enable,k=i.sample,l=i.propagatorTypes,m=i.allowedUrls,n=i.tracestate,o=i.baggage;if(j){var p=(0,_rumCore.find)(m,function(b){return(0,_rumCore.matchList)([b.match],a.url)});if(p){var q=p.propagatorTypes;0===q.length&&(q=l);// skywalking
var r=!1;q.includes("sw8")&&(q=["sw8"],r=!0);var s=r?(0,_rumCore.generateGUID)():(0,_rumCore.generateTraceId)(),t=r?(0,_rumCore.generateGUID)():(0,_rumCore.generateSpanId)(),u=(0,_rumCore.performDraw)(k),v=(0,_uuid.getUserID)(),w=(0,_uuid.getSessionID)(),x=void 0===n||n?"rum=v2&miniapp&"+f+"&"+w+"&"+v:void 0,y=void 0!==o&&o?"rum=v2,appType=miniapp,pid="+f+",sid="+w+",uid="+v:void 0,z=(0,_rumCore.makeTracingHeaders)(s,t,u,q,{tracestate:x,baggage:y,appId:f,appVersion:h,viewName:null===(c=a.view)||void 0===c?void 0:c.name,host:"miniapp_"+_platform.appName});u&&(a.trace_id=s,a.trace_data=JSON.stringify({spanId:t,sample:k,sampled:u,header:z})),b(z)}}},b.hackRequest=function hackRequest(a){var b=this;(0,_rumCore.isFunction)(_platform["default"][a])&&Object.defineProperty(_platform["default"],a,{configurable:!0,enumerable:!0,writable:!0,value:function value(){for(var c=arguments.length,d=Array(c),e=0;e<c;e++)d[e]=arguments[e];return d[0]=b.rebuildRequestOptions(d[0]),b.origin[a].apply(this,d)}})},b.rebuildRequestOptions=function rebuildRequestOptions(a){var b=this,c=a.url,d=a.success,e=a.fail,f=(0,_base.getCurrentTime)();// SDK自己的请求不监控 & 过滤不需要监控的url
if((0,_url.isEndpoint)(this.ctx,c)||(0,_rumCore.urlMatch)(c))return a;var g=(0,_extends2["default"])({},a),h={view:(0,_view.getCurView)(this.ctx),timestamp:f,url:c,name:this.getResourceName(c),method:a.method||"GET"};return this.injectTracing(h,function(a){g.header=(0,_extends2["default"])({},g.header,a)}),g.success=function(){for(var a=arguments.length,c=Array(a),e=0;e<a;e++)c[e]=arguments[e];b.sendApi(h,c[0],!0),d&&d.apply(this,c)},g.fail=function(){for(var a=arguments.length,c=Array(a),d=0;d<a;d++)c[d]=arguments[d];b.sendApi(h,c[0],!1),e&&e.apply(this,c)},g},b.sendApi=function sendApi(a,b,c){var d,e,f=(0,_view.getCurView)(this.ctx),g=b.statusCode,h=b.status,i=b.errMsg,j=b.errorMessage,k=b.message,l=b.profile;l&&(d=this.parseProfile(l),e=JSON.stringify(l)),this.sendEvent((0,_extends2["default"])({event_type:_rumCore.RumEventType.RESOURCE},a,{type:"api",status_code:h||g,message:j||i||k,view:f,success:c},d,{duration:(0,_base.getCurrentTime)()-a.timestamp,times:1,timing_data:e}))},b.getResourceName=function getResourceName(a){var b,c=this.ctx.getConfig(),d=c.parseResourceName;return b=(0,_rumCore.isFunction)(d)?d(a):(0,_url.getPathByURL)(a),b}/**

@@ -3,0 +4,0 @@ * 解析小程序的性能数据

@@ -1,3 +0,2 @@

"use strict";exports.__esModule=!0,exports["default"]=void 0;var _platform=require("../../utils/platform"),_view=require("../../utils/view"),PerfCollector=exports["default"]=/*#__PURE__*/function(){function a(){var a=this;this.name="perf-collector",this.ctx=void 0,this.sendEvent=void 0,this.perfObserver=void 0,this.observerHandler=function(b){var c=b.getEntries(),d={view:(0,_view.getCurView)(a.ctx)};if(Array.isArray(c)&&0<c.length)for(var e,f=0;f<c.length;f++)if(e=c[f],"number"==typeof e.duration)switch(e.name){case"appLaunch":case"app-click":d.launch=e.duration;break;case"firstPaint":d["first-paint"]=e.duration;break;case"firstRender":d.first_render=e.duration;break;case"firstContentfulPaint":d.first_contentful_paint=e.duration;break;case"largestContentfulPaint":d.largest_contentful_paint=e.duration;break;case"resourceTiming":case"resource-timing":d.timing_data=JSON.stringify(e);break;default:}!Object.keys(d).length}}var b=a.prototype;return b.setup=function setup(a,b){var c=a.getConfig(),d=c.collectors,e=void 0===d?{}:d;if(!1!==e.perf){this.ctx=a,this.sendEvent=b;var f=(0,_platform.getPerformance)();f&&f.createObserver&&(this.perfObserver=f.createObserver(this.observerHandler),this.perfObserver.observe({entryTypes:["launch","navigation","render","paint","resource"]}))}},b.destroy=function destroy(){this.perfObserver&&this.perfObserver.disconnect()},a}();// import {addPageListener, removePageListener} from "../../utils/hackPage";
/*
"use strict";exports.__esModule=!0,exports["default"]=void 0;var _rumCore=require("@arms/rum-core"),_platform=require("../../utils/platform"),_view=require("../../utils/view"),PerfCollector=exports["default"]=/*#__PURE__*/function(){function a(){var a=this;this.name="perf-collector",this.ctx=void 0,this.sendEvent=void 0,this.perfObserver=void 0,this.observerHandler=function(b){var c=(0,_rumCore.isArray)(b)?b:b.getEntries(),d={view:(0,_view.getCurView)(a.ctx)};if(Array.isArray(c)&&0<c.length)for(var e,f=0;f<c.length;f++)if(e=c[f],"number"==typeof e.duration)switch(e.name){case"appLaunch":case"app-click":d.launch=e.duration;break;case"firstPaint":d["first-paint"]=e.duration;break;case"firstRender":d.first_render=e.duration;break;case"firstContentfulPaint":d.first_contentful_paint=e.duration;break;case"largestContentfulPaint":d.largest_contentful_paint=e.duration;break;case"resourceTiming":case"resource-timing":d.timing_data=JSON.stringify(e);break;default:}!Object.keys(d).length}}var b=a.prototype;return b.setup=function setup(a,b){var c=a.getConfig(),d=c.collectors,e=void 0===d?{}:d;if(!1!==e.perf){this.ctx=a,this.sendEvent=b;var f=(0,_platform.getPerformance)();f&&f.createObserver&&(this.perfObserver=f.createObserver(this.observerHandler),this.perfObserver.observe({entryTypes:["launch","navigation","render","paint","resource"]}))}},b.destroy=function destroy(){this.perfObserver&&this.perfObserver.disconnect()},a}();/*
* 参考资料:

@@ -4,0 +3,0 @@ * https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/PerformanceEntry.html

@@ -13,12 +13,3 @@ interface SDK {

}
export declare enum PlatformName {
qq = "qq",
bytedance = "bytedance",
wechat = "wechat",
dingtalk = "dingtalk",
alipay = "alipay",
swan = "swan"
}
declare const sdk: SDK;
export declare const appName: string;
export declare const sdk: SDK, appName: string;
export declare function getStorageSync(key: any): any;

@@ -25,0 +16,0 @@ export declare function setStorageSync(key: string, data: string): void;

@@ -1,4 +0,6 @@

"use strict";exports.__esModule=!0,exports["default"]=exports.appName=exports.PlatformName=void 0,exports.getPerformance=getPerformance,exports.getStorageSync=getStorageSync,exports.setStorageSync=setStorageSync;var PlatformName=exports.PlatformName=/*#__PURE__*/function(a){return a.qq="qq",a.bytedance="bytedance",a.wechat="wechat",a.dingtalk="dingtalk",a.alipay="alipay",a.swan="swan",a}({});/**
"use strict";exports.__esModule=!0,exports["default"]=exports.appName=void 0,exports.getPerformance=getPerformance,exports.getStorageSync=getStorageSync,exports.sdk=void 0,exports.setStorageSync=setStorageSync;var OBJ="object",qqName="qq",bytedanceName="bytedance",wechatName="wechat",dingtalkName="dingtalk",alipayName="alipay",swanName="swan";/**
* 获取跨平台的 SDK
*/function getSDK(){var a;if("object"==typeof qq)a=qq;else if("object"==typeof tt)a=tt;else if("object"==typeof wx)a=wx;else if("object"==typeof dd)// dd 必须出现在 my之前,因为现在dd环境里也有my
a=dd;else if("object"==typeof my)a=my;else if("object"==typeof swan)a=swan;else throw new Error("Current platform is not supported.");return a}function getAppName(){var a="unknown";return"object"==typeof qq?a=PlatformName.qq:"object"==typeof tt?a=PlatformName.bytedance:"object"==typeof wx?a=PlatformName.wechat:"object"==typeof dd?a=PlatformName.dingtalk:"object"==typeof my?a=PlatformName.alipay:"object"==typeof swan&&(a=PlatformName.swan),a}var sdk=getSDK(),appName=exports.appName=getAppName();function getStorageSync(a){return"function"==typeof sdk.getStorageSync?appName===PlatformName.alipay||appName===PlatformName.dingtalk?sdk.getStorageSync({key:a}).data:sdk.getStorageSync(a):void 0}function setStorageSync(a,b){return"function"==typeof sdk.setStorageSync?appName===PlatformName.alipay||appName===PlatformName.dingtalk?sdk.setStorageSync({key:a,data:b}):sdk.setStorageSync(a,b):void 0}function getPerformance(){return"function"==typeof sdk.getPerformance?sdk.getPerformance():"performance"in sdk?sdk.performance:void 0}var _default=exports["default"]=sdk;
*/function getSDK(){var a,b="unknown";if(typeof qq==OBJ)// qq的全局也有wx命名空间,和qq等效,这会导致判断AppName失效
a=qq,b=qqName;else if(typeof tt==OBJ)// 字节的全局也有wx命名空间,和tt等效,这会导致判断AppName失效
a=tt,b=bytedanceName;else if(typeof wx==OBJ)a=wx,b=wechatName;else if(typeof dd==OBJ)// dd 必须出现在 my之前,因为现在dd环境里也有my
a=dd,b=dingtalkName;else if(typeof my==OBJ)a=my,b=alipayName;else if(typeof swan==OBJ)a=swan,b=swanName;else throw new Error("Current platform is not supported.");return{sdk:a,appName:b}}var _getSDK=getSDK(),sdk=exports.sdk=_getSDK.sdk,appName=exports.appName=_getSDK.appName;function getStorageSync(a){return"function"==typeof sdk.getStorageSync?appName===alipayName||appName===dingtalkName?sdk.getStorageSync({key:a}).data:sdk.getStorageSync(a):void 0}function setStorageSync(a,b){return"function"==typeof sdk.setStorageSync?appName===alipayName||appName===dingtalkName?sdk.setStorageSync({key:a,data:b}):sdk.setStorageSync(a,b):void 0}function getPerformance(){return"function"==typeof sdk.getPerformance?sdk.getPerformance():"performance"in sdk?sdk.performance:void 0}var _default=exports["default"]=sdk;
{
"name": "@arms/rum-miniapp",
"version": "0.0.20",
"version": "0.0.22",
"description": "arms rum javascript sdk for miniapp",

@@ -25,3 +25,3 @@ "author": "guangli.fj <guangli.fj@alibaba-inc.com>",

"dependencies": {
"@arms/rum-core": "^0.0.20"
"@arms/rum-core": "^0.0.22"
},

@@ -31,3 +31,3 @@ "devDependencies": {

},
"homepage": "https://unpkg.com/@arms/rum-miniapp@0.0.20/build/index.html"
"homepage": "https://unpkg.com/@arms/rum-miniapp@0.0.22/build/index.html"
}
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