@apmplus/integrations
Advanced tools
Comparing version 2.1.5 to 2.1.6-alpha.0
@@ -255,2 +255,3 @@ interface ContextAgent { | ||
plugins: PluginsConfig; | ||
pluginPathPrefix?: string; | ||
apdex?: ApdexConfig; | ||
@@ -773,3 +774,3 @@ sample?: SampleConfig; | ||
interface AjaxMonitorConfig { | ||
interface AjaxMonitorProps { | ||
autoWrap?: boolean; | ||
@@ -786,3 +787,3 @@ setContextAtReq: () => (ev: HttpReport) => void; | ||
} | ||
interface FetchMonitorConfig extends AjaxMonitorConfig { | ||
interface FetchMonitorProps extends AjaxMonitorProps { | ||
} | ||
@@ -795,2 +796,3 @@ interface TraceConfig { | ||
declare const AJAX_MONITOR_PLUGIN_NAME = "ajax"; | ||
declare type AjaxMonitorConfig = Omit<AjaxMonitorProps, 'setContextAtReq' | 'setTraceHeader'>; | ||
interface AjaxMonitorPluginConfig { | ||
@@ -823,2 +825,3 @@ [AJAX_MONITOR_PLUGIN_NAME]?: Partial<AjaxMonitorConfig> | boolean; | ||
declare const FETCH_MONITOR_PLUGIN_NAME = "fetch"; | ||
declare type FetchMonitorConfig = Omit<FetchMonitorProps, 'setContextAtReq' | 'setTraceHeader'>; | ||
interface FetchMonitorPluginConfig { | ||
@@ -915,2 +918,3 @@ [FETCH_MONITOR_PLUGIN_NAME]?: Partial<FetchMonitorConfig> | boolean; | ||
mpfid = "mpfid", | ||
inp = "inp", | ||
lcp = "lcp", | ||
@@ -929,4 +933,2 @@ cls = "cls", | ||
declare const PERFORMANCE_MONITOR_PLUGIN_NAME = "performance"; | ||
declare type CustomPerformancePayload = Partial<Omit<PerformancePayload, 'name' | 'value'>> & Pick<PerformancePayload, 'name' | 'value'>; | ||
declare type WithSendPerformance<C extends WebClient$1> = C & { | ||
@@ -937,5 +939,7 @@ sendCustomPerfMetric?: (metric: CustomPerformancePayload) => void; | ||
}; | ||
declare const PERFORMANCE_MONITOR_PLUGIN_NAME = "performance"; | ||
interface PerformanceMonitorPluginConfig { | ||
[PERFORMANCE_MONITOR_PLUGIN_NAME]?: Partial<PerformanceMonitorUserConfig> | boolean; | ||
} | ||
declare type CustomPerformancePayload = Partial<Omit<PerformancePayload, 'name' | 'value'>> & Pick<PerformancePayload, 'name' | 'value'>; | ||
@@ -952,2 +956,3 @@ declare const TTI_MONITOR_PLUGIN_NAME = "tti"; | ||
declare const FMP_MONITOR_PLUGIN_NAME = "fmp"; | ||
interface FMPMonitorPluginConfig { | ||
@@ -957,3 +962,3 @@ [FMP_MONITOR_PLUGIN_NAME]?: Partial<FMPMonitorConfig> | boolean; | ||
interface BlankScreenMonitorConfig { | ||
interface BlankScreenProps { | ||
autoDetect?: boolean; | ||
@@ -970,2 +975,4 @@ threshold: number; | ||
quality: number; | ||
initDetTime: number; | ||
runDetTime: number; | ||
} | ||
@@ -976,2 +983,3 @@ interface DetectBlankScreen { | ||
declare type BlankScreenMonitorConfig = Omit<BlankScreenProps, 'ssUrl'>; | ||
declare const BLANK_SCREEN_MONITOR_PLUGIN_NAME = "blankScreen"; | ||
@@ -978,0 +986,0 @@ declare type WithDetectBlankScreen<C extends WebClient$1> = C & { |
@@ -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 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; | ||
"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}function isUndefined(t){return void 0===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 t?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 addListenerToDocument=function(t,e,r,n){return void 0===n&&(n=!1),t.addEventListener(e,r,n),function(){t.removeEventListener(e,r,n)}},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(n,o,i){var u=n&&new n(function(t,n){t.getEntries?t.getEntries().forEach(function(t,e,r){return o(t,e,r,n)}):i&&i()});return[function(t){if(!n||!u)return i&&i();try{u.observe({entryTypes:t})}catch(t){return i&&i()}},function(t,e){if(!n||!u)return i&&i();try{var r={type:t,buffered:!0};isUndefined(e)||(r.durationThreshold=e),u.observe(r)}catch(t){return i&&i()}u.observe({type:t,buffered:!1})},function(){return u&&u.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,ROOT_TAGS=["BODY","HTML","HEAD"],SVG_TAG="SVG",DEFAULT_ATTR_NAME="data-apm-action",waitActionComplete=function(t,e,r,n){function o(){t.clearTimeout(i),a&&(i=t.setTimeout(function(){e()},PAGE_ACTIVITY_DELAY))}var i,u,a=!1;return[function(){a=!0,t.clearTimeout(u),u=t.setTimeout(function(){e(!0),r()},n),o()},o,function(){a=!1,t.clearTimeout(i),t.clearTimeout(u)}]},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,MAX_ACTIVITY_DELAY=1e4,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(A).length&&!t||(l.metrics[LONG_TASK_EV_TYPE]&&(l.metrics[LONG_TASK_EV_TYPE].duration=h),e=0<T.length?Math.max.apply(Math,__spreadArray([],__read(T),!1))-Math.min.apply(Math,__spreadArray([],__read(T),!1)):0,l.metrics[HTTP_EV_TYPE]&&(l.metrics[HTTP_EV_TYPE].duration=e),t=E()-l.start_time,d&&d({ev_type:ACTION_EV_TYPE,payload:__assign(__assign({},l),{duration:t,frontend_time:t-e})}),i())}function i(){m(),l&&(p={start_time:l.start_time,id:l.id}),l=null,T=[],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,d=void 0,T=[],h=0,E=__read(applyPerformance(performance),2)[1],r=__read(waitActionComplete(window,n,i,MAX_ACTIVITY_DELAY),3),v=r[0],g=r[1],m=r[2],A=applyIncompleteReq(e,[c,s],g),c=__read(applyMutationObserver(MutationObserver,g),2),s=c[0],c=c[1];s(),e.push(c),e.push(m),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)&&(T.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:{}},d=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)&&e.push(addListenerToDocument(document,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"],pure:!0};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; |
@@ -255,2 +255,3 @@ interface ContextAgent { | ||
plugins: PluginsConfig; | ||
pluginPathPrefix?: string; | ||
apdex?: ApdexConfig; | ||
@@ -773,3 +774,3 @@ sample?: SampleConfig; | ||
interface AjaxMonitorConfig { | ||
interface AjaxMonitorProps { | ||
autoWrap?: boolean; | ||
@@ -786,3 +787,3 @@ setContextAtReq: () => (ev: HttpReport) => void; | ||
} | ||
interface FetchMonitorConfig extends AjaxMonitorConfig { | ||
interface FetchMonitorProps extends AjaxMonitorProps { | ||
} | ||
@@ -795,2 +796,3 @@ interface TraceConfig { | ||
declare const AJAX_MONITOR_PLUGIN_NAME = "ajax"; | ||
declare type AjaxMonitorConfig = Omit<AjaxMonitorProps, 'setContextAtReq' | 'setTraceHeader'>; | ||
interface AjaxMonitorPluginConfig { | ||
@@ -823,2 +825,3 @@ [AJAX_MONITOR_PLUGIN_NAME]?: Partial<AjaxMonitorConfig> | boolean; | ||
declare const FETCH_MONITOR_PLUGIN_NAME = "fetch"; | ||
declare type FetchMonitorConfig = Omit<FetchMonitorProps, 'setContextAtReq' | 'setTraceHeader'>; | ||
interface FetchMonitorPluginConfig { | ||
@@ -915,2 +918,3 @@ [FETCH_MONITOR_PLUGIN_NAME]?: Partial<FetchMonitorConfig> | boolean; | ||
mpfid = "mpfid", | ||
inp = "inp", | ||
lcp = "lcp", | ||
@@ -929,4 +933,2 @@ cls = "cls", | ||
declare const PERFORMANCE_MONITOR_PLUGIN_NAME = "performance"; | ||
declare type CustomPerformancePayload = Partial<Omit<PerformancePayload, 'name' | 'value'>> & Pick<PerformancePayload, 'name' | 'value'>; | ||
declare type WithSendPerformance<C extends WebClient$1> = C & { | ||
@@ -937,5 +939,7 @@ sendCustomPerfMetric?: (metric: CustomPerformancePayload) => void; | ||
}; | ||
declare const PERFORMANCE_MONITOR_PLUGIN_NAME = "performance"; | ||
interface PerformanceMonitorPluginConfig { | ||
[PERFORMANCE_MONITOR_PLUGIN_NAME]?: Partial<PerformanceMonitorUserConfig> | boolean; | ||
} | ||
declare type CustomPerformancePayload = Partial<Omit<PerformancePayload, 'name' | 'value'>> & Pick<PerformancePayload, 'name' | 'value'>; | ||
@@ -952,2 +956,3 @@ declare const TTI_MONITOR_PLUGIN_NAME = "tti"; | ||
declare const FMP_MONITOR_PLUGIN_NAME = "fmp"; | ||
interface FMPMonitorPluginConfig { | ||
@@ -957,3 +962,3 @@ [FMP_MONITOR_PLUGIN_NAME]?: Partial<FMPMonitorConfig> | boolean; | ||
interface BlankScreenMonitorConfig { | ||
interface BlankScreenProps { | ||
autoDetect?: boolean; | ||
@@ -970,2 +975,4 @@ threshold: number; | ||
quality: number; | ||
initDetTime: number; | ||
runDetTime: number; | ||
} | ||
@@ -976,2 +983,3 @@ interface DetectBlankScreen { | ||
declare type BlankScreenMonitorConfig = Omit<BlankScreenProps, 'ssUrl'>; | ||
declare const BLANK_SCREEN_MONITOR_PLUGIN_NAME = "blankScreen"; | ||
@@ -1221,3 +1229,3 @@ declare type WithDetectBlankScreen<C extends WebClient$1> = C & { | ||
declare const BLANK_SCREEN_INTEGRATION_NAME = "blankScreen"; | ||
declare const blankScreenPlugin: (blankScreenConfig?: Partial<BlankScreenMonitorConfig> | undefined) => { | ||
declare const blankScreenPlugin: (blankScreenConfig?: Partial<BlankScreenMonitorConfig>) => { | ||
name: string; | ||
@@ -1224,0 +1232,0 @@ setup: (client: WebClient) => void; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __assign=function(){return(__assign=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e}).apply(this,arguments)};function __read(e,n){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var r,o,i=t.call(e),u=[];try{for(;(void 0===n||0<n--)&&!(r=i.next()).done;)u.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return u}var noop=function(){return{}};function isObject(e){return"object"==typeof e&&null!==e}function isFunction(e){return"function"==typeof e}function isNumber(e){return"number"==typeof e}var registerTearDownGroup=function(e,n,t,r){return e.destroyAgent.set(n,t,r)};function initSubjectInGlobal(e,n){return e.initSubject(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 getDefaultPromise(){if(getDefaultBrowser()&&"Promise"in window)return Promise}function getDefaultMutationObserver(){if(getDefaultBrowser()&&isFunction(window.MutationObserver))return window.MutationObserver}function getDefaultPerformanceObserver(){if(getDefaultBrowser()&&isFunction(window.PerformanceObserver))return window.PerformanceObserver}var applyMutationObserver=function(e,n){var t=e&&new e(n);return[function(e,n){t&&e&&t.observe(e,n)},function(){return t&&t.disconnect()}]},applyPerformance=function(t){var e=t&&t.timing||void 0;return[e,function(){return t&&t.now?t.now():(Date.now?Date.now():+new Date)-(e&&e.navigationStart||0)},function(e){var n=(t||{}).getEntriesByType;return isFunction(n)&&n.call(t,e)||[]},function(){var e=(t||{}).clearResourceTimings;isFunction(e)&&e.call(t)},function(e){var n=(t||{}).getEntriesByName;return isFunction(n)&&n.call(t,e)||[]}]},applyRequestIdleCallback=function(n){return n.requestIdleCallback||function(e){return n.setTimeout(e,1)}},invokeCallbackOnce=function(n){var t=!1;return[function(e){t||(t=!0,n&&n(e))}]},getConfig=function(e,n){return isObject(e)?__assign(__assign({},n),e):!!e&&n},RESOURCE_TYPE=["resource"],LONGTASK_TYPE=["longtask"],applyPerformanceObserver=function(n,o,t){var r=n&&new n(function(e,r){e.getEntries?e.getEntries().forEach(function(e,n,t){return o(e,n,t,r)}):t&&t()});return[function(e){if(!n||!r)return t&&t();try{r.observe({entryTypes:e})}catch(e){return t&&t()}},function(e){if(!n||!r)return t&&t();try{r.observe({type:e,buffered:!0})}catch(e){return t&&t()}r.observe({type:e,buffered:!1})},function(){return r&&r.disconnect()}]},observePerf=function(e,n,t){e=__read(applyPerformanceObserver(e,n),3),n=e[0],e=e[2];return n(t),e},LONGTASK_SUBJECT_NAME="longtask_0",observeLongtask=function(e,n){var t=getDefaultPerformanceObserver();t&&n(observePerf(t,e,LONGTASK_TYPE))},longtaskSubject=[LONGTASK_SUBJECT_NAME,observeLongtask],RESOURCE_SUBJECT_NAME="resource_0",observeResource=function(e,n){var t=getDefaultPerformanceObserver();t&&n(observePerf(t,e,RESOURCE_TYPE))},resourceSubject=[RESOURCE_SUBJECT_NAME,observeResource],JS_ERROR_EV_TYPE="js_error",HTTP_EV_TYPE="http",RESOURCE_ERROR_EV_TYPE="resource_error",CUSTOM_EV_TYPE="custom",PERFORMANCE_METRIC_EV_TYPE="performance",PERFORMANCE_TIMING_EV_TYPE="performance_timing",LONG_TASK_EV_TYPE="performance_longtask",BLANK_SCREEN_EV_TYPE="blank_screen";function getPluginConfig(e,n,t){n=null===(e=e.config())||void 0===e?void 0:e.plugins[n];return getConfig(n,t)}var UNLOAD_SUBJECT_NAME="unload_0",observeUnload=function(e,n){var t,r,o,i=getDefaultBrowser();i&&(t=__read(invokeCallbackOnce(e),1)[0],o=function(){t()},(r=["unload","beforeunload","pagehide"]).forEach(function(e){i.addEventListener(e,o)}),n(function(){r.forEach(function(e){i.removeEventListener(e,o)})}))},unloadSubject=[UNLOAD_SUBJECT_NAME,observeUnload],DOM_CONTENT_LOAD_SUBJECT_NAME="domLoad_1",observeDOMContentLoad=function(e,n){var t,r,o=getDefaultBrowser(),i=getDefaultDocument();o&&i&&(t=!1,r=function(){setTimeout(function(){e(),t=!0},0)},"loading"!==i.readyState?r():o.addEventListener("DOMContentLoaded",r,!1),n(function(){o.removeEventListener("DOMContentLoaded",r,!1)},function(e){t&&e()}))},DOMContentLoadSubject=[DOM_CONTENT_LOAD_SUBJECT_NAME,observeDOMContentLoad],DEFAULT_IGNORE_TAGS=["SCRIPT","STYLE","META","HEAD"],ERROR_RELATED_TYPE=[JS_ERROR_EV_TYPE,HTTP_EV_TYPE,RESOURCE_ERROR_EV_TYPE],DEFAULT_THRESHOLD=1.5,MAX_RENDER_TIME=1e4,MAX_CHECK_TIME=8e3,DEFAULT_CHECK_TIME=2e3,MAX_RELATED_TIME=1e4,DEFAULT_T0_DATA_URL_QUALITY=.1,DEFAULT_MAX_DEPTH=4,CHECK_EXCLUSIVE_EV_TYPES=[PERFORMANCE_METRIC_EV_TYPE,LONG_TASK_EV_TYPE,PERFORMANCE_TIMING_EV_TYPE,CUSTOM_EV_TYPE],isSkipBeforeCheck=function(e){return~CHECK_EXCLUSIVE_EV_TYPES.indexOf(e.ev_type)},blankErrorCompare=function(e,n){if(-1===ERROR_RELATED_TYPE.indexOf(n.ev_type))return e;if(n.ev_type===HTTP_EV_TYPE&&n.payload.response.status<400)return e;if(e&&ERROR_RELATED_TYPE.indexOf(e.type)<ERROR_RELATED_TYPE.indexOf(n.ev_type))return e;var t="";switch(n.ev_type){case JS_ERROR_EV_TYPE:t=n.payload.error.message;break;case HTTP_EV_TYPE:t=n.payload.request.url;break;case RESOURCE_ERROR_EV_TYPE:t=n.payload.url}return{type:n.ev_type,message:t,timestamp:now()}},isSkipMeasure=function(e,n){return~DEFAULT_IGNORE_TAGS.indexOf(e.tagName)||DEFAULT_MAX_DEPTH<n},getBounding=function(e){e=e.getBoundingClientRect();return{width:e.width,height:e.height,top:e.top}},getElementByRootSelector=function(e){return e?document.querySelector(e):document.body},measure=function(t,r,e,o){if(void 0===r&&(r=0),void 0===e&&(e=0),void 0===o&&(o=DEFAULT_THRESHOLD),!t||isSkipMeasure(t,r)||o<=e)return e;var n=function(){if(!r)return 0;var e=getBounding(t),n=e.top,e=e.height;return n>innerHeight||e<=0?0:1/(1<<r-1)}();return[].reduceRight.call(t.children,function(e,n){return measure(n,r+1,e,o)},e+n)};function serializeDom2String(e,t,n){if(void 0===t&&(t=0),void 0===n&&(n=!0),!e||isSkipMeasure(e,t))return"";var r=__assign(__assign({},getBounding(e)),{id:e.getAttribute("id"),class:e.getAttribute("class")}),o=Object.keys(r).reduce(function(e,n){return e+(isNumber(r[n])||r[n]?" "+n+'="'+r[n]+'"':"")},""),i=e.tagName.toLowerCase(),e=[].reduce.call(e.children,function(e,n){return e+serializeDom2String(n,t+1,!1)},"");return"<"+i+o+(n?' innerHeight="'+innerHeight+'"':"")+">"+e+"</"+i+">"}var screenshot=function(e){var n=e.cb,t=e.screenshotUrl,r=e.window,o=e.document,i=e.mask,u=e.partialShot,a=e.quality,c=e.rootSelector;if(getDefaultPromise()&&r&&o){if(r.html2canvas)return s();e=o.createElement("script");e.src=t,null!==(t=o.head)&&void 0!==t&&t.appendChild(e),e.onload=s}function s(){applyRequestIdleCallback(r)(function(){r.html2canvas&&r.html2canvas(u&&c&&o.querySelector(c)||o.body,{scale:360/r.innerWidth,mask:i}).then(function(e){n(handleBase64(e.toDataURL("image/jpeg",a)))}).catch(function(){n(getBlankImageBase64())})})}};function handleBase64(e){return"data:image"===e.slice(0,10)?e:getBlankImageBase64()}function getBlankImageBase64(e,n){void 0===e&&(e=192),void 0===n&&(n=108);var t=document.createElement("canvas");t.width=e,t.height=n;var r=t.getContext("2d");return r&&(r.fillStyle="#ffffff",r.fillRect(0,0,e,n)),t.toDataURL("image/jpeg")}var blankScreenGetterWithObserver=function(t,r,e,n){function o(e,n){r.forEach(function(e){return e()}),r.length=0,u&&t({ev_type:BLANK_SCREEN_EV_TYPE,payload:{timestamp:u[0],score:u[1],screenshot:n,error:a,serialized_dom:serializeDom2String(getElementByRootSelector(m))},overrides:{timestamp:e||u[0]}})}function i(){c&&clearTimeout(c),c=A.setTimeout(function(){s=C(function(){var e=getElementByRootSelector(m);e&&((e=measure(e,0,0,v))<v?(u=[now(),e],M()):u=void 0)})},1e3)}var u,a,c,s,E,_,l,f=__read(e,4),T=f[0],d=f[1],g=f[2],e=f[3],v=n.threshold,R=n.screenshot,m=n.rootSelector,f=n.autoDetect,p=n.ssUrl,S=n.quality,b=n.mask,O=n.partialShot,A=getDefaultBrowser(),N=getDefaultDocument(),C=A.requestAnimationFrame||noop,D=A.cancelAnimationFrame||noop,P=__read(applyPerformance(performance),2)[1],h=0,L=!1,M=(_=function(){u&&!L&&(L=!0,R?screenshot({cb:o.bind(null,now()),screenshotUrl:p,window:A,document:N,mask:b,partialShot:O,quality:S,rootSelector:m}):o())},function(){E||(l=now(),E=A.setTimeout(function(){E=0,(l<h?i:_)()},P()>MAX_RENDER_TIME?DEFAULT_CHECK_TIME:MAX_CHECK_TIME))});return r.push(e[0](function(){!L&&a&&o()})),f&&r.push(T[0](function(){var e=__read(applyMutationObserver(getDefaultMutationObserver(),i),2),n=e[0],t=e[1];r.push(function(){clearTimeout(c),clearTimeout(E),D(s),t&&t()}),n(null===(n=getDefaultDocument())||void 0===n?void 0:n.body,{subtree:!0,childList:!0}),r.push(d()[0](function(){c&&i()})),r.push(g()[0](function(){c&&i()})),i()})),[function(e){L||isSkipBeforeCheck(e)||(h=now(),a&&h-a.timestamp>MAX_RELATED_TIME&&(a=void 0),a=blankErrorCompare(a,e))},i]},BLANK_SCREEN_MONITOR_PLUGIN_NAME="blankScreen";function BlankScreenMonitorBasePlugin(o,i,u){o.on("init",function(){var n,e,t=getDefaultDocument(),r=getDefaultBrowser();t&&r&&((t=getPluginConfig(o,BLANK_SCREEN_MONITOR_PLUGIN_NAME,i)||getConfig(u,i))&&(r=[],t=__read(blankScreenGetterWithObserver(o.report.bind(o),r,[initSubjectInGlobal(o,DOMContentLoadSubject),function(){return initSubjectInGlobal(o,longtaskSubject)},function(){return initSubjectInGlobal(o,resourceSubject)},initSubjectInGlobal(o,unloadSubject)],t),2),n=t[0],t=t[1],o.on("report",e=function(e){return n(e),e}),r.push(function(){o.off("report",e)}),registerTearDownGroup(o,BLANK_SCREEN_MONITOR_PLUGIN_NAME,BLANK_SCREEN_EV_TYPE,r),o.provide("detectBlankScreen",t)))})}var defaultVolConfig={autoDetect:!0,threshold:DEFAULT_THRESHOLD,screenshot:!0,ssUrl:"https://apm.volccdn.com/mars-web/apmplus/web/html2canvas.min.js",mask:!1,partialShot:!0,quality:DEFAULT_T0_DATA_URL_QUALITY};function BlankScreenMonitorVolPlugin(e,n){BlankScreenMonitorBasePlugin(e,defaultVolConfig,n)}var BLANK_SCREEN_INTEGRATION_NAME=BLANK_SCREEN_MONITOR_PLUGIN_NAME,blankScreenPlugin=function(n){return{name:BLANK_SCREEN_INTEGRATION_NAME,setup:function(e){BlankScreenMonitorVolPlugin(e,n)}}};exports.BLANK_SCREEN_INTEGRATION_NAME=BLANK_SCREEN_INTEGRATION_NAME,exports.blankScreenPlugin=blankScreenPlugin; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __assign=function(){return(__assign=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e}).apply(this,arguments)};function __read(e,n){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var r,o,i=t.call(e),u=[];try{for(;(void 0===n||0<n--)&&!(r=i.next()).done;)u.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return u}var noop=function(){return{}};function isObject(e){return"object"==typeof e&&null!==e}function isUndefined(e){return void 0===e}function isFunction(e){return"function"==typeof e}function isNumber(e){return"number"==typeof e}var registerTearDownGroup=function(e,n,t,r){return e.destroyAgent.set(n,t,r)};function initSubjectInGlobal(e,n){return e.initSubject(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 getDefaultPromise(){if(getDefaultBrowser()&&"Promise"in window)return Promise}function getDefaultMutationObserver(){if(getDefaultBrowser()&&isFunction(window.MutationObserver))return window.MutationObserver}function getDefaultPerformanceObserver(){if(getDefaultBrowser()&&isFunction(window.PerformanceObserver))return window.PerformanceObserver}var applyMutationObserver=function(e,n){var t=e&&new e(n);return[function(e,n){t&&e&&t.observe(e,n)},function(){return t&&t.disconnect()}]},applyPerformance=function(t){var e=t&&t.timing||void 0;return[e,function(){return t&&t.now?t.now():(Date.now?Date.now():+new Date)-(e&&e.navigationStart||0)},function(e){var n=(t||{}).getEntriesByType;return isFunction(n)&&n.call(t,e)||[]},function(){var e=(t||{}).clearResourceTimings;isFunction(e)&&e.call(t)},function(e){var n=(t||{}).getEntriesByName;return isFunction(n)&&n.call(t,e)||[]}]},applyRequestIdleCallback=function(n){return n.requestIdleCallback||function(e){return n.setTimeout(e,1)}},addListenerToWindow=function(e,n,t,r){return void 0===r&&(r=!1),e.addEventListener(n,t,r),function(){e.removeEventListener(n,t,r)}},addListenerToDocument=function(e,n,t,r){return void 0===r&&(r=!1),e.addEventListener(n,t,r),function(){e.removeEventListener(n,t,r)}},invokeCallbackOnce=function(n){var t=!1;return[function(e){t||(t=!0,n&&n(e))}]},getConfig=function(e,n){return isObject(e)?__assign(__assign({},n),e):!!e&&n},RESOURCE_TYPE=["resource"],LONGTASK_TYPE=["longtask"],applyPerformanceObserver=function(r,o,i){var u=r&&new r(function(e,r){e.getEntries?e.getEntries().forEach(function(e,n,t){return o(e,n,t,r)}):i&&i()});return[function(e){if(!r||!u)return i&&i();try{u.observe({entryTypes:e})}catch(e){return i&&i()}},function(e,n){if(!r||!u)return i&&i();try{var t={type:e,buffered:!0};isUndefined(n)||(t.durationThreshold=n),u.observe(t)}catch(e){return i&&i()}u.observe({type:e,buffered:!1})},function(){return u&&u.disconnect()}]},observePerf=function(e,n,t){e=__read(applyPerformanceObserver(e,n),3),n=e[0],e=e[2];return n(t),e},LONGTASK_SUBJECT_NAME="longtask_0",observeLongtask=function(e,n){var t=getDefaultPerformanceObserver();t&&n(observePerf(t,e,LONGTASK_TYPE))},longtaskSubject=[LONGTASK_SUBJECT_NAME,observeLongtask],RESOURCE_SUBJECT_NAME="resource_0",observeResource=function(e,n){var t=getDefaultPerformanceObserver();t&&n(observePerf(t,e,RESOURCE_TYPE))},resourceSubject=[RESOURCE_SUBJECT_NAME,observeResource],JS_ERROR_EV_TYPE="js_error",HTTP_EV_TYPE="http",RESOURCE_ERROR_EV_TYPE="resource_error",CUSTOM_EV_TYPE="custom",PERFORMANCE_METRIC_EV_TYPE="performance",PERFORMANCE_TIMING_EV_TYPE="performance_timing",LONG_TASK_EV_TYPE="performance_longtask",BLANK_SCREEN_EV_TYPE="blank_screen";function getPluginConfig(e,n,t){n=null===(e=e.config())||void 0===e?void 0:e.plugins[n];return getConfig(n,t)}var UNLOAD_SUBJECT_NAME="unload_0",observeUnload=function(e,n){var t,r,o,i=getDefaultBrowser();i&&(t=__read(invokeCallbackOnce(e),1)[0],r=function(){t()},o=[],["unload","beforeunload","pagehide"].forEach(function(e){o.push(addListenerToWindow(i,e,r,!1))}),n(function(){o.forEach(function(e){return e()})}))},unloadSubject=[UNLOAD_SUBJECT_NAME,observeUnload],DOM_CONTENT_LOAD_SUBJECT_NAME="domLoad_1",observeDOMContentLoad=function(e,n){var t,r,o=getDefaultBrowser(),i=getDefaultDocument();o&&i&&(t=!1,r=noop,o=function(){setTimeout(function(){e(),t=!0},0)},"loading"!==i.readyState?o():r=addListenerToDocument(i,"DOMContentLoaded",o,!1),n(function(){r()},function(e){t&&e()}))},DOMContentLoadSubject=[DOM_CONTENT_LOAD_SUBJECT_NAME,observeDOMContentLoad],DEFAULT_IGNORE_TAGS=["SCRIPT","STYLE","META","HEAD"],ERROR_RELATED_TYPE=[JS_ERROR_EV_TYPE,HTTP_EV_TYPE,RESOURCE_ERROR_EV_TYPE],DEFAULT_THRESHOLD=1.5,MAX_RENDER_TIME=1e4,MAX_CHECK_TIME=8e3,DEFAULT_CHECK_TIME=4e3,MAX_RELATED_TIME=1e4,DEFAULT_T0_DATA_URL_QUALITY=.1,DEFAULT_MAX_DEPTH=4,CHECK_EXCLUSIVE_EV_TYPES=[PERFORMANCE_METRIC_EV_TYPE,LONG_TASK_EV_TYPE,PERFORMANCE_TIMING_EV_TYPE,CUSTOM_EV_TYPE],isSkipBeforeCheck=function(e){return~CHECK_EXCLUSIVE_EV_TYPES.indexOf(e.ev_type)},blankErrorCompare=function(e,n){if(-1===ERROR_RELATED_TYPE.indexOf(n.ev_type))return e;if(n.ev_type===HTTP_EV_TYPE&&n.payload.response.status<400)return e;if(e&&ERROR_RELATED_TYPE.indexOf(e.type)<ERROR_RELATED_TYPE.indexOf(n.ev_type))return e;var t="";switch(n.ev_type){case JS_ERROR_EV_TYPE:t=n.payload.error.message;break;case HTTP_EV_TYPE:t=n.payload.request.url;break;case RESOURCE_ERROR_EV_TYPE:t=n.payload.url}return{type:n.ev_type,message:t,timestamp:now()}},isSkipMeasure=function(e,n){return~DEFAULT_IGNORE_TAGS.indexOf(e.tagName)||DEFAULT_MAX_DEPTH<n},getBounding=function(e){e=e.getBoundingClientRect();return{width:e.width,height:e.height,top:e.top}},getElementByRootSelector=function(e){return e?document.querySelector(e):document.body},measure=function(t,r,e,o){if(void 0===r&&(r=0),void 0===e&&(e=0),void 0===o&&(o=DEFAULT_THRESHOLD),!t||isSkipMeasure(t,r)||o<=e)return e;var n=function(){if(!r)return 0;var e=getBounding(t),n=e.top,e=e.height;return n>innerHeight||e<=0?0:1/(1<<r-1)}();return[].reduceRight.call(t.children,function(e,n){return measure(n,r+1,e,o)},e+n)};function serializeDom2String(e,t,n){if(void 0===t&&(t=0),void 0===n&&(n=!0),!e||isSkipMeasure(e,t))return"";var r=__assign(__assign({},getBounding(e)),{id:e.getAttribute("id"),class:e.getAttribute("class")}),o=Object.keys(r).reduce(function(e,n){return e+(isNumber(r[n])||r[n]?" "+n+'="'+r[n]+'"':"")},""),i=e.tagName.toLowerCase(),e=[].reduce.call(e.children,function(e,n){return e+serializeDom2String(n,t+1,!1)},"");return"<"+i+o+(n?' innerHeight="'+innerHeight+'"':"")+">"+e+"</"+i+">"}var screenshot=function(e){var n=e.cb,t=e.screenshotUrl,r=e.window,o=e.document,i=e.mask,u=e.partialShot,a=e.quality,c=e.rootSelector;if(getDefaultPromise()&&r&&o){if(r.html2canvas)return s();e=o.createElement("script");e.src=t,null!==(t=o.head)&&void 0!==t&&t.appendChild(e),e.onload=s,e.onerror=function(){n()}}function s(){applyRequestIdleCallback(r)(function(){r.html2canvas&&r.html2canvas(u&&c&&o.querySelector(c)||o.body,{scale:360/r.innerWidth,mask:i}).then(function(e){n(handleBase64(e.toDataURL("image/jpeg",a)))}).catch(function(){n(getBlankImageBase64())})})}};function handleBase64(e){return"data:image"===e.slice(0,10)?e:getBlankImageBase64()}function getBlankImageBase64(e,n){void 0===e&&(e=192),void 0===n&&(n=108);var t=document.createElement("canvas");t.width=e,t.height=n;var r=t.getContext("2d");return r&&(r.fillStyle="#ffffff",r.fillRect(0,0,e,n)),t.toDataURL("image/jpeg")}var blankScreenGetterWithObserver=function(t,r,e,n){function o(e,n){y||(u=B())&&(y=!0,r.forEach(function(e){return e()}),r.length=0,t({ev_type:BLANK_SCREEN_EV_TYPE,payload:{timestamp:u[0],score:u[1],screenshot:n,error:a,serialized_dom:serializeDom2String(getElementByRootSelector(R))},overrides:{timestamp:e||u[0]}}))}function i(){E&&clearTimeout(E),c&&clearTimeout(c),c=N.setTimeout(function(){s=C(function(){(u=B())&&U()})},1e3)}var u,a,c,s,E,_,l,f=__read(e,4),d=f[0],T=f[1],v=f[2],g=f[3],m=n.threshold,e=n.screenshot,R=n.rootSelector,f=n.autoDetect,p=n.ssUrl,S=n.quality,b=n.mask,O=n.partialShot,A=n.initDetTime,D=n.runDetTime,N=getDefaultBrowser(),h=getDefaultDocument(),C=N.requestAnimationFrame||noop,P=N.cancelAnimationFrame||noop,L=__read(applyPerformance(performance),2)[1],M=0,y=!1,w=!e,B=function(){var e=getElementByRootSelector(R);if(e){e=measure(e,0,0,m);return e<m?[now(),e]:void 0}},U=(_=function(){u&&!y&&(w?o():(w=!0,screenshot({cb:o.bind(null,now()),screenshotUrl:p,window:N,document:h,mask:b,partialShot:O,quality:S,rootSelector:R})))},function(){E&&clearTimeout(E),l=now(),E=N.setTimeout(function(){(l<M?i:_)()},L()>MAX_RENDER_TIME?D:A)});return r.push(g[0](function(){a&&o()})),f&&r.push(d[0](function(){var e=__read(applyMutationObserver(getDefaultMutationObserver(),i),2),n=e[0],t=e[1];r.push(function(){clearTimeout(c),clearTimeout(E),P(s),t&&t()}),n(null===(n=getDefaultDocument())||void 0===n?void 0:n.body,{subtree:!0,childList:!0}),r.push(T()[0](function(){c&&i()})),r.push(v()[0](function(){c&&i()})),i()})),[function(e){y||isSkipBeforeCheck(e)||(M=now(),a&&M-a.timestamp>MAX_RELATED_TIME&&(a=void 0),a=blankErrorCompare(a,e))},i]},BLANK_SCREEN_MONITOR_PLUGIN_NAME="blankScreen";function BlankScreenMonitorBasePlugin(e,n){var t,r,o=getDefaultDocument(),i=getDefaultBrowser();o&&i&&(i=[],n=__read(blankScreenGetterWithObserver(e.report.bind(e),i,[initSubjectInGlobal(e,DOMContentLoadSubject),function(){return initSubjectInGlobal(e,longtaskSubject)},function(){return initSubjectInGlobal(e,resourceSubject)},initSubjectInGlobal(e,unloadSubject)],n),2),t=n[0],n=n[1],e.on("report",r=function(e){return t(e),e}),i.push(function(){e.off("report",r)}),registerTearDownGroup(e,BLANK_SCREEN_MONITOR_PLUGIN_NAME,BLANK_SCREEN_EV_TYPE,i),e.provide("detectBlankScreen",n))}function BlankScreenMonitorVolPlugin(n,t){n.on("init",function(){var e={autoDetect:!0,threshold:DEFAULT_THRESHOLD,screenshot:!0,ssUrl:"https://apm.volccdn.com/mars-web/apmplus/web/html2canvas.min.js",mask:!1,partialShot:!0,quality:DEFAULT_T0_DATA_URL_QUALITY,initDetTime:MAX_CHECK_TIME,runDetTime:DEFAULT_CHECK_TIME},e=t?getConfig(t,e):getPluginConfig(n,BLANK_SCREEN_MONITOR_PLUGIN_NAME,e);e&&BlankScreenMonitorBasePlugin(n,e)})}var BLANK_SCREEN_INTEGRATION_NAME=BLANK_SCREEN_MONITOR_PLUGIN_NAME,blankScreenPlugin=function(n){return void 0===n&&(n={}),{name:BLANK_SCREEN_INTEGRATION_NAME,setup:function(e){BlankScreenMonitorVolPlugin(e,n)}}};exports.BLANK_SCREEN_INTEGRATION_NAME=BLANK_SCREEN_INTEGRATION_NAME,exports.blankScreenPlugin=blankScreenPlugin; |
@@ -255,2 +255,3 @@ interface ContextAgent { | ||
plugins: PluginsConfig; | ||
pluginPathPrefix?: string; | ||
apdex?: ApdexConfig; | ||
@@ -773,3 +774,3 @@ sample?: SampleConfig; | ||
interface AjaxMonitorConfig { | ||
interface AjaxMonitorProps { | ||
autoWrap?: boolean; | ||
@@ -786,3 +787,3 @@ setContextAtReq: () => (ev: HttpReport) => void; | ||
} | ||
interface FetchMonitorConfig extends AjaxMonitorConfig { | ||
interface FetchMonitorProps extends AjaxMonitorProps { | ||
} | ||
@@ -795,2 +796,3 @@ interface TraceConfig { | ||
declare const AJAX_MONITOR_PLUGIN_NAME = "ajax"; | ||
declare type AjaxMonitorConfig = Omit<AjaxMonitorProps, 'setContextAtReq' | 'setTraceHeader'>; | ||
interface AjaxMonitorPluginConfig { | ||
@@ -823,2 +825,3 @@ [AJAX_MONITOR_PLUGIN_NAME]?: Partial<AjaxMonitorConfig> | boolean; | ||
declare const FETCH_MONITOR_PLUGIN_NAME = "fetch"; | ||
declare type FetchMonitorConfig = Omit<FetchMonitorProps, 'setContextAtReq' | 'setTraceHeader'>; | ||
interface FetchMonitorPluginConfig { | ||
@@ -915,2 +918,3 @@ [FETCH_MONITOR_PLUGIN_NAME]?: Partial<FetchMonitorConfig> | boolean; | ||
mpfid = "mpfid", | ||
inp = "inp", | ||
lcp = "lcp", | ||
@@ -929,4 +933,2 @@ cls = "cls", | ||
declare const PERFORMANCE_MONITOR_PLUGIN_NAME = "performance"; | ||
declare type CustomPerformancePayload = Partial<Omit<PerformancePayload, 'name' | 'value'>> & Pick<PerformancePayload, 'name' | 'value'>; | ||
declare type WithSendPerformance<C extends WebClient$1> = C & { | ||
@@ -937,5 +939,7 @@ sendCustomPerfMetric?: (metric: CustomPerformancePayload) => void; | ||
}; | ||
declare const PERFORMANCE_MONITOR_PLUGIN_NAME = "performance"; | ||
interface PerformanceMonitorPluginConfig { | ||
[PERFORMANCE_MONITOR_PLUGIN_NAME]?: Partial<PerformanceMonitorUserConfig> | boolean; | ||
} | ||
declare type CustomPerformancePayload = Partial<Omit<PerformancePayload, 'name' | 'value'>> & Pick<PerformancePayload, 'name' | 'value'>; | ||
@@ -952,2 +956,3 @@ declare const TTI_MONITOR_PLUGIN_NAME = "tti"; | ||
declare const FMP_MONITOR_PLUGIN_NAME = "fmp"; | ||
interface FMPMonitorPluginConfig { | ||
@@ -957,3 +962,3 @@ [FMP_MONITOR_PLUGIN_NAME]?: Partial<FMPMonitorConfig> | boolean; | ||
interface BlankScreenMonitorConfig { | ||
interface BlankScreenProps { | ||
autoDetect?: boolean; | ||
@@ -970,2 +975,4 @@ threshold: number; | ||
quality: number; | ||
initDetTime: number; | ||
runDetTime: number; | ||
} | ||
@@ -976,2 +983,3 @@ interface DetectBlankScreen { | ||
declare type BlankScreenMonitorConfig = Omit<BlankScreenProps, 'ssUrl'>; | ||
declare const BLANK_SCREEN_MONITOR_PLUGIN_NAME = "blankScreen"; | ||
@@ -978,0 +986,0 @@ declare type WithDetectBlankScreen<C extends WebClient$1> = C & { |
@@ -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 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; | ||
"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,i=t.call(e),a=[];try{for(;(void 0===r||0<r--)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return a}function __spreadArray(e,r,t){if(t||2===arguments.length)for(var n,o=0,i=r.length;o<i;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,i=0,a=" > ".length;t&&o++<5&&!("html"===(r=_htmlElementAsString(t))||1<o&&256<=i+n.length*a+r.length);)n.push(r),i+=r.length,t=t.parentNode;return n.reverse().join(" > ")}catch(e){return UNKNOWN_PATH}}function _htmlElementAsString(e){var r,t,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(r=e.split(/\s+/),u=0;u<r.length;u++)i.push("."+r[u]);for(var a=["type","name","title","alt"],u=0;u<a.length;u++)(n=o.getAttribute(t=a[u]))&&i.push("["+t+'="'+n+'"]');return i.join("")}var addListenerToDocument=function(e,r,t,n){return void 0===n&&(n=!1),e.addEventListener(r,t,n),function(){e.removeEventListener(r,t,n)}},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,n=getDefaultDocument();n&&(t=addListenerToDocument(n,CLICK_EVENT_NAME,e,!0),r(function(){t()}))},clickSubject=[CLICK_SUBJECT_NAME,observeClick],KEYPRESS_EVENT_NAME="keypress",KEYPRESS_SUBJECT_NAME=KEYPRESS_EVENT_NAME+"_0",observeKeypress=function(e,r){var t,n=getDefaultDocument();n&&(t=addListenerToDocument(n,KEYPRESS_EVENT_NAME,e,!0),r(function(){t()}))},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 i(r,t){var n;return function(e){a=void 0,e&&n!==e&&t({event:n=e,name:r})}}var a;return[i,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)&&(a||i("input",n)(e),clearTimeout(a),a=window.setTimeout(function(){a=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 i=[];return[function(){return i},function(e){var r=n(e);r&&(e=__assign(__assign({},r),{timestamp:e.timestamp||now()}),i=0<=t&&i.length+1>t?o(__spreadArray(__spreadArray([],__read(i),!1),[e],!1),t):__spreadArray(__spreadArray([],__read(i),!1),[e],!1))}]},breadcrumbGetterWithDomObserver=function(e,r,t){var n=__read(r,2),o=n[0],i=n[1],a=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(a,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(i[0](n(triggerHandlers(r,DOM_EVENT_TYPE))))),[c,u]},BREADCRUMB_MONITOR_PLUGIN_NAME="breadcrumb",defaultConfig={maxBreadcrumbs:20,dom:!0};function BreadcrumbMonitorPlugin(i){i.on("init",function(){var e,r,t,n,o=getPluginConfig(i,BREADCRUMB_MONITOR_PLUGIN_NAME,defaultConfig);o&&(o=(r=__read(breadcrumbGetterWithDomObserver(e=[],[initSubjectInGlobal(i,clickSubject),initSubjectInGlobal(i,keypressSubject)],o),2))[0],t=r[1],i.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(){i.off("report",n)}),registerTearDownGroup(i,BREADCRUMB_MONITOR_PLUGIN_NAME,JS_ERROR_EV_TYPE,e),i.provide("getBreadcrumbs",o),i.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; |
@@ -255,2 +255,3 @@ interface ContextAgent { | ||
plugins: PluginsConfig; | ||
pluginPathPrefix?: string; | ||
apdex?: ApdexConfig; | ||
@@ -773,3 +774,3 @@ sample?: SampleConfig; | ||
interface AjaxMonitorConfig { | ||
interface AjaxMonitorProps { | ||
autoWrap?: boolean; | ||
@@ -786,3 +787,3 @@ setContextAtReq: () => (ev: HttpReport) => void; | ||
} | ||
interface FetchMonitorConfig extends AjaxMonitorConfig { | ||
interface FetchMonitorProps extends AjaxMonitorProps { | ||
} | ||
@@ -795,2 +796,3 @@ interface TraceConfig { | ||
declare const AJAX_MONITOR_PLUGIN_NAME = "ajax"; | ||
declare type AjaxMonitorConfig = Omit<AjaxMonitorProps, 'setContextAtReq' | 'setTraceHeader'>; | ||
interface AjaxMonitorPluginConfig { | ||
@@ -823,2 +825,3 @@ [AJAX_MONITOR_PLUGIN_NAME]?: Partial<AjaxMonitorConfig> | boolean; | ||
declare const FETCH_MONITOR_PLUGIN_NAME = "fetch"; | ||
declare type FetchMonitorConfig = Omit<FetchMonitorProps, 'setContextAtReq' | 'setTraceHeader'>; | ||
interface FetchMonitorPluginConfig { | ||
@@ -915,2 +918,3 @@ [FETCH_MONITOR_PLUGIN_NAME]?: Partial<FetchMonitorConfig> | boolean; | ||
mpfid = "mpfid", | ||
inp = "inp", | ||
lcp = "lcp", | ||
@@ -929,4 +933,2 @@ cls = "cls", | ||
declare const PERFORMANCE_MONITOR_PLUGIN_NAME = "performance"; | ||
declare type CustomPerformancePayload = Partial<Omit<PerformancePayload, 'name' | 'value'>> & Pick<PerformancePayload, 'name' | 'value'>; | ||
declare type WithSendPerformance<C extends WebClient> = C & { | ||
@@ -937,5 +939,7 @@ sendCustomPerfMetric?: (metric: CustomPerformancePayload) => void; | ||
}; | ||
declare const PERFORMANCE_MONITOR_PLUGIN_NAME = "performance"; | ||
interface PerformanceMonitorPluginConfig { | ||
[PERFORMANCE_MONITOR_PLUGIN_NAME]?: Partial<PerformanceMonitorUserConfig> | boolean; | ||
} | ||
declare type CustomPerformancePayload = Partial<Omit<PerformancePayload, 'name' | 'value'>> & Pick<PerformancePayload, 'name' | 'value'>; | ||
@@ -952,2 +956,3 @@ declare const TTI_MONITOR_PLUGIN_NAME = "tti"; | ||
declare const FMP_MONITOR_PLUGIN_NAME = "fmp"; | ||
interface FMPMonitorPluginConfig { | ||
@@ -957,3 +962,3 @@ [FMP_MONITOR_PLUGIN_NAME]?: Partial<FMPMonitorConfig> | boolean; | ||
interface BlankScreenMonitorConfig { | ||
interface BlankScreenProps { | ||
autoDetect?: boolean; | ||
@@ -970,2 +975,4 @@ threshold: number; | ||
quality: number; | ||
initDetTime: number; | ||
runDetTime: number; | ||
} | ||
@@ -976,2 +983,3 @@ interface DetectBlankScreen { | ||
declare type BlankScreenMonitorConfig = Omit<BlankScreenProps, 'ssUrl'>; | ||
declare const BLANK_SCREEN_MONITOR_PLUGIN_NAME = "blankScreen"; | ||
@@ -978,0 +986,0 @@ declare type WithDetectBlankScreen<C extends WebClient> = C & { |
@@ -255,2 +255,3 @@ interface ContextAgent { | ||
plugins: PluginsConfig; | ||
pluginPathPrefix?: string; | ||
apdex?: ApdexConfig; | ||
@@ -773,3 +774,3 @@ sample?: SampleConfig; | ||
interface AjaxMonitorConfig { | ||
interface AjaxMonitorProps { | ||
autoWrap?: boolean; | ||
@@ -786,3 +787,3 @@ setContextAtReq: () => (ev: HttpReport) => void; | ||
} | ||
interface FetchMonitorConfig extends AjaxMonitorConfig { | ||
interface FetchMonitorProps extends AjaxMonitorProps { | ||
} | ||
@@ -795,2 +796,3 @@ interface TraceConfig { | ||
declare const AJAX_MONITOR_PLUGIN_NAME = "ajax"; | ||
declare type AjaxMonitorConfig = Omit<AjaxMonitorProps, 'setContextAtReq' | 'setTraceHeader'>; | ||
interface AjaxMonitorPluginConfig { | ||
@@ -823,2 +825,3 @@ [AJAX_MONITOR_PLUGIN_NAME]?: Partial<AjaxMonitorConfig> | boolean; | ||
declare const FETCH_MONITOR_PLUGIN_NAME = "fetch"; | ||
declare type FetchMonitorConfig = Omit<FetchMonitorProps, 'setContextAtReq' | 'setTraceHeader'>; | ||
interface FetchMonitorPluginConfig { | ||
@@ -915,2 +918,3 @@ [FETCH_MONITOR_PLUGIN_NAME]?: Partial<FetchMonitorConfig> | boolean; | ||
mpfid = "mpfid", | ||
inp = "inp", | ||
lcp = "lcp", | ||
@@ -929,4 +933,2 @@ cls = "cls", | ||
declare const PERFORMANCE_MONITOR_PLUGIN_NAME = "performance"; | ||
declare type CustomPerformancePayload = Partial<Omit<PerformancePayload, 'name' | 'value'>> & Pick<PerformancePayload, 'name' | 'value'>; | ||
declare type WithSendPerformance<C extends WebClient$1> = C & { | ||
@@ -937,5 +939,7 @@ sendCustomPerfMetric?: (metric: CustomPerformancePayload) => void; | ||
}; | ||
declare const PERFORMANCE_MONITOR_PLUGIN_NAME = "performance"; | ||
interface PerformanceMonitorPluginConfig { | ||
[PERFORMANCE_MONITOR_PLUGIN_NAME]?: Partial<PerformanceMonitorUserConfig> | boolean; | ||
} | ||
declare type CustomPerformancePayload = Partial<Omit<PerformancePayload, 'name' | 'value'>> & Pick<PerformancePayload, 'name' | 'value'>; | ||
@@ -952,2 +956,3 @@ declare const TTI_MONITOR_PLUGIN_NAME = "tti"; | ||
declare const FMP_MONITOR_PLUGIN_NAME = "fmp"; | ||
interface FMPMonitorPluginConfig { | ||
@@ -957,3 +962,3 @@ [FMP_MONITOR_PLUGIN_NAME]?: Partial<FMPMonitorConfig> | boolean; | ||
interface BlankScreenMonitorConfig { | ||
interface BlankScreenProps { | ||
autoDetect?: boolean; | ||
@@ -970,2 +975,4 @@ threshold: number; | ||
quality: number; | ||
initDetTime: number; | ||
runDetTime: number; | ||
} | ||
@@ -976,2 +983,3 @@ interface DetectBlankScreen { | ||
declare type BlankScreenMonitorConfig = Omit<BlankScreenProps, 'ssUrl'>; | ||
declare const BLANK_SCREEN_MONITOR_PLUGIN_NAME = "blankScreen"; | ||
@@ -978,0 +986,0 @@ declare type WithDetectBlankScreen<C extends WebClient$1> = C & { |
@@ -255,2 +255,3 @@ interface ContextAgent { | ||
plugins: PluginsConfig; | ||
pluginPathPrefix?: string; | ||
apdex?: ApdexConfig; | ||
@@ -773,3 +774,3 @@ sample?: SampleConfig; | ||
interface AjaxMonitorConfig { | ||
interface AjaxMonitorProps { | ||
autoWrap?: boolean; | ||
@@ -786,3 +787,3 @@ setContextAtReq: () => (ev: HttpReport) => void; | ||
} | ||
interface FetchMonitorConfig extends AjaxMonitorConfig { | ||
interface FetchMonitorProps extends AjaxMonitorProps { | ||
} | ||
@@ -795,2 +796,3 @@ interface TraceConfig { | ||
declare const AJAX_MONITOR_PLUGIN_NAME = "ajax"; | ||
declare type AjaxMonitorConfig = Omit<AjaxMonitorProps, 'setContextAtReq' | 'setTraceHeader'>; | ||
interface AjaxMonitorPluginConfig { | ||
@@ -823,2 +825,3 @@ [AJAX_MONITOR_PLUGIN_NAME]?: Partial<AjaxMonitorConfig> | boolean; | ||
declare const FETCH_MONITOR_PLUGIN_NAME = "fetch"; | ||
declare type FetchMonitorConfig = Omit<FetchMonitorProps, 'setContextAtReq' | 'setTraceHeader'>; | ||
interface FetchMonitorPluginConfig { | ||
@@ -915,2 +918,3 @@ [FETCH_MONITOR_PLUGIN_NAME]?: Partial<FetchMonitorConfig> | boolean; | ||
mpfid = "mpfid", | ||
inp = "inp", | ||
lcp = "lcp", | ||
@@ -929,4 +933,2 @@ cls = "cls", | ||
declare const PERFORMANCE_MONITOR_PLUGIN_NAME = "performance"; | ||
declare type CustomPerformancePayload = Partial<Omit<PerformancePayload, 'name' | 'value'>> & Pick<PerformancePayload, 'name' | 'value'>; | ||
declare type WithSendPerformance<C extends WebClient$3> = C & { | ||
@@ -937,5 +939,7 @@ sendCustomPerfMetric?: (metric: CustomPerformancePayload) => void; | ||
}; | ||
declare const PERFORMANCE_MONITOR_PLUGIN_NAME = "performance"; | ||
interface PerformanceMonitorPluginConfig { | ||
[PERFORMANCE_MONITOR_PLUGIN_NAME]?: Partial<PerformanceMonitorUserConfig> | boolean; | ||
} | ||
declare type CustomPerformancePayload = Partial<Omit<PerformancePayload, 'name' | 'value'>> & Pick<PerformancePayload, 'name' | 'value'>; | ||
@@ -952,2 +956,3 @@ declare const TTI_MONITOR_PLUGIN_NAME = "tti"; | ||
declare const FMP_MONITOR_PLUGIN_NAME = "fmp"; | ||
interface FMPMonitorPluginConfig { | ||
@@ -957,3 +962,3 @@ [FMP_MONITOR_PLUGIN_NAME]?: Partial<FMPMonitorConfig> | boolean; | ||
interface BlankScreenMonitorConfig { | ||
interface BlankScreenProps { | ||
autoDetect?: boolean; | ||
@@ -970,2 +975,4 @@ threshold: number; | ||
quality: number; | ||
initDetTime: number; | ||
runDetTime: number; | ||
} | ||
@@ -976,2 +983,3 @@ interface DetectBlankScreen { | ||
declare type BlankScreenMonitorConfig = Omit<BlankScreenProps, 'ssUrl'>; | ||
declare const BLANK_SCREEN_MONITOR_PLUGIN_NAME = "blankScreen"; | ||
@@ -978,0 +986,0 @@ declare type WithDetectBlankScreen<C extends WebClient$3> = C & { |
@@ -76,2 +76,5 @@ /*! ***************************************************************************** | ||
} | ||
function isUndefined(o) { | ||
return o === undefined; | ||
} | ||
function isInstanceOf(wat, base) { | ||
@@ -511,3 +514,3 @@ try { | ||
var location = getDefaultBrowser() && getDefaultLocation(); | ||
return location === null || location === void 0 ? void 0 : location.href; | ||
return location ? location.href : ''; | ||
} | ||
@@ -701,2 +704,16 @@ | ||
var addListenerToWindow = function (w, type, listener, options) { | ||
if (options === void 0) { options = false; } | ||
w.addEventListener(type, listener, options); | ||
return function () { | ||
w.removeEventListener(type, listener, options); | ||
}; | ||
}; | ||
var addListenerToDocument = function (d, type, listener, options) { | ||
if (options === void 0) { options = false; } | ||
d.addEventListener(type, listener, options); | ||
return function () { | ||
d.removeEventListener(type, listener, options); | ||
}; | ||
}; | ||
var getConfig = function (c, defaultConfig) { | ||
@@ -832,7 +849,9 @@ if (isObject(c)) { | ||
}; | ||
var bufferedObserver = function (type) { | ||
var bufferedObserver = function (type, durationThreshold) { | ||
if (!PerformanceObserver || !observer) | ||
return onFail && onFail(); | ||
try { | ||
observer.observe({ type: type, buffered: true }); | ||
var options = { type: type, buffered: true }; | ||
!isUndefined(durationThreshold) && (options.durationThreshold = durationThreshold); | ||
observer.observe(options); | ||
} | ||
@@ -889,5 +908,5 @@ catch (_a) { | ||
return; | ||
document.addEventListener(CLICK_EVENT_NAME, next, true); | ||
var removeListener = addListenerToDocument(document, CLICK_EVENT_NAME, next, true); | ||
tearDown(function () { | ||
document.removeEventListener(CLICK_EVENT_NAME, next, true); | ||
removeListener(); | ||
}); | ||
@@ -1091,5 +1110,5 @@ }; | ||
return; | ||
window.addEventListener('error', next, true); | ||
var removeListener = addListenerToWindow(window, 'error', next, true); | ||
tearDown(function () { | ||
window.removeEventListener('error', next, true); | ||
removeListener(); | ||
}); | ||
@@ -1103,5 +1122,5 @@ }; | ||
return; | ||
window.addEventListener('unhandledrejection', next, true); | ||
var removeListener = addListenerToWindow(window, 'unhandledrejection', next, true); | ||
tearDown(function () { | ||
window.removeEventListener('unhandledrejection', next, true); | ||
removeListener(); | ||
}); | ||
@@ -1237,3 +1256,2 @@ }; | ||
var PAGE_ACTIVITY_DELAY = 100; | ||
var MAX_PAGE_ACTIVITY_DELAY = 10000; | ||
var ROOT_TAGS = ['BODY', 'HTML', 'HEAD']; | ||
@@ -1246,3 +1264,3 @@ var SVG_TAG = 'SVG'; | ||
*/ | ||
var waitActionComplete = function (cb, forceClear, win) { | ||
var waitActionComplete = function (win, cb, forceClear, maxTimeOut) { | ||
var idleTimer; | ||
@@ -1262,5 +1280,5 @@ var maxIdleTimer; | ||
maxIdleTimer = win.setTimeout(function () { | ||
cb(); | ||
cb(true); | ||
forceClear(); | ||
}, MAX_PAGE_ACTIVITY_DELAY); | ||
}, maxTimeOut); | ||
notify(); | ||
@@ -1354,2 +1372,3 @@ }; | ||
var MIN_LONG_TASK = 50; | ||
var MAX_ACTIVITY_DELAY = 10000; | ||
/** | ||
@@ -1434,3 +1453,3 @@ * Hook XHR & fetch to monitor the number of incomplete requests on the current page. | ||
}; | ||
var _d = __read(waitActionComplete(reportActionIfAllowed, resetAction, window), 3), start = _d[0], notify = _d[1], complete = _d[2]; | ||
var _d = __read(waitActionComplete(window, reportActionIfAllowed, resetAction, MAX_ACTIVITY_DELAY), 3), start = _d[0], notify = _d[1], complete = _d[2]; | ||
// notify if meet xhr and fetch | ||
@@ -1541,4 +1560,3 @@ var incompleteReq = applyIncompleteReq(tearDownGroup, [xhrObserver, fetchObserver], notify); | ||
if (arrayIncludes(SUPPORT_TYPES, t)) { | ||
document.addEventListener(t, handleEvent, EVENT_LISTENER_OPTIONS); | ||
tearDownGroup.push(function () { return document.removeEventListener(t, handleEvent, EVENT_LISTENER_OPTIONS); }); | ||
tearDownGroup.push(addListenerToDocument(document, t, handleEvent, EVENT_LISTENER_OPTIONS)); | ||
} | ||
@@ -1558,2 +1576,3 @@ }); | ||
types: ["click" /* CLICK */], | ||
pure: true, | ||
}; | ||
@@ -1586,2 +1605,3 @@ function ActionMonitorBasePlugin(client, config) { | ||
var MAX_PAGE_DELAY = 30000; | ||
var getSPA = function (report, tearDownGroup, _a) { | ||
@@ -1612,3 +1632,3 @@ 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]; | ||
// get schedule function and set an empty forceClear | ||
var _c = __read(waitActionComplete(reportSPAIfAllowed, noop, window), 3), start = _c[0], notify = _c[1], complete = _c[2]; | ||
var _c = __read(waitActionComplete(window, reportSPAIfAllowed, noop, MAX_PAGE_DELAY), 3), start = _c[0], notify = _c[1], complete = _c[2]; | ||
// request | ||
@@ -1615,0 +1635,0 @@ var incompleteReq = applyIncompleteReq(tearDownGroup, [xhrObserver, fetchObserver], notify); |
@@ -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)||[]}]},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; | ||
"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 isUndefined(e){return void 0===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 e?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 addListenerToWindow=function(e,t,r,n){return void 0===n&&(n=!1),e.addEventListener(t,r,n),function(){e.removeEventListener(t,r,n)}},addListenerToDocument=function(e,t,r,n){return void 0===n&&(n=!1),e.addEventListener(t,r,n),function(){e.removeEventListener(t,r,n)}},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(n,o,i){var u=n&&new n(function(e,n){e.getEntries?e.getEntries().forEach(function(e,t,r){return o(e,t,r,n)}):i&&i()});return[function(e){if(!n||!u)return i&&i();try{u.observe({entryTypes:e})}catch(e){return i&&i()}},function(e,t){if(!n||!u)return i&&i();try{var r={type:e,buffered:!0};isUndefined(t)||(r.durationThreshold=t),u.observe(r)}catch(e){return i&&i()}u.observe({type:e,buffered:!1})},function(){return u&&u.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,n=getDefaultDocument();n&&(r=addListenerToDocument(n,CLICK_EVENT_NAME,e,!0),t(function(){r()}))},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,n=getDefaultBrowser();n&&(r=addListenerToWindow(n,"error",e,!0),t(function(){r()}))},errorSubject=[ERROR_SUBJECT_NAME,observeError],PROMISE_REJECTION_SUBJECT_NAME="perr_0",observePromiseRejection=function(e,t){var r,n=getDefaultBrowser();n&&(r=addListenerToWindow(n,"unhandledrejection",e,!0),t(function(){r()}))},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,ROOT_TAGS=["BODY","HTML","HEAD"],SVG_TAG="SVG",DEFAULT_ATTR_NAME="data-apm-action",waitActionComplete=function(e,t,r,n){function o(){e.clearTimeout(i),a&&(i=e.setTimeout(function(){t()},PAGE_ACTIVITY_DELAY))}var i,u,a=!1;return[function(){a=!0,e.clearTimeout(u),u=e.setTimeout(function(){t(!0),r()},n),o()},o,function(){a=!1,e.clearTimeout(i),e.clearTimeout(u)}]},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,MAX_ACTIVITY_DELAY=1e4,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(R).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(){A(),_&&(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(window,n,i,MAX_ACTIVITY_DELAY),3),h=r[0],g=r[1],A=r[2],R=applyIncompleteReq(t,[c,s],g),c=__read(applyMutationObserver(MutationObserver,g),2),s=c[0],c=c[1];s(),t.push(c),t.push(A),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)&&t.push(addListenerToDocument(document,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"],pure:!0};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 MAX_PAGE_DELAY=3e4,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(window,n,noop,MAX_PAGE_DELAY),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; |
@@ -255,2 +255,3 @@ interface ContextAgent { | ||
plugins: PluginsConfig; | ||
pluginPathPrefix?: string; | ||
apdex?: ApdexConfig; | ||
@@ -773,3 +774,3 @@ sample?: SampleConfig; | ||
interface AjaxMonitorConfig { | ||
interface AjaxMonitorProps { | ||
autoWrap?: boolean; | ||
@@ -786,3 +787,3 @@ setContextAtReq: () => (ev: HttpReport) => void; | ||
} | ||
interface FetchMonitorConfig extends AjaxMonitorConfig { | ||
interface FetchMonitorProps extends AjaxMonitorProps { | ||
} | ||
@@ -795,2 +796,3 @@ interface TraceConfig { | ||
declare const AJAX_MONITOR_PLUGIN_NAME = "ajax"; | ||
declare type AjaxMonitorConfig = Omit<AjaxMonitorProps, 'setContextAtReq' | 'setTraceHeader'>; | ||
interface AjaxMonitorPluginConfig { | ||
@@ -823,2 +825,3 @@ [AJAX_MONITOR_PLUGIN_NAME]?: Partial<AjaxMonitorConfig> | boolean; | ||
declare const FETCH_MONITOR_PLUGIN_NAME = "fetch"; | ||
declare type FetchMonitorConfig = Omit<FetchMonitorProps, 'setContextAtReq' | 'setTraceHeader'>; | ||
interface FetchMonitorPluginConfig { | ||
@@ -915,2 +918,3 @@ [FETCH_MONITOR_PLUGIN_NAME]?: Partial<FetchMonitorConfig> | boolean; | ||
mpfid = "mpfid", | ||
inp = "inp", | ||
lcp = "lcp", | ||
@@ -929,4 +933,2 @@ cls = "cls", | ||
declare const PERFORMANCE_MONITOR_PLUGIN_NAME = "performance"; | ||
declare type CustomPerformancePayload = Partial<Omit<PerformancePayload, 'name' | 'value'>> & Pick<PerformancePayload, 'name' | 'value'>; | ||
declare type WithSendPerformance<C extends WebClient$1> = C & { | ||
@@ -937,5 +939,7 @@ sendCustomPerfMetric?: (metric: CustomPerformancePayload) => void; | ||
}; | ||
declare const PERFORMANCE_MONITOR_PLUGIN_NAME = "performance"; | ||
interface PerformanceMonitorPluginConfig { | ||
[PERFORMANCE_MONITOR_PLUGIN_NAME]?: Partial<PerformanceMonitorUserConfig> | boolean; | ||
} | ||
declare type CustomPerformancePayload = Partial<Omit<PerformancePayload, 'name' | 'value'>> & Pick<PerformancePayload, 'name' | 'value'>; | ||
@@ -952,2 +956,3 @@ declare const TTI_MONITOR_PLUGIN_NAME = "tti"; | ||
declare const FMP_MONITOR_PLUGIN_NAME = "fmp"; | ||
interface FMPMonitorPluginConfig { | ||
@@ -957,3 +962,3 @@ [FMP_MONITOR_PLUGIN_NAME]?: Partial<FMPMonitorConfig> | boolean; | ||
interface BlankScreenMonitorConfig { | ||
interface BlankScreenProps { | ||
autoDetect?: boolean; | ||
@@ -970,2 +975,4 @@ threshold: number; | ||
quality: number; | ||
initDetTime: number; | ||
runDetTime: number; | ||
} | ||
@@ -976,2 +983,3 @@ interface DetectBlankScreen { | ||
declare type BlankScreenMonitorConfig = Omit<BlankScreenProps, 'ssUrl'>; | ||
declare const BLANK_SCREEN_MONITOR_PLUGIN_NAME = "blankScreen"; | ||
@@ -978,0 +986,0 @@ declare type WithDetectBlankScreen<C extends WebClient$1> = C & { |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __assign=function(){return(__assign=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++)for(var o in e=arguments[t])Object.prototype.hasOwnProperty.call(e,o)&&(r[o]=e[o]);return r}).apply(this,arguments)};function __read(r,e){var t="function"==typeof Symbol&&r[Symbol.iterator];if(!t)return r;var n,o,i=t.call(r),u=[];try{for(;(void 0===e||0<e--)&&!(n=i.next()).done;)u.push(n.value)}catch(r){o={error:r}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return u}function __spreadArray(r,e,t){if(t||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 r.concat(n||Array.prototype.slice.call(e))}var noop=function(){return{}};function isObject(r){return"object"==typeof r&&null!==r}function isInstanceOf(r,e){try{return r instanceof e}catch(r){return!1}}var objProto=Object.prototype;function isPlainObject(r){if(isObject(r)){if("function"!=typeof Object.getPrototypeOf)return"[object Object]"===objProto.toString.call(r);r=Object.getPrototypeOf(r);return r===objProto||null===r}return!1}function isArray(r){return"[object Array]"===objProto.toString.call(r)}function isFunction(r){return"function"==typeof r}function isString(r){return"string"==typeof r}function isError(r){switch(Object.prototype.toString.call(r)){case"[object Error]":case"[object Exception]":case"[object DOMError]":case"[object DOMException]":return!0;default:return r instanceof Error}}function isEvent(r){return"undefined"!=typeof Event&&isInstanceOf(r,Event)}function isErrorEvent(r){return"[object ErrorEvent]"===Object.prototype.toString.call(r)}function isPromiseRejectionEvent(r){return"[object PromiseRejectionEvent]"===Object.prototype.toString.call(r)}var pick=function(t,r){return t&&isObject(t)?r.reduce(function(r,e){return r[e]=t[e],r},{}):t};function getRegexp(r){return isArray(r)&&r.length?joinRegExp(r):null}function joinRegExp(r){for(var e=[],t=r.length,n=0;n<t;n++){var o=r[n];isString(o)?e.push(o.replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")):o&&o.source&&e.push(o.source)}return new RegExp(e.join("|"),"i")}function safeStringify(r){try{return isString(r)?r:JSON.stringify(r)}catch(r){return"[FAILED_TO_STRINGIFY]:"+String(r)}}var hookObjectProperty=function(i,u,c,a){return void 0===a&&(a=!0),function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];if(!i)return noop;var t=i[u],n=c.apply(void 0,__spreadArray([t],__read(r),!1)),o=n;return isFunction(o)&&a&&(o=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];try{return n.apply(this,e)}catch(r){return isFunction(t)&&t.apply(this,e)}}),i[u]=o,function(r){r||(o===i[u]?i[u]=t:n=t)}}},registerTearDownGroup=function(r,e,t,n){return r.destroyAgent.set(e,t,n)};function initSubjectInGlobal(r,e){return r.initSubject(e)}function getDefaultBrowser(){if("object"==typeof window&&isObject(window))return window}function getDefaultXMLHttpRequest(){if("function"==typeof XMLHttpRequest&&isFunction(XMLHttpRequest))return XMLHttpRequest}var getGlobalRegistry=function(r){if(r)return r.__SLARDAR_REGISTRY__||(r.__SLARDAR_REGISTRY__={Slardar:{plugins:[],errors:[],subject:{}}}),r.__SLARDAR_REGISTRY__.Slardar},reportSelfError=function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var t=getGlobalRegistry(getDefaultBrowser());t&&(t.errors||(t.errors=[]),t.errors.push(r))},getConfig=function(r,e){return isObject(r)?__assign(__assign({},e),r):!!r&&e},JS_ERROR_EV_TYPE="js_error";function getPluginConfig(r,e,t){e=null===(r=r.config())||void 0===r?void 0:r.plugins[e];return getConfig(e,t)}var ERROR_FIELDS=["name","message","stack","filename","lineno","colno"],normalize=function(r){var e;return isError(r)?e=pick(r,ERROR_FIELDS):(isPlainObject(r)||isEvent(r)||isString(r))&&(e={message:safeStringify(r)}),e},normalizeError=function(r){return normalize(r.error)},normalizeException=function(r){var e;try{var t=void 0;if("reason"in r?t=r.reason:"detail"in r&&"reason"in r.detail&&(t=r.detail.reason),t){var n=normalize(t);return __assign(__assign({},n),{name:null!==(e=n&&n.name)&&void 0!==e?e:"UnhandledRejection"})}}catch(r){}},normalizeUnknownError=function(r){return(isErrorEvent(r)?normalizeError:isPromiseRejectionEvent(r)?normalizeException:normalize)(r)},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,r){function u(r,t){if(!isFunction(r))return r;var n={type:DEFAULT_SOURCE_TYPE,data:__assign({},t)},e=r._w_||(r._w_=function(){try{return(r.handleEvent&&isFunction(r.handleEvent)?r.handleEvent:r).apply(this,[].map.call(arguments,function(r){return u(r,t)}))}catch(r){var e=normalize(r);throw e&&o({source:n,error:e}),r}});return e._hook_=!0,e}var e=getDefaultBrowser(),t=getDefaultXMLHttpRequest(),n=[];e&&n.push.apply(n,__spreadArray([],__read(DEFAULT_TIME_FUNCTION.filter(function(r){return e[r]}).map(function(o){return hookObjectProperty(e,o,function(n){return function(r){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];return n&&n.call.apply(n,__spreadArray([this,u(r,{function:o})],__read(e),!1))}},!1)()})),!1)),t&&t.prototype&&n.push(hookObjectProperty(t.prototype,"send",function(n){return function(){for(var e=this,r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return xmlHttpRequestProps.filter(function(r){return e[r]&&!e[r]._hook_}).forEach(function(r){e[r]=u(e[r],{function:r})}),n.apply(this,r)}},!1)()),DEFAULT_EVENT_TARGET.forEach(function(i){var r=e&&e[i]&&e[i].prototype;r&&r[ADD_EVENT_LISTENER]&&(n.push(hookObjectProperty(r,ADD_EVENT_LISTENER,function(o){return function(r,e,t){try{var n=e.handleEvent;isFunction(n)&&(e.handleEvent=u(n,{function:"handleEvent",target:i}))}catch(r){}return o&&o.call(this,r,u(e,{function:ADD_EVENT_LISTENER,target:i}),t)}},!1)()),n.push(hookObjectProperty(r,REMOVE_EVENT_LISTENER,function(n){return function(r,e,t){return null!=e&&e._w_&&n.call(this,r,e._w_,t),n.call(this,r,e,t)}},!1)()))}),r(function(){return n.forEach(function(r){return r()})})},ASYNC_ERROR_SUBJECT_NAME="async_error_0",asyncErrorWithSourceSubject=[ASYNC_ERROR_SUBJECT_NAME,observeAsyncErrorWithSource],ERROR_SUBJECT_NAME="err_0",observeError=function(r,e){var t=getDefaultBrowser();t&&(t.addEventListener("error",r,!0),e(function(){t.removeEventListener("error",r,!0)}))},errorSubject=[ERROR_SUBJECT_NAME,observeError],PROMISE_REJECTION_SUBJECT_NAME="perr_0",observePromiseRejection=function(r,e){var t=getDefaultBrowser();t&&(t.addEventListener("unhandledrejection",r,!0),e(function(){t.removeEventListener("unhandledrejection",r,!0)}))},promiseRejectionSubject=[PROMISE_REJECTION_SUBJECT_NAME,observePromiseRejection],isSameErrorString=function(r,e){return r&&e&&r===e},shouldDropEvent=function(r,e){return!(!r||!e)&&!(!isSameErrorString(r.message,e.message)||!isSameErrorString(r.stack,e.stack))},dedupe=function(){var e;return function(r){try{if(shouldDropEvent(r,e))return void(e=r)}catch(r){reportSelfError(r)}return e=r}},jsErrorGetterWithContext=function(o,r,e,t){function n(r){var e=r.error,t=r.extra,n=r.react,r=r.source;!(e=E?f(e):e)||!e.message||l&&l.test(e.message)||o({ev_type:JS_ERROR_EV_TYPE,payload:{error:e,breadcrumbs:[],extra:t,react:n,source:r}})}var i=__read(e,3),u=i[0],c=i[1],a=i[2],s=t.ignoreErrors,e=t.onerror,i=t.onunhandledrejection,E=t.dedupe,t=t.captureGlobalAsync,l=getRegexp(s),f=dedupe();return e&&r.push(u[0](function(r){return n({error:normalizeError(r),source:{type:"onerror"}})})),i&&r.push(c[0](function(r){return n({error:normalizeException(r),source:{type:"onunhandledrejection"}})})),t&&r.push(a()[0](function(r){n(r)})),function(r,e,t){return n({error:normalizeUnknownError(r),extra:e,react:t,source:{type:"manual"}})}},JS_ERROR_MONITOR_PLUGIN_NAME="jsError",defaultConfig={ignoreErrors:[],onerror:!0,onunhandledrejection:!0,captureGlobalAsync:!1,dedupe:!0};function JsErrorMonitorPlugin(t){t.on("init",function(){window.removeEventListener("error",t.pcErr,!0),window.removeEventListener("unhandledrejection",t.pcRej,!0);var r,e=getPluginConfig(t,JS_ERROR_MONITOR_PLUGIN_NAME,defaultConfig);e&&(e=jsErrorGetterWithContext(function(r){t.getBreadcrumbs&&(r.payload.breadcrumbs=t.getBreadcrumbs()),t.report(r)},r=[],[initSubjectInGlobal(t,errorSubject),initSubjectInGlobal(t,promiseRejectionSubject),function(){return initSubjectInGlobal(t,asyncErrorWithSourceSubject)}],e),registerTearDownGroup(t,JS_ERROR_MONITOR_PLUGIN_NAME,JS_ERROR_EV_TYPE,r),t.provide("captureException",e))})}var JS_ERROR_INTEGRATION_NAME=JS_ERROR_MONITOR_PLUGIN_NAME,jsErrorPlugin=function(){return{name:JS_ERROR_INTEGRATION_NAME,setup:function(r){JsErrorMonitorPlugin(r)}}};exports.JS_ERROR_INTEGRATION_NAME=JS_ERROR_INTEGRATION_NAME,exports.jsErrorPlugin=jsErrorPlugin; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __assign=function(){return(__assign=Object.assign||function(r){for(var e,t=1,n=arguments.length;t<n;t++)for(var o in e=arguments[t])Object.prototype.hasOwnProperty.call(e,o)&&(r[o]=e[o]);return r}).apply(this,arguments)};function __read(r,e){var t="function"==typeof Symbol&&r[Symbol.iterator];if(!t)return r;var n,o,i=t.call(r),u=[];try{for(;(void 0===e||0<e--)&&!(n=i.next()).done;)u.push(n.value)}catch(r){o={error:r}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return u}function __spreadArray(r,e,t){if(t||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 r.concat(n||Array.prototype.slice.call(e))}var noop=function(){return{}};function isObject(r){return"object"==typeof r&&null!==r}function isInstanceOf(r,e){try{return r instanceof e}catch(r){return!1}}var objProto=Object.prototype;function isPlainObject(r){if(isObject(r)){if("function"!=typeof Object.getPrototypeOf)return"[object Object]"===objProto.toString.call(r);r=Object.getPrototypeOf(r);return r===objProto||null===r}return!1}function isArray(r){return"[object Array]"===objProto.toString.call(r)}function isFunction(r){return"function"==typeof r}function isString(r){return"string"==typeof r}function isError(r){switch(Object.prototype.toString.call(r)){case"[object Error]":case"[object Exception]":case"[object DOMError]":case"[object DOMException]":return!0;default:return r instanceof Error}}function isEvent(r){return"undefined"!=typeof Event&&isInstanceOf(r,Event)}function isErrorEvent(r){return"[object ErrorEvent]"===Object.prototype.toString.call(r)}function isPromiseRejectionEvent(r){return"[object PromiseRejectionEvent]"===Object.prototype.toString.call(r)}var pick=function(t,r){return t&&isObject(t)?r.reduce(function(r,e){return r[e]=t[e],r},{}):t};function getRegexp(r){return isArray(r)&&r.length?joinRegExp(r):null}function joinRegExp(r){for(var e=[],t=r.length,n=0;n<t;n++){var o=r[n];isString(o)?e.push(o.replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")):o&&o.source&&e.push(o.source)}return new RegExp(e.join("|"),"i")}function safeStringify(r){try{return isString(r)?r:JSON.stringify(r)}catch(r){return"[FAILED_TO_STRINGIFY]:"+String(r)}}var hookObjectProperty=function(i,u,c,a){return void 0===a&&(a=!0),function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];if(!i)return noop;var t=i[u],n=c.apply(void 0,__spreadArray([t],__read(r),!1)),o=n;return isFunction(o)&&a&&(o=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];try{return n.apply(this,e)}catch(r){return isFunction(t)&&t.apply(this,e)}}),i[u]=o,function(r){r||(o===i[u]?i[u]=t:n=t)}}},registerTearDownGroup=function(r,e,t,n){return r.destroyAgent.set(e,t,n)};function initSubjectInGlobal(r,e){return r.initSubject(e)}function getDefaultBrowser(){if("object"==typeof window&&isObject(window))return window}function getDefaultXMLHttpRequest(){if("function"==typeof XMLHttpRequest&&isFunction(XMLHttpRequest))return XMLHttpRequest}var getGlobalRegistry=function(r){if(r)return r.__SLARDAR_REGISTRY__||(r.__SLARDAR_REGISTRY__={Slardar:{plugins:[],errors:[],subject:{}}}),r.__SLARDAR_REGISTRY__.Slardar},reportSelfError=function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var t=getGlobalRegistry(getDefaultBrowser());t&&(t.errors||(t.errors=[]),t.errors.push(r))},addListenerToWindow=function(r,e,t,n){return void 0===n&&(n=!1),r.addEventListener(e,t,n),function(){r.removeEventListener(e,t,n)}},getConfig=function(r,e){return isObject(r)?__assign(__assign({},e),r):!!r&&e},JS_ERROR_EV_TYPE="js_error";function getPluginConfig(r,e,t){e=null===(r=r.config())||void 0===r?void 0:r.plugins[e];return getConfig(e,t)}var ERROR_FIELDS=["name","message","stack","filename","lineno","colno"],normalize=function(r){var e;return isError(r)?e=pick(r,ERROR_FIELDS):(isPlainObject(r)||isEvent(r)||isString(r))&&(e={message:safeStringify(r)}),e},normalizeError=function(r){return normalize(r.error)},normalizeException=function(r){var e;try{var t=void 0;if("reason"in r?t=r.reason:"detail"in r&&"reason"in r.detail&&(t=r.detail.reason),t){var n=normalize(t);return __assign(__assign({},n),{name:null!==(e=n&&n.name)&&void 0!==e?e:"UnhandledRejection"})}}catch(r){}},normalizeUnknownError=function(r){return(isErrorEvent(r)?normalizeError:isPromiseRejectionEvent(r)?normalizeException:normalize)(r)},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,r){function u(r,t){if(!isFunction(r))return r;var n={type:DEFAULT_SOURCE_TYPE,data:__assign({},t)},e=r._w_||(r._w_=function(){try{return(r.handleEvent&&isFunction(r.handleEvent)?r.handleEvent:r).apply(this,[].map.call(arguments,function(r){return u(r,t)}))}catch(r){var e=normalize(r);throw e&&o({source:n,error:e}),r}});return e._hook_=!0,e}var e=getDefaultBrowser(),t=getDefaultXMLHttpRequest(),n=[];e&&n.push.apply(n,__spreadArray([],__read(DEFAULT_TIME_FUNCTION.filter(function(r){return e[r]}).map(function(o){return hookObjectProperty(e,o,function(n){return function(r){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];return n&&n.call.apply(n,__spreadArray([this,u(r,{function:o})],__read(e),!1))}},!1)()})),!1)),t&&t.prototype&&n.push(hookObjectProperty(t.prototype,"send",function(n){return function(){for(var e=this,r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return xmlHttpRequestProps.filter(function(r){return e[r]&&!e[r]._hook_}).forEach(function(r){e[r]=u(e[r],{function:r})}),n.apply(this,r)}},!1)()),DEFAULT_EVENT_TARGET.forEach(function(i){var r=e&&e[i]&&e[i].prototype;r&&r[ADD_EVENT_LISTENER]&&(n.push(hookObjectProperty(r,ADD_EVENT_LISTENER,function(o){return function(r,e,t){try{var n=e.handleEvent;isFunction(n)&&(e.handleEvent=u(n,{function:"handleEvent",target:i}))}catch(r){}return o&&o.call(this,r,u(e,{function:ADD_EVENT_LISTENER,target:i}),t)}},!1)()),n.push(hookObjectProperty(r,REMOVE_EVENT_LISTENER,function(n){return function(r,e,t){return null!=e&&e._w_&&n.call(this,r,e._w_,t),n.call(this,r,e,t)}},!1)()))}),r(function(){return n.forEach(function(r){return r()})})},ASYNC_ERROR_SUBJECT_NAME="async_error_0",asyncErrorWithSourceSubject=[ASYNC_ERROR_SUBJECT_NAME,observeAsyncErrorWithSource],ERROR_SUBJECT_NAME="err_0",observeError=function(r,e){var t,n=getDefaultBrowser();n&&(t=addListenerToWindow(n,"error",r,!0),e(function(){t()}))},errorSubject=[ERROR_SUBJECT_NAME,observeError],PROMISE_REJECTION_SUBJECT_NAME="perr_0",observePromiseRejection=function(r,e){var t,n=getDefaultBrowser();n&&(t=addListenerToWindow(n,"unhandledrejection",r,!0),e(function(){t()}))},promiseRejectionSubject=[PROMISE_REJECTION_SUBJECT_NAME,observePromiseRejection],isSameErrorString=function(r,e){return r&&e&&r===e},shouldDropEvent=function(r,e){return!(!r||!e)&&!(!isSameErrorString(r.message,e.message)||!isSameErrorString(r.stack,e.stack))},dedupe=function(){var e;return function(r){try{if(shouldDropEvent(r,e))return void(e=r)}catch(r){reportSelfError(r)}return e=r}},jsErrorGetterWithContext=function(o,r,e,t){function n(r){var e=r.error,t=r.extra,n=r.react,r=r.source;!(e=E?f(e):e)||!e.message||l&&l.test(e.message)||o({ev_type:JS_ERROR_EV_TYPE,payload:{error:e,breadcrumbs:[],extra:t,react:n,source:r}})}var i=__read(e,3),u=i[0],c=i[1],a=i[2],s=t.ignoreErrors,e=t.onerror,i=t.onunhandledrejection,E=t.dedupe,t=t.captureGlobalAsync,l=getRegexp(s),f=dedupe();return e&&r.push(u[0](function(r){return n({error:normalizeError(r),source:{type:"onerror"}})})),i&&r.push(c[0](function(r){return n({error:normalizeException(r),source:{type:"onunhandledrejection"}})})),t&&r.push(a()[0](function(r){n(r)})),function(r,e,t){return n({error:normalizeUnknownError(r),extra:e,react:t,source:{type:"manual"}})}},JS_ERROR_MONITOR_PLUGIN_NAME="jsError",defaultConfig={ignoreErrors:[],onerror:!0,onunhandledrejection:!0,captureGlobalAsync:!1,dedupe:!0};function JsErrorMonitorPlugin(t){t.on("init",function(){window.removeEventListener("error",t.pcErr,!0),window.removeEventListener("unhandledrejection",t.pcRej,!0);var r,e=getPluginConfig(t,JS_ERROR_MONITOR_PLUGIN_NAME,defaultConfig);e&&(e=jsErrorGetterWithContext(function(r){t.getBreadcrumbs&&(r.payload.breadcrumbs=t.getBreadcrumbs()),t.report(r)},r=[],[initSubjectInGlobal(t,errorSubject),initSubjectInGlobal(t,promiseRejectionSubject),function(){return initSubjectInGlobal(t,asyncErrorWithSourceSubject)}],e),registerTearDownGroup(t,JS_ERROR_MONITOR_PLUGIN_NAME,JS_ERROR_EV_TYPE,r),t.provide("captureException",e))})}var JS_ERROR_INTEGRATION_NAME=JS_ERROR_MONITOR_PLUGIN_NAME,jsErrorPlugin=function(){return{name:JS_ERROR_INTEGRATION_NAME,setup:function(r){JsErrorMonitorPlugin(r)}}};exports.JS_ERROR_INTEGRATION_NAME=JS_ERROR_INTEGRATION_NAME,exports.jsErrorPlugin=jsErrorPlugin; |
@@ -255,2 +255,3 @@ interface ContextAgent { | ||
plugins: PluginsConfig; | ||
pluginPathPrefix?: string; | ||
apdex?: ApdexConfig; | ||
@@ -773,3 +774,3 @@ sample?: SampleConfig; | ||
interface AjaxMonitorConfig { | ||
interface AjaxMonitorProps { | ||
autoWrap?: boolean; | ||
@@ -786,3 +787,3 @@ setContextAtReq: () => (ev: HttpReport) => void; | ||
} | ||
interface FetchMonitorConfig extends AjaxMonitorConfig { | ||
interface FetchMonitorProps extends AjaxMonitorProps { | ||
} | ||
@@ -795,2 +796,3 @@ interface TraceConfig { | ||
declare const AJAX_MONITOR_PLUGIN_NAME = "ajax"; | ||
declare type AjaxMonitorConfig = Omit<AjaxMonitorProps, 'setContextAtReq' | 'setTraceHeader'>; | ||
interface AjaxMonitorPluginConfig { | ||
@@ -823,2 +825,3 @@ [AJAX_MONITOR_PLUGIN_NAME]?: Partial<AjaxMonitorConfig> | boolean; | ||
declare const FETCH_MONITOR_PLUGIN_NAME = "fetch"; | ||
declare type FetchMonitorConfig = Omit<FetchMonitorProps, 'setContextAtReq' | 'setTraceHeader'>; | ||
interface FetchMonitorPluginConfig { | ||
@@ -915,2 +918,3 @@ [FETCH_MONITOR_PLUGIN_NAME]?: Partial<FetchMonitorConfig> | boolean; | ||
mpfid = "mpfid", | ||
inp = "inp", | ||
lcp = "lcp", | ||
@@ -929,4 +933,2 @@ cls = "cls", | ||
declare const PERFORMANCE_MONITOR_PLUGIN_NAME = "performance"; | ||
declare type CustomPerformancePayload = Partial<Omit<PerformancePayload, 'name' | 'value'>> & Pick<PerformancePayload, 'name' | 'value'>; | ||
declare type WithSendPerformance<C extends WebClient$1> = C & { | ||
@@ -937,5 +939,7 @@ sendCustomPerfMetric?: (metric: CustomPerformancePayload) => void; | ||
}; | ||
declare const PERFORMANCE_MONITOR_PLUGIN_NAME = "performance"; | ||
interface PerformanceMonitorPluginConfig { | ||
[PERFORMANCE_MONITOR_PLUGIN_NAME]?: Partial<PerformanceMonitorUserConfig> | boolean; | ||
} | ||
declare type CustomPerformancePayload = Partial<Omit<PerformancePayload, 'name' | 'value'>> & Pick<PerformancePayload, 'name' | 'value'>; | ||
@@ -952,2 +956,3 @@ declare const TTI_MONITOR_PLUGIN_NAME = "tti"; | ||
declare const FMP_MONITOR_PLUGIN_NAME = "fmp"; | ||
interface FMPMonitorPluginConfig { | ||
@@ -957,3 +962,3 @@ [FMP_MONITOR_PLUGIN_NAME]?: Partial<FMPMonitorConfig> | boolean; | ||
interface BlankScreenMonitorConfig { | ||
interface BlankScreenProps { | ||
autoDetect?: boolean; | ||
@@ -970,2 +975,4 @@ threshold: number; | ||
quality: number; | ||
initDetTime: number; | ||
runDetTime: number; | ||
} | ||
@@ -976,2 +983,3 @@ interface DetectBlankScreen { | ||
declare type BlankScreenMonitorConfig = Omit<BlankScreenProps, 'ssUrl'>; | ||
declare const BLANK_SCREEN_MONITOR_PLUGIN_NAME = "blankScreen"; | ||
@@ -978,0 +986,0 @@ declare type WithDetectBlankScreen<C extends WebClient$1> = C & { |
@@ -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),a=[];try{for(;(void 0===t||0<t--)&&!(r=i.next()).done;)a.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 a}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},hookObjectProperty=function(i,a,u,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 n=i[a],r=u.apply(void 0,__spreadArray([n],__read(e),!1)),o=r;return isFunction(o)&&c&&(o=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{return r.apply(this,t)}catch(e){return isFunction(n)&&n.apply(this,t)}}),i[a]=o,function(e){e||(o===i[a]?i[a]=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||a()}var n,r=[],o=[],i=!1,a=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),a(),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]},registerTearDownGroup=function(e,t,n,r){return e.destroyAgent.set(t,n,r)};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 getDefaultHistory(){return getDefaultBrowser()&&window.history}function parseUrl(e){var t=getDefaultDocument();if(!t||!e)return{url:e,protocol:"",domain:"",query:"",path:"",hash:""};t=t.createElement("a");t.href=e;e=t.pathname||"/";return"/"!==e[0]&&(e="/"+e),{url:t.href,protocol:t.protocol.slice(0,-1),domain:t.hostname,query:t.search.substring(1),path:e,hash:t.hash}}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},FIRST_PV_SUBJECT_NAME="f_view_0",applyFirstPV=function(r){return function(e,t){var n=getOverrides(r);t(noop,function(e){n&&e(n)})}},invokeCallbackOnce=function(t){var n=!1;return[function(e){n||(n=!0,t&&t(e))}]},getConfig=function(e,t){return isObject(e)?__assign(__assign({},t),e):!!e&&t},PAGEVIEW_EV_TYPE="pageview",SESSION_EV_TYPE="session",JS_ERROR_EV_TYPE="js_error",HTTP_EV_TYPE="http",RESOURCE_ERROR_EV_TYPE="resource_error",RESOURCE_EV_TYPE="resource",PERFORMANCE_METRIC_EV_TYPE="performance",LONG_TASK_EV_TYPE="performance_longtask",BLANK_SCREEN_EV_TYPE="blank_screen",ACTION_EV_TYPE="action";function getPluginConfig(e,t,n){t=null===(e=e.config())||void 0===e?void 0:e.plugins[t];return getConfig(t,n)}var HIDDEN_SUBJECT_NAME="hidden_2",visibilityStateIsHidden=function(e){return"hidden"===e.visibilityState},observeHidden=function(e,t){var n,r=getDefaultBrowser(),o=getDefaultDocument();r&&o&&(n=function(){e(visibilityStateIsHidden(o))},addEventListener("visibilitychange",n,!0),t(function(){removeEventListener("visibilitychange",n,!0)},function(e){e(visibilityStateIsHidden(o))}))},hiddenSubject=[HIDDEN_SUBJECT_NAME,observeHidden],readyStateIsComplete=function(e){return"complete"===e.readyState},UNLOAD_SUBJECT_NAME="unload_0",observeUnload=function(e,t){var n,r,o,i=getDefaultBrowser();i&&(n=__read(invokeCallbackOnce(e),1)[0],o=function(){n()},(r=["unload","beforeunload","pagehide"]).forEach(function(e){i.addEventListener(e,o)}),t(function(){r.forEach(function(e){i.removeEventListener(e,o)})}))},unloadSubject=[UNLOAD_SUBJECT_NAME,observeUnload],HISTORY_SUBJECT_NAME="history_0",HASH_SUBJECT_NAME="hash_0",observeHistory=function(e,t){var n,r,o,i=getDefaultHistory();i&&(r=function(){return e(location.href)},(n=[]).push(hookObjectProperty(i,"pushState",o=function(n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{n.apply(i,e)}finally{r()}}})(),hookObjectProperty(i,"replaceState",o)()),window.addEventListener("popstate",r,!0),n.push(function(){return window.removeEventListener("popstate",r,!0)}),t(function(){n.forEach(function(e){return e()})}))},observeHash=function(e,t){var n,r=getDefaultBrowser();r&&(r.addEventListener("hashchange",n=function(){return e(location.href)},!0),t(function(){return r.removeEventListener("hashchange",n,!0)}))},hashSubject=[HASH_SUBJECT_NAME,observeHash],historySubject=[HISTORY_SUBJECT_NAME,observeHistory],getDefaultExtractor=function(n){return function(e){var t;return"hash"===n?(null===(t=parseUrl(e).hash)||void 0===t?void 0:t.replace(/^#/,""))||"/":parseUrl(e).path}},getViewId=function(e){return joinWithSeparator(e,now())},joinWithSeparator=function(e,t){return e+"_"+t},applyOnPidChange=function(r,e,t,o){var i=t,a=e;o&&o(e);return[function(e,t,n){"user_set"!==e&&t!==i?(i=t,a=null!=n?n:i,o&&o(a),r(e,a)):"user_set"===e&&t!==a&&(a=t,o&&o(a),r(e,a))},function(){e&&r("init",e)}]},applyOnUrlChange=function(n,e){var r=e;return[function(e,t){t!==r&&n(e,r=t)}]},wrapPageview=function(e,t){return{ev_type:PAGEVIEW_EV_TYPE,payload:{pid:t,source:e}}},applyReportPageview=function(n){return function(e,t){n(wrapPageview(e,t))}},isManualMode=function(e){return"manual"===e},ERROR_WEIGHT="error_weight",DURATION_APDEX="duration_apdex",PREF_APDEX="perf_apdex",ACTION_KEY="action",getDefaultApdexDetail=function(){var e={error_count:[0,0,0,0],duration_count:[0,0,0]};return e[PREF_APDEX]={},e},getRank=function(e,t){var n=e[0]+e[1]+e[2],r=e[0]/n;return e[2]/n>t.frustrating_threshold?2:r>t.satisfying_threshold||0===n?0:1},calculateSpentTime=function(){var t=0,n=void 0;return[function(e){e?n&&(t+=now()-n,n=void 0):n=now()},function(){n&&(t+=now()-n);var e=t;return t=0,n=now(),e}]},applyCalculateWight=function(o,i){return function(e,t){var n=e.payload;switch(e.ev_type){case PERFORMANCE_METRIC_EV_TYPE:var r=n.name;n.isSupport&&o(t[PREF_APDEX],r,n.value);break;case ACTION_EV_TYPE:o(t[PREF_APDEX],ACTION_KEY,n.duration||0);break;case JS_ERROR_EV_TYPE:i(t[ERROR_WEIGHT],0);break;case HTTP_EV_TYPE:n.response.is_custom_error||400<=n.response.status?i(t[ERROR_WEIGHT],1):(r=n.response.timing)&&o(t[DURATION_APDEX],0,r.duration);break;case RESOURCE_ERROR_EV_TYPE:i(t[ERROR_WEIGHT],2);break;case BLANK_SCREEN_EV_TYPE:i(t[ERROR_WEIGHT],3);break;case RESOURCE_EV_TYPE:o(t[DURATION_APDEX],1,n.duration);break;case LONG_TASK_EV_TYPE:n.longtasks.forEach(function(e){o(t[DURATION_APDEX],2,e.duration)})}}},calculateApdex=function(){function e(){o=[0,0,0],i=getDefaultApdexDetail()}var o,i;e();return[function(e,t,n){var r=e&&e[t];!r||n<=0||(e=n<(r[0].threshold||0)?0:n>(r[1].threshold||0)?2:1,o[e]+=r[e].weight,"string"==typeof t?(n=joinWithSeparator(t,e),r=i[PREF_APDEX][n],i[PREF_APDEX][n]=(r||0)+1):2==e&&(i.duration_count[t]+=1))},function(e,t){e&&(o[2]+=e[t],i.error_count[t]+=1)},function(){return[o,i]},e]},calculateSession=function(){var o={start:now(),end:0,time_spent:0,is_bounced:!1,entry:"",exit:"",p_count:0,a_count:0};return[function(e,t){var n=__read(e,3),r=n[0],e=n[1],n=n[2];o.end=now(),o.time_spent+=t&&t.time_spent||0,o.last_page=t,o.p_count+=1,o.rank=r,o.apdex=e,o.apdex_detail=n;n=getDefaultDocument();n&&(o.is_bounced=!readyStateIsComplete(n))},function(e,t){o.time_spent+=e.time_spent,o.p_count+=1,o.exit=t},function(){o.a_count+=1},function(e){o.entry=e,o.exit=e},function(){return o}]},pvGetterWithRouteObserver=function(e,t,n,r){var o,i,a,u=r.sendInit,c=r.initPid,f=r.routeMode,s=r.extractPid,r=r.onPidUpdate,_=isManualMode(f)?function(){return""}:getDefaultExtractor(f),l=s||function(){},r=__read(applyOnPidChange(applyReportPageview(e),c||(o=location.href,null!==(i=l(o))&&void 0!==i?i:_(o)),_(location.href),r),2),d=r[0],r=r[1];return isManualMode(f)||(a=__read(applyOnUrlChange(function(e,t){return d(e,_(t),l(t))},""),1)[0],n.length&&n.forEach(function(e){return t.push(e[0](function(e){return a(f,e)}))})),u&&r(),[d.bind(null,"user_set")]},apdexGetterWithHiddenObserver=function(r,t,e,n){var o=__read(e,2),i=o[0],a=o[1],u=2===n.apdex,c=void 0,f=void 0,s=void 0,_=!1,l=__read(calculateApdex(),4),d=l[0],E=l[1],p=l[2],v=l[3],e=__read(calculateApdex(),4),o=e[0],n=e[1],h=e[2],g=e[3],l=__read(calculateSession(),5),P=l[0],b=l[1],y=l[2],T=l[3],O=l[4],e=__read(calculateSpentTime(),2),l=e[0],A=e[1];t.push(i[0](l)),u||t.push(a[0](function(){var e,t,n;_&&(e=(n=__read(h(),2))[0],t=n[1],n=getRank(e,s),P([n,e,t],I()),r({ev_type:SESSION_EV_TYPE,payload:O()}),g())}));var R=applyCalculateWight(d,E),S=applyCalculateWight(o,n),I=function(){var e=__read(p(),2),t=e[0],e=e[1];return{start:c[0],pid:c[1],view_id:c[2],end:now(),time_spent:A(),apdex:t,rank:getRank(t,s),detail:e}};return t.push(function(){_=!1}),[function(e,t){if(!c)return c=[now(),e,t],T(e),void(_=!(!s||!c));_&&(f=I(),b(f,e)),c=[now(),e,t],v()},function(e){_&&e.common.pid===c[1]&&(R(e,s),u||(S(e,s),e.ev_type===ACTION_EV_TYPE&&y()))},function(e){_&&(e.payload.last=f),r(e)},function(e){if(!e)return t.forEach(function(e){return e()}),void(t.length=0);_=!(!(s=e)||!c)}]},PAGEVIEW_MONITOR_PLUGIN_NAME="pageview",defaultConfig={sendInit:!0,routeMode:"history",apdex:2};function PageviewMonitorPlugin(l){l.on("init",function(){var e,t,n,r,o,i,a,u,c,f,s,_=getPluginConfig(l,PAGEVIEW_MONITOR_PLUGIN_NAME,defaultConfig);_&&location&&(e=_.routeMode,i=_.apdex,c=l.report.bind(l),u=noop,i&&(t=[],r=(n=__read(apdexGetterWithHiddenObserver(l.report.bind(l),t,[initSubjectInGlobal(l,hiddenSubject),initSubjectInGlobal(l,unloadSubject)],_),4))[0],o=n[1],i=n[2],a=n[3],c=i,u=r,l.on("send",o),t.push(function(){return l.off("send",o)}),l.on("start",function(){a(l.config().apdex)}),registerTearDownGroup(l,PAGEVIEW_MONITOR_PLUGIN_NAME,SESSION_EV_TYPE,t)),f=__read(pvGetterWithRouteObserver(c,c=[],isManualMode(e)?[]:[l.initSubject(hashSubject),l.initSubject(historySubject)],__assign(__assign({},_),{initPid:null===(_=l.config())||void 0===_?void 0:_.pid,onPidUpdate:function(e){var t=getViewId(e);u(e,t),l.set({pid:e,viewId:t,actionId:void 0})}})),1)[0],initPrivateSubject(l,[FIRST_PV_SUBJECT_NAME,applyFirstPV(l)],-1),s=function(){f(l.config().pid)},l.on("config",s),c.push(function(){return l.off("config",s)}),registerTearDownGroup(l,PAGEVIEW_MONITOR_PLUGIN_NAME,PAGEVIEW_EV_TYPE,c),l.provide("sendPageview",f))})}var PAGEVIEW_INTEGRATION_NAME=PAGEVIEW_MONITOR_PLUGIN_NAME,pageviewPlugin=function(){return{name:PAGEVIEW_INTEGRATION_NAME,setup:function(e){PageviewMonitorPlugin(e)}}};exports.PAGEVIEW_INTEGRATION_NAME=PAGEVIEW_INTEGRATION_NAME,exports.pageviewPlugin=pageviewPlugin; | ||
"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),a=[];try{for(;(void 0===t||0<t--)&&!(r=i.next()).done;)a.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 a}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},hookObjectProperty=function(i,a,u,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 n=i[a],r=u.apply(void 0,__spreadArray([n],__read(e),!1)),o=r;return isFunction(o)&&c&&(o=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{return r.apply(this,t)}catch(e){return isFunction(n)&&n.apply(this,t)}}),i[a]=o,function(e){e||(o===i[a]?i[a]=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||a()}var n,r=[],o=[],i=!1,a=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),a(),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]},registerTearDownGroup=function(e,t,n,r){return e.destroyAgent.set(t,n,r)};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 getDefaultHistory(){return getDefaultBrowser()&&window.history}function parseUrl(e){var t=getDefaultDocument();if(!t||!e)return{url:e,protocol:"",domain:"",query:"",path:"",hash:""};t=t.createElement("a");t.href=e;e=t.pathname||"/";return"/"!==e[0]&&(e="/"+e),{url:t.href,protocol:t.protocol.slice(0,-1),domain:t.hostname,query:t.search.substring(1),path:e,hash:t.hash}}function getLocationUrl(){var e=getDefaultBrowser()&&getDefaultLocation();return e?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},FIRST_PV_SUBJECT_NAME="f_view_0",applyFirstPV=function(r){return function(e,t){var n=getOverrides(r);t(noop,function(e){n&&e(n)})}},addListenerToWindow=function(e,t,n,r){return void 0===r&&(r=!1),e.addEventListener(t,n,r),function(){e.removeEventListener(t,n,r)}},addListenerToDocument=function(e,t,n,r){return void 0===r&&(r=!1),e.addEventListener(t,n,r),function(){e.removeEventListener(t,n,r)}},invokeCallbackOnce=function(t){var n=!1;return[function(e){n||(n=!0,t&&t(e))}]},getConfig=function(e,t){return isObject(e)?__assign(__assign({},t),e):!!e&&t},PAGEVIEW_EV_TYPE="pageview",SESSION_EV_TYPE="session",JS_ERROR_EV_TYPE="js_error",HTTP_EV_TYPE="http",RESOURCE_ERROR_EV_TYPE="resource_error",RESOURCE_EV_TYPE="resource",PERFORMANCE_METRIC_EV_TYPE="performance",LONG_TASK_EV_TYPE="performance_longtask",BLANK_SCREEN_EV_TYPE="blank_screen",ACTION_EV_TYPE="action",HIDDEN_SUBJECT_NAME="hidden_3",visibilityStateIsHidden=function(e){return"hidden"===e.visibilityState},observeHidden=function(t,e){var n,r,o,i=getDefaultDocument(),a=getDefaultBrowser();i&&a&&(r=addListenerToDocument(i,"visibilitychange",n=function(e){t("pagehide"===e.type||visibilityStateIsHidden(i))},!0),o=addListenerToWindow(a,"pagehide",n,!0),e(function(){r(),o()},function(e){e(visibilityStateIsHidden(i))}))},hiddenSubject=[HIDDEN_SUBJECT_NAME,observeHidden],readyStateIsComplete=function(e){return"complete"===e.readyState},UNLOAD_SUBJECT_NAME="unload_0",observeUnload=function(e,t){var n,r,o,i=getDefaultBrowser();i&&(n=__read(invokeCallbackOnce(e),1)[0],r=function(){n()},o=[],["unload","beforeunload","pagehide"].forEach(function(e){o.push(addListenerToWindow(i,e,r,!1))}),t(function(){o.forEach(function(e){return e()})}))},unloadSubject=[UNLOAD_SUBJECT_NAME,observeUnload],HISTORY_SUBJECT_NAME="history_0",HASH_SUBJECT_NAME="hash_0",observeHistory=function(e,t){var n,r,o,i=getDefaultHistory(),a=getDefaultBrowser();i&&a&&(r=function(){return e(location.href)},(n=[]).push(hookObjectProperty(i,"pushState",o=function(n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{n.apply(i,e)}finally{r()}}})(),hookObjectProperty(i,"replaceState",o)()),n.push(addListenerToWindow(a,"popstate",r,!0)),t(function(){n.forEach(function(e){return e()})}))},observeHash=function(e,t){var n,r=getDefaultBrowser();r&&(n=addListenerToWindow(r,"hashchange",function(){return e(location.href)},!0),t(function(){n()}))},hashSubject=[HASH_SUBJECT_NAME,observeHash],historySubject=[HISTORY_SUBJECT_NAME,observeHistory],getDefaultExtractor=function(n){return function(e){var t;return"hash"===n?(null===(t=parseUrl(e).hash)||void 0===t?void 0:t.replace(/^#/,""))||"/":parseUrl(e).path}},getViewId=function(e){return joinWithSeparator(e,now())},joinWithSeparator=function(e,t){return e+"_"+t},applyOnPidChange=function(r,e,t,o){var i=t,a=e;o&&o(e);return[function(e,t,n){"user_set"!==e&&t!==i?(i=t,a=null!=n?n:i,o&&o(a),r(e,a)):"user_set"===e&&t!==a&&(a=t,o&&o(a),r(e,a))},function(){e&&r("init",e)}]},applyOnUrlChange=function(n,e){var r=e;return[function(e,t){t!==r&&n(e,r=t)}]},wrapPageview=function(e,t){return{ev_type:PAGEVIEW_EV_TYPE,payload:{pid:t,source:e}}},applyReportPageview=function(n){return function(e,t){n(wrapPageview(e,t))}},isManualMode=function(e){return"manual"===e},ERROR_WEIGHT="error_weight",DURATION_APDEX="duration_apdex",PREF_APDEX="perf_apdex",ACTION_KEY="action",getDefaultApdexDetail=function(){var e={error_count:[0,0,0,0],duration_count:[0,0,0]};return e[PREF_APDEX]={},e},getRank=function(e,t){var n=e[0]+e[1]+e[2],r=e[0]/n;return e[2]/n>t.frustrating_threshold?2:r>t.satisfying_threshold||0===n?0:1},calculateSpentTime=function(){var t=0,n=void 0;return[function(e){e?n&&(t+=now()-n,n=void 0):n=now()},function(){n&&(t+=now()-n);var e=t;return t=0,n=now(),e}]},applyCalculateWight=function(o,i){return function(e,t){var n=e.payload;switch(e.ev_type){case PERFORMANCE_METRIC_EV_TYPE:var r=n.name;n.isSupport&&o(t[PREF_APDEX],r,n.value);break;case ACTION_EV_TYPE:o(t[PREF_APDEX],ACTION_KEY,n.duration||0);break;case JS_ERROR_EV_TYPE:i(t[ERROR_WEIGHT],0);break;case HTTP_EV_TYPE:n.response.is_custom_error||400<=n.response.status?i(t[ERROR_WEIGHT],1):(r=n.response.timing)&&o(t[DURATION_APDEX],0,r.duration);break;case RESOURCE_ERROR_EV_TYPE:i(t[ERROR_WEIGHT],2);break;case BLANK_SCREEN_EV_TYPE:i(t[ERROR_WEIGHT],3);break;case RESOURCE_EV_TYPE:o(t[DURATION_APDEX],1,n.duration);break;case LONG_TASK_EV_TYPE:n.longtasks.forEach(function(e){o(t[DURATION_APDEX],2,e.duration)})}}},calculateApdex=function(){function e(){o=[0,0,0],i=getDefaultApdexDetail()}var o,i;e();return[function(e,t,n){var r=e&&e[t];!r||n<=0||(e=n<(r[0].threshold||0)?0:n>(r[1].threshold||0)?2:1,o[e]+=r[e].weight,"string"==typeof t?(n=joinWithSeparator(t,e),r=i[PREF_APDEX][n],i[PREF_APDEX][n]=(r||0)+1):2==e&&(i.duration_count[t]+=1))},function(e,t){e&&(o[2]+=e[t],i.error_count[t]+=1)},function(){return[o,i]},e]},calculateSession=function(){var o={start:now(),end:0,time_spent:0,is_bounced:!1,entry:"",exit:"",p_count:0,a_count:0};return[function(e,t){var n=__read(e,3),r=n[0],e=n[1],n=n[2];o.end=now(),o.time_spent+=t&&t.time_spent||0,o.last_page=t,o.p_count+=1,o.rank=r,o.apdex=e,o.apdex_detail=n;n=getDefaultDocument();n&&(o.is_bounced=!readyStateIsComplete(n))},function(e,t){o.time_spent+=e.time_spent,o.p_count+=1,o.exit=t},function(){o.a_count+=1},function(e){o.entry=e,o.exit=e},function(){return o}]},pvGetterWithRouteObserver=function(e,t,n,r){var o,i,a,u=r.sendInit,c=r.initPid,f=r.routeMode,s=r.extractPid,r=r.onPidUpdate,_=isManualMode(f)?function(){return""}:getDefaultExtractor(f),d=s||function(){},r=__read(applyOnPidChange(applyReportPageview(e),c||(o=location.href,null!==(i=d(o))&&void 0!==i?i:_(o)),_(location.href),r),2),l=r[0],r=r[1];return isManualMode(f)||(a=__read(applyOnUrlChange(function(e,t){return l(e,_(t),d(t))},""),1)[0],n.length&&n.forEach(function(e){return t.push(e[0](function(e){return a(f,e)}))})),u&&r(),[l.bind(null,"user_set")]},apdexGetterWithHiddenObserver=function(r,t,e,n){var o=__read(e,2),i=o[0],a=o[1],u=2===n.apdex,c=void 0,f=void 0,s=void 0,_=!1,d=__read(calculateApdex(),4),l=d[0],p=d[1],E=d[2],v=d[3],e=__read(calculateApdex(),4),o=e[0],n=e[1],h=e[2],g=e[3],d=__read(calculateSession(),5),P=d[0],T=d[1],b=d[2],y=d[3],O=d[4],e=__read(calculateSpentTime(),2),d=e[0],A=e[1];t.push(i[0](d)),u||t.push(a[0](function(){var e,t,n;_&&(e=(n=__read(h(),2))[0],t=n[1],n=getRank(e,s),P([n,e,t],I()),r({ev_type:SESSION_EV_TYPE,payload:O()}),g())}));var R=applyCalculateWight(l,p),S=applyCalculateWight(o,n),I=function(){var e=__read(E(),2),t=e[0],e=e[1];return{start:c[0],pid:c[1],view_id:c[2],end:now(),time_spent:A(),apdex:t,rank:getRank(t,s),detail:e}};return t.push(function(){_=!1}),[function(e,t){if(!c)return c=[now(),e,t],y(e),void(_=!(!s||!c));_&&(f=I(),T(f,e)),c=[now(),e,t],v()},function(e){_&&(u||(S(e,s),e.ev_type===ACTION_EV_TYPE&&b()),e.common.pid===c[1]&&R(e,s))},function(e){_&&(e.payload.last=f),r(e)},function(e){if(!e)return t.forEach(function(e){return e()}),void(t.length=0);_=!(!(s=e)||!c)}]},PAGEVIEW_MONITOR_PLUGIN_NAME="pageview",defaultConfig={sendInit:!0,routeMode:"history",apdex:2};function PageviewMonitorBasePlugin(n,e){var t,r,o,i,a,u,c,f,s,_,d=getConfig(e,defaultConfig);d&&getDefaultLocation()&&(t=d.routeMode,a=d.apdex,f=n.report.bind(n),c=noop,a&&(r=[],e=(o=__read(apdexGetterWithHiddenObserver(n.report.bind(n),r,[initSubjectInGlobal(n,hiddenSubject),initSubjectInGlobal(n,unloadSubject)],d),4))[0],i=o[1],a=o[2],u=o[3],f=a,c=e,n.on("send",i),r.push(function(){return n.off("send",i)}),n.on("start",function(){u(n.config().apdex)}),registerTearDownGroup(n,PAGEVIEW_MONITOR_PLUGIN_NAME,SESSION_EV_TYPE,r)),s=__read(pvGetterWithRouteObserver(f,f=[],isManualMode(t)?[]:[n.initSubject(hashSubject),n.initSubject(historySubject)],__assign(__assign({},d),{initPid:null===(d=n.config())||void 0===d?void 0:d.pid,onPidUpdate:function(e){var t=getViewId(e);c(e,t),n.set({pid:e,viewId:t,actionId:void 0})}})),1)[0],initPrivateSubject(n,[FIRST_PV_SUBJECT_NAME,applyFirstPV(n)],-1),_=function(){s(n.config().pid)},n.on("config",_),f.push(function(){return n.off("config",_)}),registerTearDownGroup(n,PAGEVIEW_MONITOR_PLUGIN_NAME,PAGEVIEW_EV_TYPE,f),n.provide("sendPageview",s))}function PageviewMonitorPlugin(t){t.on("init",function(){var e=null===(e=t.config())||void 0===e?void 0:e.plugins[PAGEVIEW_MONITOR_PLUGIN_NAME];PageviewMonitorBasePlugin(t,e)})}var PAGEVIEW_INTEGRATION_NAME=PAGEVIEW_MONITOR_PLUGIN_NAME,pageviewPlugin=function(){return{name:PAGEVIEW_INTEGRATION_NAME,setup:function(e){PageviewMonitorPlugin(e)}}};exports.PAGEVIEW_INTEGRATION_NAME=PAGEVIEW_INTEGRATION_NAME,exports.pageviewPlugin=pageviewPlugin; |
@@ -255,2 +255,3 @@ interface ContextAgent { | ||
plugins: PluginsConfig; | ||
pluginPathPrefix?: string; | ||
apdex?: ApdexConfig; | ||
@@ -773,3 +774,3 @@ sample?: SampleConfig; | ||
interface AjaxMonitorConfig { | ||
interface AjaxMonitorProps { | ||
autoWrap?: boolean; | ||
@@ -786,3 +787,3 @@ setContextAtReq: () => (ev: HttpReport) => void; | ||
} | ||
interface FetchMonitorConfig extends AjaxMonitorConfig { | ||
interface FetchMonitorProps extends AjaxMonitorProps { | ||
} | ||
@@ -795,2 +796,3 @@ interface TraceConfig { | ||
declare const AJAX_MONITOR_PLUGIN_NAME = "ajax"; | ||
declare type AjaxMonitorConfig = Omit<AjaxMonitorProps, 'setContextAtReq' | 'setTraceHeader'>; | ||
interface AjaxMonitorPluginConfig { | ||
@@ -823,2 +825,3 @@ [AJAX_MONITOR_PLUGIN_NAME]?: Partial<AjaxMonitorConfig> | boolean; | ||
declare const FETCH_MONITOR_PLUGIN_NAME = "fetch"; | ||
declare type FetchMonitorConfig = Omit<FetchMonitorProps, 'setContextAtReq' | 'setTraceHeader'>; | ||
interface FetchMonitorPluginConfig { | ||
@@ -915,2 +918,3 @@ [FETCH_MONITOR_PLUGIN_NAME]?: Partial<FetchMonitorConfig> | boolean; | ||
mpfid = "mpfid", | ||
inp = "inp", | ||
lcp = "lcp", | ||
@@ -929,4 +933,2 @@ cls = "cls", | ||
declare const PERFORMANCE_MONITOR_PLUGIN_NAME = "performance"; | ||
declare type CustomPerformancePayload = Partial<Omit<PerformancePayload, 'name' | 'value'>> & Pick<PerformancePayload, 'name' | 'value'>; | ||
declare type WithSendPerformance<C extends WebClient> = C & { | ||
@@ -937,5 +939,7 @@ sendCustomPerfMetric?: (metric: CustomPerformancePayload) => void; | ||
}; | ||
declare const PERFORMANCE_MONITOR_PLUGIN_NAME = "performance"; | ||
interface PerformanceMonitorPluginConfig { | ||
[PERFORMANCE_MONITOR_PLUGIN_NAME]?: Partial<PerformanceMonitorUserConfig> | boolean; | ||
} | ||
declare type CustomPerformancePayload = Partial<Omit<PerformancePayload, 'name' | 'value'>> & Pick<PerformancePayload, 'name' | 'value'>; | ||
@@ -952,2 +956,3 @@ declare const TTI_MONITOR_PLUGIN_NAME = "tti"; | ||
declare const FMP_MONITOR_PLUGIN_NAME = "fmp"; | ||
interface FMPMonitorPluginConfig { | ||
@@ -957,3 +962,3 @@ [FMP_MONITOR_PLUGIN_NAME]?: Partial<FMPMonitorConfig> | boolean; | ||
interface BlankScreenMonitorConfig { | ||
interface BlankScreenProps { | ||
autoDetect?: boolean; | ||
@@ -970,2 +975,4 @@ threshold: number; | ||
quality: number; | ||
initDetTime: number; | ||
runDetTime: number; | ||
} | ||
@@ -976,2 +983,3 @@ interface DetectBlankScreen { | ||
declare type BlankScreenMonitorConfig = Omit<BlankScreenProps, 'ssUrl'>; | ||
declare const BLANK_SCREEN_MONITOR_PLUGIN_NAME = "blankScreen"; | ||
@@ -978,0 +986,0 @@ declare type WithDetectBlankScreen<C extends WebClient> = C & { |
@@ -255,2 +255,3 @@ interface ContextAgent { | ||
plugins: PluginsConfig; | ||
pluginPathPrefix?: string; | ||
apdex?: ApdexConfig; | ||
@@ -773,3 +774,3 @@ sample?: SampleConfig; | ||
interface AjaxMonitorConfig { | ||
interface AjaxMonitorProps { | ||
autoWrap?: boolean; | ||
@@ -786,3 +787,3 @@ setContextAtReq: () => (ev: HttpReport) => void; | ||
} | ||
interface FetchMonitorConfig extends AjaxMonitorConfig { | ||
interface FetchMonitorProps extends AjaxMonitorProps { | ||
} | ||
@@ -795,2 +796,3 @@ interface TraceConfig { | ||
declare const AJAX_MONITOR_PLUGIN_NAME = "ajax"; | ||
declare type AjaxMonitorConfig = Omit<AjaxMonitorProps, 'setContextAtReq' | 'setTraceHeader'>; | ||
interface AjaxMonitorPluginConfig { | ||
@@ -823,2 +825,3 @@ [AJAX_MONITOR_PLUGIN_NAME]?: Partial<AjaxMonitorConfig> | boolean; | ||
declare const FETCH_MONITOR_PLUGIN_NAME = "fetch"; | ||
declare type FetchMonitorConfig = Omit<FetchMonitorProps, 'setContextAtReq' | 'setTraceHeader'>; | ||
interface FetchMonitorPluginConfig { | ||
@@ -915,2 +918,3 @@ [FETCH_MONITOR_PLUGIN_NAME]?: Partial<FetchMonitorConfig> | boolean; | ||
mpfid = "mpfid", | ||
inp = "inp", | ||
lcp = "lcp", | ||
@@ -929,4 +933,2 @@ cls = "cls", | ||
declare const PERFORMANCE_MONITOR_PLUGIN_NAME = "performance"; | ||
declare type CustomPerformancePayload = Partial<Omit<PerformancePayload, 'name' | 'value'>> & Pick<PerformancePayload, 'name' | 'value'>; | ||
declare type WithSendPerformance<C extends WebClient$1> = C & { | ||
@@ -937,5 +939,7 @@ sendCustomPerfMetric?: (metric: CustomPerformancePayload) => void; | ||
}; | ||
declare const PERFORMANCE_MONITOR_PLUGIN_NAME = "performance"; | ||
interface PerformanceMonitorPluginConfig { | ||
[PERFORMANCE_MONITOR_PLUGIN_NAME]?: Partial<PerformanceMonitorUserConfig> | boolean; | ||
} | ||
declare type CustomPerformancePayload = Partial<Omit<PerformancePayload, 'name' | 'value'>> & Pick<PerformancePayload, 'name' | 'value'>; | ||
@@ -952,2 +956,3 @@ declare const TTI_MONITOR_PLUGIN_NAME = "tti"; | ||
declare const FMP_MONITOR_PLUGIN_NAME = "fmp"; | ||
interface FMPMonitorPluginConfig { | ||
@@ -957,3 +962,3 @@ [FMP_MONITOR_PLUGIN_NAME]?: Partial<FMPMonitorConfig> | boolean; | ||
interface BlankScreenMonitorConfig { | ||
interface BlankScreenProps { | ||
autoDetect?: boolean; | ||
@@ -970,2 +975,4 @@ threshold: number; | ||
quality: number; | ||
initDetTime: number; | ||
runDetTime: number; | ||
} | ||
@@ -976,2 +983,3 @@ interface DetectBlankScreen { | ||
declare type BlankScreenMonitorConfig = Omit<BlankScreenProps, 'ssUrl'>; | ||
declare const BLANK_SCREEN_MONITOR_PLUGIN_NAME = "blankScreen"; | ||
@@ -978,0 +986,0 @@ declare type WithDetectBlankScreen<C extends WebClient$1> = C & { |
@@ -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",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; | ||
"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}function isUndefined(e){return void 0===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 e?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()}]},addListenerToDocument=function(e,t,n,r){return void 0===r&&(r=!1),e.addEventListener(t,n,r),function(){e.removeEventListener(t,n,r)}},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(r,o,i){var u=r&&new r(function(e,r){e.getEntries?e.getEntries().forEach(function(e,t,n){return o(e,t,n,r)}):i&&i()});return[function(e){if(!r||!u)return i&&i();try{u.observe({entryTypes:e})}catch(e){return i&&i()}},function(e,t){if(!r||!u)return i&&i();try{var n={type:e,buffered:!0};isUndefined(t)||(n.durationThreshold=t),u.observe(n)}catch(e){return i&&i()}u.observe({type:e,buffered:!1})},function(){return u&&u.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,r=getDefaultDocument();r&&(n=addListenerToDocument(r,CLICK_EVENT_NAME,e,!0),t(function(){n()}))},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,waitActionComplete=function(e,t,n,r){function o(){e.clearTimeout(i),c&&(i=e.setTimeout(function(){t()},PAGE_ACTIVITY_DELAY))}var i,u,c=!1;return[function(){c=!0,e.clearTimeout(u),u=e.setTimeout(function(){t(!0),n()},r),o()},o,function(){c=!1,e.clearTimeout(i),e.clearTimeout(u)}]},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},MAX_PAGE_DELAY=3e4,getSPA=function(e,t,n){function r(e){!_||Object.keys(h).length&&!e||(p(initMetric(SPA_LOAD_METRIC_NAME,now()-_)),o())}function o(){d(),_=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(window,r,noop,MAX_PAGE_DELAY),3),v=i[0],e=i[1],d=i[2],h=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.5", | ||
"version": "2.1.6-alpha.0", | ||
"description": "APMPlus Integrations", | ||
@@ -9,2 +9,3 @@ "main": "dist/index.js", | ||
"files": ["dist"], | ||
"license": "MIT", | ||
"publishConfig": { | ||
@@ -11,0 +12,0 @@ "registry": "https://registry.npmjs.org/", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
553170
26
0
14089
2