@arms/rum-miniapp
Advanced tools
Comparing version 0.0.28-beta.1 to 0.0.28-beta.2
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=!0,exports["default"]=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends")),_asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")),_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"),_api=require("../../utils/api");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&&{}.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(){var a=this;this.name="api-collector",this.ctx=void 0,this.sendEvent=void 0,this.origin={request:_platform["default"].request,httpRequest:_platform["default"].httpRequest},this.sendApi=/*#__PURE__*/function(){var b=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function e(b,c,d){var f,g,h,i,j,k,l,m,n,o,p,q,r;return _regenerator["default"].wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(f=a.ctx.getConfig(),g=f.evaluateApi,h=c.statusCode,i=c.status,j=c.errMsg,k=c.errorMessage,l=c.message,m=c.profile,m&&(n=a.parseProfile(m),o=JSON.stringify(m)),!(0,_rumCore.isFunction)(g)){e.next=14;break}return e.prev=4,0===b.success&&(p=new Error("request error")),e.next=8,g(d,c,p);case 8:q=e.sent,b=(0,_extends2["default"])({},b,(0,_api.reviseApiAttr)(q)),e.next=14;break;case 12:e.prev=12,e.t0=e["catch"](4);case 14:if(r=(0,_extends2["default"])({event_type:_rumCore.RumEventType.RESOURCE,type:"api",status_code:i||h,message:k||j||l,duration:(0,_base.getCurrentTime)()-b.timestamp,times:1},b,n,{timing_data:o}),!(r.duration>_rumCore.ONE_DAY)){e.next=17;break}return e.abrupt("return");case 17:a.sendEvent(r);case 18:case"end":return e.stop()}},e,null,[[4,12]])}));return function(){return b.apply(this,arguments)}}()}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 | ||
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,headers: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(){h.success=1;for(var a=arguments.length,c=Array(a),e=0;e<a;e++)c[e]=arguments[e];b.sendApi(h,c[0],g),d&&d.apply(this,c)},g.fail=function(){h.success=0;for(var a=arguments.length,c=Array(a),d=0;d<a;d++)c[d]=arguments[d];b.sendApi(h,c[0],g),e&&e.apply(this,c)},g},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 @@ * 解析小程序的性能数据 |
@@ -1,2 +0,2 @@ | ||
"use strict";exports.__esModule=!0,exports["default"]=exports.appName=exports.VERSION=void 0,exports.getPerformance=getPerformance,exports.getStorageSync=getStorageSync,exports.sdk=void 0,exports.setStorageSync=setStorageSync;var VERSION=exports.VERSION='0.0.28-beta.1',OBJ="object",qqName="qq",bytedanceName="bytedance",wechatName="wechat",dingtalkName="dingtalk",alipayName="alipay",swanName="swan";/** | ||
"use strict";exports.__esModule=!0,exports["default"]=exports.appName=exports.VERSION=void 0,exports.getPerformance=getPerformance,exports.getStorageSync=getStorageSync,exports.sdk=void 0,exports.setStorageSync=setStorageSync;var VERSION=exports.VERSION='0.0.28-beta.2',OBJ="object",qqName="qq",bytedanceName="bytedance",wechatName="wechat",dingtalkName="dingtalk",alipayName="alipay",swanName="swan",jdName="jd";/** | ||
* 获取跨平台的 SDK | ||
@@ -6,2 +6,2 @@ */function getSDK(){var a,b="unknown";if(typeof qq===OBJ)// qq的全局也有wx命名空间,和qq等效,这会导致判断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; | ||
a=dd,b=dingtalkName;else if(typeof my===OBJ)a=my,b=alipayName;else if(typeof swan===OBJ)a=swan,b=swanName;else if(typeof jd===OBJ)a=jd,b=jdName;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.28-beta.1", | ||
"version": "0.0.28-beta.2", | ||
"description": "arms rum javascript sdk for miniapp", | ||
@@ -5,0 +5,0 @@ "author": "guangli.fj <guangli.fj@alibaba-inc.com>", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
105520