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

@apmplus/integrations

Package Overview
Dependencies
Maintainers
2
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@apmplus/integrations - npm Package Compare versions

Comparing version 2.1.3-alpha.1 to 2.1.3-alpha.2

2

dist/pageview.js

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __assign=function(){return(__assign=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function __read(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||0<t--)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function __spreadArray(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||((r=r||Array.prototype.slice.call(t,0,o))[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}var noop=function(){return{}};function isObject(e){return"object"==typeof e&&null!==e}var objProto=Object.prototype;function isArray(e){return"[object Array]"===objProto.toString.call(e)}function isFunction(e){return"function"==typeof e}var arrayRemove=function(e,t){if(!isArray(e))return e;var n=e.indexOf(t);if(0<=n){t=e.slice();return t.splice(n,1),t}return e},hookObjectProperty=function(i,a,u,c){return void 0===c&&(c=!0),function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(!i)return noop;var n=i[a],r=u.apply(void 0,__spreadArray([n],__read(e),!1)),o=r;return isFunction(o)&&c&&(o=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{return r.apply(this,t)}catch(e){return isFunction(n)&&n.apply(this,t)}}),i[a]=o,function(e){e||(o===i[a]?i[a]=n:r=n)}}},BUFFER_TIME=3e5,applyBufferTimer=function(e,t,n){var r=0;return-1===n?noop:function(){if(e())return r&&clearTimeout(r),void(r=0);0===r&&(r=setTimeout(t,n))}},nextLink=function(r,e){var t=[];try{t=e.reduce(function(e,t){try{var n=t(r);"function"==typeof n&&e.push(n)}catch(e){}return e},[])}catch(e){}return function(e){return nextLink(e,t)}},toObservable=function(e){function t(e){r=arrayRemove(r,e),i||a()}var n,r=[],o=[],i=!1,a=applyBufferTimer(function(){return!!r.length},function(){i=!0,n&&n[0](),o.forEach(function(e){return e()}),o.length=0,n=void 0},e=void 0===e?BUFFER_TIME:e);return{next:function(e){return nextLink(e,r)},complete:function(e){o.push(e)},attach:function(e,t){n=[e,t]},subscribe:function(e){if(i)throw new Error("Observer is closed");return r.push(e),n&&n[1]&&n[1](e),a(),function(){return t(e)}},unsubscribe:t}},createSafeObserver=function(e,t,n){n=toObservable(n);try{e(n.next,n.attach),t&&n.complete(t)}catch(e){}return[n.subscribe,n.unsubscribe]},registerTearDownGroup=function(e,t,n,r){return e.destroyAgent.set(t,n,r)};function initSubjectInGlobal(e,t){return e.initSubject(t)}function initPrivateSubject(e,t,n){var t=__read(t,2),r=t[0],t=t[1],o=e.privateSubject||{};return o[r]||(o[r]=createSafeObserver(t,function(){o[r]=void 0},n)),o[r]}var now=function(){return Date.now()};function getDefaultBrowser(){if("object"==typeof window&&isObject(window))return window}function getDefaultDocument(){if("object"==typeof document&&isObject(document))return document}function getDefaultLocation(){return getDefaultBrowser()&&window.location}function getDefaultHistory(){return getDefaultBrowser()&&window.history}function parseUrl(e){var t=getDefaultDocument();if(!t||!e)return{url:e,protocol:"",domain:"",query:"",path:"",hash:""};t=t.createElement("a");t.href=e;e=t.pathname||"/";return"/"!==e[0]&&(e="/"+e),{url:t.href,protocol:t.protocol.slice(0,-1),domain:t.hostname,query:t.search.substring(1),path:e,hash:t.hash}}function getLocationUrl(){var e=getDefaultBrowser()&&getDefaultLocation();return null==e?void 0:e.href}var getViewOverrides=function(e){return{pid:e.pid,view_id:e.viewId,url:getLocationUrl()}},getOverrides=function(e){var t=e.config(),t=getViewOverrides(t);return t.context=e.context?e.context.toString():{},t},FIRST_PV_SUBJECT_NAME="f_view_0",applyFirstPV=function(r){return function(e,t){var n=getOverrides(r);t(noop,function(e){n&&e(n)})}},invokeCallbackOnce=function(t){var n=!1;return[function(e){n||(n=!0,t&&t(e))}]},getConfig=function(e,t){return isObject(e)?__assign(__assign({},t),e):!!e&&t},PAGEVIEW_EV_TYPE="pageview",SESSION_EV_TYPE="session",JS_ERROR_EV_TYPE="js_error",HTTP_EV_TYPE="http",RESOURCE_ERROR_EV_TYPE="resource_error",RESOURCE_EV_TYPE="resource",PERFORMANCE_METRIC_EV_TYPE="performance",LONG_TASK_EV_TYPE="performance_longtask",BLANK_SCREEN_EV_TYPE="blank_screen",ACTION_EV_TYPE="action";function getPluginConfig(e,t,n){t=null===(e=e.config())||void 0===e?void 0:e.plugins[t];return getConfig(t,n)}var HIDDEN_SUBJECT_NAME="hidden_2",visibilityStateIsHidden=function(e){return"hidden"===e.visibilityState},observeHidden=function(e,t){var n,r=getDefaultBrowser(),o=getDefaultDocument();r&&o&&(n=function(){e(visibilityStateIsHidden(o))},addEventListener("visibilitychange",n,!0),t(function(){removeEventListener("visibilitychange",n,!0)},function(e){e(visibilityStateIsHidden(o))}))},hiddenSubject=[HIDDEN_SUBJECT_NAME,observeHidden],readyStateIsComplete=function(e){return"complete"===e.readyState},UNLOAD_SUBJECT_NAME="unload_0",observeUnload=function(e,t){var n,r,o,i=getDefaultBrowser();i&&(n=__read(invokeCallbackOnce(e),1)[0],o=function(){n()},(r=["unload","beforeunload","pagehide"]).forEach(function(e){i.addEventListener(e,o)}),t(function(){r.forEach(function(e){i.removeEventListener(e,o)})}))},unloadSubject=[UNLOAD_SUBJECT_NAME,observeUnload],HISTORY_SUBJECT_NAME="history_0",HASH_SUBJECT_NAME="hash_0",observeHistory=function(e,t){var n,r,o,i=getDefaultHistory();i&&(r=function(){return e(location.href)},(n=[]).push(hookObjectProperty(i,"pushState",o=function(n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{n.apply(i,e)}finally{r()}}})(),hookObjectProperty(i,"replaceState",o)()),window.addEventListener("popstate",r,!0),n.push(function(){return window.removeEventListener("popstate",r,!0)}),t(function(){n.forEach(function(e){return e()})}))},observeHash=function(e,t){var n,r=getDefaultBrowser();r&&(r.addEventListener("hashchange",n=function(){return e(location.href)},!0),t(function(){return r.removeEventListener("hashchange",n,!0)}))},hashSubject=[HASH_SUBJECT_NAME,observeHash],historySubject=[HISTORY_SUBJECT_NAME,observeHistory],getDefaultExtractor=function(n){return function(e){var t;return"hash"===n?(null===(t=parseUrl(e).hash)||void 0===t?void 0:t.replace(/^#/,""))||"/":parseUrl(e).path}},getViewId=function(e){return joinWithSeparator(e,now())},joinWithSeparator=function(e,t){return e+"_"+t},applyOnPidChange=function(r,e,t,o){var i=t,a=e;o&&o(e);return[function(e,t,n){"user_set"!==e&&t!==i?(i=t,a=null!=n?n:i,o&&o(a),r(e,a)):"user_set"===e&&t!==a&&(a=t,o&&o(a),r(e,a))},function(){e&&r("init",e)}]},applyOnUrlChange=function(n,e){var r=e;return[function(e,t){t!==r&&n(e,r=t)}]},wrapPageview=function(e,t){return{ev_type:PAGEVIEW_EV_TYPE,payload:{pid:t,source:e}}},applyReportPageview=function(n){return function(e,t){n(wrapPageview(e,t))}},isManualMode=function(e){return"manual"===e},ERROR_WEIGHT="error_weight",DURATION_APDEX="duration_apdex",PREF_APDEX="perf_apdex",ACTION_KEY="action",getDefaultApdexDetail=function(){var e={error_count:[0,0,0,0],duration_count:[0,0,0]};return e[PREF_APDEX]={},e},getRank=function(e,t){var n=e[0]+e[1]+e[2],r=e[0]/n;return e[2]/n>t.frustrating_threshold?2:r>t.satisfying_threshold||0===n?0:1},calculateSpentTime=function(){var t=0,n=void 0;return[function(e){e?n&&(t+=now()-n,n=void 0):n=now()},function(){n&&(t+=now()-n);var e=t;return t=0,n=now(),e}]},applyCalculateWight=function(o,i){return function(e,t){var n=e.payload;switch(e.ev_type){case PERFORMANCE_METRIC_EV_TYPE:var r=n.name;n.isSupport&&o(t[PREF_APDEX],r,n.value);break;case ACTION_EV_TYPE:o(t[PREF_APDEX],ACTION_KEY,n.duration||0);break;case JS_ERROR_EV_TYPE:i(t[ERROR_WEIGHT],0);break;case HTTP_EV_TYPE:n.response.is_custom_error||400<=n.response.status?i(t[ERROR_WEIGHT],1):(r=n.response.timing)&&o(t[DURATION_APDEX],0,r.duration);break;case RESOURCE_ERROR_EV_TYPE:i(t[ERROR_WEIGHT],2);break;case BLANK_SCREEN_EV_TYPE:i(t[ERROR_WEIGHT],3);break;case RESOURCE_EV_TYPE:o(t[DURATION_APDEX],1,n.duration);break;case LONG_TASK_EV_TYPE:n.longtasks.forEach(function(e){o(t[DURATION_APDEX],2,e.duration)})}}},calculateApdex=function(){function e(){o=[0,0,0],i=getDefaultApdexDetail()}var o,i;e();return[function(e,t,n){var r=e&&e[t];!r||n<=0||(e=n<(r[0].threshold||0)?0:n>(r[1].threshold||0)?2:1,o[e]+=r[e].weight,"string"==typeof t?(n=joinWithSeparator(t,e),r=i[PREF_APDEX][n],i[PREF_APDEX][n]=(r||0)+1):2==e&&(i.duration_count[t]+=1))},function(e,t){e&&(o[2]+=e[t],i.error_count[t]+=1)},function(){return[o,i]},e]},calculateSession=function(){var o={start:now(),end:0,time_spent:0,is_bounced:!1,entry:"",exit:"",p_count:0,a_count:0};return[function(e,t){var n=__read(e,3),r=n[0],e=n[1],n=n[2];o.end=now(),o.time_spent+=t&&t.time_spent||0,o.last_page=t,o.p_count+=1,o.rank=r,o.apdex=e,o.apdex_detail=n;n=getDefaultDocument();n&&(o.is_bounced=!readyStateIsComplete(n))},function(e,t){o.time_spent+=e.time_spent,o.p_count+=1,o.exit=t},function(){o.a_count+=1},function(e){o.entry=e,o.exit=e},function(){return o}]},pvGetterWithRouteObserver=function(e,t,n,r){var o,i,a,u=r.sendInit,c=r.initPid,f=r.routeMode,s=r.extractPid,r=r.onPidUpdate,_=isManualMode(f)?function(){return""}:getDefaultExtractor(f),l=s||function(){},r=__read(applyOnPidChange(applyReportPageview(e),c||(o=location.href,null!==(i=l(o))&&void 0!==i?i:_(o)),_(location.href),r),2),d=r[0],r=r[1];return isManualMode(f)||(a=__read(applyOnUrlChange(function(e,t){return d(e,_(t),l(t))},""),1)[0],n.length&&n.forEach(function(e){return t.push(e[0](function(e){return a(f,e)}))})),u&&r(),[d.bind(null,"user_set")]},apdexGetterWithHiddenObserver=function(r,t,e,n){var o=__read(e,2),i=o[0],a=o[1],u=2===n.apdex,c=void 0,f=void 0,s=void 0,_=!1,l=__read(calculateApdex(),4),d=l[0],E=l[1],p=l[2],v=l[3],e=__read(calculateApdex(),4),o=e[0],n=e[1],h=e[2],g=e[3],l=__read(calculateSession(),5),P=l[0],b=l[1],y=l[2],T=l[3],O=l[4],e=__read(calculateSpentTime(),2),l=e[0],A=e[1];t.push(i[0](l)),u||t.push(a[0](function(){var e,t,n;_&&(e=(n=__read(h(),2))[0],t=n[1],n=getRank(e,s),P([n,e,t],I()),r({ev_type:SESSION_EV_TYPE,payload:O()}),g())}));var R=applyCalculateWight(d,E),S=applyCalculateWight(o,n),I=function(){var e=__read(p(),2),t=e[0],e=e[1];return{start:c[0],pid:c[1],view_id:c[2],end:now(),time_spent:A(),apdex:t,rank:getRank(t,s),detail:e}};return[function(e,t){if(!c)return c=[now(),e,t],T(e),void(_=!(!s||!c));_&&(f=I(),b(f,e)),c=[now(),e,t],v()},function(e){_&&(R(e,s),u||(S(e,s),e.ev_type===ACTION_EV_TYPE&&y()))},function(e){e.payload.last=f,r(e)},function(e){if(!e)return t.forEach(function(e){return e()}),void(t.length=0);_=!(!(s=e)||!c)}]},PAGEVIEW_MONITOR_PLUGIN_NAME="pageview",defaultConfig={sendInit:!0,routeMode:"history",apdex:2};function PageviewMonitorPlugin(l){l.on("init",function(){var e,t,n,r,o,i,a,u,c,f,s,_=getPluginConfig(l,PAGEVIEW_MONITOR_PLUGIN_NAME,defaultConfig);_&&location&&(e=_.routeMode,i=_.apdex,c=l.report.bind(l),u=noop,i&&(t=[],r=(n=__read(apdexGetterWithHiddenObserver(l.report.bind(l),t,[initSubjectInGlobal(l,hiddenSubject),initSubjectInGlobal(l,unloadSubject)],_),4))[0],o=n[1],i=n[2],a=n[3],c=i,u=r,l.on("send",o),t.push(function(){return l.off("send",o)}),l.on("start",function(){a(l.config().apdex)}),registerTearDownGroup(l,PAGEVIEW_MONITOR_PLUGIN_NAME,SESSION_EV_TYPE,t)),f=__read(pvGetterWithRouteObserver(c,c=[],isManualMode(e)?[]:[l.initSubject(hashSubject),l.initSubject(historySubject)],__assign(__assign({},_),{initPid:null===(_=l.config())||void 0===_?void 0:_.pid,onPidUpdate:function(e){var t=getViewId(e);u(e,t),l.set({pid:e,viewId:t,actionId:void 0})}})),1)[0],initPrivateSubject(l,[FIRST_PV_SUBJECT_NAME,applyFirstPV(l)],-1),s=function(){f(l.config().pid)},l.on("config",s),c.push(function(){return l.off("config",s)}),registerTearDownGroup(l,PAGEVIEW_MONITOR_PLUGIN_NAME,PAGEVIEW_EV_TYPE,c),l.provide("sendPageview",f))})}var PAGEVIEW_INTEGRATION_NAME=PAGEVIEW_MONITOR_PLUGIN_NAME,pageviewPlugin=function(){return{name:PAGEVIEW_INTEGRATION_NAME,setup:function(e){PageviewMonitorPlugin(e)}}};exports.PAGEVIEW_INTEGRATION_NAME=PAGEVIEW_INTEGRATION_NAME,exports.pageviewPlugin=pageviewPlugin;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __assign=function(){return(__assign=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function __read(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||0<t--)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function __spreadArray(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||((r=r||Array.prototype.slice.call(t,0,o))[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}var noop=function(){return{}};function isObject(e){return"object"==typeof e&&null!==e}var objProto=Object.prototype;function isArray(e){return"[object Array]"===objProto.toString.call(e)}function isFunction(e){return"function"==typeof e}var arrayRemove=function(e,t){if(!isArray(e))return e;var n=e.indexOf(t);if(0<=n){t=e.slice();return t.splice(n,1),t}return e},hookObjectProperty=function(i,a,u,c){return void 0===c&&(c=!0),function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(!i)return noop;var n=i[a],r=u.apply(void 0,__spreadArray([n],__read(e),!1)),o=r;return isFunction(o)&&c&&(o=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{return r.apply(this,t)}catch(e){return isFunction(n)&&n.apply(this,t)}}),i[a]=o,function(e){e||(o===i[a]?i[a]=n:r=n)}}},BUFFER_TIME=3e5,applyBufferTimer=function(e,t,n){var r=0;return-1===n?noop:function(){if(e())return r&&clearTimeout(r),void(r=0);0===r&&(r=setTimeout(t,n))}},nextLink=function(r,e){var t=[];try{t=e.reduce(function(e,t){try{var n=t(r);"function"==typeof n&&e.push(n)}catch(e){}return e},[])}catch(e){}return function(e){return nextLink(e,t)}},toObservable=function(e){function t(e){r=arrayRemove(r,e),i||a()}var n,r=[],o=[],i=!1,a=applyBufferTimer(function(){return!!r.length},function(){i=!0,n&&n[0](),o.forEach(function(e){return e()}),o.length=0,n=void 0},e=void 0===e?BUFFER_TIME:e);return{next:function(e){return nextLink(e,r)},complete:function(e){o.push(e)},attach:function(e,t){n=[e,t]},subscribe:function(e){if(i)throw new Error("Observer is closed");return r.push(e),n&&n[1]&&n[1](e),a(),function(){return t(e)}},unsubscribe:t}},createSafeObserver=function(e,t,n){n=toObservable(n);try{e(n.next,n.attach),t&&n.complete(t)}catch(e){}return[n.subscribe,n.unsubscribe]},registerTearDownGroup=function(e,t,n,r){return e.destroyAgent.set(t,n,r)};function initSubjectInGlobal(e,t){return e.initSubject(t)}function initPrivateSubject(e,t,n){var t=__read(t,2),r=t[0],t=t[1],o=e.privateSubject||{};return o[r]||(o[r]=createSafeObserver(t,function(){o[r]=void 0},n)),o[r]}var now=function(){return Date.now()};function getDefaultBrowser(){if("object"==typeof window&&isObject(window))return window}function getDefaultDocument(){if("object"==typeof document&&isObject(document))return document}function getDefaultLocation(){return getDefaultBrowser()&&window.location}function getDefaultHistory(){return getDefaultBrowser()&&window.history}function parseUrl(e){var t=getDefaultDocument();if(!t||!e)return{url:e,protocol:"",domain:"",query:"",path:"",hash:""};t=t.createElement("a");t.href=e;e=t.pathname||"/";return"/"!==e[0]&&(e="/"+e),{url:t.href,protocol:t.protocol.slice(0,-1),domain:t.hostname,query:t.search.substring(1),path:e,hash:t.hash}}function getLocationUrl(){var e=getDefaultBrowser()&&getDefaultLocation();return null==e?void 0:e.href}var getViewOverrides=function(e){return{pid:e.pid,view_id:e.viewId,url:getLocationUrl()}},getOverrides=function(e){var t=e.config(),t=getViewOverrides(t);return t.context=e.context?e.context.toString():{},t},FIRST_PV_SUBJECT_NAME="f_view_0",applyFirstPV=function(r){return function(e,t){var n=getOverrides(r);t(noop,function(e){n&&e(n)})}},invokeCallbackOnce=function(t){var n=!1;return[function(e){n||(n=!0,t&&t(e))}]},getConfig=function(e,t){return isObject(e)?__assign(__assign({},t),e):!!e&&t},PAGEVIEW_EV_TYPE="pageview",SESSION_EV_TYPE="session",JS_ERROR_EV_TYPE="js_error",HTTP_EV_TYPE="http",RESOURCE_ERROR_EV_TYPE="resource_error",RESOURCE_EV_TYPE="resource",PERFORMANCE_METRIC_EV_TYPE="performance",LONG_TASK_EV_TYPE="performance_longtask",BLANK_SCREEN_EV_TYPE="blank_screen",ACTION_EV_TYPE="action";function getPluginConfig(e,t,n){t=null===(e=e.config())||void 0===e?void 0:e.plugins[t];return getConfig(t,n)}var HIDDEN_SUBJECT_NAME="hidden_2",visibilityStateIsHidden=function(e){return"hidden"===e.visibilityState},observeHidden=function(e,t){var n,r=getDefaultBrowser(),o=getDefaultDocument();r&&o&&(n=function(){e(visibilityStateIsHidden(o))},addEventListener("visibilitychange",n,!0),t(function(){removeEventListener("visibilitychange",n,!0)},function(e){e(visibilityStateIsHidden(o))}))},hiddenSubject=[HIDDEN_SUBJECT_NAME,observeHidden],readyStateIsComplete=function(e){return"complete"===e.readyState},UNLOAD_SUBJECT_NAME="unload_0",observeUnload=function(e,t){var n,r,o,i=getDefaultBrowser();i&&(n=__read(invokeCallbackOnce(e),1)[0],o=function(){n()},(r=["unload","beforeunload","pagehide"]).forEach(function(e){i.addEventListener(e,o)}),t(function(){r.forEach(function(e){i.removeEventListener(e,o)})}))},unloadSubject=[UNLOAD_SUBJECT_NAME,observeUnload],HISTORY_SUBJECT_NAME="history_0",HASH_SUBJECT_NAME="hash_0",observeHistory=function(e,t){var n,r,o,i=getDefaultHistory();i&&(r=function(){return e(location.href)},(n=[]).push(hookObjectProperty(i,"pushState",o=function(n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{n.apply(i,e)}finally{r()}}})(),hookObjectProperty(i,"replaceState",o)()),window.addEventListener("popstate",r,!0),n.push(function(){return window.removeEventListener("popstate",r,!0)}),t(function(){n.forEach(function(e){return e()})}))},observeHash=function(e,t){var n,r=getDefaultBrowser();r&&(r.addEventListener("hashchange",n=function(){return e(location.href)},!0),t(function(){return r.removeEventListener("hashchange",n,!0)}))},hashSubject=[HASH_SUBJECT_NAME,observeHash],historySubject=[HISTORY_SUBJECT_NAME,observeHistory],getDefaultExtractor=function(n){return function(e){var t;return"hash"===n?(null===(t=parseUrl(e).hash)||void 0===t?void 0:t.replace(/^#/,""))||"/":parseUrl(e).path}},getViewId=function(e){return joinWithSeparator(e,now())},joinWithSeparator=function(e,t){return e+"_"+t},applyOnPidChange=function(r,e,t,o){var i=t,a=e;o&&o(e);return[function(e,t,n){"user_set"!==e&&t!==i?(i=t,a=null!=n?n:i,o&&o(a),r(e,a)):"user_set"===e&&t!==a&&(a=t,o&&o(a),r(e,a))},function(){e&&r("init",e)}]},applyOnUrlChange=function(n,e){var r=e;return[function(e,t){t!==r&&n(e,r=t)}]},wrapPageview=function(e,t){return{ev_type:PAGEVIEW_EV_TYPE,payload:{pid:t,source:e}}},applyReportPageview=function(n){return function(e,t){n(wrapPageview(e,t))}},isManualMode=function(e){return"manual"===e},ERROR_WEIGHT="error_weight",DURATION_APDEX="duration_apdex",PREF_APDEX="perf_apdex",ACTION_KEY="action",getDefaultApdexDetail=function(){var e={error_count:[0,0,0,0],duration_count:[0,0,0]};return e[PREF_APDEX]={},e},getRank=function(e,t){var n=e[0]+e[1]+e[2],r=e[0]/n;return e[2]/n>t.frustrating_threshold?2:r>t.satisfying_threshold||0===n?0:1},calculateSpentTime=function(){var t=0,n=void 0;return[function(e){e?n&&(t+=now()-n,n=void 0):n=now()},function(){n&&(t+=now()-n);var e=t;return t=0,n=now(),e}]},applyCalculateWight=function(o,i){return function(e,t){var n=e.payload;switch(e.ev_type){case PERFORMANCE_METRIC_EV_TYPE:var r=n.name;n.isSupport&&o(t[PREF_APDEX],r,n.value);break;case ACTION_EV_TYPE:o(t[PREF_APDEX],ACTION_KEY,n.duration||0);break;case JS_ERROR_EV_TYPE:i(t[ERROR_WEIGHT],0);break;case HTTP_EV_TYPE:n.response.is_custom_error||400<=n.response.status?i(t[ERROR_WEIGHT],1):(r=n.response.timing)&&o(t[DURATION_APDEX],0,r.duration);break;case RESOURCE_ERROR_EV_TYPE:i(t[ERROR_WEIGHT],2);break;case BLANK_SCREEN_EV_TYPE:i(t[ERROR_WEIGHT],3);break;case RESOURCE_EV_TYPE:o(t[DURATION_APDEX],1,n.duration);break;case LONG_TASK_EV_TYPE:n.longtasks.forEach(function(e){o(t[DURATION_APDEX],2,e.duration)})}}},calculateApdex=function(){function e(){o=[0,0,0],i=getDefaultApdexDetail()}var o,i;e();return[function(e,t,n){var r=e&&e[t];!r||n<=0||(e=n<(r[0].threshold||0)?0:n>(r[1].threshold||0)?2:1,o[e]+=r[e].weight,"string"==typeof t?(n=joinWithSeparator(t,e),r=i[PREF_APDEX][n],i[PREF_APDEX][n]=(r||0)+1):2==e&&(i.duration_count[t]+=1))},function(e,t){e&&(o[2]+=e[t],i.error_count[t]+=1)},function(){return[o,i]},e]},calculateSession=function(){var o={start:now(),end:0,time_spent:0,is_bounced:!1,entry:"",exit:"",p_count:0,a_count:0};return[function(e,t){var n=__read(e,3),r=n[0],e=n[1],n=n[2];o.end=now(),o.time_spent+=t&&t.time_spent||0,o.last_page=t,o.p_count+=1,o.rank=r,o.apdex=e,o.apdex_detail=n;n=getDefaultDocument();n&&(o.is_bounced=!readyStateIsComplete(n))},function(e,t){o.time_spent+=e.time_spent,o.p_count+=1,o.exit=t},function(){o.a_count+=1},function(e){o.entry=e,o.exit=e},function(){return o}]},pvGetterWithRouteObserver=function(e,t,n,r){var o,i,a,u=r.sendInit,c=r.initPid,f=r.routeMode,s=r.extractPid,r=r.onPidUpdate,_=isManualMode(f)?function(){return""}:getDefaultExtractor(f),l=s||function(){},r=__read(applyOnPidChange(applyReportPageview(e),c||(o=location.href,null!==(i=l(o))&&void 0!==i?i:_(o)),_(location.href),r),2),d=r[0],r=r[1];return isManualMode(f)||(a=__read(applyOnUrlChange(function(e,t){return d(e,_(t),l(t))},""),1)[0],n.length&&n.forEach(function(e){return t.push(e[0](function(e){return a(f,e)}))})),u&&r(),[d.bind(null,"user_set")]},apdexGetterWithHiddenObserver=function(r,t,e,n){var o=__read(e,2),i=o[0],a=o[1],u=2===n.apdex,c=void 0,f=void 0,s=void 0,_=!1,l=__read(calculateApdex(),4),d=l[0],E=l[1],p=l[2],v=l[3],e=__read(calculateApdex(),4),o=e[0],n=e[1],h=e[2],g=e[3],l=__read(calculateSession(),5),P=l[0],b=l[1],y=l[2],T=l[3],O=l[4],e=__read(calculateSpentTime(),2),l=e[0],A=e[1];t.push(i[0](l)),u||t.push(a[0](function(){var e,t,n;_&&(e=(n=__read(h(),2))[0],t=n[1],n=getRank(e,s),P([n,e,t],I()),r({ev_type:SESSION_EV_TYPE,payload:O()}),g())}));var R=applyCalculateWight(d,E),S=applyCalculateWight(o,n),I=function(){var e=__read(p(),2),t=e[0],e=e[1];return{start:c[0],pid:c[1],view_id:c[2],end:now(),time_spent:A(),apdex:t,rank:getRank(t,s),detail:e}};return t.push(function(){_=!1}),[function(e,t){if(!c)return c=[now(),e,t],T(e),void(_=!(!s||!c));_&&(f=I(),b(f,e)),c=[now(),e,t],v()},function(e){_&&(R(e,s),u||(S(e,s),e.ev_type===ACTION_EV_TYPE&&y()))},function(e){_&&(e.payload.last=f),r(e)},function(e){if(!e)return t.forEach(function(e){return e()}),void(t.length=0);_=!(!(s=e)||!c)}]},PAGEVIEW_MONITOR_PLUGIN_NAME="pageview",defaultConfig={sendInit:!0,routeMode:"history",apdex:2};function PageviewMonitorPlugin(l){l.on("init",function(){var e,t,n,r,o,i,a,u,c,f,s,_=getPluginConfig(l,PAGEVIEW_MONITOR_PLUGIN_NAME,defaultConfig);_&&location&&(e=_.routeMode,i=_.apdex,c=l.report.bind(l),u=noop,i&&(t=[],r=(n=__read(apdexGetterWithHiddenObserver(l.report.bind(l),t,[initSubjectInGlobal(l,hiddenSubject),initSubjectInGlobal(l,unloadSubject)],_),4))[0],o=n[1],i=n[2],a=n[3],c=i,u=r,l.on("send",o),t.push(function(){return l.off("send",o)}),l.on("start",function(){a(l.config().apdex)}),registerTearDownGroup(l,PAGEVIEW_MONITOR_PLUGIN_NAME,SESSION_EV_TYPE,t)),f=__read(pvGetterWithRouteObserver(c,c=[],isManualMode(e)?[]:[l.initSubject(hashSubject),l.initSubject(historySubject)],__assign(__assign({},_),{initPid:null===(_=l.config())||void 0===_?void 0:_.pid,onPidUpdate:function(e){var t=getViewId(e);u(e,t),l.set({pid:e,viewId:t,actionId:void 0})}})),1)[0],initPrivateSubject(l,[FIRST_PV_SUBJECT_NAME,applyFirstPV(l)],-1),s=function(){f(l.config().pid)},l.on("config",s),c.push(function(){return l.off("config",s)}),registerTearDownGroup(l,PAGEVIEW_MONITOR_PLUGIN_NAME,PAGEVIEW_EV_TYPE,c),l.provide("sendPageview",f))})}var PAGEVIEW_INTEGRATION_NAME=PAGEVIEW_MONITOR_PLUGIN_NAME,pageviewPlugin=function(){return{name:PAGEVIEW_INTEGRATION_NAME,setup:function(e){PageviewMonitorPlugin(e)}}};exports.PAGEVIEW_INTEGRATION_NAME=PAGEVIEW_INTEGRATION_NAME,exports.pageviewPlugin=pageviewPlugin;
{
"name": "@apmplus/integrations",
"version": "2.1.3-alpha.1",
"version": "2.1.3-alpha.2",
"description": "APMPlus Integrations",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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