@arms/rum-browser
Advanced tools
Comparing version 0.0.27-beta.11 to 0.0.27-beta.12
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=!0,exports["default"]=void 0;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")),_extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends")),_rumCore=require("@arms/rum-core"),_performance=require("../../utils/performance"),_url=require("../../utils/url"),_base=require("../../utils/base"),_global=require("../../utils/global"),_api=require("../../utils/api"),PerfObserver=_global.global.PerformanceObserver,ApiCollector=exports["default"]=/*#__PURE__*/function(){function a(){this.name="api-collector",this.entryTypes=Object.values(_api.ApiType),this.entryCacheMap={},this.ctx=void 0,this.sendEvent=void 0}var b=a.prototype;return b.setup=function setup(a,b){var c=a.getConfig().collectors||{};!1===c.api||(this.sendEvent=b,this.ctx=a,this.perfObserver(),this.hackXhr(),this.hackFetch())},b.perfObserver=function perfObserver(){var a=this;if((0,_rumCore.isFunction)(PerfObserver)){var b=new PerformanceObserver(function(b){var c=b.getEntries().filter(function(b){return a.entryTypes.includes(b.initiatorType)});c&&c.length&&c.forEach(function(b){var c=b.name;a.entryCacheMap[c]?a.entryCacheMap[c].push(b):a.entryCacheMap[c]=[b]})});b.observe({entryTypes:["resource"]})}},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){m.push({match:function match(a){return /^https?:\/\/*/.test(a)&&(0,_rumCore.startsWith)(a,_global.location.origin)},propagatorTypes:l});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;-1<q.indexOf("sw8")&&(q=["sw8"],r=!0);var s=this.ctx.session,t=r?(0,_rumCore.generateGUID)():(0,_rumCore.generateTraceId)(),u=r?(0,_rumCore.generateGUID)():(0,_rumCore.generateSpanId)(),v=(0,_rumCore.performDraw)(k),w=s.getUserId(),x=s.getSessionId(),y=void 0===n||n?"rum=v2&browser&"+f+"&"+x+"&"+w:void 0,z=void 0!==o&&o?"rum=v2,appType=browser,pid="+f+",sid="+x+",uid="+w:void 0,A=(0,_rumCore.makeTracingHeaders)(t,u,v,q,{tracestate:y,baggage:z,appId:f,appVersion:h,viewName:null===(c=a.view)||void 0===c?void 0:c.name,host:_global.location.host});v&&(a.trace_id=t,a.trace_data=JSON.stringify({spanId:u,sample:k,sampled:v,headers:A})),b(A)}}// Browser 情况下一直允许同域请求的trace | ||
},b.hackXhr=function hackXhr(){var a=XMLHttpRequest.prototype,b=this;(0,_rumCore.interceptFunction)(a,"open",function(a,c,d,e,f){var g=c+"",h=a.toUpperCase();if(!((0,_rumCore.urlMatch)(g)||"HEAD"===h)){this.apiCache={type:_api.ApiType.XHR,method:a,url:c,async:d,user:e,password:f,headers:{}};var i=b.ctx.session.getBaseEvent();this.apiAttr=(0,_extends2["default"])({},i,{url:(0,_url.fixRelativeUrl)(g),method:h})}}),(0,_rumCore.interceptFunction)(a,"setRequestHeader",function(a,b){this.apiCache&&(this.apiCache.headers[a]=b)}),(0,_rumCore.interceptFunction)(a,"send",function(a){var c=this;if(this.apiAttr){var d=this.apiAttr;this.apiCache.data=a,b.injectTracing(this.apiAttr,function(a){Object.keys(a).forEach(function(b){c.setRequestHeader(b,a[b])})}),this.addEventListener("loadend",/*#__PURE__*/(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function a(){var e,f,g,h,i,j,k,l;return _regenerator["default"].wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(e=c.status,f=c.statusText,g=c.response,h=b.ctx.getConfig(),i=h.evaluateApi,d.status_code=e,d.message=f,j={name:c.apiAttr.url,entryType:_api.ApiType.XHR,duration:(0,_base.getCurrentTime)()-d.timestamp},!(0,_rumCore.isFunction)(i)){a.next=16;break}return a.prev=6,d.success===_rumCore.ResourceStatus.Failed&&(k=new Error(_api.ApiType.XHR+" error")),a.next=10,i(c.apiCache,g,k);case 10:l=a.sent,c.apiAttr=d=(0,_extends2["default"])({},d,(0,_api.reviseApiAttr)(l)),a.next=16;break;case 14:a.prev=14,a.t0=a["catch"](6);case 16:b.delayHandle({attr:d,entry:j});case 17:case"end":return a.stop()}},a,null,[[6,14]])}))),this.addEventListener("error",function(){c.apiAttr.success=_rumCore.ResourceStatus.Failed})}})},b.hackFetch=function hackFetch(){var a=this;(0,_base.hackFunction)(_global.global,"fetch",function(b){return function(c,d){var e,f,g;function h(){return i.apply(this,arguments)}function i(){return i=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function b(){var e,f,g,h;return _regenerator["default"].wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(e=a.ctx.getConfig(),f=e.evaluateApi,g={name:o.url,entryType:_api.ApiType.FETCH,duration:(0,_base.getCurrentTime)()-o.timestamp},!(0,_rumCore.isFunction)(f)){b.next=12;break}return b.prev=3,b.next=6,f((0,_extends2["default"])({url:c},d),l,m);case 6:h=b.sent,o=(0,_extends2["default"])({},o,(0,_api.reviseApiAttr)(h)),b.next=12;break;case 10:b.prev=10,b.t0=b["catch"](3);case 12:a.delayHandle({attr:o,entry:g});case 13:case"end":return b.stop()}},b,null,[[3,10]])})),i.apply(this,arguments)}void 0===d&&(d={});var j=c instanceof Request?c.url:(0,_rumCore.isString)(c)?c:c.toString(),k=(null===(e=d)||void 0===e||null===(f=e.method)||void 0===f?void 0:f.toUpperCase())||"GET";// method: 'HEAD' 或 mode: 'no-cors' 的请求不监听 | ||
if((0,_rumCore.urlMatch)(j)||"HEAD"===k||"no-cors"===(null===(g=d)||void 0===g?void 0:g.mode))return b.call(_global.global,c,d);var l,m,n=a.ctx.session.getBaseEvent(),o=(0,_extends2["default"])({},n,{url:(0,_url.fixRelativeUrl)(j),type:_api.ApiType.FETCH,method:k});return a.injectTracing(o,function(a){d.headers=d.headers||{},Object.keys(a).forEach(function(b){d.headers[b]=a[b]})}),b.call(_global.global,c,d).then(function(a){l=a.clone();var b=l,c=b.status,d=b.statusText;return o.status_code=c,o.message=d,h().then(),a})["catch"](function(a){throw m=a,o.message=a+"",o.success=_rumCore.ResourceStatus.Failed,h().then(),a})}})},b.delayHandle=function delayHandle(a){var b=this;(0,_rumCore.delay)(function(){b.mergeEntry(a)},200)},b.mergeEntry=function mergeEntry(a){var b=a.attr,c=a.entry;c=this.findRealEntry(c);var d=this.ctx.getConfig(),e=d.parseResourceName,f=b.url,g=b.status_code,h=b.view;b.name=(0,_url.getResourceName)(f,e);var i=(0,_performance.getResourceSuccessByCode)(g),j=(0,_performance.calcResourceTimingData)(c)||{duration:c.duration},k=(0,_extends2["default"])({event_type:_rumCore.RumEventType.RESOURCE,url:f,name:(0,_url.getResourceName)(f,e),type:c.initiatorType||c.entryType,success:i},b,{timing_data:JSON.stringify(c)},j,{view:h});this.sendEvent(k)},b.findRealEntry=function findRealEntry(a){var b=a.name,c=this.entryCacheMap[b]||[],d=c.shift();return c.length||delete this.entryCacheMap[b],d||a},a}(); | ||
},b.hackXhr=function hackXhr(){var a=XMLHttpRequest.prototype,b=this.ctx.getConfig().filters||{},c=this;(0,_rumCore.interceptFunction)(a,"open",function(a,d,e,f,g){var h=d+"",i=a.toUpperCase();// chrome 对 URL 的最大长度为 8182 个字符 | ||
if(!((0,_rumCore.urlMatch)(h,b.resource)||"HEAD"===i||8182<h.length)){this.apiCache={type:_api.ApiType.XHR,method:a,url:d,async:e,user:f,password:g,headers:{}};var j=c.ctx.session.getBaseEvent();this.apiAttr=(0,_extends2["default"])({},j,{url:(0,_url.fixRelativeUrl)(h),method:i})}}),(0,_rumCore.interceptFunction)(a,"setRequestHeader",function(a,b){this.apiCache&&(this.apiCache.headers[a]=b)}),(0,_rumCore.interceptFunction)(a,"send",function(a){var b=this;if(this.apiAttr){var d=this.apiAttr;this.apiCache.data=a,c.injectTracing(this.apiAttr,function(a){Object.keys(a).forEach(function(c){b.setRequestHeader(c,a[c])})}),this.addEventListener("loadend",/*#__PURE__*/(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function a(){var e,f,g,h,i,j,k,l;return _regenerator["default"].wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(e=b.status,f=b.statusText,g=b.response,h=c.ctx.getConfig(),i=h.evaluateApi,d.status_code=e,d.message=f,j={name:b.apiAttr.url,entryType:_api.ApiType.XHR,duration:(0,_base.getCurrentTime)()-d.timestamp},!(0,_rumCore.isFunction)(i)){a.next=16;break}return a.prev=6,d.success===_rumCore.ResourceStatus.Failed&&(k=new Error(_api.ApiType.XHR+" error")),a.next=10,i(b.apiCache,g,k);case 10:l=a.sent,b.apiAttr=d=(0,_extends2["default"])({},d,(0,_api.reviseApiAttr)(l)),a.next=16;break;case 14:a.prev=14,a.t0=a["catch"](6);case 16:c.delayHandle({attr:d,entry:j});case 17:case"end":return a.stop()}},a,null,[[6,14]])}))),this.addEventListener("error",function(){b.apiAttr.success=_rumCore.ResourceStatus.Failed})}})},b.hackFetch=function hackFetch(){var a=this,b=this.ctx.getConfig().filters||{};(0,_base.hackFunction)(_global.global,"fetch",function(c){return function(d,e){var f,g,h;function i(){return j.apply(this,arguments)}function j(){return j=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function b(){var c,f,g,h;return _regenerator["default"].wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(c=a.ctx.getConfig(),f=c.evaluateApi,g={name:p.url,entryType:_api.ApiType.FETCH,duration:(0,_base.getCurrentTime)()-p.timestamp},!(0,_rumCore.isFunction)(f)){b.next=12;break}return b.prev=3,b.next=6,f((0,_extends2["default"])({url:d},e),m,n);case 6:h=b.sent,p=(0,_extends2["default"])({},p,(0,_api.reviseApiAttr)(h)),b.next=12;break;case 10:b.prev=10,b.t0=b["catch"](3);case 12:a.delayHandle({attr:p,entry:g});case 13:case"end":return b.stop()}},b,null,[[3,10]])})),j.apply(this,arguments)}void 0===e&&(e={});var k=d instanceof Request?d.url:(0,_rumCore.isString)(d)?d:d.toString(),l=(null===(f=e)||void 0===f||null===(g=f.method)||void 0===g?void 0:g.toUpperCase())||"GET";// method: 'HEAD' 或 mode: 'no-cors' 的请求不监听 | ||
if((0,_rumCore.urlMatch)(k,b.resource)||"HEAD"===l||"no-cors"===(null===(h=e)||void 0===h?void 0:h.mode)||8182<k.length)return c.call(_global.global,d,e);var m,n,o=a.ctx.session.getBaseEvent(),p=(0,_extends2["default"])({},o,{url:(0,_url.fixRelativeUrl)(k),type:_api.ApiType.FETCH,method:l});return a.injectTracing(p,function(a){e.headers=e.headers||{},Object.keys(a).forEach(function(b){e.headers[b]=a[b]})}),c.call(_global.global,d,e).then(function(a){m=a.clone();var b=m,c=b.status,d=b.statusText;return p.status_code=c,p.message=d,i().then(),a})["catch"](function(a){throw n=a,p.message=a+"",p.success=_rumCore.ResourceStatus.Failed,i().then(),a})}})},b.delayHandle=function delayHandle(a){var b=this;(0,_rumCore.delay)(function(){b.mergeEntry(a)},200)},b.mergeEntry=function mergeEntry(a){var b=a.attr,c=a.entry;c=this.findRealEntry(c);var d=this.ctx.getConfig(),e=d.parseResourceName,f=b.url,g=b.status_code,h=b.view;b.name=(0,_url.getResourceName)(f,e);var i=(0,_performance.getResourceSuccessByCode)(g),j=(0,_performance.calcResourceTimingData)(c)||{duration:c.duration},k=(0,_extends2["default"])({event_type:_rumCore.RumEventType.RESOURCE,url:f,name:(0,_url.getResourceName)(f,e),type:c.initiatorType||c.entryType,success:i},b,{timing_data:JSON.stringify(c)},j,{view:h});this.sendEvent(k)},b.findRealEntry=function findRealEntry(a){var b=a.name,c=this.entryCacheMap[b]||[],d=c.shift();return c.length||delete this.entryCacheMap[b],d||a},a}(); |
@@ -1,5 +0,5 @@ | ||
"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"),_performance=require("../../utils/performance"),_url=require("../../utils/url"),_view=require("../../utils/view"),_global=require("../../utils/global"),_base=require("../../utils/base"),PerfObserver=_global.global.PerformanceObserver,StaticResourceCollector=exports["default"]=/*#__PURE__*/function(){function a(){var a=this;this.name="static-resource-collector",this.entryTypes=["audio","video","track","script","css","img","image","link","other"],this.errorsCache=[],this.WAIT_FOR_ERROR_TIME=1e3,this.perfObserver=void 0,this.sendEvent=void 0,this.ctx=void 0,this.sendResource=function(b){var c=a.ctx.getConfig(),d=c.parseResourceName,e=b.responseStatus,f=b.name,g=(0,_performance.getResourceType)(f,b.initiatorType),h=a.checkError(f),i=h?_rumCore.ResourceStatus.Failed:(0,_performance.getResourceStatus)(b),j=(0,_performance.calcResourceTimingData)(b,h);// If the value of the responseStatus property is 0, the resource might be a cross-origin request. | ||
"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"),_performance=require("../../utils/performance"),_url=require("../../utils/url"),_view=require("../../utils/view"),_global=require("../../utils/global"),_base=require("../../utils/base"),PerfObserver=_global.global.PerformanceObserver,StaticResourceCollector=exports["default"]=/*#__PURE__*/function(){function a(){var a=this;this.name="static-resource-collector",this.entryTypes=["audio","video","track","script","css","img","image","link","other"],this.errorsCache=[],this.WAIT_FOR_ERROR_TIME=1e3,this.perfObserver=void 0,this.sendEvent=void 0,this.ctx=void 0,this.sendResource=function(b){var c=a.ctx.getConfig(),d=c.parseResourceName,e=c.filters,f=void 0===e?{}:e,g=b.responseStatus,h=b.name,i=(0,_performance.getResourceType)(h,b.initiatorType),j=a.checkError(h),k=j?_rumCore.ResourceStatus.Failed:(0,_performance.getResourceStatus)(b),l=(0,_performance.calcResourceTimingData)(b,j);// If the value of the responseStatus property is 0, the resource might be a cross-origin request. | ||
// To allow seeing cross-origin response status codes, the CORS Access-Control-Allow-Origin HTTP | ||
// response header needs to be set. | ||
if(j){var k=a.ctx.session.getBaseEvent(),l=(0,_extends2["default"])({},k,{event_type:_rumCore.RumEventType.RESOURCE,url:f,name:(0,_url.getResourceName)(f,d),type:g,method:"GET",status_code:e,success:i},j,{timing_data:JSON.stringify(b)});(0,_rumCore.urlMatch)(l.url)||a.sendEvent(l)}},this.errorHandler=function(b){var c=b.target||b.srcElement,d=c&&c.nodeName&&1===c.nodeType,e=c.src||c.href;d&&e&&0===e.indexOf("http")&&a.errorsCache.push({src:e,timeStamp:(0,_base.getCurrentTime)()})},this.perfHandler=function(b){var c=b.getEntries().filter(function(b){return-1<a.entryTypes.indexOf(b.initiatorType)});if(c&&c.length){var d=(0,_view.getCurView)(a.ctx);// 延迟 1 s 看是否加载失败 | ||
if(l){var m=a.ctx.session.getBaseEvent(),n=(0,_extends2["default"])({},m,{event_type:_rumCore.RumEventType.RESOURCE,url:h,name:(0,_url.getResourceName)(h,d),type:i,method:"GET",status_code:g,success:k},l,{timing_data:JSON.stringify(b)});(0,_rumCore.urlMatch)(n.url,f.resource)||a.sendEvent(n)}},this.errorHandler=function(b){var c=b.target||b.srcElement,d=c&&c.nodeName&&1===c.nodeType,e=c.src||c.href;d&&e&&0===e.indexOf("http")&&a.errorsCache.push({src:e,timeStamp:(0,_base.getCurrentTime)()})},this.perfHandler=function(b){var c=b.getEntries().filter(function(b){return-1<a.entryTypes.indexOf(b.initiatorType)});if(c&&c.length){var d=(0,_view.getCurView)(a.ctx);// 延迟 1 s 看是否加载失败 | ||
setTimeout(function(){c.forEach(function(b){a.sendResource(b,d)})},a.WAIT_FOR_ERROR_TIME)}}}var b=a.prototype;return b.setup=function setup(a,b){var c=a.getConfig().collectors||{};if((this.ctx=a,this.sendEvent=b,!1!==c.staticResource)&&(0,_rumCore.isFunction)(PerfObserver)){var d;try{d=new PerfObserver(this.perfHandler),d.observe({type:"resource",buffered:!0})}catch(a){d=new PerfObserver(this.perfHandler),d.observe({entryTypes:["resource"]})}this.perfObserver=d,_global.global.addEventListener("error",this.errorHandler,!0)}},b.checkError=function checkError(a){var b=!1,c=(0,_base.getCurrentTime)();return this.errorsCache=this.errorsCache.filter(function(d){return a===d.src?(b=!0,!0):!!(1e4<c-d.timeStamp)}),b},b.destroy=function destroy(){this.perfObserver&&(_global.global.removeEventListener("error",this.errorHandler),this.perfObserver.disconnect(),this.perfObserver=null)},a}(); |
@@ -1,1 +0,1 @@ | ||
"use strict";exports.__esModule=!0,exports.location=exports.history=exports.global=exports.document=exports.VERSION=void 0;var global=exports.global=window,document=exports.document=window.document,location=exports.location=window.location,history=exports.history=window.history,VERSION=exports.VERSION='0.0.27-beta.11'; | ||
"use strict";exports.__esModule=!0,exports.location=exports.history=exports.global=exports.document=exports.VERSION=void 0;var global=exports.global=window,document=exports.document=window.document,location=exports.location=window.location,history=exports.history=window.history,VERSION=exports.VERSION='0.0.27-beta.12'; |
{ | ||
"name": "@arms/rum-browser", | ||
"version": "0.0.27-beta.11", | ||
"version": "0.0.27-beta.12", | ||
"description": "arms rum javascript sdk for browser", | ||
@@ -26,3 +26,3 @@ "author": "guangli.fj <guangli.fj@alibaba-inc.com>", | ||
"dependencies": { | ||
"@arms/rum-core": "0.0.25-beta.20", | ||
"@arms/rum-core": "0.0.25-beta.21", | ||
"web-vitals": "3.5.2" | ||
@@ -29,0 +29,0 @@ }, |
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
222053
1006
+ Added@arms/rum-core@0.0.25-beta.21(transitive)
- Removed@arms/rum-core@0.0.25-beta.20(transitive)