@grafana/faro-core
Advanced tools
Comparing version 1.3.8 to 1.3.9
@@ -1,1 +0,1 @@ | ||
var GrafanaFaroCore=function(e){"use strict";function n(e,n){return typeof e===n}function t(e,n){return Object.prototype.toString.call(e)===`[object ${n}]`}function r(e,n){try{return e instanceof n}catch(e){return!1}}const i=e=>n(e,"null"),o=e=>n(e,"string"),a=e=>n(e,"number")&&!isNaN(e)||n(e,"bigint"),s=e=>!i(e)&&n(e,"object"),l=e=>n(e,"function"),u=e=>t(e,"Array"),c="undefined"!=typeof Event,g="undefined"!=typeof Error,d="undefined"!=typeof Element,p="undefined"!=typeof Map;function f(e,t){if(e===t)return!0;if(n(e,"number")&&isNaN(e))return n(t,"number")&&isNaN(t);const r=u(e),i=u(t);if(r!==i)return!1;if(r&&i){const n=e.length;if(n!==t.length)return!1;for(let r=n;0!=r--;)if(!f(e[r],t[r]))return!1;return!0}const o=s(e),a=s(t);if(o!==a)return!1;if(e&&t&&o&&a){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;for(let r of n)if(!f(e[r],t[r]))return!1;return!0}return!1}function m(){return(new Date).toISOString()}var v;e.LogLevel=void 0,(v=e.LogLevel||(e.LogLevel={})).TRACE="trace",v.DEBUG="debug",v.INFO="info",v.LOG="log",v.WARN="warn",v.ERROR="error";const h=e.LogLevel.LOG,b=[e.LogLevel.TRACE,e.LogLevel.DEBUG,e.LogLevel.INFO,e.LogLevel.LOG,e.LogLevel.WARN,e.LogLevel.ERROR];function E(){}const y="abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789";class T{constructor(e,n){var t,r;this.signalBuffer=[],this.itemLimit=null!==(t=null==n?void 0:n.itemLimit)&&void 0!==t?t:50,this.sendTimeout=null!==(r=null==n?void 0:n.sendTimeout)&&void 0!==r?r:250,this.paused=(null==n?void 0:n.paused)||!1,this.sendFn=e,this.flushInterval=-1,this.paused||this.start(),document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&this.flush()}))}addItem(e){this.paused||(this.signalBuffer.push(e),this.signalBuffer.length>=this.itemLimit&&this.flush())}start(){this.paused=!1,this.sendTimeout>0&&(this.flushInterval=window.setInterval((()=>this.flush()),this.sendTimeout))}pause(){this.paused=!0,clearInterval(this.flushInterval)}groupItems(e){const n=new Map;return e.forEach((e=>{const t=JSON.stringify(e.meta);let r=n.get(t);r=void 0===r?[e]:[...r,e],n.set(t,r)})),Array.from(n.values())}flush(){if(this.paused||0===this.signalBuffer.length)return;this.groupItems(this.signalBuffer).forEach(this.sendFn),this.signalBuffer=[]}}var I;e.TransportItemType=void 0,(I=e.TransportItemType||(e.TransportItemType={})).EXCEPTION="exception",I.LOG="log",I.MEASUREMENT="measurement",I.TRACE="trace",I.EVENT="event";const O={[e.TransportItemType.EXCEPTION]:"exceptions",[e.TransportItemType.LOG]:"logs",[e.TransportItemType.MEASUREMENT]:"measurements",[e.TransportItemType.TRACE]:"traces",[e.TransportItemType.EVENT]:"events"};function L(n){return t=>{if(t.type===e.TransportItemType.EXCEPTION&&t.payload){const e=t.payload,r=`${e.type}: ${e.value}`;if(function(e,n){return e.some((e=>o(e)?n.includes(e):!!n.match(e)))}(n,r))return null}return t}}function S(e,n,t,r){var i;n.debug("Initializing transports");const o=[];let a=t.paused,s=[];const l=e=>{let n=e;for(const e of s){const t=n.map(e).filter(Boolean);if(0===t.length)return[];n=t}return n},u=e=>{const t=l(e);if(0!==t.length)for(const e of o)n.debug(`Transporting item using ${e.name}\n`,t),e.isBatched()&&e.send(t)};let c;(null===(i=t.batching)||void 0===i?void 0:i.enabled)&&(c=new T(u,{sendTimeout:t.batching.sendTimeout,itemLimit:t.batching.itemLimit,paused:a}));return{add:(...i)=>{n.debug("Adding transports"),i.forEach((i=>{n.debug(`Adding "${i.name}" transport`);o.some((e=>e===i))?n.warn(`Transport ${i.name} is already added`):(i.unpatchedConsole=e,i.internalLogger=n,i.config=t,i.metas=r,o.push(i))}))},addBeforeSendHooks:(...e)=>{n.debug("Adding beforeSendHooks\n",s),e.forEach((e=>{e&&s.push(e)}))},addIgnoreErrorsPatterns:(...e)=>{n.debug("Adding ignoreErrorsPatterns\n",e),e.forEach((e=>{e&&s.push(L(e))}))},getBeforeSendHooks:()=>[...s],execute:e=>{var r;a||((null===(r=t.batching)||void 0===r?void 0:r.enabled)&&(null==c||c.addItem(e)),(e=>{var r,i;if((null===(r=t.batching)||void 0===r?void 0:r.enabled)&&o.every((e=>e.isBatched())))return;const[a]=l([e]);if(void 0!==a)for(const e of o)n.debug(`Transporting item using ${e.name}\n`,a),e.isBatched()?(null===(i=t.batching)||void 0===i?void 0:i.enabled)||e.send([a]):e.send(a)})(e))},isPaused:()=>a,pause:()=>{n.debug("Pausing transports"),null==c||c.pause(),a=!0},remove:(...e)=>{n.debug("Removing transports"),e.forEach((e=>{n.debug(`Removing "${e.name}" transport`);const t=o.indexOf(e);-1!==t?o.splice(t,1):n.warn(`Transport "${e.name}" is not added`)}))},removeBeforeSendHooks:(...e)=>{s.filter((n=>!e.includes(n)))},get transports(){return[...o]},unpause:()=>{n.debug("Unpausing transports"),null==c||c.start(),a=!1}}}var N;e.InternalLoggerLevel=void 0,(N=e.InternalLoggerLevel||(e.InternalLoggerLevel={}))[N.OFF=0]="OFF",N[N.ERROR=1]="ERROR",N[N.WARN=2]="WARN",N[N.INFO=3]="INFO",N[N.VERBOSE=4]="VERBOSE";const R={debug:E,error:E,info:E,prefix:"Faro",warn:E},x=e.InternalLoggerLevel.ERROR,j=Object.assign({},console);let A=j;function k(e){var n;return A=null!==(n=e.unpatchedConsole)&&void 0!==n?n:A,A}function C(n=j,t=x){const r=R;return t>e.InternalLoggerLevel.OFF&&(r.error=t>=e.InternalLoggerLevel.ERROR?function(...e){n.error(`${r.prefix}\n`,...e)}:E,r.warn=t>=e.InternalLoggerLevel.WARN?function(...e){n.warn(`${r.prefix}\n`,...e)}:E,r.info=t>=e.InternalLoggerLevel.INFO?function(...e){n.info(`${r.prefix}\n`,...e)}:E,r.debug=t>=e.InternalLoggerLevel.VERBOSE?function(...e){n.debug(`${r.prefix}\n`,...e)}:E),r}let w=R;function P(e,n){return w=C(e,n.internalLoggerLevel),w}class B{constructor(){this.unpatchedConsole=j,this.internalLogger=R,this.config={},this.metas={}}logDebug(...e){this.internalLogger.debug(`${this.name}\n`,...e)}logInfo(...e){this.internalLogger.info(`${this.name}\n`,...e)}logWarn(...e){this.internalLogger.warn(`${this.name}\n`,...e)}logError(...e){this.internalLogger.error(`${this.name}\n`,...e)}}function F(e,n){var t,r;if(void 0===n)return e;if(void 0===e)return{resourceSpans:n};const i=null===(t=e.resourceSpans)||void 0===t?void 0:t[0];if(void 0===i)return e;const o=(null==i?void 0:i.scopeSpans)||[],a=(null===(r=null==n?void 0:n[0])||void 0===r?void 0:r.scopeSpans)||[];return Object.assign(Object.assign({},e),{resourceSpans:[Object.assign(Object.assign({},i),{scopeSpans:[...o,...a]})]})}const D="Error";let _;function G(n,t,r,o,a){t.debug("Initializing API");const s=function(n,t,r,i,o){let a;return t.debug("Initializing traces API"),{getOTEL:()=>a,getTraceContext:()=>{const e=null==a?void 0:a.trace.getSpanContext(a.context.active());return e?{trace_id:e.traceId,span_id:e.spanId}:void 0},initOTEL:(e,n)=>{t.debug("Initializing OpenTelemetry"),a={trace:e,context:n}},isOTELInitialized:()=>!!a,pushTraces:n=>{try{const r={type:e.TransportItemType.TRACE,payload:n,meta:i.value};t.debug("Pushing trace\n",r),o.execute(r)}catch(e){t.error("Error pushing trace\n",e)}}}}(0,t,0,o,a);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},s),function(n,t,r,o,a,s){var l;t.debug("Initializing exceptions API");let u=null;_=null!==(l=r.parseStacktrace)&&void 0!==l?l:_;const c=e=>{t.debug("Changing stacktrace parser"),_=null!=e?e:_};return c(r.parseStacktrace),{changeStacktraceParser:c,getStacktraceParser:()=>_,pushError:(n,{skipDedupe:l,stackFrames:c,type:g,context:d}={})=>{g=g||n.name||D;const p={meta:o.value,payload:{type:g,value:n.message,timestamp:m(),trace:s.getTraceContext(),context:null!=d?d:{}},type:e.TransportItemType.EXCEPTION};(null==(c=null!=c?c:n.stack?null==_?void 0:_(n).frames:void 0)?void 0:c.length)&&(p.payload.stacktrace={frames:c});const v={type:p.payload.type,value:p.payload.value,stackTrace:p.payload.stacktrace,context:p.payload.context};l||!r.dedupe||i(u)||!f(v,u)?(u=v,t.debug("Pushing exception\n",p),a.execute(p)):t.debug("Skipping error push because it is the same as the last one\n",p.payload)}}}(0,t,r,o,a,s)),function(e,n,t,r,i){let o,a,s;n.debug("Initializing meta API");const l=e=>{a&&r.remove(a),a={user:e},r.add(a)},u=e=>{o&&r.remove(o),o={session:e},r.add(o)};return{setUser:l,resetUser:l,setSession:u,resetSession:u,getSession:()=>r.value.session,setView:e=>{var n;if((null===(n=null==s?void 0:s.view)||void 0===n?void 0:n.name)===(null==e?void 0:e.name))return;const t=s;s={view:e},r.add(s),t&&r.remove(t)},getView:()=>r.value.view}}(0,t,0,o)),function(n,t,r,o,a,s){t.debug("Initializing logs API");let l=null;return{pushLog:(n,{context:u,level:c,skipDedupe:g}={})=>{try{const d={type:e.TransportItemType.LOG,payload:{message:n.map((e=>{try{return String(e)}catch(e){return""}})).join(" "),level:null!=c?c:h,context:null!=u?u:{},timestamp:m(),trace:s.getTraceContext()},meta:o.value},p={message:d.payload.message,level:d.payload.level,context:d.payload.context};if(!g&&r.dedupe&&!i(l)&&f(p,l))return void t.debug("Skipping log push because it is the same as the last one\n",d.payload);l=p,t.debug("Pushing log\n",d),a.execute(d)}catch(e){t.error("Error pushing log\n",e)}}}}(0,t,r,o,a,s)),function(n,t,r,o,a,s){t.debug("Initializing measurements API");let l=null;return{pushMeasurement:(n,{skipDedupe:u,context:c}={})=>{var g;try{const d={type:e.TransportItemType.MEASUREMENT,payload:Object.assign(Object.assign({},n),{trace:s.getTraceContext(),timestamp:null!==(g=n.timestamp)&&void 0!==g?g:m(),context:null!=c?c:{}}),meta:o.value},p={type:d.payload.type,values:d.payload.values,context:d.payload.context};if(!u&&r.dedupe&&!i(l)&&f(p,l))return void t.debug("Skipping measurement push because it is the same as the last one\n",d.payload);l=p,t.debug("Pushing measurement\n",d),a.execute(d)}catch(e){t.error("Error pushing measurement\n",e)}}}}(0,t,r,o,a,s)),function(n,t,r,o,a,s){let l=null;return{pushEvent:(n,u,c,{skipDedupe:g}={})=>{try{const d={meta:o.value,payload:{name:n,domain:null!=c?c:r.eventDomain,attributes:u,timestamp:m(),trace:s.getTraceContext()},type:e.TransportItemType.EVENT},p={name:d.payload.name,attributes:d.payload.attributes,domain:d.payload.domain};if(!g&&r.dedupe&&!i(l)&&f(p,l))return void t.debug("Skipping event push because it is the same as the last one\n",d.payload);l=p,t.debug("Pushing event\n",d),a.execute(d)}catch(e){t.error("Error pushing event",e)}}}}(0,t,r,o,a,s))}const $="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:void 0;const V="1.3.8";const M="_faroInternal";function z(e){e.config.isolate?e.internalLogger.debug("Skipping registering internal Faro instance on global object"):(e.internalLogger.debug("Registering internal Faro instance on global object"),Object.defineProperty($,M,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function U(){return M in $}function K(n,t,r,i,o,a,s){return t.debug("Initializing Faro"),e.faro={api:a,config:r,instrumentations:s,internalLogger:t,metas:i,pause:o.pause,transports:o,unpatchedConsole:n,unpause:o.unpause},z(e.faro),function(e){if(e.config.preventGlobalExposure)e.internalLogger.debug("Skipping registering public Faro instance in the global scope");else{if(e.internalLogger.debug(`Registering public faro reference in the global scope using "${e.config.globalObjectKey}" key`),e.config.globalObjectKey in $)return void e.internalLogger.warn(`Skipping global registration due to key "${e.config.globalObjectKey}" being used already. Please set "globalObjectKey" to something else or set "preventGlobalExposure" to "true"`);Object.defineProperty($,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}(e.faro),e.faro}e.faro={};return e.BaseExtension=B,e.BaseInstrumentation=class extends B{constructor(){super(...arguments),this.api={},this.transports={}}},e.BaseTransport=class extends B{isBatched(){return!1}getIgnoreUrls(){return[]}},e.Conventions={EventNames:{CLICK:"click",NAVIGATION:"navigation",SESSION_START:"session_start",VIEW_CHANGED:"view_changed"}},e.EVENT_CLICK="click",e.EVENT_NAVIGATION="navigation",e.EVENT_ROUTE_CHANGE="route_change",e.EVENT_SESSION_EXTEND="session_extend",e.EVENT_SESSION_RESUME="session_resume",e.EVENT_SESSION_START="session_start",e.EVENT_VIEW_CHANGED="view_changed",e.VERSION=V,e.allLogLevels=b,e.createInternalLogger=C,e.createPromiseBuffer=function(e){const{size:n,concurrency:t}=e,r=[];let i=0;const o=()=>{if(i<t&&r.length){const{producer:e,resolve:n,reject:t}=r.shift();i++,e().then((e=>{i--,o(),n(e)}),(e=>{i--,o(),t(e)}))}};return{add:e=>{if(r.length+i>=n)throw new Error("Task buffer full");return new Promise(((n,t)=>{r.push({producer:e,resolve:n,reject:t}),o()}))}}},e.dateNow=function(){return Date.now()},e.deepEqual=f,e.defaultBatchingConfig={enabled:!0,sendTimeout:250,itemLimit:50},e.defaultExceptionType=D,e.defaultGlobalObjectKey="faro",e.defaultInternalLoggerLevel=x,e.defaultLogLevel=h,e.defaultUnpatchedConsole=j,e.genShortID=function(e=10){return Array.from(Array(e)).map((()=>y[Math.floor(Math.random()*y.length)])).join("")},e.getCurrentTimestamp=m,e.getInternalFaroFromGlobalObject=function(){return $[M]},e.getTransportBody=function(n){let t={meta:{}};return void 0!==n[0]&&(t.meta=n[0].meta),n.forEach((n=>{switch(n.type){case e.TransportItemType.LOG:case e.TransportItemType.EVENT:case e.TransportItemType.EXCEPTION:case e.TransportItemType.MEASUREMENT:const r=O[n.type],i=t[r];t=Object.assign(Object.assign({},t),{[r]:void 0===i?[n.payload]:[...i,n.payload]});break;case e.TransportItemType.TRACE:t=Object.assign(Object.assign({},t),{traces:F(t.traces,n.payload.resourceSpans)})}})),t},e.globalObject=$,e.initializeFaro=function(e){const n=k(e),t=P(n,e);if(U()&&!e.isolate)return void t.error('Faro is already registered. Either add instrumentations, transports etc. to the global faro instance or use the "isolate" property');t.debug("Initializing");const r=function(e,n,t){let r=[],i=[];const o=()=>r.reduce(((e,n)=>Object.assign(e,l(n)?n():n)),{}),a=()=>{if(i.length){const e=o();i.forEach((n=>n(e)))}};return{add:(...e)=>{n.debug("Adding metas\n",e),r.push(...e),a()},remove:(...e)=>{n.debug("Removing metas\n",e),r=r.filter((n=>!e.includes(n))),a()},addListener:e=>{n.debug("Adding metas listener\n",e),i.push(e)},removeListener:e=>{n.debug("Removing metas listener\n",e),i=i.filter((n=>n!==e))},get value(){return o()}}}(0,t),i=S(n,t,e,r),o=G(0,t,e,r,i),a=function(e,n,t,r,i,o){n.debug("Initializing instrumentations");const a=[];return{add:(...s)=>{n.debug("Adding instrumentations"),s.forEach((s=>{n.debug(`Adding "${s.name}" instrumentation`),a.some((e=>e.name===s.name))?n.warn(`Instrumentation ${s.name} is already added`):(s.unpatchedConsole=e,s.internalLogger=n,s.config=t,s.metas=r,s.transports=i,s.api=o,a.push(s),s.initialize())}))},get instrumentations(){return[...a]},remove:(...e)=>{n.debug("Removing instrumentations"),e.forEach((e=>{var t,r;n.debug(`Removing "${e.name}" instrumentation`);const i=a.reduce(((n,t,r)=>null===n&&t.name===e.name?r:null),null);i?(null===(r=(t=a[i]).destroy)||void 0===r||r.call(t),a.splice(i,1)):n.warn(`Instrumentation "${e.name}" is not added`)}))}}}(n,t,e,r,i,o),s=K(n,t,e,r,i,o,a);return function(e){var n,t;const r={sdk:{version:V}},i=null===(n=e.config.sessionTracking)||void 0===n?void 0:n.session;i&&e.api.setSession(i),e.config.app&&(r.app=e.config.app),e.config.user&&(r.user=e.config.user),e.config.view&&(r.view=e.config.view),e.metas.add(r,...null!==(t=e.config.metas)&&void 0!==t?t:[])}(s),function(e){e.transports.add(...e.config.transports),e.transports.addBeforeSendHooks(e.config.beforeSend),e.transports.addIgnoreErrorsPatterns(e.config.ignoreErrors)}(s),function(e){e.instrumentations.add(...e.config.instrumentations)}(s),s},e.internalGlobalObjectKey=M,e.isArray=u,e.isBoolean=e=>n(e,"boolean"),e.isDomError=e=>t(e,"DOMError"),e.isDomException=e=>t(e,"DOMException"),e.isElement=e=>d&&r(e,Element),e.isElementDefined=d,e.isError=e=>g&&r(e,Error),e.isErrorDefined=g,e.isErrorEvent=e=>t(e,"ErrorEvent"),e.isEvent=e=>c&&r(e,Event),e.isEventDefined=c,e.isFunction=l,e.isInstanceOf=r,e.isInt=e=>a(e)&&Number.isInteger(e),e.isInternalFaroOnGlobalObject=U,e.isMap=e=>p&&r(e,Map),e.isMapDefined=p,e.isNull=i,e.isNumber=a,e.isObject=s,e.isPrimitive=e=>!s(e)&&!l(e),e.isRegExp=e=>t(e,"RegExp"),e.isString=o,e.isSymbol=e=>n(e,"symbol"),e.isSyntheticEvent=e=>s(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e,e.isThenable=e=>l(null==e?void 0:e.then),e.isToString=t,e.isTypeof=n,e.isUndefined=e=>n(e,"undefined"),e.noop=E,e.setInternalFaroOnGlobalObject=z,e.transportItemTypeToBodyKey=O,e}({}); | ||
var GrafanaFaroCore=function(e){"use strict";function n(e,n){return typeof e===n}function t(e,n){return Object.prototype.toString.call(e)===`[object ${n}]`}function r(e,n){try{return e instanceof n}catch(e){return!1}}const i=e=>n(e,"null"),o=e=>n(e,"string"),a=e=>n(e,"number")&&!isNaN(e)||n(e,"bigint"),s=e=>!i(e)&&n(e,"object"),l=e=>n(e,"function"),u=e=>t(e,"Array"),c="undefined"!=typeof Event,g="undefined"!=typeof Error,d="undefined"!=typeof Element,p="undefined"!=typeof Map;function f(e,t){if(e===t)return!0;if(n(e,"number")&&isNaN(e))return n(t,"number")&&isNaN(t);const r=u(e),i=u(t);if(r!==i)return!1;if(r&&i){const n=e.length;if(n!==t.length)return!1;for(let r=n;0!=r--;)if(!f(e[r],t[r]))return!1;return!0}const o=s(e),a=s(t);if(o!==a)return!1;if(e&&t&&o&&a){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;for(let r of n)if(!f(e[r],t[r]))return!1;return!0}return!1}function m(){return(new Date).toISOString()}var v;e.LogLevel=void 0,(v=e.LogLevel||(e.LogLevel={})).TRACE="trace",v.DEBUG="debug",v.INFO="info",v.LOG="log",v.WARN="warn",v.ERROR="error";const h=e.LogLevel.LOG,b=[e.LogLevel.TRACE,e.LogLevel.DEBUG,e.LogLevel.INFO,e.LogLevel.LOG,e.LogLevel.WARN,e.LogLevel.ERROR];function E(){}const y="abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789";class T{constructor(e,n){var t,r;this.signalBuffer=[],this.itemLimit=null!==(t=null==n?void 0:n.itemLimit)&&void 0!==t?t:50,this.sendTimeout=null!==(r=null==n?void 0:n.sendTimeout)&&void 0!==r?r:250,this.paused=(null==n?void 0:n.paused)||!1,this.sendFn=e,this.flushInterval=-1,this.paused||this.start(),document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&this.flush()}))}addItem(e){this.paused||(this.signalBuffer.push(e),this.signalBuffer.length>=this.itemLimit&&this.flush())}start(){this.paused=!1,this.sendTimeout>0&&(this.flushInterval=window.setInterval((()=>this.flush()),this.sendTimeout))}pause(){this.paused=!0,clearInterval(this.flushInterval)}groupItems(e){const n=new Map;return e.forEach((e=>{const t=JSON.stringify(e.meta);let r=n.get(t);r=void 0===r?[e]:[...r,e],n.set(t,r)})),Array.from(n.values())}flush(){if(this.paused||0===this.signalBuffer.length)return;this.groupItems(this.signalBuffer).forEach(this.sendFn),this.signalBuffer=[]}}var I;e.TransportItemType=void 0,(I=e.TransportItemType||(e.TransportItemType={})).EXCEPTION="exception",I.LOG="log",I.MEASUREMENT="measurement",I.TRACE="trace",I.EVENT="event";const O={[e.TransportItemType.EXCEPTION]:"exceptions",[e.TransportItemType.LOG]:"logs",[e.TransportItemType.MEASUREMENT]:"measurements",[e.TransportItemType.TRACE]:"traces",[e.TransportItemType.EVENT]:"events"};function L(n){return t=>{if(t.type===e.TransportItemType.EXCEPTION&&t.payload){const e=t.payload,r=`${e.type}: ${e.value}`;if(function(e,n){return e.some((e=>o(e)?n.includes(e):!!n.match(e)))}(n,r))return null}return t}}function S(e,n,t,r){var i;n.debug("Initializing transports");const o=[];let a=t.paused,s=[];const l=e=>{let n=e;for(const e of s){const t=n.map(e).filter(Boolean);if(0===t.length)return[];n=t}return n},u=e=>{const t=l(e);if(0!==t.length)for(const e of o)n.debug(`Transporting item using ${e.name}\n`,t),e.isBatched()&&e.send(t)};let c;(null===(i=t.batching)||void 0===i?void 0:i.enabled)&&(c=new T(u,{sendTimeout:t.batching.sendTimeout,itemLimit:t.batching.itemLimit,paused:a}));return{add:(...i)=>{n.debug("Adding transports"),i.forEach((i=>{n.debug(`Adding "${i.name}" transport`);o.some((e=>e===i))?n.warn(`Transport ${i.name} is already added`):(i.unpatchedConsole=e,i.internalLogger=n,i.config=t,i.metas=r,o.push(i))}))},addBeforeSendHooks:(...e)=>{n.debug("Adding beforeSendHooks\n",s),e.forEach((e=>{e&&s.push(e)}))},addIgnoreErrorsPatterns:(...e)=>{n.debug("Adding ignoreErrorsPatterns\n",e),e.forEach((e=>{e&&s.push(L(e))}))},getBeforeSendHooks:()=>[...s],execute:e=>{var r;a||((null===(r=t.batching)||void 0===r?void 0:r.enabled)&&(null==c||c.addItem(e)),(e=>{var r,i;if((null===(r=t.batching)||void 0===r?void 0:r.enabled)&&o.every((e=>e.isBatched())))return;const[a]=l([e]);if(void 0!==a)for(const e of o)n.debug(`Transporting item using ${e.name}\n`,a),e.isBatched()?(null===(i=t.batching)||void 0===i?void 0:i.enabled)||e.send([a]):e.send(a)})(e))},isPaused:()=>a,pause:()=>{n.debug("Pausing transports"),null==c||c.pause(),a=!0},remove:(...e)=>{n.debug("Removing transports"),e.forEach((e=>{n.debug(`Removing "${e.name}" transport`);const t=o.indexOf(e);-1!==t?o.splice(t,1):n.warn(`Transport "${e.name}" is not added`)}))},removeBeforeSendHooks:(...e)=>{s.filter((n=>!e.includes(n)))},get transports(){return[...o]},unpause:()=>{n.debug("Unpausing transports"),null==c||c.start(),a=!1}}}var N;e.InternalLoggerLevel=void 0,(N=e.InternalLoggerLevel||(e.InternalLoggerLevel={}))[N.OFF=0]="OFF",N[N.ERROR=1]="ERROR",N[N.WARN=2]="WARN",N[N.INFO=3]="INFO",N[N.VERBOSE=4]="VERBOSE";const R={debug:E,error:E,info:E,prefix:"Faro",warn:E},x=e.InternalLoggerLevel.ERROR,j=Object.assign({},console);let A=j;function k(e){var n;return A=null!==(n=e.unpatchedConsole)&&void 0!==n?n:A,A}function C(n=j,t=x){const r=R;return t>e.InternalLoggerLevel.OFF&&(r.error=t>=e.InternalLoggerLevel.ERROR?function(...e){n.error(`${r.prefix}\n`,...e)}:E,r.warn=t>=e.InternalLoggerLevel.WARN?function(...e){n.warn(`${r.prefix}\n`,...e)}:E,r.info=t>=e.InternalLoggerLevel.INFO?function(...e){n.info(`${r.prefix}\n`,...e)}:E,r.debug=t>=e.InternalLoggerLevel.VERBOSE?function(...e){n.debug(`${r.prefix}\n`,...e)}:E),r}let w=R;function P(e,n){return w=C(e,n.internalLoggerLevel),w}class B{constructor(){this.unpatchedConsole=j,this.internalLogger=R,this.config={},this.metas={}}logDebug(...e){this.internalLogger.debug(`${this.name}\n`,...e)}logInfo(...e){this.internalLogger.info(`${this.name}\n`,...e)}logWarn(...e){this.internalLogger.warn(`${this.name}\n`,...e)}logError(...e){this.internalLogger.error(`${this.name}\n`,...e)}}function F(e,n){var t,r;if(void 0===n)return e;if(void 0===e)return{resourceSpans:n};const i=null===(t=e.resourceSpans)||void 0===t?void 0:t[0];if(void 0===i)return e;const o=(null==i?void 0:i.scopeSpans)||[],a=(null===(r=null==n?void 0:n[0])||void 0===r?void 0:r.scopeSpans)||[];return Object.assign(Object.assign({},e),{resourceSpans:[Object.assign(Object.assign({},i),{scopeSpans:[...o,...a]})]})}const D="Error";let _;function G(n,t,r,o,a){t.debug("Initializing API");const s=function(n,t,r,i,o){let a;return t.debug("Initializing traces API"),{getOTEL:()=>a,getTraceContext:()=>{const e=null==a?void 0:a.trace.getSpanContext(a.context.active());return e?{trace_id:e.traceId,span_id:e.spanId}:void 0},initOTEL:(e,n)=>{t.debug("Initializing OpenTelemetry"),a={trace:e,context:n}},isOTELInitialized:()=>!!a,pushTraces:n=>{try{const r={type:e.TransportItemType.TRACE,payload:n,meta:i.value};t.debug("Pushing trace\n",r),o.execute(r)}catch(e){t.error("Error pushing trace\n",e)}}}}(0,t,0,o,a);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},s),function(n,t,r,o,a,s){var l;t.debug("Initializing exceptions API");let u=null;_=null!==(l=r.parseStacktrace)&&void 0!==l?l:_;const c=e=>{t.debug("Changing stacktrace parser"),_=null!=e?e:_};return c(r.parseStacktrace),{changeStacktraceParser:c,getStacktraceParser:()=>_,pushError:(n,{skipDedupe:l,stackFrames:c,type:g,context:d}={})=>{g=g||n.name||D;const p={meta:o.value,payload:{type:g,value:n.message,timestamp:m(),trace:s.getTraceContext(),context:null!=d?d:{}},type:e.TransportItemType.EXCEPTION};(null==(c=null!=c?c:n.stack?null==_?void 0:_(n).frames:void 0)?void 0:c.length)&&(p.payload.stacktrace={frames:c});const v={type:p.payload.type,value:p.payload.value,stackTrace:p.payload.stacktrace,context:p.payload.context};l||!r.dedupe||i(u)||!f(v,u)?(u=v,t.debug("Pushing exception\n",p),a.execute(p)):t.debug("Skipping error push because it is the same as the last one\n",p.payload)}}}(0,t,r,o,a,s)),function(e,n,t,r,i){let o,a,s;n.debug("Initializing meta API");const l=e=>{a&&r.remove(a),a={user:e},r.add(a)},u=e=>{o&&r.remove(o),o={session:e},r.add(o)};return{setUser:l,resetUser:l,setSession:u,resetSession:u,getSession:()=>r.value.session,setView:e=>{var n;if((null===(n=null==s?void 0:s.view)||void 0===n?void 0:n.name)===(null==e?void 0:e.name))return;const t=s;s={view:e},r.add(s),t&&r.remove(t)},getView:()=>r.value.view}}(0,t,0,o)),function(n,t,r,o,a,s){t.debug("Initializing logs API");let l=null;return{pushLog:(n,{context:u,level:c,skipDedupe:g}={})=>{try{const d={type:e.TransportItemType.LOG,payload:{message:n.map((e=>{try{return String(e)}catch(e){return""}})).join(" "),level:null!=c?c:h,context:null!=u?u:{},timestamp:m(),trace:s.getTraceContext()},meta:o.value},p={message:d.payload.message,level:d.payload.level,context:d.payload.context};if(!g&&r.dedupe&&!i(l)&&f(p,l))return void t.debug("Skipping log push because it is the same as the last one\n",d.payload);l=p,t.debug("Pushing log\n",d),a.execute(d)}catch(e){t.error("Error pushing log\n",e)}}}}(0,t,r,o,a,s)),function(n,t,r,o,a,s){t.debug("Initializing measurements API");let l=null;return{pushMeasurement:(n,{skipDedupe:u,context:c}={})=>{var g;try{const d={type:e.TransportItemType.MEASUREMENT,payload:Object.assign(Object.assign({},n),{trace:s.getTraceContext(),timestamp:null!==(g=n.timestamp)&&void 0!==g?g:m(),context:null!=c?c:{}}),meta:o.value},p={type:d.payload.type,values:d.payload.values,context:d.payload.context};if(!u&&r.dedupe&&!i(l)&&f(p,l))return void t.debug("Skipping measurement push because it is the same as the last one\n",d.payload);l=p,t.debug("Pushing measurement\n",d),a.execute(d)}catch(e){t.error("Error pushing measurement\n",e)}}}}(0,t,r,o,a,s)),function(n,t,r,o,a,s){let l=null;return{pushEvent:(n,u,c,{skipDedupe:g}={})=>{try{const d={meta:o.value,payload:{name:n,domain:null!=c?c:r.eventDomain,attributes:u,timestamp:m(),trace:s.getTraceContext()},type:e.TransportItemType.EVENT},p={name:d.payload.name,attributes:d.payload.attributes,domain:d.payload.domain};if(!g&&r.dedupe&&!i(l)&&f(p,l))return void t.debug("Skipping event push because it is the same as the last one\n",d.payload);l=p,t.debug("Pushing event\n",d),a.execute(d)}catch(e){t.error("Error pushing event",e)}}}}(0,t,r,o,a,s))}const $="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:void 0;const V="1.3.9";const M="_faroInternal";function z(e){e.config.isolate?e.internalLogger.debug("Skipping registering internal Faro instance on global object"):(e.internalLogger.debug("Registering internal Faro instance on global object"),Object.defineProperty($,M,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function U(){return M in $}function K(n,t,r,i,o,a,s){return t.debug("Initializing Faro"),e.faro={api:a,config:r,instrumentations:s,internalLogger:t,metas:i,pause:o.pause,transports:o,unpatchedConsole:n,unpause:o.unpause},z(e.faro),function(e){if(e.config.preventGlobalExposure)e.internalLogger.debug("Skipping registering public Faro instance in the global scope");else{if(e.internalLogger.debug(`Registering public faro reference in the global scope using "${e.config.globalObjectKey}" key`),e.config.globalObjectKey in $)return void e.internalLogger.warn(`Skipping global registration due to key "${e.config.globalObjectKey}" being used already. Please set "globalObjectKey" to something else or set "preventGlobalExposure" to "true"`);Object.defineProperty($,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}(e.faro),e.faro}e.faro={};return e.BaseExtension=B,e.BaseInstrumentation=class extends B{constructor(){super(...arguments),this.api={},this.transports={}}},e.BaseTransport=class extends B{isBatched(){return!1}getIgnoreUrls(){return[]}},e.Conventions={EventNames:{CLICK:"click",NAVIGATION:"navigation",SESSION_START:"session_start",VIEW_CHANGED:"view_changed"}},e.EVENT_CLICK="click",e.EVENT_NAVIGATION="navigation",e.EVENT_ROUTE_CHANGE="route_change",e.EVENT_SESSION_EXTEND="session_extend",e.EVENT_SESSION_RESUME="session_resume",e.EVENT_SESSION_START="session_start",e.EVENT_VIEW_CHANGED="view_changed",e.VERSION=V,e.allLogLevels=b,e.createInternalLogger=C,e.createPromiseBuffer=function(e){const{size:n,concurrency:t}=e,r=[];let i=0;const o=()=>{if(i<t&&r.length){const{producer:e,resolve:n,reject:t}=r.shift();i++,e().then((e=>{i--,o(),n(e)}),(e=>{i--,o(),t(e)}))}};return{add:e=>{if(r.length+i>=n)throw new Error("Task buffer full");return new Promise(((n,t)=>{r.push({producer:e,resolve:n,reject:t}),o()}))}}},e.dateNow=function(){return Date.now()},e.deepEqual=f,e.defaultBatchingConfig={enabled:!0,sendTimeout:250,itemLimit:50},e.defaultExceptionType=D,e.defaultGlobalObjectKey="faro",e.defaultInternalLoggerLevel=x,e.defaultLogLevel=h,e.defaultUnpatchedConsole=j,e.genShortID=function(e=10){return Array.from(Array(e)).map((()=>y[Math.floor(Math.random()*y.length)])).join("")},e.getCurrentTimestamp=m,e.getInternalFaroFromGlobalObject=function(){return $[M]},e.getTransportBody=function(n){let t={meta:{}};return void 0!==n[0]&&(t.meta=n[0].meta),n.forEach((n=>{switch(n.type){case e.TransportItemType.LOG:case e.TransportItemType.EVENT:case e.TransportItemType.EXCEPTION:case e.TransportItemType.MEASUREMENT:const r=O[n.type],i=t[r];t=Object.assign(Object.assign({},t),{[r]:void 0===i?[n.payload]:[...i,n.payload]});break;case e.TransportItemType.TRACE:t=Object.assign(Object.assign({},t),{traces:F(t.traces,n.payload.resourceSpans)})}})),t},e.globalObject=$,e.initializeFaro=function(e){const n=k(e),t=P(n,e);if(U()&&!e.isolate)return void t.error('Faro is already registered. Either add instrumentations, transports etc. to the global faro instance or use the "isolate" property');t.debug("Initializing");const r=function(e,n,t){let r=[],i=[];const o=()=>r.reduce(((e,n)=>Object.assign(e,l(n)?n():n)),{}),a=()=>{if(i.length){const e=o();i.forEach((n=>n(e)))}};return{add:(...e)=>{n.debug("Adding metas\n",e),r.push(...e),a()},remove:(...e)=>{n.debug("Removing metas\n",e),r=r.filter((n=>!e.includes(n))),a()},addListener:e=>{n.debug("Adding metas listener\n",e),i.push(e)},removeListener:e=>{n.debug("Removing metas listener\n",e),i=i.filter((n=>n!==e))},get value(){return o()}}}(0,t),i=S(n,t,e,r),o=G(0,t,e,r,i),a=function(e,n,t,r,i,o){n.debug("Initializing instrumentations");const a=[];return{add:(...s)=>{n.debug("Adding instrumentations"),s.forEach((s=>{n.debug(`Adding "${s.name}" instrumentation`),a.some((e=>e.name===s.name))?n.warn(`Instrumentation ${s.name} is already added`):(s.unpatchedConsole=e,s.internalLogger=n,s.config=t,s.metas=r,s.transports=i,s.api=o,a.push(s),s.initialize())}))},get instrumentations(){return[...a]},remove:(...e)=>{n.debug("Removing instrumentations"),e.forEach((e=>{var t,r;n.debug(`Removing "${e.name}" instrumentation`);const i=a.reduce(((n,t,r)=>null===n&&t.name===e.name?r:null),null);i?(null===(r=(t=a[i]).destroy)||void 0===r||r.call(t),a.splice(i,1)):n.warn(`Instrumentation "${e.name}" is not added`)}))}}}(n,t,e,r,i,o),s=K(n,t,e,r,i,o,a);return function(e){var n,t;const r={sdk:{version:V}},i=null===(n=e.config.sessionTracking)||void 0===n?void 0:n.session;i&&e.api.setSession(i),e.config.app&&(r.app=e.config.app),e.config.user&&(r.user=e.config.user),e.config.view&&(r.view=e.config.view),e.metas.add(r,...null!==(t=e.config.metas)&&void 0!==t?t:[])}(s),function(e){e.transports.add(...e.config.transports),e.transports.addBeforeSendHooks(e.config.beforeSend),e.transports.addIgnoreErrorsPatterns(e.config.ignoreErrors)}(s),function(e){e.instrumentations.add(...e.config.instrumentations)}(s),s},e.internalGlobalObjectKey=M,e.isArray=u,e.isBoolean=e=>n(e,"boolean"),e.isDomError=e=>t(e,"DOMError"),e.isDomException=e=>t(e,"DOMException"),e.isElement=e=>d&&r(e,Element),e.isElementDefined=d,e.isError=e=>g&&r(e,Error),e.isErrorDefined=g,e.isErrorEvent=e=>t(e,"ErrorEvent"),e.isEvent=e=>c&&r(e,Event),e.isEventDefined=c,e.isFunction=l,e.isInstanceOf=r,e.isInt=e=>a(e)&&Number.isInteger(e),e.isInternalFaroOnGlobalObject=U,e.isMap=e=>p&&r(e,Map),e.isMapDefined=p,e.isNull=i,e.isNumber=a,e.isObject=s,e.isPrimitive=e=>!s(e)&&!l(e),e.isRegExp=e=>t(e,"RegExp"),e.isString=o,e.isSymbol=e=>n(e,"symbol"),e.isSyntheticEvent=e=>s(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e,e.isThenable=e=>l(null==e?void 0:e.then),e.isToString=t,e.isTypeof=n,e.isUndefined=e=>n(e,"undefined"),e.noop=E,e.setInternalFaroOnGlobalObject=z,e.transportItemTypeToBodyKey=O,e}({}); |
@@ -7,3 +7,3 @@ import type { Patterns } from '../config'; | ||
readonly name = "@grafana/transport-mock"; | ||
readonly version = "1.3.8"; | ||
readonly version = "1.3.9"; | ||
items: TransportItem[]; | ||
@@ -10,0 +10,0 @@ constructor(ignoreURLs?: Patterns); |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "1.3.8"; | ||
export declare const VERSION = "1.3.9"; |
@@ -5,3 +5,3 @@ "use strict"; | ||
// auto-generated by bin/genVersion.ts | ||
exports.VERSION = '1.3.8'; | ||
exports.VERSION = '1.3.9'; | ||
//# sourceMappingURL=version.js.map |
// auto-generated by bin/genVersion.ts | ||
export const VERSION = '1.3.8'; | ||
export const VERSION = '1.3.9'; | ||
//# sourceMappingURL=version.js.map |
@@ -5,3 +5,3 @@ "use strict"; | ||
// auto-generated by bin/genVersion.ts | ||
exports.VERSION = '1.3.8'; | ||
exports.VERSION = '1.3.9'; | ||
//# sourceMappingURL=version.js.map |
@@ -7,3 +7,3 @@ import type { Patterns } from '../config'; | ||
readonly name = "@grafana/transport-mock"; | ||
readonly version = "1.3.8"; | ||
readonly version = "1.3.9"; | ||
items: TransportItem[]; | ||
@@ -10,0 +10,0 @@ constructor(ignoreURLs?: Patterns); |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "1.3.8"; | ||
export declare const VERSION = "1.3.9"; |
@@ -7,3 +7,3 @@ import type { Patterns } from '../config'; | ||
readonly name = "@grafana/transport-mock"; | ||
readonly version = "1.3.8"; | ||
readonly version = "1.3.9"; | ||
items: TransportItem[]; | ||
@@ -10,0 +10,0 @@ constructor(ignoreURLs?: Patterns); |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "1.3.8"; | ||
export declare const VERSION = "1.3.9"; |
{ | ||
"name": "@grafana/faro-core", | ||
"version": "1.3.8", | ||
"version": "1.3.9", | ||
"description": "Core package of Faro.", | ||
@@ -60,3 +60,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "6de2e06ee87af72a251966854284491f307341fb" | ||
"gitHead": "019731dbf50cefa2c3d32b28306f8aa081f08d84" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet