Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@apmplus/integrations

Package Overview
Dependencies
Maintainers
2
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@apmplus/integrations - npm Package Compare versions

Comparing version 2.1.3 to 2.1.4-alpha.0

5

dist/action.d.ts

@@ -11,2 +11,3 @@ interface ContextAgent {

declare type ParametersForFn<T extends (args: any) => any> = T extends (args: infer P) => any ? P : never;
declare type Filter<E> = (e: E) => boolean;
declare type SafeObservable<T> = [(f: T) => () => void, (f: T) => void];

@@ -172,2 +173,3 @@ declare type Observer<T extends (args: any) => any> = (next: (args: ParametersForFn<T>) => ReturnType<NextLink<T>>, attach: (disconnect: () => void, onSubscribe?: (f: T) => void) => void) => void;

declare type WithSubject<C extends AnyClient> = C & {
setFilter: (filterKey: string, filter: Filter<any>) => void;
initSubject: <T extends (args: any) => any>(args: [subjectKey: string, collector: Observer<T>]) => SafeObservable<T>;

@@ -774,5 +776,6 @@ getSubject: (key: string) => SafeObservable<any> | undefined;

collectBodyOnError: boolean;
extraExtractor?: (body: string | any, related: HttpPayload) => {
extraExtractor?: (resBody: string | any, related: HttpPayload, reqBody: any) => {
[key: string]: string;
} | false;
extractUrl?: (originalUrl: string) => string;
trace?: TraceConfig | boolean;

@@ -779,0 +782,0 @@ setTraceHeader?: (url: string, cb: (key: string, value: string) => void) => void;

@@ -11,2 +11,3 @@ interface ContextAgent {

declare type ParametersForFn<T extends (args: any) => any> = T extends (args: infer P) => any ? P : never;
declare type Filter<E> = (e: E) => boolean;
declare type SafeObservable<T> = [(f: T) => () => void, (f: T) => void];

@@ -172,2 +173,3 @@ declare type Observer<T extends (args: any) => any> = (next: (args: ParametersForFn<T>) => ReturnType<NextLink<T>>, attach: (disconnect: () => void, onSubscribe?: (f: T) => void) => void) => void;

declare type WithSubject<C extends AnyClient> = C & {
setFilter: (filterKey: string, filter: Filter<any>) => void;
initSubject: <T extends (args: any) => any>(args: [subjectKey: string, collector: Observer<T>]) => SafeObservable<T>;

@@ -774,5 +776,6 @@ getSubject: (key: string) => SafeObservable<any> | undefined;

collectBodyOnError: boolean;
extraExtractor?: (body: string | any, related: HttpPayload) => {
extraExtractor?: (resBody: string | any, related: HttpPayload, reqBody: any) => {
[key: string]: string;
} | false;
extractUrl?: (originalUrl: string) => string;
trace?: TraceConfig | boolean;

@@ -779,0 +782,0 @@ setTraceHeader?: (url: string, cb: (key: string, value: string) => void) => void;

2

dist/blankScreen.js

@@ -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/Math.pow(2,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 E();e=o.createElement("script");e.src=t,null!==(t=o.head)&&void 0!==t&&t.appendChild(e),e.onload=E}function E(){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)))})})}};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(p))},overrides:{timestamp:e||u[0]}})}function i(){c&&clearTimeout(c),c=A.setTimeout(function(){E=C(function(){var e=getElementByRootSelector(p);e&&((e=measure(e,0,0,v))<v?(u=[now(),e],L()):u=void 0)})},1e3)}var u,a,c,E,s,_,l,f=__read(e,4),T=f[0],d=f[1],g=f[2],e=f[3],v=n.threshold,R=n.screenshot,p=n.rootSelector,f=n.autoDetect,m=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,M=!1,L=(_=function(){u&&!M&&(M=!0,R?screenshot({cb:o.bind(null,now()),screenshotUrl:m,window:A,document:N,mask:b,partialShot:O,quality:S,rootSelector:p}):o())},function(){s||(l=now(),s=A.setTimeout(function(){s=0,(l<h?i:_)()},P()>MAX_RENDER_TIME?DEFAULT_CHECK_TIME:MAX_CHECK_TIME))});return r.push(e[0](function(){!M&&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(s),D(E),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){M||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:!1,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 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;

@@ -11,2 +11,3 @@ interface ContextAgent {

declare type ParametersForFn<T extends (args: any) => any> = T extends (args: infer P) => any ? P : never;
declare type Filter<E> = (e: E) => boolean;
declare type SafeObservable<T> = [(f: T) => () => void, (f: T) => void];

@@ -172,2 +173,3 @@ declare type Observer<T extends (args: any) => any> = (next: (args: ParametersForFn<T>) => ReturnType<NextLink<T>>, attach: (disconnect: () => void, onSubscribe?: (f: T) => void) => void) => void;

declare type WithSubject<C extends AnyClient> = C & {
setFilter: (filterKey: string, filter: Filter<any>) => void;
initSubject: <T extends (args: any) => any>(args: [subjectKey: string, collector: Observer<T>]) => SafeObservable<T>;

@@ -774,5 +776,6 @@ getSubject: (key: string) => SafeObservable<any> | undefined;

collectBodyOnError: boolean;
extraExtractor?: (body: string | any, related: HttpPayload) => {
extraExtractor?: (resBody: string | any, related: HttpPayload, reqBody: any) => {
[key: string]: string;
} | false;
extractUrl?: (originalUrl: string) => string;
trace?: TraceConfig | boolean;

@@ -779,0 +782,0 @@ setTraceHeader?: (url: string, cb: (key: string, value: string) => void) => void;

@@ -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&&80<=a+n.length*i+r.length);)n.push(r),a+=r.length,t=t.parentNode;return n.reverse().join(" > ")}catch(e){return UNKNOWN_PATH}}function _htmlElementAsString(e){var r,t,n,o=e,a=[];if(!o||!o.tagName)return"";a.push(o.tagName.toLowerCase()),o.id&&a.push("#"+o.id);e=o.className;if(e&&isString(e))for(r=e.split(/\s+/),u=0;u<r.length;u++)a.push("."+r[u]);for(var i=["type","name","title","alt"],u=0;u<i.length;u++)(n=o.getAttribute(t=i[u]))&&a.push("["+t+'="'+n+'"]');return a.join("")}var applyDomAndKeyPress=function(o){function a(r,t){var n;return function(e){i=void 0,e&&n!==e&&t({event:n=e,name:r})}}var i;return[a,function(n){return function(e){var r;try{r=e.target}catch(e){return}var t=r&&r.tagName;t&&("INPUT"===t||"TEXTAREA"===t||r.isContentEditable)&&(i||a("input",n)(e),clearTimeout(i),i=window.setTimeout(function(){i=void 0},o))}}]},triggerHandlers=function(r,t){return function(e){if(t)try{r(e)}catch(e){}}},domBreadcrumb=function(t){return function(e){var r;try{r=e.event.target?htmlTreeAsString(e.event.target):htmlTreeAsString(e.event)}catch(e){r="<unknown>"}0!==r.length&&t({type:"dom",category:"ui."+e.name,message:r})}},getConfig=function(e,r){return isObject(e)?__assign(__assign({},r),e):!!e&&r},JS_ERROR_EV_TYPE="js_error",HTTP_EV_TYPE="http";function getPluginConfig(e,r,t){r=null===(e=e.config())||void 0===e?void 0:e.plugins[r];return getConfig(r,t)}var CLICK_EVENT_NAME="click",CLICK_SUBJECT_NAME=CLICK_EVENT_NAME+"_0",DOM_EVENT_TYPE="dom",observeClick=function(e,r){var t=getDefaultDocument();t&&(t.addEventListener(CLICK_EVENT_NAME,e,!0),r(function(){t.removeEventListener(CLICK_EVENT_NAME,e,!0)}))},clickSubject=[CLICK_SUBJECT_NAME,observeClick],KEYPRESS_EVENT_NAME="keypress",KEYPRESS_SUBJECT_NAME=KEYPRESS_EVENT_NAME+"_0",observeKeypress=function(e,r){var t=getDefaultDocument();t&&(t.addEventListener(KEYPRESS_EVENT_NAME,e,!0),r(function(){t.removeEventListener(KEYPRESS_EVENT_NAME,e,!0)}))},keypressSubject=[KEYPRESS_SUBJECT_NAME,observeKeypress],applyBreadcrumb=function(t,n,o){void 0===t&&(t=20),void 0===n&&(n=id),void 0===o&&(o=function(e,r){return e.slice(-r)});var a=[];return[function(){return a},function(e){var r=n(e);r&&(e=__assign(__assign({},r),{timestamp:e.timestamp||now()}),a=0<=t&&a.length+1>t?o(__spreadArray(__spreadArray([],__read(a),!1),[e],!1),t):__spreadArray(__spreadArray([],__read(a),!1),[e],!1))}]},breadcrumbGetterWithDomObserver=function(e,r,t){var n=__read(r,2),o=n[0],a=n[1],i=t.maxBreadcrumbs,u=t.onAddBreadcrumb,c=t.onMaxBreadcrumbs,r=t.dom,n=__read(applyDomAndKeyPress(100),2),t=n[0],n=n[1],u=__read(applyBreadcrumb(i,u,c),2),c=u[0],u=u[1];return r&&(r=domBreadcrumb(u),e.push(o[0](t(CLICK_EVENT_NAME,triggerHandlers(r,DOM_EVENT_TYPE)))),e.push(a[0](n(triggerHandlers(r,DOM_EVENT_TYPE))))),[c,u]},BREADCRUMB_MONITOR_PLUGIN_NAME="breadcrumb",defaultConfig={maxBreadcrumbs:20,dom:!0};function BreadcrumbMonitorPlugin(a){a.on("init",function(){var e,r,t,n,o=getPluginConfig(a,BREADCRUMB_MONITOR_PLUGIN_NAME,defaultConfig);o&&(o=(r=__read(breadcrumbGetterWithDomObserver(e=[],[initSubjectInGlobal(a,clickSubject),initSubjectInGlobal(a,keypressSubject)],o),2))[0],t=r[1],a.on("report",n=function(e){return e.ev_type===HTTP_EV_TYPE&&t({type:HTTP_EV_TYPE,category:e.payload.api,message:"",data:{method:e.payload.request.method,url:e.payload.request.url,status_code:String(e.payload.response.status)},timestamp:e.payload.request.timestamp}),e}),e.push(function(){a.off("report",n)}),registerTearDownGroup(a,BREADCRUMB_MONITOR_PLUGIN_NAME,JS_ERROR_EV_TYPE,e),a.provide("getBreadcrumbs",o),a.provide("addBreadcrumb",t))})}var BREADCRUMB_INTEGRATION_NAME=BREADCRUMB_MONITOR_PLUGIN_NAME,breadcrumbPlugin=function(){return{name:BREADCRUMB_INTEGRATION_NAME,setup:function(e){BreadcrumbMonitorPlugin(e)}}};exports.BREADCRUMB_INTEGRATION_NAME=BREADCRUMB_INTEGRATION_NAME,exports.breadcrumbPlugin=breadcrumbPlugin;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __assign=function(){return(__assign=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e}).apply(this,arguments)};function __read(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,o,a=t.call(e),i=[];try{for(;(void 0===r||0<r--)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(t=a.return)&&t.call(a)}finally{if(o)throw o.error}}return i}function __spreadArray(e,r,t){if(t||2===arguments.length)for(var n,o=0,a=r.length;o<a;o++)!n&&o in r||((n=n||Array.prototype.slice.call(r,0,o))[o]=r[o]);return e.concat(n||Array.prototype.slice.call(r))}function id(e){return e}function isObject(e){return"object"==typeof e&&null!==e}function isString(e){return"string"==typeof e}var registerTearDownGroup=function(e,r,t,n){return e.destroyAgent.set(r,t,n)};function initSubjectInGlobal(e,r){return e.initSubject(r)}var now=function(){return Date.now()};function getDefaultDocument(){if("object"==typeof document&&isObject(document))return document}var UNKNOWN_PATH="<unknown>";function htmlTreeAsString(e){try{for(var r,t=e,n=[],o=0,a=0,i=" > ".length;t&&o++<5&&!("html"===(r=_htmlElementAsString(t))||1<o&&256<=a+n.length*i+r.length);)n.push(r),a+=r.length,t=t.parentNode;return n.reverse().join(" > ")}catch(e){return UNKNOWN_PATH}}function _htmlElementAsString(e){var r,t,n,o=e,a=[];if(!o||!o.tagName)return"";a.push(o.tagName.toLowerCase()),o.id&&a.push("#"+o.id);e=o.className;if(e&&isString(e))for(r=e.split(/\s+/),u=0;u<r.length;u++)a.push("."+r[u]);for(var i=["type","name","title","alt"],u=0;u<i.length;u++)(n=o.getAttribute(t=i[u]))&&a.push("["+t+'="'+n+'"]');return a.join("")}var applyDomAndKeyPress=function(o){function a(r,t){var n;return function(e){i=void 0,e&&n!==e&&t({event:n=e,name:r})}}var i;return[a,function(n){return function(e){var r;try{r=e.target}catch(e){return}var t=r&&r.tagName;t&&("INPUT"===t||"TEXTAREA"===t||r.isContentEditable)&&(i||a("input",n)(e),clearTimeout(i),i=window.setTimeout(function(){i=void 0},o))}}]},triggerHandlers=function(r,t){return function(e){if(t)try{r(e)}catch(e){}}},domBreadcrumb=function(t){return function(e){var r;try{r=e.event.target?htmlTreeAsString(e.event.target):htmlTreeAsString(e.event)}catch(e){r="<unknown>"}0!==r.length&&t({type:"dom",category:"ui."+e.name,message:r})}},getConfig=function(e,r){return isObject(e)?__assign(__assign({},r),e):!!e&&r},JS_ERROR_EV_TYPE="js_error",HTTP_EV_TYPE="http";function getPluginConfig(e,r,t){r=null===(e=e.config())||void 0===e?void 0:e.plugins[r];return getConfig(r,t)}var CLICK_EVENT_NAME="click",CLICK_SUBJECT_NAME=CLICK_EVENT_NAME+"_0",DOM_EVENT_TYPE="dom",observeClick=function(e,r){var t=getDefaultDocument();t&&(t.addEventListener(CLICK_EVENT_NAME,e,!0),r(function(){t.removeEventListener(CLICK_EVENT_NAME,e,!0)}))},clickSubject=[CLICK_SUBJECT_NAME,observeClick],KEYPRESS_EVENT_NAME="keypress",KEYPRESS_SUBJECT_NAME=KEYPRESS_EVENT_NAME+"_0",observeKeypress=function(e,r){var t=getDefaultDocument();t&&(t.addEventListener(KEYPRESS_EVENT_NAME,e,!0),r(function(){t.removeEventListener(KEYPRESS_EVENT_NAME,e,!0)}))},keypressSubject=[KEYPRESS_SUBJECT_NAME,observeKeypress],applyBreadcrumb=function(t,n,o){void 0===t&&(t=20),void 0===n&&(n=id),void 0===o&&(o=function(e,r){return e.slice(-r)});var a=[];return[function(){return a},function(e){var r=n(e);r&&(e=__assign(__assign({},r),{timestamp:e.timestamp||now()}),a=0<=t&&a.length+1>t?o(__spreadArray(__spreadArray([],__read(a),!1),[e],!1),t):__spreadArray(__spreadArray([],__read(a),!1),[e],!1))}]},breadcrumbGetterWithDomObserver=function(e,r,t){var n=__read(r,2),o=n[0],a=n[1],i=t.maxBreadcrumbs,u=t.onAddBreadcrumb,c=t.onMaxBreadcrumbs,r=t.dom,n=__read(applyDomAndKeyPress(100),2),t=n[0],n=n[1],u=__read(applyBreadcrumb(i,u,c),2),c=u[0],u=u[1];return r&&(r=domBreadcrumb(u),e.push(o[0](t(CLICK_EVENT_NAME,triggerHandlers(r,DOM_EVENT_TYPE)))),e.push(a[0](n(triggerHandlers(r,DOM_EVENT_TYPE))))),[c,u]},BREADCRUMB_MONITOR_PLUGIN_NAME="breadcrumb",defaultConfig={maxBreadcrumbs:20,dom:!0};function BreadcrumbMonitorPlugin(a){a.on("init",function(){var e,r,t,n,o=getPluginConfig(a,BREADCRUMB_MONITOR_PLUGIN_NAME,defaultConfig);o&&(o=(r=__read(breadcrumbGetterWithDomObserver(e=[],[initSubjectInGlobal(a,clickSubject),initSubjectInGlobal(a,keypressSubject)],o),2))[0],t=r[1],a.on("report",n=function(e){return e.ev_type===HTTP_EV_TYPE&&t({type:HTTP_EV_TYPE,category:e.payload.api,message:"",data:{method:e.payload.request.method,url:e.payload.request.url,status_code:String(e.payload.response.status)},timestamp:e.payload.request.timestamp}),e}),e.push(function(){a.off("report",n)}),registerTearDownGroup(a,BREADCRUMB_MONITOR_PLUGIN_NAME,JS_ERROR_EV_TYPE,e),a.provide("getBreadcrumbs",o),a.provide("addBreadcrumb",t))})}var BREADCRUMB_INTEGRATION_NAME=BREADCRUMB_MONITOR_PLUGIN_NAME,breadcrumbPlugin=function(){return{name:BREADCRUMB_INTEGRATION_NAME,setup:function(e){BreadcrumbMonitorPlugin(e)}}};exports.BREADCRUMB_INTEGRATION_NAME=BREADCRUMB_INTEGRATION_NAME,exports.breadcrumbPlugin=breadcrumbPlugin;

@@ -11,2 +11,3 @@ interface ContextAgent {

declare type ParametersForFn<T extends (args: any) => any> = T extends (args: infer P) => any ? P : never;
declare type Filter<E> = (e: E) => boolean;
declare type SafeObservable<T> = [(f: T) => () => void, (f: T) => void];

@@ -172,2 +173,3 @@ declare type Observer<T extends (args: any) => any> = (next: (args: ParametersForFn<T>) => ReturnType<NextLink<T>>, attach: (disconnect: () => void, onSubscribe?: (f: T) => void) => void) => void;

declare type WithSubject<C extends AnyClient> = C & {
setFilter: (filterKey: string, filter: Filter<any>) => void;
initSubject: <T extends (args: any) => any>(args: [subjectKey: string, collector: Observer<T>]) => SafeObservable<T>;

@@ -774,5 +776,6 @@ getSubject: (key: string) => SafeObservable<any> | undefined;

collectBodyOnError: boolean;
extraExtractor?: (body: string | any, related: HttpPayload) => {
extraExtractor?: (resBody: string | any, related: HttpPayload, reqBody: any) => {
[key: string]: string;
} | false;
extractUrl?: (originalUrl: string) => string;
trace?: TraceConfig | boolean;

@@ -779,0 +782,0 @@ setTraceHeader?: (url: string, cb: (key: string, value: string) => void) => void;

@@ -11,2 +11,3 @@ interface ContextAgent {

declare type ParametersForFn<T extends (args: any) => any> = T extends (args: infer P) => any ? P : never;
declare type Filter<E> = (e: E) => boolean;
declare type SafeObservable<T> = [(f: T) => () => void, (f: T) => void];

@@ -172,2 +173,3 @@ declare type Observer<T extends (args: any) => any> = (next: (args: ParametersForFn<T>) => ReturnType<NextLink<T>>, attach: (disconnect: () => void, onSubscribe?: (f: T) => void) => void) => void;

declare type WithSubject<C extends AnyClient> = C & {
setFilter: (filterKey: string, filter: Filter<any>) => void;
initSubject: <T extends (args: any) => any>(args: [subjectKey: string, collector: Observer<T>]) => SafeObservable<T>;

@@ -774,5 +776,6 @@ getSubject: (key: string) => SafeObservable<any> | undefined;

collectBodyOnError: boolean;
extraExtractor?: (body: string | any, related: HttpPayload) => {
extraExtractor?: (resBody: string | any, related: HttpPayload, reqBody: any) => {
[key: string]: string;
} | false;
extractUrl?: (originalUrl: string) => string;
trace?: TraceConfig | boolean;

@@ -779,0 +782,0 @@ setTraceHeader?: (url: string, cb: (key: string, value: string) => void) => void;

@@ -11,2 +11,3 @@ interface ContextAgent {

declare type ParametersForFn<T extends (args: any) => any> = T extends (args: infer P) => any ? P : never;
declare type Filter<E> = (e: E) => boolean;
declare type SafeObservable<T> = [(f: T) => () => void, (f: T) => void];

@@ -172,2 +173,3 @@ declare type Observer<T extends (args: any) => any> = (next: (args: ParametersForFn<T>) => ReturnType<NextLink<T>>, attach: (disconnect: () => void, onSubscribe?: (f: T) => void) => void) => void;

declare type WithSubject<C extends AnyClient> = C & {
setFilter: (filterKey: string, filter: Filter<any>) => void;
initSubject: <T extends (args: any) => any>(args: [subjectKey: string, collector: Observer<T>]) => SafeObservable<T>;

@@ -774,5 +776,6 @@ getSubject: (key: string) => SafeObservable<any> | undefined;

collectBodyOnError: boolean;
extraExtractor?: (body: string | any, related: HttpPayload) => {
extraExtractor?: (resBody: string | any, related: HttpPayload, reqBody: any) => {
[key: string]: string;
} | false;
extractUrl?: (originalUrl: string) => string;
trace?: TraceConfig | boolean;

@@ -779,0 +782,0 @@ setTraceHeader?: (url: string, cb: (key: string, value: string) => void) => void;

@@ -386,3 +386,2 @@ /*! *****************************************************************************

/* eslint-disable @typescript-eslint/no-invalid-void-type */
var nextLink = function (args, cb) {

@@ -389,0 +388,0 @@ var nextCbs = [];

@@ -11,2 +11,3 @@ interface ContextAgent {

declare type ParametersForFn<T extends (args: any) => any> = T extends (args: infer P) => any ? P : never;
declare type Filter<E> = (e: E) => boolean;
declare type SafeObservable<T> = [(f: T) => () => void, (f: T) => void];

@@ -172,2 +173,3 @@ declare type Observer<T extends (args: any) => any> = (next: (args: ParametersForFn<T>) => ReturnType<NextLink<T>>, attach: (disconnect: () => void, onSubscribe?: (f: T) => void) => void) => void;

declare type WithSubject<C extends AnyClient> = C & {
setFilter: (filterKey: string, filter: Filter<any>) => void;
initSubject: <T extends (args: any) => any>(args: [subjectKey: string, collector: Observer<T>]) => SafeObservable<T>;

@@ -774,5 +776,6 @@ getSubject: (key: string) => SafeObservable<any> | undefined;

collectBodyOnError: boolean;
extraExtractor?: (body: string | any, related: HttpPayload) => {
extraExtractor?: (resBody: string | any, related: HttpPayload, reqBody: any) => {
[key: string]: string;
} | false;
extractUrl?: (originalUrl: string) => string;
trace?: TraceConfig | boolean;

@@ -779,0 +782,0 @@ setTraceHeader?: (url: string, cb: (key: string, value: string) => void) => void;

@@ -11,2 +11,3 @@ interface ContextAgent {

declare type ParametersForFn<T extends (args: any) => any> = T extends (args: infer P) => any ? P : never;
declare type Filter<E> = (e: E) => boolean;
declare type SafeObservable<T> = [(f: T) => () => void, (f: T) => void];

@@ -172,2 +173,3 @@ declare type Observer<T extends (args: any) => any> = (next: (args: ParametersForFn<T>) => ReturnType<NextLink<T>>, attach: (disconnect: () => void, onSubscribe?: (f: T) => void) => void) => void;

declare type WithSubject<C extends AnyClient> = C & {
setFilter: (filterKey: string, filter: Filter<any>) => void;
initSubject: <T extends (args: any) => any>(args: [subjectKey: string, collector: Observer<T>]) => SafeObservable<T>;

@@ -774,5 +776,6 @@ getSubject: (key: string) => SafeObservable<any> | undefined;

collectBodyOnError: boolean;
extraExtractor?: (body: string | any, related: HttpPayload) => {
extraExtractor?: (resBody: string | any, related: HttpPayload, reqBody: any) => {
[key: string]: string;
} | false;
extractUrl?: (originalUrl: string) => string;
trace?: TraceConfig | boolean;

@@ -779,0 +782,0 @@ setTraceHeader?: (url: string, cb: (key: string, value: string) => void) => void;

@@ -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){_&&(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 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;

@@ -11,2 +11,3 @@ interface ContextAgent {

declare type ParametersForFn<T extends (args: any) => any> = T extends (args: infer P) => any ? P : never;
declare type Filter<E> = (e: E) => boolean;
declare type SafeObservable<T> = [(f: T) => () => void, (f: T) => void];

@@ -172,2 +173,3 @@ declare type Observer<T extends (args: any) => any> = (next: (args: ParametersForFn<T>) => ReturnType<NextLink<T>>, attach: (disconnect: () => void, onSubscribe?: (f: T) => void) => void) => void;

declare type WithSubject<C extends AnyClient> = C & {
setFilter: (filterKey: string, filter: Filter<any>) => void;
initSubject: <T extends (args: any) => any>(args: [subjectKey: string, collector: Observer<T>]) => SafeObservable<T>;

@@ -774,5 +776,6 @@ getSubject: (key: string) => SafeObservable<any> | undefined;

collectBodyOnError: boolean;
extraExtractor?: (body: string | any, related: HttpPayload) => {
extraExtractor?: (resBody: string | any, related: HttpPayload, reqBody: any) => {
[key: string]: string;
} | false;
extractUrl?: (originalUrl: string) => string;
trace?: TraceConfig | boolean;

@@ -779,0 +782,0 @@ setTraceHeader?: (url: string, cb: (key: string, value: string) => void) => void;

@@ -11,2 +11,3 @@ interface ContextAgent {

declare type ParametersForFn<T extends (args: any) => any> = T extends (args: infer P) => any ? P : never;
declare type Filter<E> = (e: E) => boolean;
declare type SafeObservable<T> = [(f: T) => () => void, (f: T) => void];

@@ -172,2 +173,3 @@ declare type Observer<T extends (args: any) => any> = (next: (args: ParametersForFn<T>) => ReturnType<NextLink<T>>, attach: (disconnect: () => void, onSubscribe?: (f: T) => void) => void) => void;

declare type WithSubject<C extends AnyClient> = C & {
setFilter: (filterKey: string, filter: Filter<any>) => void;
initSubject: <T extends (args: any) => any>(args: [subjectKey: string, collector: Observer<T>]) => SafeObservable<T>;

@@ -774,5 +776,6 @@ getSubject: (key: string) => SafeObservable<any> | undefined;

collectBodyOnError: boolean;
extraExtractor?: (body: string | any, related: HttpPayload) => {
extraExtractor?: (resBody: string | any, related: HttpPayload, reqBody: any) => {
[key: string]: string;
} | false;
extractUrl?: (originalUrl: string) => string;
trace?: TraceConfig | boolean;

@@ -779,0 +782,0 @@ setTraceHeader?: (url: string, cb: (key: string, value: string) => void) => void;

{
"name": "@apmplus/integrations",
"version": "2.1.3",
"version": "2.1.4-alpha.0",
"description": "APMPlus Integrations",

@@ -61,3 +61,3 @@ "main": "dist/index.js",

"devDependencies": {
"@slardar/rollup": "0.0.3-alpha.0"
"@slardar/rollup": "0.0.3"
},

@@ -64,0 +64,0 @@ "scripts": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc