@arms/rum-browser
Advanced tools
Comparing version 0.0.25-beta.10 to 0.0.25-beta.12
@@ -7,3 +7,2 @@ import { ICollector, IContext, ITracingHeaders, RumEvent } from '@arms/rum-core'; | ||
apiCache: IApiCache; | ||
_start_time?: number; | ||
} | ||
@@ -10,0 +9,0 @@ } |
"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"),_performance=require("../../utils/performance"),_url=require("../../utils/url"),_view=require("../../utils/view"),_base=require("../../utils/base"),_global=require("../../utils/global"),_uuid=require("../../utils/uuid"),_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.cachedEntries=[],this.cachedApiAttrs=[],this.ctx=void 0,this.sendEvent=void 0}var b=a.prototype;return b.setup=function setup(a,b){var c=a.getConfig(),d=c.collectors,e=void 0===d?{}:d;!1===e.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){a.mergeDataAndSend({entry: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;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&browser&"+f+"&"+w+"&"+v:void 0,y=void 0!==o&&o?"rum=v2,appType=browser,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:_global.location.host});u&&(a.trace_id=s,a.trace_data=JSON.stringify({spanId:t,sample:k,sampled:u,headers:z})),b(z)}}// 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();(0,_rumCore.urlMatch)(g)||"HEAD"===h||(this.apiCache={type:_api.ApiType.XHR,method:a,url:c,async:d,user:e,password:f,headers:{}},this.apiAttr={url:(0,_url.fixRelativeUrl)(g),method:h,// 异步过程 保证 view_id view_name 正确 | ||
view:(0,_view.getCurView)(b.ctx)},this._start_time=(0,_base.getCurrentTime)())}),(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,(0,_rumCore.isFunction)(PerfObserver)||(j={name:c.apiAttr.url,entryType:_api.ApiType.XHR,duration:(0,_base.getCurrentTime)()-c._start_time}),!(0,_rumCore.isFunction)(i)){a.next=16;break}return a.prev=6,d.success===_performance.ResourceStatus.Failed&&(k=new Error(_api.ApiType.XHR+" error")),a.next=10,i(c.apiCache,g,k);case 10:l=a.sent,c.apiAttr=(0,_extends2["default"])({},c.apiAttr,(0,_api.reviseApiAttr)(l)),a.next=16;break;case 14:a.prev=14,a.t0=a["catch"](6);case 16:b.mergeDataAndSend({attr:c.apiAttr,entry:j});case 17:case"end":return a.stop()}},a,null,[[6,14]])}))),this.addEventListener("error",function(){c.apiAttr.success=_performance.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;void 0===d&&(d={});var h=c instanceof Request?c.url:(0,_rumCore.isString)(c)?c:c.toString(),i=(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)(h)||"HEAD"===i||"no-cors"===(null===(g=d)||void 0===g?void 0:g.mode))return b.call(_global.global,c,d);var j,k,l=(0,_base.getCurrentTime)(),m={url:(0,_url.fixRelativeUrl)(h),type:_api.ApiType.FETCH,method:i,// 异步过程 保证 view_id view_name 正确 | ||
view:(0,_view.getCurView)(a.ctx)};return a.injectTracing(m,function(a){d.headers=d.headers||{},Object.keys(a).forEach(function(b){d.headers[b]=a[b]})}),b.call(_global.global,c,d).then(/*#__PURE__*/function(){var a=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function b(a){var c,d,e;return _regenerator["default"].wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return j=a.clone(),c=j,d=c.status,e=c.statusText,m.status_code=d,m.message=e,b.abrupt("return",a);case 5:case"end":return b.stop()}},b)}));return function(){return a.apply(this,arguments)}}(),function(a){throw k=a,m.message=a+"",m.success=_performance.ResourceStatus.Failed,a})["finally"](/*#__PURE__*/(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,(0,_rumCore.isFunction)(PerfObserver)||(g={name:m.url,entryType:_api.ApiType.FETCH,duration:(0,_base.getCurrentTime)()-l}),!(0,_rumCore.isFunction)(f)){b.next=12;break}return b.prev=3,b.next=6,f((0,_extends2["default"])({url:c},d),j,k);case 6:h=b.sent,m=(0,_extends2["default"])({},m,(0,_api.reviseApiAttr)(h)),b.next=12;break;case 10:b.prev=10,b.t0=b["catch"](3);case 12:a.mergeDataAndSend({attr:m,entry:g});case 13:case"end":return b.stop()}},b,null,[[3,10]])})))}})},b.mergeDataAndSend=function mergeDataAndSend(a){var b=this;try{var c=function(a,c){var d=b.ctx.getConfig(),e=d.parseResourceName,f=a.url,g=a.status_code,h=a.view,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},a,{timing_data:JSON.stringify(c)},j,{view:h});b.sendEvent(k)},d=a.attr,e=a.entry;if(d&&e)return void c(d,e);var f=this.cachedApiAttrs,g=this.cachedEntries;if(d){var h=g.find(function(a){return a.name===d.url});if(!h)return void f.push(d);g=g.filter(function(a){return a.name!==h.name}),c(d,h)}if(e){var i=f.find(function(a){return a.url===e.name});if(!i)return void g.push(e);f=f.filter(function(a){return a.url!==i.url}),c(i,e)}}catch(a){}},a}(); | ||
},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();(0,_rumCore.urlMatch)(g)||"HEAD"===h||(this.apiCache={type:_api.ApiType.XHR,method:a,url:c,async:d,user:e,password:f,headers:{}},this.apiAttr={timestamp:(0,_base.getCurrentTime)(),url:(0,_url.fixRelativeUrl)(g),method:h,// 异步过程 保证 view_id view_name 正确 | ||
view:(0,_view.getCurView)(b.ctx)})}),(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,(0,_rumCore.isFunction)(PerfObserver)||(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===_performance.ResourceStatus.Failed&&(k=new Error(_api.ApiType.XHR+" error")),a.next=10,i(c.apiCache,g,k);case 10:l=a.sent,c.apiAttr=(0,_extends2["default"])({},c.apiAttr,(0,_api.reviseApiAttr)(l)),a.next=16;break;case 14:a.prev=14,a.t0=a["catch"](6);case 16:b.mergeDataAndSend({attr:c.apiAttr,entry:j});case 17:case"end":return a.stop()}},a,null,[[6,14]])}))),this.addEventListener("error",function(){c.apiAttr.success=_performance.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;void 0===d&&(d={});var h=c instanceof Request?c.url:(0,_rumCore.isString)(c)?c:c.toString(),i=(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)(h)||"HEAD"===i||"no-cors"===(null===(g=d)||void 0===g?void 0:g.mode))return b.call(_global.global,c,d);var j,k,l={timestamp:(0,_base.getCurrentTime)(),url:(0,_url.fixRelativeUrl)(h),type:_api.ApiType.FETCH,method:i,// 异步过程 保证 view_id view_name 正确 | ||
view:(0,_view.getCurView)(a.ctx)};return a.injectTracing(l,function(a){d.headers=d.headers||{},Object.keys(a).forEach(function(b){d.headers[b]=a[b]})}),b.call(_global.global,c,d).then(/*#__PURE__*/function(){var a=(0,_asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function b(a){var c,d,e;return _regenerator["default"].wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return j=a.clone(),c=j,d=c.status,e=c.statusText,l.status_code=d,l.message=e,b.abrupt("return",a);case 5:case"end":return b.stop()}},b)}));return function(){return a.apply(this,arguments)}}(),function(a){throw k=a,l.message=a+"",l.success=_performance.ResourceStatus.Failed,a})["finally"](/*#__PURE__*/(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,(0,_rumCore.isFunction)(PerfObserver)||(g={name:l.url,entryType:_api.ApiType.FETCH,duration:(0,_base.getCurrentTime)()-l.timestamp}),!(0,_rumCore.isFunction)(f)){b.next=12;break}return b.prev=3,b.next=6,f((0,_extends2["default"])({url:c},d),j,k);case 6:h=b.sent,l=(0,_extends2["default"])({},l,(0,_api.reviseApiAttr)(h)),b.next=12;break;case 10:b.prev=10,b.t0=b["catch"](3);case 12:a.mergeDataAndSend({attr:l,entry:g});case 13:case"end":return b.stop()}},b,null,[[3,10]])})))}})},b.mergeDataAndSend=function mergeDataAndSend(a){var b=this;try{var c=function(a,c){var d=b.ctx.getConfig(),e=d.parseResourceName,f=a.url,g=a.status_code,h=a.view,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},a,{timing_data:JSON.stringify(c)},j,{view:h});b.sendEvent(k)},d=a.attr,e=a.entry;if(d&&e)return void c(d,e);var f=this.cachedApiAttrs,g=this.cachedEntries;if(d){var h=g.find(function(a){return a.name===d.url});if(!h)return void f.push(d);g=g.filter(function(a){return a.name!==h.name}),c(d,h)}if(e){var i=f.find(function(a){return a.url===e.name});if(!i)return void g.push(e);f=f.filter(function(a){return a.url!==i.url}),c(i,e)}}catch(a){}},a}(); |
@@ -1,2 +0,5 @@ | ||
import { ICollector, IContext, RumEvent } from '@arms/rum-core'; | ||
import { ICollector, IContext, RumEvent, RumViewEvent } from '@arms/rum-core'; | ||
interface IMeasures { | ||
[key: string]: number; | ||
} | ||
export default class WebVitalsCollector implements ICollector { | ||
@@ -6,4 +9,9 @@ name: string; | ||
sendEvent: (payload: RumEvent) => void; | ||
baseEvent: Partial<RumViewEvent>; | ||
measures: IMeasures; | ||
timer: number; | ||
setup(ctx: IContext, sendEvent: (payload: RumEvent) => void): void; | ||
private sendWebvitals; | ||
sendWebVitals(key: string, value: number): void; | ||
private onWebVitals; | ||
} | ||
export {}; |
@@ -1,7 +0,1 @@ | ||
"use strict";exports.__esModule=!0,exports["default"]=void 0;var _rumCore=require("@arms/rum-core"),_url=require("../../utils/url"),_view=require("../../utils/view"),_webVitals=require("web-vitals"),_global=require("../../utils/global"),WebVitalsCollector=exports["default"]=/*#__PURE__*/function(){function a(){this.name="web-vitals-collector",this.ctx=void 0,this.sendEvent=void 0}var b=a.prototype;return b.setup=function setup(a,b){var c=a.getConfig(),d=c.collectors,e=void 0===d?{}:d;!1===e.webVitals||(this.ctx=a,this.sendEvent=b,this.sendWebvitals())},b.sendWebvitals=function sendWebvitals(){var a=this,b=(0,_view.getCurView)(this.ctx);(0,_webVitals.onLCP)(function(c){a.sendEvent({event_type:_rumCore.RumEventType.VIEW,type:"webvitals",url:(0,_url.getCurrentURL)(),referrer:_global.document.referrer||"",// Measure | ||
largest_contentful_paint:(0,_rumCore.formatNumber)(c.value),// 保证 viewId 正确 | ||
view:b})}),(0,_webVitals.onFID)(function(c){var d={event_type:_rumCore.RumEventType.VIEW,type:"webvitals",url:(0,_url.getCurrentURL)(),referrer:_global.document.referrer||"",// Measure | ||
first_input_delay:(0,_rumCore.formatNumber)(c.value),// 保证 viewId 正确 | ||
view:b};(0,_rumCore.isArray)(c.entries)&&c.entries.forEach(function(a){a&&"first-input"===a.entryType&&(d.first_input_time=(0,_rumCore.formatNumber)(a.startTime))}),a.sendEvent(d)}),(0,_webVitals.onCLS)(function(c){a.sendEvent({event_type:_rumCore.RumEventType.VIEW,type:"webvitals",url:(0,_url.getCurrentURL)(),referrer:_global.document.referrer||"",// Measure | ||
cumulative_layout_shift:(0,_rumCore.formatNumber)(c.value),// 保证 viewId 正确 | ||
view:b})})},a}(); | ||
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=!0,exports["default"]=void 0;var _extends3=_interopRequireDefault(require("@babel/runtime/helpers/extends")),_rumCore=require("@arms/rum-core"),_url=require("../../utils/url"),_view=require("../../utils/view"),_webVitals=require("web-vitals"),_global=require("../../utils/global"),WebVitalsCollector=exports["default"]=/*#__PURE__*/function(){function a(){this.name="web-vitals-collector",this.ctx=void 0,this.sendEvent=void 0,this.baseEvent=void 0,this.measures={},this.timer=void 0}var b=a.prototype;return b.setup=function setup(a,b){var c=a.getConfig(),d=c.collectors,e=void 0===d?{}:d;!1===e.webVitals||(this.ctx=a,this.sendEvent=b,this.baseEvent={event_type:_rumCore.RumEventType.VIEW,type:"webvitals",referrer:_global.document.referrer||"",view:(0,_view.getCurView)(this.ctx)},this.onWebVitals())},b.sendWebVitals=function sendWebVitals(a,b){var c,d=this;clearTimeout(this.timer),this.measures=(0,_extends3["default"])({},this.measures,(c={},c[a]=b,c)),this.timer=setTimeout(function(){d.sendEvent((0,_extends3["default"])({},d.baseEvent,d.measures,{url:(0,_url.getCurrentURL)()})),d.measures={}},200)},b.onWebVitals=function onWebVitals(){var a=this;(0,_webVitals.onLCP)(function(b){return a.sendWebVitals("largest_contentful_paint",(0,_rumCore.formatNumber)(b.value))}),(0,_webVitals.onFID)(function(b){a.sendWebVitals("first_input_delay",(0,_rumCore.formatNumber)(b.value)),(0,_rumCore.isArray)(b.entries)&&b.entries.forEach(function(b){b&&"first-input"===b.entryType&&a.sendWebVitals("first_input_time",(0,_rumCore.formatNumber)(b.startTime))})}),(0,_webVitals.onCLS)(function(b){return a.sendWebVitals("cumulative_layout_shift",(0,_rumCore.formatNumber)(b.value))}),(0,_webVitals.onINP)(function(b){return a.sendWebVitals("interaction_to_next_paint",(0,_rumCore.formatNumber)(b.value))})},a}(); |
@@ -1,4 +0,4 @@ | ||
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=!0,exports["default"]=void 0;var _inheritsLoose2=_interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose")),_rumCore=require("@arms/rum-core"),_uuid=require("../utils/uuid"),_global=require("../utils/global"),BrowserReporter=/*#__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.name="browser-reporter",b}(0,_inheritsLoose2["default"])(b,a);var c=b.prototype;return c.init=function init(){var a=this;_global.document.addEventListener("visibilitychange",function(){"hidden"===_global.document.visibilityState&&a.flushEventQueue()})},c.request=function request(a,b,c){var d,e=a.getConfig(),f={app:{id:e.pid,env:e.env||"prod",version:e.version,type:_rumCore.AppType.browser},user:{id:(0,_uuid.getUserID)()},session:{id:(0,_uuid.getSessionID)()},view:c,net:{model:(null===(d=navigator.connection)||void 0===d?void 0:d.effectiveType)||""},events:b};if(["app","user","device","os","geo","isp","net"].forEach(function(a){var b=e[a];(0,_rumCore.isObject)(b)&&Object.keys(b).forEach(function(c){var d=b[c];// user 的 id 不能被覆盖 | ||
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=!0,exports["default"]=void 0;var _inheritsLoose2=_interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose")),_rumCore=require("@arms/rum-core"),_uuid=require("../utils/uuid"),_global=require("../utils/global"),BrowserReporter=/*#__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.name="browser-reporter",b}(0,_inheritsLoose2["default"])(b,a);var c=b.prototype;return c.init=function init(){var a=this;_global.document.addEventListener("visibilitychange",function(){"hidden"===_global.document.visibilityState&&a.flushEventQueue()})},c.request=function request(a,b,c){var d,e=a.getConfig(),f={app:{id:e.pid,env:e.env||"prod",version:e.version,type:_rumCore.AppType.browser},user:{id:(0,_uuid.getUserID)()},session:{id:(0,_uuid.getSessionID)()},view:c,net:{model:(null===(d=navigator.connection)||void 0===d?void 0:d.effectiveType)||""},events:b,_v:_global.VERSION};if(["app","user","device","os","geo","isp","net"].forEach(function(a){var b=e[a];(0,_rumCore.isObject)(b)&&Object.keys(b).forEach(function(c){var d=b[c];// user 的 id 不能被覆盖 | ||
"user"===a&&"id"===c||((0,_rumCore.isString)(d)||(0,_rumCore.isNumber)(d))&&(!(a in f)&&(f[a]={}),f[a][c]=d)})}),!("function"==typeof e.beforeReport&&(f=e.beforeReport(f),!f)))try{navigator.sendBeacon(e.endpoint,JSON.stringify(f))}catch(a){}},b}(_rumCore.Reporter),_default=exports["default"]=BrowserReporter;/** | ||
* browser reporter | ||
*/ |
@@ -7,2 +7,3 @@ import { Shell } from '@arms/rum-core'; | ||
export declare class ArmsRum extends Shell { | ||
version: string; | ||
/** | ||
@@ -9,0 +10,0 @@ * 初始化 |
@@ -1,2 +0,2 @@ | ||
"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")),_exception=_interopRequireDefault(require("./collector/exception")),_blank=_interopRequireDefault(require("./collector/exception/blank")),_perf=_interopRequireDefault(require("./collector/view/perf")),_webvitals=_interopRequireDefault(require("./collector/view/webvitals")),_api=_interopRequireDefault(require("./collector/resource/api")),_staticResource=_interopRequireDefault(require("./collector/resource/static-resource")),_click=_interopRequireDefault(require("./collector/action/click")),_defaultProcessor=_interopRequireDefault(require("./processor/default-processor")),_sessionProcessor=_interopRequireDefault(require("./processor/session-processor")),_reporter=_interopRequireDefault(require("./reporter")),_global=require("./utils/global"),ArmsRum=exports.ArmsRum=/*#__PURE__*/function(a){function b(){return a.apply(this,arguments)||this}(0,_inheritsLoose2["default"])(b,a);var c=b.prototype;return c.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")),_exception=_interopRequireDefault(require("./collector/exception")),_blank=_interopRequireDefault(require("./collector/exception/blank")),_perf=_interopRequireDefault(require("./collector/view/perf")),_webvitals=_interopRequireDefault(require("./collector/view/webvitals")),_api=_interopRequireDefault(require("./collector/resource/api")),_staticResource=_interopRequireDefault(require("./collector/resource/static-resource")),_click=_interopRequireDefault(require("./collector/action/click")),_defaultProcessor=_interopRequireDefault(require("./processor/default-processor")),_sessionProcessor=_interopRequireDefault(require("./processor/session-processor")),_reporter=_interopRequireDefault(require("./reporter")),_global=require("./utils/global"),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.version=_global.VERSION,b}(0,_inheritsLoose2["default"])(b,a);var c=b.prototype;return c.init=/** | ||
* 初始化 | ||
@@ -3,0 +3,0 @@ */function init(a){this.client.useCollectors([new _pv["default"],new _perf["default"],new _webvitals["default"],new _exception["default"],new _blank["default"],new _api["default"],new _staticResource["default"],new _click["default"]]),this.client.useProcessors([new _defaultProcessor["default"],new _sessionProcessor["default"]]),this.client.useReporter(new _reporter["default"]),this.client.init(a)},c.getConfig=function getConfig(){return this.client.getContext().getConfig()},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(_global.global.__rum);/** |
@@ -19,2 +19,3 @@ import { IViewData } from "@arms/rum-core"; | ||
method: string; | ||
timestamp: number; | ||
trace_id?: string; | ||
@@ -21,0 +22,0 @@ trace_data?: string; |
@@ -1,1 +0,1 @@ | ||
"use strict";exports.__esModule=!0,exports.ApiType=void 0,exports.reviseApiAttr=reviseApiAttr;var _rumCore=require("@arms/rum-core"),ApiType=exports.ApiType={XHR:"xmlhttprequest",FETCH:"fetch"};function reviseApiAttr(a){if(a&&(0,_rumCore.isObject)(a)){var b={};return(0,_rumCore.isString)(a.name)&&(b.name=a.name.substring(0,1e3)),(0,_rumCore.isString)(a.message)&&(b.message=a.message.substring(0,1e3)),(0,_rumCore.isNumber)(a.success)&&-1<=a.success&&1>=a.success&&(b.success=a.success),(0,_rumCore.isNumber)(a.duration)&&0<=a.duration&&(b.duration=a.duration),(0,_rumCore.isString)(a.status_code)&&(b.status_code=a.status_code.substring(0,100)),(0,_rumCore.isNumber)(a.status_code)&&(b.status_code=a.status_code),(0,_rumCore.isString)(a.snapshots)&&(b.snapshot=a.snapshots.substring(0,5e3)),b}} | ||
"use strict";exports.__esModule=!0,exports.ApiType=void 0,exports.reviseApiAttr=reviseApiAttr;var _rumCore=require("@arms/rum-core"),ApiType=exports.ApiType={XHR:"xmlhttprequest",FETCH:"fetch"};function reviseApiAttr(a){if(a&&(0,_rumCore.isObject)(a)){var b={};return(0,_rumCore.isString)(a.name)&&(b.name=a.name.substring(0,1e3)),(0,_rumCore.isString)(a.message)&&(b.message=a.message.substring(0,1e3)),(0,_rumCore.isNumber)(a.success)&&-1<=a.success&&1>=a.success&&(b.success=a.success),(0,_rumCore.isNumber)(a.duration)&&0<=a.duration&&(b.duration=a.duration),(0,_rumCore.isString)(a.status_code)&&(b.status_code=a.status_code.substring(0,100)),(0,_rumCore.isNumber)(a.status_code)&&(b.status_code=a.status_code),(0,_rumCore.isString)(a.snapshots)&&(b.snapshots=a.snapshots.substring(0,5e3)),b}} |
@@ -5,1 +5,2 @@ export declare const global: any; | ||
export declare const history: any; | ||
export declare const VERSION: string; |
@@ -1,1 +0,1 @@ | ||
"use strict";exports.__esModule=!0,exports.location=exports.history=exports.global=exports.document=void 0;var global=exports.global=window,document=exports.document=window.document,location=exports.location=window.location,history=exports.history=window.history; | ||
"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.25-beta.12'; |
@@ -17,3 +17,3 @@ /** | ||
export declare function getUserID(): any; | ||
export declare function getEventId(): string; | ||
export declare function getEventId(sampled?: boolean, samplingType?: string): string; | ||
export declare function getViewId(): string; |
@@ -6,8 +6,8 @@ "use strict";exports.__esModule=!0,exports.getEventId=getEventId,exports.getSessionID=getSessionID,exports.getUUID=getUUID,exports.getUserID=getUserID,exports.getViewId=getViewId,exports.setSessionID=setSessionID;var _rumCore=require("@arms/rum-core"),_global=require("./global"),SESSION_ID="_arms_sid",SESSION_ID_EXP="_arms_sid_exp",USER_ID="_arms_uid",localStorage=_global.global.localStorage;// 存储sessionID的键名 | ||
* 获取uuid | ||
*/function getUUID(a){return void 0===a&&(a=""),a&&(a+="_"),""+a+(0,_rumCore.generateUUID)()}/** | ||
*/function getUUID(a){return void 0===a&&(a=""),a&&(a+="_"),""+a+(0,_rumCore.generateSpanId)()}/** | ||
* 获取唯一的sessionID | ||
*/function getSessionID(){var a=localStorage.getItem(SESSION_ID),b=new Date(localStorage.getItem(SESSION_ID_EXP));return(!a||32>a.length||!b.valueOf()||b<new Date)&&(a=setSessionID()),a}/** | ||
* 设置唯一的sessionID | ||
*/function setSessionID(){var a=(0,_rumCore.generateGUID)();return localStorage.setItem(SESSION_ID,a),localStorage.setItem(SESSION_ID_EXP,new Date(Date.now()+86400000).toString()),a}/** | ||
*/function setSessionID(){var a=(0,_rumCore.generateGUID)().replace(/-/g,"");return localStorage.setItem(SESSION_ID,a),localStorage.setItem(SESSION_ID_EXP,new Date(Date.now()+86400000).toString()),a}/** | ||
* 获取唯一的userID | ||
*/function getUserID(){var a=localStorage.getItem(USER_ID);return a||(a=getUUID("user"),localStorage.setItem(USER_ID,a)),a}function getEventId(){return(0,_rumCore.generateGUID)()}function getViewId(){return(0,_rumCore.generateGUID)()} | ||
*/function getUserID(){var a=localStorage.getItem(USER_ID);return a||(a=getUUID("user"),localStorage.setItem(USER_ID,a)),a}function getEventId(a,b){void 0===a&&(a=!0),void 0===b&&(b="0");var c=getSessionID();return(0,_rumCore.generateEventId)(c,a,b)}function getViewId(){return(0,_rumCore.generateGUID)().replace(/-/g,"")} |
{ | ||
"name": "@arms/rum-browser", | ||
"version": "0.0.25-beta.10", | ||
"version": "0.0.25-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.9", | ||
"@arms/rum-core": "0.0.25-beta.11", | ||
"web-vitals": "3.5.2" | ||
@@ -29,0 +29,0 @@ }, |
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances 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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
197017
+ Added@arms/rum-core@0.0.25-beta.11(transitive)
- Removed@arms/rum-core@0.0.25-beta.9(transitive)