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