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.3 to 0.0.7

2

lib/collector/resource/api.js

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

"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;if(g){var k=(0,_rumCore.generateTraceId)(),l=(0,_rumCore.generateSpanId)(),m=(0,_rumCore.performDraw)(i),n=void 0===j||j?"rum=browser&"+e+"&"+(0,_uuid.getSessionID)():"",o=(0,_rumCore.find)(h,function(b){return(0,_rumCore.matchList)([b.match],a.url)});if(o){var p=(0,_rumCore.makeTracingHeaders)(k,l,m,o.propagatorTypes,n);a.trace_id=k,b(p)}}},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=_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.baggage;if(g){var k=(0,_rumCore.generateTraceId)(),l=(0,_rumCore.generateSpanId)(),m=(0,_rumCore.performDraw)(i),n=(0,_rumCore.find)(h,function(b){return(0,_rumCore.matchList)([b.match],a.url)});if(n){var o=(0,_rumCore.makeTracingHeaders)(k,l,m,n.propagatorTypes,void 0===j||j?{appType:"browser",pid:e,sid:(0,_uuid.getSessionID)()}:void 0);m&&(a.trace_id=k),b(o)}}},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
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),startTime:f,url:c,name:(0,_url.getPathByURL)(c),method:a.method||"GET"};return this.injectTracing(h,function(a){g.headers=(0,_extends2["default"])({},g.headers,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,duration:(0,_base.getCurrentTime)()-a.startTime},d,{times:1,timing_data:e}))}/**

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

@@ -6,5 +6,7 @@ import { ICollector, IContext, RumEvent } from '@arms/rum-core';

sendEvent: (payload: RumEvent) => void;
private prevPage;
setup(ctx: IContext, sendEvent: (payload: RumEvent) => void): void;
sendPv: () => void;
private getViewName;
destroy(): void;
}

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

"use strict";exports.__esModule=!0,exports["default"]=void 0;var _rumCore=require("@arms/rum-core"),_uuid=require("../../utils/uuid"),_view=require("../../utils/view"),_hackPage=require("../../utils/hackPage"),PvCollector=exports["default"]=/*#__PURE__*/function(){function a(){var a=this;this.name="pv-collector",this.ctx=void 0,this.sendEvent=void 0,this.sendPv=function(){var b=(0,_view.getCurPage)();a.ctx.addView({id:(0,_uuid.getViewId)(),name:b}),a.sendEvent({event_type:_rumCore.RumEventType.VIEW,type:"pv",url:b,name:b,loading_type:"initial_load"})}}var b=a.prototype;return b.setup=function setup(a,b){this.ctx=a,this.sendEvent=b,(0,_hackPage.addPageListener)("onShow",this.sendPv)},b.destroy=function destroy(){(0,_hackPage.removePageListener)("onShow",this.sendPv)},a}();
"use strict";exports.__esModule=!0,exports["default"]=void 0;var _rumCore=require("@arms/rum-core"),_uuid=require("../../utils/uuid"),_view=require("../../utils/view"),_hackPage=require("../../utils/hackPage"),PvCollector=exports["default"]=/*#__PURE__*/function(){function a(){var a=this;this.name="pv-collector",this.ctx=void 0,this.sendEvent=void 0,this.prevPage=void 0,this.sendPv=function(){var b=(0,_view.getCurPage)();if(b){// 判定路由发生变化,重新生成 viewId
var c=b.route,d=b.__rum_view_id;if(!(a.prevPage&&c===a.prevPage.route&&d===a.prevPage.viewId))// 路由没有发生变化,不发送
{var e=d?"route_back":"initial_load";d=b.__rum_view_id=(0,_uuid.getViewId)(),a.prevPage={route:c,viewId:d};var f=a.getViewName(c);a.ctx.addView({id:d,name:f}),a.sendEvent({event_type:_rumCore.RumEventType.VIEW,type:"pv",url:c,name:f,loading_type:e})}}}}var b=a.prototype;return b.setup=function setup(a,b){this.ctx=a,this.sendEvent=b,(0,_hackPage.addPageListener)("onShow",this.sendPv)},b.getViewName=function getViewName(a){var b=this.ctx.getConfig(),c=b.parseViewName,d=a;return(0,_rumCore.isFunction)(c)&&(d=c(a)),d},b.destroy=function destroy(){(0,_hackPage.removePageListener)("onShow",this.sendPv)},a}();

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

import { IClient, IConfiguration, IShell, RumEvent } from '@arms/rum-core';
import { IConfiguration, Shell } from '@arms/rum-core';
/**

@@ -8,4 +8,3 @@ * 对外导出 shell 层, 所有 shell 层模型的 API 设计约定:

*/
export declare class ArmsRum implements IShell {
client: IClient;
export declare class ArmsRum extends Shell {
/**

@@ -17,10 +16,2 @@ * 初始化

/**
* 自定义上传数据
*/
sendEvent(payload: RumEvent): void;
/**
* get config
*/
getConfig(): IConfiguration;
/**
* set config

@@ -27,0 +18,0 @@ */

@@ -1,10 +0,4 @@

"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=!0,exports["default"]=exports.ArmsRum=void 0;var _extends3=_interopRequireDefault(require("@babel/runtime/helpers/extends")),_rumCore=require("@arms/rum-core"),_pv=_interopRequireDefault(require("./collector/view/pv")),_perf=_interopRequireDefault(require("./collector/view/perf")),_exception=_interopRequireDefault(require("./collector/exception")),_api=_interopRequireDefault(require("./collector/resource/api")),_action=_interopRequireDefault(require("./collector/action")),_defaultProcessor=_interopRequireDefault(require("./processor/default-processor")),_sessionProcessor=_interopRequireDefault(require("./processor/session-processor")),_reporter=_interopRequireDefault(require("./reporter")),_network=require("./utils/network"),ArmsRum=exports.ArmsRum=/*#__PURE__*/function(){function a(){var a=this;this.client=void 0,this.updateNetType=function(b){var c=a.getConfig(),d=c.net,e=void 0===d?{}:d;a.setConfig("net",(0,_extends3["default"])({},e,{type:b}))}}var b=a.prototype;return b.init=/**
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=!0,exports["default"]=exports.ArmsRum=void 0;var _extends3=_interopRequireDefault(require("@babel/runtime/helpers/extends")),_inheritsLoose2=_interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose")),_rumCore=require("@arms/rum-core"),_pv=_interopRequireDefault(require("./collector/view/pv")),_perf=_interopRequireDefault(require("./collector/view/perf")),_exception=_interopRequireDefault(require("./collector/exception")),_api=_interopRequireDefault(require("./collector/resource/api")),_action=_interopRequireDefault(require("./collector/action")),_defaultProcessor=_interopRequireDefault(require("./processor/default-processor")),_sessionProcessor=_interopRequireDefault(require("./processor/session-processor")),_reporter=_interopRequireDefault(require("./reporter")),_network=require("./utils/network"),ArmsRum=exports.ArmsRum=/*#__PURE__*/function(a){function b(){for(var b,c=arguments.length,d=Array(c),e=0;e<c;e++)d[e]=arguments[e];return b=a.call.apply(a,[this].concat(d))||this,b.updateNetType=function(a){var c=b.getConfig(),d=c.net,e=void 0===d?{}:d;b.setConfig("net",(0,_extends3["default"])({},e,{type:a}))},b}(0,_inheritsLoose2["default"])(b,a);var c=b.prototype;return c.init=/**
* 初始化
*/function init(a){this.client=new _rumCore.Client,this.client.useCollectors([new _pv["default"],new _perf["default"],new _exception["default"],new _api["default"],new _action["default"]]),this.client.useProcessors([new _defaultProcessor["default"],new _sessionProcessor["default"]]),this.client.useReporter(new _reporter["default"]),this.client.init(a),(0,_network.getNetType)(this.updateNetType)},b.sendEvent=/**
* 自定义上传数据
*/function sendEvent(a){this.client.sendEvent(a)}/**
* get config
*/,b.getConfig=function getConfig(){return this.client.getContext().getConfig()}/**
* set config
*/,b.setConfig=function setConfig(){var a=this.client.getContext();if(2===arguments.length){var b,c=this.client.getContext(),d=c.getConfig();c.setConfig((0,_extends3["default"])({},d,(b={},b[0>=arguments.length?void 0:arguments[0]]=1>=arguments.length?void 0:arguments[1],b)))}else a.setConfig(0>=arguments.length?void 0:arguments[0])},a}(),_default=exports["default"]=new ArmsRum;/**
*/function init(a){this.client.useCollectors([new _pv["default"],new _perf["default"],new _exception["default"],new _api["default"],new _action["default"]]),this.client.useProcessors([new _defaultProcessor["default"],new _sessionProcessor["default"]]),this.client.useReporter(new _reporter["default"]),this.client.init(a),(0,_network.getNetType)(this.updateNetType)},c.setConfig=function setConfig(){var a=this.client.getContext();if(2===arguments.length){var b,c=this.client.getContext(),d=c.getConfig();c.setConfig((0,_extends3["default"])({},d,(b={},b[0>=arguments.length?void 0:arguments[0]]=1>=arguments.length?void 0:arguments[1],b)))}else a.setConfig(0>=arguments.length?void 0:arguments[0])},b}(_rumCore.Shell),_default=exports["default"]=new ArmsRum;/**
* 对外导出 shell 层, 所有 shell 层模型的 API 设计约定:

@@ -11,0 +5,0 @@ * 1. API 命名空间按照 variables / functions / events 来组织

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

"use strict";exports.__esModule=!0,exports.addPageListener=addPageListener,exports.originalPage=exports.originalComponent=void 0,exports.removePageListener=removePageListener;var _rumCore=require("@arms/rum-core"),listeners={};function hackPage(a){Object.keys(a).forEach(function(b){(0,_rumCore.interceptFunction)(a,b,function(){for(var a=this,c=arguments.length,d=Array(c),e=0;e<c;e++)d[e]=arguments[e];var f=[].concat(listeners[b]||[]);"*"!==b&&(f=f.concat(listeners["*"]||[])),f.forEach(function(b){b.apply(a,d)})})})}var originalPage=exports.originalPage=Page,originalComponent=exports.originalComponent=Component;Page=function Page(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];try{hackPage.apply(this,b)}catch(a){//
}return originalPage.apply(this,b)},Component=function Component(){for(var a,b=arguments.length,c=Array(b),d=0;d<b;d++)c[d]=arguments[d];if("PAGE"===(null===this||void 0===this||null===(a=this.$component)||void 0===a?void 0:a.$componentType))try{hackPage.apply(this,c)}catch(a){//
}return originalComponent.apply(this,c)};function addPageListener(a,b){a in listeners||(listeners[a]=[]),listeners[a].push(b)}function removePageListener(a,b){if(a in listeners){var c=listeners[a],d=c.indexOf(b);c.splice(d,1)}}
"use strict";exports.__esModule=!0,exports.addPageListener=addPageListener,exports.originalPage=exports.originalComponent=void 0,exports.removePageListener=removePageListener;var _rumCore=require("@arms/rum-core"),listeners={onShow:[]};function hackPage(a){Object.keys(listeners).forEach(function(b){var c=listeners[b];(0,_rumCore.interceptFunction)(a,b,function(){for(var a=this,b=arguments.length,d=Array(b),e=0;e<b;e++)d[e]=arguments[e];c.forEach(function(b){b.apply(a,d)})})})}var originalPage=exports.originalPage=Page,originalComponent=exports.originalComponent=Component;Page=function Page(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];try{hackPage.apply(this,b)}catch(a){//
}return originalPage.apply(this,b)},Component=function Component(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];try{var d=b[0]||{};d.methods||(d.methods={}),hackPage.call(this,d.methods)}catch(a){//
}return originalComponent.apply(this,b)};function addPageListener(a,b){a in listeners||(listeners[a]=[]),listeners[a].push(b)}function removePageListener(a,b){if(a in listeners){var c=listeners[a],d=c.indexOf(b);c.splice(d,1)}}
"use strict";exports.__esModule=!0,exports.getCurPage=getCurPage,exports.getCurView=getCurView;/**
* 获取当前 page
* @returns
*/function getCurPage(){if("function"==typeof getCurrentPages)try{var a=getCurrentPages()||[],b=a[a.length-1];return b&&b.route||null}catch(a){console.warn("[arms] error in getCurView",a)}}/**
*/function getCurPage(){if("function"==typeof getCurrentPages)try{var a=getCurrentPages()||[];return a[a.length-1]}catch(a){console.warn("[arms] error in getCurView",a)}}/**
* 获取当前 view

@@ -6,0 +6,0 @@ * @param ctx

{
"name": "@arms/rum-miniapp",
"version": "0.0.3",
"version": "0.0.7",
"description": "arms rum javascript sdk for miniapp",

@@ -21,10 +21,12 @@ "author": "guangli.fj <guangli.fj@alibaba-inc.com>",

"build": "build-scripts build",
"prepublishOnly": "npm run build",
"test": "node ./__tests__/@arms/miniapp.test.js"
},
"dependencies": {
"@arms/rum-core": "^0.0.5"
"@arms/rum-core": "^0.0.7"
},
"devDependencies": {
"typescript": "^4.9.4"
}
},
"homepage": "https://unpkg.com/@arms/rum-miniapp@0.0.7/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