@grafana/faro-web-sdk 1.3.2 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle/faro-web-sdk.iife.js +1 -1
- package/dist/bundle/types/instrumentations/console/instrumentation.d.ts +1 -1
- package/dist/bundle/types/instrumentations/errors/instrumentation.d.ts +1 -1
- package/dist/bundle/types/instrumentations/session/instrumentation.d.ts +1 -1
- package/dist/bundle/types/instrumentations/view/instrumentation.d.ts +1 -1
- package/dist/bundle/types/instrumentations/webVitals/instrumentation.d.ts +1 -1
- package/dist/bundle/types/transports/console/transport.d.ts +1 -1
- package/dist/bundle/types/transports/fetch/transport.d.ts +1 -1
- package/dist/cjs/instrumentations/session/instrumentation.js +3 -3
- package/dist/cjs/instrumentations/session/instrumentation.js.map +1 -1
- package/dist/cjs/instrumentations/session/sessionManager/PersistentSessionsManager.js +0 -11
- package/dist/cjs/instrumentations/session/sessionManager/PersistentSessionsManager.js.map +1 -1
- package/dist/cjs/instrumentations/session/sessionManager/sessionManagerUtils.js +8 -3
- package/dist/cjs/instrumentations/session/sessionManager/sessionManagerUtils.js.map +1 -1
- package/dist/cjs/metas/session/createSession.js +3 -1
- package/dist/cjs/metas/session/createSession.js.map +1 -1
- package/dist/esm/instrumentations/session/instrumentation.js +3 -3
- package/dist/esm/instrumentations/session/instrumentation.js.map +1 -1
- package/dist/esm/instrumentations/session/sessionManager/PersistentSessionsManager.js +0 -11
- package/dist/esm/instrumentations/session/sessionManager/PersistentSessionsManager.js.map +1 -1
- package/dist/esm/instrumentations/session/sessionManager/sessionManagerUtils.js +8 -3
- package/dist/esm/instrumentations/session/sessionManager/sessionManagerUtils.js.map +1 -1
- package/dist/esm/metas/session/createSession.js +3 -1
- package/dist/esm/metas/session/createSession.js.map +1 -1
- package/dist/types/instrumentations/console/instrumentation.d.ts +1 -1
- package/dist/types/instrumentations/errors/instrumentation.d.ts +1 -1
- package/dist/types/instrumentations/session/instrumentation.d.ts +1 -1
- package/dist/types/instrumentations/view/instrumentation.d.ts +1 -1
- package/dist/types/instrumentations/webVitals/instrumentation.d.ts +1 -1
- package/dist/types/transports/console/transport.d.ts +1 -1
- package/dist/types/transports/fetch/transport.d.ts +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
var GrafanaFaroWebSdk=function(e){"use strict";function n(e,n){return typeof e===n}function t(e,n){return Object.prototype.toString.call(e)===`[object ${n}]`}function i(e,n){try{return e instanceof n}catch(e){return!1}}const r=e=>n(e,"undefined"),o=e=>n(e,"null"),s=e=>n(e,"string"),a=e=>n(e,"number")&&!isNaN(e)||n(e,"bigint"),l=e=>!o(e)&&n(e,"object"),u=e=>n(e,"function"),c=e=>t(e,"Array"),d=e=>!l(e)&&!u(e),p=!r(Event),f=e=>p&&i(e,Event),g="undefined"!=typeof Error,v=e=>g&&i(e,Error),b=e=>t(e,"ErrorEvent"),m=e=>t(e,"DOMError"),h=e=>t(e,"DOMException"),w="undefined"!=typeof Element,y="undefined"!=typeof Map;function E(e,t){if(e===t)return!0;if(n(e,"number")&&isNaN(e))return n(t,"number")&&isNaN(t);const i=c(e),r=c(t);if(i!==r)return!1;if(i&&r){const n=e.length;if(n!==t.length)return!1;for(let i=n;0!=i--;)if(!E(e[i],t[i]))return!1;return!0}const o=l(e),s=l(t);if(o!==s)return!1;if(e&&t&&o&&s){const n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(let e of n)if(!i.includes(e))return!1;for(let i of n)if(!E(e[i],t[i]))return!1;return!0}return!1}function S(){return(new Date).toISOString()}var T;e.LogLevel=void 0,(T=e.LogLevel||(e.LogLevel={})).TRACE="trace",T.DEBUG="debug",T.INFO="info",T.LOG="log",T.WARN="warn",T.ERROR="error";const x=e.LogLevel.LOG,k=[e.LogLevel.TRACE,e.LogLevel.DEBUG,e.LogLevel.INFO,e.LogLevel.LOG,e.LogLevel.WARN,e.LogLevel.ERROR];function I(){}function O(e){const{size:n,concurrency:t}=e,i=[];let r=0;const o=()=>{if(r<t&&i.length){const{producer:e,resolve:n,reject:t}=i.shift();r++,e().then((e=>{r--,o(),n(e)}),(e=>{r--,o(),t(e)}))}};return{add:e=>{if(i.length+r>=n)throw new Error("Task buffer full");return new Promise(((n,t)=>{i.push({producer:e,resolve:n,reject:t}),o()}))}}}const L="abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789";function N(e=10){return Array.from(Array(e)).map((()=>L[Math.floor(Math.random()*L.length)])).join("")}function A(){return Date.now()}var C="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},j={exports:{}},R={exports:{}};R.exports=function(e,n){var t,i,r,o,s,a,l,u;for(t=3&e.length,i=e.length-t,r=n,s=3432918353,a=461845907,u=0;u<i;)l=255&e.charCodeAt(u)|(255&e.charCodeAt(++u))<<8|(255&e.charCodeAt(++u))<<16|(255&e.charCodeAt(++u))<<24,++u,r=27492+(65535&(o=5*(65535&(r=(r^=l=(65535&(l=(l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|r>>>19))+((5*(r>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,t){case 3:l^=(255&e.charCodeAt(u+2))<<16;case 2:l^=(255&e.charCodeAt(u+1))<<8;case 1:r^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(u)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return r^=e.length,r=2246822507*(65535&(r^=r>>>16))+((2246822507*(r>>>16)&65535)<<16)&4294967295,r=3266489909*(65535&(r^=r>>>13))+((3266489909*(r>>>16)&65535)<<16)&4294967295,(r^=r>>>16)>>>0};var _=R.exports,M={exports:{}};!function(e){e.exports=function(e,n){for(var t,i=e.length,r=n^i,o=0;i>=4;)t=1540483477*(65535&(t=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(t>>>16)&65535)<<16),r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16)^(t=1540483477*(65535&(t^=t>>>24))+((1540483477*(t>>>16)&65535)<<16)),i-=4,++o;switch(i){case 3:r^=(255&e.charCodeAt(o+2))<<16;case 2:r^=(255&e.charCodeAt(o+1))<<8;case 1:r=1540483477*(65535&(r^=255&e.charCodeAt(o)))+((1540483477*(r>>>16)&65535)<<16)}return r=1540483477*(65535&(r^=r>>>13))+((1540483477*(r>>>16)&65535)<<16),(r^=r>>>15)>>>0}}(M);var D=_,U=M.exports;j.exports=D;var P=j.exports.murmur3=D;j.exports.murmur2=U;class B{constructor(e,n){var t,i;this.signalBuffer=[],this.itemLimit=null!==(t=null==n?void 0:n.itemLimit)&&void 0!==t?t:50,this.sendTimeout=null!==(i=null==n?void 0:n.sendTimeout)&&void 0!==i?i:250,this.paused=(null==n?void 0:n.paused)||!1,this.sendFn=e,this.flushInterval=-1,this.paused||this.start(),document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&this.flush()}))}addItem(e){this.paused||(this.signalBuffer.push(e),this.signalBuffer.length>=this.itemLimit&&this.flush())}start(){this.paused=!1,this.sendTimeout>0&&(this.flushInterval=window.setInterval((()=>this.flush()),this.sendTimeout))}pause(){this.paused=!0,clearInterval(this.flushInterval)}groupItems(e){const n=new Map;return e.forEach((e=>{const t=P(JSON.stringify(e.meta));let i=n.get(t);i=void 0===i?[e]:[...i,e],n.set(t,i)})),Array.from(n.values())}flush(){if(this.paused||0===this.signalBuffer.length)return;this.groupItems(this.signalBuffer).forEach(this.sendFn),this.signalBuffer=[]}}var z;e.TransportItemType=void 0,(z=e.TransportItemType||(e.TransportItemType={})).EXCEPTION="exception",z.LOG="log",z.MEASUREMENT="measurement",z.TRACE="trace",z.EVENT="event";const F={[e.TransportItemType.EXCEPTION]:"exceptions",[e.TransportItemType.LOG]:"logs",[e.TransportItemType.MEASUREMENT]:"measurements",[e.TransportItemType.TRACE]:"traces",[e.TransportItemType.EVENT]:"events"};function V(n){return t=>{if(t.type===e.TransportItemType.EXCEPTION&&t.payload){const e=t.payload,i=`${e.type}: ${e.value}`;if(function(e,n){return e.some((e=>s(e)?n.includes(e):!!n.match(e)))}(n,i))return null}return t}}function $(e,n,t,i){var r;n.debug("Initializing transports");const o=[];let s=t.paused,a=[];const l=e=>{let n=e;for(const e of a){const t=n.map(e).filter(Boolean);if(0===t.length)return[];n=t}return n},u=e=>{const t=l(e);if(0!==t.length)for(const e of o)n.debug(`Transporting item using ${e.name}\n`,t),e.isBatched()&&e.send(t)};let c;(null===(r=t.batching)||void 0===r?void 0:r.enabled)&&(c=new B(u,{sendTimeout:t.batching.sendTimeout,itemLimit:t.batching.itemLimit,paused:s}));return{add:(...r)=>{n.debug("Adding transports"),r.forEach((r=>{n.debug(`Adding "${r.name}" transport`);o.some((e=>e===r))?n.warn(`Transport ${r.name} is already added`):(r.unpatchedConsole=e,r.internalLogger=n,r.config=t,r.metas=i,o.push(r))}))},addBeforeSendHooks:(...e)=>{n.debug("Adding beforeSendHooks\n",a),e.forEach((e=>{e&&a.push(e)}))},addIgnoreErrorsPatterns:(...e)=>{n.debug("Adding ignoreErrorsPatterns\n",e),e.forEach((e=>{e&&a.push(V(e))}))},getBeforeSendHooks:()=>[...a],execute:e=>{var i;s||((null===(i=t.batching)||void 0===i?void 0:i.enabled)&&(null==c||c.addItem(e)),(e=>{var i,r;if((null===(i=t.batching)||void 0===i?void 0:i.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===(r=t.batching)||void 0===r?void 0:r.enabled)||e.send([s]):e.send(s)})(e))},isPaused:()=>s,pause:()=>{n.debug("Pausing transports"),null==c||c.pause(),s=!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)=>{a.filter((n=>!e.includes(n)))},get transports(){return[...o]},unpause:()=>{n.debug("Unpausing transports"),null==c||c.start(),s=!1}}}var G;e.InternalLoggerLevel=void 0,(G=e.InternalLoggerLevel||(e.InternalLoggerLevel={}))[G.OFF=0]="OFF",G[G.ERROR=1]="ERROR",G[G.WARN=2]="WARN",G[G.INFO=3]="INFO",G[G.VERBOSE=4]="VERBOSE";const q={debug:I,error:I,info:I,prefix:"Faro",warn:I},W=e.InternalLoggerLevel.ERROR,H=Object.assign({},console);let K=H;function X(e){var n;return K=null!==(n=e.unpatchedConsole)&&void 0!==n?n:K,K}function J(n=H,t=W){const i=q;return t>e.InternalLoggerLevel.OFF&&(i.error=t>=e.InternalLoggerLevel.ERROR?function(...e){n.error(`${i.prefix}\n`,...e)}:I,i.warn=t>=e.InternalLoggerLevel.WARN?function(...e){n.warn(`${i.prefix}\n`,...e)}:I,i.info=t>=e.InternalLoggerLevel.INFO?function(...e){n.info(`${i.prefix}\n`,...e)}:I,i.debug=t>=e.InternalLoggerLevel.VERBOSE?function(...e){n.debug(`${i.prefix}\n`,...e)}:I),i}let Z=q;function Y(e,n){return Z=J(e,n.internalLoggerLevel),Z}class Q{constructor(){this.unpatchedConsole=H,this.internalLogger=q,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)}}class ee extends Q{isBatched(){return!1}getIgnoreUrls(){return[]}}function ne(e,n){var t,i;if(void 0===n)return e;if(void 0===e)return{resourceSpans:n};const r=null===(t=e.resourceSpans)||void 0===t?void 0:t[0];if(void 0===r)return e;const o=(null==r?void 0:r.scopeSpans)||[],s=(null===(i=null==n?void 0:n[0])||void 0===i?void 0:i.scopeSpans)||[];return Object.assign(Object.assign({},e),{resourceSpans:[Object.assign(Object.assign({},r),{scopeSpans:[...o,...s]})]})}function te(n){let t={meta:{}};return void 0!==n[0]&&(t.meta=n[0].meta),n.forEach((n=>{switch(n.type){case e.TransportItemType.LOG:case e.TransportItemType.EVENT:case e.TransportItemType.EXCEPTION:case e.TransportItemType.MEASUREMENT:const i=F[n.type],r=t[i];t=Object.assign(Object.assign({},t),{[i]:void 0===r?[n.payload]:[...r,n.payload]});break;case e.TransportItemType.TRACE:t=Object.assign(Object.assign({},t),{traces:ne(t.traces,n.payload.resourceSpans)})}})),t}const ie="Error";let re;function oe(n,t,i,r,s){t.debug("Initializing API");const a=function(n,t,i,r,o){let s;return t.debug("Initializing traces API"),{getOTEL:()=>s,getTraceContext:()=>{const e=null==s?void 0:s.trace.getSpanContext(s.context.active());return e?{trace_id:e.traceId,span_id:e.spanId}:void 0},initOTEL:(e,n)=>{t.debug("Initializing OpenTelemetry"),s={trace:e,context:n}},isOTELInitialized:()=>!!s,pushTraces:n=>{try{const i={type:e.TransportItemType.TRACE,payload:n,meta:r.value};t.debug("Pushing trace\n",i),o.execute(i)}catch(e){t.error("Error pushing trace\n",e)}}}}(0,t,0,r,s);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},a),function(n,t,i,r,s,a){var l;t.debug("Initializing exceptions API");let u=null;re=null!==(l=i.parseStacktrace)&&void 0!==l?l:re;const c=e=>{t.debug("Changing stacktrace parser"),re=null!=e?e:re};return c(i.parseStacktrace),{changeStacktraceParser:c,getStacktraceParser:()=>re,pushError:(n,{skipDedupe:l,stackFrames:c,type:d,context:p}={})=>{d=d||n.name||ie;const f={meta:r.value,payload:{type:d,value:n.message,timestamp:S(),trace:a.getTraceContext(),context:null!=p?p:{}},type:e.TransportItemType.EXCEPTION};(null==(c=null!=c?c:n.stack?null==re?void 0:re(n).frames:void 0)?void 0:c.length)&&(f.payload.stacktrace={frames:c});const g={type:f.payload.type,value:f.payload.value,stackTrace:f.payload.stacktrace,context:f.payload.context};l||!i.dedupe||o(u)||!E(g,u)?(u=g,t.debug("Pushing exception\n",f),s.execute(f)):t.debug("Skipping error push because it is the same as the last one\n",f.payload)}}}(0,t,i,r,s,a)),function(e,n,t,i,r){let o,s,a;n.debug("Initializing meta API");const l=e=>{s&&i.remove(s),s={user:e},i.add(s)},u=e=>{o&&i.remove(o),o={session:e},i.add(o)};return{setUser:l,resetUser:l,setSession:u,resetSession:u,getSession:()=>i.value.session,setView:e=>{var n;if((null===(n=null==a?void 0:a.view)||void 0===n?void 0:n.name)===(null==e?void 0:e.name))return;const t=a;a={view:e},i.add(a),t&&i.remove(t)},getView:()=>i.value.view}}(0,t,0,r)),function(n,t,i,r,s,a){t.debug("Initializing logs API");let l=null;return{pushLog:(n,{context:u,level:c,skipDedupe:d}={})=>{try{const p={type:e.TransportItemType.LOG,payload:{message:n.map((e=>{try{return String(e)}catch(e){return""}})).join(" "),level:null!=c?c:x,context:null!=u?u:{},timestamp:S(),trace:a.getTraceContext()},meta:r.value},f={message:p.payload.message,level:p.payload.level,context:p.payload.context};if(!d&&i.dedupe&&!o(l)&&E(f,l))return void t.debug("Skipping log push because it is the same as the last one\n",p.payload);l=f,t.debug("Pushing log\n",p),s.execute(p)}catch(e){t.error("Error pushing log\n",e)}}}}(0,t,i,r,s,a)),function(n,t,i,r,s,a){t.debug("Initializing measurements API");let l=null;return{pushMeasurement:(n,{skipDedupe:u,context:c}={})=>{var d;try{const p={type:e.TransportItemType.MEASUREMENT,payload:Object.assign(Object.assign({},n),{trace:a.getTraceContext(),timestamp:null!==(d=n.timestamp)&&void 0!==d?d:S(),context:null!=c?c:{}}),meta:r.value},f={type:p.payload.type,values:p.payload.values,context:p.payload.context};if(!u&&i.dedupe&&!o(l)&&E(f,l))return void t.debug("Skipping measurement push because it is the same as the last one\n",p.payload);l=f,t.debug("Pushing measurement\n",p),s.execute(p)}catch(e){t.error("Error pushing measurement\n",e)}}}}(0,t,i,r,s,a)),function(n,t,i,r,s,a){let l=null;return{pushEvent:(n,u,c,{skipDedupe:d}={})=>{try{const p={meta:r.value,payload:{name:n,domain:null!=c?c:i.eventDomain,attributes:u,timestamp:S(),trace:a.getTraceContext()},type:e.TransportItemType.EVENT},f={name:p.payload.name,attributes:p.payload.attributes,domain:p.payload.domain};if(!d&&i.dedupe&&!o(l)&&E(f,l))return void t.debug("Skipping event push because it is the same as the last one\n",p.payload);l=f,t.debug("Pushing event\n",p),s.execute(p)}catch(e){t.error("Error pushing event",e)}}}}(0,t,i,r,s,a))}const se="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:void 0;class ae extends Q{constructor(){super(...arguments),this.api={},this.transports={}}}const le="1.3.2";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(se,ue,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function de(){return ue in se}function pe(n,t,i,r,o,s,a){return t.debug("Initializing Faro"),e.faro={api:s,config:i,instrumentations:a,internalLogger:t,metas:r,pause:o.pause,transports:o,unpatchedConsole:n,unpause:o.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 se)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(se,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}(e.faro),e.faro}function fe(e){const n=X(e),t=Y(n,e);if(de()&&!e.isolate)return void t.error('Faro is already registered. Either add instrumentations, transports etc. to the global faro instance or use the "isolate" property');t.debug("Initializing");const i=function(e,n,t){let i=[],r=[];const o=()=>i.reduce(((e,n)=>Object.assign(e,u(n)?n():n)),{}),s=()=>{if(r.length){const e=o();r.forEach((n=>n(e)))}};return{add:(...e)=>{n.debug("Adding metas\n",e),i.push(...e),s()},remove:(...e)=>{n.debug("Removing metas\n",e),i=i.filter((n=>!e.includes(n))),s()},addListener:e=>{n.debug("Adding metas listener\n",e),r.push(e)},removeListener:e=>{n.debug("Removing metas listener\n",e),r=r.filter((n=>n!==e))},get value(){return o()}}}(0,t),r=$(n,t,e,i),o=oe(0,t,e,i,r),s=function(e,n,t,i,r,o){n.debug("Initializing instrumentations");const s=[];return{add:(...a)=>{n.debug("Adding instrumentations"),a.forEach((a=>{n.debug(`Adding "${a.name}" instrumentation`),s.some((e=>e.name===a.name))?n.warn(`Instrumentation ${a.name} is already added`):(a.unpatchedConsole=e,a.internalLogger=n,a.config=t,a.metas=i,a.transports=r,a.api=o,s.push(a),a.initialize())}))},get instrumentations(){return[...s]},remove:(...e)=>{n.debug("Removing instrumentations"),e.forEach((e=>{var t,i;n.debug(`Removing "${e.name}" instrumentation`);const r=s.reduce(((n,t,i)=>null===n&&t.name===e.name?i:null),null);r?(null===(i=(t=s[r]).destroy)||void 0===i||i.call(t),s.splice(r,1)):n.warn(`Instrumentation "${e.name}" is not added`)}))}}}(n,t,e,i,r,o),a=pe(n,t,e,i,r,o,s);return function(e){var n,t;const i={sdk:{version:le}},r=null===(n=e.config.sessionTracking)||void 0===n?void 0:n.session;r&&e.api.setSession(r),e.config.app&&(i.app=e.config.app),e.config.user&&(i.user=e.config.user),e.config.view&&(i.view=e.config.view),e.metas.add(i,...null!==(t=e.config.metas)&&void 0!==t?t:[])}(a),function(e){e.transports.add(...e.config.transports),e.transports.addBeforeSendHooks(e.config.beforeSend),e.transports.addIgnoreErrorsPatterns(e.config.ignoreErrors)}(a),function(e){e.instrumentations.add(...e.config.instrumentations)}(a),a}e.faro={};const ge="faro",ve={enabled:!0,sendTimeout:250,itemLimit:50},be="view_changed",me="session_start",he="session_resume",we="session_extend";var ye={exports:{}};!function(e,n){!function(t,i){var r="function",o="undefined",s="object",a="string",l="major",u="model",c="name",d="type",p="vendor",f="version",g="architecture",v="console",b="mobile",m="tablet",h="smarttv",w="wearable",y="embedded",E="Amazon",S="Apple",T="ASUS",x="BlackBerry",k="Browser",I="Chrome",O="Firefox",L="Google",N="Huawei",A="LG",C="Microsoft",j="Motorola",R="Opera",_="Samsung",M="Sharp",D="Sony",U="Xiaomi",P="Zebra",B="Facebook",z="Chromium OS",F="Mac OS",V=function(e){for(var n={},t=0;t<e.length;t++)n[e[t].toUpperCase()]=e[t];return n},$=function(e,n){return typeof e===a&&-1!==G(n).indexOf(G(e))},G=function(e){return e.toLowerCase()},q=function(e,n){if(typeof e===a)return e=e.replace(/^\s\s*/,""),typeof n===o?e:e.substring(0,350)},W=function(e,n){for(var t,o,a,l,u,c,d=0;d<n.length&&!u;){var p=n[d],f=n[d+1];for(t=o=0;t<p.length&&!u&&p[t];)if(u=p[t++].exec(e))for(a=0;a<f.length;a++)c=u[++o],typeof(l=f[a])===s&&l.length>0?2===l.length?typeof l[1]==r?this[l[0]]=l[1].call(this,c):this[l[0]]=l[1]:3===l.length?typeof l[1]!==r||l[1].exec&&l[1].test?this[l[0]]=c?c.replace(l[1],l[2]):i:this[l[0]]=c?l[1].call(this,c,l[2]):i:4===l.length&&(this[l[0]]=c?l[3].call(this,c.replace(l[1],l[2])):i):this[l]=c||i;d+=2}},H=function(e,n){for(var t in n)if(typeof n[t]===s&&n[t].length>0){for(var r=0;r<n[t].length;r++)if($(n[t][r],e))return"?"===t?i:t}else if($(n[t],e))return"?"===t?i:t;return e},K={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},X={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[f,[c,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[f,[c,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[c,f],[/opios[\/ ]+([\w\.]+)/i],[f,[c,R+" Mini"]],[/\bopr\/([\w\.]+)/i],[f,[c,R]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,/(avant |iemobile|slim)(?:browser)?[\/ ]?([\w\.]*)/i,/(ba?idubrowser)[\/ ]?([\w\.]+)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,/(heytap|ovi)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[c,f],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[f,[c,"UC"+k]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i],[f,[c,"WeChat(Win) Desktop"]],[/micromessenger\/([\w\.]+)/i],[f,[c,"WeChat"]],[/konqueror\/([\w\.]+)/i],[f,[c,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[f,[c,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[f,[c,"Yandex"]],[/(avast|avg)\/([\w\.]+)/i],[[c,/(.+)/,"$1 Secure "+k],f],[/\bfocus\/([\w\.]+)/i],[f,[c,O+" Focus"]],[/\bopt\/([\w\.]+)/i],[f,[c,R+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[f,[c,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[f,[c,"Dolphin"]],[/coast\/([\w\.]+)/i],[f,[c,R+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[f,[c,"MIUI "+k]],[/fxios\/([-\w\.]+)/i],[f,[c,O]],[/\bqihu|(qi?ho?o?|360)browser/i],[[c,"360 "+k]],[/(oculus|samsung|sailfish|huawei)browser\/([\w\.]+)/i],[[c,/(.+)/,"$1 "+k],f],[/(comodo_dragon)\/([\w\.]+)/i],[[c,/_/g," "],f],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|baiduboxapp|2345Explorer)[\/ ]?([\w\.]+)/i],[c,f],[/(metasr)[\/ ]?([\w\.]+)/i,/(lbbrowser)/i,/\[(linkedin)app\]/i],[c],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[c,B],f],[/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i],[c,f],[/\bgsa\/([\w\.]+) .*safari\//i],[f,[c,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[f,[c,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[f,[c,I+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[c,I+" WebView"],f],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[f,[c,"Android "+k]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[c,f],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[f,[c,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[f,c],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[c,[f,H,{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}]],[/(webkit|khtml)\/([\w\.]+)/i],[c,f],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[c,"Netscape"],f],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[f,[c,O+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i,/panasonic;(viera)/i],[c,f],[/(cobalt)\/([\w\.]+)/i],[c,[f,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[g,"amd64"]],[/(ia32(?=;))/i],[[g,G]],[/((?:i[346]|x)86)[;\)]/i],[[g,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[g,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[g,"armhf"]],[/windows (ce|mobile); ppc;/i],[[g,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[g,/ower/,"",G]],[/(sun4\w)[;\)]/i],[[g,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[g,G]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[u,[p,_],[d,m]],[/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],[u,[p,_],[d,b]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[u,[p,S],[d,b]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[u,[p,S],[d,m]],[/(macintosh);/i],[u,[p,S]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[u,[p,M],[d,b]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[u,[p,N],[d,m]],[/(?:huawei|honor)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[u,[p,N],[d,b]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i],[[u,/_/g," "],[p,U],[d,b]],[/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[u,/_/g," "],[p,U],[d,m]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[u,[p,"OPPO"],[d,b]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[u,[p,"Vivo"],[d,b]],[/\b(rmx[12]\d{3})(?: bui|;|\))/i],[u,[p,"Realme"],[d,b]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[u,[p,j],[d,b]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[u,[p,j],[d,m]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[u,[p,A],[d,m]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[u,[p,A],[d,b]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[u,[p,"Lenovo"],[d,m]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[u,/_/g," "],[p,"Nokia"],[d,b]],[/(pixel c)\b/i],[u,[p,L],[d,m]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[u,[p,L],[d,b]],[/droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[u,[p,D],[d,b]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[u,"Xperia Tablet"],[p,D],[d,m]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[u,[p,"OnePlus"],[d,b]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[u,[p,E],[d,m]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[u,/(.+)/g,"Fire Phone $1"],[p,E],[d,b]],[/(playbook);[-\w\),; ]+(rim)/i],[u,p,[d,m]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[u,[p,x],[d,b]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[u,[p,T],[d,m]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[u,[p,T],[d,b]],[/(nexus 9)/i],[u,[p,"HTC"],[d,m]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[p,[u,/_/g," "],[d,b]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[u,[p,"Acer"],[d,m]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[u,[p,"Meizu"],[d,b]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno)[-_ ]?([-\w]*)/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[p,u,[d,b]],[/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[p,u,[d,m]],[/(surface duo)/i],[u,[p,C],[d,m]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[u,[p,"Fairphone"],[d,b]],[/(u304aa)/i],[u,[p,"AT&T"],[d,b]],[/\bsie-(\w*)/i],[u,[p,"Siemens"],[d,b]],[/\b(rct\w+) b/i],[u,[p,"RCA"],[d,m]],[/\b(venue[\d ]{2,7}) b/i],[u,[p,"Dell"],[d,m]],[/\b(q(?:mv|ta)\w+) b/i],[u,[p,"Verizon"],[d,m]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[u,[p,"Barnes & Noble"],[d,m]],[/\b(tm\d{3}\w+) b/i],[u,[p,"NuVision"],[d,m]],[/\b(k88) b/i],[u,[p,"ZTE"],[d,m]],[/\b(nx\d{3}j) b/i],[u,[p,"ZTE"],[d,b]],[/\b(gen\d{3}) b.+49h/i],[u,[p,"Swiss"],[d,b]],[/\b(zur\d{3}) b/i],[u,[p,"Swiss"],[d,m]],[/\b((zeki)?tb.*\b) b/i],[u,[p,"Zeki"],[d,m]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[p,"Dragon Touch"],u,[d,m]],[/\b(ns-?\w{0,9}) b/i],[u,[p,"Insignia"],[d,m]],[/\b((nxa|next)-?\w{0,9}) b/i],[u,[p,"NextBook"],[d,m]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[p,"Voice"],u,[d,b]],[/\b(lvtel\-)?(v1[12]) b/i],[[p,"LvTel"],u,[d,b]],[/\b(ph-1) /i],[u,[p,"Essential"],[d,b]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[u,[p,"Envizen"],[d,m]],[/\b(trio[-\w\. ]+) b/i],[u,[p,"MachSpeed"],[d,m]],[/\btu_(1491) b/i],[u,[p,"Rotor"],[d,m]],[/(shield[\w ]+) b/i],[u,[p,"Nvidia"],[d,m]],[/(sprint) (\w+)/i],[p,u,[d,b]],[/(kin\.[onetw]{3})/i],[[u,/\./g," "],[p,C],[d,b]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[u,[p,P],[d,m]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[u,[p,P],[d,b]],[/smart-tv.+(samsung)/i],[p,[d,h]],[/hbbtv.+maple;(\d+)/i],[[u,/^/,"SmartTV"],[p,_],[d,h]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[p,A],[d,h]],[/(apple) ?tv/i],[p,[u,S+" TV"],[d,h]],[/crkey/i],[[u,I+"cast"],[p,L],[d,h]],[/droid.+aft(\w+)( bui|\))/i],[u,[p,E],[d,h]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[u,[p,M],[d,h]],[/(bravia[\w ]+)( bui|\))/i],[u,[p,D],[d,h]],[/(mitv-\w{5}) bui/i],[u,[p,U],[d,h]],[/Hbbtv.*(technisat) (.*);/i],[p,u,[d,h]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[p,q],[u,q],[d,h]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[d,h]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[p,u,[d,v]],[/droid.+; (shield) bui/i],[u,[p,"Nvidia"],[d,v]],[/(playstation [345portablevi]+)/i],[u,[p,D],[d,v]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[u,[p,C],[d,v]],[/((pebble))app/i],[p,u,[d,w]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[u,[p,S],[d,w]],[/droid.+; (glass) \d/i],[u,[p,L],[d,w]],[/droid.+; (wt63?0{2,3})\)/i],[u,[p,P],[d,w]],[/(quest( 2| pro)?)/i],[u,[p,B],[d,w]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[p,[d,y]],[/(aeobc)\b/i],[u,[p,E],[d,y]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+? mobile safari/i],[u,[d,b]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[u,[d,m]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[d,m]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[d,b]],[/(android[-\w\. ]{0,9});.+buil/i],[u,[p,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[f,[c,"EdgeHTML"]],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[f,[c,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[c,f],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[f,c]],os:[[/microsoft (windows) (vista|xp)/i],[c,f],[/(windows) nt 6\.2; (arm)/i,/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i,/(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i],[c,[f,H,K]],[/(win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[c,"Windows"],[f,H,K]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[f,/_/g,"."],[c,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[c,F],[f,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[f,c],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[c,f],[/\(bb(10);/i],[f,[c,x]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[f,[c,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[f,[c,O+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[f,[c,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[f,[c,"watchOS"]],[/crkey\/([\d\.]+)/i],[f,[c,I+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[c,z],f],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[c,f],[/(sunos) ?([\w\.\d]*)/i],[[c,"Solaris"],f],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[c,f]]},J=function(e,n){if(typeof e===s&&(n=e,e=i),!(this instanceof J))return new J(e,n).getResult();var v=typeof t!==o&&t.navigator?t.navigator:i,h=e||(v&&v.userAgent?v.userAgent:""),w=v&&v.userAgentData?v.userAgentData:i,y=n?function(e,n){var t={};for(var i in e)n[i]&&n[i].length%2==0?t[i]=n[i].concat(e[i]):t[i]=e[i];return t}(X,n):X,E=v&&v.userAgent==h;return this.getBrowser=function(){var e,n={};return n[c]=i,n[f]=i,W.call(n,h,y.browser),n[l]=typeof(e=n[f])===a?e.replace(/[^\d\.]/g,"").split(".")[0]:i,E&&v&&v.brave&&typeof v.brave.isBrave==r&&(n[c]="Brave"),n},this.getCPU=function(){var e={};return e[g]=i,W.call(e,h,y.cpu),e},this.getDevice=function(){var e={};return e[p]=i,e[u]=i,e[d]=i,W.call(e,h,y.device),E&&!e[d]&&w&&w.mobile&&(e[d]=b),E&&"Macintosh"==e[u]&&v&&typeof v.standalone!==o&&v.maxTouchPoints&&v.maxTouchPoints>2&&(e[u]="iPad",e[d]=m),e},this.getEngine=function(){var e={};return e[c]=i,e[f]=i,W.call(e,h,y.engine),e},this.getOS=function(){var e={};return e[c]=i,e[f]=i,W.call(e,h,y.os),E&&!e[c]&&w&&"Unknown"!=w.platform&&(e[c]=w.platform.replace(/chrome os/i,z).replace(/macos/i,F)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return h},this.setUA=function(e){return h=typeof e===a&&e.length>350?q(e,350):e,this},this.setUA(h),this};J.VERSION="1.0.36",J.BROWSER=V([c,f,l]),J.CPU=V([g]),J.DEVICE=V([u,p,d,v,b,h,m,w,y]),J.ENGINE=J.OS=V([c,f]),e.exports&&(n=e.exports=J),n.UAParser=J;var Z=typeof t!==o&&(t.jQuery||t.Zepto);if(Z&&!Z.ua){var Y=new J;Z.ua=Y.getResult(),Z.ua.get=function(){return Y.getUA()},Z.ua.set=function(e){Y.setUA(e);var n=Y.getResult();for(var t in n)Z.ua[t]=n[t]}}}("object"==typeof window?window:C)}(ye,ye.exports);var Ee=ye.exports;const Se=()=>{const e=new Ee.UAParser,{name:n,version:t}=e.getBrowser(),{name:i,version:r}=e.getOS(),o=e.getUA(),s=navigator.language,a=navigator.userAgent.includes("Mobi"),l=function(){if(!n||!t)return;if("userAgentData"in navigator)return navigator.userAgentData.brands;return}(),u="unknown";return{browser:{name:null!=n?n:u,version:null!=t?t:u,os:`${null!=i?i:u} ${null!=r?r:u}`,userAgent:null!=o?o:u,language:null!=s?s:u,mobile:a,brands:null!=l?l:u}}},Te=()=>({page:{url:location.href}}),xe=[Se,Te];function ke(e){return{id:N(),attributes:e}}const Ie={name:"default"},Oe="sessionStorage",Le="localStorage";function Ne(n){var t;try{let e;e=window[n];const t="__faro_storage_test__";return e.setItem(t,t),e.removeItem(t),!0}catch(i){return null===(t=e.faro.internalLogger)||void 0===t||t.info(`Web storage of type ${n} is not available. Reason: ${i}`),!1}}function Ae(e,n){return Me(n)?window[n].getItem(e):null}function Ce(e,n,t){if(Me(t))try{window[t].setItem(e,n)}catch(e){}}function je(e,n){Me(n)&&window[n].removeItem(e)}const Re=Ne(Le),_e=Ne(Oe);function Me(e){return e===Le?Re:e===Oe&&_e}function De(e,n){let t,i=!1;const r=()=>{null!=t?(e(...t),t=null,setTimeout(r,n)):i=!1};return(...o)=>{i?t=o:(e(...o),i=!0,setTimeout(r,n))}}function Ue(){var n,t,i;const r=e.faro.config.sessionTracking;let o=null!==(i=null!==(t=null===(n=null==r?void 0:r.sampler)||void 0===n?void 0:n.call(r,{metas:e.faro.metas.value}))&&void 0!==t?t:null==r?void 0:r.samplingRate)&&void 0!==i?i:1;if("number"!=typeof o){o=0}return Math.random()<o}const Pe="__FARO_SESSION__",Be=144e5,ze=9e5,Fe=96e4,Ve={enabled:!0,persistent:!1,maxSessionPersistenceTime:Fe};function $e({sessionId:e=N(),isSampled:n=!0}={}){const t=A();return{sessionId:e,lastActivity:t,started:t,isSampled:n}}function Ge(e){if(null==e)return!1;const n=A();if(!(n-e.started<Be))return!1;return n-e.lastActivity<ze}function qe({fetchUserSession:n,storeUserSession:t}){return function(){var i,r,o,s;if(!n||!t)return;const a=n();if(Ge(a))t(Object.assign(Object.assign({},a),{lastActivity:A()}));else{let n=We($e({isSampled:Ue()}),a);t(n),null===(i=e.faro.api)||void 0===i||i.setSession(n.sessionMeta),null===(o=null===(r=e.faro.config.sessionTracking)||void 0===r?void 0:r.onSessionChange)||void 0===o||o.call(r,null!==(s=null==a?void 0:a.sessionMeta)&&void 0!==s?s:null,n.sessionMeta)}}}function We(n,t){var i,r;return Object.assign(Object.assign({},n),{sessionMeta:{id:n.sessionId,attributes:Object.assign(Object.assign(Object.assign({},null!==(r=null===(i=e.faro.metas.value.session)||void 0===i?void 0:i.attributes)&&void 0!==r?r:{}),null!=t?{previousSession:t.sessionId}:{}),{isSampled:n.isSampled.toString()})}})}class He{constructor(){this.updateSession=De((()=>this.updateUserSession()),1e3),this.updateUserSession=qe({fetchUserSession:He.fetchUserSession,storeUserSession:He.storeUserSession}),this.init()}static removeUserSession(){je(Pe,He.storageTypeLocal)}static storeUserSession(e){Ce(Pe,JSON.stringify(e),He.storageTypeLocal)}static fetchUserSession(){const e=Ae(Pe,He.storageTypeLocal);return e?JSON.parse(e):null}init(){document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&this.updateSession()})),window.addEventListener("storage",(n=>{var t,i,r;if(n.key!==Pe)return;const o=JSON.parse(null!==(t=n.newValue)&&void 0!==t?t:""),s=JSON.parse(null!==(i=n.oldValue)&&void 0!==i?i:"");o.sessionId!==s.sessionId&&(null===(r=e.faro.api)||void 0===r||r.setSession(o.sessionMeta))})),e.faro.metas.addListener((function(n){const t=n.session,i=He.fetchUserSession();if(t&&t.id!==(null==i?void 0:i.sessionId)){const n=We($e({sessionId:t.id,isSampled:Ue()}),i);He.storeUserSession(n),e.faro.api.setSession(n.sessionMeta)}}))}}He.storageTypeLocal=Le;class Ke{constructor(){this.updateSession=De((()=>this.updateUserSession()),1e3),this.updateUserSession=qe({fetchUserSession:Ke.fetchUserSession,storeUserSession:Ke.storeUserSession}),this.init()}static removeUserSession(){je(Pe,Ke.storageTypeSession)}static storeUserSession(e){Ce(Pe,JSON.stringify(e),Ke.storageTypeSession)}static fetchUserSession(){const e=Ae(Pe,Ke.storageTypeSession);return e?JSON.parse(e):null}init(){document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&this.updateSession()})),e.faro.metas.addListener((function(n){const t=n.session,i=Ke.fetchUserSession();if(t&&t.id!==(null==i?void 0:i.sessionId)){const n=We($e({sessionId:t.id,isSampled:Ue()}),i);Ke.storeUserSession(n),e.faro.api.setSession(n.sessionMeta)}}))}}Ke.storageTypeSession=Oe;class Xe extends ae{constructor(){super(...arguments),this.name="@grafana/faro-web-sdk:instrumentation-session",this.version=le}sendSessionStartEvent(e){var n,t;const i=e.session;if(i&&i.id!==(null===(n=this.notifiedSession)||void 0===n?void 0:n.id)){if(this.notifiedSession&&this.notifiedSession.id===(null===(t=i.attributes)||void 0===t?void 0:t.previousSession))return this.api.pushEvent(we,{},void 0,{skipDedupe:!0}),void(this.notifiedSession=i);this.notifiedSession=i,this.api.pushEvent(me,{},void 0,{skipDedupe:!0})}}createInitialSessionMeta(e){var n,t,i;let r=(e.persistent?He:Ke).fetchUserSession();if(e.persistent&&e.maxSessionPersistenceTime&&r){const n=A();r.lastActivity<n-e.maxSessionPersistenceTime&&(He.removeUserSession(),r=null)}let o,s=null===(n=e.session)||void 0===n?void 0:n.id,a=null===(t=e.session)||void 0===t?void 0:t.attributes;Ge(r)?(s=null==r?void 0:r.sessionId,a=Object.assign(Object.assign({},null===(i=null==r?void 0:r.sessionMeta)||void 0===i?void 0:i.attributes),{isSampled:r.isSampled.toString()}),o=he):(s=null!=s?s:ke().id,o=me);return{sessionMeta:{id:s,attributes:Object.assign({isSampled:Ue().toString()},a)},lifecycleType:o}}registerBeforeSendHook(e){var n;const{updateSession:t}=new e;null===(n=this.transports)||void 0===n||n.addBeforeSendHooks((e=>{var n,i,r;t();const o=null===(n=e.meta.session)||void 0===n?void 0:n.attributes;if(o&&"true"===(null==o?void 0:o.isSampled)){let n;n="structuredClone"in window?structuredClone(e):JSON.parse(JSON.stringify(e));const t=null===(i=n.meta.session)||void 0===i?void 0:i.attributes;return null==t||delete t.isSampled,0===Object.keys(null!=t?t:{}).length&&(null===(r=n.meta.session)||void 0===r||delete r.attributes),n}return null}))}initialize(){var e,n;this.logDebug("init session instrumentation");const t=this.config.sessionTracking;if(null==t?void 0:t.enabled){const i=(null===(e=this.config.sessionTracking)||void 0===e?void 0:e.persistent)?He:Ke;this.registerBeforeSendHook(i);const{sessionMeta:r,lifecycleType:o}=this.createInitialSessionMeta(t);i.storeUserSession($e({sessionId:r.id,isSampled:"true"===(null===(n=r.attributes)||void 0===n?void 0:n.isSampled)})),this.notifiedSession=r,this.api.setSession(r),o===me&&this.api.pushEvent(me,{},void 0,{skipDedupe:!0}),o===he&&this.api.pushEvent(he,{},void 0,{skipDedupe:!0})}this.metas.addListener(this.sendSessionStartEvent.bind(this))}}class Je extends ae{constructor(e={}){super(),this.options=e,this.name="@grafana/faro-web-sdk:instrumentation-console",this.version=le}initialize(){this.logDebug("Initializing\n",this.options),k.filter((e=>{var n;return!(null!==(n=this.options.disabledLevels)&&void 0!==n?n:Je.defaultDisabledLevels).includes(e)})).forEach((e=>{console[e]=(...n)=>{try{this.api.pushLog(n,{level:e})}catch(e){this.logError(e)}finally{this.unpatchedConsole[e](...n)}}}))}}Je.defaultDisabledLevels=[e.LogLevel.DEBUG,e.LogLevel.TRACE,e.LogLevel.LOG];const Ze=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,Ye=/^\s*at (?:(.*\).*?|.*?) ?\((?:address at )?)?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Qe=/\((\S*)(?::(\d+))(?::(\d+))\)/,en="address at ",nn=en.length,tn=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|safari-extension|safari-web-extension|capacitor)?:\/.*?|\[native code]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,rn=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,on="safari-extension",sn="safari-web-extension",an=/Minified React error #\d+;/i;function ln(e,n,t,i){const r={filename:e||document.location.href,function:n||"?"};return void 0!==t&&(r.lineno=t),void 0!==i&&(r.colno=i),r}function un(e,n){const t=null==e?void 0:e.includes(on),i=!t&&(null==e?void 0:e.includes(sn));return t||i?[(null==e?void 0:e.includes("@"))?e.split("@")[0]:e,t?`${on}:${n}`:`${sn}:${n}`]:[e,n]}function cn(e){let n=[];e.stacktrace?n=e.stacktrace.split("\n").filter(((e,n)=>n%2==0)):e.stack&&(n=e.stack.split("\n"));const t=n.reduce(((n,t,i)=>{let r,o,s,l,u;if(r=Ye.exec(t)){if(o=r[1],s=r[2],l=r[3],u=r[4],null==s?void 0:s.startsWith("eval")){const e=Qe.exec(s);e&&(s=e[1],l=e[2],u=e[3])}s=(null==s?void 0:s.startsWith(en))?s.substring(nn):s,[o,s]=un(o,s)}else if(r=tn.exec(t)){if(o=r[1],s=r[3],l=r[4],u=r[5],s&&s.includes(" > eval")){const e=rn.exec(s);e&&(o=o||"eval",s=e[1],l=e[2])}else 0===i&&!u&&a(e.columnNumber)&&(u=String(e.columnNumber+1));[o,s]=un(o,s)}return(s||o)&&n.push(ln(s,o,l?Number(l):void 0,u?Number(u):void 0)),n}),[]);return an.test(e.message)?t.slice(1):t}function dn(e){return{frames:cn(e)}}function pn(e){let n,t,i,r,o=[];if(b(e)&&e.error)n=e.error.message,t=e.error.name,o=cn(e.error);else if((i=m(e))||h(e)){const{name:r,message:o}=e;t=null!=r?r:i?"DOMError":"DOMException",n=o?`${t}: ${o}`:t}else v(e)?(n=e.message,o=cn(e)):(l(e)||(r=f(e)))&&(t=r?e.constructor.name:void 0,n=`Non-Error exception captured with keys: ${Object.keys(e)}`);return[n,t,o]}function fn(e){const n=window.onerror;window.onerror=(...t)=>{try{const[i,r,o,a,l]=t;let u,c,d=[];const p=s(i),f=ln(r,"?",o,a);l||!p?([u,c,d]=pn(null!=l?l:i),0===d.length&&(d=[f])):p&&([u,c]=function(e){var n,t;const i=e.match(Ze),r=null!==(n=null==i?void 0:i[1])&&void 0!==n?n:ie;return[null!==(t=null==i?void 0:i[2])&&void 0!==t?t:e,r]}(i),d=[f]),u&&e.pushError(new Error(u),{type:c,stackFrames:d})}finally{null==n||n.apply(window,t)}}}class gn extends ae{constructor(){super(...arguments),this.name="@grafana/faro-web-sdk:instrumentation-errors",this.version=le}initialize(){var e;this.logDebug("Initializing"),fn(this.api),e=this.api,window.addEventListener("unhandledrejection",(n=>{var t,i;let r,o,s=n;s.reason?s=n.reason:(null===(t=n.detail)||void 0===t?void 0:t.reason)&&(s=null===(i=n.detail)||void 0===i?void 0:i.reason);let a=[];d(s)?(r=`Non-Error promise rejection captured with value: ${String(s)}`,o="UnhandledRejection"):[r,o,a]=pn(s),r&&e.pushError(new Error(r),{type:o,stackFrames:a})}))}}class vn extends ae{constructor(){super(...arguments),this.name="@grafana/faro-web-sdk:instrumentation-view",this.version=le}sendViewChangedEvent(e){var n,t,i;const r=e.view;r&&r.name!==(null===(n=this.notifiedView)||void 0===n?void 0:n.name)&&(this.api.pushEvent(be,{fromView:null!==(i=null===(t=this.notifiedView)||void 0===t?void 0:t.name)&&void 0!==i?i:"",toView:r.name},void 0,{skipDedupe:!0}),this.notifiedView=r)}initialize(){this.sendViewChangedEvent(this.metas.value),this.metas.addListener(this.sendViewChangedEvent.bind(this))}}var bn,mn,hn,wn,yn,En=-1,Sn=function(e){addEventListener("pageshow",(function(n){n.persisted&&(En=n.timeStamp,e(n))}),!0)},Tn=function(){return window.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]},xn=function(){var e=Tn();return e&&e.activationStart||0},kn=function(e,n){var t=Tn(),i="navigate";return En>=0?i="back-forward-cache":t&&(document.prerendering||xn()>0?i="prerender":document.wasDiscarded?i="restore":t.type&&(i=t.type.replace(/_/g,"-"))),{name:e,value:void 0===n?-1:n,rating:"good",delta:0,entries:[],id:"v3-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:i}},In=function(e,n,t){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){var i=new PerformanceObserver((function(e){Promise.resolve().then((function(){n(e.getEntries())}))}));return i.observe(Object.assign({type:e,buffered:!0},t||{})),i}}catch(e){}},On=function(e,n,t,i){var r,o;return function(s){n.value>=0&&(s||i)&&((o=n.value-(r||0))||void 0===r)&&(r=n.value,n.delta=o,n.rating=function(e,n){return e>n[1]?"poor":e>n[0]?"needs-improvement":"good"}(n.value,t),e(n))}},Ln=function(e){requestAnimationFrame((function(){return requestAnimationFrame((function(){return e()}))}))},Nn=function(e){var n=function(n){"pagehide"!==n.type&&"hidden"!==document.visibilityState||e(n)};addEventListener("visibilitychange",n,!0),addEventListener("pagehide",n,!0)},An=function(e){var n=!1;return function(t){n||(e(t),n=!0)}},Cn=-1,jn=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},Rn=function(e){"hidden"===document.visibilityState&&Cn>-1&&(Cn="visibilitychange"===e.type?e.timeStamp:0,Mn())},_n=function(){addEventListener("visibilitychange",Rn,!0),addEventListener("prerenderingchange",Rn,!0)},Mn=function(){removeEventListener("visibilitychange",Rn,!0),removeEventListener("prerenderingchange",Rn,!0)},Dn=function(){return Cn<0&&(Cn=jn(),_n(),Sn((function(){setTimeout((function(){Cn=jn(),_n()}),0)}))),{get firstHiddenTime(){return Cn}}},Un=function(e){document.prerendering?addEventListener("prerenderingchange",(function(){return e()}),!0):e()},Pn=[1800,3e3],Bn=function(e,n){n=n||{},Un((function(){var t,i=Dn(),r=kn("FCP"),o=In("paint",(function(e){e.forEach((function(e){"first-contentful-paint"===e.name&&(o.disconnect(),e.startTime<i.firstHiddenTime&&(r.value=Math.max(e.startTime-xn(),0),r.entries.push(e),t(!0)))}))}));o&&(t=On(e,r,Pn,n.reportAllChanges),Sn((function(i){r=kn("FCP"),t=On(e,r,Pn,n.reportAllChanges),Ln((function(){r.value=performance.now()-i.timeStamp,t(!0)}))})))}))},zn=[.1,.25],Fn={passive:!0,capture:!0},Vn=new Date,$n=function(e,n){bn||(bn=n,mn=e,hn=new Date,Wn(removeEventListener),Gn())},Gn=function(){if(mn>=0&&mn<hn-Vn){var e={entryType:"first-input",name:bn.type,target:bn.target,cancelable:bn.cancelable,startTime:bn.timeStamp,processingStart:bn.timeStamp+mn};wn.forEach((function(n){n(e)})),wn=[]}},qn=function(e){if(e.cancelable){var n=(e.timeStamp>1e12?new Date:performance.now())-e.timeStamp;"pointerdown"==e.type?function(e,n){var t=function(){$n(e,n),r()},i=function(){r()},r=function(){removeEventListener("pointerup",t,Fn),removeEventListener("pointercancel",i,Fn)};addEventListener("pointerup",t,Fn),addEventListener("pointercancel",i,Fn)}(n,e):$n(n,e)}},Wn=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach((function(n){return e(n,qn,Fn)}))},Hn=[100,300],Kn=0,Xn=1/0,Jn=0,Zn=function(e){e.forEach((function(e){e.interactionId&&(Xn=Math.min(Xn,e.interactionId),Jn=Math.max(Jn,e.interactionId),Kn=Jn?(Jn-Xn)/7+1:0)}))},Yn=function(){return yn?Kn:performance.interactionCount||0},Qn=function(){"interactionCount"in performance||yn||(yn=In("event",Zn,{type:"event",buffered:!0,durationThreshold:0}))},et=[200,500],nt=0,tt=function(){return Yn()-nt},it=[],rt={},ot=function(e){var n=it[it.length-1],t=rt[e.interactionId];if(t||it.length<10||e.duration>n.latency){if(t)t.entries.push(e),t.latency=Math.max(t.latency,e.duration);else{var i={id:e.interactionId,latency:e.duration,entries:[e]};rt[i.id]=i,it.push(i)}it.sort((function(e,n){return n.latency-e.latency})),it.splice(10).forEach((function(e){delete rt[e.id]}))}},st=[2500,4e3],at={},lt=[800,1800],ut=function e(n){document.prerendering?Un((function(){return e(n)})):"complete"!==document.readyState?addEventListener("load",(function(){return e(n)}),!0):setTimeout(n,0)};class ct extends ae{constructor(){super(...arguments),this.name="@grafana/faro-web-sdk:instrumentation-web-vitals",this.version=le}initialize(){this.logDebug("Initializing"),Object.entries(ct.mapping).forEach((([e,n])=>{n((n=>{this.api.pushMeasurement({type:"web-vitals",values:{[e]:n.value}})}))}))}}function dt(e={}){const n=[new gn,new ct,new Xe,new vn];return!1!==e.captureConsole&&n.push(new Je({disabledLevels:e.captureConsoleDisabledLevels})),n}ct.mapping={cls:function(e,n){n=n||{},Bn(An((function(){var t,i=kn("CLS",0),r=0,o=[],s=function(e){e.forEach((function(e){if(!e.hadRecentInput){var n=o[0],t=o[o.length-1];r&&e.startTime-t.startTime<1e3&&e.startTime-n.startTime<5e3?(r+=e.value,o.push(e)):(r=e.value,o=[e])}})),r>i.value&&(i.value=r,i.entries=o,t())},a=In("layout-shift",s);a&&(t=On(e,i,zn,n.reportAllChanges),Nn((function(){s(a.takeRecords()),t(!0)})),Sn((function(){r=0,i=kn("CLS",0),t=On(e,i,zn,n.reportAllChanges),Ln((function(){return t()}))})),setTimeout(t,0))})))},fcp:Bn,fid:function(e,n){n=n||{},Un((function(){var t,i=Dn(),r=kn("FID"),o=function(e){e.startTime<i.firstHiddenTime&&(r.value=e.processingStart-e.startTime,r.entries.push(e),t(!0))},s=function(e){e.forEach(o)},a=In("first-input",s);t=On(e,r,Hn,n.reportAllChanges),a&&Nn(An((function(){s(a.takeRecords()),a.disconnect()}))),a&&Sn((function(){var i;r=kn("FID"),t=On(e,r,Hn,n.reportAllChanges),wn=[],mn=-1,bn=null,Wn(addEventListener),i=o,wn.push(i),Gn()}))}))},inp:function(e,n){n=n||{},Un((function(){var t;Qn();var i,r=kn("INP"),o=function(e){e.forEach((function(e){e.interactionId&&ot(e),"first-input"===e.entryType&&!it.some((function(n){return n.entries.some((function(n){return e.duration===n.duration&&e.startTime===n.startTime}))}))&&ot(e)}));var n,t=(n=Math.min(it.length-1,Math.floor(tt()/50)),it[n]);t&&t.latency!==r.value&&(r.value=t.latency,r.entries=t.entries,i())},s=In("event",o,{durationThreshold:null!==(t=n.durationThreshold)&&void 0!==t?t:40});i=On(e,r,et,n.reportAllChanges),s&&("interactionId"in PerformanceEventTiming.prototype&&s.observe({type:"first-input",buffered:!0}),Nn((function(){o(s.takeRecords()),r.value<0&&tt()>0&&(r.value=0,r.entries=[]),i(!0)})),Sn((function(){it=[],nt=Yn(),r=kn("INP"),i=On(e,r,et,n.reportAllChanges)})))}))},lcp:function(e,n){n=n||{},Un((function(){var t,i=Dn(),r=kn("LCP"),o=function(e){var n=e[e.length-1];n&&n.startTime<i.firstHiddenTime&&(r.value=Math.max(n.startTime-xn(),0),r.entries=[n],t())},s=In("largest-contentful-paint",o);if(s){t=On(e,r,st,n.reportAllChanges);var a=An((function(){at[r.id]||(o(s.takeRecords()),s.disconnect(),at[r.id]=!0,t(!0))}));["keydown","click"].forEach((function(e){addEventListener(e,(function(){return setTimeout(a,0)}),!0)})),Nn(a),Sn((function(i){r=kn("LCP"),t=On(e,r,st,n.reportAllChanges),Ln((function(){r.value=performance.now()-i.timeStamp,at[r.id]=!0,t(!0)}))}))}}))},ttfb:function(e,n){n=n||{};var t=kn("TTFB"),i=On(e,t,lt,n.reportAllChanges);ut((function(){var r=Tn();if(r){var o=r.responseStart;if(o<=0||o>performance.now())return;t.value=Math.max(o-xn(),0),t.entries=[r],i(!0),Sn((function(){t=kn("TTFB",0),(i=On(e,t,lt,n.reportAllChanges))(!0)}))}}))}};const pt="browser",ft=()=>({k6:{isK6Browser:!0}});function gt(e,n,t,i){return new(t||(t=Promise))((function(r,o){function s(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var n;e.done?r(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(s,a)}l((i=i.apply(e,n||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class vt extends ee{constructor(e){var n,t,i,r;super(),this.options=e,this.name="@grafana/faro-web-sdk:transport-fetch",this.version=le,this.disabledUntil=new Date,this.rateLimitBackoffMs=null!==(n=e.defaultRateLimitBackoffMs)&&void 0!==n?n:5e3,this.getNow=null!==(t=e.getNow)&&void 0!==t?t:()=>Date.now(),this.promiseBuffer=O({size:null!==(i=e.bufferSize)&&void 0!==i?i:30,concurrency:null!==(r=e.concurrency)&&void 0!==r?r:5})}send(e){return gt(this,void 0,void 0,(function*(){try{if(this.disabledUntil>new Date(this.getNow()))return this.logWarn(`Dropping transport item due to too many requests. Backoff until ${this.disabledUntil}`),Promise.resolve();yield this.promiseBuffer.add((()=>{var n;const t=JSON.stringify(te(e)),{url:i,requestOptions:r,apiKey:o}=this.options,s=null!=r?r:{},{headers:a}=s,l=function(e,n){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&n.indexOf(i)<0&&(t[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)n.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(t[i[r]]=e[i[r]])}return t}(s,["headers"]),u=null===(n=this.metas.value.session)||void 0===n?void 0:n.id;return fetch(i,Object.assign({method:"POST",headers:Object.assign(Object.assign(Object.assign({"Content-Type":"application/json"},null!=a?a:{}),o?{"x-api-key":o}:{}),u?{"x-faro-session-id":u}:{}),body:t,keepalive:t.length<=6e4},null!=l?l:{})).then((e=>(429===e.status&&(this.disabledUntil=this.getRetryAfterDate(e),this.logWarn(`Too many requests, backing off until ${this.disabledUntil}`)),e.text().catch(I),e))).catch((e=>{this.logError("Failed sending payload to the receiver\n",JSON.parse(t),e)}))}))}catch(e){this.logError(e)}}))}getIgnoreUrls(){return[this.options.url]}isBatched(){return!0}getRetryAfterDate(e){const n=this.getNow(),t=e.headers.get("Retry-After");if(t){const e=Number(t);if(!isNaN(e))return new Date(1e3*e+n);const i=Date.parse(t);if(!isNaN(i))return new Date(i)}return new Date(n+this.rateLimitBackoffMs)}}function bt(e){var n,t,i,r,o,s,a,u,c;const d=[],p=J(e.unpatchedConsole,e.internalLoggerLevel);e.transports?((e.url||e.apiKey)&&p.error('if "transports" is defined, "url" and "apiKey" should not be defined'),d.push(...e.transports)):e.url?d.push(new vt({url:e.url,apiKey:e.apiKey})):p.error('either "url" or "transports" must be defined');return{app:e.app,batching:Object.assign(Object.assign({},ve),e.batching),dedupe:null===(n=e.dedupe)||void 0===n||n,globalObjectKey:e.globalObjectKey||ge,instrumentations:null!==(t=e.instrumentations)&&void 0!==t?t:dt(),internalLoggerLevel:null!==(i=e.internalLoggerLevel)&&void 0!==i?i:W,isolate:null!==(r=e.isolate)&&void 0!==r&&r,metas:function(){const n=xe;return e.metas&&n.push(...e.metas),l(window.k6)?[...n,ft]:n}(),parseStacktrace:dn,paused:null!==(o=e.paused)&&void 0!==o&&o,preventGlobalExposure:null!==(s=e.preventGlobalExposure)&&void 0!==s&&s,transports:d,unpatchedConsole:null!==(a=e.unpatchedConsole)&&void 0!==a?a:H,beforeSend:e.beforeSend,eventDomain:null!==(u=e.eventDomain)&&void 0!==u?u:pt,ignoreErrors:e.ignoreErrors,sessionTracking:Object.assign(Object.assign({},Ve),e.sessionTracking),user:e.user,view:null!==(c=e.view)&&void 0!==c?c:Ie}}return e.BaseExtension=Q,e.BaseInstrumentation=ae,e.BaseTransport=ee,e.ConsoleInstrumentation=Je,e.ConsoleTransport=class extends ee{constructor(e={}){super(),this.options=e,this.name="@grafana/faro-web-sdk:transport-console",this.version=le}send(n){var t;return this.unpatchedConsole[null!==(t=this.options.level)&&void 0!==t?t:e.LogLevel.DEBUG]("New event",te([n]))}},e.Conventions={EventNames:{CLICK:"click",NAVIGATION:"navigation",SESSION_START:"session_start",VIEW_CHANGED:"view_changed"}},e.EVENT_CLICK="click",e.EVENT_NAVIGATION="navigation",e.EVENT_ROUTE_CHANGE="route_change",e.EVENT_SESSION_EXTEND=we,e.EVENT_SESSION_RESUME=he,e.EVENT_SESSION_START=me,e.EVENT_VIEW_CHANGED=be,e.ErrorsInstrumentation=gn,e.FetchTransport=vt,e.MAX_SESSION_PERSISTENCE_TIME=Fe,e.MAX_SESSION_PERSISTENCE_TIME_BUFFER=6e4,e.PersistentSessionsManager=He,e.SESSION_EXPIRATION_TIME=Be,e.SESSION_INACTIVITY_TIME=ze,e.STORAGE_KEY=Pe,e.SessionInstrumentation=Xe,e.VERSION=le,e.ViewInstrumentation=vn,e.VolatileSessionsManager=Ke,e.WebVitalsInstrumentation=ct,e.allLogLevels=k,e.browserMeta=Se,e.buildStackFrame=ln,e.createInternalLogger=J,e.createPromiseBuffer=O,e.createSession=ke,e.deepEqual=E,e.defaultEventDomain=pt,e.defaultExceptionType=ie,e.defaultGlobalObjectKey=ge,e.defaultInternalLoggerLevel=W,e.defaultLogLevel=x,e.defaultMetas=xe,e.defaultViewMeta=Ie,e.genShortID=N,e.getCurrentTimestamp=S,e.getDataFromSafariExtensions=un,e.getInternalFaroFromGlobalObject=function(){return se[ue]},e.getStackFramesFromError=cn,e.getTransportBody=te,e.getWebInstrumentations=dt,e.globalObject=se,e.initializeFaro=function(e){const n=bt(e);if(n)return fe(n)},e.internalGlobalObjectKey=ue,e.isArray=c,e.isBoolean=e=>n(e,"boolean"),e.isDomError=m,e.isDomException=h,e.isElement=e=>w&&i(e,Element),e.isElementDefined=w,e.isError=v,e.isErrorDefined=g,e.isErrorEvent=b,e.isEvent=f,e.isEventDefined=p,e.isFunction=u,e.isInstanceOf=i,e.isInt=e=>a(e)&&Number.isInteger(e),e.isInternalFaroOnGlobalObject=de,e.isMap=e=>y&&i(e,Map),e.isMapDefined=y,e.isNull=o,e.isNumber=a,e.isObject=l,e.isPrimitive=d,e.isRegExp=e=>t(e,"RegExp"),e.isString=s,e.isSymbol=e=>n(e,"symbol"),e.isSyntheticEvent=e=>l(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e,e.isThenable=e=>u(null==e?void 0:e.then),e.isToString=t,e.isTypeof=n,e.isUndefined=r,e.makeCoreConfig=bt,e.noop=I,e.pageMeta=Te,e.parseStacktrace=dn,e.sdkMeta=()=>({sdk:{name:"@grafana/faro-core",version:le,integrations:e.faro.config.instrumentations.map((({name:e,version:n})=>({name:e,version:n})))}}),e.setInternalFaroOnGlobalObject=ce,e.transportItemTypeToBodyKey=F,e}({});
|
|
1
|
+
var GrafanaFaroWebSdk=function(e){"use strict";function n(e,n){return typeof e===n}function t(e,n){return Object.prototype.toString.call(e)===`[object ${n}]`}function i(e,n){try{return e instanceof n}catch(e){return!1}}const o=e=>n(e,"undefined"),r=e=>n(e,"null"),s=e=>n(e,"string"),a=e=>n(e,"number")&&!isNaN(e)||n(e,"bigint"),l=e=>!r(e)&&n(e,"object"),u=e=>n(e,"function"),c=e=>t(e,"Array"),d=e=>!l(e)&&!u(e),p=!o(Event),f=e=>p&&i(e,Event),g="undefined"!=typeof Error,v=e=>g&&i(e,Error),b=e=>t(e,"ErrorEvent"),m=e=>t(e,"DOMError"),h=e=>t(e,"DOMException"),w="undefined"!=typeof Element,y="undefined"!=typeof Map;function E(e,t){if(e===t)return!0;if(n(e,"number")&&isNaN(e))return n(t,"number")&&isNaN(t);const i=c(e),o=c(t);if(i!==o)return!1;if(i&&o){const n=e.length;if(n!==t.length)return!1;for(let i=n;0!=i--;)if(!E(e[i],t[i]))return!1;return!0}const r=l(e),s=l(t);if(r!==s)return!1;if(e&&t&&r&&s){const n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(let e of n)if(!i.includes(e))return!1;for(let i of n)if(!E(e[i],t[i]))return!1;return!0}return!1}function S(){return(new Date).toISOString()}var T;e.LogLevel=void 0,(T=e.LogLevel||(e.LogLevel={})).TRACE="trace",T.DEBUG="debug",T.INFO="info",T.LOG="log",T.WARN="warn",T.ERROR="error";const x=e.LogLevel.LOG,k=[e.LogLevel.TRACE,e.LogLevel.DEBUG,e.LogLevel.INFO,e.LogLevel.LOG,e.LogLevel.WARN,e.LogLevel.ERROR];function I(){}function O(e){const{size:n,concurrency:t}=e,i=[];let o=0;const r=()=>{if(o<t&&i.length){const{producer:e,resolve:n,reject:t}=i.shift();o++,e().then((e=>{o--,r(),n(e)}),(e=>{o--,r(),t(e)}))}};return{add:e=>{if(i.length+o>=n)throw new Error("Task buffer full");return new Promise(((n,t)=>{i.push({producer:e,resolve:n,reject:t}),r()}))}}}const L="abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789";function A(e=10){return Array.from(Array(e)).map((()=>L[Math.floor(Math.random()*L.length)])).join("")}function N(){return Date.now()}var C="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},j={exports:{}},R={exports:{}};R.exports=function(e,n){var t,i,o,r,s,a,l,u;for(t=3&e.length,i=e.length-t,o=n,s=3432918353,a=461845907,u=0;u<i;)l=255&e.charCodeAt(u)|(255&e.charCodeAt(++u))<<8|(255&e.charCodeAt(++u))<<16|(255&e.charCodeAt(++u))<<24,++u,o=27492+(65535&(r=5*(65535&(o=(o^=l=(65535&(l=(l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|o>>>19))+((5*(o>>>16)&65535)<<16)&4294967295))+((58964+(r>>>16)&65535)<<16);switch(l=0,t){case 3:l^=(255&e.charCodeAt(u+2))<<16;case 2:l^=(255&e.charCodeAt(u+1))<<8;case 1:o^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(u)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return o^=e.length,o=2246822507*(65535&(o^=o>>>16))+((2246822507*(o>>>16)&65535)<<16)&4294967295,o=3266489909*(65535&(o^=o>>>13))+((3266489909*(o>>>16)&65535)<<16)&4294967295,(o^=o>>>16)>>>0};var _=R.exports,M={exports:{}};!function(e){e.exports=function(e,n){for(var t,i=e.length,o=n^i,r=0;i>=4;)t=1540483477*(65535&(t=255&e.charCodeAt(r)|(255&e.charCodeAt(++r))<<8|(255&e.charCodeAt(++r))<<16|(255&e.charCodeAt(++r))<<24))+((1540483477*(t>>>16)&65535)<<16),o=1540483477*(65535&o)+((1540483477*(o>>>16)&65535)<<16)^(t=1540483477*(65535&(t^=t>>>24))+((1540483477*(t>>>16)&65535)<<16)),i-=4,++r;switch(i){case 3:o^=(255&e.charCodeAt(r+2))<<16;case 2:o^=(255&e.charCodeAt(r+1))<<8;case 1:o=1540483477*(65535&(o^=255&e.charCodeAt(r)))+((1540483477*(o>>>16)&65535)<<16)}return o=1540483477*(65535&(o^=o>>>13))+((1540483477*(o>>>16)&65535)<<16),(o^=o>>>15)>>>0}}(M);var D=_,U=M.exports;j.exports=D;var P=j.exports.murmur3=D;j.exports.murmur2=U;class B{constructor(e,n){var t,i;this.signalBuffer=[],this.itemLimit=null!==(t=null==n?void 0:n.itemLimit)&&void 0!==t?t:50,this.sendTimeout=null!==(i=null==n?void 0:n.sendTimeout)&&void 0!==i?i:250,this.paused=(null==n?void 0:n.paused)||!1,this.sendFn=e,this.flushInterval=-1,this.paused||this.start(),document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&this.flush()}))}addItem(e){this.paused||(this.signalBuffer.push(e),this.signalBuffer.length>=this.itemLimit&&this.flush())}start(){this.paused=!1,this.sendTimeout>0&&(this.flushInterval=window.setInterval((()=>this.flush()),this.sendTimeout))}pause(){this.paused=!0,clearInterval(this.flushInterval)}groupItems(e){const n=new Map;return e.forEach((e=>{const t=P(JSON.stringify(e.meta));let i=n.get(t);i=void 0===i?[e]:[...i,e],n.set(t,i)})),Array.from(n.values())}flush(){if(this.paused||0===this.signalBuffer.length)return;this.groupItems(this.signalBuffer).forEach(this.sendFn),this.signalBuffer=[]}}var z;e.TransportItemType=void 0,(z=e.TransportItemType||(e.TransportItemType={})).EXCEPTION="exception",z.LOG="log",z.MEASUREMENT="measurement",z.TRACE="trace",z.EVENT="event";const F={[e.TransportItemType.EXCEPTION]:"exceptions",[e.TransportItemType.LOG]:"logs",[e.TransportItemType.MEASUREMENT]:"measurements",[e.TransportItemType.TRACE]:"traces",[e.TransportItemType.EVENT]:"events"};function V(n){return t=>{if(t.type===e.TransportItemType.EXCEPTION&&t.payload){const e=t.payload,i=`${e.type}: ${e.value}`;if(function(e,n){return e.some((e=>s(e)?n.includes(e):!!n.match(e)))}(n,i))return null}return t}}function $(e,n,t,i){var o;n.debug("Initializing transports");const r=[];let s=t.paused,a=[];const l=e=>{let n=e;for(const e of a){const t=n.map(e).filter(Boolean);if(0===t.length)return[];n=t}return n},u=e=>{const t=l(e);if(0!==t.length)for(const e of r)n.debug(`Transporting item using ${e.name}\n`,t),e.isBatched()&&e.send(t)};let c;(null===(o=t.batching)||void 0===o?void 0:o.enabled)&&(c=new B(u,{sendTimeout:t.batching.sendTimeout,itemLimit:t.batching.itemLimit,paused:s}));return{add:(...o)=>{n.debug("Adding transports"),o.forEach((o=>{n.debug(`Adding "${o.name}" transport`);r.some((e=>e===o))?n.warn(`Transport ${o.name} is already added`):(o.unpatchedConsole=e,o.internalLogger=n,o.config=t,o.metas=i,r.push(o))}))},addBeforeSendHooks:(...e)=>{n.debug("Adding beforeSendHooks\n",a),e.forEach((e=>{e&&a.push(e)}))},addIgnoreErrorsPatterns:(...e)=>{n.debug("Adding ignoreErrorsPatterns\n",e),e.forEach((e=>{e&&a.push(V(e))}))},getBeforeSendHooks:()=>[...a],execute:e=>{var i;s||((null===(i=t.batching)||void 0===i?void 0:i.enabled)&&(null==c||c.addItem(e)),(e=>{var i,o;if((null===(i=t.batching)||void 0===i?void 0:i.enabled)&&r.every((e=>e.isBatched())))return;const[s]=l([e]);if(void 0!==s)for(const e of r)n.debug(`Transporting item using ${e.name}\n`,s),e.isBatched()?(null===(o=t.batching)||void 0===o?void 0:o.enabled)||e.send([s]):e.send(s)})(e))},isPaused:()=>s,pause:()=>{n.debug("Pausing transports"),null==c||c.pause(),s=!0},remove:(...e)=>{n.debug("Removing transports"),e.forEach((e=>{n.debug(`Removing "${e.name}" transport`);const t=r.indexOf(e);-1!==t?r.splice(t,1):n.warn(`Transport "${e.name}" is not added`)}))},removeBeforeSendHooks:(...e)=>{a.filter((n=>!e.includes(n)))},get transports(){return[...r]},unpause:()=>{n.debug("Unpausing transports"),null==c||c.start(),s=!1}}}var G;e.InternalLoggerLevel=void 0,(G=e.InternalLoggerLevel||(e.InternalLoggerLevel={}))[G.OFF=0]="OFF",G[G.ERROR=1]="ERROR",G[G.WARN=2]="WARN",G[G.INFO=3]="INFO",G[G.VERBOSE=4]="VERBOSE";const q={debug:I,error:I,info:I,prefix:"Faro",warn:I},W=e.InternalLoggerLevel.ERROR,H=Object.assign({},console);let K=H;function X(e){var n;return K=null!==(n=e.unpatchedConsole)&&void 0!==n?n:K,K}function J(n=H,t=W){const i=q;return t>e.InternalLoggerLevel.OFF&&(i.error=t>=e.InternalLoggerLevel.ERROR?function(...e){n.error(`${i.prefix}\n`,...e)}:I,i.warn=t>=e.InternalLoggerLevel.WARN?function(...e){n.warn(`${i.prefix}\n`,...e)}:I,i.info=t>=e.InternalLoggerLevel.INFO?function(...e){n.info(`${i.prefix}\n`,...e)}:I,i.debug=t>=e.InternalLoggerLevel.VERBOSE?function(...e){n.debug(`${i.prefix}\n`,...e)}:I),i}let Z=q;function Y(e,n){return Z=J(e,n.internalLoggerLevel),Z}class Q{constructor(){this.unpatchedConsole=H,this.internalLogger=q,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)}}class ee extends Q{isBatched(){return!1}getIgnoreUrls(){return[]}}function ne(e,n){var t,i;if(void 0===n)return e;if(void 0===e)return{resourceSpans:n};const o=null===(t=e.resourceSpans)||void 0===t?void 0:t[0];if(void 0===o)return e;const r=(null==o?void 0:o.scopeSpans)||[],s=(null===(i=null==n?void 0:n[0])||void 0===i?void 0:i.scopeSpans)||[];return Object.assign(Object.assign({},e),{resourceSpans:[Object.assign(Object.assign({},o),{scopeSpans:[...r,...s]})]})}function te(n){let t={meta:{}};return void 0!==n[0]&&(t.meta=n[0].meta),n.forEach((n=>{switch(n.type){case e.TransportItemType.LOG:case e.TransportItemType.EVENT:case e.TransportItemType.EXCEPTION:case e.TransportItemType.MEASUREMENT:const i=F[n.type],o=t[i];t=Object.assign(Object.assign({},t),{[i]:void 0===o?[n.payload]:[...o,n.payload]});break;case e.TransportItemType.TRACE:t=Object.assign(Object.assign({},t),{traces:ne(t.traces,n.payload.resourceSpans)})}})),t}const ie="Error";let oe;function re(n,t,i,o,s){t.debug("Initializing API");const a=function(n,t,i,o,r){let s;return t.debug("Initializing traces API"),{getOTEL:()=>s,getTraceContext:()=>{const e=null==s?void 0:s.trace.getSpanContext(s.context.active());return e?{trace_id:e.traceId,span_id:e.spanId}:void 0},initOTEL:(e,n)=>{t.debug("Initializing OpenTelemetry"),s={trace:e,context:n}},isOTELInitialized:()=>!!s,pushTraces:n=>{try{const i={type:e.TransportItemType.TRACE,payload:n,meta:o.value};t.debug("Pushing trace\n",i),r.execute(i)}catch(e){t.error("Error pushing trace\n",e)}}}}(0,t,0,o,s);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},a),function(n,t,i,o,s,a){var l;t.debug("Initializing exceptions API");let u=null;oe=null!==(l=i.parseStacktrace)&&void 0!==l?l:oe;const c=e=>{t.debug("Changing stacktrace parser"),oe=null!=e?e:oe};return c(i.parseStacktrace),{changeStacktraceParser:c,getStacktraceParser:()=>oe,pushError:(n,{skipDedupe:l,stackFrames:c,type:d,context:p}={})=>{d=d||n.name||ie;const f={meta:o.value,payload:{type:d,value:n.message,timestamp:S(),trace:a.getTraceContext(),context:null!=p?p:{}},type:e.TransportItemType.EXCEPTION};(null==(c=null!=c?c:n.stack?null==oe?void 0:oe(n).frames:void 0)?void 0:c.length)&&(f.payload.stacktrace={frames:c});const g={type:f.payload.type,value:f.payload.value,stackTrace:f.payload.stacktrace,context:f.payload.context};l||!i.dedupe||r(u)||!E(g,u)?(u=g,t.debug("Pushing exception\n",f),s.execute(f)):t.debug("Skipping error push because it is the same as the last one\n",f.payload)}}}(0,t,i,o,s,a)),function(e,n,t,i,o){let r,s,a;n.debug("Initializing meta API");const l=e=>{s&&i.remove(s),s={user:e},i.add(s)},u=e=>{r&&i.remove(r),r={session:e},i.add(r)};return{setUser:l,resetUser:l,setSession:u,resetSession:u,getSession:()=>i.value.session,setView:e=>{var n;if((null===(n=null==a?void 0:a.view)||void 0===n?void 0:n.name)===(null==e?void 0:e.name))return;const t=a;a={view:e},i.add(a),t&&i.remove(t)},getView:()=>i.value.view}}(0,t,0,o)),function(n,t,i,o,s,a){t.debug("Initializing logs API");let l=null;return{pushLog:(n,{context:u,level:c,skipDedupe:d}={})=>{try{const p={type:e.TransportItemType.LOG,payload:{message:n.map((e=>{try{return String(e)}catch(e){return""}})).join(" "),level:null!=c?c:x,context:null!=u?u:{},timestamp:S(),trace:a.getTraceContext()},meta:o.value},f={message:p.payload.message,level:p.payload.level,context:p.payload.context};if(!d&&i.dedupe&&!r(l)&&E(f,l))return void t.debug("Skipping log push because it is the same as the last one\n",p.payload);l=f,t.debug("Pushing log\n",p),s.execute(p)}catch(e){t.error("Error pushing log\n",e)}}}}(0,t,i,o,s,a)),function(n,t,i,o,s,a){t.debug("Initializing measurements API");let l=null;return{pushMeasurement:(n,{skipDedupe:u,context:c}={})=>{var d;try{const p={type:e.TransportItemType.MEASUREMENT,payload:Object.assign(Object.assign({},n),{trace:a.getTraceContext(),timestamp:null!==(d=n.timestamp)&&void 0!==d?d:S(),context:null!=c?c:{}}),meta:o.value},f={type:p.payload.type,values:p.payload.values,context:p.payload.context};if(!u&&i.dedupe&&!r(l)&&E(f,l))return void t.debug("Skipping measurement push because it is the same as the last one\n",p.payload);l=f,t.debug("Pushing measurement\n",p),s.execute(p)}catch(e){t.error("Error pushing measurement\n",e)}}}}(0,t,i,o,s,a)),function(n,t,i,o,s,a){let l=null;return{pushEvent:(n,u,c,{skipDedupe:d}={})=>{try{const p={meta:o.value,payload:{name:n,domain:null!=c?c:i.eventDomain,attributes:u,timestamp:S(),trace:a.getTraceContext()},type:e.TransportItemType.EVENT},f={name:p.payload.name,attributes:p.payload.attributes,domain:p.payload.domain};if(!d&&i.dedupe&&!r(l)&&E(f,l))return void t.debug("Skipping event push because it is the same as the last one\n",p.payload);l=f,t.debug("Pushing event\n",p),s.execute(p)}catch(e){t.error("Error pushing event",e)}}}}(0,t,i,o,s,a))}const se="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:void 0;class ae extends Q{constructor(){super(...arguments),this.api={},this.transports={}}}const le="1.3.5";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(se,ue,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function de(){return ue in se}function pe(n,t,i,o,r,s,a){return t.debug("Initializing Faro"),e.faro={api:s,config:i,instrumentations:a,internalLogger:t,metas:o,pause:r.pause,transports:r,unpatchedConsole:n,unpause:r.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 se)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(se,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}(e.faro),e.faro}function fe(e){const n=X(e),t=Y(n,e);if(de()&&!e.isolate)return void t.error('Faro is already registered. Either add instrumentations, transports etc. to the global faro instance or use the "isolate" property');t.debug("Initializing");const i=function(e,n,t){let i=[],o=[];const r=()=>i.reduce(((e,n)=>Object.assign(e,u(n)?n():n)),{}),s=()=>{if(o.length){const e=r();o.forEach((n=>n(e)))}};return{add:(...e)=>{n.debug("Adding metas\n",e),i.push(...e),s()},remove:(...e)=>{n.debug("Removing metas\n",e),i=i.filter((n=>!e.includes(n))),s()},addListener:e=>{n.debug("Adding metas listener\n",e),o.push(e)},removeListener:e=>{n.debug("Removing metas listener\n",e),o=o.filter((n=>n!==e))},get value(){return r()}}}(0,t),o=$(n,t,e,i),r=re(0,t,e,i,o),s=function(e,n,t,i,o,r){n.debug("Initializing instrumentations");const s=[];return{add:(...a)=>{n.debug("Adding instrumentations"),a.forEach((a=>{n.debug(`Adding "${a.name}" instrumentation`),s.some((e=>e.name===a.name))?n.warn(`Instrumentation ${a.name} is already added`):(a.unpatchedConsole=e,a.internalLogger=n,a.config=t,a.metas=i,a.transports=o,a.api=r,s.push(a),a.initialize())}))},get instrumentations(){return[...s]},remove:(...e)=>{n.debug("Removing instrumentations"),e.forEach((e=>{var t,i;n.debug(`Removing "${e.name}" instrumentation`);const o=s.reduce(((n,t,i)=>null===n&&t.name===e.name?i:null),null);o?(null===(i=(t=s[o]).destroy)||void 0===i||i.call(t),s.splice(o,1)):n.warn(`Instrumentation "${e.name}" is not added`)}))}}}(n,t,e,i,o,r),a=pe(n,t,e,i,o,r,s);return function(e){var n,t;const i={sdk:{version:le}},o=null===(n=e.config.sessionTracking)||void 0===n?void 0:n.session;o&&e.api.setSession(o),e.config.app&&(i.app=e.config.app),e.config.user&&(i.user=e.config.user),e.config.view&&(i.view=e.config.view),e.metas.add(i,...null!==(t=e.config.metas)&&void 0!==t?t:[])}(a),function(e){e.transports.add(...e.config.transports),e.transports.addBeforeSendHooks(e.config.beforeSend),e.transports.addIgnoreErrorsPatterns(e.config.ignoreErrors)}(a),function(e){e.instrumentations.add(...e.config.instrumentations)}(a),a}e.faro={};const ge="faro",ve={enabled:!0,sendTimeout:250,itemLimit:50},be="view_changed",me="session_start",he="session_resume",we="session_extend";var ye={exports:{}};!function(e,n){!function(t,i){var o="function",r="undefined",s="object",a="string",l="major",u="model",c="name",d="type",p="vendor",f="version",g="architecture",v="console",b="mobile",m="tablet",h="smarttv",w="wearable",y="embedded",E="Amazon",S="Apple",T="ASUS",x="BlackBerry",k="Browser",I="Chrome",O="Firefox",L="Google",A="Huawei",N="LG",C="Microsoft",j="Motorola",R="Opera",_="Samsung",M="Sharp",D="Sony",U="Xiaomi",P="Zebra",B="Facebook",z="Chromium OS",F="Mac OS",V=function(e){for(var n={},t=0;t<e.length;t++)n[e[t].toUpperCase()]=e[t];return n},$=function(e,n){return typeof e===a&&-1!==G(n).indexOf(G(e))},G=function(e){return e.toLowerCase()},q=function(e,n){if(typeof e===a)return e=e.replace(/^\s\s*/,""),typeof n===r?e:e.substring(0,350)},W=function(e,n){for(var t,r,a,l,u,c,d=0;d<n.length&&!u;){var p=n[d],f=n[d+1];for(t=r=0;t<p.length&&!u&&p[t];)if(u=p[t++].exec(e))for(a=0;a<f.length;a++)c=u[++r],typeof(l=f[a])===s&&l.length>0?2===l.length?typeof l[1]==o?this[l[0]]=l[1].call(this,c):this[l[0]]=l[1]:3===l.length?typeof l[1]!==o||l[1].exec&&l[1].test?this[l[0]]=c?c.replace(l[1],l[2]):i:this[l[0]]=c?l[1].call(this,c,l[2]):i:4===l.length&&(this[l[0]]=c?l[3].call(this,c.replace(l[1],l[2])):i):this[l]=c||i;d+=2}},H=function(e,n){for(var t in n)if(typeof n[t]===s&&n[t].length>0){for(var o=0;o<n[t].length;o++)if($(n[t][o],e))return"?"===t?i:t}else if($(n[t],e))return"?"===t?i:t;return e},K={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},X={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[f,[c,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[f,[c,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[c,f],[/opios[\/ ]+([\w\.]+)/i],[f,[c,R+" Mini"]],[/\bopr\/([\w\.]+)/i],[f,[c,R]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,/(avant |iemobile|slim)(?:browser)?[\/ ]?([\w\.]*)/i,/(ba?idubrowser)[\/ ]?([\w\.]+)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,/(heytap|ovi)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[c,f],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[f,[c,"UC"+k]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i],[f,[c,"WeChat(Win) Desktop"]],[/micromessenger\/([\w\.]+)/i],[f,[c,"WeChat"]],[/konqueror\/([\w\.]+)/i],[f,[c,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[f,[c,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[f,[c,"Yandex"]],[/(avast|avg)\/([\w\.]+)/i],[[c,/(.+)/,"$1 Secure "+k],f],[/\bfocus\/([\w\.]+)/i],[f,[c,O+" Focus"]],[/\bopt\/([\w\.]+)/i],[f,[c,R+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[f,[c,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[f,[c,"Dolphin"]],[/coast\/([\w\.]+)/i],[f,[c,R+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[f,[c,"MIUI "+k]],[/fxios\/([-\w\.]+)/i],[f,[c,O]],[/\bqihu|(qi?ho?o?|360)browser/i],[[c,"360 "+k]],[/(oculus|samsung|sailfish|huawei)browser\/([\w\.]+)/i],[[c,/(.+)/,"$1 "+k],f],[/(comodo_dragon)\/([\w\.]+)/i],[[c,/_/g," "],f],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|baiduboxapp|2345Explorer)[\/ ]?([\w\.]+)/i],[c,f],[/(metasr)[\/ ]?([\w\.]+)/i,/(lbbrowser)/i,/\[(linkedin)app\]/i],[c],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[c,B],f],[/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i],[c,f],[/\bgsa\/([\w\.]+) .*safari\//i],[f,[c,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[f,[c,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[f,[c,I+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[c,I+" WebView"],f],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[f,[c,"Android "+k]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[c,f],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[f,[c,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[f,c],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[c,[f,H,{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}]],[/(webkit|khtml)\/([\w\.]+)/i],[c,f],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[c,"Netscape"],f],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[f,[c,O+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i,/panasonic;(viera)/i],[c,f],[/(cobalt)\/([\w\.]+)/i],[c,[f,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[g,"amd64"]],[/(ia32(?=;))/i],[[g,G]],[/((?:i[346]|x)86)[;\)]/i],[[g,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[g,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[g,"armhf"]],[/windows (ce|mobile); ppc;/i],[[g,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[g,/ower/,"",G]],[/(sun4\w)[;\)]/i],[[g,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[g,G]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[u,[p,_],[d,m]],[/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],[u,[p,_],[d,b]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[u,[p,S],[d,b]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[u,[p,S],[d,m]],[/(macintosh);/i],[u,[p,S]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[u,[p,M],[d,b]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[u,[p,A],[d,m]],[/(?:huawei|honor)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[u,[p,A],[d,b]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i],[[u,/_/g," "],[p,U],[d,b]],[/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[u,/_/g," "],[p,U],[d,m]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[u,[p,"OPPO"],[d,b]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[u,[p,"Vivo"],[d,b]],[/\b(rmx[12]\d{3})(?: bui|;|\))/i],[u,[p,"Realme"],[d,b]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[u,[p,j],[d,b]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[u,[p,j],[d,m]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[u,[p,N],[d,m]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[u,[p,N],[d,b]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[u,[p,"Lenovo"],[d,m]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[u,/_/g," "],[p,"Nokia"],[d,b]],[/(pixel c)\b/i],[u,[p,L],[d,m]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[u,[p,L],[d,b]],[/droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[u,[p,D],[d,b]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[u,"Xperia Tablet"],[p,D],[d,m]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[u,[p,"OnePlus"],[d,b]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[u,[p,E],[d,m]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[u,/(.+)/g,"Fire Phone $1"],[p,E],[d,b]],[/(playbook);[-\w\),; ]+(rim)/i],[u,p,[d,m]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[u,[p,x],[d,b]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[u,[p,T],[d,m]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[u,[p,T],[d,b]],[/(nexus 9)/i],[u,[p,"HTC"],[d,m]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[p,[u,/_/g," "],[d,b]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[u,[p,"Acer"],[d,m]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[u,[p,"Meizu"],[d,b]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno)[-_ ]?([-\w]*)/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[p,u,[d,b]],[/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[p,u,[d,m]],[/(surface duo)/i],[u,[p,C],[d,m]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[u,[p,"Fairphone"],[d,b]],[/(u304aa)/i],[u,[p,"AT&T"],[d,b]],[/\bsie-(\w*)/i],[u,[p,"Siemens"],[d,b]],[/\b(rct\w+) b/i],[u,[p,"RCA"],[d,m]],[/\b(venue[\d ]{2,7}) b/i],[u,[p,"Dell"],[d,m]],[/\b(q(?:mv|ta)\w+) b/i],[u,[p,"Verizon"],[d,m]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[u,[p,"Barnes & Noble"],[d,m]],[/\b(tm\d{3}\w+) b/i],[u,[p,"NuVision"],[d,m]],[/\b(k88) b/i],[u,[p,"ZTE"],[d,m]],[/\b(nx\d{3}j) b/i],[u,[p,"ZTE"],[d,b]],[/\b(gen\d{3}) b.+49h/i],[u,[p,"Swiss"],[d,b]],[/\b(zur\d{3}) b/i],[u,[p,"Swiss"],[d,m]],[/\b((zeki)?tb.*\b) b/i],[u,[p,"Zeki"],[d,m]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[p,"Dragon Touch"],u,[d,m]],[/\b(ns-?\w{0,9}) b/i],[u,[p,"Insignia"],[d,m]],[/\b((nxa|next)-?\w{0,9}) b/i],[u,[p,"NextBook"],[d,m]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[p,"Voice"],u,[d,b]],[/\b(lvtel\-)?(v1[12]) b/i],[[p,"LvTel"],u,[d,b]],[/\b(ph-1) /i],[u,[p,"Essential"],[d,b]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[u,[p,"Envizen"],[d,m]],[/\b(trio[-\w\. ]+) b/i],[u,[p,"MachSpeed"],[d,m]],[/\btu_(1491) b/i],[u,[p,"Rotor"],[d,m]],[/(shield[\w ]+) b/i],[u,[p,"Nvidia"],[d,m]],[/(sprint) (\w+)/i],[p,u,[d,b]],[/(kin\.[onetw]{3})/i],[[u,/\./g," "],[p,C],[d,b]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[u,[p,P],[d,m]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[u,[p,P],[d,b]],[/smart-tv.+(samsung)/i],[p,[d,h]],[/hbbtv.+maple;(\d+)/i],[[u,/^/,"SmartTV"],[p,_],[d,h]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[p,N],[d,h]],[/(apple) ?tv/i],[p,[u,S+" TV"],[d,h]],[/crkey/i],[[u,I+"cast"],[p,L],[d,h]],[/droid.+aft(\w+)( bui|\))/i],[u,[p,E],[d,h]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[u,[p,M],[d,h]],[/(bravia[\w ]+)( bui|\))/i],[u,[p,D],[d,h]],[/(mitv-\w{5}) bui/i],[u,[p,U],[d,h]],[/Hbbtv.*(technisat) (.*);/i],[p,u,[d,h]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[p,q],[u,q],[d,h]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[d,h]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[p,u,[d,v]],[/droid.+; (shield) bui/i],[u,[p,"Nvidia"],[d,v]],[/(playstation [345portablevi]+)/i],[u,[p,D],[d,v]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[u,[p,C],[d,v]],[/((pebble))app/i],[p,u,[d,w]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[u,[p,S],[d,w]],[/droid.+; (glass) \d/i],[u,[p,L],[d,w]],[/droid.+; (wt63?0{2,3})\)/i],[u,[p,P],[d,w]],[/(quest( 2| pro)?)/i],[u,[p,B],[d,w]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[p,[d,y]],[/(aeobc)\b/i],[u,[p,E],[d,y]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+? mobile safari/i],[u,[d,b]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[u,[d,m]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[d,m]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[d,b]],[/(android[-\w\. ]{0,9});.+buil/i],[u,[p,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[f,[c,"EdgeHTML"]],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[f,[c,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[c,f],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[f,c]],os:[[/microsoft (windows) (vista|xp)/i],[c,f],[/(windows) nt 6\.2; (arm)/i,/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i,/(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i],[c,[f,H,K]],[/(win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[c,"Windows"],[f,H,K]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[f,/_/g,"."],[c,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[c,F],[f,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[f,c],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[c,f],[/\(bb(10);/i],[f,[c,x]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[f,[c,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[f,[c,O+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[f,[c,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[f,[c,"watchOS"]],[/crkey\/([\d\.]+)/i],[f,[c,I+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[c,z],f],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[c,f],[/(sunos) ?([\w\.\d]*)/i],[[c,"Solaris"],f],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[c,f]]},J=function(e,n){if(typeof e===s&&(n=e,e=i),!(this instanceof J))return new J(e,n).getResult();var v=typeof t!==r&&t.navigator?t.navigator:i,h=e||(v&&v.userAgent?v.userAgent:""),w=v&&v.userAgentData?v.userAgentData:i,y=n?function(e,n){var t={};for(var i in e)n[i]&&n[i].length%2==0?t[i]=n[i].concat(e[i]):t[i]=e[i];return t}(X,n):X,E=v&&v.userAgent==h;return this.getBrowser=function(){var e,n={};return n[c]=i,n[f]=i,W.call(n,h,y.browser),n[l]=typeof(e=n[f])===a?e.replace(/[^\d\.]/g,"").split(".")[0]:i,E&&v&&v.brave&&typeof v.brave.isBrave==o&&(n[c]="Brave"),n},this.getCPU=function(){var e={};return e[g]=i,W.call(e,h,y.cpu),e},this.getDevice=function(){var e={};return e[p]=i,e[u]=i,e[d]=i,W.call(e,h,y.device),E&&!e[d]&&w&&w.mobile&&(e[d]=b),E&&"Macintosh"==e[u]&&v&&typeof v.standalone!==r&&v.maxTouchPoints&&v.maxTouchPoints>2&&(e[u]="iPad",e[d]=m),e},this.getEngine=function(){var e={};return e[c]=i,e[f]=i,W.call(e,h,y.engine),e},this.getOS=function(){var e={};return e[c]=i,e[f]=i,W.call(e,h,y.os),E&&!e[c]&&w&&"Unknown"!=w.platform&&(e[c]=w.platform.replace(/chrome os/i,z).replace(/macos/i,F)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return h},this.setUA=function(e){return h=typeof e===a&&e.length>350?q(e,350):e,this},this.setUA(h),this};J.VERSION="1.0.36",J.BROWSER=V([c,f,l]),J.CPU=V([g]),J.DEVICE=V([u,p,d,v,b,h,m,w,y]),J.ENGINE=J.OS=V([c,f]),e.exports&&(n=e.exports=J),n.UAParser=J;var Z=typeof t!==r&&(t.jQuery||t.Zepto);if(Z&&!Z.ua){var Y=new J;Z.ua=Y.getResult(),Z.ua.get=function(){return Y.getUA()},Z.ua.set=function(e){Y.setUA(e);var n=Y.getResult();for(var t in n)Z.ua[t]=n[t]}}}("object"==typeof window?window:C)}(ye,ye.exports);var Ee=ye.exports;const Se=()=>{const e=new Ee.UAParser,{name:n,version:t}=e.getBrowser(),{name:i,version:o}=e.getOS(),r=e.getUA(),s=navigator.language,a=navigator.userAgent.includes("Mobi"),l=function(){if(!n||!t)return;if("userAgentData"in navigator)return navigator.userAgentData.brands;return}(),u="unknown";return{browser:{name:null!=n?n:u,version:null!=t?t:u,os:`${null!=i?i:u} ${null!=o?o:u}`,userAgent:null!=r?r:u,language:null!=s?s:u,mobile:a,brands:null!=l?l:u}}},Te=()=>({page:{url:location.href}}),xe=[Se,Te];function ke(n){var t,i,o,r;return{id:null!==(r=null===(o=null===(i=null===(t=e.faro.config)||void 0===t?void 0:t.sessionTracking)||void 0===i?void 0:i.generateSessionId)||void 0===o?void 0:o.call(i))&&void 0!==r?r:A(),attributes:n}}const Ie={name:"default"},Oe="sessionStorage",Le="localStorage";function Ae(n){var t;try{let e;e=window[n];const t="__faro_storage_test__";return e.setItem(t,t),e.removeItem(t),!0}catch(i){return null===(t=e.faro.internalLogger)||void 0===t||t.info(`Web storage of type ${n} is not available. Reason: ${i}`),!1}}function Ne(e,n){return Me(n)?window[n].getItem(e):null}function Ce(e,n,t){if(Me(t))try{window[t].setItem(e,n)}catch(e){}}function je(e,n){Me(n)&&window[n].removeItem(e)}const Re=Ae(Le),_e=Ae(Oe);function Me(e){return e===Le?Re:e===Oe&&_e}function De(e,n){let t,i=!1;const o=()=>{null!=t?(e(...t),t=null,setTimeout(o,n)):i=!1};return(...r)=>{i?t=r:(e(...r),i=!0,setTimeout(o,n))}}function Ue(){var n,t,i;const o=e.faro.config.sessionTracking;let r=null!==(i=null!==(t=null===(n=null==o?void 0:o.sampler)||void 0===n?void 0:n.call(o,{metas:e.faro.metas.value}))&&void 0!==t?t:null==o?void 0:o.samplingRate)&&void 0!==i?i:1;if("number"!=typeof r){r=0}return Math.random()<r}const Pe="__FARO_SESSION__",Be=144e5,ze=9e5,Fe=96e4,Ve={enabled:!0,persistent:!1,maxSessionPersistenceTime:Fe};function $e({sessionId:n,isSampled:t=!0}={}){var i,o;const r=N(),s=null===(o=null===(i=e.faro.config)||void 0===i?void 0:i.sessionTracking)||void 0===o?void 0:o.generateSessionId;return null==n&&(n="function"==typeof s?s():A()),{sessionId:n,lastActivity:r,started:r,isSampled:t}}function Ge(e){if(null==e)return!1;const n=N();if(!(n-e.started<Be))return!1;return n-e.lastActivity<ze}function qe({fetchUserSession:n,storeUserSession:t}){return function(){var i,o,r,s;if(!n||!t)return;const a=n();if(Ge(a))t(Object.assign(Object.assign({},a),{lastActivity:N()}));else{let n=We($e({isSampled:Ue()}),a);t(n),null===(i=e.faro.api)||void 0===i||i.setSession(n.sessionMeta),null===(r=null===(o=e.faro.config.sessionTracking)||void 0===o?void 0:o.onSessionChange)||void 0===r||r.call(o,null!==(s=null==a?void 0:a.sessionMeta)&&void 0!==s?s:null,n.sessionMeta)}}}function We(n,t){var i,o,r,s;return Object.assign(Object.assign({},n),{sessionMeta:{id:n.sessionId,attributes:Object.assign(Object.assign(Object.assign(Object.assign({},null===(o=null===(i=e.faro.config.sessionTracking)||void 0===i?void 0:i.session)||void 0===o?void 0:o.attributes),null!==(s=null===(r=e.faro.metas.value.session)||void 0===r?void 0:r.attributes)&&void 0!==s?s:{}),null!=t?{previousSession:t.sessionId}:{}),{isSampled:n.isSampled.toString()})}})}class He{constructor(){this.updateSession=De((()=>this.updateUserSession()),1e3),this.updateUserSession=qe({fetchUserSession:He.fetchUserSession,storeUserSession:He.storeUserSession}),this.init()}static removeUserSession(){je(Pe,He.storageTypeLocal)}static storeUserSession(e){Ce(Pe,JSON.stringify(e),He.storageTypeLocal)}static fetchUserSession(){const e=Ne(Pe,He.storageTypeLocal);return e?JSON.parse(e):null}init(){document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&this.updateSession()})),e.faro.metas.addListener((function(n){const t=n.session,i=He.fetchUserSession();if(t&&t.id!==(null==i?void 0:i.sessionId)){const n=We($e({sessionId:t.id,isSampled:Ue()}),i);He.storeUserSession(n),e.faro.api.setSession(n.sessionMeta)}}))}}He.storageTypeLocal=Le;class Ke{constructor(){this.updateSession=De((()=>this.updateUserSession()),1e3),this.updateUserSession=qe({fetchUserSession:Ke.fetchUserSession,storeUserSession:Ke.storeUserSession}),this.init()}static removeUserSession(){je(Pe,Ke.storageTypeSession)}static storeUserSession(e){Ce(Pe,JSON.stringify(e),Ke.storageTypeSession)}static fetchUserSession(){const e=Ne(Pe,Ke.storageTypeSession);return e?JSON.parse(e):null}init(){document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&this.updateSession()})),e.faro.metas.addListener((function(n){const t=n.session,i=Ke.fetchUserSession();if(t&&t.id!==(null==i?void 0:i.sessionId)){const n=We($e({sessionId:t.id,isSampled:Ue()}),i);Ke.storeUserSession(n),e.faro.api.setSession(n.sessionMeta)}}))}}Ke.storageTypeSession=Oe;class Xe extends ae{constructor(){super(...arguments),this.name="@grafana/faro-web-sdk:instrumentation-session",this.version=le}sendSessionStartEvent(e){var n,t;const i=e.session;if(i&&i.id!==(null===(n=this.notifiedSession)||void 0===n?void 0:n.id)){if(this.notifiedSession&&this.notifiedSession.id===(null===(t=i.attributes)||void 0===t?void 0:t.previousSession))return this.api.pushEvent(we,{},void 0,{skipDedupe:!0}),void(this.notifiedSession=i);this.notifiedSession=i,this.api.pushEvent(me,{},void 0,{skipDedupe:!0})}}createInitialSessionMeta(e){var n,t,i;let o=(e.persistent?He:Ke).fetchUserSession();if(e.persistent&&e.maxSessionPersistenceTime&&o){const n=N();o.lastActivity<n-e.maxSessionPersistenceTime&&(He.removeUserSession(),o=null)}let r,s=null===(n=e.session)||void 0===n?void 0:n.id,a=null===(t=e.session)||void 0===t?void 0:t.attributes;Ge(o)?(s=null==o?void 0:o.sessionId,a=Object.assign(Object.assign(Object.assign({},a),null===(i=null==o?void 0:o.sessionMeta)||void 0===i?void 0:i.attributes),{isSampled:(o.isSampled||!1).toString()}),r=he):(s=null!=s?s:ke().id,r=me);return{sessionMeta:{id:s,attributes:Object.assign({isSampled:Ue().toString()},a)},lifecycleType:r}}registerBeforeSendHook(e){var n;const{updateSession:t}=new e;null===(n=this.transports)||void 0===n||n.addBeforeSendHooks((e=>{var n,i,o;t();const r=null===(n=e.meta.session)||void 0===n?void 0:n.attributes;if(r&&"true"===(null==r?void 0:r.isSampled)){let n;n="structuredClone"in window?structuredClone(e):JSON.parse(JSON.stringify(e));const t=null===(i=n.meta.session)||void 0===i?void 0:i.attributes;return null==t||delete t.isSampled,0===Object.keys(null!=t?t:{}).length&&(null===(o=n.meta.session)||void 0===o||delete o.attributes),n}return null}))}initialize(){var e,n;this.logDebug("init session instrumentation");const t=this.config.sessionTracking;if(null==t?void 0:t.enabled){const i=(null===(e=this.config.sessionTracking)||void 0===e?void 0:e.persistent)?He:Ke;this.registerBeforeSendHook(i);const{sessionMeta:o,lifecycleType:r}=this.createInitialSessionMeta(t);i.storeUserSession(Object.assign(Object.assign({},$e({sessionId:o.id,isSampled:"true"===(null===(n=o.attributes)||void 0===n?void 0:n.isSampled)})),{sessionMeta:o})),this.notifiedSession=o,this.api.setSession(o),r===me&&this.api.pushEvent(me,{},void 0,{skipDedupe:!0}),r===he&&this.api.pushEvent(he,{},void 0,{skipDedupe:!0})}this.metas.addListener(this.sendSessionStartEvent.bind(this))}}class Je extends ae{constructor(e={}){super(),this.options=e,this.name="@grafana/faro-web-sdk:instrumentation-console",this.version=le}initialize(){this.logDebug("Initializing\n",this.options),k.filter((e=>{var n;return!(null!==(n=this.options.disabledLevels)&&void 0!==n?n:Je.defaultDisabledLevels).includes(e)})).forEach((e=>{console[e]=(...n)=>{try{this.api.pushLog(n,{level:e})}catch(e){this.logError(e)}finally{this.unpatchedConsole[e](...n)}}}))}}Je.defaultDisabledLevels=[e.LogLevel.DEBUG,e.LogLevel.TRACE,e.LogLevel.LOG];const Ze=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,Ye=/^\s*at (?:(.*\).*?|.*?) ?\((?:address at )?)?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Qe=/\((\S*)(?::(\d+))(?::(\d+))\)/,en="address at ",nn=en.length,tn=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|safari-extension|safari-web-extension|capacitor)?:\/.*?|\[native code]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,on=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,rn="safari-extension",sn="safari-web-extension",an=/Minified React error #\d+;/i;function ln(e,n,t,i){const o={filename:e||document.location.href,function:n||"?"};return void 0!==t&&(o.lineno=t),void 0!==i&&(o.colno=i),o}function un(e,n){const t=null==e?void 0:e.includes(rn),i=!t&&(null==e?void 0:e.includes(sn));return t||i?[(null==e?void 0:e.includes("@"))?e.split("@")[0]:e,t?`${rn}:${n}`:`${sn}:${n}`]:[e,n]}function cn(e){let n=[];e.stacktrace?n=e.stacktrace.split("\n").filter(((e,n)=>n%2==0)):e.stack&&(n=e.stack.split("\n"));const t=n.reduce(((n,t,i)=>{let o,r,s,l,u;if(o=Ye.exec(t)){if(r=o[1],s=o[2],l=o[3],u=o[4],null==s?void 0:s.startsWith("eval")){const e=Qe.exec(s);e&&(s=e[1],l=e[2],u=e[3])}s=(null==s?void 0:s.startsWith(en))?s.substring(nn):s,[r,s]=un(r,s)}else if(o=tn.exec(t)){if(r=o[1],s=o[3],l=o[4],u=o[5],s&&s.includes(" > eval")){const e=on.exec(s);e&&(r=r||"eval",s=e[1],l=e[2])}else 0===i&&!u&&a(e.columnNumber)&&(u=String(e.columnNumber+1));[r,s]=un(r,s)}return(s||r)&&n.push(ln(s,r,l?Number(l):void 0,u?Number(u):void 0)),n}),[]);return an.test(e.message)?t.slice(1):t}function dn(e){return{frames:cn(e)}}function pn(e){let n,t,i,o,r=[];if(b(e)&&e.error)n=e.error.message,t=e.error.name,r=cn(e.error);else if((i=m(e))||h(e)){const{name:o,message:r}=e;t=null!=o?o:i?"DOMError":"DOMException",n=r?`${t}: ${r}`:t}else v(e)?(n=e.message,r=cn(e)):(l(e)||(o=f(e)))&&(t=o?e.constructor.name:void 0,n=`Non-Error exception captured with keys: ${Object.keys(e)}`);return[n,t,r]}function fn(e){const n=window.onerror;window.onerror=(...t)=>{try{const[i,o,r,a,l]=t;let u,c,d=[];const p=s(i),f=ln(o,"?",r,a);l||!p?([u,c,d]=pn(null!=l?l:i),0===d.length&&(d=[f])):p&&([u,c]=function(e){var n,t;const i=e.match(Ze),o=null!==(n=null==i?void 0:i[1])&&void 0!==n?n:ie;return[null!==(t=null==i?void 0:i[2])&&void 0!==t?t:e,o]}(i),d=[f]),u&&e.pushError(new Error(u),{type:c,stackFrames:d})}finally{null==n||n.apply(window,t)}}}class gn extends ae{constructor(){super(...arguments),this.name="@grafana/faro-web-sdk:instrumentation-errors",this.version=le}initialize(){var e;this.logDebug("Initializing"),fn(this.api),e=this.api,window.addEventListener("unhandledrejection",(n=>{var t,i;let o,r,s=n;s.reason?s=n.reason:(null===(t=n.detail)||void 0===t?void 0:t.reason)&&(s=null===(i=n.detail)||void 0===i?void 0:i.reason);let a=[];d(s)?(o=`Non-Error promise rejection captured with value: ${String(s)}`,r="UnhandledRejection"):[o,r,a]=pn(s),o&&e.pushError(new Error(o),{type:r,stackFrames:a})}))}}class vn extends ae{constructor(){super(...arguments),this.name="@grafana/faro-web-sdk:instrumentation-view",this.version=le}sendViewChangedEvent(e){var n,t,i;const o=e.view;o&&o.name!==(null===(n=this.notifiedView)||void 0===n?void 0:n.name)&&(this.api.pushEvent(be,{fromView:null!==(i=null===(t=this.notifiedView)||void 0===t?void 0:t.name)&&void 0!==i?i:"",toView:o.name},void 0,{skipDedupe:!0}),this.notifiedView=o)}initialize(){this.sendViewChangedEvent(this.metas.value),this.metas.addListener(this.sendViewChangedEvent.bind(this))}}var bn,mn,hn,wn,yn,En=-1,Sn=function(e){addEventListener("pageshow",(function(n){n.persisted&&(En=n.timeStamp,e(n))}),!0)},Tn=function(){return window.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0]},xn=function(){var e=Tn();return e&&e.activationStart||0},kn=function(e,n){var t=Tn(),i="navigate";return En>=0?i="back-forward-cache":t&&(document.prerendering||xn()>0?i="prerender":document.wasDiscarded?i="restore":t.type&&(i=t.type.replace(/_/g,"-"))),{name:e,value:void 0===n?-1:n,rating:"good",delta:0,entries:[],id:"v3-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:i}},In=function(e,n,t){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){var i=new PerformanceObserver((function(e){Promise.resolve().then((function(){n(e.getEntries())}))}));return i.observe(Object.assign({type:e,buffered:!0},t||{})),i}}catch(e){}},On=function(e,n,t,i){var o,r;return function(s){n.value>=0&&(s||i)&&((r=n.value-(o||0))||void 0===o)&&(o=n.value,n.delta=r,n.rating=function(e,n){return e>n[1]?"poor":e>n[0]?"needs-improvement":"good"}(n.value,t),e(n))}},Ln=function(e){requestAnimationFrame((function(){return requestAnimationFrame((function(){return e()}))}))},An=function(e){var n=function(n){"pagehide"!==n.type&&"hidden"!==document.visibilityState||e(n)};addEventListener("visibilitychange",n,!0),addEventListener("pagehide",n,!0)},Nn=function(e){var n=!1;return function(t){n||(e(t),n=!0)}},Cn=-1,jn=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},Rn=function(e){"hidden"===document.visibilityState&&Cn>-1&&(Cn="visibilitychange"===e.type?e.timeStamp:0,Mn())},_n=function(){addEventListener("visibilitychange",Rn,!0),addEventListener("prerenderingchange",Rn,!0)},Mn=function(){removeEventListener("visibilitychange",Rn,!0),removeEventListener("prerenderingchange",Rn,!0)},Dn=function(){return Cn<0&&(Cn=jn(),_n(),Sn((function(){setTimeout((function(){Cn=jn(),_n()}),0)}))),{get firstHiddenTime(){return Cn}}},Un=function(e){document.prerendering?addEventListener("prerenderingchange",(function(){return e()}),!0):e()},Pn=[1800,3e3],Bn=function(e,n){n=n||{},Un((function(){var t,i=Dn(),o=kn("FCP"),r=In("paint",(function(e){e.forEach((function(e){"first-contentful-paint"===e.name&&(r.disconnect(),e.startTime<i.firstHiddenTime&&(o.value=Math.max(e.startTime-xn(),0),o.entries.push(e),t(!0)))}))}));r&&(t=On(e,o,Pn,n.reportAllChanges),Sn((function(i){o=kn("FCP"),t=On(e,o,Pn,n.reportAllChanges),Ln((function(){o.value=performance.now()-i.timeStamp,t(!0)}))})))}))},zn=[.1,.25],Fn={passive:!0,capture:!0},Vn=new Date,$n=function(e,n){bn||(bn=n,mn=e,hn=new Date,Wn(removeEventListener),Gn())},Gn=function(){if(mn>=0&&mn<hn-Vn){var e={entryType:"first-input",name:bn.type,target:bn.target,cancelable:bn.cancelable,startTime:bn.timeStamp,processingStart:bn.timeStamp+mn};wn.forEach((function(n){n(e)})),wn=[]}},qn=function(e){if(e.cancelable){var n=(e.timeStamp>1e12?new Date:performance.now())-e.timeStamp;"pointerdown"==e.type?function(e,n){var t=function(){$n(e,n),o()},i=function(){o()},o=function(){removeEventListener("pointerup",t,Fn),removeEventListener("pointercancel",i,Fn)};addEventListener("pointerup",t,Fn),addEventListener("pointercancel",i,Fn)}(n,e):$n(n,e)}},Wn=function(e){["mousedown","keydown","touchstart","pointerdown"].forEach((function(n){return e(n,qn,Fn)}))},Hn=[100,300],Kn=0,Xn=1/0,Jn=0,Zn=function(e){e.forEach((function(e){e.interactionId&&(Xn=Math.min(Xn,e.interactionId),Jn=Math.max(Jn,e.interactionId),Kn=Jn?(Jn-Xn)/7+1:0)}))},Yn=function(){return yn?Kn:performance.interactionCount||0},Qn=function(){"interactionCount"in performance||yn||(yn=In("event",Zn,{type:"event",buffered:!0,durationThreshold:0}))},et=[200,500],nt=0,tt=function(){return Yn()-nt},it=[],ot={},rt=function(e){var n=it[it.length-1],t=ot[e.interactionId];if(t||it.length<10||e.duration>n.latency){if(t)t.entries.push(e),t.latency=Math.max(t.latency,e.duration);else{var i={id:e.interactionId,latency:e.duration,entries:[e]};ot[i.id]=i,it.push(i)}it.sort((function(e,n){return n.latency-e.latency})),it.splice(10).forEach((function(e){delete ot[e.id]}))}},st=[2500,4e3],at={},lt=[800,1800],ut=function e(n){document.prerendering?Un((function(){return e(n)})):"complete"!==document.readyState?addEventListener("load",(function(){return e(n)}),!0):setTimeout(n,0)};class ct extends ae{constructor(){super(...arguments),this.name="@grafana/faro-web-sdk:instrumentation-web-vitals",this.version=le}initialize(){this.logDebug("Initializing"),Object.entries(ct.mapping).forEach((([e,n])=>{n((n=>{this.api.pushMeasurement({type:"web-vitals",values:{[e]:n.value}})}))}))}}function dt(e={}){const n=[new gn,new ct,new Xe,new vn];return!1!==e.captureConsole&&n.push(new Je({disabledLevels:e.captureConsoleDisabledLevels})),n}ct.mapping={cls:function(e,n){n=n||{},Bn(Nn((function(){var t,i=kn("CLS",0),o=0,r=[],s=function(e){e.forEach((function(e){if(!e.hadRecentInput){var n=r[0],t=r[r.length-1];o&&e.startTime-t.startTime<1e3&&e.startTime-n.startTime<5e3?(o+=e.value,r.push(e)):(o=e.value,r=[e])}})),o>i.value&&(i.value=o,i.entries=r,t())},a=In("layout-shift",s);a&&(t=On(e,i,zn,n.reportAllChanges),An((function(){s(a.takeRecords()),t(!0)})),Sn((function(){o=0,i=kn("CLS",0),t=On(e,i,zn,n.reportAllChanges),Ln((function(){return t()}))})),setTimeout(t,0))})))},fcp:Bn,fid:function(e,n){n=n||{},Un((function(){var t,i=Dn(),o=kn("FID"),r=function(e){e.startTime<i.firstHiddenTime&&(o.value=e.processingStart-e.startTime,o.entries.push(e),t(!0))},s=function(e){e.forEach(r)},a=In("first-input",s);t=On(e,o,Hn,n.reportAllChanges),a&&An(Nn((function(){s(a.takeRecords()),a.disconnect()}))),a&&Sn((function(){var i;o=kn("FID"),t=On(e,o,Hn,n.reportAllChanges),wn=[],mn=-1,bn=null,Wn(addEventListener),i=r,wn.push(i),Gn()}))}))},inp:function(e,n){n=n||{},Un((function(){var t;Qn();var i,o=kn("INP"),r=function(e){e.forEach((function(e){e.interactionId&&rt(e),"first-input"===e.entryType&&!it.some((function(n){return n.entries.some((function(n){return e.duration===n.duration&&e.startTime===n.startTime}))}))&&rt(e)}));var n,t=(n=Math.min(it.length-1,Math.floor(tt()/50)),it[n]);t&&t.latency!==o.value&&(o.value=t.latency,o.entries=t.entries,i())},s=In("event",r,{durationThreshold:null!==(t=n.durationThreshold)&&void 0!==t?t:40});i=On(e,o,et,n.reportAllChanges),s&&("interactionId"in PerformanceEventTiming.prototype&&s.observe({type:"first-input",buffered:!0}),An((function(){r(s.takeRecords()),o.value<0&&tt()>0&&(o.value=0,o.entries=[]),i(!0)})),Sn((function(){it=[],nt=Yn(),o=kn("INP"),i=On(e,o,et,n.reportAllChanges)})))}))},lcp:function(e,n){n=n||{},Un((function(){var t,i=Dn(),o=kn("LCP"),r=function(e){var n=e[e.length-1];n&&n.startTime<i.firstHiddenTime&&(o.value=Math.max(n.startTime-xn(),0),o.entries=[n],t())},s=In("largest-contentful-paint",r);if(s){t=On(e,o,st,n.reportAllChanges);var a=Nn((function(){at[o.id]||(r(s.takeRecords()),s.disconnect(),at[o.id]=!0,t(!0))}));["keydown","click"].forEach((function(e){addEventListener(e,(function(){return setTimeout(a,0)}),!0)})),An(a),Sn((function(i){o=kn("LCP"),t=On(e,o,st,n.reportAllChanges),Ln((function(){o.value=performance.now()-i.timeStamp,at[o.id]=!0,t(!0)}))}))}}))},ttfb:function(e,n){n=n||{};var t=kn("TTFB"),i=On(e,t,lt,n.reportAllChanges);ut((function(){var o=Tn();if(o){var r=o.responseStart;if(r<=0||r>performance.now())return;t.value=Math.max(r-xn(),0),t.entries=[o],i(!0),Sn((function(){t=kn("TTFB",0),(i=On(e,t,lt,n.reportAllChanges))(!0)}))}}))}};const pt="browser",ft=()=>({k6:{isK6Browser:!0}});function gt(e,n,t,i){return new(t||(t=Promise))((function(o,r){function s(e){try{l(i.next(e))}catch(e){r(e)}}function a(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(s,a)}l((i=i.apply(e,n||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class vt extends ee{constructor(e){var n,t,i,o;super(),this.options=e,this.name="@grafana/faro-web-sdk:transport-fetch",this.version=le,this.disabledUntil=new Date,this.rateLimitBackoffMs=null!==(n=e.defaultRateLimitBackoffMs)&&void 0!==n?n:5e3,this.getNow=null!==(t=e.getNow)&&void 0!==t?t:()=>Date.now(),this.promiseBuffer=O({size:null!==(i=e.bufferSize)&&void 0!==i?i:30,concurrency:null!==(o=e.concurrency)&&void 0!==o?o:5})}send(e){return gt(this,void 0,void 0,(function*(){try{if(this.disabledUntil>new Date(this.getNow()))return this.logWarn(`Dropping transport item due to too many requests. Backoff until ${this.disabledUntil}`),Promise.resolve();yield this.promiseBuffer.add((()=>{var n;const t=JSON.stringify(te(e)),{url:i,requestOptions:o,apiKey:r}=this.options,s=null!=o?o:{},{headers:a}=s,l=function(e,n){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&n.indexOf(i)<0&&(t[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)n.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(t[i[o]]=e[i[o]])}return t}(s,["headers"]),u=null===(n=this.metas.value.session)||void 0===n?void 0:n.id;return fetch(i,Object.assign({method:"POST",headers:Object.assign(Object.assign(Object.assign({"Content-Type":"application/json"},null!=a?a:{}),r?{"x-api-key":r}:{}),u?{"x-faro-session-id":u}:{}),body:t,keepalive:t.length<=6e4},null!=l?l:{})).then((e=>(429===e.status&&(this.disabledUntil=this.getRetryAfterDate(e),this.logWarn(`Too many requests, backing off until ${this.disabledUntil}`)),e.text().catch(I),e))).catch((e=>{this.logError("Failed sending payload to the receiver\n",JSON.parse(t),e)}))}))}catch(e){this.logError(e)}}))}getIgnoreUrls(){return[this.options.url]}isBatched(){return!0}getRetryAfterDate(e){const n=this.getNow(),t=e.headers.get("Retry-After");if(t){const e=Number(t);if(!isNaN(e))return new Date(1e3*e+n);const i=Date.parse(t);if(!isNaN(i))return new Date(i)}return new Date(n+this.rateLimitBackoffMs)}}function bt(e){var n,t,i,o,r,s,a,u,c;const d=[],p=J(e.unpatchedConsole,e.internalLoggerLevel);e.transports?((e.url||e.apiKey)&&p.error('if "transports" is defined, "url" and "apiKey" should not be defined'),d.push(...e.transports)):e.url?d.push(new vt({url:e.url,apiKey:e.apiKey})):p.error('either "url" or "transports" must be defined');return{app:e.app,batching:Object.assign(Object.assign({},ve),e.batching),dedupe:null===(n=e.dedupe)||void 0===n||n,globalObjectKey:e.globalObjectKey||ge,instrumentations:null!==(t=e.instrumentations)&&void 0!==t?t:dt(),internalLoggerLevel:null!==(i=e.internalLoggerLevel)&&void 0!==i?i:W,isolate:null!==(o=e.isolate)&&void 0!==o&&o,metas:function(){const n=xe;return e.metas&&n.push(...e.metas),l(window.k6)?[...n,ft]:n}(),parseStacktrace:dn,paused:null!==(r=e.paused)&&void 0!==r&&r,preventGlobalExposure:null!==(s=e.preventGlobalExposure)&&void 0!==s&&s,transports:d,unpatchedConsole:null!==(a=e.unpatchedConsole)&&void 0!==a?a:H,beforeSend:e.beforeSend,eventDomain:null!==(u=e.eventDomain)&&void 0!==u?u:pt,ignoreErrors:e.ignoreErrors,sessionTracking:Object.assign(Object.assign({},Ve),e.sessionTracking),user:e.user,view:null!==(c=e.view)&&void 0!==c?c:Ie}}return e.BaseExtension=Q,e.BaseInstrumentation=ae,e.BaseTransport=ee,e.ConsoleInstrumentation=Je,e.ConsoleTransport=class extends ee{constructor(e={}){super(),this.options=e,this.name="@grafana/faro-web-sdk:transport-console",this.version=le}send(n){var t;return this.unpatchedConsole[null!==(t=this.options.level)&&void 0!==t?t:e.LogLevel.DEBUG]("New event",te([n]))}},e.Conventions={EventNames:{CLICK:"click",NAVIGATION:"navigation",SESSION_START:"session_start",VIEW_CHANGED:"view_changed"}},e.EVENT_CLICK="click",e.EVENT_NAVIGATION="navigation",e.EVENT_ROUTE_CHANGE="route_change",e.EVENT_SESSION_EXTEND=we,e.EVENT_SESSION_RESUME=he,e.EVENT_SESSION_START=me,e.EVENT_VIEW_CHANGED=be,e.ErrorsInstrumentation=gn,e.FetchTransport=vt,e.MAX_SESSION_PERSISTENCE_TIME=Fe,e.MAX_SESSION_PERSISTENCE_TIME_BUFFER=6e4,e.PersistentSessionsManager=He,e.SESSION_EXPIRATION_TIME=Be,e.SESSION_INACTIVITY_TIME=ze,e.STORAGE_KEY=Pe,e.SessionInstrumentation=Xe,e.VERSION=le,e.ViewInstrumentation=vn,e.VolatileSessionsManager=Ke,e.WebVitalsInstrumentation=ct,e.allLogLevels=k,e.browserMeta=Se,e.buildStackFrame=ln,e.createInternalLogger=J,e.createPromiseBuffer=O,e.createSession=ke,e.deepEqual=E,e.defaultEventDomain=pt,e.defaultExceptionType=ie,e.defaultGlobalObjectKey=ge,e.defaultInternalLoggerLevel=W,e.defaultLogLevel=x,e.defaultMetas=xe,e.defaultViewMeta=Ie,e.genShortID=A,e.getCurrentTimestamp=S,e.getDataFromSafariExtensions=un,e.getInternalFaroFromGlobalObject=function(){return se[ue]},e.getStackFramesFromError=cn,e.getTransportBody=te,e.getWebInstrumentations=dt,e.globalObject=se,e.initializeFaro=function(e){const n=bt(e);if(n)return fe(n)},e.internalGlobalObjectKey=ue,e.isArray=c,e.isBoolean=e=>n(e,"boolean"),e.isDomError=m,e.isDomException=h,e.isElement=e=>w&&i(e,Element),e.isElementDefined=w,e.isError=v,e.isErrorDefined=g,e.isErrorEvent=b,e.isEvent=f,e.isEventDefined=p,e.isFunction=u,e.isInstanceOf=i,e.isInt=e=>a(e)&&Number.isInteger(e),e.isInternalFaroOnGlobalObject=de,e.isMap=e=>y&&i(e,Map),e.isMapDefined=y,e.isNull=r,e.isNumber=a,e.isObject=l,e.isPrimitive=d,e.isRegExp=e=>t(e,"RegExp"),e.isString=s,e.isSymbol=e=>n(e,"symbol"),e.isSyntheticEvent=e=>l(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e,e.isThenable=e=>u(null==e?void 0:e.then),e.isToString=t,e.isTypeof=n,e.isUndefined=o,e.makeCoreConfig=bt,e.noop=I,e.pageMeta=Te,e.parseStacktrace=dn,e.sdkMeta=()=>({sdk:{name:"@grafana/faro-core",version:le,integrations:e.faro.config.instrumentations.map((({name:e,version:n})=>({name:e,version:n})))}}),e.setInternalFaroOnGlobalObject=ce,e.transportItemTypeToBodyKey=F,e}({});
|
|
@@ -3,7 +3,7 @@ import type { ConsoleInstrumentationOptions } from './types';
|
|
|
3
3
|
export declare class ConsoleInstrumentation extends BaseInstrumentation {
|
|
4
4
|
private options;
|
|
5
5
|
readonly name = "@grafana/faro-web-sdk:instrumentation-console";
|
|
6
|
-
readonly version = "1.3.
|
|
6
|
+
readonly version = "1.3.5";
|
|
7
7
|
static defaultDisabledLevels: LogLevel[];
|
|
8
8
|
constructor(options?: ConsoleInstrumentationOptions);
|
|
9
9
|
initialize(): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseInstrumentation } from '@grafana/faro-core';
|
|
2
2
|
export declare class ErrorsInstrumentation extends BaseInstrumentation {
|
|
3
3
|
readonly name = "@grafana/faro-web-sdk:instrumentation-errors";
|
|
4
|
-
readonly version = "1.3.
|
|
4
|
+
readonly version = "1.3.5";
|
|
5
5
|
initialize(): void;
|
|
6
6
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseInstrumentation } from '@grafana/faro-core';
|
|
2
2
|
export declare class SessionInstrumentation extends BaseInstrumentation {
|
|
3
3
|
readonly name = "@grafana/faro-web-sdk:instrumentation-session";
|
|
4
|
-
readonly version = "1.3.
|
|
4
|
+
readonly version = "1.3.5";
|
|
5
5
|
private notifiedSession;
|
|
6
6
|
private sendSessionStartEvent;
|
|
7
7
|
private createInitialSessionMeta;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseInstrumentation } from '@grafana/faro-core';
|
|
2
2
|
export declare class ViewInstrumentation extends BaseInstrumentation {
|
|
3
3
|
readonly name = "@grafana/faro-web-sdk:instrumentation-view";
|
|
4
|
-
readonly version = "1.3.
|
|
4
|
+
readonly version = "1.3.5";
|
|
5
5
|
private notifiedView;
|
|
6
6
|
private sendViewChangedEvent;
|
|
7
7
|
initialize(): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseInstrumentation } from '@grafana/faro-core';
|
|
2
2
|
export declare class WebVitalsInstrumentation extends BaseInstrumentation {
|
|
3
3
|
readonly name = "@grafana/faro-web-sdk:instrumentation-web-vitals";
|
|
4
|
-
readonly version = "1.3.
|
|
4
|
+
readonly version = "1.3.5";
|
|
5
5
|
static mapping: {
|
|
6
6
|
cls: (onReport: import("web-vitals").CLSReportCallback, opts?: import("web-vitals").ReportOpts | undefined) => void;
|
|
7
7
|
fcp: (onReport: import("web-vitals").FCPReportCallback, opts?: import("web-vitals").ReportOpts | undefined) => void;
|
|
@@ -4,7 +4,7 @@ import type { ConsoleTransportOptions } from './types';
|
|
|
4
4
|
export declare class ConsoleTransport extends BaseTransport {
|
|
5
5
|
private options;
|
|
6
6
|
readonly name = "@grafana/faro-web-sdk:transport-console";
|
|
7
|
-
readonly version = "1.3.
|
|
7
|
+
readonly version = "1.3.5";
|
|
8
8
|
constructor(options?: ConsoleTransportOptions);
|
|
9
9
|
send(item: TransportItem): void;
|
|
10
10
|
}
|
|
@@ -4,7 +4,7 @@ import type { FetchTransportOptions } from './types';
|
|
|
4
4
|
export declare class FetchTransport extends BaseTransport {
|
|
5
5
|
private options;
|
|
6
6
|
readonly name = "@grafana/faro-web-sdk:transport-fetch";
|
|
7
|
-
readonly version = "1.3.
|
|
7
|
+
readonly version = "1.3.5";
|
|
8
8
|
promiseBuffer: PromiseBuffer<Response | void>;
|
|
9
9
|
private readonly rateLimitBackoffMs;
|
|
10
10
|
private readonly getNow;
|
|
@@ -73,7 +73,7 @@ var SessionInstrumentation = /** @class */ (function (_super) {
|
|
|
73
73
|
var lifecycleType;
|
|
74
74
|
if ((0, sessionManagerUtils_1.isUserSessionValid)(userSession)) {
|
|
75
75
|
sessionId = userSession === null || userSession === void 0 ? void 0 : userSession.sessionId;
|
|
76
|
-
sessionAttributes = __assign(__assign({}, (_c = userSession === null || userSession === void 0 ? void 0 : userSession.sessionMeta) === null || _c === void 0 ? void 0 : _c.attributes), { isSampled: userSession.isSampled.toString() });
|
|
76
|
+
sessionAttributes = __assign(__assign(__assign({}, sessionAttributes), (_c = userSession === null || userSession === void 0 ? void 0 : userSession.sessionMeta) === null || _c === void 0 ? void 0 : _c.attributes), { isSampled: (userSession.isSampled || false).toString() });
|
|
77
77
|
lifecycleType = faro_core_1.EVENT_SESSION_RESUME;
|
|
78
78
|
}
|
|
79
79
|
else {
|
|
@@ -123,10 +123,10 @@ var SessionInstrumentation = /** @class */ (function (_super) {
|
|
|
123
123
|
: VolatileSessionManager_1.VolatileSessionsManager;
|
|
124
124
|
this.registerBeforeSendHook(SessionManager);
|
|
125
125
|
var _c = this.createInitialSessionMeta(sessionTracking), initialSessionMeta = _c.sessionMeta, lifecycleType = _c.lifecycleType;
|
|
126
|
-
SessionManager.storeUserSession((0, sessionManagerUtils_1.createUserSessionObject)({
|
|
126
|
+
SessionManager.storeUserSession(__assign(__assign({}, (0, sessionManagerUtils_1.createUserSessionObject)({
|
|
127
127
|
sessionId: initialSessionMeta.id,
|
|
128
128
|
isSampled: ((_b = initialSessionMeta.attributes) === null || _b === void 0 ? void 0 : _b['isSampled']) === 'true',
|
|
129
|
-
}));
|
|
129
|
+
})), { sessionMeta: initialSessionMeta }));
|
|
130
130
|
this.notifiedSession = initialSessionMeta;
|
|
131
131
|
this.api.setSession(initialSessionMeta);
|
|
132
132
|
if (lifecycleType === faro_core_1.EVENT_SESSION_START) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../../../src/instrumentations/session/instrumentation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAS4B;AAI5B,qCAA4C;AAE5C,mDAAmE;AACnE,wFAAuF;AACvF,4EAAmG;AACnG,kFAAkF;AAIlF;IAA4C,0CAAmB;IAA/D;QAAA,
|
|
1
|
+
{"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../../../src/instrumentations/session/instrumentation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAS4B;AAI5B,qCAA4C;AAE5C,mDAAmE;AACnE,wFAAuF;AACvF,4EAAmG;AACnG,kFAAkF;AAIlF;IAA4C,0CAAmB;IAA/D;QAAA,qEAgJC;QA/IU,UAAI,GAAG,+CAA+C,CAAC;QACvD,aAAO,GAAG,mBAAO,CAAC;;IA8I7B,CAAC;IAxIS,sDAAqB,GAA7B,UAA8B,IAAU;;QACtC,IAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAE7B,IAAI,OAAO,IAAI,OAAO,CAAC,EAAE,MAAK,MAAA,IAAI,CAAC,eAAe,0CAAE,EAAE,CAAA,EAAE;YACtD,IAAI,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,eAAe,CAAC,EAAE,MAAK,MAAA,OAAO,CAAC,UAAU,0CAAG,iBAAiB,CAAC,CAAA,EAAE;gBAC/F,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,gCAAoB,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC9E,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC;g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AK,gCAAoB,EAAE;gBAC1C,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,gCAAoB,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;aAC/E;SACF;QAED,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAChE,CAAC;IACH,6BAAC;AAAD,CAAC,AAhJD,CAA4C,+BAAmB,GAgJ9D;AAhJY,wDAAsB","sourcesContent":["import {\n BaseInstrumentation,\n dateNow,\n EVENT_SESSION_EXTEND,\n EVENT_SESSION_RESUME,\n EVENT_SESSION_START,\n Meta,\n MetaSession,\n VERSION,\n} from '@grafana/faro-core';\nimport type { Config } from '@grafana/faro-core';\n\nimport type { TransportItem } from '../..';\nimport { createSession } from '../../metas';\n\nimport { type FaroUserSession, isSampled } from './sessionManager';\nimport { PersistentSessionsManager } from './sessionManager/PersistentSessionsManager';\nimport { createUserSessionObject, isUserSessionValid } from './sessionManager/sessionManagerUtils';\nimport { VolatileSessionsManager } from './sessionManager/VolatileSessionManager';\n\ntype LifecycleType = typeof EVENT_SESSION_RESUME | typeof EVENT_SESSION_START;\n\nexport class SessionInstrumentation extends BaseInstrumentation {\n readonly name = '@grafana/faro-web-sdk:instrumentation-session';\n readonly version = VERSION;\n\n // previously notified session, to ensure we don't send session start\n // event twice for the same session\n private notifiedSession: MetaSession | undefined;\n\n private sendSessionStartEvent(meta: Meta): void {\n const session = meta.session;\n\n if (session && session.id !== this.notifiedSession?.id) {\n if (this.notifiedSession && this.notifiedSession.id === session.attributes?.['previousSession']) {\n this.api.pushEvent(EVENT_SESSION_EXTEND, {}, undefined, { skipDedupe: true });\n this.notifiedSession = session;\n return;\n }\n\n this.notifiedSession = session;\n // no need to add attributes and session id, they are included as part of meta\n // automatically\n this.api.pushEvent(EVENT_SESSION_START, {}, undefined, { skipDedupe: true });\n }\n }\n\n private createInitialSessionMeta(sessionsConfig: Required<Config>['sessionTracking']): {\n sessionMeta: MetaSession;\n lifecycleType: LifecycleType;\n } {\n const sessionManager = sessionsConfig.persistent ? PersistentSessionsManager : VolatileSessionsManager;\n\n let userSession: FaroUserSession | null = sessionManager.fetchUserSession();\n\n if (sessionsConfig.persistent && sessionsConfig.maxSessionPersistenceTime && userSession) {\n const now = dateNow();\n const shouldClearPersistentSession = userSession.lastActivity < now - sessionsConfig.maxSessionPersistenceTime;\n\n if (shouldClearPersistentSession) {\n PersistentSessionsManager.removeUserSession();\n userSession = null;\n }\n }\n\n let sessionId = sessionsConfig.session?.id;\n let sessionAttributes = sessionsConfig.session?.attributes;\n\n let lifecycleType: LifecycleType;\n\n if (isUserSessionValid(userSession)) {\n sessionId = userSession?.sessionId;\n sessionAttributes = {\n ...sessionAttributes,\n ...userSession?.sessionMeta?.attributes,\n isSampled: (userSession!.isSampled || false).toString(),\n };\n\n lifecycleType = EVENT_SESSION_RESUME;\n } else {\n sessionId = sessionId ?? createSession().id;\n lifecycleType = EVENT_SESSION_START;\n }\n\n const sessionMeta: MetaSession = {\n id: sessionId,\n attributes: {\n isSampled: isSampled().toString(),\n // We do not want to recalculate the sampling decision on each init phase.\n // If session from web-storage has a isSampled attribute we will use that instead.\n ...sessionAttributes,\n },\n };\n\n return { sessionMeta, lifecycleType };\n }\n\n private registerBeforeSendHook(SessionManager: typeof VolatileSessionsManager | typeof PersistentSessionsManager) {\n const { updateSession } = new SessionManager();\n\n this.transports?.addBeforeSendHooks((item) => {\n updateSession();\n\n const attributes = item.meta.session?.attributes;\n\n if (attributes && attributes?.['isSampled'] === 'true') {\n let newItem: TransportItem;\n\n // Structured clone is supported in all major browsers\n // but for old browsers we need a fallback\n if ('structuredClone' in window) {\n newItem = structuredClone(item);\n } else {\n newItem = JSON.parse(JSON.stringify(item));\n }\n\n const newAttributes = newItem.meta.session?.attributes;\n delete newAttributes?.['isSampled'];\n\n if (Object.keys(newAttributes ?? {}).length === 0) {\n delete newItem.meta.session?.attributes;\n }\n\n return newItem;\n }\n\n return null;\n });\n }\n\n initialize() {\n this.logDebug('init session instrumentation');\n\n const sessionTracking = this.config.sessionTracking;\n\n if (sessionTracking?.enabled) {\n const SessionManager = this.config.sessionTracking?.persistent\n ? PersistentSessionsManager\n : VolatileSessionsManager;\n\n this.registerBeforeSendHook(SessionManager);\n\n const { sessionMeta: initialSessionMeta, lifecycleType } = this.createInitialSessionMeta(sessionTracking);\n\n SessionManager.storeUserSession({\n ...createUserSessionObject({\n sessionId: initialSessionMeta.id,\n isSampled: initialSessionMeta.attributes?.['isSampled'] === 'true',\n }),\n sessionMeta: initialSessionMeta,\n });\n\n this.notifiedSession = initialSessionMeta;\n this.api.setSession(initialSessionMeta);\n\n if (lifecycleType === EVENT_SESSION_START) {\n this.api.pushEvent(EVENT_SESSION_START, {}, undefined, { skipDedupe: true });\n }\n\n if (lifecycleType === EVENT_SESSION_RESUME) {\n this.api.pushEvent(EVENT_SESSION_RESUME, {}, undefined, { skipDedupe: true });\n }\n }\n\n this.metas.addListener(this.sendSessionStartEvent.bind(this));\n }\n}\n"]}
|
|
@@ -37,17 +37,6 @@ var PersistentSessionsManager = /** @class */ (function () {
|
|
|
37
37
|
_this.updateSession();
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
|
-
window.addEventListener('storage', function (event) {
|
|
41
|
-
var _a, _b, _c;
|
|
42
|
-
if (event.key !== sessionConstants_1.STORAGE_KEY) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
var newSession = JSON.parse((_a = event.newValue) !== null && _a !== void 0 ? _a : '');
|
|
46
|
-
var previousSession = JSON.parse((_b = event.oldValue) !== null && _b !== void 0 ? _b : '');
|
|
47
|
-
if (newSession.sessionId !== previousSession.sessionId) {
|
|
48
|
-
(_c = faro_core_1.faro.api) === null || _c === void 0 ? void 0 : _c.setSession(newSession.sessionMeta);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
40
|
// Users can call the setSession() method, so we need to sync this with the local storage session
|
|
52
41
|
faro_core_1.faro.metas.addListener(function syncSessionIfChangedExternally(meta) {
|
|
53
42
|
var session = meta.session;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersistentSessionsManager.js","sourceRoot":"","sources":["../../../../../src/instrumentations/session/sessionManager/PersistentSessionsManager.ts"],"names":[],"mappings":";;;AAAA,gDAA0C;AAG1C,wCAA0C;AAC1C,wDAAyF;AAEzF,uCAAuC;AACvC,uDAAuE;AACvE,6DAAwH;AAGxH;IAIE;QAAA,iBAOC;QAoBD,kBAAa,GAAG,IAAA,gBAAQ,EAAC,cAAM,OAAA,KAAI,CAAC,iBAAiB,EAAE,EAAxB,CAAwB,EAAE,uCAAoB,CAAC,CAAC;QA1B7E,IAAI,CAAC,iBAAiB,GAAG,IAAA,2CAAqB,EAAC;YAC7C,gBAAgB,EAAE,yBAAyB,CAAC,gBAAgB;YAC5D,gBAAgB,EAAE,yBAAyB,CAAC,gBAAgB;SAC7D,CAAC,CAAC;QAEH,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;IAEM,2CAAiB,GAAxB;QACE,IAAA,uBAAU,EAAC,8BAAW,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,CAAC;IACtE,CAAC;IAEM,0CAAgB,GAAvB,UAAwB,OAAwB;QAC9C,IAAA,oBAAO,EAAC,8BAAW,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,CAAC;IAC5F,CAAC;IAEM,0CAAgB,GAAvB;QACE,IAAM,aAAa,GAAG,IAAA,oBAAO,EAAC,8BAAW,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,CAAC;QAEvF,IAAI,aAAa,EAAE;YACjB,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAoB,CAAC;SACrD;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAIO,wCAAI,GAAZ;QAAA,
|
|
1
|
+
{"version":3,"file":"PersistentSessionsManager.js","sourceRoot":"","sources":["../../../../../src/instrumentations/session/sessionManager/PersistentSessionsManager.ts"],"names":[],"mappings":";;;AAAA,gDAA0C;AAG1C,wCAA0C;AAC1C,wDAAyF;AAEzF,uCAAuC;AACvC,uDAAuE;AACvE,6DAAwH;AAGxH;IAIE;QAAA,iBAOC;QAoBD,kBAAa,GAAG,IAAA,gBAAQ,EAAC,cAAM,OAAA,KAAI,CAAC,iBAAiB,EAAE,EAAxB,CAAwB,EAAE,uCAAoB,CAAC,CAAC;QA1B7E,IAAI,CAAC,iBAAiB,GAAG,IAAA,2CAAqB,EAAC;YAC7C,gBAAgB,EAAE,yBAAyB,CAAC,gBAAgB;YAC5D,gBAAgB,EAAE,yBAAyB,CAAC,gBAAgB;SAC7D,CAAC,CAAC;QAEH,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;IAEM,2CAAiB,GAAxB;QACE,IAAA,uBAAU,EAAC,8BAAW,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,CAAC;IACtE,CAAC;IAEM,0CAAgB,GAAvB,UAAwB,OAAwB;QAC9C,IAAA,oBAAO,EAAC,8BAAW,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,CAAC;IAC5F,CAAC;IAEM,0CAAgB,GAAvB;QACE,IAAM,aAAa,GAAG,IAAA,oBAAO,EAAC,8BAAW,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,CAAC;QAEvF,IAAI,aAAa,EAAE;YACjB,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAoB,CAAC;SACrD;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAIO,wCAAI,GAAZ;QAAA,iBAsBC;QArBC,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE;YAC5C,IAAI,QAAQ,CAAC,eAAe,KAAK,SAAS,EAAE;gBAC1C,KAAI,CAAC,aAAa,EAAE,CAAC;aACtB;QACH,CAAC,CAAC,CAAC;QAEH,iGAAiG;QACjG,gBAAI,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,8BAA8B,CAAC,IAAU;YACvE,IAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;YAC7B,IAAM,uBAAuB,GAAG,yBAAyB,CAAC,gBAAgB,EAAE,CAAC;YAE7E,IAAI,OAAO,IAAI,OAAO,CAAC,EAAE,MAAK,uBAAuB,aAAvB,uBAAuB,uBAAvB,uBAAuB,CAAE,SAAS,CAAA,EAAE;gBAChE,IAAM,WAAW,GAAG,IAAA,qDAA+B,EACjD,IAAA,6CAAuB,EAAC,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,EAAE,SAAS,EAAE,IAAA,oBAAS,GAAE,EAAE,CAAC,EAC1E,uBAAuB,CACxB,CAAC;gBAEF,yBAAyB,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;gBACxD,gBAAI,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;aAC9C;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAtDc,0CAAgB,GAAG,2BAAc,CAAC,KAAK,CAAC;IAuDzD,gCAAC;CAAA,AAxDD,IAwDC;AAxDY,8DAAyB","sourcesContent":["import { faro } from '@grafana/faro-core';\nimport type { Meta } from '@grafana/faro-core';\n\nimport { throttle } from '../../../utils';\nimport { getItem, removeItem, setItem, webStorageType } from '../../../utils/webStorage';\n\nimport { isSampled } from './sampling';\nimport { STORAGE_KEY, STORAGE_UPDATE_DELAY } from './sessionConstants';\nimport { addSessionMetadataToNextSession, createUserSessionObject, getUserSessionUpdater } from './sessionManagerUtils';\nimport type { FaroUserSession } from './types';\n\nexport class PersistentSessionsManager {\n private static storageTypeLocal = webStorageType.local;\n private updateUserSession: ReturnType<typeof getUserSessionUpdater>;\n\n constructor() {\n this.updateUserSession = getUserSessionUpdater({\n fetchUserSession: PersistentSessionsManager.fetchUserSession,\n storeUserSession: PersistentSessionsManager.storeUserSession,\n });\n\n this.init();\n }\n\n static removeUserSession() {\n removeItem(STORAGE_KEY, PersistentSessionsManager.storageTypeLocal);\n }\n\n static storeUserSession(session: FaroUserSession): void {\n setItem(STORAGE_KEY, JSON.stringify(session), PersistentSessionsManager.storageTypeLocal);\n }\n\n static fetchUserSession(): FaroUserSession | null {\n const storedSession = getItem(STORAGE_KEY, PersistentSessionsManager.storageTypeLocal);\n\n if (storedSession) {\n return JSON.parse(storedSession) as FaroUserSession;\n }\n\n return null;\n }\n\n updateSession = throttle(() => this.updateUserSession(), STORAGE_UPDATE_DELAY);\n\n private init(): void {\n document.addEventListener('visibilitychange', () => {\n if (document.visibilityState === 'visible') {\n this.updateSession();\n }\n });\n\n // Users can call the setSession() method, so we need to sync this with the local storage session\n faro.metas.addListener(function syncSessionIfChangedExternally(meta: Meta) {\n const session = meta.session;\n const sessionFromLocalStorage = PersistentSessionsManager.fetchUserSession();\n\n if (session && session.id !== sessionFromLocalStorage?.sessionId) {\n const userSession = addSessionMetadataToNextSession(\n createUserSessionObject({ sessionId: session.id, isSampled: isSampled() }),\n sessionFromLocalStorage\n );\n\n PersistentSessionsManager.storeUserSession(userSession);\n faro.api.setSession(userSession.sessionMeta);\n }\n });\n }\n}\n"]}
|
|
@@ -16,8 +16,13 @@ var faro_core_1 = require("@grafana/faro-core");
|
|
|
16
16
|
var sampling_1 = require("./sampling");
|
|
17
17
|
var sessionConstants_1 = require("./sessionConstants");
|
|
18
18
|
function createUserSessionObject(_a) {
|
|
19
|
-
var _b
|
|
19
|
+
var _b, _c;
|
|
20
|
+
var _d = _a === void 0 ? {} : _a, sessionId = _d.sessionId, _e = _d.isSampled, isSampled = _e === void 0 ? true : _e;
|
|
20
21
|
var now = (0, faro_core_1.dateNow)();
|
|
22
|
+
var generateSessionId = (_c = (_b = faro_core_1.faro.config) === null || _b === void 0 ? void 0 : _b.sessionTracking) === null || _c === void 0 ? void 0 : _c.generateSessionId;
|
|
23
|
+
if (sessionId == null) {
|
|
24
|
+
sessionId = typeof generateSessionId === 'function' ? generateSessionId() : (0, faro_core_1.genShortID)();
|
|
25
|
+
}
|
|
21
26
|
return {
|
|
22
27
|
sessionId: sessionId,
|
|
23
28
|
lastActivity: now,
|
|
@@ -60,10 +65,10 @@ function getUserSessionUpdater(_a) {
|
|
|
60
65
|
}
|
|
61
66
|
exports.getUserSessionUpdater = getUserSessionUpdater;
|
|
62
67
|
function addSessionMetadataToNextSession(newSession, previousSession) {
|
|
63
|
-
var _a, _b;
|
|
68
|
+
var _a, _b, _c, _d;
|
|
64
69
|
var sessionWithMeta = __assign(__assign({}, newSession), { sessionMeta: {
|
|
65
70
|
id: newSession.sessionId,
|
|
66
|
-
attributes: __assign(__assign(__assign({}, (
|
|
71
|
+
attributes: __assign(__assign(__assign(__assign({}, (_b = (_a = faro_core_1.faro.config.sessionTracking) === null || _a === void 0 ? void 0 : _a.session) === null || _b === void 0 ? void 0 : _b.attributes), ((_d = (_c = faro_core_1.faro.metas.value.session) === null || _c === void 0 ? void 0 : _c.attributes) !== null && _d !== void 0 ? _d : {})), (previousSession != null ? { previousSession: previousSession.sessionId } : {})), { isSampled: newSession.isSampled.toString() }),
|
|
67
72
|
} });
|
|
68
73
|
return sessionWithMeta;
|
|
69
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessionManagerUtils.js","sourceRoot":"","sources":["../../../../../src/instrumentations/session/sessionManager/sessionManagerUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gDAA+D;AAE/D,uCAAuC;AACvC,uDAAsF;AAQtF,SAAgB,uBAAuB,CAAC,EAGH
|
|
1
|
+
{"version":3,"file":"sessionManagerUtils.js","sourceRoot":"","sources":["../../../../../src/instrumentations/session/sessionManager/sessionManagerUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gDAA+D;AAE/D,uCAAuC;AACvC,uDAAsF;AAQtF,SAAgB,uBAAuB,CAAC,EAGH;;QAHG,qBAGL,EAAE,KAAA,EA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Y,EAAE,IAAA,mBAAO,GAAE,IAAG,CAAC;SACvE;aAAM;YACL,IAAI,UAAU,GAAG,+BAA+B,CAC9C,uBAAuB,CAAC,EAAE,SAAS,EAAE,IAAA,oBAAS,GAAE,EAAE,CAAC,EACnD,kBAAkB,CACnB,CAAC;YAEF,gBAAgB,CAAC,UAAU,CAAC,CAAC;YAE7B,MAAA,gBAAI,CAAC,GAAG,0CAAE,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;YAC7C,MAAA,MAAA,gBAAI,CAAC,MAAM,CAAC,eAAe,0CAAE,eAAe,mDAAG,MAAA,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAE,WAAW,mCAAI,IAAI,EAAE,UAAU,CAAC,WAAY,CAAC,CAAC;SAClH;IACH,CAAC,CAAC;AACJ,CAAC;AAtBD,sDAsBC;AAED,SAAgB,+BAA+B,CAAC,UAA2B,EAAE,eAAuC;;IAClH,IAAM,eAAe,yBAChB,UAAU,KACb,WAAW,EAAE;YACX,EAAE,EAAE,UAAU,CAAC,SAAS;YACxB,UAAU,0CACL,MAAA,MAAA,gBAAI,CAAC,MAAM,CAAC,eAAe,0CAAE,OAAO,0CAAE,UAAU,GAChD,CAAC,MAAA,MAAA,gBAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,0CAAE,UAAU,mCAAI,EAAE,CAAC,GAC5C,CAAC,eAAe,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,eAAe,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAClF,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC,QAAQ,EAAE,GAC3C;SACF,GACF,CAAC;IAEF,OAAO,eAAe,CAAC;AACzB,CAAC;AAfD,0EAeC","sourcesContent":["import { dateNow, faro, genShortID } from '@grafana/faro-core';\n\nimport { isSampled } from './sampling';\nimport { SESSION_EXPIRATION_TIME, SESSION_INACTIVITY_TIME } from './sessionConstants';\nimport type { FaroUserSession } from './types';\n\ntype CreateUserSessionObjectParams = {\n sessionId?: string;\n isSampled?: boolean;\n};\n\nexport function createUserSessionObject({\n sessionId,\n isSampled = true,\n}: CreateUserSessionObjectParams = {}): FaroUserSession {\n const now = dateNow();\n\n const generateSessionId = faro.config?.sessionTracking?.generateSessionId;\n\n if (sessionId == null) {\n sessionId = typeof generateSessionId === 'function' ? generateSessionId() : genShortID();\n }\n\n return {\n sessionId,\n lastActivity: now,\n started: now,\n isSampled: isSampled,\n };\n}\n\nexport function isUserSessionValid(session: FaroUserSession | null): boolean {\n if (session == null) {\n return false;\n }\n\n const now = dateNow();\n const lifetimeValid = now - session.started < SESSION_EXPIRATION_TIME;\n\n if (!lifetimeValid) {\n return false;\n }\n\n const inactivityPeriodValid = now - session.lastActivity < SESSION_INACTIVITY_TIME;\n return inactivityPeriodValid;\n}\n\ntype GetUserSessionUpdaterParams = {\n storeUserSession: (session: FaroUserSession) => void;\n fetchUserSession: () => FaroUserSession | null;\n};\n\nexport function getUserSessionUpdater({ fetchUserSession, storeUserSession }: GetUserSessionUpdaterParams): () => void {\n return function updateSession(): void {\n if (!fetchUserSession || !storeUserSession) {\n return;\n }\n\n const sessionFromStorage = fetchUserSession();\n\n if (isUserSessionValid(sessionFromStorage)) {\n storeUserSession({ ...sessionFromStorage!, lastActivity: dateNow() });\n } else {\n let newSession = addSessionMetadataToNextSession(\n createUserSessionObject({ isSampled: isSampled() }),\n sessionFromStorage\n );\n\n storeUserSession(newSession);\n\n faro.api?.setSession(newSession.sessionMeta);\n faro.config.sessionTracking?.onSessionChange?.(sessionFromStorage?.sessionMeta ?? null, newSession.sessionMeta!);\n }\n };\n}\n\nexport function addSessionMetadataToNextSession(newSession: FaroUserSession, previousSession: FaroUserSession | null) {\n const sessionWithMeta: Required<FaroUserSession> = {\n ...newSession,\n sessionMeta: {\n id: newSession.sessionId,\n attributes: {\n ...faro.config.sessionTracking?.session?.attributes,\n ...(faro.metas.value.session?.attributes ?? {}),\n ...(previousSession != null ? { previousSession: previousSession.sessionId } : {}),\n isSampled: newSession.isSampled.toString(),\n },\n },\n };\n\n return sessionWithMeta;\n}\n"]}
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createSession = void 0;
|
|
4
4
|
var faro_core_1 = require("@grafana/faro-core");
|
|
5
|
+
var __1 = require("../..");
|
|
5
6
|
function createSession(attributes) {
|
|
7
|
+
var _a, _b, _c, _d;
|
|
6
8
|
return {
|
|
7
|
-
id: (0, faro_core_1.genShortID)(),
|
|
9
|
+
id: (_d = (_c = (_b = (_a = __1.faro.config) === null || _a === void 0 ? void 0 : _a.sessionTracking) === null || _b === void 0 ? void 0 : _b.generateSessionId) === null || _c === void 0 ? void 0 : _c.call(_b)) !== null && _d !== void 0 ? _d : (0, faro_core_1.genShortID)(),
|
|
8
10
|
attributes: attributes,
|
|
9
11
|
};
|
|
10
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSession.js","sourceRoot":"","sources":["../../../../src/metas/session/createSession.ts"],"names":[],"mappings":";;;AAAA,gDAAgD;AAGhD,SAAgB,aAAa,CAAC,UAAsC
|
|
1
|
+
{"version":3,"file":"createSession.js","sourceRoot":"","sources":["../../../../src/metas/session/createSession.ts"],"names":[],"mappings":";;;AAAA,gDAAgD;AAGhD,2BAA6B;AAE7B,SAAgB,aAAa,CAAC,UAAsC;;IAClE,OAAO;QACL,EAAE,EAAE,MAAA,MAAA,MAAA,MAAA,QAAI,CAAC,MAAM,0CAAE,eAAe,0CAAE,iBAAiB,kDAAI,mCAAI,IAAA,sBAAU,GAAE;QACvE,UAAU,YAAA;KACX,CAAC;AACJ,CAAC;AALD,sCAKC","sourcesContent":["import { genShortID } from '@grafana/faro-core';\nimport type { MetaSession } from '@grafana/faro-core';\n\nimport { faro } from '../..';\n\nexport function createSession(attributes?: MetaSession['attributes']): MetaSession {\n return {\n id: faro.config?.sessionTracking?.generateSessionId?.() ?? genShortID(),\n attributes,\n };\n}\n"]}
|
|
@@ -42,7 +42,7 @@ export class SessionInstrumentation extends BaseInstrumentation {
|
|
|
42
42
|
let lifecycleType;
|
|
43
43
|
if (isUserSessionValid(userSession)) {
|
|
44
44
|
sessionId = userSession === null || userSession === void 0 ? void 0 : userSession.sessionId;
|
|
45
|
-
sessionAttributes = Object.assign(Object.assign({}, (_c = userSession === null || userSession === void 0 ? void 0 : userSession.sessionMeta) === null || _c === void 0 ? void 0 : _c.attributes), { isSampled: userSession.isSampled.toString() });
|
|
45
|
+
sessionAttributes = Object.assign(Object.assign(Object.assign({}, sessionAttributes), (_c = userSession === null || userSession === void 0 ? void 0 : userSession.sessionMeta) === null || _c === void 0 ? void 0 : _c.attributes), { isSampled: (userSession.isSampled || false).toString() });
|
|
46
46
|
lifecycleType = EVENT_SESSION_RESUME;
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
@@ -92,10 +92,10 @@ export class SessionInstrumentation extends BaseInstrumentation {
|
|
|
92
92
|
: VolatileSessionsManager;
|
|
93
93
|
this.registerBeforeSendHook(SessionManager);
|
|
94
94
|
const { sessionMeta: initialSessionMeta, lifecycleType } = this.createInitialSessionMeta(sessionTracking);
|
|
95
|
-
SessionManager.storeUserSession(createUserSessionObject({
|
|
95
|
+
SessionManager.storeUserSession(Object.assign(Object.assign({}, createUserSessionObject({
|
|
96
96
|
sessionId: initialSessionMeta.id,
|
|
97
97
|
isSampled: ((_b = initialSessionMeta.attributes) === null || _b === void 0 ? void 0 : _b['isSampled']) === 'true',
|
|
98
|
-
}));
|
|
98
|
+
})), { sessionMeta: initialSessionMeta }));
|
|
99
99
|
this.notifiedSession = initialSessionMeta;
|
|
100
100
|
this.api.setSession(initialSessionMeta);
|
|
101
101
|
if (lifecycleType === EVENT_SESSION_START) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../../../src/instrumentations/session/instrumentation.ts"],"names":[],"mappings":"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ENT_SESSION_START,\n Meta,\n MetaSession,\n VERSION,\n} from '@grafana/faro-core';\nimport type { Config } from '@grafana/faro-core';\n\nimport type { TransportItem } from '../..';\nimport { createSession } from '../../metas';\n\nimport { type FaroUserSession, isSampled } from './sessionManager';\nimport { PersistentSessionsManager } from './sessionManager/PersistentSessionsManager';\nimport { createUserSessionObject, isUserSessionValid } from './sessionManager/sessionManagerUtils';\nimport { VolatileSessionsManager } from './sessionManager/VolatileSessionManager';\n\ntype LifecycleType = typeof EVENT_SESSION_RESUME | typeof EVENT_SESSION_START;\n\nexport class SessionInstrumentation extends BaseInstrumentation {\n readonly name = '@grafana/faro-web-sdk:instrumentation-session';\n readonly version = VERSION;\n\n // previously notified session, to ensure we don't send session start\n // event twice for the same session\n private notifiedSession: MetaSession | undefined;\n\n private sendSessionStartEvent(meta: Meta): void {\n const session = meta.session;\n\n if (session && session.id !== this.notifiedSession?.id) {\n if (this.notifiedSession && this.notifiedSession.id === session.attributes?.['previousSession']) {\n this.api.pushEvent(EVENT_SESSION_EXTEND, {}, undefined, { skipDedupe: true });\n this.notifiedSession = session;\n return;\n }\n\n this.notifiedSession = session;\n // no need to add attributes and session id, they are included as part of meta\n // automatically\n this.api.pushEvent(EVENT_SESSION_START, {}, undefined, { skipDedupe: true });\n }\n }\n\n private createInitialSessionMeta(sessionsConfig: Required<Config>['sessionTracking']): {\n sessionMeta: MetaSession;\n lifecycleType: LifecycleType;\n } {\n const sessionManager = sessionsConfig.persistent ? PersistentSessionsManager : VolatileSessionsManager;\n\n let userSession: FaroUserSession | null = sessionManager.fetchUserSession();\n\n if (sessionsConfig.persistent && sessionsConfig.maxSessionPersistenceTime && userSession) {\n const now = dateNow();\n const shouldClearPersistentSession = userSession.lastActivity < now - sessionsConfig.maxSessionPersistenceTime;\n\n if (shouldClearPersistentSession) {\n PersistentSessionsManager.removeUserSession();\n userSession = null;\n }\n }\n\n let sessionId = sessionsConfig.session?.id;\n let sessionAttributes = sessionsConfig.session?.attributes;\n\n let lifecycleType: LifecycleType;\n\n if (isUserSessionValid(userSession)) {\n sessionId = userSession?.sessionId;\n sessionAttributes = {\n ...userSession?.sessionMeta?.attributes,\n isSampled: userSession!.isSampled.toString(),\n };\n lifecycleType = EVENT_SESSION_RESUME;\n } else {\n sessionId = sessionId ?? createSession().id;\n lifecycleType = EVENT_SESSION_START;\n }\n\n const sessionMeta: MetaSession = {\n id: sessionId,\n attributes: {\n isSampled: isSampled().toString(),\n // We do not want to recalculate the sampling decision on each init phase.\n // If session from web-storage has a isSampled attribute we will use that instead.\n ...sessionAttributes,\n },\n };\n\n return { sessionMeta, lifecycleType };\n }\n\n private registerBeforeSendHook(SessionManager: typeof VolatileSessionsManager | typeof PersistentSessionsManager) {\n const { updateSession } = new SessionManager();\n\n this.transports?.addBeforeSendHooks((item) => {\n updateSession();\n\n const attributes = item.meta.session?.attributes;\n\n if (attributes && attributes?.['isSampled'] === 'true') {\n let newItem: TransportItem;\n\n // Structured clone is supported in all major browsers\n // but for old browsers we need a fallback\n if ('structuredClone' in window) {\n newItem = structuredClone(item);\n } else {\n newItem = JSON.parse(JSON.stringify(item));\n }\n\n const newAttributes = newItem.meta.session?.attributes;\n delete newAttributes?.['isSampled'];\n\n if (Object.keys(newAttributes ?? {}).length === 0) {\n delete newItem.meta.session?.attributes;\n }\n\n return newItem;\n }\n\n return null;\n });\n }\n\n initialize() {\n this.logDebug('init session instrumentation');\n\n const sessionTracking = this.config.sessionTracking;\n\n if (sessionTracking?.enabled) {\n const SessionManager = this.config.sessionTracking?.persistent\n ? PersistentSessionsManager\n : VolatileSessionsManager;\n\n this.registerBeforeSendHook(SessionManager);\n\n const { sessionMeta: initialSessionMeta, lifecycleType } = this.createInitialSessionMeta(sessionTracking);\n\n SessionManager.storeUserSession(\n createUserSessionObject({\n sessionId: initialSessionMeta.id,\n isSampled: initialSessionMeta.attributes?.['isSampled'] === 'true',\n })\n );\n\n this.notifiedSession = initialSessionMeta;\n this.api.setSession(initialSessionMeta);\n\n if (lifecycleType === EVENT_SESSION_START) {\n this.api.pushEvent(EVENT_SESSION_START, {}, undefined, { skipDedupe: true });\n }\n\n if (lifecycleType === EVENT_SESSION_RESUME) {\n this.api.pushEvent(EVENT_SESSION_RESUME, {}, undefined, { skipDedupe: true });\n }\n }\n\n this.metas.addListener(this.sendSessionStartEvent.bind(this));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../../../src/instrumentations/session/instrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,OAAO,EACP,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EAGnB,OAAO,GACR,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAwB,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AACnG,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAIlF,MAAM,OAAO,sBAAuB,SAAQ,mBAAmB;IAA/D;;QACW,SAAI,GAAG,+CAA+C,CAAC;QACvD,YAAO,GAAG,OAAO,CAAC;IA8I7B,CAAC;IAxIS,qBAAqB,CAAC,IAAU;;QACtC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAE7B,IAAI,OAAO,IAAI,OAAO,CAAC,EAAE,MAAK,MAAA,IAAI,CAAC,eAAe,0CAAE,EAAE,CAAA,EAAE;YACtD,IAAI,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,eAAe,CAAC,EAAE,MAAK,MAAA,OAAO,CAAC,UAAU,0CAAG,iBAAiB,CAAC,CAAA,EAAE;gBAC/F,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,UAA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C9E;YAED,IAAI,aAAa,KAAK,oBAAoB,EAAE;gBAC1C,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;aAC/E;SACF;QAED,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAChE,CAAC;CACF","sourcesContent":["import {\n BaseInstrumentation,\n dateNow,\n EVENT_SESSION_EXTEND,\n EVENT_SESSION_RESUME,\n EVENT_SESSION_START,\n Meta,\n MetaSession,\n VERSION,\n} from '@grafana/faro-core';\nimport type { Config } from '@grafana/faro-core';\n\nimport type { TransportItem } from '../..';\nimport { createSession } from '../../metas';\n\nimport { type FaroUserSession, isSampled } from './sessionManager';\nimport { PersistentSessionsManager } from './sessionManager/PersistentSessionsManager';\nimport { createUserSessionObject, isUserSessionValid } from './sessionManager/sessionManagerUtils';\nimport { VolatileSessionsManager } from './sessionManager/VolatileSessionManager';\n\ntype LifecycleType = typeof EVENT_SESSION_RESUME | typeof EVENT_SESSION_START;\n\nexport class SessionInstrumentation extends BaseInstrumentation {\n readonly name = '@grafana/faro-web-sdk:instrumentation-session';\n readonly version = VERSION;\n\n // previously notified session, to ensure we don't send session start\n // event twice for the same session\n private notifiedSession: MetaSession | undefined;\n\n private sendSessionStartEvent(meta: Meta): void {\n const session = meta.session;\n\n if (session && session.id !== this.notifiedSession?.id) {\n if (this.notifiedSession && this.notifiedSession.id === session.attributes?.['previousSession']) {\n this.api.pushEvent(EVENT_SESSION_EXTEND, {}, undefined, { skipDedupe: true });\n this.notifiedSession = session;\n return;\n }\n\n this.notifiedSession = session;\n // no need to add attributes and session id, they are included as part of meta\n // automatically\n this.api.pushEvent(EVENT_SESSION_START, {}, undefined, { skipDedupe: true });\n }\n }\n\n private createInitialSessionMeta(sessionsConfig: Required<Config>['sessionTracking']): {\n sessionMeta: MetaSession;\n lifecycleType: LifecycleType;\n } {\n const sessionManager = sessionsConfig.persistent ? PersistentSessionsManager : VolatileSessionsManager;\n\n let userSession: FaroUserSession | null = sessionManager.fetchUserSession();\n\n if (sessionsConfig.persistent && sessionsConfig.maxSessionPersistenceTime && userSession) {\n const now = dateNow();\n const shouldClearPersistentSession = userSession.lastActivity < now - sessionsConfig.maxSessionPersistenceTime;\n\n if (shouldClearPersistentSession) {\n PersistentSessionsManager.removeUserSession();\n userSession = null;\n }\n }\n\n let sessionId = sessionsConfig.session?.id;\n let sessionAttributes = sessionsConfig.session?.attributes;\n\n let lifecycleType: LifecycleType;\n\n if (isUserSessionValid(userSession)) {\n sessionId = userSession?.sessionId;\n sessionAttributes = {\n ...sessionAttributes,\n ...userSession?.sessionMeta?.attributes,\n isSampled: (userSession!.isSampled || false).toString(),\n };\n\n lifecycleType = EVENT_SESSION_RESUME;\n } else {\n sessionId = sessionId ?? createSession().id;\n lifecycleType = EVENT_SESSION_START;\n }\n\n const sessionMeta: MetaSession = {\n id: sessionId,\n attributes: {\n isSampled: isSampled().toString(),\n // We do not want to recalculate the sampling decision on each init phase.\n // If session from web-storage has a isSampled attribute we will use that instead.\n ...sessionAttributes,\n },\n };\n\n return { sessionMeta, lifecycleType };\n }\n\n private registerBeforeSendHook(SessionManager: typeof VolatileSessionsManager | typeof PersistentSessionsManager) {\n const { updateSession } = new SessionManager();\n\n this.transports?.addBeforeSendHooks((item) => {\n updateSession();\n\n const attributes = item.meta.session?.attributes;\n\n if (attributes && attributes?.['isSampled'] === 'true') {\n let newItem: TransportItem;\n\n // Structured clone is supported in all major browsers\n // but for old browsers we need a fallback\n if ('structuredClone' in window) {\n newItem = structuredClone(item);\n } else {\n newItem = JSON.parse(JSON.stringify(item));\n }\n\n const newAttributes = newItem.meta.session?.attributes;\n delete newAttributes?.['isSampled'];\n\n if (Object.keys(newAttributes ?? {}).length === 0) {\n delete newItem.meta.session?.attributes;\n }\n\n return newItem;\n }\n\n return null;\n });\n }\n\n initialize() {\n this.logDebug('init session instrumentation');\n\n const sessionTracking = this.config.sessionTracking;\n\n if (sessionTracking?.enabled) {\n const SessionManager = this.config.sessionTracking?.persistent\n ? PersistentSessionsManager\n : VolatileSessionsManager;\n\n this.registerBeforeSendHook(SessionManager);\n\n const { sessionMeta: initialSessionMeta, lifecycleType } = this.createInitialSessionMeta(sessionTracking);\n\n SessionManager.storeUserSession({\n ...createUserSessionObject({\n sessionId: initialSessionMeta.id,\n isSampled: initialSessionMeta.attributes?.['isSampled'] === 'true',\n }),\n sessionMeta: initialSessionMeta,\n });\n\n this.notifiedSession = initialSessionMeta;\n this.api.setSession(initialSessionMeta);\n\n if (lifecycleType === EVENT_SESSION_START) {\n this.api.pushEvent(EVENT_SESSION_START, {}, undefined, { skipDedupe: true });\n }\n\n if (lifecycleType === EVENT_SESSION_RESUME) {\n this.api.pushEvent(EVENT_SESSION_RESUME, {}, undefined, { skipDedupe: true });\n }\n }\n\n this.metas.addListener(this.sendSessionStartEvent.bind(this));\n }\n}\n"]}
|
|
@@ -32,17 +32,6 @@ export class PersistentSessionsManager {
|
|
|
32
32
|
this.updateSession();
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
|
-
window.addEventListener('storage', (event) => {
|
|
36
|
-
var _a, _b, _c;
|
|
37
|
-
if (event.key !== STORAGE_KEY) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const newSession = JSON.parse((_a = event.newValue) !== null && _a !== void 0 ? _a : '');
|
|
41
|
-
const previousSession = JSON.parse((_b = event.oldValue) !== null && _b !== void 0 ? _b : '');
|
|
42
|
-
if (newSession.sessionId !== previousSession.sessionId) {
|
|
43
|
-
(_c = faro.api) === null || _c === void 0 ? void 0 : _c.setSession(newSession.sessionMeta);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
35
|
// Users can call the setSession() method, so we need to sync this with the local storage session
|
|
47
36
|
faro.metas.addListener(function syncSessionIfChangedExternally(meta) {
|
|
48
37
|
const session = meta.session;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersistentSessionsManager.js","sourceRoot":"","sources":["../../../../../src/instrumentations/session/sessionManager/PersistentSessionsManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEzF,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,+BAA+B,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAGxH,MAAM,OAAO,yBAAyB;IAIpC;QA2BA,kBAAa,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,oBAAoB,CAAC,CAAC;QA1B7E,IAAI,CAAC,iBAAiB,GAAG,qBAAqB,CAAC;YAC7C,gBAAgB,EAAE,yBAAyB,CAAC,gBAAgB;YAC5D,gBAAgB,EAAE,yBAAyB,CAAC,gBAAgB;SAC7D,CAAC,CAAC;QAEH,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;IAED,MAAM,CAAC,iBAAiB;QACtB,UAAU,CAAC,WAAW,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,CAAC;IACtE,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,OAAwB;QAC9C,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,CAAC;IAC5F,CAAC;IAED,MAAM,CAAC,gBAAgB;QACrB,MAAM,aAAa,GAAG,OAAO,CAAC,WAAW,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,CAAC;QAEvF,IAAI,aAAa,EAAE;YACjB,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAoB,CAAC;SACrD;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAIO,IAAI;QACV,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,GAAG,EAAE;YACjD,IAAI,QAAQ,CAAC,eAAe,KAAK,SAAS,EAAE;gBAC1C,IAAI,CAAC,aAAa,EAAE,CAAC;aACtB;QACH,CAAC,CAAC,CAAC;QAEH,
|
|
1
|
+
{"version":3,"file":"PersistentSessionsManager.js","sourceRoot":"","sources":["../../../../../src/instrumentations/session/sessionManager/PersistentSessionsManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEzF,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,+BAA+B,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAGxH,MAAM,OAAO,yBAAyB;IAIpC;QA2BA,kBAAa,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,oBAAoB,CAAC,CAAC;QA1B7E,IAAI,CAAC,iBAAiB,GAAG,qBAAqB,CAAC;YAC7C,gBAAgB,EAAE,yBAAyB,CAAC,gBAAgB;YAC5D,gBAAgB,EAAE,yBAAyB,CAAC,gBAAgB;SAC7D,CAAC,CAAC;QAEH,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;IAED,MAAM,CAAC,iBAAiB;QACtB,UAAU,CAAC,WAAW,EAAE,yBAAy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AAC,CAAC;IACL,CAAC;;AAtDc,0CAAgB,GAAG,cAAc,CAAC,KAAK,CAAC","sourcesContent":["import { faro } from '@grafana/faro-core';\nimport type { Meta } from '@grafana/faro-core';\n\nimport { throttle } from '../../../utils';\nimport { getItem, removeItem, setItem, webStorageType } from '../../../utils/webStorage';\n\nimport { isSampled } from './sampling';\nimport { STORAGE_KEY, STORAGE_UPDATE_DELAY } from './sessionConstants';\nimport { addSessionMetadataToNextSession, createUserSessionObject, getUserSessionUpdater } from './sessionManagerUtils';\nimport type { FaroUserSession } from './types';\n\nexport class PersistentSessionsManager {\n private static storageTypeLocal = webStorageType.local;\n private updateUserSession: ReturnType<typeof getUserSessionUpdater>;\n\n constructor() {\n this.updateUserSession = getUserSessionUpdater({\n fetchUserSession: PersistentSessionsManager.fetchUserSession,\n storeUserSession: PersistentSessionsManager.storeUserSession,\n });\n\n this.init();\n }\n\n static removeUserSession() {\n removeItem(STORAGE_KEY, PersistentSessionsManager.storageTypeLocal);\n }\n\n static storeUserSession(session: FaroUserSession): void {\n setItem(STORAGE_KEY, JSON.stringify(session), PersistentSessionsManager.storageTypeLocal);\n }\n\n static fetchUserSession(): FaroUserSession | null {\n const storedSession = getItem(STORAGE_KEY, PersistentSessionsManager.storageTypeLocal);\n\n if (storedSession) {\n return JSON.parse(storedSession) as FaroUserSession;\n }\n\n return null;\n }\n\n updateSession = throttle(() => this.updateUserSession(), STORAGE_UPDATE_DELAY);\n\n private init(): void {\n document.addEventListener('visibilitychange', () => {\n if (document.visibilityState === 'visible') {\n this.updateSession();\n }\n });\n\n // Users can call the setSession() method, so we need to sync this with the local storage session\n faro.metas.addListener(function syncSessionIfChangedExternally(meta: Meta) {\n const session = meta.session;\n const sessionFromLocalStorage = PersistentSessionsManager.fetchUserSession();\n\n if (session && session.id !== sessionFromLocalStorage?.sessionId) {\n const userSession = addSessionMetadataToNextSession(\n createUserSessionObject({ sessionId: session.id, isSampled: isSampled() }),\n sessionFromLocalStorage\n );\n\n PersistentSessionsManager.storeUserSession(userSession);\n faro.api.setSession(userSession.sessionMeta);\n }\n });\n }\n}\n"]}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { dateNow, faro, genShortID } from '@grafana/faro-core';
|
|
2
2
|
import { isSampled } from './sampling';
|
|
3
3
|
import { SESSION_EXPIRATION_TIME, SESSION_INACTIVITY_TIME } from './sessionConstants';
|
|
4
|
-
export function createUserSessionObject({ sessionId
|
|
4
|
+
export function createUserSessionObject({ sessionId, isSampled = true, } = {}) {
|
|
5
|
+
var _a, _b;
|
|
5
6
|
const now = dateNow();
|
|
7
|
+
const generateSessionId = (_b = (_a = faro.config) === null || _a === void 0 ? void 0 : _a.sessionTracking) === null || _b === void 0 ? void 0 : _b.generateSessionId;
|
|
8
|
+
if (sessionId == null) {
|
|
9
|
+
sessionId = typeof generateSessionId === 'function' ? generateSessionId() : genShortID();
|
|
10
|
+
}
|
|
6
11
|
return {
|
|
7
12
|
sessionId,
|
|
8
13
|
lastActivity: now,
|
|
@@ -41,10 +46,10 @@ export function getUserSessionUpdater({ fetchUserSession, storeUserSession }) {
|
|
|
41
46
|
};
|
|
42
47
|
}
|
|
43
48
|
export function addSessionMetadataToNextSession(newSession, previousSession) {
|
|
44
|
-
var _a, _b;
|
|
49
|
+
var _a, _b, _c, _d;
|
|
45
50
|
const sessionWithMeta = Object.assign(Object.assign({}, newSession), { sessionMeta: {
|
|
46
51
|
id: newSession.sessionId,
|
|
47
|
-
attributes: Object.assign(Object.assign(Object.assign({}, (
|
|
52
|
+
attributes: Object.assign(Object.assign(Object.assign(Object.assign({}, (_b = (_a = faro.config.sessionTracking) === null || _a === void 0 ? void 0 : _a.session) === null || _b === void 0 ? void 0 : _b.attributes), ((_d = (_c = faro.metas.value.session) === null || _c === void 0 ? void 0 : _c.attributes) !== null && _d !== void 0 ? _d : {})), (previousSession != null ? { previousSession: previousSession.sessionId } : {})), { isSampled: newSession.isSampled.toString() }),
|
|
48
53
|
} });
|
|
49
54
|
return sessionWithMeta;
|
|
50
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessionManagerUtils.js","sourceRoot":"","sources":["../../../../../src/instrumentations/session/sessionManager/sessionManagerUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAQtF,MAAM,UAAU,uBAAuB,CAAC,EACtC,SAAS,
|
|
1
|
+
{"version":3,"file":"sessionManagerUtils.js","sourceRoot":"","sources":["../../../../../src/instrumentations/session/sessionManager/sessionManagerUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAQtF,MAAM,UAAU,uBAAuB,CAAC,EACtC,SAAS,EACT,SAAS,GAAG,IAAI,MACiB,EAAE;;IACnC,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;IAEtB,MAAM,iBAAiB,GAAG,MAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,eAAe,0CAAE,iBAAiB,CAAC;IAE1E,IAAI,SAAS,IAAI,IAAI,EAAE;QACrB,SAAS,GAAG,OAAO,iBAAiB,KAAK,UAAU,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;KAC1F;IAED,OAAO;QACL,SAAS;QACT,YAAY,EAAE,GAAG;QACjB,OAAO,EAAE,GAAG;QACZ,SAAS,EAAE,SAAS;KACrB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,OAA+B;IAChE,IAAI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,WAAW,EAAE;YACX,EAAE,EAAE,UAAU,CAAC,SAAS;YACxB,UAAU,8DACL,MAAA,MAAA,IAAI,CAAC,MAAM,CAAC,eAAe,0CAAE,OAAO,0CAAE,UAAU,GAChD,CAAC,MAAA,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,0CAAE,UAAU,mCAAI,EAAE,CAAC,GAC5C,CAAC,eAAe,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,eAAe,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAClF,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC,QAAQ,EAAE,GAC3C;SACF,GACF,CAAC;IAEF,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["import { dateNow, faro, genShortID } from '@grafana/faro-core';\n\nimport { isSampled } from './sampling';\nimport { SESSION_EXPIRATION_TIME, SESSION_INACTIVITY_TIME } from './sessionConstants';\nimport type { FaroUserSession } from './types';\n\ntype CreateUserSessionObjectParams = {\n sessionId?: string;\n isSampled?: boolean;\n};\n\nexport function createUserSessionObject({\n sessionId,\n isSampled = true,\n}: CreateUserSessionObjectParams = {}): FaroUserSession {\n const now = dateNow();\n\n const generateSessionId = faro.config?.sessionTracking?.generateSessionId;\n\n if (sessionId == null) {\n sessionId = typeof generateSessionId === 'function' ? generateSessionId() : genShortID();\n }\n\n return {\n sessionId,\n lastActivity: now,\n started: now,\n isSampled: isSampled,\n };\n}\n\nexport function isUserSessionValid(session: FaroUserSession | null): boolean {\n if (session == null) {\n return false;\n }\n\n const now = dateNow();\n const lifetimeValid = now - session.started < SESSION_EXPIRATION_TIME;\n\n if (!lifetimeValid) {\n return false;\n }\n\n const inactivityPeriodValid = now - session.lastActivity < SESSION_INACTIVITY_TIME;\n return inactivityPeriodValid;\n}\n\ntype GetUserSessionUpdaterParams = {\n storeUserSession: (session: FaroUserSession) => void;\n fetchUserSession: () => FaroUserSession | null;\n};\n\nexport function getUserSessionUpdater({ fetchUserSession, storeUserSession }: GetUserSessionUpdaterParams): () => void {\n return function updateSession(): void {\n if (!fetchUserSession || !storeUserSession) {\n return;\n }\n\n const sessionFromStorage = fetchUserSession();\n\n if (isUserSessionValid(sessionFromStorage)) {\n storeUserSession({ ...sessionFromStorage!, lastActivity: dateNow() });\n } else {\n let newSession = addSessionMetadataToNextSession(\n createUserSessionObject({ isSampled: isSampled() }),\n sessionFromStorage\n );\n\n storeUserSession(newSession);\n\n faro.api?.setSession(newSession.sessionMeta);\n faro.config.sessionTracking?.onSessionChange?.(sessionFromStorage?.sessionMeta ?? null, newSession.sessionMeta!);\n }\n };\n}\n\nexport function addSessionMetadataToNextSession(newSession: FaroUserSession, previousSession: FaroUserSession | null) {\n const sessionWithMeta: Required<FaroUserSession> = {\n ...newSession,\n sessionMeta: {\n id: newSession.sessionId,\n attributes: {\n ...faro.config.sessionTracking?.session?.attributes,\n ...(faro.metas.value.session?.attributes ?? {}),\n ...(previousSession != null ? { previousSession: previousSession.sessionId } : {}),\n isSampled: newSession.isSampled.toString(),\n },\n },\n };\n\n return sessionWithMeta;\n}\n"]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { genShortID } from '@grafana/faro-core';
|
|
2
|
+
import { faro } from '../..';
|
|
2
3
|
export function createSession(attributes) {
|
|
4
|
+
var _a, _b, _c, _d;
|
|
3
5
|
return {
|
|
4
|
-
id: genShortID(),
|
|
6
|
+
id: (_d = (_c = (_b = (_a = faro.config) === null || _a === void 0 ? void 0 : _a.sessionTracking) === null || _b === void 0 ? void 0 : _b.generateSessionId) === null || _c === void 0 ? void 0 : _c.call(_b)) !== null && _d !== void 0 ? _d : genShortID(),
|
|
5
7
|
attributes,
|
|
6
8
|
};
|
|
7
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSession.js","sourceRoot":"","sources":["../../../../src/metas/session/createSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,MAAM,UAAU,aAAa,CAAC,UAAsC
|
|
1
|
+
{"version":3,"file":"createSession.js","sourceRoot":"","sources":["../../../../src/metas/session/createSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAE7B,MAAM,UAAU,aAAa,CAAC,UAAsC;;IAClE,OAAO;QACL,EAAE,EAAE,MAAA,MAAA,MAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,eAAe,0CAAE,iBAAiB,kDAAI,mCAAI,UAAU,EAAE;QACvE,UAAU;KACX,CAAC;AACJ,CAAC","sourcesContent":["import { genShortID } from '@grafana/faro-core';\nimport type { MetaSession } from '@grafana/faro-core';\n\nimport { faro } from '../..';\n\nexport function createSession(attributes?: MetaSession['attributes']): MetaSession {\n return {\n id: faro.config?.sessionTracking?.generateSessionId?.() ?? genShortID(),\n attributes,\n };\n}\n"]}
|
|
@@ -3,7 +3,7 @@ import type { ConsoleInstrumentationOptions } from './types';
|
|
|
3
3
|
export declare class ConsoleInstrumentation extends BaseInstrumentation {
|
|
4
4
|
private options;
|
|
5
5
|
readonly name = "@grafana/faro-web-sdk:instrumentation-console";
|
|
6
|
-
readonly version = "1.3.
|
|
6
|
+
readonly version = "1.3.5";
|
|
7
7
|
static defaultDisabledLevels: LogLevel[];
|
|
8
8
|
constructor(options?: ConsoleInstrumentationOptions);
|
|
9
9
|
initialize(): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseInstrumentation } from '@grafana/faro-core';
|
|
2
2
|
export declare class ErrorsInstrumentation extends BaseInstrumentation {
|
|
3
3
|
readonly name = "@grafana/faro-web-sdk:instrumentation-errors";
|
|
4
|
-
readonly version = "1.3.
|
|
4
|
+
readonly version = "1.3.5";
|
|
5
5
|
initialize(): void;
|
|
6
6
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseInstrumentation } from '@grafana/faro-core';
|
|
2
2
|
export declare class SessionInstrumentation extends BaseInstrumentation {
|
|
3
3
|
readonly name = "@grafana/faro-web-sdk:instrumentation-session";
|
|
4
|
-
readonly version = "1.3.
|
|
4
|
+
readonly version = "1.3.5";
|
|
5
5
|
private notifiedSession;
|
|
6
6
|
private sendSessionStartEvent;
|
|
7
7
|
private createInitialSessionMeta;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseInstrumentation } from '@grafana/faro-core';
|
|
2
2
|
export declare class ViewInstrumentation extends BaseInstrumentation {
|
|
3
3
|
readonly name = "@grafana/faro-web-sdk:instrumentation-view";
|
|
4
|
-
readonly version = "1.3.
|
|
4
|
+
readonly version = "1.3.5";
|
|
5
5
|
private notifiedView;
|
|
6
6
|
private sendViewChangedEvent;
|
|
7
7
|
initialize(): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseInstrumentation } from '@grafana/faro-core';
|
|
2
2
|
export declare class WebVitalsInstrumentation extends BaseInstrumentation {
|
|
3
3
|
readonly name = "@grafana/faro-web-sdk:instrumentation-web-vitals";
|
|
4
|
-
readonly version = "1.3.
|
|
4
|
+
readonly version = "1.3.5";
|
|
5
5
|
static mapping: {
|
|
6
6
|
cls: (onReport: import("web-vitals").CLSReportCallback, opts?: import("web-vitals").ReportOpts | undefined) => void;
|
|
7
7
|
fcp: (onReport: import("web-vitals").FCPReportCallback, opts?: import("web-vitals").ReportOpts | undefined) => void;
|
|
@@ -4,7 +4,7 @@ import type { ConsoleTransportOptions } from './types';
|
|
|
4
4
|
export declare class ConsoleTransport extends BaseTransport {
|
|
5
5
|
private options;
|
|
6
6
|
readonly name = "@grafana/faro-web-sdk:transport-console";
|
|
7
|
-
readonly version = "1.3.
|
|
7
|
+
readonly version = "1.3.5";
|
|
8
8
|
constructor(options?: ConsoleTransportOptions);
|
|
9
9
|
send(item: TransportItem): void;
|
|
10
10
|
}
|
|
@@ -4,7 +4,7 @@ import type { FetchTransportOptions } from './types';
|
|
|
4
4
|
export declare class FetchTransport extends BaseTransport {
|
|
5
5
|
private options;
|
|
6
6
|
readonly name = "@grafana/faro-web-sdk:transport-fetch";
|
|
7
|
-
readonly version = "1.3.
|
|
7
|
+
readonly version = "1.3.5";
|
|
8
8
|
promiseBuffer: PromiseBuffer<Response | void>;
|
|
9
9
|
private readonly rateLimitBackoffMs;
|
|
10
10
|
private readonly getNow;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/faro-web-sdk",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
4
4
|
"description": "Faro instrumentations, metas, transports for web.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"observability",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"quality:circular-deps": "madge --circular ."
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@grafana/faro-core": "^1.3.
|
|
55
|
+
"@grafana/faro-core": "^1.3.5",
|
|
56
56
|
"ua-parser-js": "^1.0.32",
|
|
57
57
|
"web-vitals": "^3.1.1"
|
|
58
58
|
},
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "d571a26ef68f79488cc52ee30682320aa44ff380"
|
|
67
67
|
}
|