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.9 to 0.0.10

2

lib/collector/resource/api.js
"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,headers: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
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:this.getResourceName(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}))},b.getResourceName=function getResourceName(a){var b=this.ctx.getConfig(),c=b.parseResourceName,d=a;return(0,_rumCore.isFunction)(c)&&(d=c(a)),d||(d=(0,_url.getPathByURL)(a)),d}/**
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:this.getResourceName(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}))},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}/**
* 解析小程序的性能数据

@@ -4,0 +4,0 @@ * 参考:https://developers.weixin.qq.com/miniprogram/dev/api/network/request/wx.request.html

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

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

"build": "build-scripts build",
"prepublishOnly": "npm run build",
"test": "node ./__tests__/@arms/miniapp.test.js"

@@ -30,3 +31,3 @@ },

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