@apmplus/integrations
Advanced tools
Comparing version 2.1.4 to 2.1.5-alpha.0
@@ -259,2 +259,5 @@ interface ContextAgent { | ||
}; | ||
declare type WebTransport = SdkTransport & { | ||
useBeacon?: boolean; | ||
}; | ||
@@ -888,2 +891,3 @@ interface Common$1 { | ||
dedupe: boolean; | ||
gatherPath: boolean; | ||
}; | ||
@@ -1050,3 +1054,3 @@ | ||
integrations?: Integration<BrowserCommandClient>[] | ||
transport?: SdkTransport | ||
transport?: WebTransport | ||
storageExpires?: number | boolean // 只能初始化配置一次 | ||
@@ -1089,3 +1093,3 @@ plugins?: AjaxMonitorPluginConfig & | ||
integrations?: Integration<BrowserCommandClient>[] | ||
transport: SdkTransport | ||
transport: WebTransport | ||
} | ||
@@ -1092,0 +1096,0 @@ |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __assign=function(){return(__assign=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function __read(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||0<e--)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u}function __spreadArray(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||((n=n||Array.prototype.slice.call(e,0,o))[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}var noop=function(){return{}};function isObject(t){return"object"==typeof t&&null!==t}var objProto=Object.prototype;function isArray(t){return"[object Array]"===objProto.toString.call(t)}function isFunction(t){return"function"==typeof t}function arrayIncludes(t,e){if(!isArray(t))return!1;if(0===t.length)return!1;for(var r=0;r<t.length;){if(t[r]===e)return!0;r++}return!1}var applyRecord=function(){var r={};return[r,function(t,e){return r[t]=e},function(t){return delete r[t]}]},hookMethodDangerously=function(i,u,a){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(!i)return noop;var r=i[u],n=a.apply(void 0,__spreadArray([r],__read(t),!1)),o=n;return isFunction(o)&&(o=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n.apply(this,t)}),i[u]=o,function(){o===i[u]?i[u]=r:n=r}}};function mathRNG(){for(var t=new Array(16),e=0,r=0;r<16;r++)0==(3&r)&&(e=4294967296*Math.random()),t[r]=e>>>((3&r)<<3)&255;return t}function bytesToUuid(t){for(var e=[],r=0;r<256;++r)e[r]=(r+256).toString(16).substr(1);var n=0,o=e;return[o[t[n++]],o[t[n++]],o[t[n++]],o[t[n++]],"-",o[t[n++]],o[t[n++]],"-",o[t[n++]],o[t[n++]],"-",o[t[n++]],o[t[n++]],"-",o[t[n++]],o[t[n++]],o[t[n++]],o[t[n++]],o[t[+n]],o[t[15]]].join("")}function uuid(){var t=mathRNG();return t[6]=15&t[6]|64,t[8]=63&t[8]|128,bytesToUuid(t)}var registerTearDownGroup=function(t,e,r,n){return t.destroyAgent.set(e,r,n)};function initSubjectInGlobal(t,e){return t.initSubject(e)}var now=function(){return Date.now()};function getDefaultBrowser(){if("object"==typeof window&&isObject(window))return window}function getDefaultDocument(){if("object"==typeof document&&isObject(document))return document}function getDefaultLocation(){return getDefaultBrowser()&&window.location}function getDefaultPerformanceObserver(){if(getDefaultBrowser()&&isFunction(window.PerformanceObserver))return window.PerformanceObserver}function getLocationUrl(){var t=getDefaultBrowser()&&getDefaultLocation();return null==t?void 0:t.href}var getViewOverrides=function(t){return{pid:t.pid,view_id:t.viewId,url:getLocationUrl()}},getOverrides=function(t){var e=t.config(),e=getViewOverrides(e);return e.context=t.context?t.context.toString():{},e},reportWithCurrentContext=function(e,t){void 0===t&&(t=!1);var r=getOverrides(e);return t&&(r.timestamp=now()),function(t){e.report(__assign(__assign({},t),{overrides:r}))}},applyMutationObserver=function(t,e){var r=t&&new t(e);return[function(t,e){r&&t&&r.observe(t,e)},function(){return r&&r.disconnect()}]},applyPerformance=function(r){var t=r&&r.timing||void 0;return[t,function(){return r&&r.now?r.now():(Date.now?Date.now():+new Date)-(t&&t.navigationStart||0)},function(t){var e=(r||{}).getEntriesByType;return isFunction(e)&&e.call(r,t)||[]},function(){var t=(r||{}).clearResourceTimings;isFunction(t)&&t.call(r)},function(t){var e=(r||{}).getEntriesByName;return isFunction(e)&&e.call(r,t)||[]}]},XHR_SUBJECT_NAME="xhr_0",getReportPathRegExp=function(){var e=new RegExp("\\/monitor_web\\/collect|\\/monitor_browser\\/collect\\/batch","i");return function(t){return e.test(t)}},hookOpen=function(n){return function(){for(var t,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return t=__read(e,2),this._method=t[0],this._url=t[1],n.apply(this,e)}},hookSetHeader=function(o){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._reqHeaders=this._reqHeaders||{};var r=__read(t,2),n=r[0],r=r[1];return this._reqHeaders[n]=r,o&&o.apply(this,t)}},hookOnreadystatechange=function(n,o){return hookMethodDangerously(n,"onreadystatechange",function(r){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 4===this.readyState&&o(n),r&&r.apply(this,t)}})},hookSend=function(n,o){var i=getReportPathRegExp();return function(){for(var t,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return this._start=now(),this._data=null==e?void 0:e[0],i(this._url)||(t=o([this._method,this._url,this._start,this]),hookOnreadystatechange(this,t)()),n.apply(this,e)}},applyXHR=function(n){return function(t,e){var r;n&&((r=[]).push(hookMethodDangerously(n,"open",hookOpen)()),r.push(hookMethodDangerously(n,"setRequestHeader",hookSetHeader)()),r.push(hookMethodDangerously(n,"send",hookSend)(t)),e(function(){r.forEach(function(t){return t()})}))}},FETCH_SUBJECT_NAME="fetch_0",hookFetch=function(n,o){return function(t,e){var r=o([t,e=void 0===e?{}:e]),e=n(t,e);return e.then(function(t){r(t)},function(){r(void 0)}),e}},observeFetch=function(t,e){var r,n=getDefaultBrowser();n&&fetch&&((r=[]).push(hookMethodDangerously(n,"fetch",hookFetch)(t)),e(function(){r.forEach(function(t){return t()})}))},fetchSubject=[FETCH_SUBJECT_NAME,observeFetch],RESOURCE_TYPE=["resource"],LONGTASK_TYPE=["longtask"],applyPerformanceObserver=function(e,o,r){var n=e&&new e(function(t,n){t.getEntries?t.getEntries().forEach(function(t,e,r){return o(t,e,r,n)}):r&&r()});return[function(t){if(!e||!n)return r&&r();try{n.observe({entryTypes:t})}catch(t){return r&&r()}},function(t){if(!e||!n)return r&&r();try{n.observe({type:t,buffered:!0})}catch(t){return r&&r()}n.observe({type:t,buffered:!1})},function(){return n&&n.disconnect()}]},observePerf=function(t,e,r){t=__read(applyPerformanceObserver(t,e),3),e=t[0],t=t[2];return e(r),t},LONGTASK_SUBJECT_NAME="longtask_0",observeLongtask=function(t,e){var r=getDefaultPerformanceObserver();r&&e(observePerf(r,t,LONGTASK_TYPE))},longtaskSubject=[LONGTASK_SUBJECT_NAME,observeLongtask],RESOURCE_SUBJECT_NAME="resource_0",observeResource=function(t,e){var r=getDefaultPerformanceObserver();r&&e(observePerf(r,t,RESOURCE_TYPE))},resourceSubject=[RESOURCE_SUBJECT_NAME,observeResource],JS_ERROR_EV_TYPE="js_error",HTTP_EV_TYPE="http",RESOURCE_EV_TYPE="resource",LONG_TASK_EV_TYPE="performance_longtask",ACTION_EV_TYPE="action",PAGE_ACTIVITY_DELAY=100,MAX_PAGE_ACTIVITY_DELAY=1e4,ROOT_TAGS=["BODY","HTML","HEAD"],waitActionComplete=function(t,e,r){function n(){r.clearTimeout(o),u&&(o=r.setTimeout(function(){t()},PAGE_ACTIVITY_DELAY))}var o,i,u=!1;return[function(){u=!0,r.clearTimeout(i),i=r.setTimeout(function(){t(),e()},MAX_PAGE_ACTIVITY_DELAY),n()},n,function(){u=!1,r.clearTimeout(o),r.clearTimeout(i)}]},getDomPath=function(t){var e=t,r=[];try{for(;null!==e.parentNode;){for(var n=0,o=0,i=0;i<e.parentNode.childNodes.length;i++){var u=e.parentNode.childNodes[i];u.nodeName===e.nodeName&&(u===e&&(o=n),n++)}e.hasAttribute("id")&&""!==e.id?r.unshift(e.nodeName+"#"+e.id):1<n?r.unshift(e.nodeName+":eq("+o+")"):r.unshift(e.nodeName),e=e.parentNode}return r.slice(1).join(">")}catch(t){return}},isSupportsElementClosest=function(){var t;return function(){return void 0===t?t="closest"in HTMLElement.prototype:t}}(),findElementWithAttributeByParents=function(t,e,r){void 0===r&&(r=10);for(var n=t,o=0;o<r&&n;o++){if(~ROOT_TAGS.indexOf(n.nodeName))return;if(n.hasAttribute(e))return n;n=n.parentElement}},getActionNameByAttribute=function(t,e){t=isSupportsElementClosest()?t.closest("["+e+"]"):findElementWithAttributeByParents(t,e);if(t)return t.getAttribute(e).trim()},getActionName=function(t,e){return getActionNameByAttribute(t,e)||t.innerText},SUPPORT_TYPES=["click"],EVENT_LISTENER_OPTIONS={capture:!0},MIN_LONG_TASK=50,DEFAULT_ATTR_NAME="data-apm-action",applyIncompleteReq=function(t,e,r){var n=__read(e,2),o=n[0],i=n[1],e=__read(applyRecord(),3),n=e[0],u=e[1],a=e[2],c=0;return t.push(o[0](function(t){__read(t,1)[0];var e=c+=1;return u(e,now()),r(),function(){a(e),r()}})),t.push(i[0](function(){var t=c+=1;return u(t,now()),r(),function(){a(t),r()}})),n},actionGetterWithFetchObserver=function(o,e,t,r){function n(t){var e;!l||!_&&!Object.keys(l.metrics).length||Object.keys(m).length&&!t||(l.metrics[LONG_TASK_EV_TYPE]&&(l.metrics[LONG_TASK_EV_TYPE].duration=E),e=0<h.length?Math.max.apply(Math,__spreadArray([],__read(h),!1))-Math.min.apply(Math,__spreadArray([],__read(h),!1)):0,l.metrics[HTTP_EV_TYPE]&&(l.metrics[HTTP_EV_TYPE].duration=e),t=T()-l.start_time,d&&d({ev_type:ACTION_EV_TYPE,payload:__assign(__assign({},l),{duration:t,frontend_time:t-e})}),i())}function i(){y(),l&&(p={start_time:l.start_time,id:l.id}),l=null,h=[],E=0}function u(t){l&&(l.metrics[t]={count:(null!==(t=null===(t=l.metrics[t])||void 0===t?void 0:t.count)&&void 0!==t?t:0)+1})}var a=__read(t,4),c=a[0],s=a[1],f=a[2],t=a[3],a=r.types,_=r.pure,l=null,p=null,d=void 0,h=[],E=0,T=__read(applyPerformance(performance),2)[1],r=__read(waitActionComplete(n,i,window),3),v=r[0],g=r[1],y=r[2],m=applyIncompleteReq(e,[c,s],g),c=__read(applyMutationObserver(MutationObserver,g),2),s=c[0],c=c[1];s(),e.push(c),e.push(y),e.push(f[0](function(t){var e=t.startTime,t=t.duration;g(),l&&l.start_time<=e+MIN_LONG_TASK&&(E+=t,u(LONG_TASK_EV_TYPE))})),e.push(t[0](function(t){var e=t.startTime,r=t.duration,t=t.initiatorType;g(),l&&l.start_time<e&&(["xmlhttprequest","fetch"].includes(t)&&(h.push(e,e+r),u(HTTP_EV_TYPE)),["xmlhttprequest","fetch","beacon"].includes(t)||u(RESOURCE_EV_TYPE))}));function A(t,e){var r=uuid(),n=__read(applyPerformance(performance),2)[1];l={start_time:n(),id:r,type:e,target:t,metrics:{}},d=o(),v()}function O(t){var e;n(!0),i(),t.target instanceof HTMLElement&&((e=getActionName(t.target,DEFAULT_ATTR_NAME))&&A({name:e,path:getDomPath(t.target)},t.type))}a&&a.forEach(function(t){arrayIncludes(SUPPORT_TYPES,t)&&(document.addEventListener(t,O,EVENT_LISTENER_OPTIONS),e.push(function(){return document.removeEventListener(t,O,EVENT_LISTENER_OPTIONS)}))});return[function(t){if(t.ev_type===HTTP_EV_TYPE)return(e=t.payload.response.timing&&t.payload.response.timing.startTime)?l&&e>l.start_time?l.id:p&&e>p.start_time?p.id:void 0:void 0;if(t.ev_type!==LONG_TASK_EV_TYPE)return l?(t.ev_type!==JS_ERROR_EV_TYPE&&t.ev_type!==RESOURCE_EV_TYPE||u(t.ev_type),l.id):void 0;var e=t.payload.longtasks.length&&t.payload.longtasks[0].startTime+MIN_LONG_TASK;return l&&e&&e>l.start_time?l.id:void 0},function(t,e){n(!0),i(),A({name:t},e)}]},ACTION_MONITOR_PLUGIN_NAME="action",defaultConfig={types:["click"]};function ActionMonitorBasePlugin(t,e){void 0===e&&(e=defaultConfig);var r,n,o=[],i=getDefaultDocument(),u=getDefaultBrowser();i&&u&&(e=__read(actionGetterWithFetchObserver(function(){return reportWithCurrentContext(t,!0)},o,[initSubjectInGlobal(t,[XHR_SUBJECT_NAME,applyXHR(XMLHttpRequest&&XMLHttpRequest.prototype)]),initSubjectInGlobal(t,fetchSubject),initSubjectInGlobal(t,longtaskSubject),initSubjectInGlobal(t,resourceSubject)],e),2),r=e[0],e=e[1],t.on("report",n=function(t){var e=r(t);return e&&t.extra&&(t.extra.action_id=e),t}),o.push(function(){t.off("report",n)}),t.provide("startAction",e),registerTearDownGroup(t,ACTION_MONITOR_PLUGIN_NAME,ACTION_EV_TYPE,o))}var ACTION_INTEGRATION_NAME=ACTION_MONITOR_PLUGIN_NAME,actionPlugin=function(e){return{name:ACTION_INTEGRATION_NAME,setup:function(t){ActionMonitorBasePlugin(t,e)}}};exports.ACTION_INTEGRATION_NAME=ACTION_INTEGRATION_NAME,exports.actionPlugin=actionPlugin; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __assign=function(){return(__assign=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function __read(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||0<e--)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u}function __spreadArray(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||((n=n||Array.prototype.slice.call(e,0,o))[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}var noop=function(){return{}};function isObject(t){return"object"==typeof t&&null!==t}var objProto=Object.prototype;function isArray(t){return"[object Array]"===objProto.toString.call(t)}function isFunction(t){return"function"==typeof t}function isString(t){return"string"==typeof t}function arrayIncludes(t,e){if(!isArray(t))return!1;if(0===t.length)return!1;for(var r=0;r<t.length;){if(t[r]===e)return!0;r++}return!1}var applyRecord=function(){var r={};return[r,function(t,e){return r[t]=e},function(t){return delete r[t]}]},hookMethodDangerously=function(i,u,a){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(!i)return noop;var r=i[u],n=a.apply(void 0,__spreadArray([r],__read(t),!1)),o=n;return isFunction(o)&&(o=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n.apply(this,t)}),i[u]=o,function(){o===i[u]?i[u]=r:n=r}}};function mathRNG(){for(var t=new Array(16),e=0,r=0;r<16;r++)0==(3&r)&&(e=4294967296*Math.random()),t[r]=e>>>((3&r)<<3)&255;return t}function bytesToUuid(t){for(var e=[],r=0;r<256;++r)e[r]=(r+256).toString(16).substr(1);var n=0,o=e;return[o[t[n++]],o[t[n++]],o[t[n++]],o[t[n++]],"-",o[t[n++]],o[t[n++]],"-",o[t[n++]],o[t[n++]],"-",o[t[n++]],o[t[n++]],"-",o[t[n++]],o[t[n++]],o[t[n++]],o[t[n++]],o[t[+n]],o[t[15]]].join("")}function uuid(){var t=mathRNG();return t[6]=15&t[6]|64,t[8]=63&t[8]|128,bytesToUuid(t)}var registerTearDownGroup=function(t,e,r,n){return t.destroyAgent.set(e,r,n)};function initSubjectInGlobal(t,e){return t.initSubject(e)}var now=function(){return Date.now()};function getDefaultBrowser(){if("object"==typeof window&&isObject(window))return window}function getDefaultDocument(){if("object"==typeof document&&isObject(document))return document}function getDefaultLocation(){return getDefaultBrowser()&&window.location}function getDefaultPerformanceObserver(){if(getDefaultBrowser()&&isFunction(window.PerformanceObserver))return window.PerformanceObserver}function getLocationUrl(){var t=getDefaultBrowser()&&getDefaultLocation();return null==t?void 0:t.href}var getViewOverrides=function(t){return{pid:t.pid,view_id:t.viewId,url:getLocationUrl()}},getOverrides=function(t){var e=t.config(),e=getViewOverrides(e);return e.context=t.context?t.context.toString():{},e},reportWithCurrentContext=function(e,t){void 0===t&&(t=!1);var r=getOverrides(e);return t&&(r.timestamp=now()),function(t){e.report(__assign(__assign({},t),{overrides:r}))}},applyMutationObserver=function(t,e){var r=t&&new t(e);return[function(t,e){r&&t&&r.observe(t,e)},function(){return r&&r.disconnect()}]},applyPerformance=function(r){var t=r&&r.timing||void 0;return[t,function(){return r&&r.now?r.now():(Date.now?Date.now():+new Date)-(t&&t.navigationStart||0)},function(t){var e=(r||{}).getEntriesByType;return isFunction(e)&&e.call(r,t)||[]},function(){var t=(r||{}).clearResourceTimings;isFunction(t)&&t.call(r)},function(t){var e=(r||{}).getEntriesByName;return isFunction(e)&&e.call(r,t)||[]}]},UNKNOWN_PATH="<unknown>";function htmlTreeAsString(t){try{for(var e,r=t,n=[],o=0,i=0,u=" > ".length;r&&o++<5&&!("html"===(e=_htmlElementAsString(r))||1<o&&256<=i+n.length*u+e.length);)n.push(e),i+=e.length,r=r.parentNode;return n.reverse().join(" > ")}catch(t){return UNKNOWN_PATH}}function _htmlElementAsString(t){var e,r,n,o=t,i=[];if(!o||!o.tagName)return"";i.push(o.tagName.toLowerCase()),o.id&&i.push("#"+o.id);t=o.className;if(t&&isString(t))for(e=t.split(/\s+/),a=0;a<e.length;a++)i.push("."+e[a]);for(var u=["type","name","title","alt"],a=0;a<u.length;a++)(n=o.getAttribute(r=u[a]))&&i.push("["+r+'="'+n+'"]');return i.join("")}var XHR_SUBJECT_NAME="xhr_0",getReportPathRegExp=function(){var e=new RegExp("\\/monitor_web\\/collect|\\/monitor_browser\\/collect\\/batch","i");return function(t){return e.test(t)}},hookOpen=function(n){return function(){for(var t,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return t=__read(e,2),this._method=t[0],this._url=t[1],n.apply(this,e)}},hookSetHeader=function(o){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._reqHeaders=this._reqHeaders||{};var r=__read(t,2),n=r[0],r=r[1];return this._reqHeaders[n]=r,o&&o.apply(this,t)}},hookOnreadystatechange=function(n,o){return hookMethodDangerously(n,"onreadystatechange",function(r){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 4===this.readyState&&o(n),r&&r.apply(this,t)}})},hookSend=function(n,o){var i=getReportPathRegExp();return function(){for(var t,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return this._start=now(),this._data=null==e?void 0:e[0],i(this._url)||(t=o([this._method,this._url,this._start,this]),hookOnreadystatechange(this,t)()),n.apply(this,e)}},applyXHR=function(n){return function(t,e){var r;n&&((r=[]).push(hookMethodDangerously(n,"open",hookOpen)()),r.push(hookMethodDangerously(n,"setRequestHeader",hookSetHeader)()),r.push(hookMethodDangerously(n,"send",hookSend)(t)),e(function(){r.forEach(function(t){return t()})}))}},FETCH_SUBJECT_NAME="fetch_0",hookFetch=function(n,o){return function(t,e){var r=o([t,e=void 0===e?{}:e]),e=n(t,e);return e.then(function(t){r(t)},function(){r(void 0)}),e}},observeFetch=function(t,e){var r,n=getDefaultBrowser();n&&fetch&&((r=[]).push(hookMethodDangerously(n,"fetch",hookFetch)(t)),e(function(){r.forEach(function(t){return t()})}))},fetchSubject=[FETCH_SUBJECT_NAME,observeFetch],RESOURCE_TYPE=["resource"],LONGTASK_TYPE=["longtask"],applyPerformanceObserver=function(e,o,r){var n=e&&new e(function(t,n){t.getEntries?t.getEntries().forEach(function(t,e,r){return o(t,e,r,n)}):r&&r()});return[function(t){if(!e||!n)return r&&r();try{n.observe({entryTypes:t})}catch(t){return r&&r()}},function(t){if(!e||!n)return r&&r();try{n.observe({type:t,buffered:!0})}catch(t){return r&&r()}n.observe({type:t,buffered:!1})},function(){return n&&n.disconnect()}]},observePerf=function(t,e,r){t=__read(applyPerformanceObserver(t,e),3),e=t[0],t=t[2];return e(r),t},LONGTASK_SUBJECT_NAME="longtask_0",observeLongtask=function(t,e){var r=getDefaultPerformanceObserver();r&&e(observePerf(r,t,LONGTASK_TYPE))},longtaskSubject=[LONGTASK_SUBJECT_NAME,observeLongtask],RESOURCE_SUBJECT_NAME="resource_0",observeResource=function(t,e){var r=getDefaultPerformanceObserver();r&&e(observePerf(r,t,RESOURCE_TYPE))},resourceSubject=[RESOURCE_SUBJECT_NAME,observeResource],PAGEVIEW_EV_TYPE="pageview",JS_ERROR_EV_TYPE="js_error",HTTP_EV_TYPE="http",RESOURCE_EV_TYPE="resource",LONG_TASK_EV_TYPE="performance_longtask",ACTION_EV_TYPE="action",PAGE_ACTIVITY_DELAY=100,MAX_PAGE_ACTIVITY_DELAY=1e4,ROOT_TAGS=["BODY","HTML","HEAD"],SVG_TAG="SVG",DEFAULT_ATTR_NAME="data-apm-action",waitActionComplete=function(t,e,r){function n(){r.clearTimeout(o),u&&(o=r.setTimeout(function(){t()},PAGE_ACTIVITY_DELAY))}var o,i,u=!1;return[function(){u=!0,r.clearTimeout(i),i=r.setTimeout(function(){t(),e()},MAX_PAGE_ACTIVITY_DELAY),n()},n,function(){u=!1,r.clearTimeout(o),r.clearTimeout(i)}]},isSupportsElementClosest=function(){var t;return function(){return void 0===t?t="closest"in HTMLElement.prototype:t}}(),findElementWithAttributeByParents=function(t,e,r){void 0===r&&(r=10);for(var n=t,o=0;o<r&&n;o++){if(~ROOT_TAGS.indexOf(n.nodeName))return;if(n.hasAttribute(e))return n;n=n.parentElement}},getActionNameByAttribute=function(t,e){t=isSupportsElementClosest()?t.closest("["+e+"]"):findElementWithAttributeByParents(t,e);if(t)return t.getAttribute(e).trim()},getActionName=function(t,e){return getActionNameByAttribute(t,e)||t.innerText},isSVGTarget=function(t){for(var e=t,r=!1;e;)e.tagName.toUpperCase()===SVG_TAG?r=!(e=null):e=e.parentElement;return r},isElementWithinTwoLevels=function(t){t=t.children;return!t.length||![].slice.call(t).some(function(t){return 0<t.children.length})},isValidTarget=function(t){var e=t.tagName.toUpperCase();return 1===t.nodeType&&!ROOT_TAGS.includes(e)&&!isSVGTarget(t)&&((!t.style||"none"!==t.style.display)&&(!(!["A","BUTTON","INPUT","TEXTAREA"].includes(e)&&!getActionNameByAttribute(t,DEFAULT_ATTR_NAME))||!!isElementWithinTwoLevels(t)))},SUPPORT_TYPES=["click"],EVENT_LISTENER_OPTIONS={capture:!0},MIN_LONG_TASK=50,applyIncompleteReq=function(t,e,r){var n=__read(e,2),o=n[0],i=n[1],e=__read(applyRecord(),3),n=e[0],u=e[1],a=e[2],c=0;return t.push(o[0](function(t){__read(t,1)[0];var e=c+=1;return u(e,now()),r(),function(){a(e),r()}})),t.push(i[0](function(){var t=c+=1;return u(t,now()),r(),function(){a(t),r()}})),n},actionGetterWithFetchObserver=function(o,e,t,r){function n(t){var e;!l||!_&&!Object.keys(l.metrics).length||Object.keys(m).length&&!t||(l.metrics[LONG_TASK_EV_TYPE]&&(l.metrics[LONG_TASK_EV_TYPE].duration=h),e=0<E.length?Math.max.apply(Math,__spreadArray([],__read(E),!1))-Math.min.apply(Math,__spreadArray([],__read(E),!1)):0,l.metrics[HTTP_EV_TYPE]&&(l.metrics[HTTP_EV_TYPE].duration=e),t=d()-l.start_time,T&&T({ev_type:ACTION_EV_TYPE,payload:__assign(__assign({},l),{duration:t,frontend_time:t-e})}),i())}function i(){A(),l&&(p={start_time:l.start_time,id:l.id}),l=null,E=[],h=0}function u(t){l&&(l.metrics[t]={count:(null!==(t=null===(t=l.metrics[t])||void 0===t?void 0:t.count)&&void 0!==t?t:0)+1})}var a=__read(t,4),c=a[0],s=a[1],f=a[2],t=a[3],a=r.types,_=r.pure,l=null,p=null,T=void 0,E=[],h=0,d=__read(applyPerformance(performance),2)[1],r=__read(waitActionComplete(n,i,window),3),v=r[0],g=r[1],A=r[2],m=applyIncompleteReq(e,[c,s],g),c=__read(applyMutationObserver(MutationObserver,g),2),s=c[0],c=c[1];s(),e.push(c),e.push(A),e.push(f[0](function(t){var e=t.startTime,t=t.duration;g(),l&&l.start_time<=e+MIN_LONG_TASK&&(h+=t,u(LONG_TASK_EV_TYPE))})),e.push(t[0](function(t){var e=t.startTime,r=t.duration,t=t.initiatorType;g(),l&&l.start_time<e&&(["xmlhttprequest","fetch"].includes(t)&&(E.push(e,e+r),u(HTTP_EV_TYPE)),["xmlhttprequest","fetch","beacon"].includes(t)||u(RESOURCE_EV_TYPE))}));function y(t,e){var r=uuid(),n=__read(applyPerformance(performance),2)[1];l={start_time:n(),id:r,type:e,target:t,metrics:{}},T=o(),v()}function O(t){var e;n(!0),i(),t.target instanceof HTMLElement&&isValidTarget(t.target)&&((e=getActionName(t.target,DEFAULT_ATTR_NAME))&&y({name:e,path:htmlTreeAsString(t.target)},t.type))}a&&a.forEach(function(t){arrayIncludes(SUPPORT_TYPES,t)&&(document.addEventListener(t,O,EVENT_LISTENER_OPTIONS),e.push(function(){return document.removeEventListener(t,O,EVENT_LISTENER_OPTIONS)}))});return[function(t){if(t.ev_type===PAGEVIEW_EV_TYPE)return n(!0),void i();if(t.ev_type===HTTP_EV_TYPE)return(e=t.payload.response.timing&&t.payload.response.timing.startTime)?l&&e>l.start_time?l.id:p&&e>p.start_time?p.id:void 0:void 0;if(t.ev_type!==LONG_TASK_EV_TYPE)return l?(t.ev_type!==JS_ERROR_EV_TYPE&&t.ev_type!==RESOURCE_EV_TYPE||u(t.ev_type),l.id):void 0;var e=t.payload.longtasks.length&&t.payload.longtasks[0].startTime+MIN_LONG_TASK;return l&&e&&e>l.start_time?l.id:void 0},function(t,e){n(!0),i(),y({name:t},e)}]},ACTION_MONITOR_PLUGIN_NAME="action",defaultConfig={types:["click"]};function ActionMonitorBasePlugin(t,e){void 0===e&&(e=defaultConfig);var r,n,o=[],i=getDefaultDocument(),u=getDefaultBrowser();i&&u&&(e=__read(actionGetterWithFetchObserver(function(){return reportWithCurrentContext(t,!0)},o,[initSubjectInGlobal(t,[XHR_SUBJECT_NAME,applyXHR(XMLHttpRequest&&XMLHttpRequest.prototype)]),initSubjectInGlobal(t,fetchSubject),initSubjectInGlobal(t,longtaskSubject),initSubjectInGlobal(t,resourceSubject)],e),2),r=e[0],e=e[1],t.on("report",n=function(t){var e=r(t);return e&&t.extra&&(t.extra.action_id=e),t}),o.push(function(){t.off("report",n)}),t.provide("startAction",e),registerTearDownGroup(t,ACTION_MONITOR_PLUGIN_NAME,ACTION_EV_TYPE,o))}var ACTION_INTEGRATION_NAME=ACTION_MONITOR_PLUGIN_NAME,actionPlugin=function(e){return{name:ACTION_INTEGRATION_NAME,setup:function(t){ActionMonitorBasePlugin(t,e)}}};exports.ACTION_INTEGRATION_NAME=ACTION_INTEGRATION_NAME,exports.actionPlugin=actionPlugin; |
@@ -259,2 +259,5 @@ interface ContextAgent { | ||
}; | ||
declare type WebTransport = SdkTransport & { | ||
useBeacon?: boolean; | ||
}; | ||
@@ -888,2 +891,3 @@ interface Common$1 { | ||
dedupe: boolean; | ||
gatherPath: boolean; | ||
}; | ||
@@ -1050,3 +1054,3 @@ | ||
integrations?: Integration<BrowserCommandClient>[] | ||
transport?: SdkTransport | ||
transport?: WebTransport | ||
storageExpires?: number | boolean // 只能初始化配置一次 | ||
@@ -1089,3 +1093,3 @@ plugins?: AjaxMonitorPluginConfig & | ||
integrations?: Integration<BrowserCommandClient>[] | ||
transport: SdkTransport | ||
transport: WebTransport | ||
} | ||
@@ -1092,0 +1096,0 @@ |
@@ -259,2 +259,5 @@ interface ContextAgent { | ||
}; | ||
declare type WebTransport = SdkTransport & { | ||
useBeacon?: boolean; | ||
}; | ||
@@ -888,2 +891,3 @@ interface Common$1 { | ||
dedupe: boolean; | ||
gatherPath: boolean; | ||
}; | ||
@@ -1050,3 +1054,3 @@ | ||
integrations?: Integration<BrowserCommandClient>[] | ||
transport?: SdkTransport | ||
transport?: WebTransport | ||
storageExpires?: number | boolean // 只能初始化配置一次 | ||
@@ -1089,3 +1093,3 @@ plugins?: AjaxMonitorPluginConfig & | ||
integrations?: Integration<BrowserCommandClient>[] | ||
transport: SdkTransport | ||
transport: WebTransport | ||
} | ||
@@ -1092,0 +1096,0 @@ |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __assign=function(){return(__assign=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e}).apply(this,arguments)};function __read(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,o,a=t.call(e),i=[];try{for(;(void 0===r||0<r--)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(t=a.return)&&t.call(a)}finally{if(o)throw o.error}}return i}function __spreadArray(e,r,t){if(t||2===arguments.length)for(var n,o=0,a=r.length;o<a;o++)!n&&o in r||((n=n||Array.prototype.slice.call(r,0,o))[o]=r[o]);return e.concat(n||Array.prototype.slice.call(r))}function id(e){return e}function isObject(e){return"object"==typeof e&&null!==e}function isString(e){return"string"==typeof e}var registerTearDownGroup=function(e,r,t,n){return e.destroyAgent.set(r,t,n)};function initSubjectInGlobal(e,r){return e.initSubject(r)}var now=function(){return Date.now()};function getDefaultDocument(){if("object"==typeof document&&isObject(document))return document}var UNKNOWN_PATH="<unknown>";function htmlTreeAsString(e){try{for(var r,t=e,n=[],o=0,a=0,i=" > ".length;t&&o++<5&&!("html"===(r=_htmlElementAsString(t))||1<o&&256<=a+n.length*i+r.length);)n.push(r),a+=r.length,t=t.parentNode;return n.reverse().join(" > ")}catch(e){return UNKNOWN_PATH}}function _htmlElementAsString(e){var r,t,n,o=e,a=[];if(!o||!o.tagName)return"";a.push(o.tagName.toLowerCase()),o.id&&a.push("#"+o.id);e=o.className;if(e&&isString(e))for(r=e.split(/\s+/),u=0;u<r.length;u++)a.push("."+r[u]);for(var i=["type","name","title","alt"],u=0;u<i.length;u++)(n=o.getAttribute(t=i[u]))&&a.push("["+t+'="'+n+'"]');return a.join("")}var applyDomAndKeyPress=function(o){function a(r,t){var n;return function(e){i=void 0,e&&n!==e&&t({event:n=e,name:r})}}var i;return[a,function(n){return function(e){var r;try{r=e.target}catch(e){return}var t=r&&r.tagName;t&&("INPUT"===t||"TEXTAREA"===t||r.isContentEditable)&&(i||a("input",n)(e),clearTimeout(i),i=window.setTimeout(function(){i=void 0},o))}}]},triggerHandlers=function(r,t){return function(e){if(t)try{r(e)}catch(e){}}},domBreadcrumb=function(t){return function(e){var r;try{r=e.event.target?htmlTreeAsString(e.event.target):htmlTreeAsString(e.event)}catch(e){r="<unknown>"}0!==r.length&&t({type:"dom",category:"ui."+e.name,message:r})}},getConfig=function(e,r){return isObject(e)?__assign(__assign({},r),e):!!e&&r},JS_ERROR_EV_TYPE="js_error",HTTP_EV_TYPE="http";function getPluginConfig(e,r,t){r=null===(e=e.config())||void 0===e?void 0:e.plugins[r];return getConfig(r,t)}var CLICK_EVENT_NAME="click",CLICK_SUBJECT_NAME=CLICK_EVENT_NAME+"_0",DOM_EVENT_TYPE="dom",observeClick=function(e,r){var t=getDefaultDocument();t&&(t.addEventListener(CLICK_EVENT_NAME,e,!0),r(function(){t.removeEventListener(CLICK_EVENT_NAME,e,!0)}))},clickSubject=[CLICK_SUBJECT_NAME,observeClick],KEYPRESS_EVENT_NAME="keypress",KEYPRESS_SUBJECT_NAME=KEYPRESS_EVENT_NAME+"_0",observeKeypress=function(e,r){var t=getDefaultDocument();t&&(t.addEventListener(KEYPRESS_EVENT_NAME,e,!0),r(function(){t.removeEventListener(KEYPRESS_EVENT_NAME,e,!0)}))},keypressSubject=[KEYPRESS_SUBJECT_NAME,observeKeypress],applyBreadcrumb=function(t,n,o){void 0===t&&(t=20),void 0===n&&(n=id),void 0===o&&(o=function(e,r){return e.slice(-r)});var a=[];return[function(){return a},function(e){var r=n(e);r&&(e=__assign(__assign({},r),{timestamp:e.timestamp||now()}),a=0<=t&&a.length+1>t?o(__spreadArray(__spreadArray([],__read(a),!1),[e],!1),t):__spreadArray(__spreadArray([],__read(a),!1),[e],!1))}]},breadcrumbGetterWithDomObserver=function(e,r,t){var n=__read(r,2),o=n[0],a=n[1],i=t.maxBreadcrumbs,u=t.onAddBreadcrumb,c=t.onMaxBreadcrumbs,r=t.dom,n=__read(applyDomAndKeyPress(100),2),t=n[0],n=n[1],u=__read(applyBreadcrumb(i,u,c),2),c=u[0],u=u[1];return r&&(r=domBreadcrumb(u),e.push(o[0](t(CLICK_EVENT_NAME,triggerHandlers(r,DOM_EVENT_TYPE)))),e.push(a[0](n(triggerHandlers(r,DOM_EVENT_TYPE))))),[c,u]},BREADCRUMB_MONITOR_PLUGIN_NAME="breadcrumb",defaultConfig={maxBreadcrumbs:20,dom:!0};function BreadcrumbMonitorPlugin(a){a.on("init",function(){var e,r,t,n,o=getPluginConfig(a,BREADCRUMB_MONITOR_PLUGIN_NAME,defaultConfig);o&&(o=(r=__read(breadcrumbGetterWithDomObserver(e=[],[initSubjectInGlobal(a,clickSubject),initSubjectInGlobal(a,keypressSubject)],o),2))[0],t=r[1],a.on("report",n=function(e){return e.ev_type===HTTP_EV_TYPE&&t({type:HTTP_EV_TYPE,category:e.payload.api,message:"",data:{method:e.payload.request.method,url:e.payload.request.url,status_code:String(e.payload.response.status)},timestamp:e.payload.request.timestamp}),e}),e.push(function(){a.off("report",n)}),registerTearDownGroup(a,BREADCRUMB_MONITOR_PLUGIN_NAME,JS_ERROR_EV_TYPE,e),a.provide("getBreadcrumbs",o),a.provide("addBreadcrumb",t))})}var BREADCRUMB_INTEGRATION_NAME=BREADCRUMB_MONITOR_PLUGIN_NAME,breadcrumbPlugin=function(){return{name:BREADCRUMB_INTEGRATION_NAME,setup:function(e){BreadcrumbMonitorPlugin(e)}}};exports.BREADCRUMB_INTEGRATION_NAME=BREADCRUMB_INTEGRATION_NAME,exports.breadcrumbPlugin=breadcrumbPlugin; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __assign=function(){return(__assign=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e}).apply(this,arguments)};function __read(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,o,a=t.call(e),i=[];try{for(;(void 0===r||0<r--)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(t=a.return)&&t.call(a)}finally{if(o)throw o.error}}return i}function __spreadArray(e,r,t){if(t||2===arguments.length)for(var n,o=0,a=r.length;o<a;o++)!n&&o in r||((n=n||Array.prototype.slice.call(r,0,o))[o]=r[o]);return e.concat(n||Array.prototype.slice.call(r))}function id(e){return e}function isObject(e){return"object"==typeof e&&null!==e}function isString(e){return"string"==typeof e}var registerTearDownGroup=function(e,r,t,n){return e.destroyAgent.set(r,t,n)};function initSubjectInGlobal(e,r){return e.initSubject(r)}var now=function(){return Date.now()};function getDefaultDocument(){if("object"==typeof document&&isObject(document))return document}var UNKNOWN_PATH="<unknown>";function htmlTreeAsString(e){try{for(var r,t=e,n=[],o=0,a=0,i=" > ".length;t&&o++<5&&!("html"===(r=_htmlElementAsString(t))||1<o&&256<=a+n.length*i+r.length);)n.push(r),a+=r.length,t=t.parentNode;return n.reverse().join(" > ")}catch(e){return UNKNOWN_PATH}}function _htmlElementAsString(e){var r,t,n,o=e,a=[];if(!o||!o.tagName)return"";a.push(o.tagName.toLowerCase()),o.id&&a.push("#"+o.id);e=o.className;if(e&&isString(e))for(r=e.split(/\s+/),u=0;u<r.length;u++)a.push("."+r[u]);for(var i=["type","name","title","alt"],u=0;u<i.length;u++)(n=o.getAttribute(t=i[u]))&&a.push("["+t+'="'+n+'"]');return a.join("")}var getConfig=function(e,r){return isObject(e)?__assign(__assign({},r),e):!!e&&r},JS_ERROR_EV_TYPE="js_error",HTTP_EV_TYPE="http";function getPluginConfig(e,r,t){r=null===(e=e.config())||void 0===e?void 0:e.plugins[r];return getConfig(r,t)}var CLICK_EVENT_NAME="click",CLICK_SUBJECT_NAME=CLICK_EVENT_NAME+"_0",DOM_EVENT_TYPE="dom",observeClick=function(e,r){var t=getDefaultDocument();t&&(t.addEventListener(CLICK_EVENT_NAME,e,!0),r(function(){t.removeEventListener(CLICK_EVENT_NAME,e,!0)}))},clickSubject=[CLICK_SUBJECT_NAME,observeClick],KEYPRESS_EVENT_NAME="keypress",KEYPRESS_SUBJECT_NAME=KEYPRESS_EVENT_NAME+"_0",observeKeypress=function(e,r){var t=getDefaultDocument();t&&(t.addEventListener(KEYPRESS_EVENT_NAME,e,!0),r(function(){t.removeEventListener(KEYPRESS_EVENT_NAME,e,!0)}))},keypressSubject=[KEYPRESS_SUBJECT_NAME,observeKeypress],domBreadcrumb=function(t){return function(e){var r;try{r=e.event.target?htmlTreeAsString(e.event.target):htmlTreeAsString(e.event)}catch(e){r=UNKNOWN_PATH}0!==r.length&&t({type:"dom",category:"ui."+e.name,message:r})}},triggerHandlers=function(r,t){return function(e){if(t)try{r(e)}catch(e){}}},applyDomAndKeyPress=function(o){function a(r,t){var n;return function(e){i=void 0,e&&n!==e&&t({event:n=e,name:r})}}var i;return[a,function(n){return function(e){var r;try{r=e.target}catch(e){return}var t=r&&r.tagName;t&&("INPUT"===t||"TEXTAREA"===t||r.isContentEditable)&&(i||a("input",n)(e),clearTimeout(i),i=window.setTimeout(function(){i=void 0},o))}}]},applyBreadcrumb=function(t,n,o){void 0===t&&(t=20),void 0===n&&(n=id),void 0===o&&(o=function(e,r){return e.slice(-r)});var a=[];return[function(){return a},function(e){var r=n(e);r&&(e=__assign(__assign({},r),{timestamp:e.timestamp||now()}),a=0<=t&&a.length+1>t?o(__spreadArray(__spreadArray([],__read(a),!1),[e],!1),t):__spreadArray(__spreadArray([],__read(a),!1),[e],!1))}]},breadcrumbGetterWithDomObserver=function(e,r,t){var n=__read(r,2),o=n[0],a=n[1],i=t.maxBreadcrumbs,u=t.onAddBreadcrumb,c=t.onMaxBreadcrumbs,r=t.dom,n=__read(applyDomAndKeyPress(100),2),t=n[0],n=n[1],u=__read(applyBreadcrumb(i,u,c),2),c=u[0],u=u[1];return r&&(r=domBreadcrumb(u),e.push(o[0](t(CLICK_EVENT_NAME,triggerHandlers(r,DOM_EVENT_TYPE)))),e.push(a[0](n(triggerHandlers(r,DOM_EVENT_TYPE))))),[c,u]},BREADCRUMB_MONITOR_PLUGIN_NAME="breadcrumb",defaultConfig={maxBreadcrumbs:20,dom:!0};function BreadcrumbMonitorPlugin(a){a.on("init",function(){var e,r,t,n,o=getPluginConfig(a,BREADCRUMB_MONITOR_PLUGIN_NAME,defaultConfig);o&&(o=(r=__read(breadcrumbGetterWithDomObserver(e=[],[initSubjectInGlobal(a,clickSubject),initSubjectInGlobal(a,keypressSubject)],o),2))[0],t=r[1],a.on("report",n=function(e){return e.ev_type===HTTP_EV_TYPE&&t({type:HTTP_EV_TYPE,category:e.payload.api,message:"",data:{method:e.payload.request.method,url:e.payload.request.url,status_code:String(e.payload.response.status)},timestamp:e.payload.request.timestamp}),e}),e.push(function(){a.off("report",n)}),registerTearDownGroup(a,BREADCRUMB_MONITOR_PLUGIN_NAME,JS_ERROR_EV_TYPE,e),a.provide("getBreadcrumbs",o),a.provide("addBreadcrumb",t))})}var BREADCRUMB_INTEGRATION_NAME=BREADCRUMB_MONITOR_PLUGIN_NAME,breadcrumbPlugin=function(){return{name:BREADCRUMB_INTEGRATION_NAME,setup:function(e){BreadcrumbMonitorPlugin(e)}}};exports.BREADCRUMB_INTEGRATION_NAME=BREADCRUMB_INTEGRATION_NAME,exports.breadcrumbPlugin=breadcrumbPlugin; |
@@ -259,2 +259,5 @@ interface ContextAgent { | ||
}; | ||
declare type WebTransport = SdkTransport & { | ||
useBeacon?: boolean; | ||
}; | ||
@@ -888,2 +891,3 @@ interface Common$1 { | ||
dedupe: boolean; | ||
gatherPath: boolean; | ||
}; | ||
@@ -1050,3 +1054,3 @@ | ||
integrations?: Integration<BrowserCommandClient>[] | ||
transport?: SdkTransport | ||
transport?: WebTransport | ||
storageExpires?: number | boolean // 只能初始化配置一次 | ||
@@ -1089,3 +1093,3 @@ plugins?: AjaxMonitorPluginConfig & | ||
integrations?: Integration<BrowserCommandClient>[] | ||
transport: SdkTransport | ||
transport: WebTransport | ||
} | ||
@@ -1092,0 +1096,0 @@ |
@@ -259,2 +259,5 @@ interface ContextAgent { | ||
}; | ||
declare type WebTransport = SdkTransport & { | ||
useBeacon?: boolean; | ||
}; | ||
@@ -888,2 +891,3 @@ interface Common$1 { | ||
dedupe: boolean; | ||
gatherPath: boolean; | ||
}; | ||
@@ -1050,3 +1054,3 @@ | ||
integrations?: Integration<BrowserCommandClient>[] | ||
transport?: SdkTransport | ||
transport?: WebTransport | ||
storageExpires?: number | boolean // 只能初始化配置一次 | ||
@@ -1089,3 +1093,3 @@ plugins?: AjaxMonitorPluginConfig & | ||
integrations?: Integration<BrowserCommandClient>[] | ||
transport: SdkTransport | ||
transport: WebTransport | ||
} | ||
@@ -1092,0 +1096,0 @@ |
@@ -259,2 +259,5 @@ interface ContextAgent { | ||
}; | ||
declare type WebTransport = SdkTransport & { | ||
useBeacon?: boolean; | ||
}; | ||
@@ -888,2 +891,3 @@ interface Common$1 { | ||
dedupe: boolean; | ||
gatherPath: boolean; | ||
}; | ||
@@ -1050,3 +1054,3 @@ | ||
integrations?: Integration<BrowserCommandClient>[] | ||
transport?: SdkTransport | ||
transport?: WebTransport | ||
storageExpires?: number | boolean // 只能初始化配置一次 | ||
@@ -1089,3 +1093,3 @@ plugins?: AjaxMonitorPluginConfig & | ||
integrations?: Integration<BrowserCommandClient>[] | ||
transport: SdkTransport | ||
transport: WebTransport | ||
} | ||
@@ -1092,0 +1096,0 @@ |
@@ -618,2 +618,83 @@ /*! ***************************************************************************** | ||
/** | ||
* from sentry https://github.com/getsentry/sentry-javascript/blob/5.30.0/packages/utils/src/browser.ts | ||
*/ | ||
var UNKNOWN_PATH = '<unknown>'; | ||
/** | ||
* Given a child DOM element, returns a query-selector statement describing that | ||
* and its ancestors | ||
* e.g. [HTMLElement] => body > div > input#foo.btn[name=baz] | ||
* @returns generated DOM path | ||
*/ | ||
function htmlTreeAsString(elem) { | ||
// try/catch both: | ||
// - accessing event.target (see getsentry/raven-js#838, #768) | ||
// - `htmlTreeAsString` because it's complex, and just accessing the DOM incorrectly | ||
// - can throw an exception in some circumstances. | ||
try { | ||
var currentElem = elem; | ||
var MAX_TRAVERSE_HEIGHT = 5; | ||
var MAX_OUTPUT_LEN = 256; // be matched with the filtering rules of data reporting | ||
var out = []; | ||
var height = 0; | ||
var len = 0; | ||
var separator = ' > '; | ||
var sepLength = separator.length; | ||
var nextStr = void 0; | ||
while (currentElem && height++ < MAX_TRAVERSE_HEIGHT) { | ||
nextStr = _htmlElementAsString(currentElem); | ||
// bail out if | ||
// - nextStr is the 'html' element | ||
// - the length of the string that would be created exceeds MAX_OUTPUT_LEN | ||
// (ignore this limit if we are on the first iteration) | ||
if (nextStr === 'html' || (height > 1 && len + out.length * sepLength + nextStr.length >= MAX_OUTPUT_LEN)) { | ||
break; | ||
} | ||
out.push(nextStr); | ||
len += nextStr.length; | ||
currentElem = currentElem.parentNode; | ||
} | ||
return out.reverse().join(separator); | ||
} | ||
catch (_oO) { | ||
return UNKNOWN_PATH; | ||
} | ||
} | ||
/** | ||
* Returns a simple, query-selector representation of a DOM element | ||
* e.g. [HTMLElement] => input#foo.btn[name=baz] | ||
* @returns generated DOM path | ||
*/ | ||
function _htmlElementAsString(el) { | ||
var elem = el; | ||
var out = []; | ||
var classes; | ||
var key; | ||
var attr; | ||
var i; | ||
if (!elem || !elem.tagName) { | ||
return ''; | ||
} | ||
out.push(elem.tagName.toLowerCase()); | ||
if (elem.id) { | ||
out.push("#" + elem.id); | ||
} | ||
var className = elem.className; | ||
if (className && isString(className)) { | ||
classes = className.split(/\s+/); | ||
for (i = 0; i < classes.length; i++) { | ||
out.push("." + classes[i]); | ||
} | ||
} | ||
var attrlist = ['type', 'name', 'title', 'alt']; | ||
for (i = 0; i < attrlist.length; i++) { | ||
key = attrlist[i]; | ||
attr = elem.getAttribute(key); | ||
if (attr) { | ||
out.push("[" + key + "=\"" + attr + "\"]"); | ||
} | ||
} | ||
return out.join(''); | ||
} | ||
var getConfig = function (c, defaultConfig) { | ||
@@ -785,2 +866,3 @@ if (isObject(c)) { | ||
var PAGEVIEW_EV_TYPE = 'pageview'; | ||
var JS_ERROR_EV_TYPE = 'js_error'; | ||
@@ -799,2 +881,15 @@ var HTTP_EV_TYPE = 'http'; | ||
var CLICK_EVENT_NAME = 'click'; | ||
var CLICK_SUBJECT_NAME = CLICK_EVENT_NAME + "_0"; | ||
var observeClick = function (next, tearDown) { | ||
var document = getDefaultDocument(); | ||
if (!document) | ||
return; | ||
document.addEventListener(CLICK_EVENT_NAME, next, true); | ||
tearDown(function () { | ||
document.removeEventListener(CLICK_EVENT_NAME, next, true); | ||
}); | ||
}; | ||
var clickSubject = [CLICK_SUBJECT_NAME, observeClick]; | ||
var ERROR_FIELDS = ['name', 'message', 'stack', 'filename', 'lineno', 'colno']; | ||
@@ -1140,2 +1235,4 @@ var normalize = function (ex) { | ||
var ROOT_TAGS = ['BODY', 'HTML', 'HEAD']; | ||
var SVG_TAG = 'SVG'; | ||
var DEFAULT_ATTR_NAME = 'data-apm-action'; | ||
/** | ||
@@ -1172,40 +1269,2 @@ * 控制等待策略和强制结算 | ||
}; | ||
/** | ||
* 从target中获取path | ||
*/ | ||
var getDomPath = function (element) { | ||
var el = element; | ||
var stack = []; | ||
try { | ||
while (el.parentNode !== null) { | ||
var sibCount = 0; | ||
var sibIndex = 0; | ||
// eslint-disable-next-line @typescript-eslint/prefer-for-of | ||
for (var i = 0; i < el.parentNode.childNodes.length; i++) { | ||
var sib = el.parentNode.childNodes[i]; | ||
if (sib.nodeName === el.nodeName) { | ||
if (sib === el) { | ||
sibIndex = sibCount; | ||
} | ||
sibCount++; | ||
} | ||
} | ||
if (el.hasAttribute('id') && el.id !== '') { | ||
stack.unshift(el.nodeName + '#' + el.id); | ||
} | ||
else if (sibCount > 1) { | ||
stack.unshift(el.nodeName + ':eq(' + sibIndex + ')'); | ||
} | ||
else { | ||
stack.unshift(el.nodeName); | ||
} | ||
el = el.parentNode; | ||
} | ||
// removes the html element | ||
return stack.slice(1).join('>'); | ||
} | ||
catch (_a) { | ||
return; | ||
} | ||
}; | ||
var isSupportsElementClosest = (function () { | ||
@@ -1248,2 +1307,40 @@ var supportsElementClosest; | ||
}; | ||
var isSVGTarget = function (element) { | ||
var current = element; | ||
var flag = false; | ||
while (current) { | ||
if (current.tagName.toUpperCase() === SVG_TAG) { | ||
current = null; | ||
flag = true; | ||
} | ||
else { | ||
current = current.parentElement; | ||
} | ||
} | ||
return flag; | ||
}; | ||
var isElementWithinTwoLevels = function (element) { | ||
var childElement = element.children; | ||
return childElement.length ? ![].slice.call(childElement).some(function (c) { return c.children.length > 0; }) : true; | ||
}; | ||
var isValidTarget = function (element) { | ||
// if not element node or is root element or is svg | ||
var tagName = element.tagName.toUpperCase(); | ||
if (element.nodeType !== 1 || ROOT_TAGS.includes(tagName) || isSVGTarget(element)) { | ||
return false; | ||
} | ||
// if element display none | ||
if (element.style && element.style.display === 'none') { | ||
return false; | ||
} | ||
// if is allowed TagName or has special attribute | ||
if (['A', 'BUTTON', 'INPUT', 'TEXTAREA'].includes(tagName) || getActionNameByAttribute(element, DEFAULT_ATTR_NAME)) { | ||
return true; | ||
} | ||
// if element not within two levels | ||
if (!isElementWithinTwoLevels(element)) { | ||
return false; | ||
} | ||
return true; | ||
}; | ||
@@ -1253,3 +1350,2 @@ var SUPPORT_TYPES = ["click" /* CLICK */]; | ||
var MIN_LONG_TASK = 50; | ||
var DEFAULT_ATTR_NAME = 'data-apm-action'; | ||
/** | ||
@@ -1373,2 +1469,8 @@ * Hook XHR & fetch to monitor the number of incomplete requests on the current page. | ||
var applyOtherReport = function (ev) { | ||
// if there is a new Page View, forcefully settle the current action | ||
if (ev.ev_type === PAGEVIEW_EV_TYPE) { | ||
reportActionIfAllowed(true); | ||
resetAction(); | ||
return; | ||
} | ||
// because http needs to wait timing so http event belongs to the delay-type events, need special correction. | ||
@@ -1423,3 +1525,3 @@ if (ev.ev_type === HTTP_EV_TYPE) { | ||
resetAction(); | ||
if (!(e.target instanceof HTMLElement)) { | ||
if (!(e.target instanceof HTMLElement) || !isValidTarget(e.target)) { | ||
return; | ||
@@ -1431,3 +1533,3 @@ } | ||
} | ||
initAction({ name: name, path: getDomPath(e.target) }, e.type); | ||
initAction({ name: name, path: htmlTreeAsString(e.target) }, e.type); | ||
}; | ||
@@ -1481,3 +1583,3 @@ types && | ||
var getSPA = function (report, tearDownGroup, _a) { | ||
var _b = __read(_a, 6), pvObserver = _b[0], xhrObserver = _b[1], fetchObserver = _b[2], resourceObserver = _b[3], longtaskObserver = _b[4], MutationObserver = _b[5]; | ||
var _b = __read(_a, 7), pvObserver = _b[0], clickObserver = _b[1], xhrObserver = _b[2], fetchObserver = _b[3], resourceObserver = _b[4], longtaskObserver = _b[5], MutationObserver = _b[6]; | ||
var spa_load_start = 0; | ||
@@ -1530,2 +1632,9 @@ var reportMetric = applyReportMetric(report); | ||
})); | ||
// force report last SPA and clear status when the click is triggered | ||
tearDownGroup.push(clickObserver[0](function () { | ||
// force report last SPA | ||
reportSPAIfAllowed(true); | ||
// clear status | ||
endSPA(); | ||
})); | ||
// reset SPA status when tear down | ||
@@ -1544,2 +1653,3 @@ tearDownGroup.push(endSPA); | ||
initPrivateSubject(client, [PV_SUBJECT_NAME, applyPV(client)]), | ||
initSubjectInGlobal(client, clickSubject), | ||
initSubjectInGlobal(client, [XHR_SUBJECT_NAME, applyXHR(XMLHttpRequest && XMLHttpRequest.prototype)]), | ||
@@ -1546,0 +1656,0 @@ initSubjectInGlobal(client, fetchSubject), |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __assign=function(){return(__assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function __read(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),u=[];try{for(;(void 0===t||0<t--)&&!(n=i.next()).done;)u.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u}function __spreadArray(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||((n=n||Array.prototype.slice.call(t,0,o))[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}var REFRESH_PRE_START_CONTEXT_INTEGRATION_NAME="refreshPreStartContext",refreshPreStartContext=function(){return{name:REFRESH_PRE_START_CONTEXT_INTEGRATION_NAME,setup:function(n){n.on("start",function(){var r=n.getPreStartQueue();r.forEach(function(e,t){r[t]=__assign(__assign({},e),{overrides:__assign(__assign({},null!==(e=e.overrides)&&void 0!==e?e:{}),{context:(null===(e=n.context)||void 0===e?void 0:e.toString())||{}})})})})}}},noop=function(){return{}};function isObject(e){return"object"==typeof e&&null!==e}function isInstanceOf(e,t){try{return e instanceof t}catch(e){return!1}}var objProto=Object.prototype;function isPlainObject(e){if(isObject(e)){if("function"!=typeof Object.getPrototypeOf)return"[object Object]"===objProto.toString.call(e);e=Object.getPrototypeOf(e);return e===objProto||null===e}return!1}function isArray(e){return"[object Array]"===objProto.toString.call(e)}function isFunction(e){return"function"==typeof e}function isString(e){return"string"==typeof e}function isError(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMError]":case"[object DOMException]":return!0;default:return e instanceof Error}}function isEvent(e){return"undefined"!=typeof Event&&isInstanceOf(e,Event)}function isErrorEvent(e){return"[object ErrorEvent]"===Object.prototype.toString.call(e)}function isPromiseRejectionEvent(e){return"[object PromiseRejectionEvent]"===Object.prototype.toString.call(e)}function arrayIncludes(e,t){if(!isArray(e))return!1;if(0===e.length)return!1;for(var r=0;r<e.length;){if(e[r]===t)return!0;r++}return!1}var arrayRemove=function(e,t){if(!isArray(e))return e;var r=e.indexOf(t);if(0<=r){t=e.slice();return t.splice(r,1),t}return e},applyRecord=function(){var r={};return[r,function(e,t){return r[e]=t},function(e){return delete r[e]}]},pick=function(r,e){return r&&isObject(r)?e.reduce(function(e,t){return e[t]=r[t],e},{}):r};function getRegexp(e){return isArray(e)&&e.length?joinRegExp(e):null}function joinRegExp(e){for(var t=[],r=e.length,n=0;n<r;n++){var o=e[n];isString(o)?t.push(o.replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")):o&&o.source&&t.push(o.source)}return new RegExp(t.join("|"),"i")}function safeStringify(e){try{return isString(e)?e:JSON.stringify(e)}catch(e){return"[FAILED_TO_STRINGIFY]:"+String(e)}}function safeJoin(e,t){if(!isArray(e))return"";for(var r=[],n=0;n<e.length;n++)try{r.push(String(e[n]))}catch(e){r.push("[value cannot be serialized]")}return r.join(t)}var hookObjectProperty=function(i,u,a,c){return void 0===c&&(c=!0),function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(!i)return noop;var r=i[u],n=a.apply(void 0,__spreadArray([r],__read(e),!1)),o=n;return isFunction(o)&&c&&(o=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{return n.apply(this,t)}catch(e){return isFunction(r)&&r.apply(this,t)}}),i[u]=o,function(e){e||(o===i[u]?i[u]=r:n=r)}}},hookMethodDangerously=function(i,u,a){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(!i)return noop;var r=i[u],n=a.apply(void 0,__spreadArray([r],__read(e),!1)),o=n;return isFunction(o)&&(o=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.apply(this,e)}),i[u]=o,function(){o===i[u]?i[u]=r:n=r}}};function mathRNG(){for(var e=new Array(16),t=0,r=0;r<16;r++)0==(3&r)&&(t=4294967296*Math.random()),e[r]=t>>>((3&r)<<3)&255;return e}function bytesToUuid(e){for(var t=[],r=0;r<256;++r)t[r]=(r+256).toString(16).substr(1);var n=0,o=t;return[o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],o[e[+n]],o[e[15]]].join("")}function uuid(){var e=mathRNG();return e[6]=15&e[6]|64,e[8]=63&e[8]|128,bytesToUuid(e)}var BUFFER_TIME=3e5,applyBufferTimer=function(e,t,r){var n=0;return-1===r?noop:function(){if(e())return n&&clearTimeout(n),void(n=0);0===n&&(n=setTimeout(t,r))}},nextLink=function(n,e){var t=[];try{t=e.reduce(function(e,t){try{var r=t(n);"function"==typeof r&&e.push(r)}catch(e){}return e},[])}catch(e){}return function(e){return nextLink(e,t)}},toObservable=function(e){function t(e){n=arrayRemove(n,e),i||u()}var r,n=[],o=[],i=!1,u=applyBufferTimer(function(){return!!n.length},function(){i=!0,r&&r[0](),o.forEach(function(e){return e()}),o.length=0,r=void 0},e=void 0===e?BUFFER_TIME:e);return{next:function(e){return nextLink(e,n)},complete:function(e){o.push(e)},attach:function(e,t){r=[e,t]},subscribe:function(e){if(i)throw new Error("Observer is closed");return n.push(e),r&&r[1]&&r[1](e),u(),function(){return t(e)}},unsubscribe:t}},createSafeObserver=function(e,t,r){r=toObservable(r);try{e(r.next,r.attach),t&&r.complete(t)}catch(e){}return[r.subscribe,r.unsubscribe]},registerTearDownGroup=function(e,t,r,n){return e.destroyAgent.set(t,r,n)};function initSubjectInGlobal(e,t){return e.initSubject(t)}function initPrivateSubject(e,t,r){var t=__read(t,2),n=t[0],t=t[1],o=e.privateSubject||{};return o[n]||(o[n]=createSafeObserver(t,function(){o[n]=void 0},r)),o[n]}var now=function(){return Date.now()};function getDefaultBrowser(){if("object"==typeof window&&isObject(window))return window}function getDefaultDocument(){if("object"==typeof document&&isObject(document))return document}function getDefaultLocation(){return getDefaultBrowser()&&window.location}function getDefaultXMLHttpRequest(){if("function"==typeof XMLHttpRequest&&isFunction(XMLHttpRequest))return XMLHttpRequest}function getDefaultMutationObserver(){if(getDefaultBrowser()&&isFunction(window.MutationObserver))return window.MutationObserver}function getDefaultPerformanceObserver(){if(getDefaultBrowser()&&isFunction(window.PerformanceObserver))return window.PerformanceObserver}function getLocationUrl(){var e=getDefaultBrowser()&&getDefaultLocation();return null==e?void 0:e.href}var getViewOverrides=function(e){return{pid:e.pid,view_id:e.viewId,url:getLocationUrl()}},getOverrides=function(e){var t=e.config(),t=getViewOverrides(t);return t.context=e.context?e.context.toString():{},t},reportWithCurrentContext=function(t,e){void 0===e&&(e=!1);var r=getOverrides(t);return e&&(r.timestamp=now()),function(e){t.report(__assign(__assign({},e),{overrides:r}))}},PV_SUBJECT_NAME="view_0",applyPV=function(o){return function(r,e){function t(e){var t;e.viewId&&e.viewId!==(null===(t=o.config())||void 0===t?void 0:t.viewId)&&(r(n),n=__assign(__assign({},getOverrides(o)),getViewOverrides(e)))}var n=getOverrides(o);o.on("beforeConfig",t),e(function(){o.off("beforeConfig",t)})}},getGlobalRegistry=function(e){if(e)return e.__SLARDAR_REGISTRY__||(e.__SLARDAR_REGISTRY__={Slardar:{plugins:[],errors:[],subject:{}}}),e.__SLARDAR_REGISTRY__.Slardar},reportSelfError=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=getGlobalRegistry(getDefaultBrowser());r&&(r.errors||(r.errors=[]),r.errors.push(e))},applyMutationObserver=function(e,t){var r=e&&new e(t);return[function(e,t){r&&e&&r.observe(e,t)},function(){return r&&r.disconnect()}]},applyPerformance=function(r){var e=r&&r.timing||void 0;return[e,function(){return r&&r.now?r.now():(Date.now?Date.now():+new Date)-(e&&e.navigationStart||0)},function(e){var t=(r||{}).getEntriesByType;return isFunction(t)&&t.call(r,e)||[]},function(){var e=(r||{}).clearResourceTimings;isFunction(e)&&e.call(r)},function(e){var t=(r||{}).getEntriesByName;return isFunction(t)&&t.call(r,e)||[]}]},getConfig=function(e,t){return isObject(e)?__assign(__assign({},t),e):!!e&&t},XHR_SUBJECT_NAME="xhr_0",getReportPathRegExp=function(){var t=new RegExp("\\/monitor_web\\/collect|\\/monitor_browser\\/collect\\/batch","i");return function(e){return t.test(e)}},hookOpen=function(n){return function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e=__read(t,2),this._method=e[0],this._url=e[1],n.apply(this,t)}},hookSetHeader=function(o){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._reqHeaders=this._reqHeaders||{};var r=__read(e,2),n=r[0],r=r[1];return this._reqHeaders[n]=r,o&&o.apply(this,e)}},hookOnreadystatechange=function(n,o){return hookMethodDangerously(n,"onreadystatechange",function(r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 4===this.readyState&&o(n),r&&r.apply(this,e)}})},hookSend=function(n,o){var i=getReportPathRegExp();return function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return this._start=now(),this._data=null==t?void 0:t[0],i(this._url)||(e=o([this._method,this._url,this._start,this]),hookOnreadystatechange(this,e)()),n.apply(this,t)}},applyXHR=function(n){return function(e,t){var r;n&&((r=[]).push(hookMethodDangerously(n,"open",hookOpen)()),r.push(hookMethodDangerously(n,"setRequestHeader",hookSetHeader)()),r.push(hookMethodDangerously(n,"send",hookSend)(e)),t(function(){r.forEach(function(e){return e()})}))}},FETCH_SUBJECT_NAME="fetch_0",hookFetch=function(n,o){return function(e,t){var r=o([e,t=void 0===t?{}:t]),t=n(e,t);return t.then(function(e){r(e)},function(){r(void 0)}),t}},observeFetch=function(e,t){var r,n=getDefaultBrowser();n&&fetch&&((r=[]).push(hookMethodDangerously(n,"fetch",hookFetch)(e)),t(function(){r.forEach(function(e){return e()})}))},fetchSubject=[FETCH_SUBJECT_NAME,observeFetch],RESOURCE_TYPE=["resource"],LONGTASK_TYPE=["longtask"],applyPerformanceObserver=function(t,o,r){var n=t&&new t(function(e,n){e.getEntries?e.getEntries().forEach(function(e,t,r){return o(e,t,r,n)}):r&&r()});return[function(e){if(!t||!n)return r&&r();try{n.observe({entryTypes:e})}catch(e){return r&&r()}},function(e){if(!t||!n)return r&&r();try{n.observe({type:e,buffered:!0})}catch(e){return r&&r()}n.observe({type:e,buffered:!1})},function(){return n&&n.disconnect()}]},observePerf=function(e,t,r){e=__read(applyPerformanceObserver(e,t),3),t=e[0],e=e[2];return t(r),e},LONGTASK_SUBJECT_NAME="longtask_0",observeLongtask=function(e,t){var r=getDefaultPerformanceObserver();r&&t(observePerf(r,e,LONGTASK_TYPE))},longtaskSubject=[LONGTASK_SUBJECT_NAME,observeLongtask],RESOURCE_SUBJECT_NAME="resource_0",observeResource=function(e,t){var r=getDefaultPerformanceObserver();r&&t(observePerf(r,e,RESOURCE_TYPE))},resourceSubject=[RESOURCE_SUBJECT_NAME,observeResource],JS_ERROR_EV_TYPE="js_error",HTTP_EV_TYPE="http",RESOURCE_EV_TYPE="resource",PERFORMANCE_METRIC_EV_TYPE="performance",LONG_TASK_EV_TYPE="performance_longtask",ACTION_EV_TYPE="action";function getPluginConfig(e,t,r){t=null===(e=e.config())||void 0===e?void 0:e.plugins[t];return getConfig(t,r)}var ERROR_FIELDS=["name","message","stack","filename","lineno","colno"],normalize=function(e){var t;return isError(e)?t=pick(e,ERROR_FIELDS):(isPlainObject(e)||isEvent(e)||isString(e))&&(t={message:safeStringify(e)}),t},normalizeError=function(e){return normalize(e.error)},normalizeException=function(e){var t;try{var r=void 0;if("reason"in e?r=e.reason:"detail"in e&&"reason"in e.detail&&(r=e.detail.reason),r){var n=normalize(r);return __assign(__assign({},n),{name:null!==(t=n&&n.name)&&void 0!==t?t:"UnhandledRejection"})}}catch(e){}},normalizeUnknownError=function(e){return(isErrorEvent(e)?normalizeError:isPromiseRejectionEvent(e)?normalizeException:normalize)(e)},DEFAULT_EVENT_TARGET=["EventTarget","Window","Node","ApplicationCache","ChannelMergerNode","EventSource","FileReader","HTMLUnknownElement","IDBDatabase","IDBRequest","IDBTransaction","MessagePort","Notification","SVGElementInstance","Screen","TextTrack","TextTrackCue","TextTrackList","WebSocket","Worker","XMLHttpRequest","XMLHttpRequestEventTarget","XMLHttpRequestUpload"],DEFAULT_TIME_FUNCTION=["setTimeout","setInterval","requestAnimationFrame","requestIdleCallback"],xmlHttpRequestProps=["onload","onerror","onprogress","onreadystatechange"],ADD_EVENT_LISTENER="addEventListener",REMOVE_EVENT_LISTENER="removeEventListener",DEFAULT_SOURCE_TYPE="capture-global",observeAsyncErrorWithSource=function(o,e){function u(e,r){if(!isFunction(e))return e;var n={type:DEFAULT_SOURCE_TYPE,data:__assign({},r)},t=e._w_||(e._w_=function(){try{return(e.handleEvent&&isFunction(e.handleEvent)?e.handleEvent:e).apply(this,[].map.call(arguments,function(e){return u(e,r)}))}catch(e){var t=normalize(e);throw t&&o({source:n,error:t}),e}});return t._hook_=!0,t}var t=getDefaultBrowser(),r=getDefaultXMLHttpRequest(),n=[];t&&n.push.apply(n,__spreadArray([],__read(DEFAULT_TIME_FUNCTION.filter(function(e){return t[e]}).map(function(o){return hookObjectProperty(t,o,function(n){return function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return n&&n.call.apply(n,__spreadArray([this,u(e,{function:o})],__read(t),!1))}},!1)()})),!1)),r&&r.prototype&&n.push(hookObjectProperty(r.prototype,"send",function(n){return function(){for(var t=this,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return xmlHttpRequestProps.filter(function(e){return t[e]&&!t[e]._hook_}).forEach(function(e){t[e]=u(t[e],{function:e})}),n.apply(this,e)}},!1)()),DEFAULT_EVENT_TARGET.forEach(function(i){var e=t&&t[i]&&t[i].prototype;e&&e[ADD_EVENT_LISTENER]&&(n.push(hookObjectProperty(e,ADD_EVENT_LISTENER,function(o){return function(e,t,r){try{var n=t.handleEvent;isFunction(n)&&(t.handleEvent=u(n,{function:"handleEvent",target:i}))}catch(e){}return o&&o.call(this,e,u(t,{function:ADD_EVENT_LISTENER,target:i}),r)}},!1)()),n.push(hookObjectProperty(e,REMOVE_EVENT_LISTENER,function(n){return function(e,t,r){return null!=t&&t._w_&&n.call(this,e,t._w_,r),n.call(this,e,t,r)}},!1)()))}),e(function(){return n.forEach(function(e){return e()})})},ASYNC_ERROR_SUBJECT_NAME="async_error_0",asyncErrorWithSourceSubject=[ASYNC_ERROR_SUBJECT_NAME,observeAsyncErrorWithSource],ERROR_SUBJECT_NAME="err_0",observeError=function(e,t){var r=getDefaultBrowser();r&&(r.addEventListener("error",e,!0),t(function(){r.removeEventListener("error",e,!0)}))},errorSubject=[ERROR_SUBJECT_NAME,observeError],PROMISE_REJECTION_SUBJECT_NAME="perr_0",observePromiseRejection=function(e,t){var r=getDefaultBrowser();r&&(r.addEventListener("unhandledrejection",e,!0),t(function(){r.removeEventListener("unhandledrejection",e,!0)}))},promiseRejectionSubject=[PROMISE_REJECTION_SUBJECT_NAME,observePromiseRejection],isSameErrorString=function(e,t){return e&&t&&e===t},shouldDropEvent=function(e,t){return!(!e||!t)&&!(!isSameErrorString(e.message,t.message)||!isSameErrorString(e.stack,t.stack))},dedupe=function(){var t;return function(e){try{if(shouldDropEvent(e,t))return void(t=e)}catch(e){reportSelfError(e)}return t=e}},jsErrorGetterWithContext=function(o,e,t,r){function n(e){var t=e.error,r=e.extra,n=e.react,e=e.source;!(t=f?l(t):t)||!t.message||_&&_.test(t.message)||o({ev_type:JS_ERROR_EV_TYPE,payload:{error:t,breadcrumbs:[],extra:r,react:n,source:e}})}var i=__read(t,3),u=i[0],a=i[1],c=i[2],s=r.ignoreErrors,t=r.onerror,i=r.onunhandledrejection,f=r.dedupe,r=r.captureGlobalAsync,_=getRegexp(s),l=dedupe();return t&&e.push(u[0](function(e){return n({error:normalizeError(e),source:{type:"onerror"}})})),i&&e.push(a[0](function(e){return n({error:normalizeException(e),source:{type:"onunhandledrejection"}})})),r&&e.push(c()[0](function(e){n(e)})),function(e,t,r){return n({error:normalizeUnknownError(e),extra:t,react:r,source:{type:"manual"}})}},JS_ERROR_MONITOR_PLUGIN_NAME="jsError",defaultConfig$1={ignoreErrors:[],onerror:!0,onunhandledrejection:!0,captureGlobalAsync:!1,dedupe:!0};function JsErrorMonitorPlugin(r){r.on("init",function(){window.removeEventListener("error",r.pcErr,!0),window.removeEventListener("unhandledrejection",r.pcRej,!0);var e,t=getPluginConfig(r,JS_ERROR_MONITOR_PLUGIN_NAME,defaultConfig$1);t&&(t=jsErrorGetterWithContext(function(e){r.getBreadcrumbs&&(e.payload.breadcrumbs=r.getBreadcrumbs()),r.report(e)},e=[],[initSubjectInGlobal(r,errorSubject),initSubjectInGlobal(r,promiseRejectionSubject),function(){return initSubjectInGlobal(r,asyncErrorWithSourceSubject)}],t),registerTearDownGroup(r,JS_ERROR_MONITOR_PLUGIN_NAME,JS_ERROR_EV_TYPE,e),r.provide("captureException",t))})}var defaultMetricContext={isSupport:!0,isPolyfill:!1,isBounced:!1,isCustom:!1,type:"perf"},initMetric=function(e,t){return __assign({name:e,value:t},defaultMetricContext)},wrapPerformanceMetric=function(e,t){return{ev_type:PERFORMANCE_METRIC_EV_TYPE,payload:e,overrides:t}},applyReportMetric=function(r){return function(e,t){r(wrapPerformanceMetric(e,t))}},SPA_LOAD_METRIC_NAME="spa_load",PAGE_ACTIVITY_DELAY=100,MAX_PAGE_ACTIVITY_DELAY=1e4,ROOT_TAGS=["BODY","HTML","HEAD"],waitActionComplete=function(e,t,r){function n(){r.clearTimeout(o),u&&(o=r.setTimeout(function(){e()},PAGE_ACTIVITY_DELAY))}var o,i,u=!1;return[function(){u=!0,r.clearTimeout(i),i=r.setTimeout(function(){e(),t()},MAX_PAGE_ACTIVITY_DELAY),n()},n,function(){u=!1,r.clearTimeout(o),r.clearTimeout(i)}]},getDomPath=function(e){var t=e,r=[];try{for(;null!==t.parentNode;){for(var n=0,o=0,i=0;i<t.parentNode.childNodes.length;i++){var u=t.parentNode.childNodes[i];u.nodeName===t.nodeName&&(u===t&&(o=n),n++)}t.hasAttribute("id")&&""!==t.id?r.unshift(t.nodeName+"#"+t.id):1<n?r.unshift(t.nodeName+":eq("+o+")"):r.unshift(t.nodeName),t=t.parentNode}return r.slice(1).join(">")}catch(e){return}},isSupportsElementClosest=function(){var e;return function(){return void 0===e?e="closest"in HTMLElement.prototype:e}}(),findElementWithAttributeByParents=function(e,t,r){void 0===r&&(r=10);for(var n=e,o=0;o<r&&n;o++){if(~ROOT_TAGS.indexOf(n.nodeName))return;if(n.hasAttribute(t))return n;n=n.parentElement}},getActionNameByAttribute=function(e,t){e=isSupportsElementClosest()?e.closest("["+t+"]"):findElementWithAttributeByParents(e,t);if(e)return e.getAttribute(t).trim()},getActionName=function(e,t){return getActionNameByAttribute(e,t)||e.innerText},SUPPORT_TYPES=["click"],EVENT_LISTENER_OPTIONS={capture:!0},MIN_LONG_TASK=50,DEFAULT_ATTR_NAME="data-apm-action",applyIncompleteReq=function(e,t,r){var n=__read(t,2),o=n[0],i=n[1],t=__read(applyRecord(),3),n=t[0],u=t[1],a=t[2],c=0;return e.push(o[0](function(e){__read(e,1)[0];var t=c+=1;return u(t,now()),r(),function(){a(t),r()}})),e.push(i[0](function(){var e=c+=1;return u(e,now()),r(),function(){a(e),r()}})),n},actionGetterWithFetchObserver=function(o,t,e,r){function n(e){var t;!l||!_&&!Object.keys(l.metrics).length||Object.keys(y).length&&!e||(l.metrics[LONG_TASK_EV_TYPE]&&(l.metrics[LONG_TASK_EV_TYPE].duration=v),t=0<d.length?Math.max.apply(Math,__spreadArray([],__read(d),!1))-Math.min.apply(Math,__spreadArray([],__read(d),!1)):0,l.metrics[HTTP_EV_TYPE]&&(l.metrics[HTTP_EV_TYPE].duration=t),e=h()-l.start_time,p&&p({ev_type:ACTION_EV_TYPE,payload:__assign(__assign({},l),{duration:e,frontend_time:e-t})}),i())}function i(){R(),l&&(E={start_time:l.start_time,id:l.id}),l=null,d=[],v=0}function u(e){l&&(l.metrics[e]={count:(null!==(e=null===(e=l.metrics[e])||void 0===e?void 0:e.count)&&void 0!==e?e:0)+1})}var a=__read(e,4),c=a[0],s=a[1],f=a[2],e=a[3],a=r.types,_=r.pure,l=null,E=null,p=void 0,d=[],v=0,h=__read(applyPerformance(performance),2)[1],r=__read(waitActionComplete(n,i,window),3),g=r[0],T=r[1],R=r[2],y=applyIncompleteReq(t,[c,s],T),c=__read(applyMutationObserver(MutationObserver,T),2),s=c[0],c=c[1];s(),t.push(c),t.push(R),t.push(f[0](function(e){var t=e.startTime,e=e.duration;T(),l&&l.start_time<=t+MIN_LONG_TASK&&(v+=e,u(LONG_TASK_EV_TYPE))})),t.push(e[0](function(e){var t=e.startTime,r=e.duration,e=e.initiatorType;T(),l&&l.start_time<t&&(["xmlhttprequest","fetch"].includes(e)&&(d.push(t,t+r),u(HTTP_EV_TYPE)),["xmlhttprequest","fetch","beacon"].includes(e)||u(RESOURCE_EV_TYPE))}));function S(e,t){var r=uuid(),n=__read(applyPerformance(performance),2)[1];l={start_time:n(),id:r,type:t,target:e,metrics:{}},p=o(),g()}function b(e){var t;n(!0),i(),e.target instanceof HTMLElement&&((t=getActionName(e.target,DEFAULT_ATTR_NAME))&&S({name:t,path:getDomPath(e.target)},e.type))}a&&a.forEach(function(e){arrayIncludes(SUPPORT_TYPES,e)&&(document.addEventListener(e,b,EVENT_LISTENER_OPTIONS),t.push(function(){return document.removeEventListener(e,b,EVENT_LISTENER_OPTIONS)}))});return[function(e){if(e.ev_type===HTTP_EV_TYPE)return(t=e.payload.response.timing&&e.payload.response.timing.startTime)?l&&t>l.start_time?l.id:E&&t>E.start_time?E.id:void 0:void 0;if(e.ev_type!==LONG_TASK_EV_TYPE)return l?(e.ev_type!==JS_ERROR_EV_TYPE&&e.ev_type!==RESOURCE_EV_TYPE||u(e.ev_type),l.id):void 0;var t=e.payload.longtasks.length&&e.payload.longtasks[0].startTime+MIN_LONG_TASK;return l&&t&&t>l.start_time?l.id:void 0},function(e,t){n(!0),i(),S({name:e},t)}]},ACTION_MONITOR_PLUGIN_NAME="action",defaultConfig={types:["click"]};function ActionMonitorBasePlugin(e,t){void 0===t&&(t=defaultConfig);var r,n,o=[],i=getDefaultDocument(),u=getDefaultBrowser();i&&u&&(t=__read(actionGetterWithFetchObserver(function(){return reportWithCurrentContext(e,!0)},o,[initSubjectInGlobal(e,[XHR_SUBJECT_NAME,applyXHR(XMLHttpRequest&&XMLHttpRequest.prototype)]),initSubjectInGlobal(e,fetchSubject),initSubjectInGlobal(e,longtaskSubject),initSubjectInGlobal(e,resourceSubject)],t),2),r=t[0],t=t[1],e.on("report",n=function(e){var t=r(e);return t&&e.extra&&(e.extra.action_id=t),e}),o.push(function(){e.off("report",n)}),e.provide("startAction",t),registerTearDownGroup(e,ACTION_MONITOR_PLUGIN_NAME,ACTION_EV_TYPE,o))}var getSPA=function(e,t,r){function n(e){!_||Object.keys(d).length&&!e||(l(initMetric(SPA_LOAD_METRIC_NAME,now()-_)),o())}function o(){p(),_=0}var i=__read(r,6),u=i[0],a=i[1],c=i[2],s=i[3],f=i[4],r=i[5],_=0,l=applyReportMetric(e),i=__read(waitActionComplete(n,noop,window),3),E=i[0],e=i[1],p=i[2],d=applyIncompleteReq(t,[a,c],e);t.push(s[0](e)),t.push(f[0](e));var e=__read(applyMutationObserver(r,e),2),v=e[0],e=e[1];t.push(e);var h=!0;t.push(u[0](function(){h?h=!1:(n(!0),o(),_=now(),v(document,{childList:!0,subtree:!0}),E())})),t.push(o)};function SPALoadMonitorPlugin(n){n.on("init",function(){var e=[],t=getDefaultDocument(),r=getDefaultMutationObserver();t&&r&&(getSPA(n.report.bind(n),e,[initPrivateSubject(n,[PV_SUBJECT_NAME,applyPV(n)]),initSubjectInGlobal(n,[XHR_SUBJECT_NAME,applyXHR(XMLHttpRequest&&XMLHttpRequest.prototype)]),initSubjectInGlobal(n,fetchSubject),initSubjectInGlobal(n,resourceSubject),initSubjectInGlobal(n,longtaskSubject),r]),n.on("beforeDestroy",function(){e.forEach(function(e){return e()})}))})}var CAPTURE_CONSOLE_INTEGRATION_NAME="captureConsole",captureConsole=function(e){var e=e.levels,r=void 0===e?["log","info","warn","error","debug","assert"]:e;return{name:CAPTURE_CONSOLE_INTEGRATION_NAME,setup:function(n){var t,o=getDefaultBrowser();o&&o.console&&(t=[],r.forEach(function(e){e in o.console&&t.push(hookMethodDangerously(o.console,e,function(r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{r&&r.call.apply(r,__spreadArray([o.console],__read(e),!1))}finally{n("captureException",safeJoin(e," "))}}})())}),n.on("beforeDestroy",function(){t.forEach(function(e){return e()})}))}}},JS_ERROR_INTEGRATION_NAME=JS_ERROR_MONITOR_PLUGIN_NAME,jsErrorPlugin=function(){return{name:JS_ERROR_INTEGRATION_NAME,setup:function(e){JsErrorMonitorPlugin(e)}}},ACTION_INTEGRATION_NAME=ACTION_MONITOR_PLUGIN_NAME,actionPlugin=function(t){return{name:ACTION_INTEGRATION_NAME,setup:function(e){ActionMonitorBasePlugin(e,t)}}},SPA_LOAD_INTEGRATION_NAME="spa_load",SPALoadPlugin=function(){return{name:SPA_LOAD_INTEGRATION_NAME,setup:function(e){SPALoadMonitorPlugin(e)}}};exports.SPALoadPlugin=SPALoadPlugin,exports.actionPlugin=actionPlugin,exports.captureConsole=captureConsole,exports.jsErrorPlugin=jsErrorPlugin,exports.refreshPreStartContext=refreshPreStartContext; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __assign=function(){return(__assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function __read(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),u=[];try{for(;(void 0===t||0<t--)&&!(n=i.next()).done;)u.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u}function __spreadArray(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||((n=n||Array.prototype.slice.call(t,0,o))[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}var REFRESH_PRE_START_CONTEXT_INTEGRATION_NAME="refreshPreStartContext",refreshPreStartContext=function(){return{name:REFRESH_PRE_START_CONTEXT_INTEGRATION_NAME,setup:function(n){n.on("start",function(){var r=n.getPreStartQueue();r.forEach(function(e,t){r[t]=__assign(__assign({},e),{overrides:__assign(__assign({},null!==(e=e.overrides)&&void 0!==e?e:{}),{context:(null===(e=n.context)||void 0===e?void 0:e.toString())||{}})})})})}}},noop=function(){return{}};function isObject(e){return"object"==typeof e&&null!==e}function isInstanceOf(e,t){try{return e instanceof t}catch(e){return!1}}var objProto=Object.prototype;function isPlainObject(e){if(isObject(e)){if("function"!=typeof Object.getPrototypeOf)return"[object Object]"===objProto.toString.call(e);e=Object.getPrototypeOf(e);return e===objProto||null===e}return!1}function isArray(e){return"[object Array]"===objProto.toString.call(e)}function isFunction(e){return"function"==typeof e}function isString(e){return"string"==typeof e}function isError(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMError]":case"[object DOMException]":return!0;default:return e instanceof Error}}function isEvent(e){return"undefined"!=typeof Event&&isInstanceOf(e,Event)}function isErrorEvent(e){return"[object ErrorEvent]"===Object.prototype.toString.call(e)}function isPromiseRejectionEvent(e){return"[object PromiseRejectionEvent]"===Object.prototype.toString.call(e)}function arrayIncludes(e,t){if(!isArray(e))return!1;if(0===e.length)return!1;for(var r=0;r<e.length;){if(e[r]===t)return!0;r++}return!1}var arrayRemove=function(e,t){if(!isArray(e))return e;var r=e.indexOf(t);if(0<=r){t=e.slice();return t.splice(r,1),t}return e},applyRecord=function(){var r={};return[r,function(e,t){return r[e]=t},function(e){return delete r[e]}]},pick=function(r,e){return r&&isObject(r)?e.reduce(function(e,t){return e[t]=r[t],e},{}):r};function getRegexp(e){return isArray(e)&&e.length?joinRegExp(e):null}function joinRegExp(e){for(var t=[],r=e.length,n=0;n<r;n++){var o=e[n];isString(o)?t.push(o.replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")):o&&o.source&&t.push(o.source)}return new RegExp(t.join("|"),"i")}function safeStringify(e){try{return isString(e)?e:JSON.stringify(e)}catch(e){return"[FAILED_TO_STRINGIFY]:"+String(e)}}function safeJoin(e,t){if(!isArray(e))return"";for(var r=[],n=0;n<e.length;n++)try{r.push(String(e[n]))}catch(e){r.push("[value cannot be serialized]")}return r.join(t)}var hookObjectProperty=function(i,u,a,c){return void 0===c&&(c=!0),function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(!i)return noop;var r=i[u],n=a.apply(void 0,__spreadArray([r],__read(e),!1)),o=n;return isFunction(o)&&c&&(o=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{return n.apply(this,t)}catch(e){return isFunction(r)&&r.apply(this,t)}}),i[u]=o,function(e){e||(o===i[u]?i[u]=r:n=r)}}},hookMethodDangerously=function(i,u,a){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(!i)return noop;var r=i[u],n=a.apply(void 0,__spreadArray([r],__read(e),!1)),o=n;return isFunction(o)&&(o=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.apply(this,e)}),i[u]=o,function(){o===i[u]?i[u]=r:n=r}}};function mathRNG(){for(var e=new Array(16),t=0,r=0;r<16;r++)0==(3&r)&&(t=4294967296*Math.random()),e[r]=t>>>((3&r)<<3)&255;return e}function bytesToUuid(e){for(var t=[],r=0;r<256;++r)t[r]=(r+256).toString(16).substr(1);var n=0,o=t;return[o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],o[e[+n]],o[e[15]]].join("")}function uuid(){var e=mathRNG();return e[6]=15&e[6]|64,e[8]=63&e[8]|128,bytesToUuid(e)}var BUFFER_TIME=3e5,applyBufferTimer=function(e,t,r){var n=0;return-1===r?noop:function(){if(e())return n&&clearTimeout(n),void(n=0);0===n&&(n=setTimeout(t,r))}},nextLink=function(n,e){var t=[];try{t=e.reduce(function(e,t){try{var r=t(n);"function"==typeof r&&e.push(r)}catch(e){}return e},[])}catch(e){}return function(e){return nextLink(e,t)}},toObservable=function(e){function t(e){n=arrayRemove(n,e),i||u()}var r,n=[],o=[],i=!1,u=applyBufferTimer(function(){return!!n.length},function(){i=!0,r&&r[0](),o.forEach(function(e){return e()}),o.length=0,r=void 0},e=void 0===e?BUFFER_TIME:e);return{next:function(e){return nextLink(e,n)},complete:function(e){o.push(e)},attach:function(e,t){r=[e,t]},subscribe:function(e){if(i)throw new Error("Observer is closed");return n.push(e),r&&r[1]&&r[1](e),u(),function(){return t(e)}},unsubscribe:t}},createSafeObserver=function(e,t,r){r=toObservable(r);try{e(r.next,r.attach),t&&r.complete(t)}catch(e){}return[r.subscribe,r.unsubscribe]},registerTearDownGroup=function(e,t,r,n){return e.destroyAgent.set(t,r,n)};function initSubjectInGlobal(e,t){return e.initSubject(t)}function initPrivateSubject(e,t,r){var t=__read(t,2),n=t[0],t=t[1],o=e.privateSubject||{};return o[n]||(o[n]=createSafeObserver(t,function(){o[n]=void 0},r)),o[n]}var now=function(){return Date.now()};function getDefaultBrowser(){if("object"==typeof window&&isObject(window))return window}function getDefaultDocument(){if("object"==typeof document&&isObject(document))return document}function getDefaultLocation(){return getDefaultBrowser()&&window.location}function getDefaultXMLHttpRequest(){if("function"==typeof XMLHttpRequest&&isFunction(XMLHttpRequest))return XMLHttpRequest}function getDefaultMutationObserver(){if(getDefaultBrowser()&&isFunction(window.MutationObserver))return window.MutationObserver}function getDefaultPerformanceObserver(){if(getDefaultBrowser()&&isFunction(window.PerformanceObserver))return window.PerformanceObserver}function getLocationUrl(){var e=getDefaultBrowser()&&getDefaultLocation();return null==e?void 0:e.href}var getViewOverrides=function(e){return{pid:e.pid,view_id:e.viewId,url:getLocationUrl()}},getOverrides=function(e){var t=e.config(),t=getViewOverrides(t);return t.context=e.context?e.context.toString():{},t},reportWithCurrentContext=function(t,e){void 0===e&&(e=!1);var r=getOverrides(t);return e&&(r.timestamp=now()),function(e){t.report(__assign(__assign({},e),{overrides:r}))}},PV_SUBJECT_NAME="view_0",applyPV=function(o){return function(r,e){function t(e){var t;e.viewId&&e.viewId!==(null===(t=o.config())||void 0===t?void 0:t.viewId)&&(r(n),n=__assign(__assign({},getOverrides(o)),getViewOverrides(e)))}var n=getOverrides(o);o.on("beforeConfig",t),e(function(){o.off("beforeConfig",t)})}},getGlobalRegistry=function(e){if(e)return e.__SLARDAR_REGISTRY__||(e.__SLARDAR_REGISTRY__={Slardar:{plugins:[],errors:[],subject:{}}}),e.__SLARDAR_REGISTRY__.Slardar},reportSelfError=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=getGlobalRegistry(getDefaultBrowser());r&&(r.errors||(r.errors=[]),r.errors.push(e))},applyMutationObserver=function(e,t){var r=e&&new e(t);return[function(e,t){r&&e&&r.observe(e,t)},function(){return r&&r.disconnect()}]},applyPerformance=function(r){var e=r&&r.timing||void 0;return[e,function(){return r&&r.now?r.now():(Date.now?Date.now():+new Date)-(e&&e.navigationStart||0)},function(e){var t=(r||{}).getEntriesByType;return isFunction(t)&&t.call(r,e)||[]},function(){var e=(r||{}).clearResourceTimings;isFunction(e)&&e.call(r)},function(e){var t=(r||{}).getEntriesByName;return isFunction(t)&&t.call(r,e)||[]}]},UNKNOWN_PATH="<unknown>";function htmlTreeAsString(e){try{for(var t,r=e,n=[],o=0,i=0,u=" > ".length;r&&o++<5&&!("html"===(t=_htmlElementAsString(r))||1<o&&256<=i+n.length*u+t.length);)n.push(t),i+=t.length,r=r.parentNode;return n.reverse().join(" > ")}catch(e){return UNKNOWN_PATH}}function _htmlElementAsString(e){var t,r,n,o=e,i=[];if(!o||!o.tagName)return"";i.push(o.tagName.toLowerCase()),o.id&&i.push("#"+o.id);e=o.className;if(e&&isString(e))for(t=e.split(/\s+/),a=0;a<t.length;a++)i.push("."+t[a]);for(var u=["type","name","title","alt"],a=0;a<u.length;a++)(n=o.getAttribute(r=u[a]))&&i.push("["+r+'="'+n+'"]');return i.join("")}var getConfig=function(e,t){return isObject(e)?__assign(__assign({},t),e):!!e&&t},XHR_SUBJECT_NAME="xhr_0",getReportPathRegExp=function(){var t=new RegExp("\\/monitor_web\\/collect|\\/monitor_browser\\/collect\\/batch","i");return function(e){return t.test(e)}},hookOpen=function(n){return function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e=__read(t,2),this._method=e[0],this._url=e[1],n.apply(this,t)}},hookSetHeader=function(o){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._reqHeaders=this._reqHeaders||{};var r=__read(e,2),n=r[0],r=r[1];return this._reqHeaders[n]=r,o&&o.apply(this,e)}},hookOnreadystatechange=function(n,o){return hookMethodDangerously(n,"onreadystatechange",function(r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 4===this.readyState&&o(n),r&&r.apply(this,e)}})},hookSend=function(n,o){var i=getReportPathRegExp();return function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return this._start=now(),this._data=null==t?void 0:t[0],i(this._url)||(e=o([this._method,this._url,this._start,this]),hookOnreadystatechange(this,e)()),n.apply(this,t)}},applyXHR=function(n){return function(e,t){var r;n&&((r=[]).push(hookMethodDangerously(n,"open",hookOpen)()),r.push(hookMethodDangerously(n,"setRequestHeader",hookSetHeader)()),r.push(hookMethodDangerously(n,"send",hookSend)(e)),t(function(){r.forEach(function(e){return e()})}))}},FETCH_SUBJECT_NAME="fetch_0",hookFetch=function(n,o){return function(e,t){var r=o([e,t=void 0===t?{}:t]),t=n(e,t);return t.then(function(e){r(e)},function(){r(void 0)}),t}},observeFetch=function(e,t){var r,n=getDefaultBrowser();n&&fetch&&((r=[]).push(hookMethodDangerously(n,"fetch",hookFetch)(e)),t(function(){r.forEach(function(e){return e()})}))},fetchSubject=[FETCH_SUBJECT_NAME,observeFetch],RESOURCE_TYPE=["resource"],LONGTASK_TYPE=["longtask"],applyPerformanceObserver=function(t,o,r){var n=t&&new t(function(e,n){e.getEntries?e.getEntries().forEach(function(e,t,r){return o(e,t,r,n)}):r&&r()});return[function(e){if(!t||!n)return r&&r();try{n.observe({entryTypes:e})}catch(e){return r&&r()}},function(e){if(!t||!n)return r&&r();try{n.observe({type:e,buffered:!0})}catch(e){return r&&r()}n.observe({type:e,buffered:!1})},function(){return n&&n.disconnect()}]},observePerf=function(e,t,r){e=__read(applyPerformanceObserver(e,t),3),t=e[0],e=e[2];return t(r),e},LONGTASK_SUBJECT_NAME="longtask_0",observeLongtask=function(e,t){var r=getDefaultPerformanceObserver();r&&t(observePerf(r,e,LONGTASK_TYPE))},longtaskSubject=[LONGTASK_SUBJECT_NAME,observeLongtask],RESOURCE_SUBJECT_NAME="resource_0",observeResource=function(e,t){var r=getDefaultPerformanceObserver();r&&t(observePerf(r,e,RESOURCE_TYPE))},resourceSubject=[RESOURCE_SUBJECT_NAME,observeResource],PAGEVIEW_EV_TYPE="pageview",JS_ERROR_EV_TYPE="js_error",HTTP_EV_TYPE="http",RESOURCE_EV_TYPE="resource",PERFORMANCE_METRIC_EV_TYPE="performance",LONG_TASK_EV_TYPE="performance_longtask",ACTION_EV_TYPE="action";function getPluginConfig(e,t,r){t=null===(e=e.config())||void 0===e?void 0:e.plugins[t];return getConfig(t,r)}var CLICK_EVENT_NAME="click",CLICK_SUBJECT_NAME=CLICK_EVENT_NAME+"_0",observeClick=function(e,t){var r=getDefaultDocument();r&&(r.addEventListener(CLICK_EVENT_NAME,e,!0),t(function(){r.removeEventListener(CLICK_EVENT_NAME,e,!0)}))},clickSubject=[CLICK_SUBJECT_NAME,observeClick],ERROR_FIELDS=["name","message","stack","filename","lineno","colno"],normalize=function(e){var t;return isError(e)?t=pick(e,ERROR_FIELDS):(isPlainObject(e)||isEvent(e)||isString(e))&&(t={message:safeStringify(e)}),t},normalizeError=function(e){return normalize(e.error)},normalizeException=function(e){var t;try{var r=void 0;if("reason"in e?r=e.reason:"detail"in e&&"reason"in e.detail&&(r=e.detail.reason),r){var n=normalize(r);return __assign(__assign({},n),{name:null!==(t=n&&n.name)&&void 0!==t?t:"UnhandledRejection"})}}catch(e){}},normalizeUnknownError=function(e){return(isErrorEvent(e)?normalizeError:isPromiseRejectionEvent(e)?normalizeException:normalize)(e)},DEFAULT_EVENT_TARGET=["EventTarget","Window","Node","ApplicationCache","ChannelMergerNode","EventSource","FileReader","HTMLUnknownElement","IDBDatabase","IDBRequest","IDBTransaction","MessagePort","Notification","SVGElementInstance","Screen","TextTrack","TextTrackCue","TextTrackList","WebSocket","Worker","XMLHttpRequest","XMLHttpRequestEventTarget","XMLHttpRequestUpload"],DEFAULT_TIME_FUNCTION=["setTimeout","setInterval","requestAnimationFrame","requestIdleCallback"],xmlHttpRequestProps=["onload","onerror","onprogress","onreadystatechange"],ADD_EVENT_LISTENER="addEventListener",REMOVE_EVENT_LISTENER="removeEventListener",DEFAULT_SOURCE_TYPE="capture-global",observeAsyncErrorWithSource=function(o,e){function u(e,r){if(!isFunction(e))return e;var n={type:DEFAULT_SOURCE_TYPE,data:__assign({},r)},t=e._w_||(e._w_=function(){try{return(e.handleEvent&&isFunction(e.handleEvent)?e.handleEvent:e).apply(this,[].map.call(arguments,function(e){return u(e,r)}))}catch(e){var t=normalize(e);throw t&&o({source:n,error:t}),e}});return t._hook_=!0,t}var t=getDefaultBrowser(),r=getDefaultXMLHttpRequest(),n=[];t&&n.push.apply(n,__spreadArray([],__read(DEFAULT_TIME_FUNCTION.filter(function(e){return t[e]}).map(function(o){return hookObjectProperty(t,o,function(n){return function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return n&&n.call.apply(n,__spreadArray([this,u(e,{function:o})],__read(t),!1))}},!1)()})),!1)),r&&r.prototype&&n.push(hookObjectProperty(r.prototype,"send",function(n){return function(){for(var t=this,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return xmlHttpRequestProps.filter(function(e){return t[e]&&!t[e]._hook_}).forEach(function(e){t[e]=u(t[e],{function:e})}),n.apply(this,e)}},!1)()),DEFAULT_EVENT_TARGET.forEach(function(i){var e=t&&t[i]&&t[i].prototype;e&&e[ADD_EVENT_LISTENER]&&(n.push(hookObjectProperty(e,ADD_EVENT_LISTENER,function(o){return function(e,t,r){try{var n=t.handleEvent;isFunction(n)&&(t.handleEvent=u(n,{function:"handleEvent",target:i}))}catch(e){}return o&&o.call(this,e,u(t,{function:ADD_EVENT_LISTENER,target:i}),r)}},!1)()),n.push(hookObjectProperty(e,REMOVE_EVENT_LISTENER,function(n){return function(e,t,r){return null!=t&&t._w_&&n.call(this,e,t._w_,r),n.call(this,e,t,r)}},!1)()))}),e(function(){return n.forEach(function(e){return e()})})},ASYNC_ERROR_SUBJECT_NAME="async_error_0",asyncErrorWithSourceSubject=[ASYNC_ERROR_SUBJECT_NAME,observeAsyncErrorWithSource],ERROR_SUBJECT_NAME="err_0",observeError=function(e,t){var r=getDefaultBrowser();r&&(r.addEventListener("error",e,!0),t(function(){r.removeEventListener("error",e,!0)}))},errorSubject=[ERROR_SUBJECT_NAME,observeError],PROMISE_REJECTION_SUBJECT_NAME="perr_0",observePromiseRejection=function(e,t){var r=getDefaultBrowser();r&&(r.addEventListener("unhandledrejection",e,!0),t(function(){r.removeEventListener("unhandledrejection",e,!0)}))},promiseRejectionSubject=[PROMISE_REJECTION_SUBJECT_NAME,observePromiseRejection],isSameErrorString=function(e,t){return e&&t&&e===t},shouldDropEvent=function(e,t){return!(!e||!t)&&!(!isSameErrorString(e.message,t.message)||!isSameErrorString(e.stack,t.stack))},dedupe=function(){var t;return function(e){try{if(shouldDropEvent(e,t))return void(t=e)}catch(e){reportSelfError(e)}return t=e}},jsErrorGetterWithContext=function(o,e,t,r){function n(e){var t=e.error,r=e.extra,n=e.react,e=e.source;!(t=f?_(t):t)||!t.message||l&&l.test(t.message)||o({ev_type:JS_ERROR_EV_TYPE,payload:{error:t,breadcrumbs:[],extra:r,react:n,source:e}})}var i=__read(t,3),u=i[0],a=i[1],c=i[2],s=r.ignoreErrors,t=r.onerror,i=r.onunhandledrejection,f=r.dedupe,r=r.captureGlobalAsync,l=getRegexp(s),_=dedupe();return t&&e.push(u[0](function(e){return n({error:normalizeError(e),source:{type:"onerror"}})})),i&&e.push(a[0](function(e){return n({error:normalizeException(e),source:{type:"onunhandledrejection"}})})),r&&e.push(c()[0](function(e){n(e)})),function(e,t,r){return n({error:normalizeUnknownError(e),extra:t,react:r,source:{type:"manual"}})}},JS_ERROR_MONITOR_PLUGIN_NAME="jsError",defaultConfig$1={ignoreErrors:[],onerror:!0,onunhandledrejection:!0,captureGlobalAsync:!1,dedupe:!0};function JsErrorMonitorPlugin(r){r.on("init",function(){window.removeEventListener("error",r.pcErr,!0),window.removeEventListener("unhandledrejection",r.pcRej,!0);var e,t=getPluginConfig(r,JS_ERROR_MONITOR_PLUGIN_NAME,defaultConfig$1);t&&(t=jsErrorGetterWithContext(function(e){r.getBreadcrumbs&&(e.payload.breadcrumbs=r.getBreadcrumbs()),r.report(e)},e=[],[initSubjectInGlobal(r,errorSubject),initSubjectInGlobal(r,promiseRejectionSubject),function(){return initSubjectInGlobal(r,asyncErrorWithSourceSubject)}],t),registerTearDownGroup(r,JS_ERROR_MONITOR_PLUGIN_NAME,JS_ERROR_EV_TYPE,e),r.provide("captureException",t))})}var defaultMetricContext={isSupport:!0,isPolyfill:!1,isBounced:!1,isCustom:!1,type:"perf"},initMetric=function(e,t){return __assign({name:e,value:t},defaultMetricContext)},wrapPerformanceMetric=function(e,t){return{ev_type:PERFORMANCE_METRIC_EV_TYPE,payload:e,overrides:t}},applyReportMetric=function(r){return function(e,t){r(wrapPerformanceMetric(e,t))}},SPA_LOAD_METRIC_NAME="spa_load",PAGE_ACTIVITY_DELAY=100,MAX_PAGE_ACTIVITY_DELAY=1e4,ROOT_TAGS=["BODY","HTML","HEAD"],SVG_TAG="SVG",DEFAULT_ATTR_NAME="data-apm-action",waitActionComplete=function(e,t,r){function n(){r.clearTimeout(o),u&&(o=r.setTimeout(function(){e()},PAGE_ACTIVITY_DELAY))}var o,i,u=!1;return[function(){u=!0,r.clearTimeout(i),i=r.setTimeout(function(){e(),t()},MAX_PAGE_ACTIVITY_DELAY),n()},n,function(){u=!1,r.clearTimeout(o),r.clearTimeout(i)}]},isSupportsElementClosest=function(){var e;return function(){return void 0===e?e="closest"in HTMLElement.prototype:e}}(),findElementWithAttributeByParents=function(e,t,r){void 0===r&&(r=10);for(var n=e,o=0;o<r&&n;o++){if(~ROOT_TAGS.indexOf(n.nodeName))return;if(n.hasAttribute(t))return n;n=n.parentElement}},getActionNameByAttribute=function(e,t){e=isSupportsElementClosest()?e.closest("["+t+"]"):findElementWithAttributeByParents(e,t);if(e)return e.getAttribute(t).trim()},getActionName=function(e,t){return getActionNameByAttribute(e,t)||e.innerText},isSVGTarget=function(e){for(var t=e,r=!1;t;)t.tagName.toUpperCase()===SVG_TAG?r=!(t=null):t=t.parentElement;return r},isElementWithinTwoLevels=function(e){e=e.children;return!e.length||![].slice.call(e).some(function(e){return 0<e.children.length})},isValidTarget=function(e){var t=e.tagName.toUpperCase();return 1===e.nodeType&&!ROOT_TAGS.includes(t)&&!isSVGTarget(e)&&((!e.style||"none"!==e.style.display)&&(!(!["A","BUTTON","INPUT","TEXTAREA"].includes(t)&&!getActionNameByAttribute(e,DEFAULT_ATTR_NAME))||!!isElementWithinTwoLevels(e)))},SUPPORT_TYPES=["click"],EVENT_LISTENER_OPTIONS={capture:!0},MIN_LONG_TASK=50,applyIncompleteReq=function(e,t,r){var n=__read(t,2),o=n[0],i=n[1],t=__read(applyRecord(),3),n=t[0],u=t[1],a=t[2],c=0;return e.push(o[0](function(e){__read(e,1)[0];var t=c+=1;return u(t,now()),r(),function(){a(t),r()}})),e.push(i[0](function(){var e=c+=1;return u(e,now()),r(),function(){a(e),r()}})),n},actionGetterWithFetchObserver=function(o,t,e,r){function n(e){var t;!_||!l&&!Object.keys(_.metrics).length||Object.keys(A).length&&!e||(_.metrics[LONG_TASK_EV_TYPE]&&(_.metrics[LONG_TASK_EV_TYPE].duration=v),t=0<d.length?Math.max.apply(Math,__spreadArray([],__read(d),!1))-Math.min.apply(Math,__spreadArray([],__read(d),!1)):0,_.metrics[HTTP_EV_TYPE]&&(_.metrics[HTTP_EV_TYPE].duration=t),e=T()-_.start_time,p&&p({ev_type:ACTION_EV_TYPE,payload:__assign(__assign({},_),{duration:e,frontend_time:e-t})}),i())}function i(){R(),_&&(E={start_time:_.start_time,id:_.id}),_=null,d=[],v=0}function u(e){_&&(_.metrics[e]={count:(null!==(e=null===(e=_.metrics[e])||void 0===e?void 0:e.count)&&void 0!==e?e:0)+1})}var a=__read(e,4),c=a[0],s=a[1],f=a[2],e=a[3],a=r.types,l=r.pure,_=null,E=null,p=void 0,d=[],v=0,T=__read(applyPerformance(performance),2)[1],r=__read(waitActionComplete(n,i,window),3),h=r[0],g=r[1],R=r[2],A=applyIncompleteReq(t,[c,s],g),c=__read(applyMutationObserver(MutationObserver,g),2),s=c[0],c=c[1];s(),t.push(c),t.push(R),t.push(f[0](function(e){var t=e.startTime,e=e.duration;g(),_&&_.start_time<=t+MIN_LONG_TASK&&(v+=e,u(LONG_TASK_EV_TYPE))})),t.push(e[0](function(e){var t=e.startTime,r=e.duration,e=e.initiatorType;g(),_&&_.start_time<t&&(["xmlhttprequest","fetch"].includes(e)&&(d.push(t,t+r),u(HTTP_EV_TYPE)),["xmlhttprequest","fetch","beacon"].includes(e)||u(RESOURCE_EV_TYPE))}));function S(e,t){var r=uuid(),n=__read(applyPerformance(performance),2)[1];_={start_time:n(),id:r,type:t,target:e,metrics:{}},p=o(),h()}function y(e){var t;n(!0),i(),e.target instanceof HTMLElement&&isValidTarget(e.target)&&((t=getActionName(e.target,DEFAULT_ATTR_NAME))&&S({name:t,path:htmlTreeAsString(e.target)},e.type))}a&&a.forEach(function(e){arrayIncludes(SUPPORT_TYPES,e)&&(document.addEventListener(e,y,EVENT_LISTENER_OPTIONS),t.push(function(){return document.removeEventListener(e,y,EVENT_LISTENER_OPTIONS)}))});return[function(e){if(e.ev_type===PAGEVIEW_EV_TYPE)return n(!0),void i();if(e.ev_type===HTTP_EV_TYPE)return(t=e.payload.response.timing&&e.payload.response.timing.startTime)?_&&t>_.start_time?_.id:E&&t>E.start_time?E.id:void 0:void 0;if(e.ev_type!==LONG_TASK_EV_TYPE)return _?(e.ev_type!==JS_ERROR_EV_TYPE&&e.ev_type!==RESOURCE_EV_TYPE||u(e.ev_type),_.id):void 0;var t=e.payload.longtasks.length&&e.payload.longtasks[0].startTime+MIN_LONG_TASK;return _&&t&&t>_.start_time?_.id:void 0},function(e,t){n(!0),i(),S({name:e},t)}]},ACTION_MONITOR_PLUGIN_NAME="action",defaultConfig={types:["click"]};function ActionMonitorBasePlugin(e,t){void 0===t&&(t=defaultConfig);var r,n,o=[],i=getDefaultDocument(),u=getDefaultBrowser();i&&u&&(t=__read(actionGetterWithFetchObserver(function(){return reportWithCurrentContext(e,!0)},o,[initSubjectInGlobal(e,[XHR_SUBJECT_NAME,applyXHR(XMLHttpRequest&&XMLHttpRequest.prototype)]),initSubjectInGlobal(e,fetchSubject),initSubjectInGlobal(e,longtaskSubject),initSubjectInGlobal(e,resourceSubject)],t),2),r=t[0],t=t[1],e.on("report",n=function(e){var t=r(e);return t&&e.extra&&(e.extra.action_id=t),e}),o.push(function(){e.off("report",n)}),e.provide("startAction",t),registerTearDownGroup(e,ACTION_MONITOR_PLUGIN_NAME,ACTION_EV_TYPE,o))}var getSPA=function(e,t,r){function n(e){!_||Object.keys(v).length&&!e||(E(initMetric(SPA_LOAD_METRIC_NAME,now()-_)),o())}function o(){d(),_=0}var i=__read(r,7),u=i[0],a=i[1],c=i[2],s=i[3],f=i[4],l=i[5],r=i[6],_=0,E=applyReportMetric(e),i=__read(waitActionComplete(n,noop,window),3),p=i[0],e=i[1],d=i[2],v=applyIncompleteReq(t,[c,s],e);t.push(f[0](e)),t.push(l[0](e));var e=__read(applyMutationObserver(r,e),2),T=e[0],e=e[1];t.push(e);var h=!0;t.push(u[0](function(){h?h=!1:(n(!0),o(),_=now(),T(document,{childList:!0,subtree:!0}),p())})),t.push(a[0](function(){n(!0),o()})),t.push(o)};function SPALoadMonitorPlugin(n){n.on("init",function(){var e=[],t=getDefaultDocument(),r=getDefaultMutationObserver();t&&r&&(getSPA(n.report.bind(n),e,[initPrivateSubject(n,[PV_SUBJECT_NAME,applyPV(n)]),initSubjectInGlobal(n,clickSubject),initSubjectInGlobal(n,[XHR_SUBJECT_NAME,applyXHR(XMLHttpRequest&&XMLHttpRequest.prototype)]),initSubjectInGlobal(n,fetchSubject),initSubjectInGlobal(n,resourceSubject),initSubjectInGlobal(n,longtaskSubject),r]),n.on("beforeDestroy",function(){e.forEach(function(e){return e()})}))})}var CAPTURE_CONSOLE_INTEGRATION_NAME="captureConsole",captureConsole=function(e){var e=e.levels,r=void 0===e?["log","info","warn","error","debug","assert"]:e;return{name:CAPTURE_CONSOLE_INTEGRATION_NAME,setup:function(n){var t,o=getDefaultBrowser();o&&o.console&&(t=[],r.forEach(function(e){e in o.console&&t.push(hookMethodDangerously(o.console,e,function(r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{r&&r.call.apply(r,__spreadArray([o.console],__read(e),!1))}finally{n("captureException",safeJoin(e," "))}}})())}),n.on("beforeDestroy",function(){t.forEach(function(e){return e()})}))}}},JS_ERROR_INTEGRATION_NAME=JS_ERROR_MONITOR_PLUGIN_NAME,jsErrorPlugin=function(){return{name:JS_ERROR_INTEGRATION_NAME,setup:function(e){JsErrorMonitorPlugin(e)}}},ACTION_INTEGRATION_NAME=ACTION_MONITOR_PLUGIN_NAME,actionPlugin=function(t){return{name:ACTION_INTEGRATION_NAME,setup:function(e){ActionMonitorBasePlugin(e,t)}}},SPA_LOAD_INTEGRATION_NAME="spa_load",SPALoadPlugin=function(){return{name:SPA_LOAD_INTEGRATION_NAME,setup:function(e){SPALoadMonitorPlugin(e)}}};exports.SPALoadPlugin=SPALoadPlugin,exports.actionPlugin=actionPlugin,exports.captureConsole=captureConsole,exports.jsErrorPlugin=jsErrorPlugin,exports.refreshPreStartContext=refreshPreStartContext; |
@@ -259,2 +259,5 @@ interface ContextAgent { | ||
}; | ||
declare type WebTransport = SdkTransport & { | ||
useBeacon?: boolean; | ||
}; | ||
@@ -888,2 +891,3 @@ interface Common$1 { | ||
dedupe: boolean; | ||
gatherPath: boolean; | ||
}; | ||
@@ -1050,3 +1054,3 @@ | ||
integrations?: Integration<BrowserCommandClient>[] | ||
transport?: SdkTransport | ||
transport?: WebTransport | ||
storageExpires?: number | boolean // 只能初始化配置一次 | ||
@@ -1089,3 +1093,3 @@ plugins?: AjaxMonitorPluginConfig & | ||
integrations?: Integration<BrowserCommandClient>[] | ||
transport: SdkTransport | ||
transport: WebTransport | ||
} | ||
@@ -1092,0 +1096,0 @@ |
@@ -259,2 +259,5 @@ interface ContextAgent { | ||
}; | ||
declare type WebTransport = SdkTransport & { | ||
useBeacon?: boolean; | ||
}; | ||
@@ -888,2 +891,3 @@ interface Common$1 { | ||
dedupe: boolean; | ||
gatherPath: boolean; | ||
}; | ||
@@ -1050,3 +1054,3 @@ | ||
integrations?: Integration<BrowserCommandClient>[] | ||
transport?: SdkTransport | ||
transport?: WebTransport | ||
storageExpires?: number | boolean // 只能初始化配置一次 | ||
@@ -1089,3 +1093,3 @@ plugins?: AjaxMonitorPluginConfig & | ||
integrations?: Integration<BrowserCommandClient>[] | ||
transport: SdkTransport | ||
transport: WebTransport | ||
} | ||
@@ -1092,0 +1096,0 @@ |
@@ -259,2 +259,5 @@ interface ContextAgent { | ||
}; | ||
declare type WebTransport = SdkTransport & { | ||
useBeacon?: boolean; | ||
}; | ||
@@ -888,2 +891,3 @@ interface Common$1 { | ||
dedupe: boolean; | ||
gatherPath: boolean; | ||
}; | ||
@@ -1050,3 +1054,3 @@ | ||
integrations?: Integration<BrowserCommandClient>[] | ||
transport?: SdkTransport | ||
transport?: WebTransport | ||
storageExpires?: number | boolean // 只能初始化配置一次 | ||
@@ -1089,3 +1093,3 @@ plugins?: AjaxMonitorPluginConfig & | ||
integrations?: Integration<BrowserCommandClient>[] | ||
transport: SdkTransport | ||
transport: WebTransport | ||
} | ||
@@ -1092,0 +1096,0 @@ |
@@ -259,2 +259,5 @@ interface ContextAgent { | ||
}; | ||
declare type WebTransport = SdkTransport & { | ||
useBeacon?: boolean; | ||
}; | ||
@@ -888,2 +891,3 @@ interface Common$1 { | ||
dedupe: boolean; | ||
gatherPath: boolean; | ||
}; | ||
@@ -1050,3 +1054,3 @@ | ||
integrations?: Integration<BrowserCommandClient>[] | ||
transport?: SdkTransport | ||
transport?: WebTransport | ||
storageExpires?: number | boolean // 只能初始化配置一次 | ||
@@ -1089,3 +1093,3 @@ plugins?: AjaxMonitorPluginConfig & | ||
integrations?: Integration<BrowserCommandClient>[] | ||
transport: SdkTransport | ||
transport: WebTransport | ||
} | ||
@@ -1092,0 +1096,0 @@ |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __assign=function(){return(__assign=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function __read(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),u=[];try{for(;(void 0===t||0<t--)&&!(r=i.next()).done;)u.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u}function __spreadArray(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||((r=r||Array.prototype.slice.call(t,0,o))[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}var noop=function(){return{}};function isObject(e){return"object"==typeof e&&null!==e}var objProto=Object.prototype;function isArray(e){return"[object Array]"===objProto.toString.call(e)}function isFunction(e){return"function"==typeof e}var arrayRemove=function(e,t){if(!isArray(e))return e;var n=e.indexOf(t);if(0<=n){t=e.slice();return t.splice(n,1),t}return e},applyRecord=function(){var n={};return[n,function(e,t){return n[e]=t},function(e){return delete n[e]}]},hookMethodDangerously=function(i,u,c){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(!i)return noop;var n=i[u],r=c.apply(void 0,__spreadArray([n],__read(e),!1)),o=r;return isFunction(o)&&(o=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r.apply(this,e)}),i[u]=o,function(){o===i[u]?i[u]=n:r=n}}},BUFFER_TIME=3e5,applyBufferTimer=function(e,t,n){var r=0;return-1===n?noop:function(){if(e())return r&&clearTimeout(r),void(r=0);0===r&&(r=setTimeout(t,n))}},nextLink=function(r,e){var t=[];try{t=e.reduce(function(e,t){try{var n=t(r);"function"==typeof n&&e.push(n)}catch(e){}return e},[])}catch(e){}return function(e){return nextLink(e,t)}},toObservable=function(e){function t(e){r=arrayRemove(r,e),i||u()}var n,r=[],o=[],i=!1,u=applyBufferTimer(function(){return!!r.length},function(){i=!0,n&&n[0](),o.forEach(function(e){return e()}),o.length=0,n=void 0},e=void 0===e?BUFFER_TIME:e);return{next:function(e){return nextLink(e,r)},complete:function(e){o.push(e)},attach:function(e,t){n=[e,t]},subscribe:function(e){if(i)throw new Error("Observer is closed");return r.push(e),n&&n[1]&&n[1](e),u(),function(){return t(e)}},unsubscribe:t}},createSafeObserver=function(e,t,n){n=toObservable(n);try{e(n.next,n.attach),t&&n.complete(t)}catch(e){}return[n.subscribe,n.unsubscribe]};function initSubjectInGlobal(e,t){return e.initSubject(t)}function initPrivateSubject(e,t,n){var t=__read(t,2),r=t[0],t=t[1],o=e.privateSubject||{};return o[r]||(o[r]=createSafeObserver(t,function(){o[r]=void 0},n)),o[r]}var now=function(){return Date.now()};function getDefaultBrowser(){if("object"==typeof window&&isObject(window))return window}function getDefaultDocument(){if("object"==typeof document&&isObject(document))return document}function getDefaultLocation(){return getDefaultBrowser()&&window.location}function getDefaultMutationObserver(){if(getDefaultBrowser()&&isFunction(window.MutationObserver))return window.MutationObserver}function getDefaultPerformanceObserver(){if(getDefaultBrowser()&&isFunction(window.PerformanceObserver))return window.PerformanceObserver}function getLocationUrl(){var e=getDefaultBrowser()&&getDefaultLocation();return null==e?void 0:e.href}var getViewOverrides=function(e){return{pid:e.pid,view_id:e.viewId,url:getLocationUrl()}},getOverrides=function(e){var t=e.config(),t=getViewOverrides(t);return t.context=e.context?e.context.toString():{},t},PV_SUBJECT_NAME="view_0",applyPV=function(o){return function(n,e){function t(e){var t;e.viewId&&e.viewId!==(null===(t=o.config())||void 0===t?void 0:t.viewId)&&(n(r),r=__assign(__assign({},getOverrides(o)),getViewOverrides(e)))}var r=getOverrides(o);o.on("beforeConfig",t),e(function(){o.off("beforeConfig",t)})}},applyMutationObserver=function(e,t){var n=e&&new e(t);return[function(e,t){n&&e&&n.observe(e,t)},function(){return n&&n.disconnect()}]},XHR_SUBJECT_NAME="xhr_0",getReportPathRegExp=function(){var t=new RegExp("\\/monitor_web\\/collect|\\/monitor_browser\\/collect\\/batch","i");return function(e){return t.test(e)}},hookOpen=function(r){return function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e=__read(t,2),this._method=e[0],this._url=e[1],r.apply(this,t)}},hookSetHeader=function(o){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._reqHeaders=this._reqHeaders||{};var n=__read(e,2),r=n[0],n=n[1];return this._reqHeaders[r]=n,o&&o.apply(this,e)}},hookOnreadystatechange=function(r,o){return hookMethodDangerously(r,"onreadystatechange",function(n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 4===this.readyState&&o(r),n&&n.apply(this,e)}})},hookSend=function(r,o){var i=getReportPathRegExp();return function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return this._start=now(),this._data=null==t?void 0:t[0],i(this._url)||(e=o([this._method,this._url,this._start,this]),hookOnreadystatechange(this,e)()),r.apply(this,t)}},applyXHR=function(r){return function(e,t){var n;r&&((n=[]).push(hookMethodDangerously(r,"open",hookOpen)()),n.push(hookMethodDangerously(r,"setRequestHeader",hookSetHeader)()),n.push(hookMethodDangerously(r,"send",hookSend)(e)),t(function(){n.forEach(function(e){return e()})}))}},FETCH_SUBJECT_NAME="fetch_0",hookFetch=function(r,o){return function(e,t){var n=o([e,t=void 0===t?{}:t]),t=r(e,t);return t.then(function(e){n(e)},function(){n(void 0)}),t}},observeFetch=function(e,t){var n,r=getDefaultBrowser();r&&fetch&&((n=[]).push(hookMethodDangerously(r,"fetch",hookFetch)(e)),t(function(){n.forEach(function(e){return e()})}))},fetchSubject=[FETCH_SUBJECT_NAME,observeFetch],RESOURCE_TYPE=["resource"],LONGTASK_TYPE=["longtask"],applyPerformanceObserver=function(t,o,n){var r=t&&new t(function(e,r){e.getEntries?e.getEntries().forEach(function(e,t,n){return o(e,t,n,r)}):n&&n()});return[function(e){if(!t||!r)return n&&n();try{r.observe({entryTypes:e})}catch(e){return n&&n()}},function(e){if(!t||!r)return n&&n();try{r.observe({type:e,buffered:!0})}catch(e){return n&&n()}r.observe({type:e,buffered:!1})},function(){return r&&r.disconnect()}]},observePerf=function(e,t,n){e=__read(applyPerformanceObserver(e,t),3),t=e[0],e=e[2];return t(n),e},LONGTASK_SUBJECT_NAME="longtask_0",observeLongtask=function(e,t){var n=getDefaultPerformanceObserver();n&&t(observePerf(n,e,LONGTASK_TYPE))},longtaskSubject=[LONGTASK_SUBJECT_NAME,observeLongtask],RESOURCE_SUBJECT_NAME="resource_0",observeResource=function(e,t){var n=getDefaultPerformanceObserver();n&&t(observePerf(n,e,RESOURCE_TYPE))},resourceSubject=[RESOURCE_SUBJECT_NAME,observeResource],PERFORMANCE_METRIC_EV_TYPE="performance",defaultMetricContext={isSupport:!0,isPolyfill:!1,isBounced:!1,isCustom:!1,type:"perf"},initMetric=function(e,t){return __assign({name:e,value:t},defaultMetricContext)},wrapPerformanceMetric=function(e,t){return{ev_type:PERFORMANCE_METRIC_EV_TYPE,payload:e,overrides:t}},applyReportMetric=function(n){return function(e,t){n(wrapPerformanceMetric(e,t))}},SPA_LOAD_METRIC_NAME="spa_load",PAGE_ACTIVITY_DELAY=100,MAX_PAGE_ACTIVITY_DELAY=1e4,waitActionComplete=function(e,t,n){function r(){n.clearTimeout(o),u&&(o=n.setTimeout(function(){e()},PAGE_ACTIVITY_DELAY))}var o,i,u=!1;return[function(){u=!0,n.clearTimeout(i),i=n.setTimeout(function(){e(),t()},MAX_PAGE_ACTIVITY_DELAY),r()},r,function(){u=!1,n.clearTimeout(o),n.clearTimeout(i)}]},applyIncompleteReq=function(e,t,n){var r=__read(t,2),o=r[0],i=r[1],t=__read(applyRecord(),3),r=t[0],u=t[1],c=t[2],a=0;return e.push(o[0](function(e){__read(e,1)[0];var t=a+=1;return u(t,now()),n(),function(){c(t),n()}})),e.push(i[0](function(){var e=a+=1;return u(e,now()),n(),function(){c(e),n()}})),r},getSPA=function(e,t,n){function r(e){!l||Object.keys(h).length&&!e||(p(initMetric(SPA_LOAD_METRIC_NAME,now()-l)),o())}function o(){v(),l=0}var i=__read(n,6),u=i[0],c=i[1],a=i[2],f=i[3],s=i[4],n=i[5],l=0,p=applyReportMetric(e),i=__read(waitActionComplete(r,noop,window),3),_=i[0],e=i[1],v=i[2],h=applyIncompleteReq(t,[c,a],e);t.push(f[0](e)),t.push(s[0](e));var e=__read(applyMutationObserver(n,e),2),d=e[0],e=e[1];t.push(e);var b=!0;t.push(u[0](function(){b?b=!1:(r(!0),o(),l=now(),d(document,{childList:!0,subtree:!0}),_())})),t.push(o)};function SPALoadMonitorPlugin(r){r.on("init",function(){var e=[],t=getDefaultDocument(),n=getDefaultMutationObserver();t&&n&&(getSPA(r.report.bind(r),e,[initPrivateSubject(r,[PV_SUBJECT_NAME,applyPV(r)]),initSubjectInGlobal(r,[XHR_SUBJECT_NAME,applyXHR(XMLHttpRequest&&XMLHttpRequest.prototype)]),initSubjectInGlobal(r,fetchSubject),initSubjectInGlobal(r,resourceSubject),initSubjectInGlobal(r,longtaskSubject),n]),r.on("beforeDestroy",function(){e.forEach(function(e){return e()})}))})}var SPA_LOAD_INTEGRATION_NAME="spa_load",SPALoadPlugin=function(){return{name:SPA_LOAD_INTEGRATION_NAME,setup:function(e){SPALoadMonitorPlugin(e)}}};exports.SPALoadPlugin=SPALoadPlugin,exports.SPA_LOAD_INTEGRATION_NAME=SPA_LOAD_INTEGRATION_NAME; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __assign=function(){return(__assign=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function __read(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),u=[];try{for(;(void 0===t||0<t--)&&!(r=i.next()).done;)u.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u}function __spreadArray(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||((r=r||Array.prototype.slice.call(t,0,o))[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}var noop=function(){return{}};function isObject(e){return"object"==typeof e&&null!==e}var objProto=Object.prototype;function isArray(e){return"[object Array]"===objProto.toString.call(e)}function isFunction(e){return"function"==typeof e}var arrayRemove=function(e,t){if(!isArray(e))return e;var n=e.indexOf(t);if(0<=n){t=e.slice();return t.splice(n,1),t}return e},applyRecord=function(){var n={};return[n,function(e,t){return n[e]=t},function(e){return delete n[e]}]},hookMethodDangerously=function(i,u,c){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(!i)return noop;var n=i[u],r=c.apply(void 0,__spreadArray([n],__read(e),!1)),o=r;return isFunction(o)&&(o=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r.apply(this,e)}),i[u]=o,function(){o===i[u]?i[u]=n:r=n}}},BUFFER_TIME=3e5,applyBufferTimer=function(e,t,n){var r=0;return-1===n?noop:function(){if(e())return r&&clearTimeout(r),void(r=0);0===r&&(r=setTimeout(t,n))}},nextLink=function(r,e){var t=[];try{t=e.reduce(function(e,t){try{var n=t(r);"function"==typeof n&&e.push(n)}catch(e){}return e},[])}catch(e){}return function(e){return nextLink(e,t)}},toObservable=function(e){function t(e){r=arrayRemove(r,e),i||u()}var n,r=[],o=[],i=!1,u=applyBufferTimer(function(){return!!r.length},function(){i=!0,n&&n[0](),o.forEach(function(e){return e()}),o.length=0,n=void 0},e=void 0===e?BUFFER_TIME:e);return{next:function(e){return nextLink(e,r)},complete:function(e){o.push(e)},attach:function(e,t){n=[e,t]},subscribe:function(e){if(i)throw new Error("Observer is closed");return r.push(e),n&&n[1]&&n[1](e),u(),function(){return t(e)}},unsubscribe:t}},createSafeObserver=function(e,t,n){n=toObservable(n);try{e(n.next,n.attach),t&&n.complete(t)}catch(e){}return[n.subscribe,n.unsubscribe]};function initSubjectInGlobal(e,t){return e.initSubject(t)}function initPrivateSubject(e,t,n){var t=__read(t,2),r=t[0],t=t[1],o=e.privateSubject||{};return o[r]||(o[r]=createSafeObserver(t,function(){o[r]=void 0},n)),o[r]}var now=function(){return Date.now()};function getDefaultBrowser(){if("object"==typeof window&&isObject(window))return window}function getDefaultDocument(){if("object"==typeof document&&isObject(document))return document}function getDefaultLocation(){return getDefaultBrowser()&&window.location}function getDefaultMutationObserver(){if(getDefaultBrowser()&&isFunction(window.MutationObserver))return window.MutationObserver}function getDefaultPerformanceObserver(){if(getDefaultBrowser()&&isFunction(window.PerformanceObserver))return window.PerformanceObserver}function getLocationUrl(){var e=getDefaultBrowser()&&getDefaultLocation();return null==e?void 0:e.href}var getViewOverrides=function(e){return{pid:e.pid,view_id:e.viewId,url:getLocationUrl()}},getOverrides=function(e){var t=e.config(),t=getViewOverrides(t);return t.context=e.context?e.context.toString():{},t},PV_SUBJECT_NAME="view_0",applyPV=function(o){return function(n,e){function t(e){var t;e.viewId&&e.viewId!==(null===(t=o.config())||void 0===t?void 0:t.viewId)&&(n(r),r=__assign(__assign({},getOverrides(o)),getViewOverrides(e)))}var r=getOverrides(o);o.on("beforeConfig",t),e(function(){o.off("beforeConfig",t)})}},applyMutationObserver=function(e,t){var n=e&&new e(t);return[function(e,t){n&&e&&n.observe(e,t)},function(){return n&&n.disconnect()}]},XHR_SUBJECT_NAME="xhr_0",getReportPathRegExp=function(){var t=new RegExp("\\/monitor_web\\/collect|\\/monitor_browser\\/collect\\/batch","i");return function(e){return t.test(e)}},hookOpen=function(r){return function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e=__read(t,2),this._method=e[0],this._url=e[1],r.apply(this,t)}},hookSetHeader=function(o){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._reqHeaders=this._reqHeaders||{};var n=__read(e,2),r=n[0],n=n[1];return this._reqHeaders[r]=n,o&&o.apply(this,e)}},hookOnreadystatechange=function(r,o){return hookMethodDangerously(r,"onreadystatechange",function(n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 4===this.readyState&&o(r),n&&n.apply(this,e)}})},hookSend=function(r,o){var i=getReportPathRegExp();return function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return this._start=now(),this._data=null==t?void 0:t[0],i(this._url)||(e=o([this._method,this._url,this._start,this]),hookOnreadystatechange(this,e)()),r.apply(this,t)}},applyXHR=function(r){return function(e,t){var n;r&&((n=[]).push(hookMethodDangerously(r,"open",hookOpen)()),n.push(hookMethodDangerously(r,"setRequestHeader",hookSetHeader)()),n.push(hookMethodDangerously(r,"send",hookSend)(e)),t(function(){n.forEach(function(e){return e()})}))}},FETCH_SUBJECT_NAME="fetch_0",hookFetch=function(r,o){return function(e,t){var n=o([e,t=void 0===t?{}:t]),t=r(e,t);return t.then(function(e){n(e)},function(){n(void 0)}),t}},observeFetch=function(e,t){var n,r=getDefaultBrowser();r&&fetch&&((n=[]).push(hookMethodDangerously(r,"fetch",hookFetch)(e)),t(function(){n.forEach(function(e){return e()})}))},fetchSubject=[FETCH_SUBJECT_NAME,observeFetch],RESOURCE_TYPE=["resource"],LONGTASK_TYPE=["longtask"],applyPerformanceObserver=function(t,o,n){var r=t&&new t(function(e,r){e.getEntries?e.getEntries().forEach(function(e,t,n){return o(e,t,n,r)}):n&&n()});return[function(e){if(!t||!r)return n&&n();try{r.observe({entryTypes:e})}catch(e){return n&&n()}},function(e){if(!t||!r)return n&&n();try{r.observe({type:e,buffered:!0})}catch(e){return n&&n()}r.observe({type:e,buffered:!1})},function(){return r&&r.disconnect()}]},observePerf=function(e,t,n){e=__read(applyPerformanceObserver(e,t),3),t=e[0],e=e[2];return t(n),e},LONGTASK_SUBJECT_NAME="longtask_0",observeLongtask=function(e,t){var n=getDefaultPerformanceObserver();n&&t(observePerf(n,e,LONGTASK_TYPE))},longtaskSubject=[LONGTASK_SUBJECT_NAME,observeLongtask],RESOURCE_SUBJECT_NAME="resource_0",observeResource=function(e,t){var n=getDefaultPerformanceObserver();n&&t(observePerf(n,e,RESOURCE_TYPE))},resourceSubject=[RESOURCE_SUBJECT_NAME,observeResource],PERFORMANCE_METRIC_EV_TYPE="performance",CLICK_EVENT_NAME="click",CLICK_SUBJECT_NAME=CLICK_EVENT_NAME+"_0",observeClick=function(e,t){var n=getDefaultDocument();n&&(n.addEventListener(CLICK_EVENT_NAME,e,!0),t(function(){n.removeEventListener(CLICK_EVENT_NAME,e,!0)}))},clickSubject=[CLICK_SUBJECT_NAME,observeClick],defaultMetricContext={isSupport:!0,isPolyfill:!1,isBounced:!1,isCustom:!1,type:"perf"},initMetric=function(e,t){return __assign({name:e,value:t},defaultMetricContext)},wrapPerformanceMetric=function(e,t){return{ev_type:PERFORMANCE_METRIC_EV_TYPE,payload:e,overrides:t}},applyReportMetric=function(n){return function(e,t){n(wrapPerformanceMetric(e,t))}},SPA_LOAD_METRIC_NAME="spa_load",PAGE_ACTIVITY_DELAY=100,MAX_PAGE_ACTIVITY_DELAY=1e4,waitActionComplete=function(e,t,n){function r(){n.clearTimeout(o),u&&(o=n.setTimeout(function(){e()},PAGE_ACTIVITY_DELAY))}var o,i,u=!1;return[function(){u=!0,n.clearTimeout(i),i=n.setTimeout(function(){e(),t()},MAX_PAGE_ACTIVITY_DELAY),r()},r,function(){u=!1,n.clearTimeout(o),n.clearTimeout(i)}]},applyIncompleteReq=function(e,t,n){var r=__read(t,2),o=r[0],i=r[1],t=__read(applyRecord(),3),r=t[0],u=t[1],c=t[2],a=0;return e.push(o[0](function(e){__read(e,1)[0];var t=a+=1;return u(t,now()),n(),function(){c(t),n()}})),e.push(i[0](function(){var e=a+=1;return u(e,now()),n(),function(){c(e),n()}})),r},getSPA=function(e,t,n){function r(e){!_||Object.keys(d).length&&!e||(p(initMetric(SPA_LOAD_METRIC_NAME,now()-_)),o())}function o(){h(),_=0}var i=__read(n,7),u=i[0],c=i[1],a=i[2],f=i[3],s=i[4],l=i[5],n=i[6],_=0,p=applyReportMetric(e),i=__read(waitActionComplete(r,noop,window),3),v=i[0],e=i[1],h=i[2],d=applyIncompleteReq(t,[a,f],e);t.push(s[0](e)),t.push(l[0](e));var e=__read(applyMutationObserver(n,e),2),E=e[0],e=e[1];t.push(e);var b=!0;t.push(u[0](function(){b?b=!1:(r(!0),o(),_=now(),E(document,{childList:!0,subtree:!0}),v())})),t.push(c[0](function(){r(!0),o()})),t.push(o)};function SPALoadMonitorPlugin(r){r.on("init",function(){var e=[],t=getDefaultDocument(),n=getDefaultMutationObserver();t&&n&&(getSPA(r.report.bind(r),e,[initPrivateSubject(r,[PV_SUBJECT_NAME,applyPV(r)]),initSubjectInGlobal(r,clickSubject),initSubjectInGlobal(r,[XHR_SUBJECT_NAME,applyXHR(XMLHttpRequest&&XMLHttpRequest.prototype)]),initSubjectInGlobal(r,fetchSubject),initSubjectInGlobal(r,resourceSubject),initSubjectInGlobal(r,longtaskSubject),n]),r.on("beforeDestroy",function(){e.forEach(function(e){return e()})}))})}var SPA_LOAD_INTEGRATION_NAME="spa_load",SPALoadPlugin=function(){return{name:SPA_LOAD_INTEGRATION_NAME,setup:function(e){SPALoadMonitorPlugin(e)}}};exports.SPALoadPlugin=SPALoadPlugin,exports.SPA_LOAD_INTEGRATION_NAME=SPA_LOAD_INTEGRATION_NAME; |
{ | ||
"name": "@apmplus/integrations", | ||
"version": "2.1.4", | ||
"version": "2.1.5-alpha.0", | ||
"description": "APMPlus Integrations", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
546559
13991
2