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 1.2.2 to 2.0.0

41

dist/action.d.ts

@@ -115,2 +115,7 @@ declare type BatchSender<E> = EventSender<E> & {

declare type ParametersForFn<T extends (args: any) => any> = T extends (args: infer P) => any ? P : never;
declare type SafeObservable<T> = [(f: T) => () => void, (f: T) => void];
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 NextLink<T extends (args: any) => any> = (args: ParametersForFn<T>, cb: T[]) => NextLink<ReturnType<T>>;
declare type WithContext<C extends AnyClient> = C & {

@@ -142,2 +147,7 @@ context?: ContextAgent;

declare type WithSubject<C extends AnyClient> = C & {
initSubject: <T extends (args: any) => any>(args: [subjectKey: string, collector: Observer<T>]) => SafeObservable<T>;
getSubject: (key: string) => SafeObservable<any> | undefined;
};
/** 公共筛选条件 */

@@ -727,6 +737,7 @@ interface FilterCondition {

onPidUpdate?: (pid: string) => void;
createObserver?: (mode: string) => SafeObservable<(args: string) => void>;
}
declare const PAGEVIEW_MONITOR_PLUGIN_NAME = "pageview";
declare type WithSendPageview<C extends WebClient$1> = C & {
declare type WithSendPageview<C extends WithSubject<WebClient$1>> = C & {
sendPageview?: SendPageview;

@@ -783,3 +794,5 @@ };

lcp = "lcp",
cls = "cls"
cls = "cls",
longtask = "longtask",
timing = "timing"
}

@@ -792,5 +805,2 @@ interface PerformancePrecollect {

[key in MetricEnum]: boolean;
} & {
timing: boolean;
longtask: boolean;
};

@@ -1011,4 +1021,3 @@

type PrecollectArg = [string, string, PrecollectData, number, string]
type BrowserClient =
WithDetectBlankScreen<
type BrowserClient = WithDetectBlankScreen<
WithBreadcrumb<

@@ -1021,10 +1030,12 @@ WithReportResourceError<

WithContext<
Client<
BrowserReportEvent,
BrowserSendEvent,
BrowserBuilder,
BrowserSender,
BrowserInitConfig,
BrowserUserConfig,
BrowserConfig
WithSubject<
Client<
BrowserReportEvent,
BrowserSendEvent,
BrowserBuilder,
BrowserSender,
BrowserInitConfig,
BrowserUserConfig,
BrowserConfig
>
>

@@ -1031,0 +1042,0 @@ >

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __assign=function(){return(__assign=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function __read(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,a=r.call(t),i=[];try{for(;(void 0===e||0<e--)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i}function __spreadArray(t,e,r){if(r||2===arguments.length)for(var n,o=0,a=e.length;o<a;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))}function isObject(t){return"object"==typeof t&&null!==t}var objProto=Object.prototype;function isArray(t){return"[object Array]"===objProto.toString.call(t)}function isFunction(t){return"function"==typeof t}function arrayIncludes(t,e){if(!isArray(t))return!1;if(0===t.length)return!1;for(var r=0;r<t.length;){if(t[r]===e)return!0;r++}return!1}var applyRecord=function(){var r={};return[r,function(t,e){return r[t]=e},function(t){return delete r[t]}]},hookMethodDangerously=function(r,n,o){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];r[n]=o.apply(void 0,__spreadArray([r[n]],__read(t),!1))}};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)}function getDefaultBrowser(){if("object"==typeof window&&isObject(window))return window}function getDefaultDocument(){if("object"==typeof document&&isObject(document))return document}function getDefaultPerformance(){if(getDefaultBrowser()&&isObject(window.performance))return window.performance}function getDefaultXMLHttpRequest(){if("function"==typeof XMLHttpRequest&&isFunction(XMLHttpRequest))return XMLHttpRequest}function getDefaultMutationObserver(){if(getDefaultBrowser()&&isFunction(window.MutationObserver))return window.MutationObserver}var getGlobalRegistry=function(t){if(t)return t.__SLARDAR_REGISTRY__||(t.__SLARDAR_REGISTRY__={Slardar:{plugins:[],errors:[]}}),t.__SLARDAR_REGISTRY__.Slardar},reportSelfError=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=getGlobalRegistry(getDefaultBrowser());r&&(r.errors||(r.errors=[]),r.errors.push(t))},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)||[]}]},applyMonitor=function(t,e,r,n){void 0===e&&(e={}),void 0===n&&(n=[]);try{var o=t.apply(void 0,__spreadArray([],__read(n),!1));return o&&o(e,r)||[]}catch(t){return reportSelfError(t),[]}},PAGE_ACTIVITY_DELAY=100,MAX_PAGE_ACTIVITY_DELAY=1e4,hookXHRSend=function(r,o,a){var i=0;return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=i+=2;return o(n,Date.now()),hookMethodDangerously(this,"onreadystatechange",function(r){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return 4===this.readyState&&a(n),r&&r.apply(this,t)}})(),r.apply(this,t)}},hookFetch=function(o,a,i){var u=1;return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=o.apply(void 0,__spreadArray([],__read(t),!1)),n=u+=2;a(n,Date.now());return r.then(function(){i(n)},function(){i(n)}),r}},applyIncompleteReq=function(t,e){var r=__read(applyRecord(),3),n=r[0],o=r[1],r=r[2];return e&&hookMethodDangerously(e.prototype,"send",hookXHRSend)(o,r),t&&hookMethodDangerously(t,"fetch",hookFetch)(o,r),[n]},waitActionComplete=function(t,e,r){var n,o;return[function(){r.clearTimeout(o),o=r.setTimeout(function(){t(),e()},MAX_PAGE_ACTIVITY_DELAY)},function(){r.clearTimeout(n),n=r.setTimeout(function(){t()},PAGE_ACTIVITY_DELAY)},function(){r.clearTimeout(n),r.clearTimeout(o)}]},getDomPath=function(t){var e=t,r=[];try{for(;null!==e.parentNode;){for(var n=0,o=0,a=0;a<e.parentNode.childNodes.length;a++){var i=e.parentNode.childNodes[a];i.nodeName===e.nodeName&&(i===e&&(o=n),n++)}e.hasAttribute("id")&&""!==e.id?r.unshift(e.nodeName+"#"+e.id):1<n?r.unshift(e.nodeName+":eq("+o+")"):r.unshift(e.nodeName),e=e.parentNode}return r.slice(1).join(">")}catch(t){return}},ACTION_EV_TYPE="action",HTTP_EV_TYPE="http",LONGTASK_RV_TYPE="performance_longtask",JS_ERROR_EV_TYPE="js_error",RESOURCE_EV_TYPE="resource",RELATED_EV_TYPES=[LONGTASK_RV_TYPE,HTTP_EV_TYPE,JS_ERROR_EV_TYPE,RESOURCE_EV_TYPE],SUPPORT_TYPES=["click"],EVENT_LISTENER_OPTIONS={capture:!0},ActionMonitor=function(T,g,h,m,P){if(void 0===T&&(T=getDefaultBrowser()),void 0===g&&(g=getDefaultDocument()),void 0===h&&(h=getDefaultXMLHttpRequest()),void 0===m&&(m=getDefaultMutationObserver()),void 0===P&&(P=getDefaultPerformance()),g&&T)return function(t,r){var e=t.types,n=[],o=null,a=[],i=0,u=__read(applyPerformance(P),2)[1],c=__read(applyIncompleteReq(T,h),1)[0],f=function(){var t,e;o&&Object.keys(o.metrics).length&&!Object.keys(c).length&&(o.metrics[LONGTASK_RV_TYPE]&&(o.metrics[LONGTASK_RV_TYPE].duration=i),t=0<a.length?Math.max.apply(Math,__spreadArray([],__read(a),!1))-Math.min.apply(Math,__spreadArray([],__read(a),!1)):0,o.metrics[HTTP_EV_TYPE]&&(o.metrics[HTTP_EV_TYPE].duration=t),e=u()-o.start_time,r&&r({ev_type:ACTION_EV_TYPE,payload:__assign(__assign({},o),{duration:e,frontend_time:e-t})}),_())},_=function(){d(),o=null,a=[],i=0},l=__read(waitActionComplete(f,_,T),3),s=l[0],p=l[1],d=l[2],t=__read(applyMutationObserver(m,p),2),l=t[0],y=t[1];l();function v(t){var e;f(),_(),t.target instanceof HTMLElement&&((e=t.target.innerText)&&(E({name:e,path:getDomPath(t.target)},t.type),s()))}var E=function(t,e){var r=uuid(),n=__read(applyPerformance(P),2)[1];o={start_time:n(),id:r,type:e,target:t,metrics:{}}};e&&e.forEach(function(t){arrayIncludes(SUPPORT_TYPES,t)&&(g.addEventListener(t,v,EVENT_LISTENER_OPTIONS),n.push(function(){return g.removeEventListener(t,v,EVENT_LISTENER_OPTIONS)}))});return[function(){n.forEach(function(t){return t()}),y()},function(t){if(o&&arrayIncludes(RELATED_EV_TYPES,t.ev_type)){if(p(),t.ev_type===HTTP_EV_TYPE){if(!t.payload.response.timing)return;var e=t.payload.response.timing,r=e.startTime,e=e.duration;if(r<o.start_time)return;a.push(r,r+e)}else if(t.ev_type===LONGTASK_RV_TYPE){if(!t.payload.longtasks.length||t.payload.longtasks[0].startTime<o.start_time)return;t.payload.longtasks.forEach(function(t){i+=t.duration})}else if(t.ev_type===RESOURCE_EV_TYPE&&t.payload.startTime<o.start_time)return;return o.metrics[t.ev_type]={count:(null!==(t=null===(t=o.metrics[t.ev_type])||void 0===t?void 0:t.count)&&void 0!==t?t:0)+1},o.id}},function(t,e){f(),_(),E({name:t},e),s()}]}},ACTION_MONITOR_PLUGIN_NAME="action",defaultConfig={types:["click"]};function ActionMonitorBasePlugin(t,e){function r(t){var e=o(t);return e&&t.extra&&(t.extra.action_id=e),t}var e=__read(applyMonitor(ActionMonitor,e=void 0===e?defaultConfig:e,t.report.bind(t)),3),n=e[0],o=e[1],e=e[2];t.on("report",r),t.provide("startAction",e),t.on("beforeDestroy",function(){n(),t.off("report",r)})}var actionPlugin=function(e){return{name:ACTION_MONITOR_PLUGIN_NAME,setup:function(t){ActionMonitorBasePlugin(t,e)}}};exports.actionPlugin=actionPlugin;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __assign=function(){return(__assign=Object.assign||function(t){for(var r,e=1,n=arguments.length;e<n;e++)for(var o in r=arguments[e])Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o]);return t}).apply(this,arguments)};function __read(t,r){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var n,o,a=e.call(t),i=[];try{for(;(void 0===r||0<r--)&&!(n=a.next()).done;)i.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(e=a.return)&&e.call(a)}finally{if(o)throw o.error}}return i}function __spreadArray(t,r,e){if(e||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 t.concat(n||Array.prototype.slice.call(r))}var noop=function(){return{}};function isObject(t){return"object"==typeof t&&null!==t}var objProto=Object.prototype;function isArray(t){return"[object Array]"===objProto.toString.call(t)}function isFunction(t){return"function"==typeof t}function arrayIncludes(t,r){if(!isArray(t))return!1;if(0===t.length)return!1;for(var e=0;e<t.length;){if(t[e]===r)return!0;e++}return!1}var applyRecord=function(){var e={};return[e,function(t,r){return e[t]=r},function(t){return delete e[t]}]},hookMethodDangerously=function(a,i,u){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(!a)return noop;var e=a[i],n=u.apply(void 0,__spreadArray([e],__read(t),!1)),o=n;return isFunction(o)&&(o=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return n.apply(this,t)}),a[i]=o,function(){o===a[i]?a[i]=e:n=e}}};function mathRNG(){for(var t=new Array(16),r=0,e=0;e<16;e++)0==(3&e)&&(r=4294967296*Math.random()),t[e]=r>>>((3&e)<<3)&255;return t}function bytesToUuid(t){for(var r=[],e=0;e<256;++e)r[e]=(e+256).toString(16).substr(1);var n=0,o=r;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)}function getDefaultBrowser(){if("object"==typeof window&&isObject(window))return window}function getDefaultDocument(){if("object"==typeof document&&isObject(document))return document}function getDefaultPerformance(){if(getDefaultBrowser()&&isObject(window.performance))return window.performance}function getDefaultXMLHttpRequest(){if("function"==typeof XMLHttpRequest&&isFunction(XMLHttpRequest))return XMLHttpRequest}function getDefaultMutationObserver(){if(getDefaultBrowser()&&isFunction(window.MutationObserver))return window.MutationObserver}var getGlobalRegistry=function(t){if(t)return t.__SLARDAR_REGISTRY__||(t.__SLARDAR_REGISTRY__={Slardar:{plugins:[],errors:[],subject:{}}}),t.__SLARDAR_REGISTRY__.Slardar},reportSelfError=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var e=getGlobalRegistry(getDefaultBrowser());e&&(e.errors||(e.errors=[]),e.errors.push(t))},applyMutationObserver=function(t,r){var e=t&&new t(r);return[function(t,r){e&&t&&e.observe(t,r)},function(){return e&&e.disconnect()}]},applyPerformance=function(e){var t=e&&e.timing||void 0;return[t,function(){return e&&e.now?e.now():(Date.now?Date.now():+new Date)-(t&&t.navigationStart||0)},function(t){var r=(e||{}).getEntriesByType;return isFunction(r)&&r.call(e,t)||[]},function(){var t=(e||{}).clearResourceTimings;isFunction(t)&&t.call(e)},function(t){var r=(e||{}).getEntriesByName;return isFunction(r)&&r.call(e,t)||[]}]},applyMonitor=function(t,r,e,n){void 0===r&&(r={}),void 0===n&&(n=[]);try{var o=t.apply(void 0,__spreadArray([],__read(n),!1));return o&&o(r,e)||[]}catch(t){return reportSelfError(t),[]}},now=function(){return Date.now()},PAGE_ACTIVITY_DELAY=100,MAX_PAGE_ACTIVITY_DELAY=1e4,hookXHRSend=function(e,o,a){var i=0;return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=i+=2;return o(n,now()),hookMethodDangerously(this,"onreadystatechange",function(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return 4===this.readyState&&a(n),e&&e.apply(this,t)}})(),e.apply(this,t)}},hookFetch=function(o,a,i){var u=1;return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var e=o.apply(void 0,__spreadArray([],__read(t),!1)),n=u+=2;a(n,now());return e.then(function(){i(n)},function(){i(n)}),e}},applyIncompleteReq=function(t,r){var e=__read(applyRecord(),3),n=e[0],o=e[1],e=e[2];return r&&hookMethodDangerously(r.prototype,"send",hookXHRSend)(o,e),t&&hookMethodDangerously(t,"fetch",hookFetch)(o,e),[n]},waitActionComplete=function(t,r,e){var n,o;return[function(){e.clearTimeout(o),o=e.setTimeout(function(){t(),r()},MAX_PAGE_ACTIVITY_DELAY)},function(){e.clearTimeout(n),n=e.setTimeout(function(){t()},PAGE_ACTIVITY_DELAY)},function(){e.clearTimeout(n),e.clearTimeout(o)}]},getDomPath=function(t){var r=t,e=[];try{for(;null!==r.parentNode;){for(var n=0,o=0,a=0;a<r.parentNode.childNodes.length;a++){var i=r.parentNode.childNodes[a];i.nodeName===r.nodeName&&(i===r&&(o=n),n++)}r.hasAttribute("id")&&""!==r.id?e.unshift(r.nodeName+"#"+r.id):1<n?e.unshift(r.nodeName+":eq("+o+")"):e.unshift(r.nodeName),r=r.parentNode}return e.slice(1).join(">")}catch(t){return}},ACTION_EV_TYPE="action",HTTP_EV_TYPE="http",LONGTASK_RV_TYPE="performance_longtask",JS_ERROR_EV_TYPE="js_error",RESOURCE_EV_TYPE="resource",RELATED_EV_TYPES=[LONGTASK_RV_TYPE,HTTP_EV_TYPE,JS_ERROR_EV_TYPE,RESOURCE_EV_TYPE],SUPPORT_TYPES=["click"],EVENT_LISTENER_OPTIONS={capture:!0},ActionMonitor=function(T,g,h,m,P){if(void 0===T&&(T=getDefaultBrowser()),void 0===g&&(g=getDefaultDocument()),void 0===h&&(h=getDefaultXMLHttpRequest()),void 0===m&&(m=getDefaultMutationObserver()),void 0===P&&(P=getDefaultPerformance()),g&&T)return function(t,e){var r=t.types,n=[],o=null,a=[],i=0,u=__read(applyPerformance(P),2)[1],c=__read(applyIncompleteReq(T,h),1)[0],f=function(){var t,r;o&&Object.keys(o.metrics).length&&!Object.keys(c).length&&(o.metrics[LONGTASK_RV_TYPE]&&(o.metrics[LONGTASK_RV_TYPE].duration=i),t=0<a.length?Math.max.apply(Math,__spreadArray([],__read(a),!1))-Math.min.apply(Math,__spreadArray([],__read(a),!1)):0,o.metrics[HTTP_EV_TYPE]&&(o.metrics[HTTP_EV_TYPE].duration=t),r=u()-o.start_time,e&&e({ev_type:ACTION_EV_TYPE,payload:__assign(__assign({},o),{duration:r,frontend_time:r-t})}),_())},_=function(){d(),o=null,a=[],i=0},l=__read(waitActionComplete(f,_,T),3),s=l[0],p=l[1],d=l[2],t=__read(applyMutationObserver(m,p),2),l=t[0],y=t[1];l();function v(t){var r;f(),_(),t.target instanceof HTMLElement&&((r=t.target.innerText)&&(E({name:r,path:getDomPath(t.target)},t.type),s()))}var E=function(t,r){var e=uuid(),n=__read(applyPerformance(P),2)[1];o={start_time:n(),id:e,type:r,target:t,metrics:{}}};r&&r.forEach(function(t){arrayIncludes(SUPPORT_TYPES,t)&&(g.addEventListener(t,v,EVENT_LISTENER_OPTIONS),n.push(function(){return g.removeEventListener(t,v,EVENT_LISTENER_OPTIONS)}))});return[function(){n.forEach(function(t){return t()}),y()},function(t){if(o&&arrayIncludes(RELATED_EV_TYPES,t.ev_type)){if(p(),t.ev_type===HTTP_EV_TYPE){if(!t.payload.response.timing)return;var r=t.payload.response.timing,e=r.startTime,r=r.duration;if(e<o.start_time)return;a.push(e,e+r)}else if(t.ev_type===LONGTASK_RV_TYPE){if(!t.payload.longtasks.length||t.payload.longtasks[0].startTime<o.start_time)return;t.payload.longtasks.forEach(function(t){i+=t.duration})}else if(t.ev_type===RESOURCE_EV_TYPE&&t.payload.startTime<o.start_time)return;return o.metrics[t.ev_type]={count:(null!==(t=null===(t=o.metrics[t.ev_type])||void 0===t?void 0:t.count)&&void 0!==t?t:0)+1},o.id}},function(t,r){f(),_(),E({name:t},r),s()}]}},ACTION_MONITOR_PLUGIN_NAME="action",defaultConfig={types:["click"]};function ActionMonitorBasePlugin(t,r){function e(t){var r=o(t);return r&&t.extra&&(t.extra.action_id=r),t}var r=__read(applyMonitor(ActionMonitor,r=void 0===r?defaultConfig:r,t.report.bind(t)),3),n=r[0],o=r[1],r=r[2];t.on("report",e),t.provide("startAction",r),t.on("beforeDestroy",function(){n(),t.off("report",e)})}var actionPlugin=function(r){return{name:ACTION_MONITOR_PLUGIN_NAME,setup:function(t){ActionMonitorBasePlugin(t,r)}}};exports.actionPlugin=actionPlugin;

@@ -115,2 +115,7 @@ declare type BatchSender<E> = EventSender<E> & {

declare type ParametersForFn<T extends (args: any) => any> = T extends (args: infer P) => any ? P : never;
declare type SafeObservable<T> = [(f: T) => () => void, (f: T) => void];
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 NextLink<T extends (args: any) => any> = (args: ParametersForFn<T>, cb: T[]) => NextLink<ReturnType<T>>;
declare type WithContext<C extends AnyClient> = C & {

@@ -142,2 +147,7 @@ context?: ContextAgent;

declare type WithSubject<C extends AnyClient> = C & {
initSubject: <T extends (args: any) => any>(args: [subjectKey: string, collector: Observer<T>]) => SafeObservable<T>;
getSubject: (key: string) => SafeObservable<any> | undefined;
};
/** 公共筛选条件 */

@@ -727,6 +737,7 @@ interface FilterCondition {

onPidUpdate?: (pid: string) => void;
createObserver?: (mode: string) => SafeObservable<(args: string) => void>;
}
declare const PAGEVIEW_MONITOR_PLUGIN_NAME = "pageview";
declare type WithSendPageview<C extends WebClient$1> = C & {
declare type WithSendPageview<C extends WithSubject<WebClient$1>> = C & {
sendPageview?: SendPageview;

@@ -783,3 +794,5 @@ };

lcp = "lcp",
cls = "cls"
cls = "cls",
longtask = "longtask",
timing = "timing"
}

@@ -792,5 +805,2 @@ interface PerformancePrecollect {

[key in MetricEnum]: boolean;
} & {
timing: boolean;
longtask: boolean;
};

@@ -1011,4 +1021,3 @@

type PrecollectArg = [string, string, PrecollectData, number, string]
type BrowserClient =
WithDetectBlankScreen<
type BrowserClient = WithDetectBlankScreen<
WithBreadcrumb<

@@ -1021,10 +1030,12 @@ WithReportResourceError<

WithContext<
Client<
BrowserReportEvent,
BrowserSendEvent,
BrowserBuilder,
BrowserSender,
BrowserInitConfig,
BrowserUserConfig,
BrowserConfig
WithSubject<
Client<
BrowserReportEvent,
BrowserSendEvent,
BrowserBuilder,
BrowserSender,
BrowserInitConfig,
BrowserUserConfig,
BrowserConfig
>
>

@@ -1031,0 +1042,0 @@ >

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __assign=function(){return(__assign=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var o in n=arguments[r])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e}).apply(this,arguments)};function __read(e,n){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var t,o,i=r.call(e),a=[];try{for(;(void 0===n||0<n--)&&!(t=i.next()).done;)a.push(t.value)}catch(e){o={error:e}}finally{try{t&&!t.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function __spreadArray(e,n,r){if(r||2===arguments.length)for(var t,o=0,i=n.length;o<i;o++)!t&&o in n||((t=t||Array.prototype.slice.call(n,0,o))[o]=n[o]);return e.concat(t||Array.prototype.slice.call(n))}function isObject(e){return"object"==typeof e&&null!==e}function isFunction(e){return"function"==typeof e}function getDefaultBrowser(){if("object"==typeof window&&isObject(window))return window}function getDefaultDocument(){if("object"==typeof document&&isObject(document))return document}function getDefaultPerformance(){if(getDefaultBrowser()&&isObject(window.performance))return window.performance}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 getGlobalRegistry=function(e){if(e)return e.__SLARDAR_REGISTRY__||(e.__SLARDAR_REGISTRY__={Slardar:{plugins:[],errors:[]}}),e.__SLARDAR_REGISTRY__.Slardar},reportSelfError=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=getGlobalRegistry(getDefaultBrowser());r&&(r.errors||(r.errors=[]),r.errors.push(e))},applyMutationObserver=function(e,n){var r=e&&new e(n);return[function(e,n){r&&e&&r.observe(e,n)},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 n=(r||{}).getEntriesByType;return isFunction(n)&&n.call(r,e)||[]},function(){var e=(r||{}).clearResourceTimings;isFunction(e)&&e.call(r)},function(e){var n=(r||{}).getEntriesByName;return isFunction(n)&&n.call(r,e)||[]}]},applyPerformanceObserver=function(r,o,n,i){var t=r&&new r(function(e,t){e.getEntries?e.getEntries().forEach(function(e,n,r){return o(e,n,r,t)}):i&&i(),n&&t.disconnect()});return[function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];if(!r||!t)return i&&i();try{n.forEach(function(e){-1<r.supportedEntryTypes.indexOf(e)&&t.observe({type:e,buffered:!1})})}catch(e){try{t.observe({entryTypes:n})}catch(e){return i&&i()}}},function(){return t&&t.disconnect()}]},applyMonitor=function(e,n,r,t){void 0===n&&(n={}),void 0===t&&(t=[]);try{var o=e.apply(void 0,__spreadArray([],__read(t),!1));return o&&o(n,r)||[]}catch(e){return reportSelfError(e),[]}},invokeCallbackOnce=function(n){var r=!1;return[function(e){r||(r=!0,n&&n(e))}]},onPageUnload=function(e){var n=__read(invokeCallbackOnce(e),1)[0];["unload","beforeunload","pagehide"].forEach(function(e){addEventListener(e,n)})},getConfig=function(e,n){return isObject(e)?__assign(__assign({},n),e):!!e&&n};function getPluginConfig(e,n,r){n=null===(e=e.config())||void 0===e?void 0:e.plugins[n];return getConfig(n,r)}var DEFAULT_IGNORE_TAGS=["SCRIPT","STYLE","META","HEAD"],ERROR_RELATED_TYPE=["js_error","http","resource_error"],DEFAULT_THRESHOLD=1.5,MAX_RENDER_TIME=1e4,MAX_CHECK_TIME=8e3,DEFAULT_CHECK_TIME=2e3,MAX_RELATED_TIME=1e4,getRequestIdleCallback=function(n){return n.requestIdleCallback||function(e){return n.setTimeout(e,1)}},blankErrorCompare=function(e,n){if(-1===ERROR_RELATED_TYPE.indexOf(n.ev_type))return e;if("http"===n.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 r="";switch(n.ev_type){case"js_error":r=n.payload.error.message;break;case"http":r=n.payload.request.url;break;case"resource_error":r=n.payload.url}return{type:n.ev_type,message:r,timestamp:Date.now()}},measure=function(r,t,e,o,i){if(void 0===t&&(t=0),void 0===e&&(e=0),void 0===o&&(o=DEFAULT_THRESHOLD),void 0===i&&(i=DEFAULT_IGNORE_TAGS),!r||-1<i.indexOf(r.tagName)||o<=e||4<t)return e;var n=function(){if(!t)return 0;var e=r.getBoundingClientRect(),n=e.top,e=e.height;return n>innerHeight||e<=0?0:1/Math.pow(2,t-1)}();return[].reduceRight.call(r.children,function(e,n){return measure(n,t+1,e,o,i)},e+n)},screenshot=function(n,e,r,t){if(getDefaultPromise()&&r&&t){if(r.html2canvas)return i();var o=t.createElement("script");o.src=e,null!==(e=t.head)&&void 0!==e&&e.appendChild(o),o.onload=i}function i(){getRequestIdleCallback(r)(function(){r.html2canvas&&r.html2canvas(t.body,{scale:360/r.innerWidth}).then(function(e){n(e.toDataURL("image/jpeg",.1))})})}},BlankScreenMonitor=function(w,O,A,M,S){if(void 0===w&&(w=getDefaultBrowser()),void 0===O&&(O=getDefaultDocument()),void 0===A&&(A=getDefaultPerformanceObserver()),void 0===M&&(M=getDefaultMutationObserver()),void 0===S&&(S=getDefaultPerformance()),O&&w)return function(e,n){var r,t,o,i,a,u,c=e.threshold,l=e.screenshot,f=e.rootSelector,s=e.autoDetect,_=e.ssUrl,d=getRequestIdleCallback(w),p=__read(applyPerformance(S),2)[1],v=0,g=!1,E=function(e){r&&n&&n({ev_type:"blank_screen",payload:{timestamp:r[0],score:r[1],screenshot:e,error:t}})},y=(i=function(){r&&!g&&(g=!0,b(),l?screenshot(E,_,w,O):E())},function(){a||(u=Date.now(),a=w.setTimeout(function(){a=0,u<v||i()},p()>MAX_RENDER_TIME?DEFAULT_CHECK_TIME:MAX_CHECK_TIME))});onPageUnload(function(){g||E()});function m(){o&&clearTimeout(o),o=w.setTimeout(function(){d(function(){w.requestAnimationFrame(function(){var e=f?O.querySelector(f):O.body;e&&((e=measure(e,0,0,c))<c?(r=[Date.now(),e],y()):r=void 0)})})},1e3)}var b=function(){clearTimeout(o),h&&h(),T&&T()},R=__read(applyMutationObserver(M,m),2),D=R[0],h=R[1],e=__read(applyPerformanceObserver(A,function(e,n,r){return o&&1<r.length&&m()}),2),R=e[0],T=e[1];return s&&(D(null===(D=getDefaultDocument())||void 0===D?void 0:D.body,{subtree:!0,childList:!0}),R("longtask","resource"),m()),[b,function(e){g||(v=Date.now(),t&&v-t.timestamp>MAX_RELATED_TIME&&(t=void 0),t=blankErrorCompare(t,e))},m]}},BLANK_SCREEN_MONITOR_PLUGIN_NAME="blankScreen";function BlankScreenMonitorBasePlugin(o,i,a){o.on("init",function(){var e,n,r,t=getPluginConfig(o,BLANK_SCREEN_MONITOR_PLUGIN_NAME,i)||getConfig(a,i);t&&(t=__read(applyMonitor(BlankScreenMonitor,t,o.report.bind(o)),3),e=t[0],n=t[1],t=t[2],o.on("report",r=function(e){return n(e),e}),o.on("beforeDestroy",function(){e(),o.off("report",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"};function BlankScreenMonitorVolPlugin(e,n){BlankScreenMonitorBasePlugin(e,defaultVolConfig,n)}var blankScreenPlugin=function(n){return{name:BLANK_SCREEN_MONITOR_PLUGIN_NAME,setup:function(e){BlankScreenMonitorVolPlugin(e,n)}}};exports.blankScreenPlugin=blankScreenPlugin;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __assign=function(){return(__assign=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var o in n=arguments[r])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e}).apply(this,arguments)};function __read(e,n){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var t,o,i=r.call(e),a=[];try{for(;(void 0===n||0<n--)&&!(t=i.next()).done;)a.push(t.value)}catch(e){o={error:e}}finally{try{t&&!t.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function __spreadArray(e,n,r){if(r||2===arguments.length)for(var t,o=0,i=n.length;o<i;o++)!t&&o in n||((t=t||Array.prototype.slice.call(n,0,o))[o]=n[o]);return e.concat(t||Array.prototype.slice.call(n))}function isObject(e){return"object"==typeof e&&null!==e}function isFunction(e){return"function"==typeof e}function getDefaultBrowser(){if("object"==typeof window&&isObject(window))return window}function getDefaultDocument(){if("object"==typeof document&&isObject(document))return document}function getDefaultPerformance(){if(getDefaultBrowser()&&isObject(window.performance))return window.performance}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 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=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=getGlobalRegistry(getDefaultBrowser());r&&(r.errors||(r.errors=[]),r.errors.push(e))},applyMutationObserver=function(e,n){var r=e&&new e(n);return[function(e,n){r&&e&&r.observe(e,n)},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 n=(r||{}).getEntriesByType;return isFunction(n)&&n.call(r,e)||[]},function(){var e=(r||{}).clearResourceTimings;isFunction(e)&&e.call(r)},function(e){var n=(r||{}).getEntriesByName;return isFunction(n)&&n.call(r,e)||[]}]},applyPerformanceObserver=function(r,o,n,i){var t=r&&new r(function(e,t){e.getEntries?e.getEntries().forEach(function(e,n,r){return o(e,n,r,t)}):i&&i(),n&&t.disconnect()});return[function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];if(!r||!t)return i&&i();try{n.forEach(function(e){-1<r.supportedEntryTypes.indexOf(e)&&t.observe({type:e,buffered:!1})})}catch(e){try{t.observe({entryTypes:n})}catch(e){return i&&i()}}},function(){return t&&t.disconnect()}]},applyMonitor=function(e,n,r,t){void 0===n&&(n={}),void 0===t&&(t=[]);try{var o=e.apply(void 0,__spreadArray([],__read(t),!1));return o&&o(n,r)||[]}catch(e){return reportSelfError(e),[]}},applyRequestIdleCallback=function(n){return n.requestIdleCallback||function(e){return n.setTimeout(e,1)}},now=function(){return Date.now()};function onDOMContentLoaded(e){var n=getDefaultBrowser(),r=getDefaultDocument();n&&r&&("loading"!==r.readyState?e():n.addEventListener("DOMContentLoaded",function(){setTimeout(function(){e()},0)},!1))}var invokeCallbackOnce=function(n){var r=!1;return[function(e){r||(r=!0,n&&n(e))}]},onPageUnload=function(e){var n=__read(invokeCallbackOnce(e),1)[0];["unload","beforeunload","pagehide"].forEach(function(e){addEventListener(e,n)})},getConfig=function(e,n){return isObject(e)?__assign(__assign({},n),e):!!e&&n};function getPluginConfig(e,n,r){n=null===(e=e.config())||void 0===e?void 0:e.plugins[n];return getConfig(n,r)}var DEFAULT_IGNORE_TAGS=["SCRIPT","STYLE","META","HEAD"],ERROR_RELATED_TYPE=["js_error","http","resource_error"],DEFAULT_THRESHOLD=1.5,MAX_RENDER_TIME=1e4,MAX_CHECK_TIME=8e3,DEFAULT_CHECK_TIME=2e3,MAX_RELATED_TIME=1e4,CHECK_EXCLUSIVE_EV_TYPES=["performance","performance_longtask","performance_timing","custom"],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("http"===n.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 r="";switch(n.ev_type){case"js_error":r=n.payload.error.message;break;case"http":r=n.payload.request.url;break;case"resource_error":r=n.payload.url}return{type:n.ev_type,message:r,timestamp:now()}},measure=function(r,t,e,o,i){if(void 0===t&&(t=0),void 0===e&&(e=0),void 0===o&&(o=DEFAULT_THRESHOLD),void 0===i&&(i=DEFAULT_IGNORE_TAGS),!r||-1<i.indexOf(r.tagName)||o<=e||4<t)return e;var n=function(){if(!t)return 0;var e=r.getBoundingClientRect(),n=e.top,e=e.height;return n>innerHeight||e<=0?0:1/Math.pow(2,t-1)}();return[].reduceRight.call(r.children,function(e,n){return measure(n,t+1,e,o,i)},e+n)},screenshot=function(n,e,r,t){if(getDefaultPromise()&&r&&t){if(r.html2canvas)return i();var o=t.createElement("script");o.src=e,null!==(e=t.head)&&void 0!==e&&e.appendChild(o),o.onload=i}function i(){applyRequestIdleCallback(r)(function(){r.html2canvas&&r.html2canvas(t.body,{scale:360/r.innerWidth}).then(function(e){n(e.toDataURL("image/jpeg",.1))})})}},BlankScreenMonitor=function(w,O,S,A,C){if(void 0===w&&(w=getDefaultBrowser()),void 0===O&&(O=getDefaultDocument()),void 0===S&&(S=getDefaultPerformanceObserver()),void 0===A&&(A=getDefaultMutationObserver()),void 0===C&&(C=getDefaultPerformance()),O&&w)return function(e,n){var r,t,o,i,a,u,c=e.threshold,f=e.screenshot,l=e.rootSelector,s=e.autoDetect,d=e.ssUrl,_=applyRequestIdleCallback(w),p=__read(applyPerformance(C),2)[1],v=0,E=!1,g=function(e){r&&n&&n({ev_type:"blank_screen",payload:{timestamp:r[0],score:r[1],screenshot:e,error:t}})},m=(i=function(){r&&!E&&(E=!0,D(),f?screenshot(g,d,w,O):g())},function(){a||(u=now(),a=w.setTimeout(function(){a=0,u<v||i()},p()>MAX_RENDER_TIME?DEFAULT_CHECK_TIME:MAX_CHECK_TIME))});onPageUnload(function(){!E&&t&&g()});function y(){o&&clearTimeout(o),o=w.setTimeout(function(){_(function(){w.requestAnimationFrame(function(){var e=l?O.querySelector(l):O.body;e&&((e=measure(e,0,0,c))<c?(r=[now(),e],m()):r=void 0)})})},1e3)}var D=function(){clearTimeout(o),R&&R(),h&&h()},e=__read(applyMutationObserver(A,y),2),b=e[0],R=e[1],e=__read(applyPerformanceObserver(S,function(e,n,r){return o&&1<r.length&&y()}),2),T=e[0],h=e[1];return s&&onDOMContentLoaded(function(){var e;b(null===(e=getDefaultDocument())||void 0===e?void 0:e.body,{subtree:!0,childList:!0}),T("longtask","resource"),y()}),[D,function(e){E||isSkipBeforeCheck(e)||(v=now(),t&&v-t.timestamp>MAX_RELATED_TIME&&(t=void 0),t=blankErrorCompare(t,e))},y]}},BLANK_SCREEN_MONITOR_PLUGIN_NAME="blankScreen";function BlankScreenMonitorBasePlugin(o,i,a){o.on("init",function(){var e,n,r,t=getPluginConfig(o,BLANK_SCREEN_MONITOR_PLUGIN_NAME,i)||getConfig(a,i);t&&(t=__read(applyMonitor(BlankScreenMonitor,t,o.report.bind(o)),3),e=t[0],n=t[1],t=t[2],o.on("report",r=function(e){return n(e),e}),o.on("beforeDestroy",function(){e(),o.off("report",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"};function BlankScreenMonitorVolPlugin(e,n){BlankScreenMonitorBasePlugin(e,defaultVolConfig,n)}var blankScreenPlugin=function(n){return{name:BLANK_SCREEN_MONITOR_PLUGIN_NAME,setup:function(e){BlankScreenMonitorVolPlugin(e,n)}}};exports.blankScreenPlugin=blankScreenPlugin;

@@ -115,2 +115,7 @@ declare type BatchSender<E> = EventSender<E> & {

declare type ParametersForFn<T extends (args: any) => any> = T extends (args: infer P) => any ? P : never;
declare type SafeObservable<T> = [(f: T) => () => void, (f: T) => void];
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 NextLink<T extends (args: any) => any> = (args: ParametersForFn<T>, cb: T[]) => NextLink<ReturnType<T>>;
declare type WithContext<C extends AnyClient> = C & {

@@ -142,2 +147,7 @@ context?: ContextAgent;

declare type WithSubject<C extends AnyClient> = C & {
initSubject: <T extends (args: any) => any>(args: [subjectKey: string, collector: Observer<T>]) => SafeObservable<T>;
getSubject: (key: string) => SafeObservable<any> | undefined;
};
/** 公共筛选条件 */

@@ -727,6 +737,7 @@ interface FilterCondition {

onPidUpdate?: (pid: string) => void;
createObserver?: (mode: string) => SafeObservable<(args: string) => void>;
}
declare const PAGEVIEW_MONITOR_PLUGIN_NAME = "pageview";
declare type WithSendPageview<C extends WebClient$1> = C & {
declare type WithSendPageview<C extends WithSubject<WebClient$1>> = C & {
sendPageview?: SendPageview;

@@ -783,3 +794,5 @@ };

lcp = "lcp",
cls = "cls"
cls = "cls",
longtask = "longtask",
timing = "timing"
}

@@ -792,5 +805,2 @@ interface PerformancePrecollect {

[key in MetricEnum]: boolean;
} & {
timing: boolean;
longtask: boolean;
};

@@ -1011,4 +1021,3 @@

type PrecollectArg = [string, string, PrecollectData, number, string]
type BrowserClient =
WithDetectBlankScreen<
type BrowserClient = WithDetectBlankScreen<
WithBreadcrumb<

@@ -1021,10 +1030,12 @@ WithReportResourceError<

WithContext<
Client<
BrowserReportEvent,
BrowserSendEvent,
BrowserBuilder,
BrowserSender,
BrowserInitConfig,
BrowserUserConfig,
BrowserConfig
WithSubject<
Client<
BrowserReportEvent,
BrowserSendEvent,
BrowserBuilder,
BrowserSender,
BrowserInitConfig,
BrowserUserConfig,
BrowserConfig
>
>

@@ -1031,0 +1042,0 @@ >

@@ -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,a=t.call(r),i=[];try{for(;(void 0===e||0<e--)&&!(n=a.next()).done;)i.push(n.value)}catch(r){o={error:r}}finally{try{n&&!n.done&&(t=a.return)&&t.call(a)}finally{if(o)throw o.error}}return i}function __spreadArray(r,e,t){if(t||2===arguments.length)for(var n,o=0,a=e.length;o<a;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 id(r){return r}function isObject(r){return"object"==typeof r&&null!==r}function isString(r){return"string"==typeof r}function getDefaultBrowser(){if("object"==typeof window&&isObject(window))return window}function getDefaultDocument(){if("object"==typeof document&&isObject(document))return document}var getGlobalRegistry=function(r){if(r)return r.__SLARDAR_REGISTRY__||(r.__SLARDAR_REGISTRY__={Slardar:{plugins:[],errors:[]}}),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))},applyMonitor=function(r,e,t,n){void 0===e&&(e={}),void 0===n&&(n=[]);try{var o=r.apply(void 0,__spreadArray([],__read(n),!1));return o&&o(e,t)||[]}catch(r){return reportSelfError(r),[]}},UNKNOWN_PATH="<unknown>";function htmlTreeAsString(r){try{for(var e,t=r,n=[],o=0,a=0,i=" > ".length;t&&o++<5&&!("html"===(e=_htmlElementAsString(t))||1<o&&80<=a+n.length*i+e.length);)n.push(e),a+=e.length,t=t.parentNode;return n.reverse().join(" > ")}catch(r){return UNKNOWN_PATH}}function _htmlElementAsString(r){var e,t,n,o=r,a=[];if(!o||!o.tagName)return"";a.push(o.tagName.toLowerCase()),o.id&&a.push("#"+o.id);r=o.className;if(r&&isString(r))for(e=r.split(/\s+/),u=0;u<e.length;u++)a.push("."+e[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(e,t){var n;return function(r){i=void 0,r&&n!==r&&t({event:n=r,name:e})}}var i;return[a,function(n){return function(r){var e;try{e=r.target}catch(r){return}var t=e&&e.tagName;t&&("INPUT"===t||"TEXTAREA"===t||e.isContentEditable)&&(i||a("input",n)(r),clearTimeout(i),i=window.setTimeout(function(){i=void 0},o))}}]},triggerHandlers=function(e,t){return function(r){if(t)try{e(r)}catch(r){}}},domBreadcrumb=function(t){return function(r){var e;try{e=r.event.target?htmlTreeAsString(r.event.target):htmlTreeAsString(r.event)}catch(r){e="<unknown>"}0!==e.length&&t({type:"dom",category:"ui."+r.name,message:e})}},getConfig=function(r,e){return isObject(r)?__assign(__assign({},e),r):!!r&&e};function getPluginConfig(r,e,t){e=null===(r=r.config())||void 0===r?void 0:r.plugins[e];return getConfig(e,t)}var applyBreadcrumb=function(e,t,n){void 0===e&&(e=20),void 0===t&&(t=id),void 0===n&&(n=function(r,e){return r.slice(-e)});var o=[];return[function(){return o},function(r){t(r)&&(r=__assign(__assign({},r),{timestamp:r.timestamp||Date.now()}),o=0<=e&&o.length+1>e?n(__spreadArray(__spreadArray([],__read(o),!1),[r],!1),e):__spreadArray(__spreadArray([],__read(o),!1),[r],!1))}]},BreadcrumbMonitor=function(c){if(c=void 0===c?getDefaultDocument():c)return function(r,e){var t=r.maxBreadcrumbs,n=r.onAddBreadcrumb,o=r.onMaxBreadcrumbs,a=r.dom,i=__read(applyDomAndKeyPress(100),2),r=i[0],i=i[1],t=__read(applyBreadcrumb(t,n,o),2),n=t[0],o=t[1],t=domBreadcrumb(o),u=[];a&&(u.push(r("click",triggerHandlers(t,"dom"))),u.push(i(triggerHandlers(t,"dom"))),c.addEventListener("click",u[0]),c.addEventListener("keypress",u[1]));return[n,o,function(){c.removeEventListener("click",u[0]),c.removeEventListener("keypress",u[1])}]}},BREADCRUMB_MONITOR_PLUGIN_NAME="breadcrumb",defaultConfig={maxBreadcrumbs:20,dom:!0};function BreadcrumbMonitorPlugin(n){n.on("init",function(){var e,r,t=getPluginConfig(n,BREADCRUMB_MONITOR_PLUGIN_NAME,defaultConfig);t&&(t=(r=__read(applyMonitor(BreadcrumbMonitor,t,noop),3))[0],e=r[1],r=r[2],n.on("report",function(r){return"http"===r.ev_type&&e({type:"http",category:r.payload.api,message:"",data:{method:r.payload.request.method,url:r.payload.request.url,status_code:String(r.payload.response.status)},timestamp:r.payload.request.timestamp}),r}),n.on("beforeDestroy",r),n.provide("getBreadcrumbs",t),n.provide("addBreadcrumb",e))})}var breadcrumbPlugin=function(){return{name:BREADCRUMB_MONITOR_PLUGIN_NAME,setup:function(r){BreadcrumbMonitorPlugin(r)}}};exports.breadcrumbPlugin=breadcrumbPlugin;
"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,a=t.call(r),i=[];try{for(;(void 0===e||0<e--)&&!(n=a.next()).done;)i.push(n.value)}catch(r){o={error:r}}finally{try{n&&!n.done&&(t=a.return)&&t.call(a)}finally{if(o)throw o.error}}return i}function __spreadArray(r,e,t){if(t||2===arguments.length)for(var n,o=0,a=e.length;o<a;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 id(r){return r}function isObject(r){return"object"==typeof r&&null!==r}function isString(r){return"string"==typeof r}function getDefaultBrowser(){if("object"==typeof window&&isObject(window))return window}function getDefaultDocument(){if("object"==typeof document&&isObject(document))return document}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))},applyMonitor=function(r,e,t,n){void 0===e&&(e={}),void 0===n&&(n=[]);try{var o=r.apply(void 0,__spreadArray([],__read(n),!1));return o&&o(e,t)||[]}catch(r){return reportSelfError(r),[]}},now=function(){return Date.now()},UNKNOWN_PATH="<unknown>";function htmlTreeAsString(r){try{for(var e,t=r,n=[],o=0,a=0,i=" > ".length;t&&o++<5&&!("html"===(e=_htmlElementAsString(t))||1<o&&80<=a+n.length*i+e.length);)n.push(e),a+=e.length,t=t.parentNode;return n.reverse().join(" > ")}catch(r){return UNKNOWN_PATH}}function _htmlElementAsString(r){var e,t,n,o=r,a=[];if(!o||!o.tagName)return"";a.push(o.tagName.toLowerCase()),o.id&&a.push("#"+o.id);r=o.className;if(r&&isString(r))for(e=r.split(/\s+/),u=0;u<e.length;u++)a.push("."+e[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(e,t){var n;return function(r){i=void 0,r&&n!==r&&t({event:n=r,name:e})}}var i;return[a,function(n){return function(r){var e;try{e=r.target}catch(r){return}var t=e&&e.tagName;t&&("INPUT"===t||"TEXTAREA"===t||e.isContentEditable)&&(i||a("input",n)(r),clearTimeout(i),i=window.setTimeout(function(){i=void 0},o))}}]},triggerHandlers=function(e,t){return function(r){if(t)try{e(r)}catch(r){}}},domBreadcrumb=function(t){return function(r){var e;try{e=r.event.target?htmlTreeAsString(r.event.target):htmlTreeAsString(r.event)}catch(r){e="<unknown>"}0!==e.length&&t({type:"dom",category:"ui."+r.name,message:e})}},getConfig=function(r,e){return isObject(r)?__assign(__assign({},e),r):!!r&&e};function getPluginConfig(r,e,t){e=null===(r=r.config())||void 0===r?void 0:r.plugins[e];return getConfig(e,t)}var applyBreadcrumb=function(e,t,n){void 0===e&&(e=20),void 0===t&&(t=id),void 0===n&&(n=function(r,e){return r.slice(-e)});var o=[];return[function(){return o},function(r){t(r)&&(r=__assign(__assign({},r),{timestamp:r.timestamp||now()}),o=0<=e&&o.length+1>e?n(__spreadArray(__spreadArray([],__read(o),!1),[r],!1),e):__spreadArray(__spreadArray([],__read(o),!1),[r],!1))}]},BreadcrumbMonitor=function(c){if(c=void 0===c?getDefaultDocument():c)return function(r,e){var t=r.maxBreadcrumbs,n=r.onAddBreadcrumb,o=r.onMaxBreadcrumbs,a=r.dom,i=__read(applyDomAndKeyPress(100),2),r=i[0],i=i[1],t=__read(applyBreadcrumb(t,n,o),2),n=t[0],o=t[1],t=domBreadcrumb(o),u=[];a&&(u.push(r("click",triggerHandlers(t,"dom"))),u.push(i(triggerHandlers(t,"dom"))),c.addEventListener("click",u[0]),c.addEventListener("keypress",u[1]));return[n,o,function(){c.removeEventListener("click",u[0]),c.removeEventListener("keypress",u[1])}]}},BREADCRUMB_MONITOR_PLUGIN_NAME="breadcrumb",defaultConfig={maxBreadcrumbs:20,dom:!0};function BreadcrumbMonitorPlugin(n){n.on("init",function(){var e,r,t=getPluginConfig(n,BREADCRUMB_MONITOR_PLUGIN_NAME,defaultConfig);t&&(t=(r=__read(applyMonitor(BreadcrumbMonitor,t,noop),3))[0],e=r[1],r=r[2],n.on("report",function(r){return"http"===r.ev_type&&e({type:"http",category:r.payload.api,message:"",data:{method:r.payload.request.method,url:r.payload.request.url,status_code:String(r.payload.response.status)},timestamp:r.payload.request.timestamp}),r}),n.on("beforeDestroy",r),n.provide("getBreadcrumbs",t),n.provide("addBreadcrumb",e))})}var breadcrumbPlugin=function(){return{name:BREADCRUMB_MONITOR_PLUGIN_NAME,setup:function(r){BreadcrumbMonitorPlugin(r)}}};exports.breadcrumbPlugin=breadcrumbPlugin;

@@ -115,2 +115,7 @@ declare type BatchSender<E> = EventSender<E> & {

declare type ParametersForFn<T extends (args: any) => any> = T extends (args: infer P) => any ? P : never;
declare type SafeObservable<T> = [(f: T) => () => void, (f: T) => void];
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 NextLink<T extends (args: any) => any> = (args: ParametersForFn<T>, cb: T[]) => NextLink<ReturnType<T>>;
declare type WithContext<C extends AnyClient> = C & {

@@ -142,2 +147,7 @@ context?: ContextAgent;

declare type WithSubject<C extends AnyClient> = C & {
initSubject: <T extends (args: any) => any>(args: [subjectKey: string, collector: Observer<T>]) => SafeObservable<T>;
getSubject: (key: string) => SafeObservable<any> | undefined;
};
/** 公共筛选条件 */

@@ -727,6 +737,7 @@ interface FilterCondition {

onPidUpdate?: (pid: string) => void;
createObserver?: (mode: string) => SafeObservable<(args: string) => void>;
}
declare const PAGEVIEW_MONITOR_PLUGIN_NAME = "pageview";
declare type WithSendPageview<C extends WebClient> = C & {
declare type WithSendPageview<C extends WithSubject<WebClient>> = C & {
sendPageview?: SendPageview;

@@ -783,3 +794,5 @@ };

lcp = "lcp",
cls = "cls"
cls = "cls",
longtask = "longtask",
timing = "timing"
}

@@ -792,5 +805,2 @@ interface PerformancePrecollect {

[key in MetricEnum]: boolean;
} & {
timing: boolean;
longtask: boolean;
};

@@ -1011,4 +1021,3 @@

type PrecollectArg = [string, string, PrecollectData, number, string]
type BrowserClient =
WithDetectBlankScreen<
type BrowserClient = WithDetectBlankScreen<
WithBreadcrumb<

@@ -1021,10 +1030,12 @@ WithReportResourceError<

WithContext<
Client<
BrowserReportEvent,
BrowserSendEvent,
BrowserBuilder,
BrowserSender,
BrowserInitConfig,
BrowserUserConfig,
BrowserConfig
WithSubject<
Client<
BrowserReportEvent,
BrowserSendEvent,
BrowserBuilder,
BrowserSender,
BrowserInitConfig,
BrowserUserConfig,
BrowserConfig
>
>

@@ -1031,0 +1042,0 @@ >

@@ -1,1 +0,1 @@

"use strict";function __read(r,o){var e="function"==typeof Symbol&&r[Symbol.iterator];if(!e)return r;var t,n,a=e.call(r),l=[];try{for(;(void 0===o||0<o--)&&!(t=a.next()).done;)l.push(t.value)}catch(r){n={error:r}}finally{try{t&&!t.done&&(e=a.return)&&e.call(a)}finally{if(n)throw n.error}}return l}function __spreadArray(r,o,e){if(e||2===arguments.length)for(var t,n=0,a=o.length;n<a;n++)!t&&n in o||((t=t||Array.prototype.slice.call(o,0,n))[n]=o[n]);return r.concat(t||Array.prototype.slice.call(o))}function isObject(r){return"object"==typeof r&&null!==r}Object.defineProperty(exports,"__esModule",{value:!0});var objProto=Object.prototype;function isArray(r){return"[object Array]"===objProto.toString.call(r)}function safeJoin(r,o){if(!isArray(r))return"";for(var e=[],t=0;t<r.length;t++)try{e.push(String(r[t]))}catch(r){e.push("[value cannot be serialized]")}return e.join(o)}var hookMethodDangerously=function(e,t,n){return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];e[t]=n.apply(void 0,__spreadArray([e[t]],__read(r),!1))}};function getDefaultBrowser(){if("object"==typeof window&&isObject(window))return window}var captureConsole=function(r){var r=r.levels,o=void 0===r?["log","info","warn","error","debug","assert"]:r;return{name:"captureConsole",setup:function(t){var n=getDefaultBrowser();n&&n.console&&o.forEach(function(r){r in n.console&&hookMethodDangerously(n.console,r,function(e){return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];try{e&&e.call.apply(e,__spreadArray([n.console],__read(r),!1))}finally{t("captureException",safeJoin(r," "))}}})()})}}};exports.captureConsole=captureConsole;
"use strict";function __read(r,o){var n="function"==typeof Symbol&&r[Symbol.iterator];if(!n)return r;var e,t,a=n.call(r),u=[];try{for(;(void 0===o||0<o--)&&!(e=a.next()).done;)u.push(e.value)}catch(r){t={error:r}}finally{try{e&&!e.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return u}function __spreadArray(r,o,n){if(n||2===arguments.length)for(var e,t=0,a=o.length;t<a;t++)!e&&t in o||((e=e||Array.prototype.slice.call(o,0,t))[t]=o[t]);return r.concat(e||Array.prototype.slice.call(o))}Object.defineProperty(exports,"__esModule",{value:!0});var noop=function(){return{}};function isObject(r){return"object"==typeof r&&null!==r}var objProto=Object.prototype;function isArray(r){return"[object Array]"===objProto.toString.call(r)}function isFunction(r){return"function"==typeof r}function safeJoin(r,o){if(!isArray(r))return"";for(var n=[],e=0;e<r.length;e++)try{n.push(String(r[e]))}catch(r){n.push("[value cannot be serialized]")}return n.join(o)}var hookMethodDangerously=function(a,u,i){return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];if(!a)return noop;var n=a[u],e=i.apply(void 0,__spreadArray([n],__read(r),!1)),t=e;return isFunction(t)&&(t=function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];return e.apply(this,r)}),a[u]=t,function(){t===a[u]?a[u]=n:e=n}}};function getDefaultBrowser(){if("object"==typeof window&&isObject(window))return window}var captureConsole=function(r){var r=r.levels,n=void 0===r?["log","info","warn","error","debug","assert"]:r;return{name:"captureConsole",setup:function(e){var o,t=getDefaultBrowser();t&&t.console&&(o=[],n.forEach(function(r){r in t.console&&o.push(hookMethodDangerously(t.console,r,function(n){return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];try{n&&n.call.apply(n,__spreadArray([t.console],__read(r),!1))}finally{e("captureException",safeJoin(r," "))}}})())}),e.on("beforeDestroy",function(){o.forEach(function(r){return r()})}))}}};exports.captureConsole=captureConsole;

@@ -115,2 +115,7 @@ declare type BatchSender<E> = EventSender<E> & {

declare type ParametersForFn<T extends (args: any) => any> = T extends (args: infer P) => any ? P : never;
declare type SafeObservable<T> = [(f: T) => () => void, (f: T) => void];
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 NextLink<T extends (args: any) => any> = (args: ParametersForFn<T>, cb: T[]) => NextLink<ReturnType<T>>;
declare type WithContext<C extends AnyClient> = C & {

@@ -142,2 +147,7 @@ context?: ContextAgent;

declare type WithSubject<C extends AnyClient> = C & {
initSubject: <T extends (args: any) => any>(args: [subjectKey: string, collector: Observer<T>]) => SafeObservable<T>;
getSubject: (key: string) => SafeObservable<any> | undefined;
};
/** 公共筛选条件 */

@@ -727,6 +737,7 @@ interface FilterCondition {

onPidUpdate?: (pid: string) => void;
createObserver?: (mode: string) => SafeObservable<(args: string) => void>;
}
declare const PAGEVIEW_MONITOR_PLUGIN_NAME = "pageview";
declare type WithSendPageview<C extends WebClient$1> = C & {
declare type WithSendPageview<C extends WithSubject<WebClient$1>> = C & {
sendPageview?: SendPageview;

@@ -783,3 +794,5 @@ };

lcp = "lcp",
cls = "cls"
cls = "cls",
longtask = "longtask",
timing = "timing"
}

@@ -792,5 +805,2 @@ interface PerformancePrecollect {

[key in MetricEnum]: boolean;
} & {
timing: boolean;
longtask: boolean;
};

@@ -1011,4 +1021,3 @@

type PrecollectArg = [string, string, PrecollectData, number, string]
type BrowserClient =
WithDetectBlankScreen<
type BrowserClient = WithDetectBlankScreen<
WithBreadcrumb<

@@ -1021,10 +1030,12 @@ WithReportResourceError<

WithContext<
Client<
BrowserReportEvent,
BrowserSendEvent,
BrowserBuilder,
BrowserSender,
BrowserInitConfig,
BrowserUserConfig,
BrowserConfig
WithSubject<
Client<
BrowserReportEvent,
BrowserSendEvent,
BrowserBuilder,
BrowserSender,
BrowserInitConfig,
BrowserUserConfig,
BrowserConfig
>
>

@@ -1031,0 +1042,0 @@ >

@@ -1,1 +0,1 @@

"use strict";function isObject(t){return"object"==typeof t&&null!==t}function isNumber(t){return"number"==typeof t}function isString(t){return"string"==typeof t}function safeStringify(t){try{return isString(t)?t:JSON.stringify(t)}catch(t){return"[FAILED_TO_STRINGIFY]:"+String(t)}}Object.defineProperty(exports,"__esModule",{value:!0});var CUSTOM_EV_TYPE="custom",CUSTOM_EVENT_TYPE="event",CUSTOM_LOG_TYPE="log",normalizeCustomEventData=function(t){if(t&&isObject(t)&&t.name&&isString(t.name)){var e={name:t.name,type:CUSTOM_EVENT_TYPE};if("metrics"in t&&isObject(t.metrics)){var n=t.metrics,i={};for(r in n)isNumber(n[r])&&(i[r]=n[r]);e.metrics=i}if("categories"in t&&isObject(t.categories)){var r,o=t.categories,s={};for(r in o)s[r]=safeStringify(o[r]);e.categories=s}return e}},normalizeCustomLogData=function(t){if(t&&isObject(t)&&t.content&&isString(t.content)){var e={content:safeStringify(t.content),type:CUSTOM_LOG_TYPE,level:"info"};if("level"in t&&(e.level=t.level),"extra"in t&&isObject(t.extra)){var n,i=t.extra,r={},o={};for(n in i)isNumber(i[n])?r[n]=i[n]:o[n]=safeStringify(i[n]);e.metrics=r,e.categories=o}return e}},CustomPlugin=function(e){e.provide("sendEvent",function(t){t=normalizeCustomEventData(t);t&&e.report({ev_type:CUSTOM_EV_TYPE,payload:t,extra:{timestamp:Date.now()}})}),e.provide("sendLog",function(t){t=normalizeCustomLogData(t);t&&e.report({ev_type:CUSTOM_EV_TYPE,payload:t,extra:{timestamp:Date.now()}})})},customPlugin=function(){return{name:"custom",setup:function(t){CustomPlugin(t)}}};exports.customPlugin=customPlugin;
"use strict";function isObject(t){return"object"==typeof t&&null!==t}function isNumber(t){return"number"==typeof t}function isString(t){return"string"==typeof t}function safeStringify(t){try{return isString(t)?t:JSON.stringify(t)}catch(t){return"[FAILED_TO_STRINGIFY]:"+String(t)}}Object.defineProperty(exports,"__esModule",{value:!0});var now=function(){return Date.now()},CUSTOM_EV_TYPE="custom",CUSTOM_EVENT_TYPE="event",CUSTOM_LOG_TYPE="log",normalizeCustomEventData=function(t){if(t&&isObject(t)&&t.name&&isString(t.name)){var e={name:t.name,type:CUSTOM_EVENT_TYPE};if("metrics"in t&&isObject(t.metrics)){var n=t.metrics,i={};for(r in n)isNumber(n[r])&&(i[r]=n[r]);e.metrics=i}if("categories"in t&&isObject(t.categories)){var r,o=t.categories,s={};for(r in o)s[r]=safeStringify(o[r]);e.categories=s}return e}},normalizeCustomLogData=function(t){if(t&&isObject(t)&&t.content&&isString(t.content)){var e={content:safeStringify(t.content),type:CUSTOM_LOG_TYPE,level:"info"};if("level"in t&&(e.level=t.level),"extra"in t&&isObject(t.extra)){var n,i=t.extra,r={},o={};for(n in i)isNumber(i[n])?r[n]=i[n]:o[n]=safeStringify(i[n]);e.metrics=r,e.categories=o}return e}},CustomPlugin=function(e){e.provide("sendEvent",function(t){t=normalizeCustomEventData(t);t&&e.report({ev_type:CUSTOM_EV_TYPE,payload:t,extra:{timestamp:now()}})}),e.provide("sendLog",function(t){t=normalizeCustomLogData(t);t&&e.report({ev_type:CUSTOM_EV_TYPE,payload:t,extra:{timestamp:now()}})})},customPlugin=function(){return{name:"custom",setup:function(t){CustomPlugin(t)}}};exports.customPlugin=customPlugin;

@@ -115,2 +115,7 @@ declare type BatchSender<E> = EventSender<E> & {

declare type ParametersForFn<T extends (args: any) => any> = T extends (args: infer P) => any ? P : never;
declare type SafeObservable<T> = [(f: T) => () => void, (f: T) => void];
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 NextLink<T extends (args: any) => any> = (args: ParametersForFn<T>, cb: T[]) => NextLink<ReturnType<T>>;
declare type WithContext<C extends AnyClient> = C & {

@@ -142,2 +147,7 @@ context?: ContextAgent;

declare type WithSubject<C extends AnyClient> = C & {
initSubject: <T extends (args: any) => any>(args: [subjectKey: string, collector: Observer<T>]) => SafeObservable<T>;
getSubject: (key: string) => SafeObservable<any> | undefined;
};
/** 公共筛选条件 */

@@ -727,6 +737,7 @@ interface FilterCondition {

onPidUpdate?: (pid: string) => void;
createObserver?: (mode: string) => SafeObservable<(args: string) => void>;
}
declare const PAGEVIEW_MONITOR_PLUGIN_NAME = "pageview";
declare type WithSendPageview<C extends WebClient$2> = C & {
declare type WithSendPageview<C extends WithSubject<WebClient$2>> = C & {
sendPageview?: SendPageview;

@@ -783,3 +794,5 @@ };

lcp = "lcp",
cls = "cls"
cls = "cls",
longtask = "longtask",
timing = "timing"
}

@@ -792,5 +805,2 @@ interface PerformancePrecollect {

[key in MetricEnum]: boolean;
} & {
timing: boolean;
longtask: boolean;
};

@@ -1011,4 +1021,3 @@

type PrecollectArg = [string, string, PrecollectData, number, string]
type BrowserClient =
WithDetectBlankScreen<
type BrowserClient = WithDetectBlankScreen<
WithBreadcrumb<

@@ -1021,10 +1030,12 @@ WithReportResourceError<

WithContext<
Client<
BrowserReportEvent,
BrowserSendEvent,
BrowserBuilder,
BrowserSender,
BrowserInitConfig,
BrowserUserConfig,
BrowserConfig
WithSubject<
Client<
BrowserReportEvent,
BrowserSendEvent,
BrowserBuilder,
BrowserSender,
BrowserInitConfig,
BrowserUserConfig,
BrowserConfig
>
>

@@ -1031,0 +1042,0 @@ >

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

*/
// eslint-disable-next-line @typescript-eslint/ban-types
var hookObjectProperty = function (obj, key, hookFunc, isCatchError) {

@@ -273,2 +274,3 @@ if (isCatchError === void 0) { isCatchError = true; }

*/
// eslint-disable-next-line @typescript-eslint/ban-types
var hookMethodDangerously = function (obj, key, hookFunc) {

@@ -280,3 +282,21 @@ return function () {

}
obj[key] = hookFunc.apply(void 0, __spreadArray([obj[key]], __read(params), false));
if (!obj) {
return noop;
}
var origin = obj[key];
var hookedUnsafe = hookFunc.apply(void 0, __spreadArray([origin], __read(params), false));
var hooked = hookedUnsafe;
if (isFunction(hooked)) {
hooked = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return hookedUnsafe.apply(this, args);
};
}
obj[key] = hooked;
return function () {
hooked === obj[key] ? (obj[key] = origin) : (hookedUnsafe = origin);
};
};

@@ -371,2 +391,3 @@ };

errors: [],
subject: {},
},

@@ -438,2 +459,4 @@ };

var now = function () { return Date.now(); };
var getConfig = function (c, defaultConfig) {

@@ -771,3 +794,3 @@ if (isObject(c)) {

var requestId = (uniqId += 2);
before(requestId, Date.now());
before(requestId, now());
hookMethodDangerously(this, 'onreadystatechange', function (origin) {

@@ -798,3 +821,3 @@ return function () {

var requestId = (uniqId += 2);
before(requestId, Date.now());
before(requestId, now());
var onResolve = function () {

@@ -1055,2 +1078,3 @@ after(requestId);

return;
var tearDownGroup = [];
levels.forEach(function (level) {

@@ -1075,4 +1099,7 @@ if (!(level in global.console)) {

};
hookMethodDangerously(global.console, level, hookConsoleLevel)();
tearDownGroup.push(hookMethodDangerously(global.console, level, hookConsoleLevel)());
});
client.on('beforeDestroy', function () {
tearDownGroup.forEach(function (e) { return e(); });
});
},

@@ -1079,0 +1106,0 @@ });

@@ -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),a=[];try{for(;(void 0===e||0<e--)&&!(n=i.next()).done;)a.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 a}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 refreshPreStartContext=function(){return{name:"refreshPreStartContext",setup:function(n){n.on("start",function(){var t=n.getPreStartQueue();t.forEach(function(r,e){t[e]=__assign(__assign({},r),{overrides:__assign(__assign({},null!==(r=r.overrides)&&void 0!==r?r:{}),{context:(null===(r=n.context)||void 0===r?void 0:r.toString())||{}})})})})}}},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)}function arrayIncludes(r,e){if(!isArray(r))return!1;if(0===r.length)return!1;for(var t=0;t<r.length;){if(r[t]===e)return!0;t++}return!1}var applyRecord=function(){var t={};return[t,function(r,e){return t[r]=e},function(r){return delete t[r]}]},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)}}function safeJoin(r,e){if(!isArray(r))return"";for(var t=[],n=0;n<r.length;n++)try{t.push(String(r[n]))}catch(r){t.push("[value cannot be serialized]")}return t.join(e)}var hookObjectProperty=function(i,a,u,c){return void 0===c&&(c=!0),function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];if(!i)return noop;var t=i[a],n=u.apply(void 0,__spreadArray([t],__read(r),!1)),o=n;return isFunction(o)&&c&&(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[a]=o,function(r){r||(o===i[a]?i[a]=t:n=t)}}},hookMethodDangerously=function(t,n,o){return function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];t[n]=o.apply(void 0,__spreadArray([t[n]],__read(r),!1))}};function mathRNG(){for(var r=new Array(16),e=0,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),r[t]=e>>>((3&t)<<3)&255;return r}function bytesToUuid(r){for(var e=[],t=0;t<256;++t)e[t]=(t+256).toString(16).substr(1);var n=0,o=e;return[o[r[n++]],o[r[n++]],o[r[n++]],o[r[n++]],"-",o[r[n++]],o[r[n++]],"-",o[r[n++]],o[r[n++]],"-",o[r[n++]],o[r[n++]],"-",o[r[n++]],o[r[n++]],o[r[n++]],o[r[n++]],o[r[+n]],o[r[15]]].join("")}function uuid(){var r=mathRNG();return r[6]=15&r[6]|64,r[8]=63&r[8]|128,bytesToUuid(r)}function getDefaultBrowser(){if("object"==typeof window&&isObject(window))return window}function getDefaultDocument(){if("object"==typeof document&&isObject(document))return document}function getDefaultPerformance(){if(getDefaultBrowser()&&isObject(window.performance))return window.performance}function getDefaultXMLHttpRequest(){if("function"==typeof XMLHttpRequest&&isFunction(XMLHttpRequest))return XMLHttpRequest}function getDefaultMutationObserver(){if(getDefaultBrowser()&&isFunction(window.MutationObserver))return window.MutationObserver}var getGlobalRegistry=function(r){if(r)return r.__SLARDAR_REGISTRY__||(r.__SLARDAR_REGISTRY__={Slardar:{plugins:[],errors:[]}}),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))},applyMutationObserver=function(r,e){var t=r&&new r(e);return[function(r,e){t&&r&&t.observe(r,e)},function(){return t&&t.disconnect()}]},applyPerformance=function(t){var r=t&&t.timing||void 0;return[r,function(){return t&&t.now?t.now():(Date.now?Date.now():+new Date)-(r&&r.navigationStart||0)},function(r){var e=(t||{}).getEntriesByType;return isFunction(e)&&e.call(t,r)||[]},function(){var r=(t||{}).clearResourceTimings;isFunction(r)&&r.call(t)},function(r){var e=(t||{}).getEntriesByName;return isFunction(e)&&e.call(t,r)||[]}]},applyMonitor=function(r,e,t,n){void 0===e&&(e={}),void 0===n&&(n=[]);try{var o=r.apply(void 0,__spreadArray([],__read(n),!1));return o&&o(e,t)||[]}catch(r){return reportSelfError(r),[]}},getConfig=function(r,e){return isObject(r)?__assign(__assign({},e),r):!!r&&e};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",hookGlobalAsync=function(o,e,r){void 0===e&&(e=getDefaultBrowser()),void 0===r&&(r=getDefaultXMLHttpRequest());function a(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 a(r,t)}))}catch(r){var e=normalize(r);throw e&&o({error:e,source:n}),r}});return e._hook_=!0,e}var u=[];return e&&u.push.apply(u,__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,a(r,{function:o})],__read(e),!1))}},!1)()})),!1)),r&&r.prototype&&u.push(hookObjectProperty(r.prototype,"send",function(n){return function(){for(var t=this,r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return u.push.apply(u,__spreadArray([],__read(xmlHttpRequestProps.filter(function(r){return t[r]&&!t[r]._hook_}).map(function(e){var r=hookObjectProperty(t,e,function(r){return a(r,{function:e})},!1)();return function(){r(),t[e]._hook_=void 0}})),!1)),n.apply(this,r)}},!1)()),DEFAULT_EVENT_TARGET.forEach(function(i){var r=e[i]&&e[i].prototype;r&&r[ADD_EVENT_LISTENER]&&(u.push(hookObjectProperty(r,ADD_EVENT_LISTENER,function(o){return function(r,e,t){try{var n=e.handleEvent;isFunction(n)&&(e.handleEvent=a(n,{function:"handleEvent",target:i}))}catch(r){}return o&&o.call(this,r,a(e,{function:ADD_EVENT_LISTENER,target:i}),t)}},!1)()),u.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)()))}),u},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}},JS_ERROR_EV_TYPE$1="js_error",JsErrorMonitor=function(_){if(_=void 0===_?getDefaultBrowser():_)return function(r,o){var e,t,n=r.ignoreErrors,i=r.onerror,a=r.onunhandledrejection,u=r.dedupe,r=r.captureGlobalAsync,c=getRegexp(n),s=[],l=dedupe(),f=function(r){var e=r.error,t=r.extra,n=r.react,r=r.source,e=u?l(e):e;o&&e&&(c&&c.test(e.message)||o({ev_type:JS_ERROR_EV_TYPE$1,payload:{error:e,breadcrumbs:[],extra:t,react:n,source:r}}))};i&&(_.addEventListener("error",e=function(r){return f({error:normalizeError(r),source:{type:"onerror"}})}),s.push(function(){return _.removeEventListener("error",e)})),a&&(_.addEventListener("unhandledrejection",t=function(r){return f({error:normalizeException(r),source:{type:"onunhandledrejection"}})}),s.push(function(){return _.removeEventListener("unhandledrejection",t)})),r&&s.push.apply(s,__spreadArray([],__read(hookGlobalAsync(f)),!1));return[function(r,e,t){return f({error:normalizeUnknownError(r),extra:e,react:t,source:{type:"manual"}})},function(){s.forEach(function(r){return r()})}]}},JS_ERROR_MONITOR_PLUGIN_NAME="jsError",defaultConfig$1={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$1);e&&(e=(r=__read(applyMonitor(JsErrorMonitor,e,function(r){t.getBreadcrumbs&&(r.payload.breadcrumbs=t.getBreadcrumbs()),t.report(r)}),2))[0],r=r[1],t.on("beforeDestroy",r),t.provide("captureException",e))})}var PAGE_ACTIVITY_DELAY=100,MAX_PAGE_ACTIVITY_DELAY=1e4,hookXHRSend=function(t,o,i){var a=0;return function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var n=a+=2;return o(n,Date.now()),hookMethodDangerously(this,"onreadystatechange",function(t){return function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return 4===this.readyState&&i(n),t&&t.apply(this,r)}})(),t.apply(this,r)}},hookFetch=function(o,i,a){var u=1;return function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var t=o.apply(void 0,__spreadArray([],__read(r),!1)),n=u+=2;i(n,Date.now());return t.then(function(){a(n)},function(){a(n)}),t}},applyIncompleteReq=function(r,e){var t=__read(applyRecord(),3),n=t[0],o=t[1],t=t[2];return e&&hookMethodDangerously(e.prototype,"send",hookXHRSend)(o,t),r&&hookMethodDangerously(r,"fetch",hookFetch)(o,t),[n]},waitActionComplete=function(r,e,t){var n,o;return[function(){t.clearTimeout(o),o=t.setTimeout(function(){r(),e()},MAX_PAGE_ACTIVITY_DELAY)},function(){t.clearTimeout(n),n=t.setTimeout(function(){r()},PAGE_ACTIVITY_DELAY)},function(){t.clearTimeout(n),t.clearTimeout(o)}]},getDomPath=function(r){var e=r,t=[];try{for(;null!==e.parentNode;){for(var n=0,o=0,i=0;i<e.parentNode.childNodes.length;i++){var a=e.parentNode.childNodes[i];a.nodeName===e.nodeName&&(a===e&&(o=n),n++)}e.hasAttribute("id")&&""!==e.id?t.unshift(e.nodeName+"#"+e.id):1<n?t.unshift(e.nodeName+":eq("+o+")"):t.unshift(e.nodeName),e=e.parentNode}return t.slice(1).join(">")}catch(r){return}},ACTION_EV_TYPE="action",HTTP_EV_TYPE="http",LONGTASK_RV_TYPE="performance_longtask",JS_ERROR_EV_TYPE="js_error",RESOURCE_EV_TYPE="resource",RELATED_EV_TYPES=[LONGTASK_RV_TYPE,HTTP_EV_TYPE,JS_ERROR_EV_TYPE,RESOURCE_EV_TYPE],SUPPORT_TYPES=["click"],EVENT_LISTENER_OPTIONS={capture:!0},ActionMonitor=function(y,h,T,m,R){if(void 0===y&&(y=getDefaultBrowser()),void 0===h&&(h=getDefaultDocument()),void 0===T&&(T=getDefaultXMLHttpRequest()),void 0===m&&(m=getDefaultMutationObserver()),void 0===R&&(R=getDefaultPerformance()),h&&y)return function(r,t){var e=r.types,n=[],o=null,i=[],a=0,u=__read(applyPerformance(R),2)[1],c=__read(applyIncompleteReq(y,T),1)[0],s=function(){var r,e;o&&Object.keys(o.metrics).length&&!Object.keys(c).length&&(o.metrics[LONGTASK_RV_TYPE]&&(o.metrics[LONGTASK_RV_TYPE].duration=a),r=0<i.length?Math.max.apply(Math,__spreadArray([],__read(i),!1))-Math.min.apply(Math,__spreadArray([],__read(i),!1)):0,o.metrics[HTTP_EV_TYPE]&&(o.metrics[HTTP_EV_TYPE].duration=r),e=u()-o.start_time,t&&t({ev_type:ACTION_EV_TYPE,payload:__assign(__assign({},o),{duration:e,frontend_time:e-r})}),l())},l=function(){E(),o=null,i=[],a=0},f=__read(waitActionComplete(s,l,y),3),_=f[0],p=f[1],E=f[2],r=__read(applyMutationObserver(m,p),2),f=r[0],d=r[1];f();function v(r){var e;s(),l(),r.target instanceof HTMLElement&&((e=r.target.innerText)&&(g({name:e,path:getDomPath(r.target)},r.type),_()))}var g=function(r,e){var t=uuid(),n=__read(applyPerformance(R),2)[1];o={start_time:n(),id:t,type:e,target:r,metrics:{}}};e&&e.forEach(function(r){arrayIncludes(SUPPORT_TYPES,r)&&(h.addEventListener(r,v,EVENT_LISTENER_OPTIONS),n.push(function(){return h.removeEventListener(r,v,EVENT_LISTENER_OPTIONS)}))});return[function(){n.forEach(function(r){return r()}),d()},function(r){if(o&&arrayIncludes(RELATED_EV_TYPES,r.ev_type)){if(p(),r.ev_type===HTTP_EV_TYPE){if(!r.payload.response.timing)return;var e=r.payload.response.timing,t=e.startTime,e=e.duration;if(t<o.start_time)return;i.push(t,t+e)}else if(r.ev_type===LONGTASK_RV_TYPE){if(!r.payload.longtasks.length||r.payload.longtasks[0].startTime<o.start_time)return;r.payload.longtasks.forEach(function(r){a+=r.duration})}else if(r.ev_type===RESOURCE_EV_TYPE&&r.payload.startTime<o.start_time)return;return o.metrics[r.ev_type]={count:(null!==(r=null===(r=o.metrics[r.ev_type])||void 0===r?void 0:r.count)&&void 0!==r?r:0)+1},o.id}},function(r,e){s(),l(),g({name:r},e),_()}]}},ACTION_MONITOR_PLUGIN_NAME="action",defaultConfig={types:["click"]};function ActionMonitorBasePlugin(r,e){function t(r){var e=o(r);return e&&r.extra&&(r.extra.action_id=e),r}var e=__read(applyMonitor(ActionMonitor,e=void 0===e?defaultConfig:e,r.report.bind(r)),3),n=e[0],o=e[1],e=e[2];r.on("report",t),r.provide("startAction",e),r.on("beforeDestroy",function(){n(),r.off("report",t)})}var captureConsole=function(r){var r=r.levels,e=void 0===r?["log","info","warn","error","debug","assert"]:r;return{name:"captureConsole",setup:function(n){var o=getDefaultBrowser();o&&o.console&&e.forEach(function(r){r in o.console&&hookMethodDangerously(o.console,r,function(t){return function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];try{t&&t.call.apply(t,__spreadArray([o.console],__read(r),!1))}finally{n("captureException",safeJoin(r," "))}}})()})}}},jsErrorPlugin=function(){return{name:JS_ERROR_MONITOR_PLUGIN_NAME,setup:function(r){JsErrorMonitorPlugin(r)}}},actionPlugin=function(e){return{name:ACTION_MONITOR_PLUGIN_NAME,setup:function(r){ActionMonitorBasePlugin(r,e)}}};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(r){for(var t,e=1,n=arguments.length;e<n;e++)for(var o in t=arguments[e])Object.prototype.hasOwnProperty.call(t,o)&&(r[o]=t[o]);return r}).apply(this,arguments)};function __read(r,t){var e="function"==typeof Symbol&&r[Symbol.iterator];if(!e)return r;var n,o,i=e.call(r),a=[];try{for(;(void 0===t||0<t--)&&!(n=i.next()).done;)a.push(n.value)}catch(r){o={error:r}}finally{try{n&&!n.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return a}function __spreadArray(r,t,e){if(e||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 r.concat(n||Array.prototype.slice.call(t))}var refreshPreStartContext=function(){return{name:"refreshPreStartContext",setup:function(n){n.on("start",function(){var e=n.getPreStartQueue();e.forEach(function(r,t){e[t]=__assign(__assign({},r),{overrides:__assign(__assign({},null!==(r=r.overrides)&&void 0!==r?r:{}),{context:(null===(r=n.context)||void 0===r?void 0:r.toString())||{}})})})})}}},noop=function(){return{}};function isObject(r){return"object"==typeof r&&null!==r}function isInstanceOf(r,t){try{return r instanceof t}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)}function arrayIncludes(r,t){if(!isArray(r))return!1;if(0===r.length)return!1;for(var e=0;e<r.length;){if(r[e]===t)return!0;e++}return!1}var applyRecord=function(){var e={};return[e,function(r,t){return e[r]=t},function(r){return delete e[r]}]},pick=function(e,r){return e&&isObject(e)?r.reduce(function(r,t){return r[t]=e[t],r},{}):e};function getRegexp(r){return isArray(r)&&r.length?joinRegExp(r):null}function joinRegExp(r){for(var t=[],e=r.length,n=0;n<e;n++){var o=r[n];isString(o)?t.push(o.replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")):o&&o.source&&t.push(o.source)}return new RegExp(t.join("|"),"i")}function safeStringify(r){try{return isString(r)?r:JSON.stringify(r)}catch(r){return"[FAILED_TO_STRINGIFY]:"+String(r)}}function safeJoin(r,t){if(!isArray(r))return"";for(var e=[],n=0;n<r.length;n++)try{e.push(String(r[n]))}catch(r){e.push("[value cannot be serialized]")}return e.join(t)}var hookObjectProperty=function(i,a,u,c){return void 0===c&&(c=!0),function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];if(!i)return noop;var e=i[a],n=u.apply(void 0,__spreadArray([e],__read(r),!1)),o=n;return isFunction(o)&&c&&(o=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];try{return n.apply(this,t)}catch(r){return isFunction(e)&&e.apply(this,t)}}),i[a]=o,function(r){r||(o===i[a]?i[a]=e:n=e)}}},hookMethodDangerously=function(i,a,u){return function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];if(!i)return noop;var e=i[a],n=u.apply(void 0,__spreadArray([e],__read(r),!1)),o=n;return isFunction(o)&&(o=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return n.apply(this,r)}),i[a]=o,function(){o===i[a]?i[a]=e:n=e}}};function mathRNG(){for(var r=new Array(16),t=0,e=0;e<16;e++)0==(3&e)&&(t=4294967296*Math.random()),r[e]=t>>>((3&e)<<3)&255;return r}function bytesToUuid(r){for(var t=[],e=0;e<256;++e)t[e]=(e+256).toString(16).substr(1);var n=0,o=t;return[o[r[n++]],o[r[n++]],o[r[n++]],o[r[n++]],"-",o[r[n++]],o[r[n++]],"-",o[r[n++]],o[r[n++]],"-",o[r[n++]],o[r[n++]],"-",o[r[n++]],o[r[n++]],o[r[n++]],o[r[n++]],o[r[+n]],o[r[15]]].join("")}function uuid(){var r=mathRNG();return r[6]=15&r[6]|64,r[8]=63&r[8]|128,bytesToUuid(r)}function getDefaultBrowser(){if("object"==typeof window&&isObject(window))return window}function getDefaultDocument(){if("object"==typeof document&&isObject(document))return document}function getDefaultPerformance(){if(getDefaultBrowser()&&isObject(window.performance))return window.performance}function getDefaultXMLHttpRequest(){if("function"==typeof XMLHttpRequest&&isFunction(XMLHttpRequest))return XMLHttpRequest}function getDefaultMutationObserver(){if(getDefaultBrowser()&&isFunction(window.MutationObserver))return window.MutationObserver}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=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=getGlobalRegistry(getDefaultBrowser());e&&(e.errors||(e.errors=[]),e.errors.push(r))},applyMutationObserver=function(r,t){var e=r&&new r(t);return[function(r,t){e&&r&&e.observe(r,t)},function(){return e&&e.disconnect()}]},applyPerformance=function(e){var r=e&&e.timing||void 0;return[r,function(){return e&&e.now?e.now():(Date.now?Date.now():+new Date)-(r&&r.navigationStart||0)},function(r){var t=(e||{}).getEntriesByType;return isFunction(t)&&t.call(e,r)||[]},function(){var r=(e||{}).clearResourceTimings;isFunction(r)&&r.call(e)},function(r){var t=(e||{}).getEntriesByName;return isFunction(t)&&t.call(e,r)||[]}]},applyMonitor=function(r,t,e,n){void 0===t&&(t={}),void 0===n&&(n=[]);try{var o=r.apply(void 0,__spreadArray([],__read(n),!1));return o&&o(t,e)||[]}catch(r){return reportSelfError(r),[]}},now=function(){return Date.now()},getConfig=function(r,t){return isObject(r)?__assign(__assign({},t),r):!!r&&t};function getPluginConfig(r,t,e){t=null===(r=r.config())||void 0===r?void 0:r.plugins[t];return getConfig(t,e)}var ERROR_FIELDS=["name","message","stack","filename","lineno","colno"],normalize=function(r){var t;return isError(r)?t=pick(r,ERROR_FIELDS):(isPlainObject(r)||isEvent(r)||isString(r))&&(t={message:safeStringify(r)}),t},normalizeError=function(r){return normalize(r.error)},normalizeException=function(r){var t;try{var e=void 0;if("reason"in r?e=r.reason:"detail"in r&&"reason"in r.detail&&(e=r.detail.reason),e){var n=normalize(e);return __assign(__assign({},n),{name:null!==(t=n&&n.name)&&void 0!==t?t:"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",hookGlobalAsync=function(o,t,r){void 0===t&&(t=getDefaultBrowser()),void 0===r&&(r=getDefaultXMLHttpRequest());function a(r,e){if(!isFunction(r))return r;var n={type:DEFAULT_SOURCE_TYPE,data:__assign({},e)},t=r._w_||(r._w_=function(){try{return(r.handleEvent&&isFunction(r.handleEvent)?r.handleEvent:r).apply(this,[].map.call(arguments,function(r){return a(r,e)}))}catch(r){var t=normalize(r);throw t&&o({error:t,source:n}),r}});return t._hook_=!0,t}var u=[];return t&&u.push.apply(u,__spreadArray([],__read(DEFAULT_TIME_FUNCTION.filter(function(r){return t[r]}).map(function(o){return hookObjectProperty(t,o,function(n){return function(r){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];return n&&n.call.apply(n,__spreadArray([this,a(r,{function:o})],__read(t),!1))}},!1)()})),!1)),r&&r.prototype&&u.push(hookObjectProperty(r.prototype,"send",function(n){return function(){for(var e=this,r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return u.push.apply(u,__spreadArray([],__read(xmlHttpRequestProps.filter(function(r){return e[r]&&!e[r]._hook_}).map(function(t){var r=hookObjectProperty(e,t,function(r){return a(r,{function:t})},!1)();return function(){r(),e[t]._hook_=void 0}})),!1)),n.apply(this,r)}},!1)()),DEFAULT_EVENT_TARGET.forEach(function(i){var r=t[i]&&t[i].prototype;r&&r[ADD_EVENT_LISTENER]&&(u.push(hookObjectProperty(r,ADD_EVENT_LISTENER,function(o){return function(r,t,e){try{var n=t.handleEvent;isFunction(n)&&(t.handleEvent=a(n,{function:"handleEvent",target:i}))}catch(r){}return o&&o.call(this,r,a(t,{function:ADD_EVENT_LISTENER,target:i}),e)}},!1)()),u.push(hookObjectProperty(r,REMOVE_EVENT_LISTENER,function(n){return function(r,t,e){return null!=t&&t._w_&&n.call(this,r,t._w_,e),n.call(this,r,t,e)}},!1)()))}),u},isSameErrorString=function(r,t){return r&&t&&r===t},shouldDropEvent=function(r,t){return!(!r||!t)&&!(!isSameErrorString(r.message,t.message)||!isSameErrorString(r.stack,t.stack))},dedupe=function(){var t;return function(r){try{if(shouldDropEvent(r,t))return void(t=r)}catch(r){reportSelfError(r)}return t=r}},JS_ERROR_EV_TYPE$1="js_error",JsErrorMonitor=function(p){if(p=void 0===p?getDefaultBrowser():p)return function(r,o){var t,e,n=r.ignoreErrors,i=r.onerror,a=r.onunhandledrejection,u=r.dedupe,r=r.captureGlobalAsync,c=getRegexp(n),s=[],f=dedupe(),l=function(r){var t=r.error,e=r.extra,n=r.react,r=r.source,t=u?f(t):t;o&&t&&(c&&c.test(t.message)||o({ev_type:JS_ERROR_EV_TYPE$1,payload:{error:t,breadcrumbs:[],extra:e,react:n,source:r}}))};i&&(p.addEventListener("error",t=function(r){return l({error:normalizeError(r),source:{type:"onerror"}})}),s.push(function(){return p.removeEventListener("error",t)})),a&&(p.addEventListener("unhandledrejection",e=function(r){return l({error:normalizeException(r),source:{type:"onunhandledrejection"}})}),s.push(function(){return p.removeEventListener("unhandledrejection",e)})),r&&s.push.apply(s,__spreadArray([],__read(hookGlobalAsync(l)),!1));return[function(r,t,e){return l({error:normalizeUnknownError(r),extra:t,react:e,source:{type:"manual"}})},function(){s.forEach(function(r){return r()})}]}},JS_ERROR_MONITOR_PLUGIN_NAME="jsError",defaultConfig$1={ignoreErrors:[],onerror:!0,onunhandledrejection:!0,captureGlobalAsync:!1,dedupe:!0};function JsErrorMonitorPlugin(e){e.on("init",function(){window.removeEventListener("error",e.pcErr,!0),window.removeEventListener("unhandledrejection",e.pcRej,!0);var r,t=getPluginConfig(e,JS_ERROR_MONITOR_PLUGIN_NAME,defaultConfig$1);t&&(t=(r=__read(applyMonitor(JsErrorMonitor,t,function(r){e.getBreadcrumbs&&(r.payload.breadcrumbs=e.getBreadcrumbs()),e.report(r)}),2))[0],r=r[1],e.on("beforeDestroy",r),e.provide("captureException",t))})}var PAGE_ACTIVITY_DELAY=100,MAX_PAGE_ACTIVITY_DELAY=1e4,hookXHRSend=function(e,o,i){var a=0;return function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var n=a+=2;return o(n,now()),hookMethodDangerously(this,"onreadystatechange",function(e){return function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return 4===this.readyState&&i(n),e&&e.apply(this,r)}})(),e.apply(this,r)}},hookFetch=function(o,i,a){var u=1;return function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var e=o.apply(void 0,__spreadArray([],__read(r),!1)),n=u+=2;i(n,now());return e.then(function(){a(n)},function(){a(n)}),e}},applyIncompleteReq=function(r,t){var e=__read(applyRecord(),3),n=e[0],o=e[1],e=e[2];return t&&hookMethodDangerously(t.prototype,"send",hookXHRSend)(o,e),r&&hookMethodDangerously(r,"fetch",hookFetch)(o,e),[n]},waitActionComplete=function(r,t,e){var n,o;return[function(){e.clearTimeout(o),o=e.setTimeout(function(){r(),t()},MAX_PAGE_ACTIVITY_DELAY)},function(){e.clearTimeout(n),n=e.setTimeout(function(){r()},PAGE_ACTIVITY_DELAY)},function(){e.clearTimeout(n),e.clearTimeout(o)}]},getDomPath=function(r){var t=r,e=[];try{for(;null!==t.parentNode;){for(var n=0,o=0,i=0;i<t.parentNode.childNodes.length;i++){var a=t.parentNode.childNodes[i];a.nodeName===t.nodeName&&(a===t&&(o=n),n++)}t.hasAttribute("id")&&""!==t.id?e.unshift(t.nodeName+"#"+t.id):1<n?e.unshift(t.nodeName+":eq("+o+")"):e.unshift(t.nodeName),t=t.parentNode}return e.slice(1).join(">")}catch(r){return}},ACTION_EV_TYPE="action",HTTP_EV_TYPE="http",LONGTASK_RV_TYPE="performance_longtask",JS_ERROR_EV_TYPE="js_error",RESOURCE_EV_TYPE="resource",RELATED_EV_TYPES=[LONGTASK_RV_TYPE,HTTP_EV_TYPE,JS_ERROR_EV_TYPE,RESOURCE_EV_TYPE],SUPPORT_TYPES=["click"],EVENT_LISTENER_OPTIONS={capture:!0},ActionMonitor=function(y,h,T,m,R){if(void 0===y&&(y=getDefaultBrowser()),void 0===h&&(h=getDefaultDocument()),void 0===T&&(T=getDefaultXMLHttpRequest()),void 0===m&&(m=getDefaultMutationObserver()),void 0===R&&(R=getDefaultPerformance()),h&&y)return function(r,e){var t=r.types,n=[],o=null,i=[],a=0,u=__read(applyPerformance(R),2)[1],c=__read(applyIncompleteReq(y,T),1)[0],s=function(){var r,t;o&&Object.keys(o.metrics).length&&!Object.keys(c).length&&(o.metrics[LONGTASK_RV_TYPE]&&(o.metrics[LONGTASK_RV_TYPE].duration=a),r=0<i.length?Math.max.apply(Math,__spreadArray([],__read(i),!1))-Math.min.apply(Math,__spreadArray([],__read(i),!1)):0,o.metrics[HTTP_EV_TYPE]&&(o.metrics[HTTP_EV_TYPE].duration=r),t=u()-o.start_time,e&&e({ev_type:ACTION_EV_TYPE,payload:__assign(__assign({},o),{duration:t,frontend_time:t-r})}),f())},f=function(){E(),o=null,i=[],a=0},l=__read(waitActionComplete(s,f,y),3),p=l[0],_=l[1],E=l[2],r=__read(applyMutationObserver(m,_),2),l=r[0],d=r[1];l();function v(r){var t;s(),f(),r.target instanceof HTMLElement&&((t=r.target.innerText)&&(g({name:t,path:getDomPath(r.target)},r.type),p()))}var g=function(r,t){var e=uuid(),n=__read(applyPerformance(R),2)[1];o={start_time:n(),id:e,type:t,target:r,metrics:{}}};t&&t.forEach(function(r){arrayIncludes(SUPPORT_TYPES,r)&&(h.addEventListener(r,v,EVENT_LISTENER_OPTIONS),n.push(function(){return h.removeEventListener(r,v,EVENT_LISTENER_OPTIONS)}))});return[function(){n.forEach(function(r){return r()}),d()},function(r){if(o&&arrayIncludes(RELATED_EV_TYPES,r.ev_type)){if(_(),r.ev_type===HTTP_EV_TYPE){if(!r.payload.response.timing)return;var t=r.payload.response.timing,e=t.startTime,t=t.duration;if(e<o.start_time)return;i.push(e,e+t)}else if(r.ev_type===LONGTASK_RV_TYPE){if(!r.payload.longtasks.length||r.payload.longtasks[0].startTime<o.start_time)return;r.payload.longtasks.forEach(function(r){a+=r.duration})}else if(r.ev_type===RESOURCE_EV_TYPE&&r.payload.startTime<o.start_time)return;return o.metrics[r.ev_type]={count:(null!==(r=null===(r=o.metrics[r.ev_type])||void 0===r?void 0:r.count)&&void 0!==r?r:0)+1},o.id}},function(r,t){s(),f(),g({name:r},t),p()}]}},ACTION_MONITOR_PLUGIN_NAME="action",defaultConfig={types:["click"]};function ActionMonitorBasePlugin(r,t){function e(r){var t=o(r);return t&&r.extra&&(r.extra.action_id=t),r}var t=__read(applyMonitor(ActionMonitor,t=void 0===t?defaultConfig:t,r.report.bind(r)),3),n=t[0],o=t[1],t=t[2];r.on("report",e),r.provide("startAction",t),r.on("beforeDestroy",function(){n(),r.off("report",e)})}var captureConsole=function(r){var r=r.levels,e=void 0===r?["log","info","warn","error","debug","assert"]:r;return{name:"captureConsole",setup:function(n){var t,o=getDefaultBrowser();o&&o.console&&(t=[],e.forEach(function(r){r in o.console&&t.push(hookMethodDangerously(o.console,r,function(e){return function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];try{e&&e.call.apply(e,__spreadArray([o.console],__read(r),!1))}finally{n("captureException",safeJoin(r," "))}}})())}),n.on("beforeDestroy",function(){t.forEach(function(r){return r()})}))}}},jsErrorPlugin=function(){return{name:JS_ERROR_MONITOR_PLUGIN_NAME,setup:function(r){JsErrorMonitorPlugin(r)}}},actionPlugin=function(t){return{name:ACTION_MONITOR_PLUGIN_NAME,setup:function(r){ActionMonitorBasePlugin(r,t)}}};exports.actionPlugin=actionPlugin,exports.captureConsole=captureConsole,exports.jsErrorPlugin=jsErrorPlugin,exports.refreshPreStartContext=refreshPreStartContext;

@@ -115,2 +115,7 @@ declare type BatchSender<E> = EventSender<E> & {

declare type ParametersForFn<T extends (args: any) => any> = T extends (args: infer P) => any ? P : never;
declare type SafeObservable<T> = [(f: T) => () => void, (f: T) => void];
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 NextLink<T extends (args: any) => any> = (args: ParametersForFn<T>, cb: T[]) => NextLink<ReturnType<T>>;
declare type WithContext<C extends AnyClient> = C & {

@@ -142,2 +147,7 @@ context?: ContextAgent;

declare type WithSubject<C extends AnyClient> = C & {
initSubject: <T extends (args: any) => any>(args: [subjectKey: string, collector: Observer<T>]) => SafeObservable<T>;
getSubject: (key: string) => SafeObservable<any> | undefined;
};
/** 公共筛选条件 */

@@ -727,6 +737,7 @@ interface FilterCondition {

onPidUpdate?: (pid: string) => void;
createObserver?: (mode: string) => SafeObservable<(args: string) => void>;
}
declare const PAGEVIEW_MONITOR_PLUGIN_NAME = "pageview";
declare type WithSendPageview<C extends WebClient$1> = C & {
declare type WithSendPageview<C extends WithSubject<WebClient$1>> = C & {
sendPageview?: SendPageview;

@@ -783,3 +794,5 @@ };

lcp = "lcp",
cls = "cls"
cls = "cls",
longtask = "longtask",
timing = "timing"
}

@@ -792,5 +805,2 @@ interface PerformancePrecollect {

[key in MetricEnum]: boolean;
} & {
timing: boolean;
longtask: boolean;
};

@@ -1011,4 +1021,3 @@

type PrecollectArg = [string, string, PrecollectData, number, string]
type BrowserClient =
WithDetectBlankScreen<
type BrowserClient = WithDetectBlankScreen<
WithBreadcrumb<

@@ -1021,10 +1030,12 @@ WithReportResourceError<

WithContext<
Client<
BrowserReportEvent,
BrowserSendEvent,
BrowserBuilder,
BrowserSender,
BrowserInitConfig,
BrowserUserConfig,
BrowserConfig
WithSubject<
Client<
BrowserReportEvent,
BrowserSendEvent,
BrowserBuilder,
BrowserSender,
BrowserInitConfig,
BrowserUserConfig,
BrowserConfig
>
>

@@ -1031,0 +1042,0 @@ >

@@ -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),a=[];try{for(;(void 0===e||0<e--)&&!(n=i.next()).done;)a.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 a}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,a,u,c){return void 0===c&&(c=!0),function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];if(!i)return noop;var t=i[a],n=u.apply(void 0,__spreadArray([t],__read(r),!1)),o=n;return isFunction(o)&&c&&(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[a]=o,function(r){r||(o===i[a]?i[a]=t:n=t)}}};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:[]}}),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))},applyMonitor=function(r,e,t,n){void 0===e&&(e={}),void 0===n&&(n=[]);try{var o=r.apply(void 0,__spreadArray([],__read(n),!1));return o&&o(e,t)||[]}catch(r){return reportSelfError(r),[]}},getConfig=function(r,e){return isObject(r)?__assign(__assign({},e),r):!!r&&e};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",hookGlobalAsync=function(o,e,r){void 0===e&&(e=getDefaultBrowser()),void 0===r&&(r=getDefaultXMLHttpRequest());function a(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 a(r,t)}))}catch(r){var e=normalize(r);throw e&&o({error:e,source:n}),r}});return e._hook_=!0,e}var u=[];return e&&u.push.apply(u,__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,a(r,{function:o})],__read(e),!1))}},!1)()})),!1)),r&&r.prototype&&u.push(hookObjectProperty(r.prototype,"send",function(n){return function(){for(var t=this,r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return u.push.apply(u,__spreadArray([],__read(xmlHttpRequestProps.filter(function(r){return t[r]&&!t[r]._hook_}).map(function(e){var r=hookObjectProperty(t,e,function(r){return a(r,{function:e})},!1)();return function(){r(),t[e]._hook_=void 0}})),!1)),n.apply(this,r)}},!1)()),DEFAULT_EVENT_TARGET.forEach(function(i){var r=e[i]&&e[i].prototype;r&&r[ADD_EVENT_LISTENER]&&(u.push(hookObjectProperty(r,ADD_EVENT_LISTENER,function(o){return function(r,e,t){try{var n=e.handleEvent;isFunction(n)&&(e.handleEvent=a(n,{function:"handleEvent",target:i}))}catch(r){}return o&&o.call(this,r,a(e,{function:ADD_EVENT_LISTENER,target:i}),t)}},!1)()),u.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)()))}),u},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}},JS_ERROR_EV_TYPE="js_error",JsErrorMonitor=function(p){if(p=void 0===p?getDefaultBrowser():p)return function(r,o){var e,t,n=r.ignoreErrors,i=r.onerror,a=r.onunhandledrejection,u=r.dedupe,r=r.captureGlobalAsync,c=getRegexp(n),s=[],l=dedupe(),f=function(r){var e=r.error,t=r.extra,n=r.react,r=r.source,e=u?l(e):e;o&&e&&(c&&c.test(e.message)||o({ev_type:JS_ERROR_EV_TYPE,payload:{error:e,breadcrumbs:[],extra:t,react:n,source:r}}))};i&&(p.addEventListener("error",e=function(r){return f({error:normalizeError(r),source:{type:"onerror"}})}),s.push(function(){return p.removeEventListener("error",e)})),a&&(p.addEventListener("unhandledrejection",t=function(r){return f({error:normalizeException(r),source:{type:"onunhandledrejection"}})}),s.push(function(){return p.removeEventListener("unhandledrejection",t)})),r&&s.push.apply(s,__spreadArray([],__read(hookGlobalAsync(f)),!1));return[function(r,e,t){return f({error:normalizeUnknownError(r),extra:e,react:t,source:{type:"manual"}})},function(){s.forEach(function(r){return r()})}]}},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=(r=__read(applyMonitor(JsErrorMonitor,e,function(r){t.getBreadcrumbs&&(r.payload.breadcrumbs=t.getBreadcrumbs()),t.report(r)}),2))[0],r=r[1],t.on("beforeDestroy",r),t.provide("captureException",e))})}var jsErrorPlugin=function(){return{name:JS_ERROR_MONITOR_PLUGIN_NAME,setup:function(r){JsErrorMonitorPlugin(r)}}};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),a=[];try{for(;(void 0===e||0<e--)&&!(n=i.next()).done;)a.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 a}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,a,u,c){return void 0===c&&(c=!0),function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];if(!i)return noop;var t=i[a],n=u.apply(void 0,__spreadArray([t],__read(r),!1)),o=n;return isFunction(o)&&c&&(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[a]=o,function(r){r||(o===i[a]?i[a]=t:n=t)}}};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))},applyMonitor=function(r,e,t,n){void 0===e&&(e={}),void 0===n&&(n=[]);try{var o=r.apply(void 0,__spreadArray([],__read(n),!1));return o&&o(e,t)||[]}catch(r){return reportSelfError(r),[]}},getConfig=function(r,e){return isObject(r)?__assign(__assign({},e),r):!!r&&e};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",hookGlobalAsync=function(o,e,r){void 0===e&&(e=getDefaultBrowser()),void 0===r&&(r=getDefaultXMLHttpRequest());function a(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 a(r,t)}))}catch(r){var e=normalize(r);throw e&&o({error:e,source:n}),r}});return e._hook_=!0,e}var u=[];return e&&u.push.apply(u,__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,a(r,{function:o})],__read(e),!1))}},!1)()})),!1)),r&&r.prototype&&u.push(hookObjectProperty(r.prototype,"send",function(n){return function(){for(var t=this,r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return u.push.apply(u,__spreadArray([],__read(xmlHttpRequestProps.filter(function(r){return t[r]&&!t[r]._hook_}).map(function(e){var r=hookObjectProperty(t,e,function(r){return a(r,{function:e})},!1)();return function(){r(),t[e]._hook_=void 0}})),!1)),n.apply(this,r)}},!1)()),DEFAULT_EVENT_TARGET.forEach(function(i){var r=e[i]&&e[i].prototype;r&&r[ADD_EVENT_LISTENER]&&(u.push(hookObjectProperty(r,ADD_EVENT_LISTENER,function(o){return function(r,e,t){try{var n=e.handleEvent;isFunction(n)&&(e.handleEvent=a(n,{function:"handleEvent",target:i}))}catch(r){}return o&&o.call(this,r,a(e,{function:ADD_EVENT_LISTENER,target:i}),t)}},!1)()),u.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)()))}),u},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}},JS_ERROR_EV_TYPE="js_error",JsErrorMonitor=function(p){if(p=void 0===p?getDefaultBrowser():p)return function(r,o){var e,t,n=r.ignoreErrors,i=r.onerror,a=r.onunhandledrejection,u=r.dedupe,r=r.captureGlobalAsync,c=getRegexp(n),s=[],l=dedupe(),f=function(r){var e=r.error,t=r.extra,n=r.react,r=r.source,e=u?l(e):e;o&&e&&(c&&c.test(e.message)||o({ev_type:JS_ERROR_EV_TYPE,payload:{error:e,breadcrumbs:[],extra:t,react:n,source:r}}))};i&&(p.addEventListener("error",e=function(r){return f({error:normalizeError(r),source:{type:"onerror"}})}),s.push(function(){return p.removeEventListener("error",e)})),a&&(p.addEventListener("unhandledrejection",t=function(r){return f({error:normalizeException(r),source:{type:"onunhandledrejection"}})}),s.push(function(){return p.removeEventListener("unhandledrejection",t)})),r&&s.push.apply(s,__spreadArray([],__read(hookGlobalAsync(f)),!1));return[function(r,e,t){return f({error:normalizeUnknownError(r),extra:e,react:t,source:{type:"manual"}})},function(){s.forEach(function(r){return r()})}]}},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=(r=__read(applyMonitor(JsErrorMonitor,e,function(r){t.getBreadcrumbs&&(r.payload.breadcrumbs=t.getBreadcrumbs()),t.report(r)}),2))[0],r=r[1],t.on("beforeDestroy",r),t.provide("captureException",e))})}var jsErrorPlugin=function(){return{name:JS_ERROR_MONITOR_PLUGIN_NAME,setup:function(r){JsErrorMonitorPlugin(r)}}};exports.jsErrorPlugin=jsErrorPlugin;

@@ -115,2 +115,7 @@ declare type BatchSender<E> = EventSender<E> & {

declare type ParametersForFn<T extends (args: any) => any> = T extends (args: infer P) => any ? P : never;
declare type SafeObservable<T> = [(f: T) => () => void, (f: T) => void];
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 NextLink<T extends (args: any) => any> = (args: ParametersForFn<T>, cb: T[]) => NextLink<ReturnType<T>>;
declare type WithContext<C extends AnyClient> = C & {

@@ -142,2 +147,7 @@ context?: ContextAgent;

declare type WithSubject<C extends AnyClient> = C & {
initSubject: <T extends (args: any) => any>(args: [subjectKey: string, collector: Observer<T>]) => SafeObservable<T>;
getSubject: (key: string) => SafeObservable<any> | undefined;
};
/** 公共筛选条件 */

@@ -727,6 +737,7 @@ interface FilterCondition {

onPidUpdate?: (pid: string) => void;
createObserver?: (mode: string) => SafeObservable<(args: string) => void>;
}
declare const PAGEVIEW_MONITOR_PLUGIN_NAME = "pageview";
declare type WithSendPageview<C extends WebClient$1> = C & {
declare type WithSendPageview<C extends WithSubject<WebClient$1>> = C & {
sendPageview?: SendPageview;

@@ -783,3 +794,5 @@ };

lcp = "lcp",
cls = "cls"
cls = "cls",
longtask = "longtask",
timing = "timing"
}

@@ -792,5 +805,2 @@ interface PerformancePrecollect {

[key in MetricEnum]: boolean;
} & {
timing: boolean;
longtask: boolean;
};

@@ -1011,4 +1021,3 @@

type PrecollectArg = [string, string, PrecollectData, number, string]
type BrowserClient =
WithDetectBlankScreen<
type BrowserClient = WithDetectBlankScreen<
WithBreadcrumb<

@@ -1021,10 +1030,12 @@ WithReportResourceError<

WithContext<
Client<
BrowserReportEvent,
BrowserSendEvent,
BrowserBuilder,
BrowserSender,
BrowserInitConfig,
BrowserUserConfig,
BrowserConfig
WithSubject<
Client<
BrowserReportEvent,
BrowserSendEvent,
BrowserBuilder,
BrowserSender,
BrowserInitConfig,
BrowserUserConfig,
BrowserConfig
>
>

@@ -1055,3 +1066,3 @@ >

declare type WebClient = Client<BrowserReportEvent, any, any, any, any, any, BrowserConfig>;
declare type WebClient = WithSubject<Client<BrowserReportEvent, any, any, any, any, any, BrowserConfig>>;
declare const pageviewPlugin: () => {

@@ -1058,0 +1069,0 @@ name: string;

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __assign=function(){return(__assign=Object.assign||function(n){for(var r,t=1,e=arguments.length;t<e;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o]);return n}).apply(this,arguments)};function __read(n,r){var t="function"==typeof Symbol&&n[Symbol.iterator];if(!t)return n;var e,o,i=t.call(n),a=[];try{for(;(void 0===r||0<r--)&&!(e=i.next()).done;)a.push(e.value)}catch(n){o={error:n}}finally{try{e&&!e.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return a}function __spreadArray(n,r,t){if(t||2===arguments.length)for(var e,o=0,i=r.length;o<i;o++)!e&&o in r||((e=e||Array.prototype.slice.call(r,0,o))[o]=r[o]);return n.concat(e||Array.prototype.slice.call(r))}var noop=function(){return{}};function isObject(n){return"object"==typeof n&&null!==n}function isFunction(n){return"function"==typeof n}var hookObjectProperty=function(i,a,u,f){return void 0===f&&(f=!0),function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];if(!i)return noop;var t=i[a],e=u.apply(void 0,__spreadArray([t],__read(n),!1)),o=e;return isFunction(o)&&f&&(o=function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];try{return e.apply(this,r)}catch(n){return isFunction(t)&&t.apply(this,r)}}),i[a]=o,function(n){n||(o===i[a]?i[a]=t:e=t)}}};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}var getGlobalRegistry=function(n){if(n)return n.__SLARDAR_REGISTRY__||(n.__SLARDAR_REGISTRY__={Slardar:{plugins:[],errors:[]}}),n.__SLARDAR_REGISTRY__.Slardar},reportSelfError=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var t=getGlobalRegistry(getDefaultBrowser());t&&(t.errors||(t.errors=[]),t.errors.push(n))},applyMonitor=function(n,r,t,e){void 0===r&&(r={}),void 0===e&&(e=[]);try{var o=n.apply(void 0,__spreadArray([],__read(e),!1));return o&&o(r,t)||[]}catch(n){return reportSelfError(n),[]}};function parseUrl(n){var r=getDefaultDocument();if(!r||!n)return{url:n,protocol:"",domain:"",query:"",path:"",hash:""};r=r.createElement("a");r.href=n;n=r.pathname||"/";return"/"!==n[0]&&(n="/"+n),{url:r.href,protocol:r.protocol.slice(0,-1),domain:r.hostname,query:r.search.substring(1),path:n,hash:r.hash}}var getConfig=function(n,r){return isObject(n)?__assign(__assign({},r),n):!!n&&r};function getPluginConfig(n,r,t){r=null===(n=n.config())||void 0===n?void 0:n.plugins[r];return getConfig(r,t)}var getDefaultExtractor=function(t){return function(n){var r;return"hash"===t?(null===(r=parseUrl(n).hash)||void 0===r?void 0:r.replace(/^#/,""))||"/":parseUrl(n).path}},applyOnPidChange=function(e,n,r,o){var i=r,a=n;o&&o(n);return[function(n,r,t){"user_set"!==n&&r!==i?(i=r,a=null!=t?t:i,o&&o(a),e(n,a)):"user_set"===n&&r!==a&&(a=r,o&&o(a),e(n,a))},function(){n&&e("init",n)}]},applyOnUrlChange=function(t,n){var e=n;return[function(n,r){r!==e&&t(n,e=r)}]},PAGEVIEW_EV_TYPE="pageview",PageviewMonitor=function(_,h,v){if(void 0===_&&(_=getDefaultBrowser()),void 0===h&&(h=getDefaultLocation()),void 0===v&&(v=getDefaultHistory()),_&&h)return function(n,t){var r,e,o,i,a,u=n.sendInit,f=n.initPid,c=n.routeMode,l=n.extractPid,n=n.onPidUpdate,s=[],p="manual"===c?function(){return""}:getDefaultExtractor(c),d=l||function(){},l=__read(applyOnPidChange(function(n,r){t&&t({ev_type:PAGEVIEW_EV_TYPE,payload:{pid:r,source:n}})},f||(r=h.href,null!==(e=d(r))&&void 0!==e?e:p(r)),p(h.href),n),2),g=l[0],f=l[1],n=g.bind(null,"user_set");"manual"!==c&&(o=__read(applyOnUrlChange(function(n,r){return g(n,p(r),d(r))},""),1)[0],i=function(){return o("history",h.href)},v&&(l=function(t){return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];try{t.apply(v,n)}finally{i()}}},s.push(hookObjectProperty(v,"pushState",l)(),hookObjectProperty(v,"replaceState",l)())),"hash"===c?(a=function(){return o("hash",h.href)},_.addEventListener("hashchange",a,!0),s.push(function(){return _.removeEventListener("hashchange",a,!0)})):(_.addEventListener("popstate",i,!0),s.push(function(){return _.removeEventListener("popstate",i,!0)})));return u&&f(),[n,function(){s.forEach(function(n){return n()})}]}},PAGEVIEW_MONITOR_PLUGIN_NAME="pageview",defaultConfig={sendInit:!0,routeMode:"history"};function PageviewMonitorPlugin(t){t.on("init",function(){var n,r=getPluginConfig(t,PAGEVIEW_MONITOR_PLUGIN_NAME,defaultConfig);r&&(r=__read(applyMonitor(PageviewMonitor,__assign(__assign({},r),{initPid:null===(r=t.config())||void 0===r?void 0:r.pid,onPidUpdate:function(n){t.set({pid:n,viewId:n+"_"+Date.now(),actionId:void 0})}}),t.report.bind(t)),2),n=r[0],r=r[1],t.on("config",function(){n(t.config().pid)}),t.on("beforeDestroy",r),t.provide("sendPageview",n))})}var pageviewPlugin=function(){return{name:PAGEVIEW_MONITOR_PLUGIN_NAME,setup:function(n){PageviewMonitorPlugin(n)}}};exports.pageviewPlugin=pageviewPlugin;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __assign=function(){return(__assign=Object.assign||function(n){for(var r,t=1,e=arguments.length;t<e;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o]);return n}).apply(this,arguments)};function __read(n,r){var t="function"==typeof Symbol&&n[Symbol.iterator];if(!t)return n;var e,o,i=t.call(n),a=[];try{for(;(void 0===r||0<r--)&&!(e=i.next()).done;)a.push(e.value)}catch(n){o={error:n}}finally{try{e&&!e.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return a}function __spreadArray(n,r,t){if(t||2===arguments.length)for(var e,o=0,i=r.length;o<i;o++)!e&&o in r||((e=e||Array.prototype.slice.call(r,0,o))[o]=r[o]);return n.concat(e||Array.prototype.slice.call(r))}var noop=function(){return{}};function isObject(n){return"object"==typeof n&&null!==n}function isFunction(n){return"function"==typeof n}var hookObjectProperty=function(i,a,u,c){return void 0===c&&(c=!0),function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];if(!i)return noop;var t=i[a],e=u.apply(void 0,__spreadArray([t],__read(n),!1)),o=e;return isFunction(o)&&c&&(o=function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];try{return e.apply(this,r)}catch(n){return isFunction(t)&&t.apply(this,r)}}),i[a]=o,function(n){n||(o===i[a]?i[a]=t:e=t)}}};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}var getGlobalRegistry=function(n){if(n)return n.__SLARDAR_REGISTRY__||(n.__SLARDAR_REGISTRY__={Slardar:{plugins:[],errors:[],subject:{}}}),n.__SLARDAR_REGISTRY__.Slardar},reportSelfError=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var t=getGlobalRegistry(getDefaultBrowser());t&&(t.errors||(t.errors=[]),t.errors.push(n))},applyMonitor=function(n,r,t,e){void 0===r&&(r={}),void 0===e&&(e=[]);try{var o=n.apply(void 0,__spreadArray([],__read(e),!1));return o&&o(r,t)||[]}catch(n){return reportSelfError(n),[]}},now=function(){return Date.now()};function parseUrl(n){var r=getDefaultDocument();if(!r||!n)return{url:n,protocol:"",domain:"",query:"",path:"",hash:""};r=r.createElement("a");r.href=n;n=r.pathname||"/";return"/"!==n[0]&&(n="/"+n),{url:r.href,protocol:r.protocol.slice(0,-1),domain:r.hostname,query:r.search.substring(1),path:n,hash:r.hash}}var getConfig=function(n,r){return isObject(n)?__assign(__assign({},r),n):!!n&&r};function getPluginConfig(n,r,t){r=null===(n=n.config())||void 0===n?void 0:n.plugins[r];return getConfig(r,t)}var HISTORY_SUBJECT_NAME="history_0",HASH_SUBJECT_NAME="hash_0",observeHistory=function(n,r){var t,e,o,i=getDefaultHistory();i&&(e=function(){return n(location.href)},(t=[]).push(hookObjectProperty(i,"pushState",o=function(t){return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];try{t.apply(i,n)}finally{e()}}})(),hookObjectProperty(i,"replaceState",o)()),window.addEventListener("popstate",e,!0),t.push(function(){return window.removeEventListener("popstate",e,!0)}),r(function(){t.forEach(function(n){return n()})}))},observeHash=function(n,r){var t,e=getDefaultBrowser();e&&(e.addEventListener("hashchange",t=function(){return n(location.href)},!0),r(function(){return e.removeEventListener("hashchange",t,!0)}))},hashSubject=[HASH_SUBJECT_NAME,observeHash],historySubject=[HISTORY_SUBJECT_NAME,observeHistory],getDefaultExtractor=function(t){return function(n){var r;return"hash"===t?(null===(r=parseUrl(n).hash)||void 0===r?void 0:r.replace(/^#/,""))||"/":parseUrl(n).path}},applyOnPidChange=function(e,n,r,o){var i=r,a=n;o&&o(n);return[function(n,r,t){"user_set"!==n&&r!==i?(i=r,a=null!=t?t:i,o&&o(a),e(n,a)):"user_set"===n&&r!==a&&(a=r,o&&o(a),e(n,a))},function(){n&&e("init",n)}]},applyOnUrlChange=function(t,n){var e=n;return[function(n,r){r!==e&&t(n,e=r)}]},PAGEVIEW_EV_TYPE="pageview",PageviewMonitor=function(n,d){if(void 0===n&&(n=getDefaultBrowser()),void 0===d&&(d=getDefaultLocation()),n&&d)return function(n,t){var r,e,o,i=n.sendInit,a=n.initPid,u=n.routeMode,c=n.extractPid,f=n.onPidUpdate,n=n.createObserver,s=[],l="manual"===u?function(){return""}:getDefaultExtractor(u),p=c||function(){},a=__read(applyOnPidChange(function(n,r){t&&t({ev_type:PAGEVIEW_EV_TYPE,payload:{pid:r,source:n}})},a||(r=d.href,null!==(e=p(r))&&void 0!==e?e:l(r)),l(d.href),f),2),_=a[0],f=a[1],a=_.bind(null,"user_set");"manual"!==u&&(o=__read(applyOnUrlChange(function(n,r){return _(n,l(r),p(r))},""),1)[0],n=__read(n(u),1)[0],s.push(n(function(n){return o(u,n)})));return i&&f(),[a,function(){s.forEach(function(n){return n()})}]}},PAGEVIEW_MONITOR_PLUGIN_NAME="pageview",defaultConfig={sendInit:!0,routeMode:"history"};function PageviewMonitorPlugin(t){t.on("init",function(){var n,r=getPluginConfig(t,PAGEVIEW_MONITOR_PLUGIN_NAME,defaultConfig);r&&(r=__read(applyMonitor(PageviewMonitor,__assign(__assign({},r),{initPid:null===(r=t.config())||void 0===r?void 0:r.pid,onPidUpdate:function(n){t.set({pid:n,viewId:n+"_"+now(),actionId:void 0})},createObserver:function(n){return t.initSubject("hash"===n?hashSubject:historySubject)}}),t.report.bind(t)),2),n=r[0],r=r[1],t.on("config",function(){n(t.config().pid)}),t.on("beforeDestroy",r),t.provide("sendPageview",n))})}var pageviewPlugin=function(){return{name:PAGEVIEW_MONITOR_PLUGIN_NAME,setup:function(n){PageviewMonitorPlugin(n)}}};exports.pageviewPlugin=pageviewPlugin;

@@ -115,2 +115,7 @@ declare type BatchSender<E> = EventSender<E> & {

declare type ParametersForFn<T extends (args: any) => any> = T extends (args: infer P) => any ? P : never;
declare type SafeObservable<T> = [(f: T) => () => void, (f: T) => void];
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 NextLink<T extends (args: any) => any> = (args: ParametersForFn<T>, cb: T[]) => NextLink<ReturnType<T>>;
declare type WithContext<C extends AnyClient> = C & {

@@ -142,2 +147,7 @@ context?: ContextAgent;

declare type WithSubject<C extends AnyClient> = C & {
initSubject: <T extends (args: any) => any>(args: [subjectKey: string, collector: Observer<T>]) => SafeObservable<T>;
getSubject: (key: string) => SafeObservable<any> | undefined;
};
/** 公共筛选条件 */

@@ -727,6 +737,7 @@ interface FilterCondition {

onPidUpdate?: (pid: string) => void;
createObserver?: (mode: string) => SafeObservable<(args: string) => void>;
}
declare const PAGEVIEW_MONITOR_PLUGIN_NAME = "pageview";
declare type WithSendPageview<C extends WebClient> = C & {
declare type WithSendPageview<C extends WithSubject<WebClient>> = C & {
sendPageview?: SendPageview;

@@ -783,3 +794,5 @@ };

lcp = "lcp",
cls = "cls"
cls = "cls",
longtask = "longtask",
timing = "timing"
}

@@ -792,5 +805,2 @@ interface PerformancePrecollect {

[key in MetricEnum]: boolean;
} & {
timing: boolean;
longtask: boolean;
};

@@ -1011,4 +1021,3 @@

type PrecollectArg = [string, string, PrecollectData, number, string]
type BrowserClient =
WithDetectBlankScreen<
type BrowserClient = WithDetectBlankScreen<
WithBreadcrumb<

@@ -1021,10 +1030,12 @@ WithReportResourceError<

WithContext<
Client<
BrowserReportEvent,
BrowserSendEvent,
BrowserBuilder,
BrowserSender,
BrowserInitConfig,
BrowserUserConfig,
BrowserConfig
WithSubject<
Client<
BrowserReportEvent,
BrowserSendEvent,
BrowserBuilder,
BrowserSender,
BrowserInitConfig,
BrowserUserConfig,
BrowserConfig
>
>

@@ -1031,0 +1042,0 @@ >

@@ -1,1 +0,1 @@

"use strict";function __read(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,a,i=t.call(e),u=[];try{for(;(void 0===r||0<r--)&&!(n=i.next()).done;)u.push(n.value)}catch(e){a={error:e}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(a)throw a.error}}return u}function id(e){return e}function isObject(e){return"object"==typeof e&&null!==e}Object.defineProperty(exports,"__esModule",{value:!0});var objProto=Object.prototype;function isArray(e){return"[object Array]"===objProto.toString.call(e)}function isBoolean(e){return"boolean"==typeof e}function isNumber(e){return"number"==typeof e}function arrayIncludes(e,r){if(!isArray(e))return!1;if(0===e.length)return!1;for(var t=0;t<e.length;){if(e[t]===r)return!0;t++}return!1}var safeVisit=function(e,r,t){for(var n,r=__read(r.split(".")),a=r[0],i=r.slice(1);e&&0<i.length;)e=e[a],a=(n=__read(i))[0],i=n.slice(1);if(e)return t(e,a)},isHitBySampleRate=function(e){return Math.random()<Number(e)},isHitByRandom=function(e,r){return e<Number(r)};function getDefaultBrowser(){if("object"==typeof window&&isObject(window))return window}var getGlobalRegistry=function(e){if(e)return e.__SLARDAR_REGISTRY__||(e.__SLARDAR_REGISTRY__={Slardar:{plugins:[],errors:[]}}),e.__SLARDAR_REGISTRY__.Slardar},reportSelfError=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var t=getGlobalRegistry(getDefaultBrowser());t&&(t.errors||(t.errors=[]),t.errors.push(e))},withSampleRate=function(e,r){var t=e.common||{};return t.sample_rate=r,e.common=t,e},hitFnWithRandom=function(e,r,t,n,a){return e?(i=a(n,r),function(){return i}):function(){return t(r)};var i},parseValues=function(e,r){return e.map(function(e){switch(r){case"number":return Number(e);case"boolean":return"1"===e;default:return String(e)}})},checkVal=function(e,r,t){switch(t){case"eq":return arrayIncludes(r,e);case"neq":return!arrayIncludes(r,e);case"gt":return e>r[0];case"gte":return e>=r[0];case"lt":return e<r[0];case"lte":return e<=r[0];case"regex":return Boolean(e.match(new RegExp(r.join("|"))));case"not_regex":return!e.match(new RegExp(r.join("|")));default:return!1}},checkFilter=function(e,r,t,n){e=safeVisit(e,r,function(e,r){return e[r]});if(void 0===e)return!1;r=isBoolean(e)?"bool":isNumber(e)?"number":"string";return checkVal(e,parseValues(n,r),t)},matchFilter=function(r,e){try{return"rule"===e.type?checkFilter(r,e.field,e.op,e.values):"and"===e.type?e.children.every(function(e){return matchFilter(r,e)}):e.children.some(function(e){return matchFilter(r,e)})}catch(e){return reportSelfError(e),!1}},getHitMap=function(a,i,u,o,l,c){var f={};return Object.keys(a).forEach(function(e){var r=a[e],t=r.enable,n=r.sample_rate,r=r.conditional_sample_rules;t?(f[e]={enable:t,sample_rate:n,effectiveSampleRate:n*u,hit:hitFnWithRandom(i,n,o,l,c)},r&&(f[e].conditional_hit_rules=r.map(function(e){var r=e.sample_rate,e=e.filter;return{sample_rate:r,hit:hitFnWithRandom(i,r,o,l,c),effectiveSampleRate:r*u,filter:e}}))):f[e]={enable:t,hit:function(){return!1},sample_rate:0,effectiveSampleRate:0}}),f},getSampler=function(e,r,t,n){if(!r)return id;var a=r.sample_rate,i=r.include_users,u=r.sample_granularity,o=r.rules,r=r.r,r=void 0===r?Math.random():r;if(arrayIncludes(i,e))return function(e){return withSampleRate(e,1)};var u="session"===u,l=hitFnWithRandom(u,a,t,r,n),c=getHitMap(o,u,a,t,r,n);return function(e){if(!l())return!1;if(!(e.ev_type in c))return withSampleRate(e,a);if(!c[e.ev_type].enable)return!1;if(null!==(r=e.common)&&void 0!==r&&r.sample_rate)return e;var r=c[e.ev_type],t=r.conditional_hit_rules;if(t)for(var n=0;n<t.length;n++)if(matchFilter(e,t[n].filter))return!!t[n].hit()&&withSampleRate(e,t[n].effectiveSampleRate);return!!r.hit()&&withSampleRate(e,r.effectiveSampleRate)}},SamplePlugin=function(t){t.on("start",function(){var e=t.config(),r=e.userId,e=e.sample;e&&0===e.sample_rate&&t.destroy();e=getSampler(r,e,isHitBySampleRate,isHitByRandom);t.on("build",e)})},samplePlugin=function(){return{name:"sample",setup:function(e){SamplePlugin(e)}}};exports.samplePlugin=samplePlugin;
"use strict";function __read(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,a,i=t.call(e),u=[];try{for(;(void 0===r||0<r--)&&!(n=i.next()).done;)u.push(n.value)}catch(e){a={error:e}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(a)throw a.error}}return u}function id(e){return e}function isObject(e){return"object"==typeof e&&null!==e}Object.defineProperty(exports,"__esModule",{value:!0});var objProto=Object.prototype;function isArray(e){return"[object Array]"===objProto.toString.call(e)}function isBoolean(e){return"boolean"==typeof e}function isNumber(e){return"number"==typeof e}function arrayIncludes(e,r){if(!isArray(e))return!1;if(0===e.length)return!1;for(var t=0;t<e.length;){if(e[t]===r)return!0;t++}return!1}var safeVisit=function(e,r,t){for(var n,r=__read(r.split(".")),a=r[0],i=r.slice(1);e&&0<i.length;)e=e[a],a=(n=__read(i))[0],i=n.slice(1);if(e)return t(e,a)},isHitBySampleRate=function(e){return Math.random()<Number(e)},isHitByRandom=function(e,r){return e<Number(r)};function getDefaultBrowser(){if("object"==typeof window&&isObject(window))return window}var 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=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var t=getGlobalRegistry(getDefaultBrowser());t&&(t.errors||(t.errors=[]),t.errors.push(e))},withSampleRate=function(e,r){var t=e.common||{};return t.sample_rate=r,e.common=t,e},hitFnWithRandom=function(e,r,t,n,a){return e?(i=a(n,r),function(){return i}):function(){return t(r)};var i},parseValues=function(e,r){return e.map(function(e){switch(r){case"number":return Number(e);case"boolean":return"1"===e;default:return String(e)}})},checkVal=function(e,r,t){switch(t){case"eq":return arrayIncludes(r,e);case"neq":return!arrayIncludes(r,e);case"gt":return e>r[0];case"gte":return e>=r[0];case"lt":return e<r[0];case"lte":return e<=r[0];case"regex":return Boolean(e.match(new RegExp(r.join("|"))));case"not_regex":return!e.match(new RegExp(r.join("|")));default:return!1}},checkFilter=function(e,r,t,n){e=safeVisit(e,r,function(e,r){return e[r]});if(void 0===e)return!1;r=isBoolean(e)?"bool":isNumber(e)?"number":"string";return checkVal(e,parseValues(n,r),t)},matchFilter=function(r,e){try{return"rule"===e.type?checkFilter(r,e.field,e.op,e.values):"and"===e.type?e.children.every(function(e){return matchFilter(r,e)}):e.children.some(function(e){return matchFilter(r,e)})}catch(e){return reportSelfError(e),!1}},getHitMap=function(a,i,u,o,l,c){var f={};return Object.keys(a).forEach(function(e){var r=a[e],t=r.enable,n=r.sample_rate,r=r.conditional_sample_rules;t?(f[e]={enable:t,sample_rate:n,effectiveSampleRate:n*u,hit:hitFnWithRandom(i,n,o,l,c)},r&&(f[e].conditional_hit_rules=r.map(function(e){var r=e.sample_rate,e=e.filter;return{sample_rate:r,hit:hitFnWithRandom(i,r,o,l,c),effectiveSampleRate:r*u,filter:e}}))):f[e]={enable:t,hit:function(){return!1},sample_rate:0,effectiveSampleRate:0}}),f},getSampler=function(e,r,t,n){if(!r)return id;var a=r.sample_rate,i=r.include_users,u=r.sample_granularity,o=r.rules,r=r.r,r=void 0===r?Math.random():r;if(arrayIncludes(i,e))return function(e){return withSampleRate(e,1)};var u="session"===u,l=hitFnWithRandom(u,a,t,r,n),c=getHitMap(o,u,a,t,r,n);return function(e){if(!l())return!1;if(!(e.ev_type in c))return withSampleRate(e,a);if(!c[e.ev_type].enable)return!1;if(null!==(r=e.common)&&void 0!==r&&r.sample_rate)return e;var r=c[e.ev_type],t=r.conditional_hit_rules;if(t)for(var n=0;n<t.length;n++)if(matchFilter(e,t[n].filter))return!!t[n].hit()&&withSampleRate(e,t[n].effectiveSampleRate);return!!r.hit()&&withSampleRate(e,r.effectiveSampleRate)}},SamplePlugin=function(t){t.on("start",function(){var e=t.config(),r=e.userId,e=e.sample;e&&0===e.sample_rate&&t.destroy();e=getSampler(r,e,isHitBySampleRate,isHitByRandom);t.on("build",e)})},samplePlugin=function(){return{name:"sample",setup:function(e){SamplePlugin(e)}}};exports.samplePlugin=samplePlugin;
{
"name": "@apmplus/integrations",
"version": "1.2.2",
"version": "2.0.0",
"description": "APMPlus Integrations",

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

},
"gitHead": "8938b234fc2048cd7dbd3a59397c0609ca679921"
"gitHead": "b45290513b3eb50b24f3c67b8425edfe175c50f6"
}
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