@grafana/faro-core 2.6.2 → 2.7.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.
@@ -1 +1 @@
1
- var GrafanaFaroCore=function(e){"use strict";class t{constructor(e,t){var n,r;this.signalBuffer=[],this.itemLimit=null!==(n=null==t?void 0:t.itemLimit)&&void 0!==n?n:50,this.sendTimeout=null!==(r=null==t?void 0:t.sendTimeout)&&void 0!==r?r:250,this.paused=(null==t?void 0:t.paused)||!1,this.sendFn=e,this.flushInterval=-1,this.paused||this.start(),document.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&this.flush()})}addItem(e){this.paused||(this.signalBuffer.push(e),this.signalBuffer.length>=this.itemLimit&&this.flush())}start(){this.paused=!1,this.sendTimeout>0&&(this.flushInterval=window.setInterval(()=>this.flush(),this.sendTimeout))}pause(){this.paused=!0,clearInterval(this.flushInterval)}groupItems(e){const t=new Map;return e.forEach(e=>{const n=JSON.stringify(e.meta);let r=t.get(n);r=void 0===r?[e]:[...r,e],t.set(n,r)}),Array.from(t.values())}flush(){if(this.paused||0===this.signalBuffer.length)return;this.groupItems(this.signalBuffer).forEach(this.sendFn),this.signalBuffer=[]}}var n;e.TransportItemType=void 0,(n=e.TransportItemType||(e.TransportItemType={})).EXCEPTION="exception",n.LOG="log",n.MEASUREMENT="measurement",n.TRACE="trace",n.EVENT="event";const r={[e.TransportItemType.EXCEPTION]:"exceptions",[e.TransportItemType.LOG]:"logs",[e.TransportItemType.MEASUREMENT]:"measurements",[e.TransportItemType.TRACE]:"traces",[e.TransportItemType.EVENT]:"events"};function s(e,n,r,s){var a;n.debug("Initializing transports");const o=[];let u=r.paused,c=[];const l=e=>{let t=e;for(const e of c){const n=t.map(e).filter(Boolean);if(0===n.length)return[];t=i(n,r)}return t},d=e=>{const t=l(e);if(0!==t.length)for(const e of o)n.debug(`Transporting item using ${e.name}\n`,t),e.isBatched()&&e.send(t)};let g;(null===(a=r.batching)||void 0===a?void 0:a.enabled)&&(g=new t(d,{sendTimeout:r.batching.sendTimeout,itemLimit:r.batching.itemLimit,paused:u}));return{add:(...t)=>{n.debug("Adding transports"),t.forEach(t=>{n.debug(`Adding "${t.name}" transport`);o.some(e=>e===t)?n.warn(`Transport ${t.name} is already added`):(t.unpatchedConsole=e,t.internalLogger=n,t.config=r,t.metas=s,o.push(t))})},addBeforeSendHooks:(...e)=>{n.debug("Adding beforeSendHooks\n",c),e.forEach(e=>{e&&c.push(e)})},getBeforeSendHooks:()=>[...c],execute:e=>{var t;u||((null===(t=r.batching)||void 0===t?void 0:t.enabled)&&(null==g||g.addItem(e)),(e=>{var t,s;if((null===(t=r.batching)||void 0===t?void 0:t.enabled)&&o.every(e=>e.isBatched()))return;const[i]=l([e]);if(void 0!==i)for(const e of o)n.debug(`Transporting item using ${e.name}\n`,i),e.isBatched()?(null===(s=r.batching)||void 0===s?void 0:s.enabled)||e.send([i]):e.send(i)})(e))},isPaused:()=>u,pause:()=>{n.debug("Pausing transports"),null==g||g.pause(),u=!0},remove:(...e)=>{n.debug("Removing transports"),e.forEach(e=>{n.debug(`Removing "${e.name}" transport`);const t=o.indexOf(e);-1!==t?o.splice(t,1):n.warn(`Transport "${e.name}" is not added`)})},removeBeforeSendHooks:(...e)=>{c.filter(t=>!e.includes(t))},get transports(){return[...o]},unpause:()=>{n.debug("Unpausing transports"),null==g||g.start(),u=!1}}}function i(t,n){if(n.preserveOriginalError)for(const n of t)n.type===e.TransportItemType.EXCEPTION&&delete n.payload.originalError;return t}function a(e,t){return typeof e===t}function o(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function u(e,t){try{return e instanceof t}catch(e){return!1}}const c=e=>a(e,"null"),l=e=>a(e,"string"),d=e=>a(e,"number")&&!isNaN(e)||a(e,"bigint"),g=e=>!c(e)&&a(e,"object"),p=e=>a(e,"function"),f=e=>o(e,"Array"),m="undefined"!=typeof Event,h="undefined"!=typeof Error,b=e=>h&&u(e,Error),v="undefined"!=typeof Element,E="undefined"!=typeof Map;function y(e){return null==e||(f(e)||l(e)?0===e.length:!!g(e)&&0===Object.keys(e).length)}function T(e,t){if(e===t)return!0;if(a(e,"number")&&isNaN(e))return a(t,"number")&&isNaN(t);const n=f(e),r=f(t);if(n!==r)return!1;if(n&&r){const n=e.length;if(n!==t.length)return!1;for(let r=n;0!==r--;)if(!T(e[r],t[r]))return!1;return!0}const s=g(e),i=g(t);if(s!==i)return!1;if(e&&t&&s&&i){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(!T(e[r],t[r]))return!1;return!0}return!1}function I(){return Date.now()}function O(){return"undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():Date.now()}function S(){return(new Date).toISOString()}function A(e){return new Date(e).toISOString()}var L;e.LogLevel=void 0,(L=e.LogLevel||(e.LogLevel={})).TRACE="trace",L.DEBUG="debug",L.INFO="info",L.LOG="log",L.WARN="warn",L.ERROR="error";const j=e.LogLevel.LOG,_=[e.LogLevel.TRACE,e.LogLevel.DEBUG,e.LogLevel.INFO,e.LogLevel.LOG,e.LogLevel.WARN,e.LogLevel.ERROR];function x(){}const w="abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789";function N(e=10){return Array.from(Array(e)).map(()=>w[Math.floor(59*Math.random())]).join("")}const R="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:void 0;function U(){const e=new WeakSet;return function(t,n){if(g(n)&&null!==n){if(e.has(n))return null;e.add(n)}return n}}function k(e={}){return JSON.stringify(null!=e?e:{},U())}function C(e={}){const t={};for(const[n,r]of Object.entries(e))t[n]=g(r)&&null!==r?k(r):String(r);return t}class B{constructor(){this.subscribers=[]}subscribe(e){return this.subscribers.push(e),{unsubscribe:()=>this.unsubscribe(e)}}unsubscribe(e){this.subscribers=this.subscribers.filter(t=>t!==e)}notify(e){this.subscribers.forEach(t=>t(e))}first(){const e=new B,t=t=>{e.notify(t),n.unsubscribe()},n=this.subscribe(t),r=e.unsubscribe.bind(e);return this.withUnsubscribeOverride(e,r,t)}takeWhile(e){const t=new B,n=r=>{e(r)?t.notify(r):t.unsubscribe(n)};this.subscribe(n);const r=t.unsubscribe.bind(t);return this.withUnsubscribeOverride(t,r,n)}filter(e){const t=new B,n=n=>{e(n)&&t.notify(n)};this.subscribe(n);const r=t.unsubscribe.bind(t);return this.withUnsubscribeOverride(t,r,n)}merge(...e){const t=new B,n=[];e.forEach(e=>{const r=e.subscribe(e=>{t.notify(e)});n.push(r)});const r=t.unsubscribeAll.bind(t);return t.unsubscribe=()=>{n.forEach(e=>e.unsubscribe()),r()},t}withUnsubscribeOverride(e,t,n){return e.unsubscribe=e=>{t(e),this.unsubscribe(n)},e}unsubscribeAll(){this.subscribers=[]}}var P;e.InternalLoggerLevel=void 0,(P=e.InternalLoggerLevel||(e.InternalLoggerLevel={}))[P.OFF=0]="OFF",P[P.ERROR=1]="ERROR",P[P.WARN=2]="WARN",P[P.INFO=3]="INFO",P[P.VERBOSE=4]="VERBOSE";const M={debug:x,error:x,info:x,prefix:"Faro",warn:x},D=e.InternalLoggerLevel.ERROR,F=Object.assign({},console);let V=F;function z(e){var t;return V=null!==(t=e.unpatchedConsole)&&void 0!==t?t:V,V}function $(t=F,n=D){const r=M;return n>e.InternalLoggerLevel.OFF&&(r.error=n>=e.InternalLoggerLevel.ERROR?function(...e){t.error(`${r.prefix}\n`,...e)}:x,r.warn=n>=e.InternalLoggerLevel.WARN?function(...e){t.warn(`${r.prefix}\n`,...e)}:x,r.info=n>=e.InternalLoggerLevel.INFO?function(...e){t.info(`${r.prefix}\n`,...e)}:x,r.debug=n>=e.InternalLoggerLevel.VERBOSE?function(...e){t.debug(`${r.prefix}\n`,...e)}:x),r}let G=M;function H(e,t){return G=$(e,t.internalLoggerLevel),G}class K{constructor(){this.unpatchedConsole=F,this.internalLogger=M,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 W(e,t){var n,r;if(void 0===t)return e;if(void 0===e)return{resourceSpans:t};const s=null===(n=e.resourceSpans)||void 0===n?void 0:n[0];if(void 0===s)return e;const i=(null==s?void 0:s.scopeSpans)||[],a=(null===(r=null==t?void 0:t[0])||void 0===r?void 0:r.scopeSpans)||[];return Object.assign(Object.assign({},e),{resourceSpans:[Object.assign(Object.assign({},s),{scopeSpans:[...i,...a]})]})}const X={Normal:"normal",Critical:"critical"};var J;e.UserActionState=void 0,(J=e.UserActionState||(e.UserActionState={}))[J.Started=0]="Started",J[J.Halted=1]="Halted",J[J.Cancelled=2]="Cancelled",J[J.Ended=3]="Ended";class q{constructor(){this.buffer=[]}addItem(e){this.buffer.push(e)}flushBuffer(e){if(p(e))for(const t of this.buffer)e(t);this.buffer.length=0}size(){return this.buffer.length}}class Q extends B{constructor({name:t,parentId:n,trigger:r,transports:s,attributes:i,trackUserActionsExcludeItem:a,importance:o=X.Normal,pushEvent:u}){super(),this.name=t,this.attributes=i,this.id=N(),this.trigger=r,this.parentId=null!=n?n:this.id,this.trackUserActionsExcludeItem=a,this.importance=o,this._pushEvent=u,this._itemBuffer=new q,this._transports=s,this._state=e.UserActionState.Started,this._start()}addItem(t){return this._state===e.UserActionState.Started&&(this._itemBuffer.addItem(t),!0)}_start(){this._state=e.UserActionState.Started,this._state===e.UserActionState.Started&&(this.startTime=I(),this._startTimeMono=O())}halt(){this._state===e.UserActionState.Started&&(this._state=e.UserActionState.Halted,this.notify(this._state))}cancel(){this._state===e.UserActionState.Started&&this._itemBuffer.flushBuffer(e=>{this._transports.execute(e)}),this._state=e.UserActionState.Cancelled,this.notify(this._state)}end(){if(this._state===e.UserActionState.Cancelled)return;const t=I(),n=O()-this._startTimeMono;this._state=e.UserActionState.Ended,this._itemBuffer.flushBuffer(t=>{if(function(t,n){return(null==n?void 0:n(t))||t.type===e.TransportItemType.MEASUREMENT&&"web-vitals"===t.payload.type}(t,this.trackUserActionsExcludeItem))return void this._transports.execute(t);const n=Object.assign(Object.assign({},t),{payload:Object.assign(Object.assign({},t.payload),{action:{parentId:this.id,name:this.name}})});this._transports.execute(n)}),this._state=e.UserActionState.Ended,this.notify(this._state),this._pushEvent("faro.user.action",Object.assign({userActionName:this.name,userActionStartTime:this.startTime.toString(),userActionEndTime:t.toString(),userActionDuration:n.toString(),userActionTrigger:this.trigger,userActionImportance:this.importance},C(this.attributes)),void 0,{timestampOverwriteMs:this.startTime,customPayloadTransformer:e=>(e.action={id:this.id,name:this.name},e)})}getState(){return this._state}}const Y=new B;function Z(t,n){if(!t)return!1;return(null==t?void 0:t.getState())===e.UserActionState.Started&&(t.addItem(n),!0)}const ee="Error";let te;function ne({internalLogger:t,config:n,metas:r,transports:s,tracesApi:i,userActionsApi:a}){var o;t.debug("Initializing exceptions API");let u=null;te=null!==(o=n.parseStacktrace)&&void 0!==o?o:te;const d=e=>{t.debug("Changing stacktrace parser"),te=null!=e?e:te},{ignoreErrors:p=[],preserveOriginalError:m}=n;return d(n.parseStacktrace),{changeStacktraceParser:d,getStacktraceParser:()=>te,pushError:(o,{skipDedupe:d,stackFrames:h,type:v,context:E,spanContext:I,timestampOverwriteMs:O,originalError:L,fingerprint:j,fatal:_}={})=>{var x;if(!function(e,t){const{message:n,name:r,stack:s}=t;return i=e,a=n+" "+r+" "+s,i.some(e=>l(e)?a.includes(e):!!a.match(e));var i,a}(p,null!=L?L:o))try{const l=C(Object.assign(Object.assign({},function(e){let t=e.cause;b(t)?t=e.cause.toString():null!==t&&(g(e.cause)||f(e.cause))?t=k(e.cause):null!=t&&(t=e.cause.toString());return null==t?{}:{cause:t}}(null!=L?L:o)),null!=E?E:{})),p={meta:r.value,payload:Object.assign(Object.assign(Object.assign(Object.assign({type:v||o.name||ee,value:o.message,timestamp:O?A(O):S(),trace:I?{trace_id:I.traceId,span_id:I.spanId}:i.getTraceContext()},y(l)?{}:{context:l}),m?{originalError:L}:{}),j?{fingerprint:j}:{}),void 0!==_?{fatal:_}:{}),type:e.TransportItemType.EXCEPTION};(null==(h=null!=h?h:o.stack?null==te?void 0:te(o).frames:void 0)?void 0:h.length)&&(p.payload.stacktrace={frames:h});const w={type:p.payload.type,value:p.payload.value,stacktrace:p.payload.stacktrace,context:p.payload.context,fingerprint:p.payload.fingerprint,fatal:null!==(x=p.payload.fatal)&&void 0!==x&&x};if(!d&&n.dedupe&&!c(u)&&T(w,u))return void t.debug("Skipping error push because it is the same as the last one\n",p.payload);u=w,t.debug("Pushing exception\n",p),Z(a.getActiveUserAction(),p)||s.execute(p)}catch(e){t.error("Error pushing event",e)}}}}const re=e=>e.map(e=>{try{return String(e)}catch(e){return""}}).join(" ");function se(t,n,r,s,i){n.debug("Initializing API");let a=null;const o=function({transports:t,internalLogger:n,config:r,pushEvent:s}){var i;const a=null===(i=r.userActionsInstrumentation)||void 0===i?void 0:i.excludeItem;let o;const u=()=>o;return{startUserAction:(r,i,c)=>{if(void 0===u()){const n=new Q({name:r,transports:t,attributes:i,trigger:(null==c?void 0:c.triggerName)||"faroApiCall",importance:(null==c?void 0:c.importance)||X.Normal,trackUserActionsExcludeItem:a,pushEvent:s});return n.filter(t=>[e.UserActionState.Ended,e.UserActionState.Cancelled].includes(t)).first().subscribe(()=>{o=void 0}),Y.notify({type:"user_action_start",userAction:n}),o=n,o}n.error("Attempted to create a new user action while one is already running. This is not possible.")},getActiveUserAction:u}}({transports:i,config:r,internalLogger:n,pushEvent:(e,t,r,s)=>{a?a(e,t,r,s):n.warn("pushEventImpl is not initialized. Event dropped:",{name:e,attributes:t,domain:r,options:s})}}),u=function(t,n,r,s,i){let a;return n.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,t)=>{n.debug("Initializing OpenTelemetry"),a={trace:e,context:t}},isOTELInitialized:()=>!!a,pushTraces:t=>{try{const r={type:e.TransportItemType.TRACE,payload:t,meta:s.value};n.debug("Pushing trace\n",r),i.execute(r)}catch(e){n.error("Error pushing trace\n",e)}}}}(0,n,0,s,i),d={internalLogger:n,userActionsApi:o,config:r,metas:s,transports:i,tracesApi:u},g=function({internalLogger:t,config:n,metas:r,transports:s,tracesApi:i,userActionsApi:a}){let o=null;return{pushEvent:(u,l,d,{skipDedupe:g,spanContext:p,timestampOverwriteMs:f,customPayloadTransformer:m=e=>e}={})=>{try{const h=C(l),b={meta:r.value,payload:m({name:u,domain:null!=d?d:n.eventDomain,attributes:y(h)?void 0:h,timestamp:f?A(f):S(),trace:p?{trace_id:p.traceId,span_id:p.spanId}:i.getTraceContext()}),type:e.TransportItemType.EVENT},v={name:b.payload.name,attributes:b.payload.attributes,domain:b.payload.domain};if(!g&&n.dedupe&&!c(o)&&T(v,o))return void t.debug("Skipping event push because it is the same as the last one\n",b.payload);o=v,t.debug("Pushing event\n",b),Z(a.getActiveUserAction(),b)||s.execute(b)}catch(e){t.error("Error pushing event",e)}}}}(d);return a=g.pushEvent,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},u),ne(d)),function({internalLogger:e,metas:t}){let n,r,s,i;e.debug("Initializing meta API");const a=e=>{r&&t.remove(r),r={user:e},t.add(r)},o=(e,r)=>{var s;const i=null==r?void 0:r.overrides,a=i?{overrides:Object.assign(Object.assign({},null===(s=null==n?void 0:n.session)||void 0===s?void 0:s.overrides),i)}:{};n&&t.remove(n),n={session:Object.assign(Object.assign({},y(e)?void 0:e),a)},t.add(n)},u=()=>t.value.session,c=()=>t.value.page;return{setUser:a,resetUser:a,setSession:o,resetSession:o,getSession:u,setView:(e,n)=>{var r;if((null==n?void 0:n.overrides)&&o(u(),{overrides:n.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},t.add(s),i&&t.remove(i)},getView:()=>t.value.view,setPage:e=>{var n;const r=l(e)?Object.assign(Object.assign({},null!==(n=null==i?void 0:i.page)&&void 0!==n?n:c()),{id:e}):e;i&&t.remove(i),i={page:r},t.add(i)},getPage:c}}(d)),function({internalLogger:t,config:n,metas:r,transports:s,tracesApi:i,userActionsApi:a}){var o;t.debug("Initializing logs API");let u=null;const l=null!==(o=n.logArgsSerializer)&&void 0!==o?o:re;return{pushLog:(o,{context:d,level:g,skipDedupe:p,spanContext:f,timestampOverwriteMs:m}={})=>{try{const h=C(d),b={type:e.TransportItemType.LOG,payload:{message:l(o),level:null!=g?g:j,context:y(h)?void 0:h,timestamp:m?A(m):S(),trace:f?{trace_id:f.traceId,span_id:f.spanId}:i.getTraceContext()},meta:r.value},v={message:b.payload.message,level:b.payload.level,context:b.payload.context};if(!p&&n.dedupe&&!c(u)&&T(v,u))return void t.debug("Skipping log push because it is the same as the last one\n",b.payload);u=v,t.debug("Pushing log\n",b),Z(a.getActiveUserAction(),b)||s.execute(b)}catch(e){t.error("Error pushing log\n",e)}}}}(d)),function({internalLogger:t,config:n,metas:r,transports:s,tracesApi:i,userActionsApi:a}){t.debug("Initializing measurements API");let o=null;return{pushMeasurement:(u,{skipDedupe:l,context:d,spanContext:g,timestampOverwriteMs:p}={})=>{try{const f=C(d),m={type:e.TransportItemType.MEASUREMENT,payload:Object.assign(Object.assign({},u),{trace:g?{trace_id:g.traceId,span_id:g.spanId}:i.getTraceContext(),timestamp:p?A(p):S(),context:y(f)?void 0:f}),meta:r.value},h={type:m.payload.type,values:m.payload.values,context:m.payload.context};if(!l&&n.dedupe&&!c(o)&&T(h,o))return void t.debug("Skipping measurement push because it is the same as the last one\n",m.payload);o=h,t.debug("Pushing measurement\n",m),Z(a.getActiveUserAction(),m)||s.execute(m)}catch(e){t.error("Error pushing measurement\n",e)}}}}(d)),g),o)}const ie="2.6.2";const ae="_faroInternal";function oe(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(R,ae,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function ue(){return ae in R}function ce(t,n,r,s,i,a,o){return n.debug("Initializing Faro"),e.faro={api:a,config:r,instrumentations:o,internalLogger:n,metas:s,pause:i.pause,transports:i,unpatchedConsole:t,unpause:i.unpause},oe(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 R)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(R,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}(e.faro),e.faro}e.faro={api:{pushLog:()=>{},pushError:()=>{},changeStacktraceParser:()=>{},getStacktraceParser:()=>{},pushMeasurement:()=>{},pushTraces:()=>{},getOTEL:()=>{},getTraceContext:()=>{},initOTEL:()=>{},isOTELInitialized:()=>!1,setUser:()=>{},resetUser:()=>{},setSession:()=>{},resetSession:()=>{},getSession:()=>{},setView:()=>{},getView:()=>{},setPage:()=>{},getPage:()=>{},pushEvent:()=>{},startUserAction:()=>{},getActiveUserAction:()=>{}}};return e.BaseExtension=K,e.BaseInstrumentation=class extends K{constructor(){super(...arguments),this.api={},this.transports={}}},e.BaseTransport=class extends K{isBatched(){return!1}getIgnoreUrls(){return[]}},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=B,e.UserActionImportance=X,e.VERSION=ie,e.allLogLevels=_,e.clampSamplingRate=function(e){return Math.min(1,Math.max(0,e))},e.createInternalLogger=$,e.createPromiseBuffer=function(e){const{size:t,concurrency:n}=e,r=[];let s=0;const i=()=>{if(s<n&&r.length){const{producer:e,resolve:t,reject:n}=r.shift();s++,e().then(e=>{s--,i(),t(e)},e=>{s--,i(),n(e)})}};return{add:e=>{if(r.length+s>=t)throw new Error("Task buffer full");return new Promise((t,n)=>{r.push({producer:e,resolve:t,reject:n}),i()})}}},e.dateNow=I,e.deepEqual=T,e.defaultBatchingConfig={enabled:!0,sendTimeout:250,itemLimit:50},e.defaultErrorArgsSerializer=e=>e.map(e=>g(e)?k(e):String(e)).join(" "),e.defaultExceptionType=ee,e.defaultGlobalObjectKey="faro",e.defaultInternalLoggerLevel=D,e.defaultLogArgsSerializer=re,e.defaultLogLevel=j,e.defaultUnpatchedConsole=F,e.genShortID=N,e.getCircularDependencyReplacer=U,e.getCurrentTimestamp=S,e.getInternalFaroFromGlobalObject=function(){return R[ae]},e.getTransportBody=function(t){let n={meta:{}};return void 0!==t[0]&&(n.meta=t[0].meta),t.forEach(t=>{switch(t.type){case e.TransportItemType.LOG:case e.TransportItemType.EVENT:case e.TransportItemType.EXCEPTION:case e.TransportItemType.MEASUREMENT:{const e=r[t.type],s=n[e];n=Object.assign(Object.assign({},n),{[e]:void 0===s?[t.payload]:[...s,t.payload]});break}case e.TransportItemType.TRACE:n=Object.assign(Object.assign({},n),{traces:W(n.traces,t.payload.resourceSpans)})}}),n},e.globalObject=R,e.initializeFaro=function(e){const t=z(e),n=H(t,e);if(ue()&&!e.isolate)return void n.error('Faro is already registered. Either add instrumentations, transports etc. to the global faro instance or use the "isolate" property');n.debug("Initializing");const r=function(e,t){let n=[],r=[];const s=()=>n.reduce((e,t)=>Object.assign(e,p(t)?t():t),{}),i=()=>{if(r.length){const e=s();r.forEach(t=>t(e))}};return{add:(...e)=>{t.debug("Adding metas\n",e),n.push(...e),i()},remove:(...e)=>{t.debug("Removing metas\n",e),n=n.filter(t=>!e.includes(t)),i()},addListener:e=>{t.debug("Adding metas listener\n",e),r.push(e)},removeListener:e=>{t.debug("Removing metas listener\n",e),r=r.filter(t=>t!==e)},get value(){return s()}}}(0,n),i=s(t,n,e,r),a=se(0,n,e,r,i),o=function(e,t,n,r,s,i){t.debug("Initializing instrumentations");const a=[];return{add:(...o)=>{t.debug("Adding instrumentations"),o.forEach(o=>{t.debug(`Adding "${o.name}" instrumentation`),a.some(e=>e.name===o.name)?t.warn(`Instrumentation ${o.name} is already added`):(o.unpatchedConsole=e,o.internalLogger=t,o.config=n,o.metas=r,o.transports=s,o.api=i,a.push(o),o.initialize())})},get instrumentations(){return[...a]},remove:(...e)=>{t.debug("Removing instrumentations"),e.forEach(e=>{var n,r;t.debug(`Removing "${e.name}" instrumentation`);const s=a.reduce((t,n,r)=>null===t&&n.name===e.name?r:null,null);null!==s?(null===(r=(n=a[s]).destroy)||void 0===r||r.call(n),a.splice(s,1)):t.warn(`Instrumentation "${e.name}" is not added`)})}}}(t,n,e,r,i,a),u=ce(t,n,e,r,i,a,o);return function(e){var t,n;const r={sdk:{version:ie,name:"faro"},app:{bundleId:e.config.app.name&&(s=e.config.app.name,null==R?void 0:R[`__faroBundleId_${s}`])}};var s;const i=null===(t=e.config.sessionTracking)||void 0===t?void 0:t.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!==(n=e.config.metas)&&void 0!==n?n:[])}(u),function(e){e.transports.add(...e.config.transports),e.transports.addBeforeSendHooks(e.config.beforeSend)}(u),function(e){e.instrumentations.add(...e.config.instrumentations)}(u),u},e.internalGlobalObjectKey=ae,e.isArray=f,e.isBoolean=e=>a(e,"boolean"),e.isDomError=e=>o(e,"DOMError"),e.isDomException=e=>o(e,"DOMException"),e.isElement=e=>v&&u(e,Element),e.isElementDefined=v,e.isEmpty=y,e.isError=b,e.isErrorDefined=h,e.isErrorEvent=e=>o(e,"ErrorEvent"),e.isEvent=e=>m&&u(e,Event),e.isEventDefined=m,e.isFunction=p,e.isInstanceOf=u,e.isInt=e=>d(e)&&Number.isInteger(e),e.isInternalFaroOnGlobalObject=ue,e.isMap=e=>E&&u(e,Map),e.isMapDefined=E,e.isNull=c,e.isNumber=d,e.isObject=g,e.isPrimitive=e=>!g(e)&&!p(e),e.isRegExp=e=>o(e,"RegExp"),e.isString=l,e.isSymbol=e=>a(e,"symbol"),e.isSyntheticEvent=e=>g(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e,e.isThenable=e=>p(null==e?void 0:e.then),e.isToString=o,e.isTypeof=a,e.isUndefined=e=>a(e,"undefined"),e.monoNow=O,e.noop=x,e.setInternalFaroOnGlobalObject=oe,e.stringifyExternalJson=k,e.stringifyObjectValues=C,e.transportItemTypeToBodyKey=r,e.unknownString="unknown",e.userActionsMessageBus=Y,e}({});
1
+ var GrafanaFaroCore=function(e){"use strict";class t{constructor(e,t){var n,r;this.signalBuffer=[],this.itemLimit=null!==(n=null==t?void 0:t.itemLimit)&&void 0!==n?n:50,this.sendTimeout=null!==(r=null==t?void 0:t.sendTimeout)&&void 0!==r?r:250,this.paused=(null==t?void 0:t.paused)||!1,this.sendFn=e,this.flushInterval=-1,this.paused||this.start(),document.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&this.flush()})}addItem(e){this.paused||(this.signalBuffer.push(e),this.signalBuffer.length>=this.itemLimit&&this.flush())}start(){this.paused=!1,this.sendTimeout>0&&(this.flushInterval=window.setInterval(()=>this.flush(),this.sendTimeout))}pause(){this.paused=!0,clearInterval(this.flushInterval)}groupItems(e){const t=new Map;return e.forEach(e=>{const n=JSON.stringify(e.meta);let r=t.get(n);r=void 0===r?[e]:[...r,e],t.set(n,r)}),Array.from(t.values())}flush(){if(this.paused||0===this.signalBuffer.length)return;this.groupItems(this.signalBuffer).forEach(this.sendFn),this.signalBuffer=[]}}var n;e.TransportItemType=void 0,(n=e.TransportItemType||(e.TransportItemType={})).EXCEPTION="exception",n.LOG="log",n.MEASUREMENT="measurement",n.TRACE="trace",n.EVENT="event";const r={[e.TransportItemType.EXCEPTION]:"exceptions",[e.TransportItemType.LOG]:"logs",[e.TransportItemType.MEASUREMENT]:"measurements",[e.TransportItemType.TRACE]:"traces",[e.TransportItemType.EVENT]:"events"};function i(e,n,r,i){var a;n.debug("Initializing transports");const o=[];let u=r.paused,c=[];const l=e=>{let t=e;for(const e of c){const n=t.map(e).filter(Boolean);if(0===n.length)return[];t=s(n,r)}return t},d=e=>{const t=l(e);if(0!==t.length)for(const e of o)n.debug(`Transporting item using ${e.name}\n`,t),e.isBatched()&&e.send(t)};let g;(null===(a=r.batching)||void 0===a?void 0:a.enabled)&&(g=new t(d,{sendTimeout:r.batching.sendTimeout,itemLimit:r.batching.itemLimit,paused:u}));return{add:(...t)=>{n.debug("Adding transports"),t.forEach(t=>{n.debug(`Adding "${t.name}" transport`);o.some(e=>e===t)?n.warn(`Transport ${t.name} is already added`):(t.unpatchedConsole=e,t.internalLogger=n,t.config=r,t.metas=i,o.push(t))})},addBeforeSendHooks:(...e)=>{n.debug("Adding beforeSendHooks\n",c),e.forEach(e=>{e&&c.push(e)})},getBeforeSendHooks:()=>[...c],execute:e=>{var t;u||((null===(t=r.batching)||void 0===t?void 0:t.enabled)&&(null==g||g.addItem(e)),(e=>{var t,i;if((null===(t=r.batching)||void 0===t?void 0:t.enabled)&&o.every(e=>e.isBatched()))return;const[s]=l([e]);if(void 0!==s)for(const e of o)n.debug(`Transporting item using ${e.name}\n`,s),e.isBatched()?(null===(i=r.batching)||void 0===i?void 0:i.enabled)||e.send([s]):e.send(s)})(e))},isPaused:()=>u,pause:()=>{n.debug("Pausing transports"),null==g||g.pause(),u=!0},remove:(...e)=>{n.debug("Removing transports"),e.forEach(e=>{n.debug(`Removing "${e.name}" transport`);const t=o.indexOf(e);-1!==t?o.splice(t,1):n.warn(`Transport "${e.name}" is not added`)})},removeBeforeSendHooks:(...e)=>{c.filter(t=>!e.includes(t))},get transports(){return[...o]},unpause:()=>{n.debug("Unpausing transports"),null==g||g.start(),u=!1}}}function s(t,n){if(n.preserveOriginalError)for(const n of t)n.type===e.TransportItemType.EXCEPTION&&delete n.payload.originalError;return t}function a(e,t){return typeof e===t}function o(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function u(e,t){try{return e instanceof t}catch(e){return!1}}const c=e=>a(e,"null"),l=e=>a(e,"string"),d=e=>a(e,"number")&&!isNaN(e)||a(e,"bigint"),g=e=>!c(e)&&a(e,"object"),p=e=>a(e,"function"),f=e=>o(e,"Array"),m="undefined"!=typeof Event,h="undefined"!=typeof Error,b=e=>h&&u(e,Error),v="undefined"!=typeof Element,E="undefined"!=typeof Map;function y(e){return null==e||(f(e)||l(e)?0===e.length:!!g(e)&&0===Object.keys(e).length)}function O(e,t){if(e===t)return!0;if(a(e,"number")&&isNaN(e))return a(t,"number")&&isNaN(t);const n=f(e),r=f(t);if(n!==r)return!1;if(n&&r){const n=e.length;if(n!==t.length)return!1;for(let r=n;0!==r--;)if(!O(e[r],t[r]))return!1;return!0}const i=g(e),s=g(t);if(i!==s)return!1;if(e&&t&&i&&s){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(!O(e[r],t[r]))return!1;return!0}return!1}function T(){return Date.now()}function I(){return"undefined"!=typeof performance&&"function"==typeof performance.now?performance.now():Date.now()}function S(){return(new Date).toISOString()}function A(e){return new Date(e).toISOString()}var L;e.LogLevel=void 0,(L=e.LogLevel||(e.LogLevel={})).TRACE="trace",L.DEBUG="debug",L.INFO="info",L.LOG="log",L.WARN="warn",L.ERROR="error";const _=e.LogLevel.LOG,j=[e.LogLevel.TRACE,e.LogLevel.DEBUG,e.LogLevel.INFO,e.LogLevel.LOG,e.LogLevel.WARN,e.LogLevel.ERROR];function w(){}const x="abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789";function N(e=10){return Array.from(Array(e)).map(()=>x[Math.floor(59*Math.random())]).join("")}const R="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:void 0;function U(e){const t=`__faroBundleId_${e}`,n=null==R?void 0:R[t];if("string"==typeof n&&""!==n)return n;const r="undefined"!=typeof window?window[t]:void 0;return"string"==typeof r&&""!==r?r:void 0}function k(){const e=new WeakSet;return function(t,n){if(g(n)&&null!==n){if(e.has(n))return null;e.add(n)}return n}}function C(e={}){return JSON.stringify(null!=e?e:{},k())}function B(e={}){const t={};for(const[n,r]of Object.entries(e))t[n]=g(r)&&null!==r?C(r):String(r);return t}class P{constructor(){this.subscribers=[]}subscribe(e){return this.subscribers.push(e),{unsubscribe:()=>this.unsubscribe(e)}}unsubscribe(e){this.subscribers=this.subscribers.filter(t=>t!==e)}notify(e){this.subscribers.forEach(t=>t(e))}first(){const e=new P,t=t=>{e.notify(t),n.unsubscribe()},n=this.subscribe(t),r=e.unsubscribe.bind(e);return this.withUnsubscribeOverride(e,r,t)}takeWhile(e){const t=new P,n=r=>{e(r)?t.notify(r):t.unsubscribe(n)};this.subscribe(n);const r=t.unsubscribe.bind(t);return this.withUnsubscribeOverride(t,r,n)}filter(e){const t=new P,n=n=>{e(n)&&t.notify(n)};this.subscribe(n);const r=t.unsubscribe.bind(t);return this.withUnsubscribeOverride(t,r,n)}merge(...e){const t=new P,n=[];e.forEach(e=>{const r=e.subscribe(e=>{t.notify(e)});n.push(r)});const r=t.unsubscribeAll.bind(t);return t.unsubscribe=()=>{n.forEach(e=>e.unsubscribe()),r()},t}withUnsubscribeOverride(e,t,n){return e.unsubscribe=e=>{t(e),this.unsubscribe(n)},e}unsubscribeAll(){this.subscribers=[]}}var M;e.InternalLoggerLevel=void 0,(M=e.InternalLoggerLevel||(e.InternalLoggerLevel={}))[M.OFF=0]="OFF",M[M.ERROR=1]="ERROR",M[M.WARN=2]="WARN",M[M.INFO=3]="INFO",M[M.VERBOSE=4]="VERBOSE";const D={debug:w,error:w,info:w,prefix:"Faro",warn:w},F=e.InternalLoggerLevel.ERROR,V=Object.assign({},console);let $=V;function z(e){var t;return $=null!==(t=e.unpatchedConsole)&&void 0!==t?t:$,$}function G(t=V,n=F){const r=D;return n>e.InternalLoggerLevel.OFF&&(r.error=n>=e.InternalLoggerLevel.ERROR?function(...e){t.error(`${r.prefix}\n`,...e)}:w,r.warn=n>=e.InternalLoggerLevel.WARN?function(...e){t.warn(`${r.prefix}\n`,...e)}:w,r.info=n>=e.InternalLoggerLevel.INFO?function(...e){t.info(`${r.prefix}\n`,...e)}:w,r.debug=n>=e.InternalLoggerLevel.VERBOSE?function(...e){t.debug(`${r.prefix}\n`,...e)}:w),r}let H=D;function K(e,t){return H=G(e,t.internalLoggerLevel),H}class W{constructor(){this.unpatchedConsole=V,this.internalLogger=D,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 X(e,t){var n,r;if(void 0===t)return e;if(void 0===e)return{resourceSpans:t};const i=null===(n=e.resourceSpans)||void 0===n?void 0:n[0];if(void 0===i)return e;const s=(null==i?void 0:i.scopeSpans)||[],a=(null===(r=null==t?void 0:t[0])||void 0===r?void 0:r.scopeSpans)||[];return Object.assign(Object.assign({},e),{resourceSpans:[Object.assign(Object.assign({},i),{scopeSpans:[...s,...a]})]})}const J={Normal:"normal",Critical:"critical"};var q;e.UserActionState=void 0,(q=e.UserActionState||(e.UserActionState={}))[q.Started=0]="Started",q[q.Halted=1]="Halted",q[q.Cancelled=2]="Cancelled",q[q.Ended=3]="Ended";class Q{constructor(){this.buffer=[]}addItem(e){this.buffer.push(e)}flushBuffer(e){if(p(e))for(const t of this.buffer)e(t);this.buffer.length=0}size(){return this.buffer.length}}class Y extends P{constructor({name:t,parentId:n,trigger:r,transports:i,attributes:s,trackUserActionsExcludeItem:a,importance:o=J.Normal,pushEvent:u}){super(),this.name=t,this.attributes=s,this.id=N(),this.trigger=r,this.parentId=null!=n?n:this.id,this.trackUserActionsExcludeItem=a,this.importance=o,this._pushEvent=u,this._itemBuffer=new Q,this._transports=i,this._state=e.UserActionState.Started,this._start()}addItem(t){return this._state===e.UserActionState.Started&&(this._itemBuffer.addItem(t),!0)}_start(){this._state=e.UserActionState.Started,this._state===e.UserActionState.Started&&(this.startTime=T(),this._startTimeMono=I())}halt(){this._state===e.UserActionState.Started&&(this._state=e.UserActionState.Halted,this.notify(this._state))}cancel(){this._state===e.UserActionState.Started&&this._itemBuffer.flushBuffer(e=>{this._transports.execute(e)}),this._state=e.UserActionState.Cancelled,this.notify(this._state)}end(){if(this._state===e.UserActionState.Cancelled)return;const t=T(),n=I()-this._startTimeMono;this._state=e.UserActionState.Ended,this._itemBuffer.flushBuffer(t=>{if(function(t,n){return(null==n?void 0:n(t))||t.type===e.TransportItemType.MEASUREMENT&&"web-vitals"===t.payload.type}(t,this.trackUserActionsExcludeItem))return void this._transports.execute(t);const n=Object.assign(Object.assign({},t),{payload:Object.assign(Object.assign({},t.payload),{action:{parentId:this.id,name:this.name}})});this._transports.execute(n)}),this._state=e.UserActionState.Ended,this.notify(this._state),this._pushEvent("faro.user.action",Object.assign({userActionName:this.name,userActionStartTime:this.startTime.toString(),userActionEndTime:t.toString(),userActionDuration:n.toString(),userActionTrigger:this.trigger,userActionImportance:this.importance},B(this.attributes)),void 0,{timestampOverwriteMs:this.startTime,customPayloadTransformer:e=>(e.action={id:this.id,name:this.name},e)})}getState(){return this._state}}const Z=new P;function ee(t,n){if(!t)return!1;return(null==t?void 0:t.getState())===e.UserActionState.Started&&(t.addItem(n),!0)}const te="Error";let ne;function re({internalLogger:t,config:n,metas:r,transports:i,tracesApi:s,userActionsApi:a}){var o;t.debug("Initializing exceptions API");let u=null;ne=null!==(o=n.parseStacktrace)&&void 0!==o?o:ne;const d=e=>{t.debug("Changing stacktrace parser"),ne=null!=e?e:ne},{ignoreErrors:p=[],preserveOriginalError:m}=n;return d(n.parseStacktrace),{changeStacktraceParser:d,getStacktraceParser:()=>ne,pushError:(o,{skipDedupe:d,stackFrames:h,type:v,context:E,spanContext:T,timestampOverwriteMs:I,originalError:L,fingerprint:_,fatal:j}={})=>{var w;if(!function(e,t){const{message:n,name:r,stack:i}=t;return s=e,a=n+" "+r+" "+i,s.some(e=>l(e)?a.includes(e):!!a.match(e));var s,a}(p,null!=L?L:o))try{const l=B(Object.assign(Object.assign({},function(e){let t=e.cause;b(t)?t=e.cause.toString():null!==t&&(g(e.cause)||f(e.cause))?t=C(e.cause):null!=t&&(t=e.cause.toString());return null==t?{}:{cause:t}}(null!=L?L:o)),null!=E?E:{})),p={meta:r.value,payload:Object.assign(Object.assign(Object.assign(Object.assign({type:v||o.name||te,value:o.message,timestamp:I?A(I):S(),trace:T?{trace_id:T.traceId,span_id:T.spanId}:s.getTraceContext()},y(l)?{}:{context:l}),m?{originalError:L}:{}),_?{fingerprint:_}:{}),void 0!==j?{fatal:j}:{}),type:e.TransportItemType.EXCEPTION};(null==(h=null!=h?h:o.stack?null==ne?void 0:ne(o).frames:void 0)?void 0:h.length)&&(p.payload.stacktrace={frames:h});const x={type:p.payload.type,value:p.payload.value,stacktrace:p.payload.stacktrace,context:p.payload.context,fingerprint:p.payload.fingerprint,fatal:null!==(w=p.payload.fatal)&&void 0!==w&&w};if(!d&&n.dedupe&&!c(u)&&O(x,u))return void t.debug("Skipping error push because it is the same as the last one\n",p.payload);u=x,t.debug("Pushing exception\n",p),ee(a.getActiveUserAction(),p)||i.execute(p)}catch(e){t.error("Error pushing event",e)}}}}const ie=e=>e.map(e=>{try{return String(e)}catch(e){return""}}).join(" ");function se(t,n,r,i,s){n.debug("Initializing API");let a=null;const o=function({transports:t,internalLogger:n,config:r,pushEvent:i}){var s;const a=null===(s=r.userActionsInstrumentation)||void 0===s?void 0:s.excludeItem;let o;const u=()=>o;return{startUserAction:(r,s,c)=>{if(void 0===u()){const n=new Y({name:r,transports:t,attributes:s,trigger:(null==c?void 0:c.triggerName)||"faroApiCall",importance:(null==c?void 0:c.importance)||J.Normal,trackUserActionsExcludeItem:a,pushEvent:i});return n.filter(t=>[e.UserActionState.Ended,e.UserActionState.Cancelled].includes(t)).first().subscribe(()=>{o=void 0}),Z.notify({type:"user_action_start",userAction:n}),o=n,o}n.error("Attempted to create a new user action while one is already running. This is not possible.")},getActiveUserAction:u}}({transports:s,config:r,internalLogger:n,pushEvent:(e,t,r,i)=>{a?a(e,t,r,i):n.warn("pushEventImpl is not initialized. Event dropped:",{name:e,attributes:t,domain:r,options:i})}}),u=function(t,n,r,i,s){let a;return n.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,t)=>{n.debug("Initializing OpenTelemetry"),a={trace:e,context:t}},isOTELInitialized:()=>!!a,pushTraces:t=>{try{const r={type:e.TransportItemType.TRACE,payload:t,meta:i.value};n.debug("Pushing trace\n",r),s.execute(r)}catch(e){n.error("Error pushing trace\n",e)}}}}(0,n,0,i,s),d={internalLogger:n,userActionsApi:o,config:r,metas:i,transports:s,tracesApi:u},g=function({internalLogger:t,config:n,metas:r,transports:i,tracesApi:s,userActionsApi:a}){let o=null;return{pushEvent:(u,l,d,{skipDedupe:g,spanContext:p,timestampOverwriteMs:f,customPayloadTransformer:m=e=>e}={})=>{try{const h=B(l),b={meta:r.value,payload:m({name:u,domain:null!=d?d:n.eventDomain,attributes:y(h)?void 0:h,timestamp:f?A(f):S(),trace:p?{trace_id:p.traceId,span_id:p.spanId}:s.getTraceContext()}),type:e.TransportItemType.EVENT},v={name:b.payload.name,attributes:b.payload.attributes,domain:b.payload.domain};if(!g&&n.dedupe&&!c(o)&&O(v,o))return void t.debug("Skipping event push because it is the same as the last one\n",b.payload);o=v,t.debug("Pushing event\n",b),ee(a.getActiveUserAction(),b)||i.execute(b)}catch(e){t.error("Error pushing event",e)}}}}(d);return a=g.pushEvent,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},u),re(d)),function({internalLogger:e,metas:t}){let n,r,i,s;e.debug("Initializing meta API");const a=e=>{r&&t.remove(r),r={user:e},t.add(r)},o=(e,r)=>{var i;const s=null==r?void 0:r.overrides,a=s?{overrides:Object.assign(Object.assign({},null===(i=null==n?void 0:n.session)||void 0===i?void 0:i.overrides),s)}:{};n&&t.remove(n),n={session:Object.assign(Object.assign({},y(e)?void 0:e),a)},t.add(n)},u=()=>t.value.session,c=()=>t.value.page;return{setUser:a,resetUser:a,setSession:o,resetSession:o,getSession:u,setView:(e,n)=>{var r;if((null==n?void 0:n.overrides)&&o(u(),{overrides:n.overrides}),(null===(r=null==i?void 0:i.view)||void 0===r?void 0:r.name)===(null==e?void 0:e.name))return;const s=i;i={view:e},t.add(i),s&&t.remove(s)},getView:()=>t.value.view,setPage:e=>{var n;const r=l(e)?Object.assign(Object.assign({},null!==(n=null==s?void 0:s.page)&&void 0!==n?n:c()),{id:e}):e;s&&t.remove(s),s={page:r},t.add(s)},getPage:c}}(d)),function({internalLogger:t,config:n,metas:r,transports:i,tracesApi:s,userActionsApi:a}){var o;t.debug("Initializing logs API");let u=null;const l=null!==(o=n.logArgsSerializer)&&void 0!==o?o:ie;return{pushLog:(o,{context:d,level:g,skipDedupe:p,spanContext:f,timestampOverwriteMs:m}={})=>{try{const h=B(d),b={type:e.TransportItemType.LOG,payload:{message:l(o),level:null!=g?g:_,context:y(h)?void 0:h,timestamp:m?A(m):S(),trace:f?{trace_id:f.traceId,span_id:f.spanId}:s.getTraceContext()},meta:r.value},v={message:b.payload.message,level:b.payload.level,context:b.payload.context};if(!p&&n.dedupe&&!c(u)&&O(v,u))return void t.debug("Skipping log push because it is the same as the last one\n",b.payload);u=v,t.debug("Pushing log\n",b),ee(a.getActiveUserAction(),b)||i.execute(b)}catch(e){t.error("Error pushing log\n",e)}}}}(d)),function({internalLogger:t,config:n,metas:r,transports:i,tracesApi:s,userActionsApi:a}){t.debug("Initializing measurements API");let o=null;return{pushMeasurement:(u,{skipDedupe:l,context:d,spanContext:g,timestampOverwriteMs:p}={})=>{try{const f=B(d),m={type:e.TransportItemType.MEASUREMENT,payload:Object.assign(Object.assign({},u),{trace:g?{trace_id:g.traceId,span_id:g.spanId}:s.getTraceContext(),timestamp:p?A(p):S(),context:y(f)?void 0:f}),meta:r.value},h={type:m.payload.type,values:m.payload.values,context:m.payload.context};if(!l&&n.dedupe&&!c(o)&&O(h,o))return void t.debug("Skipping measurement push because it is the same as the last one\n",m.payload);o=h,t.debug("Pushing measurement\n",m),ee(a.getActiveUserAction(),m)||i.execute(m)}catch(e){t.error("Error pushing measurement\n",e)}}}}(d)),g),o)}const ae="2.7.0";function oe(e){var t,n;const r=e.config.app.name,i=r?function(e){return null==R?void 0:R[`__faroGitHash_${e}`]}(r):void 0,s={sdk:{version:ae,name:"faro"},app:Object.assign({bundleId:r&&U(r)},void 0!==i?{gitHash:i}:{})},a=null===(t=e.config.sessionTracking)||void 0===t?void 0:t.session;a&&e.api.setSession(a),e.config.app&&(s.app=Object.assign(Object.assign({},e.config.app),s.app)),e.config.user&&(s.user=e.config.user),e.config.view&&(s.view=e.config.view),e.metas.add(s,...null!==(n=e.config.metas)&&void 0!==n?n:[])}const ue="_faroInternal";function ce(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(R,ue,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function le(){return ue in R}function de(t,n,r,i,s,a,o){return n.debug("Initializing Faro"),e.faro={api:a,config:r,instrumentations:o,internalLogger:n,metas:i,pause:s.pause,transports:s,unpatchedConsole:t,unpause:s.unpause},ce(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 R)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(R,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}(e.faro),e.faro}e.faro={api:{pushLog:()=>{},pushError:()=>{},changeStacktraceParser:()=>{},getStacktraceParser:()=>{},pushMeasurement:()=>{},pushTraces:()=>{},getOTEL:()=>{},getTraceContext:()=>{},initOTEL:()=>{},isOTELInitialized:()=>!1,setUser:()=>{},resetUser:()=>{},setSession:()=>{},resetSession:()=>{},getSession:()=>{},setView:()=>{},getView:()=>{},setPage:()=>{},getPage:()=>{},pushEvent:()=>{},startUserAction:()=>{},getActiveUserAction:()=>{}}};return e.BaseExtension=W,e.BaseInstrumentation=class extends W{constructor(){super(...arguments),this.api={},this.transports={}}},e.BaseTransport=class extends W{isBatched(){return!1}getIgnoreUrls(){return[]}},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=P,e.UserActionImportance=J,e.VERSION=ae,e.allLogLevels=j,e.clampSamplingRate=function(e){return Math.min(1,Math.max(0,e))},e.createInternalLogger=G,e.createPromiseBuffer=function(e){const{size:t,concurrency:n}=e,r=[];let i=0;const s=()=>{if(i<n&&r.length){const{producer:e,resolve:t,reject:n}=r.shift();i++,e().then(e=>{i--,s(),t(e)},e=>{i--,s(),n(e)})}};return{add:e=>{if(r.length+i>=t)throw new Error("Task buffer full");return new Promise((t,n)=>{r.push({producer:e,resolve:t,reject:n}),s()})}}},e.dateNow=T,e.deepEqual=O,e.defaultBatchingConfig={enabled:!0,sendTimeout:250,itemLimit:50},e.defaultErrorArgsSerializer=e=>e.map(e=>g(e)?C(e):String(e)).join(" "),e.defaultExceptionType=te,e.defaultGlobalObjectKey="faro",e.defaultInternalLoggerLevel=F,e.defaultLogArgsSerializer=ie,e.defaultLogLevel=_,e.defaultUnpatchedConsole=V,e.genShortID=N,e.getCircularDependencyReplacer=k,e.getCurrentTimestamp=S,e.getInternalFaroFromGlobalObject=function(){return R[ue]},e.getTransportBody=function(t){let n={meta:{}};return void 0!==t[0]&&(n.meta=t[0].meta),t.forEach(t=>{switch(t.type){case e.TransportItemType.LOG:case e.TransportItemType.EVENT:case e.TransportItemType.EXCEPTION:case e.TransportItemType.MEASUREMENT:{const e=r[t.type],i=n[e];n=Object.assign(Object.assign({},n),{[e]:void 0===i?[t.payload]:[...i,t.payload]});break}case e.TransportItemType.TRACE:n=Object.assign(Object.assign({},n),{traces:X(n.traces,t.payload.resourceSpans)})}}),n},e.globalObject=R,e.initializeFaro=function(e){const t=z(e),n=K(t,e);if(le()&&!e.isolate)return void n.error('Faro is already registered. Either add instrumentations, transports etc. to the global faro instance or use the "isolate" property');n.debug("Initializing");const r=function(e,t){let n=[],r=[];const i=()=>n.reduce((e,t)=>Object.assign(e,p(t)?t():t),{}),s=()=>{if(r.length){const e=i();r.forEach(t=>t(e))}};return{add:(...e)=>{t.debug("Adding metas\n",e),n.push(...e),s()},remove:(...e)=>{t.debug("Removing metas\n",e),n=n.filter(t=>!e.includes(t)),s()},addListener:e=>{t.debug("Adding metas listener\n",e),r.push(e)},removeListener:e=>{t.debug("Removing metas listener\n",e),r=r.filter(t=>t!==e)},get value(){return i()}}}(0,n),s=i(t,n,e,r),a=se(0,n,e,r,s),o=function(e,t,n,r,i,s){t.debug("Initializing instrumentations");const a=[];return{add:(...o)=>{t.debug("Adding instrumentations"),o.forEach(o=>{t.debug(`Adding "${o.name}" instrumentation`),a.some(e=>e.name===o.name)?t.warn(`Instrumentation ${o.name} is already added`):(o.unpatchedConsole=e,o.internalLogger=t,o.config=n,o.metas=r,o.transports=i,o.api=s,a.push(o),o.initialize())})},get instrumentations(){return[...a]},remove:(...e)=>{t.debug("Removing instrumentations"),e.forEach(e=>{var n,r;t.debug(`Removing "${e.name}" instrumentation`);const i=a.reduce((t,n,r)=>null===t&&n.name===e.name?r:null,null);null!==i?(null===(r=(n=a[i]).destroy)||void 0===r||r.call(n),a.splice(i,1)):t.warn(`Instrumentation "${e.name}" is not added`)})}}}(t,n,e,r,s,a),u=de(t,n,e,r,s,a,o);return oe(u),function(e){e.transports.add(...e.config.transports),e.transports.addBeforeSendHooks(e.config.beforeSend)}(u),function(e){e.instrumentations.add(...e.config.instrumentations)}(u),u},e.internalGlobalObjectKey=ue,e.isArray=f,e.isBoolean=e=>a(e,"boolean"),e.isDomError=e=>o(e,"DOMError"),e.isDomException=e=>o(e,"DOMException"),e.isElement=e=>v&&u(e,Element),e.isElementDefined=v,e.isEmpty=y,e.isError=b,e.isErrorDefined=h,e.isErrorEvent=e=>o(e,"ErrorEvent"),e.isEvent=e=>m&&u(e,Event),e.isEventDefined=m,e.isFunction=p,e.isInstanceOf=u,e.isInt=e=>d(e)&&Number.isInteger(e),e.isInternalFaroOnGlobalObject=le,e.isMap=e=>E&&u(e,Map),e.isMapDefined=E,e.isNull=c,e.isNumber=d,e.isObject=g,e.isPrimitive=e=>!g(e)&&!p(e),e.isRegExp=e=>o(e,"RegExp"),e.isString=l,e.isSymbol=e=>a(e,"symbol"),e.isSyntheticEvent=e=>g(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e,e.isThenable=e=>p(null==e?void 0:e.then),e.isToString=o,e.isTypeof=a,e.isUndefined=e=>a(e,"undefined"),e.monoNow=I,e.noop=w,e.setInternalFaroOnGlobalObject=ce,e.stringifyExternalJson=C,e.stringifyObjectValues=B,e.transportItemTypeToBodyKey=r,e.unknownString="unknown",e.userActionsMessageBus=Z,e}({});
@@ -20,6 +20,7 @@ export interface MetaSDK {
20
20
  }
21
21
  export interface MetaApp {
22
22
  bundleId?: string;
23
+ gitHash?: string;
23
24
  environment?: string;
24
25
  installationId?: string;
25
26
  name?: string;
@@ -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 = "2.6.2";
7
+ readonly version = "2.7.0";
8
8
  items: TransportItem[];
9
9
  constructor(ignoreURLs?: Patterns);
10
10
  send(items: TransportItem[]): void | Promise<void>;
@@ -9,7 +9,7 @@ export { noop } from './noop';
9
9
  export { createPromiseBuffer } from './promiseBuffer';
10
10
  export type { BufferItem, PromiseBuffer, PromiseBufferOptions, PromiseProducer } from './promiseBuffer';
11
11
  export { genShortID } from './shortId';
12
- export { getBundleId } from './sourceMaps';
12
+ export { getBundleId, getGitHash } from './sourceMaps';
13
13
  export { dateNow, monoNow } from './date';
14
14
  export { getCircularDependencyReplacer, stringifyExternalJson, stringifyObjectValues } from './json';
15
15
  export { Observable } from './reactive';
@@ -1 +1,7 @@
1
+ /**
2
+ * Reads the bundle id injected by `@grafana/faro-metro-plugin` / webpack plugin preamble.
3
+ * Prefer `globalObject` (globalThis-first). Also check `window` for older bundles that set the
4
+ * property only on `window` when it differed from `globalThis` (e.g. legacy preamble order).
5
+ */
1
6
  export declare function getBundleId(appName: string): string | undefined;
7
+ export declare function getGitHash(appName: string): string | undefined;
@@ -1 +1 @@
1
- export declare const VERSION = "2.6.2";
1
+ export declare const VERSION = "2.7.0";
@@ -5,14 +5,14 @@ const sourceMaps_1 = require("../utils/sourceMaps");
5
5
  const version_1 = require("../version");
6
6
  function registerInitialMetas(faro) {
7
7
  var _a, _b;
8
+ const appName = faro.config.app.name;
9
+ const gitHash = appName ? (0, sourceMaps_1.getGitHash)(appName) : undefined;
8
10
  const initial = {
9
11
  sdk: {
10
12
  version: version_1.VERSION,
11
13
  name: 'faro',
12
14
  },
13
- app: {
14
- bundleId: faro.config.app.name && (0, sourceMaps_1.getBundleId)(faro.config.app.name),
15
- },
15
+ app: Object.assign({ bundleId: appName && (0, sourceMaps_1.getBundleId)(appName) }, (gitHash !== undefined ? { gitHash } : {})),
16
16
  };
17
17
  const session = (_a = faro.config.sessionTracking) === null || _a === void 0 ? void 0 : _a.session;
18
18
  if (session) {
@@ -1 +1 @@
1
- {"version":3,"file":"registerInitial.js","sourceRoot":"","sources":["../../../src/metas/registerInitial.ts"],"names":[],"mappings":";;AAMA,oDA6BC;AAlCD,oDAAkD;AAClD,wCAAqC;AAIrC,SAAgB,oBAAoB,CAAC,IAAU;;IAC7C,MAAM,OAAO,GAAS;QACpB,GAAG,EAAE;YACH,OAAO,EAAE,iBAAO;YAChB,IAAI,EAAE,MAAM;SACb;QACD,GAAG,EAAE;YACH,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI,IAAA,wBAAW,EAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;SACpE;KACF,CAAC;IAEF,MAAM,OAAO,GAAG,MAAA,IAAI,CAAC,MAAM,CAAC,eAAe,0CAAE,OAAO,CAAC;IACrD,IAAI,OAAO,EAAE,CAAC;QACZ,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QACpB,OAAO,CAAC,GAAG,mCAAQ,IAAI,CAAC,MAAM,CAAC,GAAG,GAAK,OAAO,CAAC,GAAG,CAAE,CAAC;IACvD,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAClC,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAClC,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,MAAA,IAAI,CAAC,MAAM,CAAC,KAAK,mCAAI,EAAE,CAAC,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import type { Faro } from '../sdk';\nimport { getBundleId } from '../utils/sourceMaps';\nimport { VERSION } from '../version';\n\nimport type { Meta } from './types';\n\nexport function registerInitialMetas(faro: Faro): void {\n const initial: Meta = {\n sdk: {\n version: VERSION,\n name: 'faro',\n },\n app: {\n bundleId: faro.config.app.name && getBundleId(faro.config.app.name),\n },\n };\n\n const session = faro.config.sessionTracking?.session;\n if (session) {\n faro.api.setSession(session);\n }\n\n if (faro.config.app) {\n initial.app = { ...faro.config.app, ...initial.app };\n }\n\n if (faro.config.user) {\n initial.user = faro.config.user;\n }\n\n if (faro.config.view) {\n initial.view = faro.config.view;\n }\n\n faro.metas.add(initial, ...(faro.config.metas ?? []));\n}\n"]}
1
+ {"version":3,"file":"registerInitial.js","sourceRoot":"","sources":["../../../src/metas/registerInitial.ts"],"names":[],"mappings":";;AAMA,oDAiCC;AAtCD,oDAA8D;AAC9D,wCAAqC;AAIrC,SAAgB,oBAAoB,CAAC,IAAU;;IAC7C,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;IACrC,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,IAAA,uBAAU,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE1D,MAAM,OAAO,GAAS;QACpB,GAAG,EAAE;YACH,OAAO,EAAE,iBAAO;YAChB,IAAI,EAAE,MAAM;SACb;QACD,GAAG,kBACD,QAAQ,EAAE,OAAO,IAAI,IAAA,wBAAW,EAAC,OAAO,CAAC,IACtC,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAC9C;KACF,CAAC;IAEF,MAAM,OAAO,GAAG,MAAA,IAAI,CAAC,MAAM,CAAC,eAAe,0CAAE,OAAO,CAAC;IACrD,IAAI,OAAO,EAAE,CAAC;QACZ,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QACpB,OAAO,CAAC,GAAG,mCAAQ,IAAI,CAAC,MAAM,CAAC,GAAG,GAAK,OAAO,CAAC,GAAG,CAAE,CAAC;IACvD,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAClC,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAClC,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,MAAA,IAAI,CAAC,MAAM,CAAC,KAAK,mCAAI,EAAE,CAAC,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import type { Faro } from '../sdk';\nimport { getBundleId, getGitHash } from '../utils/sourceMaps';\nimport { VERSION } from '../version';\n\nimport type { Meta } from './types';\n\nexport function registerInitialMetas(faro: Faro): void {\n const appName = faro.config.app.name;\n const gitHash = appName ? getGitHash(appName) : undefined;\n\n const initial: Meta = {\n sdk: {\n version: VERSION,\n name: 'faro',\n },\n app: {\n bundleId: appName && getBundleId(appName),\n ...(gitHash !== undefined ? { gitHash } : {}),\n },\n };\n\n const session = faro.config.sessionTracking?.session;\n if (session) {\n faro.api.setSession(session);\n }\n\n if (faro.config.app) {\n initial.app = { ...faro.config.app, ...initial.app };\n }\n\n if (faro.config.user) {\n initial.user = faro.config.user;\n }\n\n if (faro.config.view) {\n initial.view = faro.config.view;\n }\n\n faro.metas.add(initial, ...(faro.config.metas ?? []));\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/metas/types.ts"],"names":[],"mappings":"","sourcesContent":["export type MetaGetter<P = Partial<Meta>> = () => P;\n\nexport type MetaItem<P = Partial<Meta>> = P | MetaGetter<P>;\n\nexport type MetasListener = (value: Meta) => void;\n\nexport interface Metas {\n add: (...getters: MetaItem[]) => void;\n remove: (...getters: MetaItem[]) => void;\n addListener: (listener: MetasListener) => void;\n removeListener: (listener: MetasListener) => void;\n value: Meta;\n}\n\nexport type MetaAttributes = Record<string, string>;\n\nexport interface MetaSDKIntegration {\n name?: string;\n version?: string;\n}\n\nexport interface MetaSDK {\n name?: string;\n version?: string;\n integrations?: MetaSDKIntegration[];\n}\n\nexport interface MetaApp {\n bundleId?: string;\n environment?: string;\n installationId?: string;\n name?: string;\n namespace?: string;\n release?: string;\n version?: string;\n}\n\nexport interface MetaUser {\n /**\n * User email address.\n */\n email?: string;\n /**\n * Unique identifier\n */\n id?: string;\n /**\n * Short name or login/username of the user.\n */\n username?: string;\n /**\n * User’s full name\n */\n fullName?: string;\n /**\n * comma separated list of user roles. \"admin\",editor\" etc.\n */\n roles?: string;\n /**\n * Unique user hash to correlate information for a user in anonymized form.\n */\n hash?: string;\n /**\n * arbitrary user attributes, must be of type string.\n */\n attributes?: MetaAttributes;\n}\n\nexport interface MetaSession {\n id?: string;\n attributes?: MetaAttributes;\n overrides?: MetaOverrides;\n}\n\nexport interface MetaPage {\n id?: string;\n url?: string;\n attributes?: MetaAttributes;\n}\n\ninterface NavigatorUABrandVersion {\n brand?: string;\n version?: string;\n}\n\nexport interface MetaBrowser {\n name?: string;\n version?: string;\n os?: string;\n mobile?: boolean;\n userAgent?: string;\n language?: string;\n brands?: NavigatorUABrandVersion[] | string;\n viewportWidth?: string;\n viewportHeight?: string;\n}\n\nexport interface MetaView {\n name: string;\n}\n\nexport interface MetaK6 {\n isK6Browser?: boolean;\n testRunId?: string;\n}\n\n// Fields on MetaOS and MetaDevice use snake_case to mirror the Faro spec wire\n// format, which in turn mirrors OTel `os.*` and `device.*` semantic convention\n// attribute keys (e.g. os.build_id, device.model.identifier). Intentionally\n// inconsistent with the camelCase used elsewhere in Meta.\nexport interface MetaOS {\n name?: string;\n version?: string;\n build_id?: string;\n detail?: string;\n}\n\nexport interface MetaDevice {\n manufacturer?: string;\n model_identifier?: string;\n model_name?: string;\n brand?: string;\n is_physical?: boolean;\n type?: string;\n}\n\nexport interface Meta {\n sdk?: MetaSDK;\n app?: MetaApp;\n user?: MetaUser;\n session?: MetaSession;\n page?: MetaPage;\n browser?: MetaBrowser;\n view?: MetaView;\n k6?: MetaK6;\n os?: MetaOS;\n device?: MetaDevice;\n}\n\n/**\n * MetaOverrides are instructions that allow the receiver to override certain properties (Grafana Cloud only).\n */\nexport type MetaOverrides = {\n /**\n * New service name (Grafana Cloud only)\n */\n serviceName?: string;\n\n /**\n * Enable or disable geolocation tracking (Grafana Cloud only).\n * Geolocation tracking must be enabled in the Grafana Cloud settings first.\n * It cannot be enabled solely on the client side.\n * This option allows control over tracking on the client side to comply with user\n * privacy requirements.\n */\n geoLocationTrackingEnabled?: boolean;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/metas/types.ts"],"names":[],"mappings":"","sourcesContent":["export type MetaGetter<P = Partial<Meta>> = () => P;\n\nexport type MetaItem<P = Partial<Meta>> = P | MetaGetter<P>;\n\nexport type MetasListener = (value: Meta) => void;\n\nexport interface Metas {\n add: (...getters: MetaItem[]) => void;\n remove: (...getters: MetaItem[]) => void;\n addListener: (listener: MetasListener) => void;\n removeListener: (listener: MetasListener) => void;\n value: Meta;\n}\n\nexport type MetaAttributes = Record<string, string>;\n\nexport interface MetaSDKIntegration {\n name?: string;\n version?: string;\n}\n\nexport interface MetaSDK {\n name?: string;\n version?: string;\n integrations?: MetaSDKIntegration[];\n}\n\nexport interface MetaApp {\n bundleId?: string;\n gitHash?: string;\n environment?: string;\n installationId?: string;\n name?: string;\n namespace?: string;\n release?: string;\n version?: string;\n}\n\nexport interface MetaUser {\n /**\n * User email address.\n */\n email?: string;\n /**\n * Unique identifier\n */\n id?: string;\n /**\n * Short name or login/username of the user.\n */\n username?: string;\n /**\n * User’s full name\n */\n fullName?: string;\n /**\n * comma separated list of user roles. \"admin\",editor\" etc.\n */\n roles?: string;\n /**\n * Unique user hash to correlate information for a user in anonymized form.\n */\n hash?: string;\n /**\n * arbitrary user attributes, must be of type string.\n */\n attributes?: MetaAttributes;\n}\n\nexport interface MetaSession {\n id?: string;\n attributes?: MetaAttributes;\n overrides?: MetaOverrides;\n}\n\nexport interface MetaPage {\n id?: string;\n url?: string;\n attributes?: MetaAttributes;\n}\n\ninterface NavigatorUABrandVersion {\n brand?: string;\n version?: string;\n}\n\nexport interface MetaBrowser {\n name?: string;\n version?: string;\n os?: string;\n mobile?: boolean;\n userAgent?: string;\n language?: string;\n brands?: NavigatorUABrandVersion[] | string;\n viewportWidth?: string;\n viewportHeight?: string;\n}\n\nexport interface MetaView {\n name: string;\n}\n\nexport interface MetaK6 {\n isK6Browser?: boolean;\n testRunId?: string;\n}\n\n// Fields on MetaOS and MetaDevice use snake_case to mirror the Faro spec wire\n// format, which in turn mirrors OTel `os.*` and `device.*` semantic convention\n// attribute keys (e.g. os.build_id, device.model.identifier). Intentionally\n// inconsistent with the camelCase used elsewhere in Meta.\nexport interface MetaOS {\n name?: string;\n version?: string;\n build_id?: string;\n detail?: string;\n}\n\nexport interface MetaDevice {\n manufacturer?: string;\n model_identifier?: string;\n model_name?: string;\n brand?: string;\n is_physical?: boolean;\n type?: string;\n}\n\nexport interface Meta {\n sdk?: MetaSDK;\n app?: MetaApp;\n user?: MetaUser;\n session?: MetaSession;\n page?: MetaPage;\n browser?: MetaBrowser;\n view?: MetaView;\n k6?: MetaK6;\n os?: MetaOS;\n device?: MetaDevice;\n}\n\n/**\n * MetaOverrides are instructions that allow the receiver to override certain properties (Grafana Cloud only).\n */\nexport type MetaOverrides = {\n /**\n * New service name (Grafana Cloud only)\n */\n serviceName?: string;\n\n /**\n * Enable or disable geolocation tracking (Grafana Cloud only).\n * Geolocation tracking must be enabled in the Grafana Cloud settings first.\n * It cannot be enabled solely on the client side.\n * This option allows control over tracking on the client side to comply with user\n * privacy requirements.\n */\n geoLocationTrackingEnabled?: boolean;\n};\n"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Observable = exports.stringifyObjectValues = exports.stringifyExternalJson = exports.getCircularDependencyReplacer = exports.monoNow = exports.dateNow = exports.getBundleId = exports.genShortID = exports.createPromiseBuffer = exports.noop = exports.LogLevel = exports.defaultLogLevel = exports.allLogLevels = exports.isEmpty = exports.isUndefined = exports.isTypeof = exports.isToString = exports.isThenable = exports.isSyntheticEvent = exports.isSymbol = exports.isString = exports.isRegExp = exports.isPrimitive = exports.isObject = exports.isNumber = exports.isNull = exports.isMapDefined = exports.isMap = exports.isInt = exports.isInstanceOf = exports.isFunction = exports.isEventDefined = exports.isEvent = exports.isErrorEvent = exports.isErrorDefined = exports.isError = exports.isElementDefined = exports.isElement = exports.isDomException = exports.isDomError = exports.isBoolean = exports.isArray = exports.getCurrentTimestamp = exports.deepEqual = exports.clampSamplingRate = void 0;
3
+ exports.Observable = exports.stringifyObjectValues = exports.stringifyExternalJson = exports.getCircularDependencyReplacer = exports.monoNow = exports.dateNow = exports.getGitHash = exports.getBundleId = exports.genShortID = exports.createPromiseBuffer = exports.noop = exports.LogLevel = exports.defaultLogLevel = exports.allLogLevels = exports.isEmpty = exports.isUndefined = exports.isTypeof = exports.isToString = exports.isThenable = exports.isSyntheticEvent = exports.isSymbol = exports.isString = exports.isRegExp = exports.isPrimitive = exports.isObject = exports.isNumber = exports.isNull = exports.isMapDefined = exports.isMap = exports.isInt = exports.isInstanceOf = exports.isFunction = exports.isEventDefined = exports.isEvent = exports.isErrorEvent = exports.isErrorDefined = exports.isError = exports.isElementDefined = exports.isElement = exports.isDomException = exports.isDomError = exports.isBoolean = exports.isArray = exports.getCurrentTimestamp = exports.deepEqual = exports.clampSamplingRate = void 0;
4
4
  var sampling_1 = require("./sampling");
5
5
  Object.defineProperty(exports, "clampSamplingRate", { enumerable: true, get: function () { return sampling_1.clampSamplingRate; } });
6
6
  var deepEqual_1 = require("./deepEqual");
@@ -49,6 +49,7 @@ var shortId_1 = require("./shortId");
49
49
  Object.defineProperty(exports, "genShortID", { enumerable: true, get: function () { return shortId_1.genShortID; } });
50
50
  var sourceMaps_1 = require("./sourceMaps");
51
51
  Object.defineProperty(exports, "getBundleId", { enumerable: true, get: function () { return sourceMaps_1.getBundleId; } });
52
+ Object.defineProperty(exports, "getGitHash", { enumerable: true, get: function () { return sourceMaps_1.getGitHash; } });
52
53
  var date_2 = require("./date");
53
54
  Object.defineProperty(exports, "dateNow", { enumerable: true, get: function () { return date_2.dateNow; } });
54
55
  Object.defineProperty(exports, "monoNow", { enumerable: true, get: function () { return date_2.monoNow; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAEA,uCAA+C;AAAtC,6GAAA,iBAAiB,OAAA;AAE1B,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAElB,+BAA6C;AAApC,2GAAA,mBAAmB,OAAA;AAE5B,2BA8Bc;AA7BZ,6FAAA,OAAO,OAAA;AACP,+FAAA,SAAS,OAAA;AACT,gGAAA,UAAU,OAAA;AACV,oGAAA,cAAc,OAAA;AACd,+FAAA,SAAS,OAAA;AACT,sGAAA,gBAAgB,OAAA;AAChB,6FAAA,OAAO,OAAA;AACP,oGAAA,cAAc,OAAA;AACd,kGAAA,YAAY,OAAA;AACZ,6FAAA,OAAO,OAAA;AACP,oGAAA,cAAc,OAAA;AACd,gGAAA,UAAU,OAAA;AACV,kGAAA,YAAY,OAAA;AACZ,2FAAA,KAAK,OAAA;AACL,2FAAA,KAAK,OAAA;AACL,kGAAA,YAAY,OAAA;AACZ,4FAAA,MAAM,OAAA;AACN,8FAAA,QAAQ,OAAA;AACR,8FAAA,QAAQ,OAAA;AACR,iGAAA,WAAW,OAAA;AACX,8FAAA,QAAQ,OAAA;AACR,8FAAA,QAAQ,OAAA;AACR,8FAAA,QAAQ,OAAA;AACR,sGAAA,gBAAgB,OAAA;AAChB,gGAAA,UAAU,OAAA;AACV,gGAAA,UAAU,OAAA;AACV,8FAAA,QAAQ,OAAA;AACR,iGAAA,WAAW,OAAA;AACX,6FAAA,OAAO,OAAA;AAIT,yCAAsE;AAA7D,yGAAA,YAAY,OAAA;AAAE,4GAAA,eAAe,OAAA;AAAE,qGAAA,QAAQ,OAAA;AAEhD,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AAEb,iDAAsD;AAA7C,oHAAA,mBAAmB,OAAA;AAG5B,qCAAuC;AAA9B,qGAAA,UAAU,OAAA;AAEnB,2CAA2C;AAAlC,yGAAA,WAAW,OAAA;AAEpB,+BAA0C;AAAjC,+FAAA,OAAO,OAAA;AAAE,+FAAA,OAAO,OAAA;AAEzB,+BAAqG;AAA5F,qHAAA,6BAA6B,OAAA;AAAE,6GAAA,qBAAqB,OAAA;AAAE,6GAAA,qBAAqB,OAAA;AAEpF,uCAAwC;AAA/B,sGAAA,UAAU,OAAA","sourcesContent":["export type { BaseObject, BaseObjectKey, BaseObjectPrimitiveValue, BaseObjectValue } from './baseObject';\n\nexport { clampSamplingRate } from './sampling';\n\nexport { deepEqual } from './deepEqual';\n\nexport { getCurrentTimestamp } from './date';\n\nexport {\n isArray,\n isBoolean,\n isDomError,\n isDomException,\n isElement,\n isElementDefined,\n isError,\n isErrorDefined,\n isErrorEvent,\n isEvent,\n isEventDefined,\n isFunction,\n isInstanceOf,\n isInt,\n isMap,\n isMapDefined,\n isNull,\n isNumber,\n isObject,\n isPrimitive,\n isRegExp,\n isString,\n isSymbol,\n isSyntheticEvent,\n isThenable,\n isToString,\n isTypeof,\n isUndefined,\n isEmpty,\n} from './is';\nexport type { IsFnHelper } from './is';\n\nexport { allLogLevels, defaultLogLevel, LogLevel } from './logLevels';\n\nexport { noop } from './noop';\n\nexport { createPromiseBuffer } from './promiseBuffer';\nexport type { BufferItem, PromiseBuffer, PromiseBufferOptions, PromiseProducer } from './promiseBuffer';\n\nexport { genShortID } from './shortId';\n\nexport { getBundleId } from './sourceMaps';\n\nexport { dateNow, monoNow } from './date';\n\nexport { getCircularDependencyReplacer, stringifyExternalJson, stringifyObjectValues } from './json';\n\nexport { Observable } from './reactive';\nexport type { Subscription } from './reactive';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAEA,uCAA+C;AAAtC,6GAAA,iBAAiB,OAAA;AAE1B,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAElB,+BAA6C;AAApC,2GAAA,mBAAmB,OAAA;AAE5B,2BA8Bc;AA7BZ,6FAAA,OAAO,OAAA;AACP,+FAAA,SAAS,OAAA;AACT,gGAAA,UAAU,OAAA;AACV,oGAAA,cAAc,OAAA;AACd,+FAAA,SAAS,OAAA;AACT,sGAAA,gBAAgB,OAAA;AAChB,6FAAA,OAAO,OAAA;AACP,oGAAA,cAAc,OAAA;AACd,kGAAA,YAAY,OAAA;AACZ,6FAAA,OAAO,OAAA;AACP,oGAAA,cAAc,OAAA;AACd,gGAAA,UAAU,OAAA;AACV,kGAAA,YAAY,OAAA;AACZ,2FAAA,KAAK,OAAA;AACL,2FAAA,KAAK,OAAA;AACL,kGAAA,YAAY,OAAA;AACZ,4FAAA,MAAM,OAAA;AACN,8FAAA,QAAQ,OAAA;AACR,8FAAA,QAAQ,OAAA;AACR,iGAAA,WAAW,OAAA;AACX,8FAAA,QAAQ,OAAA;AACR,8FAAA,QAAQ,OAAA;AACR,8FAAA,QAAQ,OAAA;AACR,sGAAA,gBAAgB,OAAA;AAChB,gGAAA,UAAU,OAAA;AACV,gGAAA,UAAU,OAAA;AACV,8FAAA,QAAQ,OAAA;AACR,iGAAA,WAAW,OAAA;AACX,6FAAA,OAAO,OAAA;AAIT,yCAAsE;AAA7D,yGAAA,YAAY,OAAA;AAAE,4GAAA,eAAe,OAAA;AAAE,qGAAA,QAAQ,OAAA;AAEhD,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AAEb,iDAAsD;AAA7C,oHAAA,mBAAmB,OAAA;AAG5B,qCAAuC;AAA9B,qGAAA,UAAU,OAAA;AAEnB,2CAAuD;AAA9C,yGAAA,WAAW,OAAA;AAAE,wGAAA,UAAU,OAAA;AAEhC,+BAA0C;AAAjC,+FAAA,OAAO,OAAA;AAAE,+FAAA,OAAO,OAAA;AAEzB,+BAAqG;AAA5F,qHAAA,6BAA6B,OAAA;AAAE,6GAAA,qBAAqB,OAAA;AAAE,6GAAA,qBAAqB,OAAA;AAEpF,uCAAwC;AAA/B,sGAAA,UAAU,OAAA","sourcesContent":["export type { BaseObject, BaseObjectKey, BaseObjectPrimitiveValue, BaseObjectValue } from './baseObject';\n\nexport { clampSamplingRate } from './sampling';\n\nexport { deepEqual } from './deepEqual';\n\nexport { getCurrentTimestamp } from './date';\n\nexport {\n isArray,\n isBoolean,\n isDomError,\n isDomException,\n isElement,\n isElementDefined,\n isError,\n isErrorDefined,\n isErrorEvent,\n isEvent,\n isEventDefined,\n isFunction,\n isInstanceOf,\n isInt,\n isMap,\n isMapDefined,\n isNull,\n isNumber,\n isObject,\n isPrimitive,\n isRegExp,\n isString,\n isSymbol,\n isSyntheticEvent,\n isThenable,\n isToString,\n isTypeof,\n isUndefined,\n isEmpty,\n} from './is';\nexport type { IsFnHelper } from './is';\n\nexport { allLogLevels, defaultLogLevel, LogLevel } from './logLevels';\n\nexport { noop } from './noop';\n\nexport { createPromiseBuffer } from './promiseBuffer';\nexport type { BufferItem, PromiseBuffer, PromiseBufferOptions, PromiseProducer } from './promiseBuffer';\n\nexport { genShortID } from './shortId';\n\nexport { getBundleId, getGitHash } from './sourceMaps';\n\nexport { dateNow, monoNow } from './date';\n\nexport { getCircularDependencyReplacer, stringifyExternalJson, stringifyObjectValues } from './json';\n\nexport { Observable } from './reactive';\nexport type { Subscription } from './reactive';\n"]}
@@ -1,8 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getBundleId = getBundleId;
4
+ exports.getGitHash = getGitHash;
4
5
  const globalObject_1 = require("../globalObject");
6
+ /**
7
+ * Reads the bundle id injected by `@grafana/faro-metro-plugin` / webpack plugin preamble.
8
+ * Prefer `globalObject` (globalThis-first). Also check `window` for older bundles that set the
9
+ * property only on `window` when it differed from `globalThis` (e.g. legacy preamble order).
10
+ */
5
11
  function getBundleId(appName) {
6
- return globalObject_1.globalObject === null || globalObject_1.globalObject === void 0 ? void 0 : globalObject_1.globalObject[`__faroBundleId_${appName}`];
12
+ const key = `__faroBundleId_${appName}`;
13
+ const fromGlobal = globalObject_1.globalObject === null || globalObject_1.globalObject === void 0 ? void 0 : globalObject_1.globalObject[key];
14
+ if (typeof fromGlobal === 'string' && fromGlobal !== '') {
15
+ return fromGlobal;
16
+ }
17
+ const fromWindow = typeof window !== 'undefined' ? window[key] : undefined;
18
+ if (typeof fromWindow === 'string' && fromWindow !== '') {
19
+ return fromWindow;
20
+ }
21
+ return undefined;
22
+ }
23
+ function getGitHash(appName) {
24
+ return globalObject_1.globalObject === null || globalObject_1.globalObject === void 0 ? void 0 : globalObject_1.globalObject[`__faroGitHash_${appName}`];
7
25
  }
8
26
  //# sourceMappingURL=sourceMaps.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sourceMaps.js","sourceRoot":"","sources":["../../../src/utils/sourceMaps.ts"],"names":[],"mappings":";;AAEA,kCAEC;AAJD,kDAA+C;AAE/C,SAAgB,WAAW,CAAC,OAAe;IACzC,OAAQ,2BAAoB,aAApB,2BAAY,uBAAZ,2BAAY,CAAW,kBAAkB,OAAO,EAAE,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["import { globalObject } from '../globalObject';\n\nexport function getBundleId(appName: string): string | undefined {\n return (globalObject as any)?.[`__faroBundleId_${appName}`];\n}\n"]}
1
+ {"version":3,"file":"sourceMaps.js","sourceRoot":"","sources":["../../../src/utils/sourceMaps.ts"],"names":[],"mappings":";;AAOA,kCAWC;AAED,gCAEC;AAtBD,kDAA+C;AAE/C;;;;GAIG;AACH,SAAgB,WAAW,CAAC,OAAe;IACzC,MAAM,GAAG,GAAG,kBAAkB,OAAO,EAAE,CAAC;IACxC,MAAM,UAAU,GAAI,2BAAoB,aAApB,2BAAY,uBAAZ,2BAAY,CAAW,GAAG,CAAC,CAAC;IAChD,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,EAAE,EAAE,CAAC;QACxD,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,MAAM,UAAU,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAE,MAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACpF,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,EAAE,EAAE,CAAC;QACxD,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAgB,UAAU,CAAC,OAAe;IACxC,OAAQ,2BAAoB,aAApB,2BAAY,uBAAZ,2BAAY,CAAW,iBAAiB,OAAO,EAAE,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["import { globalObject } from '../globalObject';\n\n/**\n * Reads the bundle id injected by `@grafana/faro-metro-plugin` / webpack plugin preamble.\n * Prefer `globalObject` (globalThis-first). Also check `window` for older bundles that set the\n * property only on `window` when it differed from `globalThis` (e.g. legacy preamble order).\n */\nexport function getBundleId(appName: string): string | undefined {\n const key = `__faroBundleId_${appName}`;\n const fromGlobal = (globalObject as any)?.[key];\n if (typeof fromGlobal === 'string' && fromGlobal !== '') {\n return fromGlobal;\n }\n const fromWindow = typeof window !== 'undefined' ? (window as any)[key] : undefined;\n if (typeof fromWindow === 'string' && fromWindow !== '') {\n return fromWindow;\n }\n return undefined;\n}\n\nexport function getGitHash(appName: string): string | undefined {\n return (globalObject as any)?.[`__faroGitHash_${appName}`];\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 = '2.6.2';
5
+ exports.VERSION = '2.7.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,OAAO,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '2.6.2';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '2.7.0';\n"]}
@@ -1,15 +1,15 @@
1
- import { getBundleId } from '../utils/sourceMaps';
1
+ import { getBundleId, getGitHash } from '../utils/sourceMaps';
2
2
  import { VERSION } from '../version';
3
3
  export function registerInitialMetas(faro) {
4
4
  var _a, _b;
5
+ const appName = faro.config.app.name;
6
+ const gitHash = appName ? getGitHash(appName) : undefined;
5
7
  const initial = {
6
8
  sdk: {
7
9
  version: VERSION,
8
10
  name: 'faro',
9
11
  },
10
- app: {
11
- bundleId: faro.config.app.name && getBundleId(faro.config.app.name),
12
- },
12
+ app: Object.assign({ bundleId: appName && getBundleId(appName) }, (gitHash !== undefined ? { gitHash } : {})),
13
13
  };
14
14
  const session = (_a = faro.config.sessionTracking) === null || _a === void 0 ? void 0 : _a.session;
15
15
  if (session) {
@@ -1 +1 @@
1
- {"version":3,"file":"registerInitial.js","sourceRoot":"","sources":["../../../src/metas/registerInitial.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAIrC,MAAM,UAAU,oBAAoB,CAAC,IAAU;;IAC7C,MAAM,OAAO,GAAS;QACpB,GAAG,EAAE;YACH,OAAO,EAAE,OAAO;YAChB,IAAI,EAAE,MAAM;SACb;QACD,GAAG,EAAE;YACH,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;SACpE;KACF,CAAC;IAEF,MAAM,OAAO,GAAG,MAAA,IAAI,CAAC,MAAM,CAAC,eAAe,0CAAE,OAAO,CAAC;IACrD,IAAI,OAAO,EAAE,CAAC;QACZ,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QACpB,OAAO,CAAC,GAAG,mCAAQ,IAAI,CAAC,MAAM,CAAC,GAAG,GAAK,OAAO,CAAC,GAAG,CAAE,CAAC;IACvD,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAClC,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAClC,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,MAAA,IAAI,CAAC,MAAM,CAAC,KAAK,mCAAI,EAAE,CAAC,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import type { Faro } from '../sdk';\nimport { getBundleId } from '../utils/sourceMaps';\nimport { VERSION } from '../version';\n\nimport type { Meta } from './types';\n\nexport function registerInitialMetas(faro: Faro): void {\n const initial: Meta = {\n sdk: {\n version: VERSION,\n name: 'faro',\n },\n app: {\n bundleId: faro.config.app.name && getBundleId(faro.config.app.name),\n },\n };\n\n const session = faro.config.sessionTracking?.session;\n if (session) {\n faro.api.setSession(session);\n }\n\n if (faro.config.app) {\n initial.app = { ...faro.config.app, ...initial.app };\n }\n\n if (faro.config.user) {\n initial.user = faro.config.user;\n }\n\n if (faro.config.view) {\n initial.view = faro.config.view;\n }\n\n faro.metas.add(initial, ...(faro.config.metas ?? []));\n}\n"]}
1
+ {"version":3,"file":"registerInitial.js","sourceRoot":"","sources":["../../../src/metas/registerInitial.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAIrC,MAAM,UAAU,oBAAoB,CAAC,IAAU;;IAC7C,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;IACrC,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE1D,MAAM,OAAO,GAAS;QACpB,GAAG,EAAE;YACH,OAAO,EAAE,OAAO;YAChB,IAAI,EAAE,MAAM;SACb;QACD,GAAG,kBACD,QAAQ,EAAE,OAAO,IAAI,WAAW,CAAC,OAAO,CAAC,IACtC,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAC9C;KACF,CAAC;IAEF,MAAM,OAAO,GAAG,MAAA,IAAI,CAAC,MAAM,CAAC,eAAe,0CAAE,OAAO,CAAC;IACrD,IAAI,OAAO,EAAE,CAAC;QACZ,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QACpB,OAAO,CAAC,GAAG,mCAAQ,IAAI,CAAC,MAAM,CAAC,GAAG,GAAK,OAAO,CAAC,GAAG,CAAE,CAAC;IACvD,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAClC,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAClC,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,MAAA,IAAI,CAAC,MAAM,CAAC,KAAK,mCAAI,EAAE,CAAC,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import type { Faro } from '../sdk';\nimport { getBundleId, getGitHash } from '../utils/sourceMaps';\nimport { VERSION } from '../version';\n\nimport type { Meta } from './types';\n\nexport function registerInitialMetas(faro: Faro): void {\n const appName = faro.config.app.name;\n const gitHash = appName ? getGitHash(appName) : undefined;\n\n const initial: Meta = {\n sdk: {\n version: VERSION,\n name: 'faro',\n },\n app: {\n bundleId: appName && getBundleId(appName),\n ...(gitHash !== undefined ? { gitHash } : {}),\n },\n };\n\n const session = faro.config.sessionTracking?.session;\n if (session) {\n faro.api.setSession(session);\n }\n\n if (faro.config.app) {\n initial.app = { ...faro.config.app, ...initial.app };\n }\n\n if (faro.config.user) {\n initial.user = faro.config.user;\n }\n\n if (faro.config.view) {\n initial.view = faro.config.view;\n }\n\n faro.metas.add(initial, ...(faro.config.metas ?? []));\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/metas/types.ts"],"names":[],"mappings":"","sourcesContent":["export type MetaGetter<P = Partial<Meta>> = () => P;\n\nexport type MetaItem<P = Partial<Meta>> = P | MetaGetter<P>;\n\nexport type MetasListener = (value: Meta) => void;\n\nexport interface Metas {\n add: (...getters: MetaItem[]) => void;\n remove: (...getters: MetaItem[]) => void;\n addListener: (listener: MetasListener) => void;\n removeListener: (listener: MetasListener) => void;\n value: Meta;\n}\n\nexport type MetaAttributes = Record<string, string>;\n\nexport interface MetaSDKIntegration {\n name?: string;\n version?: string;\n}\n\nexport interface MetaSDK {\n name?: string;\n version?: string;\n integrations?: MetaSDKIntegration[];\n}\n\nexport interface MetaApp {\n bundleId?: string;\n environment?: string;\n installationId?: string;\n name?: string;\n namespace?: string;\n release?: string;\n version?: string;\n}\n\nexport interface MetaUser {\n /**\n * User email address.\n */\n email?: string;\n /**\n * Unique identifier\n */\n id?: string;\n /**\n * Short name or login/username of the user.\n */\n username?: string;\n /**\n * User’s full name\n */\n fullName?: string;\n /**\n * comma separated list of user roles. \"admin\",editor\" etc.\n */\n roles?: string;\n /**\n * Unique user hash to correlate information for a user in anonymized form.\n */\n hash?: string;\n /**\n * arbitrary user attributes, must be of type string.\n */\n attributes?: MetaAttributes;\n}\n\nexport interface MetaSession {\n id?: string;\n attributes?: MetaAttributes;\n overrides?: MetaOverrides;\n}\n\nexport interface MetaPage {\n id?: string;\n url?: string;\n attributes?: MetaAttributes;\n}\n\ninterface NavigatorUABrandVersion {\n brand?: string;\n version?: string;\n}\n\nexport interface MetaBrowser {\n name?: string;\n version?: string;\n os?: string;\n mobile?: boolean;\n userAgent?: string;\n language?: string;\n brands?: NavigatorUABrandVersion[] | string;\n viewportWidth?: string;\n viewportHeight?: string;\n}\n\nexport interface MetaView {\n name: string;\n}\n\nexport interface MetaK6 {\n isK6Browser?: boolean;\n testRunId?: string;\n}\n\n// Fields on MetaOS and MetaDevice use snake_case to mirror the Faro spec wire\n// format, which in turn mirrors OTel `os.*` and `device.*` semantic convention\n// attribute keys (e.g. os.build_id, device.model.identifier). Intentionally\n// inconsistent with the camelCase used elsewhere in Meta.\nexport interface MetaOS {\n name?: string;\n version?: string;\n build_id?: string;\n detail?: string;\n}\n\nexport interface MetaDevice {\n manufacturer?: string;\n model_identifier?: string;\n model_name?: string;\n brand?: string;\n is_physical?: boolean;\n type?: string;\n}\n\nexport interface Meta {\n sdk?: MetaSDK;\n app?: MetaApp;\n user?: MetaUser;\n session?: MetaSession;\n page?: MetaPage;\n browser?: MetaBrowser;\n view?: MetaView;\n k6?: MetaK6;\n os?: MetaOS;\n device?: MetaDevice;\n}\n\n/**\n * MetaOverrides are instructions that allow the receiver to override certain properties (Grafana Cloud only).\n */\nexport type MetaOverrides = {\n /**\n * New service name (Grafana Cloud only)\n */\n serviceName?: string;\n\n /**\n * Enable or disable geolocation tracking (Grafana Cloud only).\n * Geolocation tracking must be enabled in the Grafana Cloud settings first.\n * It cannot be enabled solely on the client side.\n * This option allows control over tracking on the client side to comply with user\n * privacy requirements.\n */\n geoLocationTrackingEnabled?: boolean;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/metas/types.ts"],"names":[],"mappings":"","sourcesContent":["export type MetaGetter<P = Partial<Meta>> = () => P;\n\nexport type MetaItem<P = Partial<Meta>> = P | MetaGetter<P>;\n\nexport type MetasListener = (value: Meta) => void;\n\nexport interface Metas {\n add: (...getters: MetaItem[]) => void;\n remove: (...getters: MetaItem[]) => void;\n addListener: (listener: MetasListener) => void;\n removeListener: (listener: MetasListener) => void;\n value: Meta;\n}\n\nexport type MetaAttributes = Record<string, string>;\n\nexport interface MetaSDKIntegration {\n name?: string;\n version?: string;\n}\n\nexport interface MetaSDK {\n name?: string;\n version?: string;\n integrations?: MetaSDKIntegration[];\n}\n\nexport interface MetaApp {\n bundleId?: string;\n gitHash?: string;\n environment?: string;\n installationId?: string;\n name?: string;\n namespace?: string;\n release?: string;\n version?: string;\n}\n\nexport interface MetaUser {\n /**\n * User email address.\n */\n email?: string;\n /**\n * Unique identifier\n */\n id?: string;\n /**\n * Short name or login/username of the user.\n */\n username?: string;\n /**\n * User’s full name\n */\n fullName?: string;\n /**\n * comma separated list of user roles. \"admin\",editor\" etc.\n */\n roles?: string;\n /**\n * Unique user hash to correlate information for a user in anonymized form.\n */\n hash?: string;\n /**\n * arbitrary user attributes, must be of type string.\n */\n attributes?: MetaAttributes;\n}\n\nexport interface MetaSession {\n id?: string;\n attributes?: MetaAttributes;\n overrides?: MetaOverrides;\n}\n\nexport interface MetaPage {\n id?: string;\n url?: string;\n attributes?: MetaAttributes;\n}\n\ninterface NavigatorUABrandVersion {\n brand?: string;\n version?: string;\n}\n\nexport interface MetaBrowser {\n name?: string;\n version?: string;\n os?: string;\n mobile?: boolean;\n userAgent?: string;\n language?: string;\n brands?: NavigatorUABrandVersion[] | string;\n viewportWidth?: string;\n viewportHeight?: string;\n}\n\nexport interface MetaView {\n name: string;\n}\n\nexport interface MetaK6 {\n isK6Browser?: boolean;\n testRunId?: string;\n}\n\n// Fields on MetaOS and MetaDevice use snake_case to mirror the Faro spec wire\n// format, which in turn mirrors OTel `os.*` and `device.*` semantic convention\n// attribute keys (e.g. os.build_id, device.model.identifier). Intentionally\n// inconsistent with the camelCase used elsewhere in Meta.\nexport interface MetaOS {\n name?: string;\n version?: string;\n build_id?: string;\n detail?: string;\n}\n\nexport interface MetaDevice {\n manufacturer?: string;\n model_identifier?: string;\n model_name?: string;\n brand?: string;\n is_physical?: boolean;\n type?: string;\n}\n\nexport interface Meta {\n sdk?: MetaSDK;\n app?: MetaApp;\n user?: MetaUser;\n session?: MetaSession;\n page?: MetaPage;\n browser?: MetaBrowser;\n view?: MetaView;\n k6?: MetaK6;\n os?: MetaOS;\n device?: MetaDevice;\n}\n\n/**\n * MetaOverrides are instructions that allow the receiver to override certain properties (Grafana Cloud only).\n */\nexport type MetaOverrides = {\n /**\n * New service name (Grafana Cloud only)\n */\n serviceName?: string;\n\n /**\n * Enable or disable geolocation tracking (Grafana Cloud only).\n * Geolocation tracking must be enabled in the Grafana Cloud settings first.\n * It cannot be enabled solely on the client side.\n * This option allows control over tracking on the client side to comply with user\n * privacy requirements.\n */\n geoLocationTrackingEnabled?: boolean;\n};\n"]}
@@ -6,7 +6,7 @@ export { allLogLevels, defaultLogLevel, LogLevel } from './logLevels';
6
6
  export { noop } from './noop';
7
7
  export { createPromiseBuffer } from './promiseBuffer';
8
8
  export { genShortID } from './shortId';
9
- export { getBundleId } from './sourceMaps';
9
+ export { getBundleId, getGitHash } from './sourceMaps';
10
10
  export { dateNow, monoNow } from './date';
11
11
  export { getCircularDependencyReplacer, stringifyExternalJson, stringifyObjectValues } from './json';
12
12
  export { Observable } from './reactive';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAE7C,OAAO,EACL,OAAO,EACP,SAAS,EACT,UAAU,EACV,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,cAAc,EACd,YAAY,EACZ,OAAO,EACP,cAAc,EACd,UAAU,EACV,YAAY,EACZ,KAAK,EACL,KAAK,EACL,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,OAAO,GACR,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGtD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAE1C,OAAO,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAC;AAErG,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC","sourcesContent":["export type { BaseObject, BaseObjectKey, BaseObjectPrimitiveValue, BaseObjectValue } from './baseObject';\n\nexport { clampSamplingRate } from './sampling';\n\nexport { deepEqual } from './deepEqual';\n\nexport { getCurrentTimestamp } from './date';\n\nexport {\n isArray,\n isBoolean,\n isDomError,\n isDomException,\n isElement,\n isElementDefined,\n isError,\n isErrorDefined,\n isErrorEvent,\n isEvent,\n isEventDefined,\n isFunction,\n isInstanceOf,\n isInt,\n isMap,\n isMapDefined,\n isNull,\n isNumber,\n isObject,\n isPrimitive,\n isRegExp,\n isString,\n isSymbol,\n isSyntheticEvent,\n isThenable,\n isToString,\n isTypeof,\n isUndefined,\n isEmpty,\n} from './is';\nexport type { IsFnHelper } from './is';\n\nexport { allLogLevels, defaultLogLevel, LogLevel } from './logLevels';\n\nexport { noop } from './noop';\n\nexport { createPromiseBuffer } from './promiseBuffer';\nexport type { BufferItem, PromiseBuffer, PromiseBufferOptions, PromiseProducer } from './promiseBuffer';\n\nexport { genShortID } from './shortId';\n\nexport { getBundleId } from './sourceMaps';\n\nexport { dateNow, monoNow } from './date';\n\nexport { getCircularDependencyReplacer, stringifyExternalJson, stringifyObjectValues } from './json';\n\nexport { Observable } from './reactive';\nexport type { Subscription } from './reactive';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAE7C,OAAO,EACL,OAAO,EACP,SAAS,EACT,UAAU,EACV,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,cAAc,EACd,YAAY,EACZ,OAAO,EACP,cAAc,EACd,UAAU,EACV,YAAY,EACZ,KAAK,EACL,KAAK,EACL,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,OAAO,GACR,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGtD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAE1C,OAAO,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAC;AAErG,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC","sourcesContent":["export type { BaseObject, BaseObjectKey, BaseObjectPrimitiveValue, BaseObjectValue } from './baseObject';\n\nexport { clampSamplingRate } from './sampling';\n\nexport { deepEqual } from './deepEqual';\n\nexport { getCurrentTimestamp } from './date';\n\nexport {\n isArray,\n isBoolean,\n isDomError,\n isDomException,\n isElement,\n isElementDefined,\n isError,\n isErrorDefined,\n isErrorEvent,\n isEvent,\n isEventDefined,\n isFunction,\n isInstanceOf,\n isInt,\n isMap,\n isMapDefined,\n isNull,\n isNumber,\n isObject,\n isPrimitive,\n isRegExp,\n isString,\n isSymbol,\n isSyntheticEvent,\n isThenable,\n isToString,\n isTypeof,\n isUndefined,\n isEmpty,\n} from './is';\nexport type { IsFnHelper } from './is';\n\nexport { allLogLevels, defaultLogLevel, LogLevel } from './logLevels';\n\nexport { noop } from './noop';\n\nexport { createPromiseBuffer } from './promiseBuffer';\nexport type { BufferItem, PromiseBuffer, PromiseBufferOptions, PromiseProducer } from './promiseBuffer';\n\nexport { genShortID } from './shortId';\n\nexport { getBundleId, getGitHash } from './sourceMaps';\n\nexport { dateNow, monoNow } from './date';\n\nexport { getCircularDependencyReplacer, stringifyExternalJson, stringifyObjectValues } from './json';\n\nexport { Observable } from './reactive';\nexport type { Subscription } from './reactive';\n"]}
@@ -1,5 +1,22 @@
1
1
  import { globalObject } from '../globalObject';
2
+ /**
3
+ * Reads the bundle id injected by `@grafana/faro-metro-plugin` / webpack plugin preamble.
4
+ * Prefer `globalObject` (globalThis-first). Also check `window` for older bundles that set the
5
+ * property only on `window` when it differed from `globalThis` (e.g. legacy preamble order).
6
+ */
2
7
  export function getBundleId(appName) {
3
- return globalObject === null || globalObject === void 0 ? void 0 : globalObject[`__faroBundleId_${appName}`];
8
+ const key = `__faroBundleId_${appName}`;
9
+ const fromGlobal = globalObject === null || globalObject === void 0 ? void 0 : globalObject[key];
10
+ if (typeof fromGlobal === 'string' && fromGlobal !== '') {
11
+ return fromGlobal;
12
+ }
13
+ const fromWindow = typeof window !== 'undefined' ? window[key] : undefined;
14
+ if (typeof fromWindow === 'string' && fromWindow !== '') {
15
+ return fromWindow;
16
+ }
17
+ return undefined;
18
+ }
19
+ export function getGitHash(appName) {
20
+ return globalObject === null || globalObject === void 0 ? void 0 : globalObject[`__faroGitHash_${appName}`];
4
21
  }
5
22
  //# sourceMappingURL=sourceMaps.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sourceMaps.js","sourceRoot":"","sources":["../../../src/utils/sourceMaps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,OAAQ,YAAoB,aAApB,YAAY,uBAAZ,YAAY,CAAW,kBAAkB,OAAO,EAAE,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["import { globalObject } from '../globalObject';\n\nexport function getBundleId(appName: string): string | undefined {\n return (globalObject as any)?.[`__faroBundleId_${appName}`];\n}\n"]}
1
+ {"version":3,"file":"sourceMaps.js","sourceRoot":"","sources":["../../../src/utils/sourceMaps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,MAAM,GAAG,GAAG,kBAAkB,OAAO,EAAE,CAAC;IACxC,MAAM,UAAU,GAAI,YAAoB,aAApB,YAAY,uBAAZ,YAAY,CAAW,GAAG,CAAC,CAAC;IAChD,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,EAAE,EAAE,CAAC;QACxD,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,MAAM,UAAU,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAE,MAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACpF,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,EAAE,EAAE,CAAC;QACxD,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,OAAQ,YAAoB,aAApB,YAAY,uBAAZ,YAAY,CAAW,iBAAiB,OAAO,EAAE,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["import { globalObject } from '../globalObject';\n\n/**\n * Reads the bundle id injected by `@grafana/faro-metro-plugin` / webpack plugin preamble.\n * Prefer `globalObject` (globalThis-first). Also check `window` for older bundles that set the\n * property only on `window` when it differed from `globalThis` (e.g. legacy preamble order).\n */\nexport function getBundleId(appName: string): string | undefined {\n const key = `__faroBundleId_${appName}`;\n const fromGlobal = (globalObject as any)?.[key];\n if (typeof fromGlobal === 'string' && fromGlobal !== '') {\n return fromGlobal;\n }\n const fromWindow = typeof window !== 'undefined' ? (window as any)[key] : undefined;\n if (typeof fromWindow === 'string' && fromWindow !== '') {\n return fromWindow;\n }\n return undefined;\n}\n\nexport function getGitHash(appName: string): string | undefined {\n return (globalObject as any)?.[`__faroGitHash_${appName}`];\n}\n"]}
@@ -1,3 +1,3 @@
1
1
  // auto-generated by bin/genVersion.ts
2
- export const VERSION = '2.6.2';
2
+ export const VERSION = '2.7.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,OAAO,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '2.6.2';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '2.7.0';\n"]}
@@ -20,6 +20,7 @@ export interface MetaSDK {
20
20
  }
21
21
  export interface MetaApp {
22
22
  bundleId?: string;
23
+ gitHash?: string;
23
24
  environment?: string;
24
25
  installationId?: string;
25
26
  name?: string;
@@ -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 = "2.6.2";
7
+ readonly version = "2.7.0";
8
8
  items: TransportItem[];
9
9
  constructor(ignoreURLs?: Patterns);
10
10
  send(items: TransportItem[]): void | Promise<void>;
@@ -9,7 +9,7 @@ export { noop } from './noop';
9
9
  export { createPromiseBuffer } from './promiseBuffer';
10
10
  export type { BufferItem, PromiseBuffer, PromiseBufferOptions, PromiseProducer } from './promiseBuffer';
11
11
  export { genShortID } from './shortId';
12
- export { getBundleId } from './sourceMaps';
12
+ export { getBundleId, getGitHash } from './sourceMaps';
13
13
  export { dateNow, monoNow } from './date';
14
14
  export { getCircularDependencyReplacer, stringifyExternalJson, stringifyObjectValues } from './json';
15
15
  export { Observable } from './reactive';
@@ -1 +1,7 @@
1
+ /**
2
+ * Reads the bundle id injected by `@grafana/faro-metro-plugin` / webpack plugin preamble.
3
+ * Prefer `globalObject` (globalThis-first). Also check `window` for older bundles that set the
4
+ * property only on `window` when it differed from `globalThis` (e.g. legacy preamble order).
5
+ */
1
6
  export declare function getBundleId(appName: string): string | undefined;
7
+ export declare function getGitHash(appName: string): string | undefined;
@@ -1 +1 @@
1
- export declare const VERSION = "2.6.2";
1
+ export declare const VERSION = "2.7.0";
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@grafana/faro-core",
3
- "version": "2.6.2",
3
+ "packageManager": "yarn@4.14.1",
4
+ "version": "2.7.0",
4
5
  "description": "Core package of Faro.",
5
6
  "keywords": [
6
7
  "observability",
@@ -56,13 +57,13 @@
56
57
  },
57
58
  "dependencies": {
58
59
  "@opentelemetry/api": "^1.9.0",
59
- "@opentelemetry/otlp-transformer": "^0.217.0"
60
+ "@opentelemetry/otlp-transformer": "^0.218.0"
60
61
  },
61
62
  "devDependencies": {
62
- "@types/node": "24.12.2"
63
+ "@types/node": "24.12.4"
63
64
  },
64
65
  "publishConfig": {
65
66
  "access": "public"
66
67
  },
67
- "gitHead": "17193d67d1bd31587acc1a738138493a5fa6671f"
68
+ "gitHead": "8313816ee0a4a5307e92a95b596d0961b28b4b7d"
68
69
  }