@grafana/faro-core
Version:
Core package of Faro.
2 lines (1 loc) • 21.2 kB
JavaScript
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}({});