@grafana/faro-core 1.18.2 → 1.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -77,7 +77,6 @@ The `api` property on the Faro instance contains all the necessary methods to pu
77
77
 
78
78
  - `pushError` - is a method to push an error/exception to the Faro instance. It accepts a mandatory `message` parameter
79
79
  and an optional one where you can set:
80
-
81
80
  - `skipDedupe` - a flag for enforcing error push even if the error is identical to the previous one.
82
81
  - `stackFrames` - an array of stack frames. Defaults to parsing `error.stack` if present.
83
82
  - `type` - the type of exception. Default value: `error.name` or `"error"`.
@@ -119,7 +118,6 @@ The `api` property on the Faro instance contains all the necessary methods to pu
119
118
  The second optional parameter is called `domain` and it is a string that's used to group events together.
120
119
 
121
120
  The third optional parameter is an optional `options` object where you can set:
122
-
123
121
  - `skipDedupe` - a flag for enforcing event push even if the event is identical to the previous one.
124
122
 
125
123
  ```ts
@@ -136,7 +134,6 @@ The `api` property on the Faro instance contains all the necessary methods to pu
136
134
 
137
135
  - `pushLog` - is a method to register a log event. The method accepts a mandatory `args` parameter which is an array of
138
136
  arguments that will be stringified and sent to the transports and an optional one where you can set:
139
-
140
137
  - `skipDedupe` - a flag for enforcing log push even if the log is identical to the previous one.
141
138
  - `logLevel` - the type of message that we register.
142
139
  - `context` - a plain object containing primitive values that will be recorded along with the message.
@@ -159,7 +156,6 @@ The `api` property on the Faro instance contains all the necessary methods to pu
159
156
 
160
157
  - `pushMeasurement` - is a method for registering metrics. The method accepts a mandatory `payload` parameter and an
161
158
  optional parameter for passing additional options:
162
-
163
159
  - `skipDedupe` - a flag for enforcing measurement push even if the measurement is identical to the previous one.
164
160
 
165
161
  ```ts
@@ -1 +1 @@
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 s=e=>n(e,"null"),i=e=>n(e,"string"),a=e=>n(e,"number")&&!isNaN(e)||n(e,"bigint"),o=e=>!s(e)&&n(e,"object"),u=e=>n(e,"function"),l=e=>t(e,"Array"),c="undefined"!=typeof Event,g="undefined"!=typeof Error,d=e=>g&&r(e,Error),p="undefined"!=typeof Element,f="undefined"!=typeof Map;function b(e){return null==e||(l(e)||i(e)?0===e.length:!!o(e)&&0===Object.keys(e).length)}function m(e,t){if(e===t)return!0;if(n(e,"number")&&isNaN(e))return n(t,"number")&&isNaN(t);const r=l(e),s=l(t);if(r!==s)return!1;if(r&&s){const n=e.length;if(n!==t.length)return!1;for(let r=n;0!=r--;)if(!m(e[r],t[r]))return!1;return!0}const i=o(e),a=o(t);if(i!==a)return!1;if(e&&t&&i&&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(!m(e[r],t[r]))return!1;return!0}return!1}function v(){return(new Date).toISOString()}function h(e){return new Date(e).toISOString()}var E;e.LogLevel=void 0,(E=e.LogLevel||(e.LogLevel={})).TRACE="trace",E.DEBUG="debug",E.INFO="info",E.LOG="log",E.WARN="warn",E.ERROR="error";const y=e.LogLevel.LOG,I=[e.LogLevel.TRACE,e.LogLevel.DEBUG,e.LogLevel.INFO,e.LogLevel.LOG,e.LogLevel.WARN,e.LogLevel.ERROR];function O(){}const T="abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789";const L="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:void 0;function S(){const e=new WeakSet;return function(n,t){if(o(t)&&null!==t){if(e.has(t))return null;e.add(t)}return t}}function N(e={}){return JSON.stringify(null!=e?e:{},S())}function j(e={}){const n={};for(const[t,r]of Object.entries(e))n[t]=o(r)&&null!==r?N(r):String(r);return n}class A{constructor(){this.subscribers=[]}subscribe(e){return this.subscribers.push(e),{unsubscribe:()=>this.unsubscribe(e)}}unsubscribe(e){this.subscribers=this.subscribers.filter((n=>n!==e))}notify(e){this.subscribers.forEach((n=>n(e)))}first(){const e=new A,n=n=>{e.notify(n),t.unsubscribe()},t=this.subscribe(n),r=e.unsubscribe.bind(e);return this.withUnsubscribeOverride(e,r,n)}takeWhile(e){const n=new A,t=r=>{e(r)?n.notify(r):n.unsubscribe(t)};this.subscribe(t);const r=n.unsubscribe.bind(n);return this.withUnsubscribeOverride(n,r,t)}filter(e){const n=new A,t=t=>{e(t)&&n.notify(t)};this.subscribe(t);const r=n.unsubscribe.bind(n);return this.withUnsubscribeOverride(n,r,t)}merge(...e){const n=new A,t=[];e.forEach((e=>{const r=e.subscribe((e=>{n.notify(e)}));t.push(r)}));const r=n.unsubscribeAll.bind(n);return n.unsubscribe=()=>{t.forEach((e=>e.unsubscribe())),r()},n}withUnsubscribeOverride(e,n,t){return e.unsubscribe=e=>{n(e),this.unsubscribe(t)},e}unsubscribeAll(){this.subscribers=[]}}class R{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 x;e.TransportItemType=void 0,(x=e.TransportItemType||(e.TransportItemType={})).EXCEPTION="exception",x.LOG="log",x.MEASUREMENT="measurement",x.TRACE="trace",x.EVENT="event";const w={[e.TransportItemType.EXCEPTION]:"exceptions",[e.TransportItemType.LOG]:"logs",[e.TransportItemType.MEASUREMENT]:"measurements",[e.TransportItemType.TRACE]:"traces",[e.TransportItemType.EVENT]:"events"};function C(e,n,t,r){var s;n.debug("Initializing transports");const i=[];let a=t.paused,o=[];const u=e=>{let n=e;for(const e of o){const r=n.map(e).filter(Boolean);if(0===r.length)return[];n=_(r,t)}return n},l=e=>{const t=u(e);if(0!==t.length)for(const e of i)n.debug(`Transporting item using ${e.name}\n`,t),e.isBatched()&&e.send(t)};let c;(null===(s=t.batching)||void 0===s?void 0:s.enabled)&&(c=new R(l,{sendTimeout:t.batching.sendTimeout,itemLimit:t.batching.itemLimit,paused:a}));return{add:(...s)=>{n.debug("Adding transports"),s.forEach((s=>{n.debug(`Adding "${s.name}" transport`);i.some((e=>e===s))?n.warn(`Transport ${s.name} is already added`):(s.unpatchedConsole=e,s.internalLogger=n,s.config=t,s.metas=r,i.push(s))}))},addBeforeSendHooks:(...e)=>{n.debug("Adding beforeSendHooks\n",o),e.forEach((e=>{e&&o.push(e)}))},getBeforeSendHooks:()=>[...o],execute:e=>{var r;a||((null===(r=t.batching)||void 0===r?void 0:r.enabled)&&(null==c||c.addItem(e)),(e=>{var r,s;if((null===(r=t.batching)||void 0===r?void 0:r.enabled)&&i.every((e=>e.isBatched())))return;const[a]=u([e]);if(void 0!==a)for(const e of i)n.debug(`Transporting item using ${e.name}\n`,a),e.isBatched()?(null===(s=t.batching)||void 0===s?void 0:s.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=i.indexOf(e);-1!==t?i.splice(t,1):n.warn(`Transport "${e.name}" is not added`)}))},removeBeforeSendHooks:(...e)=>{o.filter((n=>!e.includes(n)))},get transports(){return[...i]},unpause:()=>{n.debug("Unpausing transports"),null==c||c.start(),a=!1}}}function _(n,t){if(t.preserveOriginalError)for(const t of n)t.type===e.TransportItemType.EXCEPTION&&delete t.payload.originalError;return n}var k;e.InternalLoggerLevel=void 0,(k=e.InternalLoggerLevel||(e.InternalLoggerLevel={}))[k.OFF=0]="OFF",k[k.ERROR=1]="ERROR",k[k.WARN=2]="WARN",k[k.INFO=3]="INFO",k[k.VERBOSE=4]="VERBOSE";const B={debug:O,error:O,info:O,prefix:"Faro",warn:O},M=e.InternalLoggerLevel.ERROR,P=Object.assign({},console);let D=P;function F(e){var n;return D=null!==(n=e.unpatchedConsole)&&void 0!==n?n:D,D}function V(n=P,t=M){const r=B;return t>e.InternalLoggerLevel.OFF&&(r.error=t>=e.InternalLoggerLevel.ERROR?function(...e){n.error(`${r.prefix}\n`,...e)}:O,r.warn=t>=e.InternalLoggerLevel.WARN?function(...e){n.warn(`${r.prefix}\n`,...e)}:O,r.info=t>=e.InternalLoggerLevel.INFO?function(...e){n.info(`${r.prefix}\n`,...e)}:O,r.debug=t>=e.InternalLoggerLevel.VERBOSE?function(...e){n.debug(`${r.prefix}\n`,...e)}:O),r}let U=B;function G(e,n){return U=V(e,n.internalLoggerLevel),U}class ${constructor(){this.unpatchedConsole=P,this.internalLogger=B,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 z(e,n){var t,r;if(void 0===n)return e;if(void 0===e)return{resourceSpans:n};const s=null===(t=e.resourceSpans)||void 0===t?void 0:t[0];if(void 0===s)return e;const i=(null==s?void 0:s.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({},s),{scopeSpans:[...i,...a]})]})}const K="user-action-start",W="user-action-end",H="user-action-cancel",X="user-action-halt";const J="Error";let q;function Q({internalLogger:n,config:t,metas:r,transports:a,tracesApi:u,actionBuffer:c,getMessage:g}){var p;n.debug("Initializing exceptions API");let f=null;q=null!==(p=t.parseStacktrace)&&void 0!==p?p:q;const E=e=>{n.debug("Changing stacktrace parser"),q=null!=e?e:q},{ignoreErrors:y=[],preserveOriginalError:I}=t;return E(t.parseStacktrace),{changeStacktraceParser:E,getStacktraceParser:()=>q,pushError:(p,{skipDedupe:E,stackFrames:O,type:T,context:L,spanContext:S,timestampOverwriteMs:A,originalError:R}={})=>{if(!function(e,n){const{message:t,name:r,stack:s}=n;return a=e,o=t+" "+r+" "+s,a.some((e=>i(e)?o.includes(e):!!o.match(e)));var a,o}(y,null!=R?R:p))try{const i=j(Object.assign(Object.assign({},function(e){let n=e.cause;d(n)?n=e.cause.toString():null!==n&&(o(e.cause)||l(e.cause))?n=N(e.cause):null!=n&&(n=e.cause.toString());return null==n?{}:{cause:n}}(null!=R?R:p)),null!=L?L:{})),y={meta:r.value,payload:Object.assign(Object.assign({type:T||p.name||J,value:p.message,timestamp:A?h(A):v(),trace:S?{trace_id:S.traceId,span_id:S.spanId}:u.getTraceContext()},b(i)?{}:{context:i}),I?{originalError:R}:{}),type:e.TransportItemType.EXCEPTION};(null==(O=null!=O?O:p.stack?null==q?void 0:q(p).frames:void 0)?void 0:O.length)&&(y.payload.stacktrace={frames:O});const x={type:y.payload.type,value:y.payload.value,stackTrace:y.payload.stacktrace,context:y.payload.context};if(!E&&t.dedupe&&!s(f)&&m(x,f))return void n.debug("Skipping error push because it is the same as the last one\n",y.payload);f=x,n.debug("Pushing exception\n",y);const w=g();w&&w.type===K?c.addItem(y):a.execute(y)}catch(e){n.error("Error pushing event",e)}}}}const Y=e=>e.map((e=>{try{return String(e)}catch(e){return""}})).join(" ");class Z{constructor(){this.buffer=[]}addItem(e){this.buffer.push(e)}flushBuffer(e){if(u(e))for(const n of this.buffer)e(n);this.buffer.length=0}size(){return this.buffer.length}}function ee({apiMessageBus:n,transports:t,config:r}){const s=new Z,i=r.trackUserActionsExcludeItem;let a;n.subscribe((n=>{if(K!==n.type&&X!==n.type){if(n.type===W){const{id:r,name:o}=n;return s.flushBuffer((n=>{if(function(n,t){return(null==t?void 0:t(n))||n.type===e.TransportItemType.MEASUREMENT&&"web-vitals"===n.payload.type}(n,i))return void t.execute(n);const s=Object.assign(Object.assign({},n),{payload:Object.assign(Object.assign({},n.payload),{action:{parentId:r,name:o}})});t.execute(s)})),void(a=void 0)}n.type===H&&(a=void 0,s.flushBuffer((e=>{t.execute(e)})))}else a=n}));return{actionBuffer:s,getMessage:()=>a}}const ne=new A;function te(n,t,r,a,o){t.debug("Initializing API");const{actionBuffer:u,getMessage:l}=ee({apiMessageBus:ne,transports:o,config:r}),c=function(n,t,r,s,i){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:s.value};t.debug("Pushing trace\n",r),i.execute(r)}catch(e){t.error("Error pushing trace\n",e)}}}}(0,t,0,a,o),g={unpatchedConsole:n,internalLogger:t,config:r,metas:a,transports:o,tracesApi:c,actionBuffer:u,getMessage:l};return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},c),Q(g)),function({internalLogger:e,metas:n}){let t,r,s,a;e.debug("Initializing meta API");const o=e=>{r&&n.remove(r),r={user:e},n.add(r)},u=(e,r)=>{var s;const i=null==r?void 0:r.overrides,a=i?{overrides:Object.assign(Object.assign({},null===(s=null==t?void 0:t.session)||void 0===s?void 0:s.overrides),i)}:{};t&&n.remove(t),t={session:Object.assign(Object.assign({},b(e)?void 0:e),a)},n.add(t)},l=()=>n.value.session,c=()=>n.value.page;return{setUser:o,resetUser:o,setSession:u,resetSession:u,getSession:l,setView:(e,t)=>{var r;if((null==t?void 0:t.overrides)&&u(l(),{overrides:t.overrides}),(null===(r=null==s?void 0:s.view)||void 0===r?void 0:r.name)===(null==e?void 0:e.name))return;const i=s;s={view:e},n.add(s),i&&n.remove(i)},getView:()=>n.value.view,setPage:e=>{var t;const r=i(e)?Object.assign(Object.assign({},null!==(t=null==a?void 0:a.page)&&void 0!==t?t:c()),{id:e}):e;a&&n.remove(a),a={page:r},n.add(a)},getPage:c}}(g)),function({internalLogger:n,config:t,metas:r,transports:i,tracesApi:a,actionBuffer:o,getMessage:u}){var l;n.debug("Initializing logs API");let c=null;const g=null!==(l=t.logArgsSerializer)&&void 0!==l?l:Y;return{pushLog:(l,{context:d,level:p,skipDedupe:f,spanContext:E,timestampOverwriteMs:I}={})=>{try{const O=j(d),T={type:e.TransportItemType.LOG,payload:{message:g(l),level:null!=p?p:y,context:b(O)?void 0:O,timestamp:I?h(I):v(),trace:E?{trace_id:E.traceId,span_id:E.spanId}:a.getTraceContext()},meta:r.value},L={message:T.payload.message,level:T.payload.level,context:T.payload.context};if(!f&&t.dedupe&&!s(c)&&m(L,c))return void n.debug("Skipping log push because it is the same as the last one\n",T.payload);c=L,n.debug("Pushing log\n",T);const S=u();S&&S.type===K?o.addItem(T):i.execute(T)}catch(e){n.error("Error pushing log\n",e)}}}}(g)),function({internalLogger:n,config:t,metas:r,transports:i,tracesApi:a,actionBuffer:o,getMessage:u}){n.debug("Initializing measurements API");let l=null;return{pushMeasurement:(c,{skipDedupe:g,context:d,spanContext:p,timestampOverwriteMs:f}={})=>{try{const E=j(d),y={type:e.TransportItemType.MEASUREMENT,payload:Object.assign(Object.assign({},c),{trace:p?{trace_id:p.traceId,span_id:p.spanId}:a.getTraceContext(),timestamp:f?h(f):v(),context:b(E)?void 0:E}),meta:r.value},I={type:y.payload.type,values:y.payload.values,context:y.payload.context};if(!g&&t.dedupe&&!s(l)&&m(I,l))return void n.debug("Skipping measurement push because it is the same as the last one\n",y.payload);l=I,n.debug("Pushing measurement\n",y);const O=u();O&&O.type===K?o.addItem(y):i.execute(y)}catch(e){n.error("Error pushing measurement\n",e)}}}}(g)),function({internalLogger:n,config:t,metas:r,transports:i,tracesApi:a,actionBuffer:o,getMessage:u}){let l=null;return{pushEvent:(c,g,d,{skipDedupe:p,spanContext:f,timestampOverwriteMs:E,customPayloadTransformer:y=e=>e}={})=>{try{const I=j(g),O={meta:r.value,payload:y({name:c,domain:null!=d?d:t.eventDomain,attributes:b(I)?void 0:I,timestamp:E?h(E):v(),trace:f?{trace_id:f.traceId,span_id:f.spanId}:a.getTraceContext()}),type:e.TransportItemType.EVENT},T={name:O.payload.name,attributes:O.payload.attributes,domain:O.payload.domain};if(!p&&t.dedupe&&!s(l)&&m(T,l))return void n.debug("Skipping event push because it is the same as the last one\n",O.payload);l=T,n.debug("Pushing event\n",O);const L=u();L&&L.type===K?o.addItem(O):i.execute(O)}catch(e){n.error("Error pushing event",e)}}}}(g))}const re="1.18.2";const se="_faroInternal";function ie(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(L,se,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function ae(){return se in L}function oe(n,t,r,s,i,a,o){return t.debug("Initializing Faro"),e.faro={api:a,config:r,instrumentations:o,internalLogger:t,metas:s,pause:i.pause,transports:i,unpatchedConsole:n,unpause:i.unpause},ie(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 L)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(L,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}(e.faro),e.faro}e.faro={};return e.BaseExtension=$,e.BaseInstrumentation=class extends ${constructor(){super(...arguments),this.api={},this.transports={}}},e.BaseTransport=class extends ${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_OVERRIDES_SERVICE_NAME="service_name_override",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.Observable=A,e.USER_ACTION_CANCEL=H,e.USER_ACTION_END=W,e.USER_ACTION_HALT=X,e.USER_ACTION_START=K,e.VERSION=re,e.allLogLevels=I,e.apiMessageBus=ne,e.createInternalLogger=V,e.createPromiseBuffer=function(e){const{size:n,concurrency:t}=e,r=[];let s=0;const i=()=>{if(s<t&&r.length){const{producer:e,resolve:n,reject:t}=r.shift();s++,e().then((e=>{s--,i(),n(e)}),(e=>{s--,i(),t(e)}))}};return{add:e=>{if(r.length+s>=n)throw new Error("Task buffer full");return new Promise(((n,t)=>{r.push({producer:e,resolve:n,reject:t}),i()}))}}},e.dateNow=function(){return Date.now()},e.deepEqual=m,e.defaultBatchingConfig={enabled:!0,sendTimeout:250,itemLimit:50},e.defaultErrorArgsSerializer=e=>e.map((e=>o(e)?N(e):String(e))).join(" "),e.defaultExceptionType=J,e.defaultGlobalObjectKey="faro",e.defaultInternalLoggerLevel=M,e.defaultLogArgsSerializer=Y,e.defaultLogLevel=y,e.defaultUnpatchedConsole=P,e.genShortID=function(e=10){return Array.from(Array(e)).map((()=>T[Math.floor(59*Math.random())])).join("")},e.getCircularDependencyReplacer=S,e.getCurrentTimestamp=v,e.getInternalFaroFromGlobalObject=function(){return L[se]},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=w[n.type],s=t[r];t=Object.assign(Object.assign({},t),{[r]:void 0===s?[n.payload]:[...s,n.payload]});break;case e.TransportItemType.TRACE:t=Object.assign(Object.assign({},t),{traces:z(t.traces,n.payload.resourceSpans)})}})),t},e.globalObject=L,e.initializeFaro=function(e){const n=F(e),t=G(n,e);if(ae()&&!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){let t=[],r=[];const s=()=>t.reduce(((e,n)=>Object.assign(e,u(n)?n():n)),{}),i=()=>{if(r.length){const e=s();r.forEach((n=>n(e)))}};return{add:(...e)=>{n.debug("Adding metas\n",e),t.push(...e),i()},remove:(...e)=>{n.debug("Removing metas\n",e),t=t.filter((n=>!e.includes(n))),i()},addListener:e=>{n.debug("Adding metas listener\n",e),r.push(e)},removeListener:e=>{n.debug("Removing metas listener\n",e),r=r.filter((n=>n!==e))},get value(){return s()}}}(0,t),s=C(n,t,e,r),i=te(n,t,e,r,s),a=function(e,n,t,r,s,i){n.debug("Initializing instrumentations");const a=[];return{add:(...o)=>{n.debug("Adding instrumentations"),o.forEach((o=>{n.debug(`Adding "${o.name}" instrumentation`),a.some((e=>e.name===o.name))?n.warn(`Instrumentation ${o.name} is already added`):(o.unpatchedConsole=e,o.internalLogger=n,o.config=t,o.metas=r,o.transports=s,o.api=i,a.push(o),o.initialize())}))},get instrumentations(){return[...a]},remove:(...e)=>{n.debug("Removing instrumentations"),e.forEach((e=>{var t,r;n.debug(`Removing "${e.name}" instrumentation`);const s=a.reduce(((n,t,r)=>null===n&&t.name===e.name?r:null),null);s?(null===(r=(t=a[s]).destroy)||void 0===r||r.call(t),a.splice(s,1)):n.warn(`Instrumentation "${e.name}" is not added`)}))}}}(n,t,e,r,s,i),o=oe(n,t,e,r,s,i,a);return function(e){var n,t;const r={sdk:{version:re},app:{bundleId:e.config.app.name&&(s=e.config.app.name,null==L?void 0:L[`__faroBundleId_${s}`])}};var s;const i=null===(n=e.config.sessionTracking)||void 0===n?void 0:n.session;i&&e.api.setSession(i),e.config.app&&(r.app=Object.assign(Object.assign({},e.config.app),r.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:[])}(o),function(e){e.transports.add(...e.config.transports),e.transports.addBeforeSendHooks(e.config.beforeSend)}(o),function(e){e.instrumentations.add(...e.config.instrumentations)}(o),o},e.internalGlobalObjectKey=se,e.isArray=l,e.isBoolean=e=>n(e,"boolean"),e.isDomError=e=>t(e,"DOMError"),e.isDomException=e=>t(e,"DOMException"),e.isElement=e=>p&&r(e,Element),e.isElementDefined=p,e.isEmpty=b,e.isError=d,e.isErrorDefined=g,e.isErrorEvent=e=>t(e,"ErrorEvent"),e.isEvent=e=>c&&r(e,Event),e.isEventDefined=c,e.isFunction=u,e.isInstanceOf=r,e.isInt=e=>a(e)&&Number.isInteger(e),e.isInternalFaroOnGlobalObject=ae,e.isMap=e=>f&&r(e,Map),e.isMapDefined=f,e.isNull=s,e.isNumber=a,e.isObject=o,e.isPrimitive=e=>!o(e)&&!u(e),e.isRegExp=e=>t(e,"RegExp"),e.isString=i,e.isSymbol=e=>n(e,"symbol"),e.isSyntheticEvent=e=>o(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e,e.isThenable=e=>u(null==e?void 0:e.then),e.isToString=t,e.isTypeof=n,e.isUndefined=e=>n(e,"undefined"),e.noop=O,e.setInternalFaroOnGlobalObject=ie,e.stringifyExternalJson=N,e.stringifyObjectValues=j,e.transportItemTypeToBodyKey=w,e.unknownString="unknown",e}({});
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 s=e=>n(e,"null"),i=e=>n(e,"string"),a=e=>n(e,"number")&&!isNaN(e)||n(e,"bigint"),o=e=>!s(e)&&n(e,"object"),u=e=>n(e,"function"),l=e=>t(e,"Array"),c="undefined"!=typeof Event,g="undefined"!=typeof Error,d=e=>g&&r(e,Error),p="undefined"!=typeof Element,f="undefined"!=typeof Map;function b(e){return null==e||(l(e)||i(e)?0===e.length:!!o(e)&&0===Object.keys(e).length)}function m(e,t){if(e===t)return!0;if(n(e,"number")&&isNaN(e))return n(t,"number")&&isNaN(t);const r=l(e),s=l(t);if(r!==s)return!1;if(r&&s){const n=e.length;if(n!==t.length)return!1;for(let r=n;0!=r--;)if(!m(e[r],t[r]))return!1;return!0}const i=o(e),a=o(t);if(i!==a)return!1;if(e&&t&&i&&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(!m(e[r],t[r]))return!1;return!0}return!1}function v(){return(new Date).toISOString()}function h(e){return new Date(e).toISOString()}var E;e.LogLevel=void 0,(E=e.LogLevel||(e.LogLevel={})).TRACE="trace",E.DEBUG="debug",E.INFO="info",E.LOG="log",E.WARN="warn",E.ERROR="error";const y=e.LogLevel.LOG,I=[e.LogLevel.TRACE,e.LogLevel.DEBUG,e.LogLevel.INFO,e.LogLevel.LOG,e.LogLevel.WARN,e.LogLevel.ERROR];function O(){}const T="abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789";const L="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:void 0;function S(){const e=new WeakSet;return function(n,t){if(o(t)&&null!==t){if(e.has(t))return null;e.add(t)}return t}}function N(e={}){return JSON.stringify(null!=e?e:{},S())}function j(e={}){const n={};for(const[t,r]of Object.entries(e))n[t]=o(r)&&null!==r?N(r):String(r);return n}class A{constructor(){this.subscribers=[]}subscribe(e){return this.subscribers.push(e),{unsubscribe:()=>this.unsubscribe(e)}}unsubscribe(e){this.subscribers=this.subscribers.filter((n=>n!==e))}notify(e){this.subscribers.forEach((n=>n(e)))}first(){const e=new A,n=n=>{e.notify(n),t.unsubscribe()},t=this.subscribe(n),r=e.unsubscribe.bind(e);return this.withUnsubscribeOverride(e,r,n)}takeWhile(e){const n=new A,t=r=>{e(r)?n.notify(r):n.unsubscribe(t)};this.subscribe(t);const r=n.unsubscribe.bind(n);return this.withUnsubscribeOverride(n,r,t)}filter(e){const n=new A,t=t=>{e(t)&&n.notify(t)};this.subscribe(t);const r=n.unsubscribe.bind(n);return this.withUnsubscribeOverride(n,r,t)}merge(...e){const n=new A,t=[];e.forEach((e=>{const r=e.subscribe((e=>{n.notify(e)}));t.push(r)}));const r=n.unsubscribeAll.bind(n);return n.unsubscribe=()=>{t.forEach((e=>e.unsubscribe())),r()},n}withUnsubscribeOverride(e,n,t){return e.unsubscribe=e=>{n(e),this.unsubscribe(t)},e}unsubscribeAll(){this.subscribers=[]}}class R{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 x;e.TransportItemType=void 0,(x=e.TransportItemType||(e.TransportItemType={})).EXCEPTION="exception",x.LOG="log",x.MEASUREMENT="measurement",x.TRACE="trace",x.EVENT="event";const w={[e.TransportItemType.EXCEPTION]:"exceptions",[e.TransportItemType.LOG]:"logs",[e.TransportItemType.MEASUREMENT]:"measurements",[e.TransportItemType.TRACE]:"traces",[e.TransportItemType.EVENT]:"events"};function C(e,n,t,r){var s;n.debug("Initializing transports");const i=[];let a=t.paused,o=[];const u=e=>{let n=e;for(const e of o){const r=n.map(e).filter(Boolean);if(0===r.length)return[];n=_(r,t)}return n},l=e=>{const t=u(e);if(0!==t.length)for(const e of i)n.debug(`Transporting item using ${e.name}\n`,t),e.isBatched()&&e.send(t)};let c;(null===(s=t.batching)||void 0===s?void 0:s.enabled)&&(c=new R(l,{sendTimeout:t.batching.sendTimeout,itemLimit:t.batching.itemLimit,paused:a}));return{add:(...s)=>{n.debug("Adding transports"),s.forEach((s=>{n.debug(`Adding "${s.name}" transport`);i.some((e=>e===s))?n.warn(`Transport ${s.name} is already added`):(s.unpatchedConsole=e,s.internalLogger=n,s.config=t,s.metas=r,i.push(s))}))},addBeforeSendHooks:(...e)=>{n.debug("Adding beforeSendHooks\n",o),e.forEach((e=>{e&&o.push(e)}))},getBeforeSendHooks:()=>[...o],execute:e=>{var r;a||((null===(r=t.batching)||void 0===r?void 0:r.enabled)&&(null==c||c.addItem(e)),(e=>{var r,s;if((null===(r=t.batching)||void 0===r?void 0:r.enabled)&&i.every((e=>e.isBatched())))return;const[a]=u([e]);if(void 0!==a)for(const e of i)n.debug(`Transporting item using ${e.name}\n`,a),e.isBatched()?(null===(s=t.batching)||void 0===s?void 0:s.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=i.indexOf(e);-1!==t?i.splice(t,1):n.warn(`Transport "${e.name}" is not added`)}))},removeBeforeSendHooks:(...e)=>{o.filter((n=>!e.includes(n)))},get transports(){return[...i]},unpause:()=>{n.debug("Unpausing transports"),null==c||c.start(),a=!1}}}function _(n,t){if(t.preserveOriginalError)for(const t of n)t.type===e.TransportItemType.EXCEPTION&&delete t.payload.originalError;return n}var k;e.InternalLoggerLevel=void 0,(k=e.InternalLoggerLevel||(e.InternalLoggerLevel={}))[k.OFF=0]="OFF",k[k.ERROR=1]="ERROR",k[k.WARN=2]="WARN",k[k.INFO=3]="INFO",k[k.VERBOSE=4]="VERBOSE";const B={debug:O,error:O,info:O,prefix:"Faro",warn:O},M=e.InternalLoggerLevel.ERROR,P=Object.assign({},console);let D=P;function F(e){var n;return D=null!==(n=e.unpatchedConsole)&&void 0!==n?n:D,D}function V(n=P,t=M){const r=B;return t>e.InternalLoggerLevel.OFF&&(r.error=t>=e.InternalLoggerLevel.ERROR?function(...e){n.error(`${r.prefix}\n`,...e)}:O,r.warn=t>=e.InternalLoggerLevel.WARN?function(...e){n.warn(`${r.prefix}\n`,...e)}:O,r.info=t>=e.InternalLoggerLevel.INFO?function(...e){n.info(`${r.prefix}\n`,...e)}:O,r.debug=t>=e.InternalLoggerLevel.VERBOSE?function(...e){n.debug(`${r.prefix}\n`,...e)}:O),r}let U=B;function G(e,n){return U=V(e,n.internalLoggerLevel),U}class ${constructor(){this.unpatchedConsole=P,this.internalLogger=B,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 z(e,n){var t,r;if(void 0===n)return e;if(void 0===e)return{resourceSpans:n};const s=null===(t=e.resourceSpans)||void 0===t?void 0:t[0];if(void 0===s)return e;const i=(null==s?void 0:s.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({},s),{scopeSpans:[...i,...a]})]})}const K="user-action-start",W="user-action-end",H="user-action-cancel",X="user-action-halt";const J="Error";let q;function Q({internalLogger:n,config:t,metas:r,transports:a,tracesApi:u,actionBuffer:c,getMessage:g}){var p;n.debug("Initializing exceptions API");let f=null;q=null!==(p=t.parseStacktrace)&&void 0!==p?p:q;const E=e=>{n.debug("Changing stacktrace parser"),q=null!=e?e:q},{ignoreErrors:y=[],preserveOriginalError:I}=t;return E(t.parseStacktrace),{changeStacktraceParser:E,getStacktraceParser:()=>q,pushError:(p,{skipDedupe:E,stackFrames:O,type:T,context:L,spanContext:S,timestampOverwriteMs:A,originalError:R}={})=>{if(!function(e,n){const{message:t,name:r,stack:s}=n;return a=e,o=t+" "+r+" "+s,a.some((e=>i(e)?o.includes(e):!!o.match(e)));var a,o}(y,null!=R?R:p))try{const i=j(Object.assign(Object.assign({},function(e){let n=e.cause;d(n)?n=e.cause.toString():null!==n&&(o(e.cause)||l(e.cause))?n=N(e.cause):null!=n&&(n=e.cause.toString());return null==n?{}:{cause:n}}(null!=R?R:p)),null!=L?L:{})),y={meta:r.value,payload:Object.assign(Object.assign({type:T||p.name||J,value:p.message,timestamp:A?h(A):v(),trace:S?{trace_id:S.traceId,span_id:S.spanId}:u.getTraceContext()},b(i)?{}:{context:i}),I?{originalError:R}:{}),type:e.TransportItemType.EXCEPTION};(null==(O=null!=O?O:p.stack?null==q?void 0:q(p).frames:void 0)?void 0:O.length)&&(y.payload.stacktrace={frames:O});const x={type:y.payload.type,value:y.payload.value,stackTrace:y.payload.stacktrace,context:y.payload.context};if(!E&&t.dedupe&&!s(f)&&m(x,f))return void n.debug("Skipping error push because it is the same as the last one\n",y.payload);f=x,n.debug("Pushing exception\n",y);const w=g();w&&w.type===K?c.addItem(y):a.execute(y)}catch(e){n.error("Error pushing event",e)}}}}const Y=e=>e.map((e=>{try{return String(e)}catch(e){return""}})).join(" ");class Z{constructor(){this.buffer=[]}addItem(e){this.buffer.push(e)}flushBuffer(e){if(u(e))for(const n of this.buffer)e(n);this.buffer.length=0}size(){return this.buffer.length}}function ee({apiMessageBus:n,transports:t,config:r}){const s=new Z,i=r.trackUserActionsExcludeItem;let a;n.subscribe((n=>{if(K!==n.type&&X!==n.type){if(n.type===W){const{id:r,name:o}=n;return s.flushBuffer((n=>{if(function(n,t){return(null==t?void 0:t(n))||n.type===e.TransportItemType.MEASUREMENT&&"web-vitals"===n.payload.type}(n,i))return void t.execute(n);const s=Object.assign(Object.assign({},n),{payload:Object.assign(Object.assign({},n.payload),{action:{parentId:r,name:o}})});t.execute(s)})),void(a=void 0)}n.type===H&&(a=void 0,s.flushBuffer((e=>{t.execute(e)})))}else a=n}));return{actionBuffer:s,getMessage:()=>a}}const ne=new A;function te(n,t,r,a,o){t.debug("Initializing API");const{actionBuffer:u,getMessage:l}=ee({apiMessageBus:ne,transports:o,config:r}),c=function(n,t,r,s,i){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:s.value};t.debug("Pushing trace\n",r),i.execute(r)}catch(e){t.error("Error pushing trace\n",e)}}}}(0,t,0,a,o),g={unpatchedConsole:n,internalLogger:t,config:r,metas:a,transports:o,tracesApi:c,actionBuffer:u,getMessage:l};return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},c),Q(g)),function({internalLogger:e,metas:n}){let t,r,s,a;e.debug("Initializing meta API");const o=e=>{r&&n.remove(r),r={user:e},n.add(r)},u=(e,r)=>{var s;const i=null==r?void 0:r.overrides,a=i?{overrides:Object.assign(Object.assign({},null===(s=null==t?void 0:t.session)||void 0===s?void 0:s.overrides),i)}:{};t&&n.remove(t),t={session:Object.assign(Object.assign({},b(e)?void 0:e),a)},n.add(t)},l=()=>n.value.session,c=()=>n.value.page;return{setUser:o,resetUser:o,setSession:u,resetSession:u,getSession:l,setView:(e,t)=>{var r;if((null==t?void 0:t.overrides)&&u(l(),{overrides:t.overrides}),(null===(r=null==s?void 0:s.view)||void 0===r?void 0:r.name)===(null==e?void 0:e.name))return;const i=s;s={view:e},n.add(s),i&&n.remove(i)},getView:()=>n.value.view,setPage:e=>{var t;const r=i(e)?Object.assign(Object.assign({},null!==(t=null==a?void 0:a.page)&&void 0!==t?t:c()),{id:e}):e;a&&n.remove(a),a={page:r},n.add(a)},getPage:c}}(g)),function({internalLogger:n,config:t,metas:r,transports:i,tracesApi:a,actionBuffer:o,getMessage:u}){var l;n.debug("Initializing logs API");let c=null;const g=null!==(l=t.logArgsSerializer)&&void 0!==l?l:Y;return{pushLog:(l,{context:d,level:p,skipDedupe:f,spanContext:E,timestampOverwriteMs:I}={})=>{try{const O=j(d),T={type:e.TransportItemType.LOG,payload:{message:g(l),level:null!=p?p:y,context:b(O)?void 0:O,timestamp:I?h(I):v(),trace:E?{trace_id:E.traceId,span_id:E.spanId}:a.getTraceContext()},meta:r.value},L={message:T.payload.message,level:T.payload.level,context:T.payload.context};if(!f&&t.dedupe&&!s(c)&&m(L,c))return void n.debug("Skipping log push because it is the same as the last one\n",T.payload);c=L,n.debug("Pushing log\n",T);const S=u();S&&S.type===K?o.addItem(T):i.execute(T)}catch(e){n.error("Error pushing log\n",e)}}}}(g)),function({internalLogger:n,config:t,metas:r,transports:i,tracesApi:a,actionBuffer:o,getMessage:u}){n.debug("Initializing measurements API");let l=null;return{pushMeasurement:(c,{skipDedupe:g,context:d,spanContext:p,timestampOverwriteMs:f}={})=>{try{const E=j(d),y={type:e.TransportItemType.MEASUREMENT,payload:Object.assign(Object.assign({},c),{trace:p?{trace_id:p.traceId,span_id:p.spanId}:a.getTraceContext(),timestamp:f?h(f):v(),context:b(E)?void 0:E}),meta:r.value},I={type:y.payload.type,values:y.payload.values,context:y.payload.context};if(!g&&t.dedupe&&!s(l)&&m(I,l))return void n.debug("Skipping measurement push because it is the same as the last one\n",y.payload);l=I,n.debug("Pushing measurement\n",y);const O=u();O&&O.type===K?o.addItem(y):i.execute(y)}catch(e){n.error("Error pushing measurement\n",e)}}}}(g)),function({internalLogger:n,config:t,metas:r,transports:i,tracesApi:a,actionBuffer:o,getMessage:u}){let l=null;return{pushEvent:(c,g,d,{skipDedupe:p,spanContext:f,timestampOverwriteMs:E,customPayloadTransformer:y=e=>e}={})=>{try{const I=j(g),O={meta:r.value,payload:y({name:c,domain:null!=d?d:t.eventDomain,attributes:b(I)?void 0:I,timestamp:E?h(E):v(),trace:f?{trace_id:f.traceId,span_id:f.spanId}:a.getTraceContext()}),type:e.TransportItemType.EVENT},T={name:O.payload.name,attributes:O.payload.attributes,domain:O.payload.domain};if(!p&&t.dedupe&&!s(l)&&m(T,l))return void n.debug("Skipping event push because it is the same as the last one\n",O.payload);l=T,n.debug("Pushing event\n",O);const L=u();L&&L.type===K?o.addItem(O):i.execute(O)}catch(e){n.error("Error pushing event",e)}}}}(g))}const re="1.19.0";const se="_faroInternal";function ie(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(L,se,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function ae(){return se in L}function oe(n,t,r,s,i,a,o){return t.debug("Initializing Faro"),e.faro={api:a,config:r,instrumentations:o,internalLogger:t,metas:s,pause:i.pause,transports:i,unpatchedConsole:n,unpause:i.unpause},ie(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 L)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(L,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}(e.faro),e.faro}e.faro={};return e.BaseExtension=$,e.BaseInstrumentation=class extends ${constructor(){super(...arguments),this.api={},this.transports={}}},e.BaseTransport=class extends ${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_OVERRIDES_SERVICE_NAME="service_name_override",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.Observable=A,e.USER_ACTION_CANCEL=H,e.USER_ACTION_END=W,e.USER_ACTION_HALT=X,e.USER_ACTION_START=K,e.VERSION=re,e.allLogLevels=I,e.apiMessageBus=ne,e.createInternalLogger=V,e.createPromiseBuffer=function(e){const{size:n,concurrency:t}=e,r=[];let s=0;const i=()=>{if(s<t&&r.length){const{producer:e,resolve:n,reject:t}=r.shift();s++,e().then((e=>{s--,i(),n(e)}),(e=>{s--,i(),t(e)}))}};return{add:e=>{if(r.length+s>=n)throw new Error("Task buffer full");return new Promise(((n,t)=>{r.push({producer:e,resolve:n,reject:t}),i()}))}}},e.dateNow=function(){return Date.now()},e.deepEqual=m,e.defaultBatchingConfig={enabled:!0,sendTimeout:250,itemLimit:50},e.defaultErrorArgsSerializer=e=>e.map((e=>o(e)?N(e):String(e))).join(" "),e.defaultExceptionType=J,e.defaultGlobalObjectKey="faro",e.defaultInternalLoggerLevel=M,e.defaultLogArgsSerializer=Y,e.defaultLogLevel=y,e.defaultUnpatchedConsole=P,e.genShortID=function(e=10){return Array.from(Array(e)).map((()=>T[Math.floor(59*Math.random())])).join("")},e.getCircularDependencyReplacer=S,e.getCurrentTimestamp=v,e.getInternalFaroFromGlobalObject=function(){return L[se]},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=w[n.type],s=t[r];t=Object.assign(Object.assign({},t),{[r]:void 0===s?[n.payload]:[...s,n.payload]});break;case e.TransportItemType.TRACE:t=Object.assign(Object.assign({},t),{traces:z(t.traces,n.payload.resourceSpans)})}})),t},e.globalObject=L,e.initializeFaro=function(e){const n=F(e),t=G(n,e);if(ae()&&!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){let t=[],r=[];const s=()=>t.reduce(((e,n)=>Object.assign(e,u(n)?n():n)),{}),i=()=>{if(r.length){const e=s();r.forEach((n=>n(e)))}};return{add:(...e)=>{n.debug("Adding metas\n",e),t.push(...e),i()},remove:(...e)=>{n.debug("Removing metas\n",e),t=t.filter((n=>!e.includes(n))),i()},addListener:e=>{n.debug("Adding metas listener\n",e),r.push(e)},removeListener:e=>{n.debug("Removing metas listener\n",e),r=r.filter((n=>n!==e))},get value(){return s()}}}(0,t),s=C(n,t,e,r),i=te(n,t,e,r,s),a=function(e,n,t,r,s,i){n.debug("Initializing instrumentations");const a=[];return{add:(...o)=>{n.debug("Adding instrumentations"),o.forEach((o=>{n.debug(`Adding "${o.name}" instrumentation`),a.some((e=>e.name===o.name))?n.warn(`Instrumentation ${o.name} is already added`):(o.unpatchedConsole=e,o.internalLogger=n,o.config=t,o.metas=r,o.transports=s,o.api=i,a.push(o),o.initialize())}))},get instrumentations(){return[...a]},remove:(...e)=>{n.debug("Removing instrumentations"),e.forEach((e=>{var t,r;n.debug(`Removing "${e.name}" instrumentation`);const s=a.reduce(((n,t,r)=>null===n&&t.name===e.name?r:null),null);null!==s?(null===(r=(t=a[s]).destroy)||void 0===r||r.call(t),a.splice(s,1)):n.warn(`Instrumentation "${e.name}" is not added`)}))}}}(n,t,e,r,s,i),o=oe(n,t,e,r,s,i,a);return function(e){var n,t;const r={sdk:{version:re},app:{bundleId:e.config.app.name&&(s=e.config.app.name,null==L?void 0:L[`__faroBundleId_${s}`])}};var s;const i=null===(n=e.config.sessionTracking)||void 0===n?void 0:n.session;i&&e.api.setSession(i),e.config.app&&(r.app=Object.assign(Object.assign({},e.config.app),r.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:[])}(o),function(e){e.transports.add(...e.config.transports),e.transports.addBeforeSendHooks(e.config.beforeSend)}(o),function(e){e.instrumentations.add(...e.config.instrumentations)}(o),o},e.internalGlobalObjectKey=se,e.isArray=l,e.isBoolean=e=>n(e,"boolean"),e.isDomError=e=>t(e,"DOMError"),e.isDomException=e=>t(e,"DOMException"),e.isElement=e=>p&&r(e,Element),e.isElementDefined=p,e.isEmpty=b,e.isError=d,e.isErrorDefined=g,e.isErrorEvent=e=>t(e,"ErrorEvent"),e.isEvent=e=>c&&r(e,Event),e.isEventDefined=c,e.isFunction=u,e.isInstanceOf=r,e.isInt=e=>a(e)&&Number.isInteger(e),e.isInternalFaroOnGlobalObject=ae,e.isMap=e=>f&&r(e,Map),e.isMapDefined=f,e.isNull=s,e.isNumber=a,e.isObject=o,e.isPrimitive=e=>!o(e)&&!u(e),e.isRegExp=e=>t(e,"RegExp"),e.isString=i,e.isSymbol=e=>n(e,"symbol"),e.isSyntheticEvent=e=>o(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e,e.isThenable=e=>u(null==e?void 0:e.then),e.isToString=t,e.isTypeof=n,e.isUndefined=e=>n(e,"undefined"),e.noop=O,e.setInternalFaroOnGlobalObject=ie,e.stringifyExternalJson=N,e.stringifyObjectValues=j,e.transportItemTypeToBodyKey=w,e.unknownString="unknown",e}({});
@@ -4,7 +4,7 @@ import type { Transport, TransportItem } from '../transports';
4
4
  export declare class MockTransport extends BaseTransport implements Transport {
5
5
  private ignoreURLs;
6
6
  readonly name = "@grafana/transport-mock";
7
- readonly version = "1.18.2";
7
+ readonly version = "1.19.0";
8
8
  items: TransportItem[];
9
9
  constructor(ignoreURLs?: Patterns);
10
10
  send(items: TransportItem[]): void | Promise<void>;
@@ -1 +1 @@
1
- export declare const VERSION = "1.18.2";
1
+ export declare const VERSION = "1.19.0";
@@ -51,7 +51,7 @@ function initializeInstrumentations(unpatchedConsole, internalLogger, config, me
51
51
  }
52
52
  return null;
53
53
  }, null);
54
- if (!existingInstrumentationIndex) {
54
+ if (existingInstrumentationIndex === null) {
55
55
  internalLogger.warn("Instrumentation \"".concat(instrumentationToRemove.name, "\" is not added"));
56
56
  return;
57
57
  }
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../src/instrumentations/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;AASA,gEA6EC;AA7ED,SAAgB,0BAA0B,CACxC,gBAAkC,EAClC,cAA8B,EAC9B,MAAc,EACd,KAAY,EACZ,UAAsB,EACtB,GAAQ;IAER,cAAc,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAEtD,IAAM,gBAAgB,GAAsB,EAAE,CAAC;IAE/C,IAAM,GAAG,GAA4B;QAAC,6BAAsB;aAAtB,UAAsB,EAAtB,qBAAsB,EAAtB,IAAsB;YAAtB,wCAAsB;;QAC1D,cAAc,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAEhD,mBAAmB,CAAC,OAAO,CAAC,UAAC,kBAAkB;YAC7C,cAAc,CAAC,KAAK,CAAC,mBAAW,kBAAkB,CAAC,IAAI,uBAAmB,CAAC,CAAC;YAE5E,IAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAClC,UAAC,uBAAuB,IAAK,OAAA,uBAAuB,CAAC,IAAI,KAAK,kBAAkB,CAAC,IAAI,EAAxD,CAAwD,CACtF,CAAC;YAEF,IAAI,MAAM,EAAE,CAAC;gBACX,cAAc,CAAC,IAAI,CAAC,0BAAmB,kBAAkB,CAAC,IAAI,sBAA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AE5D,gBAAgB,CAAC,MAAM,CAAC,4BAA4B,EAAE,CAAC,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO;QACL,GAAG,KAAA;QACH,IAAI,gBAAgB;YAClB,yBAAW,gBAAgB,QAAE;QAC/B,CAAC;QACD,MAAM,QAAA;KACP,CAAC;AACJ,CAAC","sourcesContent":["import type { API } from '../api';\nimport type { Config } from '../config';\nimport type { InternalLogger } from '../internalLogger';\nimport type { Metas } from '../metas';\nimport type { Transports } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\n\nimport type { Instrumentation, Instrumentations } from './types';\n\nexport function initializeInstrumentations(\n unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas,\n transports: Transports,\n api: API\n): Instrumentations {\n internalLogger.debug('Initializing instrumentations');\n\n const instrumentations: Instrumentation[] = [];\n\n const add: Instrumentations['add'] = (...newInstrumentations) => {\n internalLogger.debug('Adding instrumentations');\n\n newInstrumentations.forEach((newInstrumentation) => {\n internalLogger.debug(`Adding \"${newInstrumentation.name}\" instrumentation`);\n\n const exists = instrumentations.some(\n (existingInstrumentation) => existingInstrumentation.name === newInstrumentation.name\n );\n\n if (exists) {\n internalLogger.warn(`Instrumentation ${newInstrumentation.name} is already added`);\n\n return;\n }\n\n newInstrumentation.unpatchedConsole = unpatchedConsole;\n newInstrumentation.internalLogger = internalLogger;\n newInstrumentation.config = config;\n newInstrumentation.metas = metas;\n newInstrumentation.transports = transports;\n newInstrumentation.api = api;\n\n instrumentations.push(newInstrumentation);\n\n newInstrumentation.initialize();\n });\n };\n\n const remove: Instrumentations['remove'] = (...instrumentationsToRemove) => {\n internalLogger.debug('Removing instrumentations');\n\n instrumentationsToRemove.forEach((instrumentationToRemove) => {\n internalLogger.debug(`Removing \"${instrumentationToRemove.name}\" instrumentation`);\n\n const existingInstrumentationIndex = instrumentations.reduce<number | null>(\n (acc, existingInstrumentation, existingTransportIndex) => {\n if (acc === null && existingInstrumentation.name === instrumentationToRemove.name) {\n return existingTransportIndex;\n }\n\n return null;\n },\n null\n );\n\n if (!existingInstrumentationIndex) {\n internalLogger.warn(`Instrumentation \"${instrumentationToRemove.name}\" is not added`);\n\n return;\n }\n\n instrumentations[existingInstrumentationIndex]!.destroy?.();\n\n instrumentations.splice(existingInstrumentationIndex, 1);\n });\n };\n\n return {\n add,\n get instrumentations() {\n return [...instrumentations];\n },\n remove,\n };\n}\n"]}
1
+ {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../src/instrumentations/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;AASA,gEA6EC;AA7ED,SAAgB,0BAA0B,CACxC,gBAAkC,EAClC,cAA8B,EAC9B,MAAc,EACd,KAAY,EACZ,UAAsB,EACtB,GAAQ;IAER,cAAc,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAEtD,IAAM,gBAAgB,GAAsB,EAAE,CAAC;IAE/C,IAAM,GAAG,GAA4B;QAAC,6BAAsB;aAAtB,UAAsB,EAAtB,qBAAsB,EAAtB,IAAsB;YAAtB,wCAAsB;;QAC1D,cAAc,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAEhD,mBAAmB,CAAC,OAAO,CAAC,UAAC,kBAAkB;YAC7C,cAAc,CAAC,KAAK,CAAC,mBAAW,kBAAkB,CAAC,IAAI,uBAAmB,CAAC,CAAC;YAE5E,IAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAClC,UAAC,uBAAuB,IAAK,OAAA,uBAAuB,CAAC,IAAI,KAAK,kBAAkB,CAAC,IAAI,EAAxD,CAAwD,CACtF,CAAC;YAEF,IAAI,MAAM,EAAE,CAAC;gBACX,cAAc,CAAC,IAAI,CAAC,0BAAmB,kBAAkB,CAAC,IAAI,sBAAmB,CAAC,CAAC;gBAEnF,OAAO;YACT,CAAC;YAED,kBAAkB,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;YACvD,kBAAkB,CAAC,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AAC;IAEF,OAAO;QACL,GAAG,KAAA;QACH,IAAI,gBAAgB;YAClB,yBAAW,gBAAgB,QAAE;QAC/B,CAAC;QACD,MAAM,QAAA;KACP,CAAC;AACJ,CAAC","sourcesContent":["import type { API } from '../api';\nimport type { Config } from '../config';\nimport type { InternalLogger } from '../internalLogger';\nimport type { Metas } from '../metas';\nimport type { Transports } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\n\nimport type { Instrumentation, Instrumentations } from './types';\n\nexport function initializeInstrumentations(\n unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas,\n transports: Transports,\n api: API\n): Instrumentations {\n internalLogger.debug('Initializing instrumentations');\n\n const instrumentations: Instrumentation[] = [];\n\n const add: Instrumentations['add'] = (...newInstrumentations) => {\n internalLogger.debug('Adding instrumentations');\n\n newInstrumentations.forEach((newInstrumentation) => {\n internalLogger.debug(`Adding \"${newInstrumentation.name}\" instrumentation`);\n\n const exists = instrumentations.some(\n (existingInstrumentation) => existingInstrumentation.name === newInstrumentation.name\n );\n\n if (exists) {\n internalLogger.warn(`Instrumentation ${newInstrumentation.name} is already added`);\n\n return;\n }\n\n newInstrumentation.unpatchedConsole = unpatchedConsole;\n newInstrumentation.internalLogger = internalLogger;\n newInstrumentation.config = config;\n newInstrumentation.metas = metas;\n newInstrumentation.transports = transports;\n newInstrumentation.api = api;\n\n instrumentations.push(newInstrumentation);\n\n newInstrumentation.initialize();\n });\n };\n\n const remove: Instrumentations['remove'] = (...instrumentationsToRemove) => {\n internalLogger.debug('Removing instrumentations');\n\n instrumentationsToRemove.forEach((instrumentationToRemove) => {\n internalLogger.debug(`Removing \"${instrumentationToRemove.name}\" instrumentation`);\n\n const existingInstrumentationIndex = instrumentations.reduce<number | null>(\n (acc, existingInstrumentation, existingTransportIndex) => {\n if (acc === null && existingInstrumentation.name === instrumentationToRemove.name) {\n return existingTransportIndex;\n }\n\n return null;\n },\n null\n );\n\n if (existingInstrumentationIndex === null) {\n internalLogger.warn(`Instrumentation \"${instrumentationToRemove.name}\" is not added`);\n\n return;\n }\n\n instrumentations[existingInstrumentationIndex]!.destroy?.();\n\n instrumentations.splice(existingInstrumentationIndex, 1);\n });\n };\n\n return {\n add,\n get instrumentations() {\n return [...instrumentations];\n },\n remove,\n };\n}\n"]}
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // auto-generated by bin/genVersion.ts
5
- exports.VERSION = '1.18.2';
5
+ exports.VERSION = '1.19.0';
6
6
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.18.2';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.19.0';\n"]}
@@ -31,7 +31,7 @@ export function initializeInstrumentations(unpatchedConsole, internalLogger, con
31
31
  }
32
32
  return null;
33
33
  }, null);
34
- if (!existingInstrumentationIndex) {
34
+ if (existingInstrumentationIndex === null) {
35
35
  internalLogger.warn(`Instrumentation "${instrumentationToRemove.name}" is not added`);
36
36
  return;
37
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../src/instrumentations/initialize.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,0BAA0B,CACxC,gBAAkC,EAClC,cAA8B,EAC9B,MAAc,EACd,KAAY,EACZ,UAAsB,EACtB,GAAQ;IAER,cAAc,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAEtD,MAAM,gBAAgB,GAAsB,EAAE,CAAC;IAE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AAC,GAAG,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,EAAE;gBACvD,IAAI,GAAG,KAAK,IAAI,IAAI,uBAAuB,CAAC,IAAI,KAAK,uBAAuB,CAAC,IAAI,EAAE,CAAC;oBAClF,OAAO,sBAAsB,CAAC;gBAChC,CAAC;gBAED,OAAO,IAAI,CAAC;YACd,CAAC,EACD,IAAI,CACL,CAAC;YAEF,IAAI,CAAC,4BAA4B,EAAE,CAAC;gBAClC,cAAc,CAAC,IAAI,CAAC,oBAAoB,uBAAuB,CAAC,IAAI,gBAAgB,CAAC,CAAC;gBAEtF,OAAO;YACT,CAAC;YAED,MAAA,MAAA,gBAAgB,CAAC,4BAA4B,CAAE,EAAC,OAAO,kDAAI,CAAC;YAE5D,gBAAgB,CAAC,MAAM,CAAC,4BAA4B,EAAE,CAAC,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO;QACL,GAAG;QACH,IAAI,gBAAgB;YAClB,OAAO,CAAC,GAAG,gBAAgB,CAAC,CAAC;QAC/B,CAAC;QACD,MAAM;KACP,CAAC;AACJ,CAAC","sourcesContent":["import type { API } from '../api';\nimport type { Config } from '../config';\nimport type { InternalLogger } from '../internalLogger';\nimport type { Metas } from '../metas';\nimport type { Transports } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\n\nimport type { Instrumentation, Instrumentations } from './types';\n\nexport function initializeInstrumentations(\n unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas,\n transports: Transports,\n api: API\n): Instrumentations {\n internalLogger.debug('Initializing instrumentations');\n\n const instrumentations: Instrumentation[] = [];\n\n const add: Instrumentations['add'] = (...newInstrumentations) => {\n internalLogger.debug('Adding instrumentations');\n\n newInstrumentations.forEach((newInstrumentation) => {\n internalLogger.debug(`Adding \"${newInstrumentation.name}\" instrumentation`);\n\n const exists = instrumentations.some(\n (existingInstrumentation) => existingInstrumentation.name === newInstrumentation.name\n );\n\n if (exists) {\n internalLogger.warn(`Instrumentation ${newInstrumentation.name} is already added`);\n\n return;\n }\n\n newInstrumentation.unpatchedConsole = unpatchedConsole;\n newInstrumentation.internalLogger = internalLogger;\n newInstrumentation.config = config;\n newInstrumentation.metas = metas;\n newInstrumentation.transports = transports;\n newInstrumentation.api = api;\n\n instrumentations.push(newInstrumentation);\n\n newInstrumentation.initialize();\n });\n };\n\n const remove: Instrumentations['remove'] = (...instrumentationsToRemove) => {\n internalLogger.debug('Removing instrumentations');\n\n instrumentationsToRemove.forEach((instrumentationToRemove) => {\n internalLogger.debug(`Removing \"${instrumentationToRemove.name}\" instrumentation`);\n\n const existingInstrumentationIndex = instrumentations.reduce<number | null>(\n (acc, existingInstrumentation, existingTransportIndex) => {\n if (acc === null && existingInstrumentation.name === instrumentationToRemove.name) {\n return existingTransportIndex;\n }\n\n return null;\n },\n null\n );\n\n if (!existingInstrumentationIndex) {\n internalLogger.warn(`Instrumentation \"${instrumentationToRemove.name}\" is not added`);\n\n return;\n }\n\n instrumentations[existingInstrumentationIndex]!.destroy?.();\n\n instrumentations.splice(existingInstrumentationIndex, 1);\n });\n };\n\n return {\n add,\n get instrumentations() {\n return [...instrumentations];\n },\n remove,\n };\n}\n"]}
1
+ {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../src/instrumentations/initialize.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,0BAA0B,CACxC,gBAAkC,EAClC,cAA8B,EAC9B,MAAc,EACd,KAAY,EACZ,UAAsB,EACtB,GAAQ;IAER,cAAc,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAEtD,MAAM,gBAAgB,GAAsB,EAAE,CAAC;IAE/C,MAAM,GAAG,GAA4B,CAAC,GAAG,mBAAmB,EAAE,EAAE;QAC9D,cAAc,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAEhD,mBAAmB,CAAC,OAAO,CAAC,CAAC,kBAAkB,EAAE,EAAE;YACjD,cAAc,CAAC,KAA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gBAED,OAAO,IAAI,CAAC;YACd,CAAC,EACD,IAAI,CACL,CAAC;YAEF,IAAI,4BAA4B,KAAK,IAAI,EAAE,CAAC;gBAC1C,cAAc,CAAC,IAAI,CAAC,oBAAoB,uBAAuB,CAAC,IAAI,gBAAgB,CAAC,CAAC;gBAEtF,OAAO;YACT,CAAC;YAED,MAAA,MAAA,gBAAgB,CAAC,4BAA4B,CAAE,EAAC,OAAO,kDAAI,CAAC;YAE5D,gBAAgB,CAAC,MAAM,CAAC,4BAA4B,EAAE,CAAC,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO;QACL,GAAG;QACH,IAAI,gBAAgB;YAClB,OAAO,CAAC,GAAG,gBAAgB,CAAC,CAAC;QAC/B,CAAC;QACD,MAAM;KACP,CAAC;AACJ,CAAC","sourcesContent":["import type { API } from '../api';\nimport type { Config } from '../config';\nimport type { InternalLogger } from '../internalLogger';\nimport type { Metas } from '../metas';\nimport type { Transports } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\n\nimport type { Instrumentation, Instrumentations } from './types';\n\nexport function initializeInstrumentations(\n unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas,\n transports: Transports,\n api: API\n): Instrumentations {\n internalLogger.debug('Initializing instrumentations');\n\n const instrumentations: Instrumentation[] = [];\n\n const add: Instrumentations['add'] = (...newInstrumentations) => {\n internalLogger.debug('Adding instrumentations');\n\n newInstrumentations.forEach((newInstrumentation) => {\n internalLogger.debug(`Adding \"${newInstrumentation.name}\" instrumentation`);\n\n const exists = instrumentations.some(\n (existingInstrumentation) => existingInstrumentation.name === newInstrumentation.name\n );\n\n if (exists) {\n internalLogger.warn(`Instrumentation ${newInstrumentation.name} is already added`);\n\n return;\n }\n\n newInstrumentation.unpatchedConsole = unpatchedConsole;\n newInstrumentation.internalLogger = internalLogger;\n newInstrumentation.config = config;\n newInstrumentation.metas = metas;\n newInstrumentation.transports = transports;\n newInstrumentation.api = api;\n\n instrumentations.push(newInstrumentation);\n\n newInstrumentation.initialize();\n });\n };\n\n const remove: Instrumentations['remove'] = (...instrumentationsToRemove) => {\n internalLogger.debug('Removing instrumentations');\n\n instrumentationsToRemove.forEach((instrumentationToRemove) => {\n internalLogger.debug(`Removing \"${instrumentationToRemove.name}\" instrumentation`);\n\n const existingInstrumentationIndex = instrumentations.reduce<number | null>(\n (acc, existingInstrumentation, existingTransportIndex) => {\n if (acc === null && existingInstrumentation.name === instrumentationToRemove.name) {\n return existingTransportIndex;\n }\n\n return null;\n },\n null\n );\n\n if (existingInstrumentationIndex === null) {\n internalLogger.warn(`Instrumentation \"${instrumentationToRemove.name}\" is not added`);\n\n return;\n }\n\n instrumentations[existingInstrumentationIndex]!.destroy?.();\n\n instrumentations.splice(existingInstrumentationIndex, 1);\n });\n };\n\n return {\n add,\n get instrumentations() {\n return [...instrumentations];\n },\n remove,\n };\n}\n"]}
@@ -1,3 +1,3 @@
1
1
  // auto-generated by bin/genVersion.ts
2
- export const VERSION = '1.18.2';
2
+ export const VERSION = '1.19.0';
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.18.2';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.19.0';\n"]}
@@ -51,7 +51,7 @@ function initializeInstrumentations(unpatchedConsole, internalLogger, config, me
51
51
  }
52
52
  return null;
53
53
  }, null);
54
- if (!existingInstrumentationIndex) {
54
+ if (existingInstrumentationIndex === null) {
55
55
  internalLogger.warn("Instrumentation \"".concat(instrumentationToRemove.name, "\" is not added"));
56
56
  return;
57
57
  }
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../../src/instrumentations/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;AASA,gEA6EC;AA7ED,SAAgB,0BAA0B,CACxC,gBAAkC,EAClC,cAA8B,EAC9B,MAAc,EACd,KAAY,EACZ,UAAsB,EACtB,GAAQ;IAER,cAAc,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAEtD,IAAM,gBAAgB,GAAsB,EAAE,CAAC;IAE/C,IAAM,GAAG,GAA4B;QAAC,6BAAsB;aAAtB,UAAsB,EAAtB,qBAAsB,EAAtB,IAAsB;YAAtB,wCAAsB;;QAC1D,cAAc,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAEhD,mBAAmB,CAAC,OAAO,CAAC,UAAC,kBAAkB;YAC7C,cAAc,CAAC,KAAK,CAAC,mBAAW,kBAAkB,CAAC,IAAI,uBAAmB,CAAC,CAAC;YAE5E,IAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,CAClC,UAAC,uBAAuB,IAAK,OAAA,uBAAuB,CAAC,IAAI,KAAK,kBAAkB,CAAC,IAAI,EAAxD,CAAwD,CACtF,CAAC;YAEF,IAAI,MAAM,EAAE,CAAC;gBACX,cAAc,CAAC,IAAI,CAAC,0BAAmB,kBAAkB,CAAC,IAAI,sBAAmB,CAAC,CAAC;gBAEnF,OAAO;YACT,CAAC;YAED,kBAAkB,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;YACvD,kBAAkB,CAAC,cAAc,GAAG,cAAc,CAAC;YACnD,kBAAkB,CAAC,MAAM,GAAG,MAAM,CAAC;YACnC,kBAAkB,CAAC,KAAK,GAAG,KAAK,CAAC;YACjC,kBAAkB,CAAC,UAAU,GAAG,UAAU,CAAC;YAC3C,kBAAkB,CAAC,GAAG,GAAG,GAAG,CAAC;YAE7B,gBAAgB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YAE1C,kBAAkB,CAAC,UAAU,EAAE,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,IAAM,MAAM,GAA+B;QAAC,kCAA2B;aAA3B,UAA2B,EAA3B,qBAA2B,EAA3B,IAA2B;YAA3B,6CAA2B;;QACrE,cAAc,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAElD,wBAAwB,CAAC,OAAO,CAAC,UAAC,uBAAuB;;YACvD,cAAc,CAAC,KAAK,CAAC,qBAAa,uBAAuB,CAAC,IAAI,uBAAmB,CAAC,CAAC;YAEnF,IAAM,4BAA4B,GAAG,gBAAgB,CAAC,MAAM,CAC1D,UAAC,GAAG,EAAE,uBAAuB,EAAE,sBAAsB;gBACnD,IAAI,GAAG,KAAK,IAAI,IAAI,uBAAuB,CAAC,IAAI,KAAK,uBAAuB,CAAC,IAAI,EAAE,CAAC;oBAClF,OAAO,sBAAsB,CAAC;gBAChC,CAAC;gBAED,OAAO,IAAI,CAAC;YACd,CAAC,EACD,IAAI,CACL,CAAC;YAEF,IAAI,CAAC,4BAA4B,EAAE,CAAC;gBAClC,cAAc,CAAC,IAAI,CAAC,4BAAoB,uBAAuB,CAAC,IAAI,oBAAgB,CAAC,CAAC;gBAEtF,OAAO;YACT,CAAC;YAED,MAAA,MAAA,gBAAgB,CAAC,4BAA4B,CAAE,EAAC,OAAO,kDAAI,CAAC;YAE5D,gBAAgB,CAAC,MAAM,CAAC,4BAA4B,EAAE,CAAC,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO;QACL,GAAG,KAAA;QACH,IAAI,gBAAgB;YAClB,yBAAW,gBAAgB,QAAE;QAC/B,CAAC;QACD,MAAM,QAAA;KACP,CAAC;AACJ,CAAC","sourcesContent":["import type { API } from '../api';\nimport type { Config } from '../config';\nimport type { InternalLogger } from '../internalLogger';\nimport type { Metas } from '../metas';\nimport type { Transports } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\n\nimport type { Instrumentation, Instrumentations } from './types';\n\nexport function initializeInstrumentations(\n unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas,\n transports: Transports,\n api: API\n): Instrumentations {\n internalLogger.debug('Initializing instrumentations');\n\n const instrumentations: Instrumentation[] = [];\n\n const add: Instrumentations['add'] = (...newInstrumentations) => {\n internalLogger.debug('Adding instrumentations');\n\n newInstrumentations.forEach((newInstrumentation) => {\n internalLogger.debug(`Adding \"${newInstrumentation.name}\" instrumentation`);\n\n const exists = instrumentations.some(\n (existingInstrumentation) => existingInstrumentation.name === newInstrumentation.name\n );\n\n if (exists) {\n internalLogger.warn(`Instrumentation ${newInstrumentation.name} is already added`);\n\n return;\n }\n\n newInstrumentation.unpatchedConsole = unpatchedConsole;\n newInstrumentation.internalLogger = internalLogger;\n newInstrumentation.config = config;\n newInstrumentation.metas = metas;\n newInstrumentation.transports = transports;\n newInstrumentation.api = api;\n\n instrumentations.push(newInstrumentation);\n\n newInstrumentation.initialize();\n });\n };\n\n const remove: Instrumentations['remove'] = (...instrumentationsToRemove) => {\n internalLogger.debug('Removing instrumentations');\n\n instrumentationsToRemove.forEach((instrumentationToRemove) => {\n internalLogger.debug(`Removing \"${instrumentationToRemove.name}\" instrumentation`);\n\n const existingInstrumentationIndex = instrumentations.reduce<number | null>(\n (acc, existingInstrumentation, existingTransportIndex) => {\n if (acc === null && existingInstrumentation.name === instrumentationToRemove.name) {\n return existingTransportIndex;\n }\n\n return null;\n },\n null\n );\n\n if (!existingInstrumentationIndex) {\n internalLogger.warn(`Instrumentation \"${instrumentationToRemove.name}\" is not added`);\n\n return;\n }\n\n instrumentations[existingInstrumentationIndex]!.destroy?.();\n\n instrumentations.splice(existingInstrumentationIndex, 1);\n });\n };\n\n return {\n add,\n get instrumentations() {\n return [...instrumentations];\n },\n remove,\n };\n}\n"]}
1
+ {"version":3,"file":"initialize.js","s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CAAC,CAAC;IAEF,IAAM,MAAM,GAA+B;QAAC,kCAA2B;aAA3B,UAA2B,EAA3B,qBAA2B,EAA3B,IAA2B;YAA3B,6CAA2B;;QACrE,cAAc,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAElD,wBAAwB,CAAC,OAAO,CAAC,UAAC,uBAAuB;;YACvD,cAAc,CAAC,KAAK,CAAC,qBAAa,uBAAuB,CAAC,IAAI,uBAAmB,CAAC,CAAC;YAEnF,IAAM,4BAA4B,GAAG,gBAAgB,CAAC,MAAM,CAC1D,UAAC,GAAG,EAAE,uBAAuB,EAAE,sBAAsB;gBACnD,IAAI,GAAG,KAAK,IAAI,IAAI,uBAAuB,CAAC,IAAI,KAAK,uBAAuB,CAAC,IAAI,EAAE,CAAC;oBAClF,OAAO,sBAAsB,CAAC;gBAChC,CAAC;gBAED,OAAO,IAAI,CAAC;YACd,CAAC,EACD,IAAI,CACL,CAAC;YAEF,IAAI,4BAA4B,KAAK,IAAI,EAAE,CAAC;gBAC1C,cAAc,CAAC,IAAI,CAAC,4BAAoB,uBAAuB,CAAC,IAAI,oBAAgB,CAAC,CAAC;gBAEtF,OAAO;YACT,CAAC;YAED,MAAA,MAAA,gBAAgB,CAAC,4BAA4B,CAAE,EAAC,OAAO,kDAAI,CAAC;YAE5D,gBAAgB,CAAC,MAAM,CAAC,4BAA4B,EAAE,CAAC,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO;QACL,GAAG,KAAA;QACH,IAAI,gBAAgB;YAClB,yBAAW,gBAAgB,QAAE;QAC/B,CAAC;QACD,MAAM,QAAA;KACP,CAAC;AACJ,CAAC","sourcesContent":["import type { API } from '../api';\nimport type { Config } from '../config';\nimport type { InternalLogger } from '../internalLogger';\nimport type { Metas } from '../metas';\nimport type { Transports } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\n\nimport type { Instrumentation, Instrumentations } from './types';\n\nexport function initializeInstrumentations(\n unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas,\n transports: Transports,\n api: API\n): Instrumentations {\n internalLogger.debug('Initializing instrumentations');\n\n const instrumentations: Instrumentation[] = [];\n\n const add: Instrumentations['add'] = (...newInstrumentations) => {\n internalLogger.debug('Adding instrumentations');\n\n newInstrumentations.forEach((newInstrumentation) => {\n internalLogger.debug(`Adding \"${newInstrumentation.name}\" instrumentation`);\n\n const exists = instrumentations.some(\n (existingInstrumentation) => existingInstrumentation.name === newInstrumentation.name\n );\n\n if (exists) {\n internalLogger.warn(`Instrumentation ${newInstrumentation.name} is already added`);\n\n return;\n }\n\n newInstrumentation.unpatchedConsole = unpatchedConsole;\n newInstrumentation.internalLogger = internalLogger;\n newInstrumentation.config = config;\n newInstrumentation.metas = metas;\n newInstrumentation.transports = transports;\n newInstrumentation.api = api;\n\n instrumentations.push(newInstrumentation);\n\n newInstrumentation.initialize();\n });\n };\n\n const remove: Instrumentations['remove'] = (...instrumentationsToRemove) => {\n internalLogger.debug('Removing instrumentations');\n\n instrumentationsToRemove.forEach((instrumentationToRemove) => {\n internalLogger.debug(`Removing \"${instrumentationToRemove.name}\" instrumentation`);\n\n const existingInstrumentationIndex = instrumentations.reduce<number | null>(\n (acc, existingInstrumentation, existingTransportIndex) => {\n if (acc === null && existingInstrumentation.name === instrumentationToRemove.name) {\n return existingTransportIndex;\n }\n\n return null;\n },\n null\n );\n\n if (existingInstrumentationIndex === null) {\n internalLogger.warn(`Instrumentation \"${instrumentationToRemove.name}\" is not added`);\n\n return;\n }\n\n instrumentations[existingInstrumentationIndex]!.destroy?.();\n\n instrumentations.splice(existingInstrumentationIndex, 1);\n });\n };\n\n return {\n add,\n get instrumentations() {\n return [...instrumentations];\n },\n remove,\n };\n}\n"]}
@@ -60,9 +60,9 @@ describe('BatchExecutor', function () {
60
60
  itemLimit: 2,
61
61
  });
62
62
  be.addItem(item);
63
- expect(mockSendFunction).not.toBeCalled();
63
+ expect(mockSendFunction).not.toHaveBeenCalled();
64
64
  be.addItem(item);
65
- expect(mockSendFunction).toBeCalledTimes(1);
65
+ expect(mockSendFunction).toHaveBeenCalledTimes(1);
66
66
  });
67
67
  it('tests send with empty buffer', function () {
68
68
  var mockSendFunction = jest.fn();
@@ -70,7 +70,7 @@ describe('BatchExecutor', function () {
70
70
  sendTimeout: 1,
71
71
  });
72
72
  jest.advanceTimersByTime(2);
73
- expect(mockSendFunction).not.toBeCalled();
73
+ expect(mockSendFunction).not.toHaveBeenCalled();
74
74
  });
75
75
  it('tests send when "visibilitychange" event is emitted and visibilityState changes', function () {
76
76
  var mockSendFunction = jest.fn();
@@ -86,7 +86,7 @@ describe('BatchExecutor', function () {
86
86
  },
87
87
  });
88
88
  document.dispatchEvent(new Event('visibilitychange'));
89
- expect(mockSendFunction).toBeCalledTimes(1);
89
+ expect(mockSendFunction).toHaveBeenCalledTimes(1);
90
90
  });
91
91
  it('tests send when "visibilitychange" event is emitted and visibilityState changes to visible', function () {
92
92
  var mockSendFunction = jest.fn();
@@ -102,7 +102,7 @@ describe('BatchExecutor', function () {
102
102
  },
103
103
  });
104
104
  document.dispatchEvent(new Event('visibilitychange'));
105
- expect(mockSendFunction).toBeCalledTimes(0);
105
+ expect(mockSendFunction).toHaveBeenCalledTimes(0);
106
106
  });
107
107
  it('tests send when starting paused', function () {
108
108
  var mockSendFunction = jest.fn();
@@ -113,7 +113,7 @@ describe('BatchExecutor', function () {
113
113
  });
114
114
  be.addItem(item);
115
115
  jest.advanceTimersByTime(2);
116
- expect(mockSendFunction).not.toBeCalled();
116
+ expect(mockSendFunction).not.toHaveBeenCalled();
117
117
  });
118
118
  it('tests send when paused', function () {
119
119
  var mockSendFunction = jest.fn();
@@ -124,7 +124,7 @@ describe('BatchExecutor', function () {
124
124
  be.addItem(item);
125
125
  be.pause();
126
126
  jest.advanceTimersByTime(2);
127
- expect(mockSendFunction).not.toBeCalled();
127
+ expect(mockSendFunction).not.toHaveBeenCalled();
128
128
  });
129
129
  it('tests send when unpaused', function () {
130
130
  var mockSendFunction = jest.fn();
@@ -136,9 +136,9 @@ describe('BatchExecutor', function () {
136
136
  be.pause();
137
137
  jest.advanceTimersByTime(2);
138
138
  be.start();
139
- expect(mockSendFunction).not.toBeCalled();
139
+ expect(mockSendFunction).not.toHaveBeenCalled();
140
140
  jest.advanceTimersByTime(2);
141
- expect(mockSendFunction).toBeCalledTimes(1);
141
+ expect(mockSendFunction).toHaveBeenCalledTimes(1);
142
142
  });
143
143
  it('tests groupItems', function () {
144
144
  var be = new batchExecutor_1.BatchExecutor(function () { }, {
@@ -172,7 +172,7 @@ describe('BatchExecutor', function () {
172
172
  },
173
173
  } }));
174
174
  jest.advanceTimersByTime(2);
175
- expect(mockSendFunction).toBeCalledTimes(2);
175
+ expect(mockSendFunction).toHaveBeenCalledTimes(2);
176
176
  });
177
177
  });
178
178
  });
@@ -1 +1 @@
1
- {"version":3,"file":"batchExecutor.test.js","sourceRoot":"","sources":["../../../../../src/transports/batchExecutor.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,wBAA0E;AAE1E,iDAAgD;AAEhD,IAAM,qBAAqB,GAAG,UAAC,UAAoB,IAA8B,OAAA,CAAC;IAChF,IAAI,EAAE,qBAAiB,CAAC,GAAG;IAC3B,OAAO,EAAE;QACP,OAAO,EAAE,EAAE;QACX,KAAK,EAAE,YAAQ,CAAC,IAAI;QACpB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,0BAA0B;KACtC;IACD,IAAI,EAAE;QACJ,GAAG,EAAE;YACH,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU;SAC9E;KACF;CACF,CAAC,EAb+E,CAa/E,CAAC;AAEH,QAAQ,CAAC,eAAe,EAAE;IACxB,E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ACP,IAAI,EAAE;oBACJ,GAAG,EAAE;wBACH,IAAI,EAAE,KAAK;qBACZ;iBACF,IACD,CAAC;YACH,EAAE,CAAC,OAAO,uBACL,IAAI,KACP,IAAI,EAAE;oBACJ,GAAG,EAAE;wBACH,IAAI,EAAE,KAAK;qBACZ;iBACF,IACD,CAAC;YAEH,EAAE,CAAC,OAAO,uBACL,IAAI,KACP,IAAI,EAAE;oBACJ,GAAG,EAAE;wBACH,IAAI,EAAE,KAAK;qBACZ;iBACF,IACD,CAAC;YAEH,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;YAC5B,MAAM,CAAC,gBAAgB,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/**\n * @jest-environment jsdom\n */\nimport { LogEvent, LogLevel, TransportItem, TransportItemType } from '..';\n\nimport { BatchExecutor } from './batchExecutor';\n\nconst generateTransportItem = (randomMeta?: boolean): TransportItem<LogEvent> => ({\n type: TransportItemType.LOG,\n payload: {\n context: {},\n level: LogLevel.INFO,\n message: 'hi',\n timestamp: '2023-01-27T09:53:01.035Z',\n },\n meta: {\n sdk: {\n name: randomMeta ? (Math.random() + 1).toString(36).substring(7) : 'test-sdk',\n },\n },\n});\n\ndescribe('BatchExecutor', () => {\n it('tests instantiating BatchExecutor class', () => {\n const sendSpy = jest.fn();\n const be = new BatchExecutor(sendSpy);\n expect(be).toBeInstanceOf(BatchExecutor);\n });\n\n describe('config options', () => {\n afterEach(() => {\n jest.restoreAllMocks();\n });\n\n beforeAll(() => {\n jest.useFakeTimers();\n });\n\n it('tests send when exceeding batch size', () => {\n const mockSendFunction = jest.fn();\n const item = generateTransportItem();\n const be = new BatchExecutor(mockSendFunction, {\n sendTimeout: 1,\n itemLimit: 2,\n });\n\n be.addItem(item);\n expect(mockSendFunction).not.toBeCalled();\n\n be.addItem(item);\n expect(mockSendFunction).toBeCalledTimes(1);\n });\n\n it('tests send with empty buffer', () => {\n const mockSendFunction = jest.fn();\n new BatchExecutor(mockSendFunction, {\n sendTimeout: 1,\n });\n\n jest.advanceTimersByTime(2);\n expect(mockSendFunction).not.toBeCalled();\n });\n\n it('tests send when \"visibilitychange\" event is emitted and visibilityState changes', () => {\n const mockSendFunction = jest.fn();\n const item = generateTransportItem();\n const be = new BatchExecutor(mockSendFunction, {\n sendTimeout: 1,\n });\n\n be.addItem(item);\n Object.defineProperty(document, 'visibilityState', {\n configurable: true,\n get() {\n return 'hidden';\n },\n });\n document.dispatchEvent(new Event('visibilitychange'));\n expect(mockSendFunction).toBeCalledTimes(1);\n });\n\n it('tests send when \"visibilitychange\" event is emitted and visibilityState changes to visible', () => {\n const mockSendFunction = jest.fn();\n const item = generateTransportItem();\n const be = new BatchExecutor(mockSendFunction, {\n sendTimeout: 1,\n });\n\n be.addItem(item);\n Object.defineProperty(document, 'visibilityState', {\n configurable: true,\n get() {\n return 'visible';\n },\n });\n document.dispatchEvent(new Event('visibilitychange'));\n expect(mockSendFunction).toBeCalledTimes(0);\n });\n\n it('tests send when starting paused', () => {\n const mockSendFunction = jest.fn();\n const item = generateTransportItem();\n const be = new BatchExecutor(mockSendFunction, {\n sendTimeout: 1,\n paused: true,\n });\n\n be.addItem(item);\n jest.advanceTimersByTime(2);\n\n expect(mockSendFunction).not.toBeCalled();\n });\n\n it('tests send when paused', () => {\n const mockSendFunction = jest.fn();\n const item = generateTransportItem();\n const be = new BatchExecutor(mockSendFunction, {\n sendTimeout: 1,\n });\n\n be.addItem(item);\n be.pause();\n jest.advanceTimersByTime(2);\n\n expect(mockSendFunction).not.toBeCalled();\n });\n\n it('tests send when unpaused', () => {\n const mockSendFunction = jest.fn();\n const item = generateTransportItem();\n const be = new BatchExecutor(mockSendFunction, {\n sendTimeout: 1,\n });\n\n be.addItem(item);\n be.pause();\n jest.advanceTimersByTime(2);\n be.start();\n\n expect(mockSendFunction).not.toBeCalled();\n jest.advanceTimersByTime(2);\n expect(mockSendFunction).toBeCalledTimes(1);\n });\n\n it('tests groupItems', () => {\n const be = new BatchExecutor(() => {}, {\n sendTimeout: 1,\n });\n const itemsWithSameMeta = [...Array(3)].map(() => generateTransportItem(false));\n const itemsWithRandomMeta = [...Array(5)].map(() => generateTransportItem(true));\n const groups = be.groupItems([...itemsWithSameMeta, ...itemsWithRandomMeta]);\n expect(groups).toHaveLength(itemsWithRandomMeta.length + 1);\n });\n\n it('tests grouping', () => {\n const mockSendFunction = jest.fn();\n const be = new BatchExecutor(mockSendFunction, {\n sendTimeout: 1,\n });\n be.start();\n const item = generateTransportItem();\n\n be.addItem({\n ...item,\n meta: {\n sdk: {\n name: 'foo',\n },\n },\n });\n be.addItem({\n ...item,\n meta: {\n sdk: {\n name: 'foo',\n },\n },\n });\n\n be.addItem({\n ...item,\n meta: {\n sdk: {\n name: 'bar',\n },\n },\n });\n\n jest.advanceTimersByTime(2);\n expect(mockSendFunction).toBeCalledTimes(2);\n });\n });\n});\n"]}
1
+ {"version":3,"file":"batchExecutor.test.js","sourceRoot":"","sources":["../../../../../src/transports/batchExecutor.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,wBAA0E;AAE1E,iDAAgD;AAEhD,IAAM,qBAAqB,GAAG,UAAC,UAAoB,IAA8B,OAAA,CAAC;IAChF,IAAI,EAAE,qBAAiB,CAAC,GAAG;IAC3B,OAAO,EAAE;QACP,OAAO,EAAE,EAAE;QACX,KAAK,EAAE,YAAQ,CAAC,IAAI;QACpB,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,0BAA0B;KACtC;IACD,IAAI,EAAE;QACJ,GAAG,EAAE;YACH,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU;SAC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AE,CAAC;YACX,IAAM,IAAI,GAAG,qBAAqB,EAAE,CAAC;YAErC,EAAE,CAAC,OAAO,uBACL,IAAI,KACP,IAAI,EAAE;oBACJ,GAAG,EAAE;wBACH,IAAI,EAAE,KAAK;qBACZ;iBACF,IACD,CAAC;YACH,EAAE,CAAC,OAAO,uBACL,IAAI,KACP,IAAI,EAAE;oBACJ,GAAG,EAAE;wBACH,IAAI,EAAE,KAAK;qBACZ;iBACF,IACD,CAAC;YAEH,EAAE,CAAC,OAAO,uBACL,IAAI,KACP,IAAI,EAAE;oBACJ,GAAG,EAAE;wBACH,IAAI,EAAE,KAAK;qBACZ;iBACF,IACD,CAAC;YAEH,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;YAC5B,MAAM,CAAC,gBAAgB,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/**\n * @jest-environment jsdom\n */\nimport { LogEvent, LogLevel, TransportItem, TransportItemType } from '..';\n\nimport { BatchExecutor } from './batchExecutor';\n\nconst generateTransportItem = (randomMeta?: boolean): TransportItem<LogEvent> => ({\n type: TransportItemType.LOG,\n payload: {\n context: {},\n level: LogLevel.INFO,\n message: 'hi',\n timestamp: '2023-01-27T09:53:01.035Z',\n },\n meta: {\n sdk: {\n name: randomMeta ? (Math.random() + 1).toString(36).substring(7) : 'test-sdk',\n },\n },\n});\n\ndescribe('BatchExecutor', () => {\n it('tests instantiating BatchExecutor class', () => {\n const sendSpy = jest.fn();\n const be = new BatchExecutor(sendSpy);\n expect(be).toBeInstanceOf(BatchExecutor);\n });\n\n describe('config options', () => {\n afterEach(() => {\n jest.restoreAllMocks();\n });\n\n beforeAll(() => {\n jest.useFakeTimers();\n });\n\n it('tests send when exceeding batch size', () => {\n const mockSendFunction = jest.fn();\n const item = generateTransportItem();\n const be = new BatchExecutor(mockSendFunction, {\n sendTimeout: 1,\n itemLimit: 2,\n });\n\n be.addItem(item);\n expect(mockSendFunction).not.toHaveBeenCalled();\n\n be.addItem(item);\n expect(mockSendFunction).toHaveBeenCalledTimes(1);\n });\n\n it('tests send with empty buffer', () => {\n const mockSendFunction = jest.fn();\n new BatchExecutor(mockSendFunction, {\n sendTimeout: 1,\n });\n\n jest.advanceTimersByTime(2);\n expect(mockSendFunction).not.toHaveBeenCalled();\n });\n\n it('tests send when \"visibilitychange\" event is emitted and visibilityState changes', () => {\n const mockSendFunction = jest.fn();\n const item = generateTransportItem();\n const be = new BatchExecutor(mockSendFunction, {\n sendTimeout: 1,\n });\n\n be.addItem(item);\n Object.defineProperty(document, 'visibilityState', {\n configurable: true,\n get() {\n return 'hidden';\n },\n });\n document.dispatchEvent(new Event('visibilitychange'));\n expect(mockSendFunction).toHaveBeenCalledTimes(1);\n });\n\n it('tests send when \"visibilitychange\" event is emitted and visibilityState changes to visible', () => {\n const mockSendFunction = jest.fn();\n const item = generateTransportItem();\n const be = new BatchExecutor(mockSendFunction, {\n sendTimeout: 1,\n });\n\n be.addItem(item);\n Object.defineProperty(document, 'visibilityState', {\n configurable: true,\n get() {\n return 'visible';\n },\n });\n document.dispatchEvent(new Event('visibilitychange'));\n expect(mockSendFunction).toHaveBeenCalledTimes(0);\n });\n\n it('tests send when starting paused', () => {\n const mockSendFunction = jest.fn();\n const item = generateTransportItem();\n const be = new BatchExecutor(mockSendFunction, {\n sendTimeout: 1,\n paused: true,\n });\n\n be.addItem(item);\n jest.advanceTimersByTime(2);\n\n expect(mockSendFunction).not.toHaveBeenCalled();\n });\n\n it('tests send when paused', () => {\n const mockSendFunction = jest.fn();\n const item = generateTransportItem();\n const be = new BatchExecutor(mockSendFunction, {\n sendTimeout: 1,\n });\n\n be.addItem(item);\n be.pause();\n jest.advanceTimersByTime(2);\n\n expect(mockSendFunction).not.toHaveBeenCalled();\n });\n\n it('tests send when unpaused', () => {\n const mockSendFunction = jest.fn();\n const item = generateTransportItem();\n const be = new BatchExecutor(mockSendFunction, {\n sendTimeout: 1,\n });\n\n be.addItem(item);\n be.pause();\n jest.advanceTimersByTime(2);\n be.start();\n\n expect(mockSendFunction).not.toHaveBeenCalled();\n jest.advanceTimersByTime(2);\n expect(mockSendFunction).toHaveBeenCalledTimes(1);\n });\n\n it('tests groupItems', () => {\n const be = new BatchExecutor(() => {}, {\n sendTimeout: 1,\n });\n const itemsWithSameMeta = [...Array(3)].map(() => generateTransportItem(false));\n const itemsWithRandomMeta = [...Array(5)].map(() => generateTransportItem(true));\n const groups = be.groupItems([...itemsWithSameMeta, ...itemsWithRandomMeta]);\n expect(groups).toHaveLength(itemsWithRandomMeta.length + 1);\n });\n\n it('tests grouping', () => {\n const mockSendFunction = jest.fn();\n const be = new BatchExecutor(mockSendFunction, {\n sendTimeout: 1,\n });\n be.start();\n const item = generateTransportItem();\n\n be.addItem({\n ...item,\n meta: {\n sdk: {\n name: 'foo',\n },\n },\n });\n be.addItem({\n ...item,\n meta: {\n sdk: {\n name: 'foo',\n },\n },\n });\n\n be.addItem({\n ...item,\n meta: {\n sdk: {\n name: 'bar',\n },\n },\n });\n\n jest.advanceTimersByTime(2);\n expect(mockSendFunction).toHaveBeenCalledTimes(2);\n });\n });\n});\n"]}
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // auto-generated by bin/genVersion.ts
5
- exports.VERSION = '1.18.2';
5
+ exports.VERSION = '1.19.0';
6
6
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.18.2';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.19.0';\n"]}
@@ -4,7 +4,7 @@ import type { Transport, TransportItem } from '../transports';
4
4
  export declare class MockTransport extends BaseTransport implements Transport {
5
5
  private ignoreURLs;
6
6
  readonly name = "@grafana/transport-mock";
7
- readonly version = "1.18.2";
7
+ readonly version = "1.19.0";
8
8
  items: TransportItem[];
9
9
  constructor(ignoreURLs?: Patterns);
10
10
  send(items: TransportItem[]): void | Promise<void>;
@@ -1 +1 @@
1
- export declare const VERSION = "1.18.2";
1
+ export declare const VERSION = "1.19.0";
@@ -4,7 +4,7 @@ import type { Transport, TransportItem } from '../transports';
4
4
  export declare class MockTransport extends BaseTransport implements Transport {
5
5
  private ignoreURLs;
6
6
  readonly name = "@grafana/transport-mock";
7
- readonly version = "1.18.2";
7
+ readonly version = "1.19.0";
8
8
  items: TransportItem[];
9
9
  constructor(ignoreURLs?: Patterns);
10
10
  send(items: TransportItem[]): void | Promise<void>;
@@ -1 +1 @@
1
- export declare const VERSION = "1.18.2";
1
+ export declare const VERSION = "1.19.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/faro-core",
3
- "version": "1.18.2",
3
+ "version": "1.19.0",
4
4
  "description": "Core package of Faro.",
5
5
  "keywords": [
6
6
  "observability",
@@ -30,21 +30,21 @@
30
30
  ],
31
31
  "scripts": {
32
32
  "start": "yarn watch",
33
- "build": "run-s build:*",
33
+ "build": "run-s 'build:*'",
34
34
  "build:version": "node bin/genVersion.js",
35
- "build:compile": "run-p build:compile:*",
35
+ "build:compile": "run-p 'build:compile:*'",
36
36
  "build:compile:cjs": "tsc --build tsconfig.cjs.json",
37
37
  "build:compile:esm": "tsc --build tsconfig.esm.json",
38
- "build:compile:bundle": "run-s build:compile:bundle:*",
38
+ "build:compile:bundle": "run-s 'build:compile:bundle:*'",
39
39
  "build:compile:bundle:create": "rollup -c ./rollup.config.js",
40
40
  "build:compile:bundle:remove-extras": "rimraf dist/bundle/dist",
41
41
  "watch": "run-s build:version watch:compile",
42
42
  "watch:compile": "yarn build:compile:cjs -w",
43
43
  "clean": "rimraf dist/ yarn-error.log",
44
- "quality": "run-s quality:*",
44
+ "quality": "run-s 'quality:*'",
45
45
  "quality:test": "jest",
46
46
  "quality:format": "prettier --cache --cache-location=../../.cache/prettier/core --ignore-path ../../.prettierignore -w \"./**/*.{js,jsx,ts,tsx,css,scss,md,yaml,yml,json}\"",
47
- "quality:lint": "run-s quality:lint:*",
47
+ "quality:lint": "run-s 'quality:lint:*'",
48
48
  "quality:lint:eslint": "eslint --cache --cache-location ../../.cache/eslint/core --ignore-path ../../.eslintignore \"./**/*.{js,jsx,ts,tsx}\"",
49
49
  "quality:lint:prettier": "prettier --cache --cache-location=../../.cache/prettier/core --ignore-path ../../.prettierignore -c \"./**/*.{js,jsx,ts,tsx,css,scss,md,yaml,yml,json}\"",
50
50
  "quality:lint:md": "markdownlint README.md",
@@ -52,13 +52,13 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@opentelemetry/api": "^1.9.0",
55
- "@opentelemetry/otlp-transformer": "^0.201.0"
55
+ "@opentelemetry/otlp-transformer": "^0.202.0"
56
56
  },
57
57
  "devDependencies": {
58
- "@types/node": "^22.10.2"
58
+ "@types/node": "^24.0.1"
59
59
  },
60
60
  "publishConfig": {
61
61
  "access": "public"
62
62
  },
63
- "gitHead": "b88a8a0946172cd2ad7f22882b9307749e844916"
63
+ "gitHead": "ffae80438840da07851a0d6da1e0414c24c04165"
64
64
  }