@grafana/faro-core 1.13.3 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle/faro-core.iife.js +1 -1
- package/dist/bundle/types/api/meta/types.d.ts +4 -3
- package/dist/bundle/types/config/types.d.ts +33 -1
- package/dist/bundle/types/metas/types.d.ts +36 -1
- package/dist/bundle/types/testUtils/mockTransport.d.ts +1 -1
- package/dist/bundle/types/version.d.ts +1 -1
- package/dist/cjs/api/meta/initialize.js +8 -2
- package/dist/cjs/api/meta/initialize.js.map +1 -1
- package/dist/cjs/api/meta/types.js.map +1 -1
- package/dist/cjs/config/types.js.map +1 -1
- package/dist/cjs/metas/types.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/api/meta/initialize.js +8 -2
- package/dist/esm/api/meta/initialize.js.map +1 -1
- package/dist/esm/api/meta/types.js.map +1 -1
- package/dist/esm/config/types.js.map +1 -1
- package/dist/esm/metas/types.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/spec/core/src/api/meta/initialize.js +8 -2
- package/dist/spec/core/src/api/meta/initialize.js.map +1 -1
- package/dist/spec/core/src/api/meta/initilialize.test.js +28 -0
- package/dist/spec/core/src/api/meta/initilialize.test.js.map +1 -1
- package/dist/spec/core/src/api/meta/types.js.map +1 -1
- package/dist/spec/core/src/config/types.js.map +1 -1
- package/dist/spec/core/src/metas/types.js.map +1 -1
- package/dist/spec/core/src/version.js +1 -1
- package/dist/spec/core/src/version.js.map +1 -1
- package/dist/types/api/meta/types.d.ts +4 -3
- package/dist/types/config/types.d.ts +33 -1
- package/dist/types/core/src/api/meta/types.d.ts +4 -3
- package/dist/types/core/src/config/types.d.ts +33 -1
- package/dist/types/core/src/metas/types.d.ts +36 -1
- package/dist/types/core/src/testUtils/mockTransport.d.ts +1 -1
- package/dist/types/core/src/version.d.ts +1 -1
- package/dist/types/metas/types.d.ts +36 -1
- package/dist/types/testUtils/mockTransport.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
var GrafanaFaroCore=function(e){"use strict";function n(e,n){return typeof e===n}function t(e,n){return Object.prototype.toString.call(e)===`[object ${n}]`}function r(e,n){try{return e instanceof n}catch(e){return!1}}const i=e=>n(e,"null"),a=e=>n(e,"string"),s=e=>n(e,"number")&&!isNaN(e)||n(e,"bigint"),o=e=>!i(e)&&n(e,"object"),u=e=>n(e,"function"),l=e=>t(e,"Array"),c="undefined"!=typeof Event,d="undefined"!=typeof Error,g=e=>d&&r(e,Error),p="undefined"!=typeof Element,f="undefined"!=typeof Map;function m(e){return null==e||(l(e)||a(e)?0===e.length:!!o(e)&&0===Object.keys(e).length)}function v(e,t){if(e===t)return!0;if(n(e,"number")&&isNaN(e))return n(t,"number")&&isNaN(t);const r=l(e),i=l(t);if(r!==i)return!1;if(r&&i){const n=e.length;if(n!==t.length)return!1;for(let r=n;0!=r--;)if(!v(e[r],t[r]))return!1;return!0}const a=o(e),s=o(t);if(a!==s)return!1;if(e&&t&&a&&s){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;for(let r of n)if(!v(e[r],t[r]))return!1;return!0}return!1}function b(){return(new Date).toISOString()}function h(e){return new Date(e).toISOString()}var E;e.LogLevel=void 0,(E=e.LogLevel||(e.LogLevel={})).TRACE="trace",E.DEBUG="debug",E.INFO="info",E.LOG="log",E.WARN="warn",E.ERROR="error";const y=e.LogLevel.LOG,I=[e.LogLevel.TRACE,e.LogLevel.DEBUG,e.LogLevel.INFO,e.LogLevel.LOG,e.LogLevel.WARN,e.LogLevel.ERROR];function T(){}const O="abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789";const L="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:void 0;function S(){const e=new WeakSet;return function(n,t){if(o(t)&&null!==t){if(e.has(t))return null;e.add(t)}return t}}function N(e={}){return JSON.stringify(null!=e?e:{},S())}function j(e={}){const n={};for(const[t,r]of Object.entries(e))n[t]=o(r)&&null!==r?N(r):String(r);return n}class R{constructor(e,n){var t,r;this.signalBuffer=[],this.itemLimit=null!==(t=null==n?void 0:n.itemLimit)&&void 0!==t?t:50,this.sendTimeout=null!==(r=null==n?void 0:n.sendTimeout)&&void 0!==r?r:250,this.paused=(null==n?void 0:n.paused)||!1,this.sendFn=e,this.flushInterval=-1,this.paused||this.start(),document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&this.flush()}))}addItem(e){this.paused||(this.signalBuffer.push(e),this.signalBuffer.length>=this.itemLimit&&this.flush())}start(){this.paused=!1,this.sendTimeout>0&&(this.flushInterval=window.setInterval((()=>this.flush()),this.sendTimeout))}pause(){this.paused=!0,clearInterval(this.flushInterval)}groupItems(e){const n=new Map;return e.forEach((e=>{const t=JSON.stringify(e.meta);let r=n.get(t);r=void 0===r?[e]:[...r,e],n.set(t,r)})),Array.from(n.values())}flush(){if(this.paused||0===this.signalBuffer.length)return;this.groupItems(this.signalBuffer).forEach(this.sendFn),this.signalBuffer=[]}}var x;e.TransportItemType=void 0,(x=e.TransportItemType||(e.TransportItemType={})).EXCEPTION="exception",x.LOG="log",x.MEASUREMENT="measurement",x.TRACE="trace",x.EVENT="event";const A={[e.TransportItemType.EXCEPTION]:"exceptions",[e.TransportItemType.LOG]:"logs",[e.TransportItemType.MEASUREMENT]:"measurements",[e.TransportItemType.TRACE]:"traces",[e.TransportItemType.EVENT]:"events"};function w(n){return t=>{if(t.type===e.TransportItemType.EXCEPTION&&t.payload){const e=t.payload,r=`${e.type}: ${e.value}`;if(function(e,n){return e.some((e=>a(e)?n.includes(e):!!n.match(e)))}(n,r))return null}return t}}function C(e,n,t,r){var i;n.debug("Initializing transports");const a=[];let s=t.paused,o=[];const u=e=>{let n=e;for(const e of o){const t=n.map(e).filter(Boolean);if(0===t.length)return[];n=t}return n},l=e=>{const t=u(e);if(0!==t.length)for(const e of a)n.debug(`Transporting item using ${e.name}\n`,t),e.isBatched()&&e.send(t)};let c;(null===(i=t.batching)||void 0===i?void 0:i.enabled)&&(c=new R(l,{sendTimeout:t.batching.sendTimeout,itemLimit:t.batching.itemLimit,paused:s}));return{add:(...i)=>{n.debug("Adding transports"),i.forEach((i=>{n.debug(`Adding "${i.name}" transport`);a.some((e=>e===i))?n.warn(`Transport ${i.name} is already added`):(i.unpatchedConsole=e,i.internalLogger=n,i.config=t,i.metas=r,a.push(i))}))},addBeforeSendHooks:(...e)=>{n.debug("Adding beforeSendHooks\n",o),e.forEach((e=>{e&&o.push(e)}))},addIgnoreErrorsPatterns:(...e)=>{n.debug("Adding ignoreErrorsPatterns\n",e),e.forEach((e=>{e&&o.push(w(e))}))},getBeforeSendHooks:()=>[...o],execute:e=>{var r;s||((null===(r=t.batching)||void 0===r?void 0:r.enabled)&&(null==c||c.addItem(e)),(e=>{var r,i;if((null===(r=t.batching)||void 0===r?void 0:r.enabled)&&a.every((e=>e.isBatched())))return;const[s]=u([e]);if(void 0!==s)for(const e of a)n.debug(`Transporting item using ${e.name}\n`,s),e.isBatched()?(null===(i=t.batching)||void 0===i?void 0:i.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=a.indexOf(e);-1!==t?a.splice(t,1):n.warn(`Transport "${e.name}" is not added`)}))},removeBeforeSendHooks:(...e)=>{o.filter((n=>!e.includes(n)))},get transports(){return[...a]},unpause:()=>{n.debug("Unpausing transports"),null==c||c.start(),s=!1}}}var k;e.InternalLoggerLevel=void 0,(k=e.InternalLoggerLevel||(e.InternalLoggerLevel={}))[k.OFF=0]="OFF",k[k.ERROR=1]="ERROR",k[k.WARN=2]="WARN",k[k.INFO=3]="INFO",k[k.VERBOSE=4]="VERBOSE";const _={debug:T,error:T,info:T,prefix:"Faro",warn:T},P=e.InternalLoggerLevel.ERROR,B=Object.assign({},console);let F=B;function D(e){var n;return F=null!==(n=e.unpatchedConsole)&&void 0!==n?n:F,F}function V(n=B,t=P){const r=_;return t>e.InternalLoggerLevel.OFF&&(r.error=t>=e.InternalLoggerLevel.ERROR?function(...e){n.error(`${r.prefix}\n`,...e)}:T,r.warn=t>=e.InternalLoggerLevel.WARN?function(...e){n.warn(`${r.prefix}\n`,...e)}:T,r.info=t>=e.InternalLoggerLevel.INFO?function(...e){n.info(`${r.prefix}\n`,...e)}:T,r.debug=t>=e.InternalLoggerLevel.VERBOSE?function(...e){n.debug(`${r.prefix}\n`,...e)}:T),r}let M=_;function $(e,n){return M=V(e,n.internalLoggerLevel),M}class G{constructor(){this.unpatchedConsole=B,this.internalLogger=_,this.config={},this.metas={}}logDebug(...e){this.internalLogger.debug(`${this.name}\n`,...e)}logInfo(...e){this.internalLogger.info(`${this.name}\n`,...e)}logWarn(...e){this.internalLogger.warn(`${this.name}\n`,...e)}logError(...e){this.internalLogger.error(`${this.name}\n`,...e)}}function z(e,n){var t,r;if(void 0===n)return e;if(void 0===e)return{resourceSpans:n};const i=null===(t=e.resourceSpans)||void 0===t?void 0:t[0];if(void 0===i)return e;const a=(null==i?void 0:i.scopeSpans)||[],s=(null===(r=null==n?void 0:n[0])||void 0===r?void 0:r.scopeSpans)||[];return Object.assign(Object.assign({},e),{resourceSpans:[Object.assign(Object.assign({},i),{scopeSpans:[...a,...s]})]})}const U="Error";let K;function W(e){let n=e.cause;return g(n)?n=e.cause.toString():null!==n&&(o(e.cause)||l(e.cause))?n=N(e.cause):null!=n&&(n=e.cause.toString()),null==n?{}:{cause:n}}const H=e=>e.map((e=>{try{return String(e)}catch(e){return""}})).join(" ");function X(n,t,r,s,o){t.debug("Initializing API");const u=function(n,t,r,i,a){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 r={type:e.TransportItemType.TRACE,payload:n,meta:i.value};t.debug("Pushing trace\n",r),a.execute(r)}catch(e){t.error("Error pushing trace\n",e)}}}}(0,t,0,s,o);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},u),function(n,t,r,a,s,o){var u;t.debug("Initializing exceptions API");let l=null;K=null!==(u=r.parseStacktrace)&&void 0!==u?u:K;const c=e=>{t.debug("Changing stacktrace parser"),K=null!=e?e:K};return c(r.parseStacktrace),{changeStacktraceParser:c,getStacktraceParser:()=>K,pushError:(n,{skipDedupe:u,stackFrames:c,type:d,context:g,spanContext:p,timestampOverwriteMs:f}={})=>{d=d||n.name||U;const m={meta:a.value,payload:{type:d,value:n.message,timestamp:f?h(f):b(),trace:p?{trace_id:p.traceId,span_id:p.spanId}:o.getTraceContext(),context:j(Object.assign(Object.assign({},W(n)),null!=g?g:{}))},type:e.TransportItemType.EXCEPTION};(null==(c=null!=c?c:n.stack?null==K?void 0:K(n).frames:void 0)?void 0:c.length)&&(m.payload.stacktrace={frames:c});const E={type:m.payload.type,value:m.payload.value,stackTrace:m.payload.stacktrace,context:m.payload.context};u||!r.dedupe||i(l)||!v(E,l)?(l=E,t.debug("Pushing exception\n",m),s.execute(m)):t.debug("Skipping error push because it is the same as the last one\n",m.payload)}}}(0,t,r,s,o,u)),function(e,n,t,r){let i,s,o,u;n.debug("Initializing meta API");const l=e=>{s&&r.remove(s),s={user:e},r.add(s)},c=(e,n)=>{const t=null==n?void 0:n.overrides;i&&r.remove(i),i={session:Object.assign(Object.assign({},m(e)?void 0:e),t?{overrides:t}:{})},r.add(i)},d=()=>r.value.session,g=()=>r.value.page;return{setUser:l,resetUser:l,setSession:c,resetSession:c,getSession:d,setView:(e,n)=>{var t;if((null==n?void 0:n.overrides)&&c(d(),{overrides:n.overrides}),(null===(t=null==o?void 0:o.view)||void 0===t?void 0:t.name)===(null==e?void 0:e.name))return;const i=o;o={view:e},r.add(o),i&&r.remove(i)},getView:()=>r.value.view,setPage:e=>{var n;const t=a(e)?Object.assign(Object.assign({},null!==(n=null==u?void 0:u.page)&&void 0!==n?n:g()),{id:e}):e;u&&r.remove(u),u={page:t},r.add(u)},getPage:g}}(0,t,0,s)),function(n,t,r,a,s,o){var u;t.debug("Initializing logs API");let l=null;const c=null!==(u=r.logArgsSerializer)&&void 0!==u?u:H;return{pushLog:(n,{context:u,level:d,skipDedupe:g,spanContext:p,timestampOverwriteMs:f}={})=>{try{const m={type:e.TransportItemType.LOG,payload:{message:c(n),level:null!=d?d:y,context:j(u),timestamp:f?h(f):b(),trace:p?{trace_id:p.traceId,span_id:p.spanId}:o.getTraceContext()},meta:a.value},E={message:m.payload.message,level:m.payload.level,context:m.payload.context};if(!g&&r.dedupe&&!i(l)&&v(E,l))return void t.debug("Skipping log push because it is the same as the last one\n",m.payload);l=E,t.debug("Pushing log\n",m),s.execute(m)}catch(e){t.error("Error pushing log\n",e)}}}}(0,t,r,s,o,u)),function(n,t,r,a,s,o){t.debug("Initializing measurements API");let u=null;return{pushMeasurement:(n,{skipDedupe:l,context:c,spanContext:d,timestampOverwriteMs:g}={})=>{try{const p={type:e.TransportItemType.MEASUREMENT,payload:Object.assign(Object.assign({},n),{trace:d?{trace_id:d.traceId,span_id:d.spanId}:o.getTraceContext(),timestamp:g?h(g):b(),context:j(c)}),meta:a.value},f={type:p.payload.type,values:p.payload.values,context:p.payload.context};if(!l&&r.dedupe&&!i(u)&&v(f,u))return void t.debug("Skipping measurement push because it is the same as the last one\n",p.payload);u=f,t.debug("Pushing measurement\n",p),s.execute(p)}catch(e){t.error("Error pushing measurement\n",e)}}}}(0,t,r,s,o,u)),function(n,t,r,a,s,o){let u=null;return{pushEvent:(n,l,c,{skipDedupe:d,spanContext:g,timestampOverwriteMs:p}={})=>{try{const f={meta:a.value,payload:{name:n,domain:null!=c?c:r.eventDomain,attributes:j(l),timestamp:p?h(p):b(),trace:g?{trace_id:g.traceId,span_id:g.spanId}:o.getTraceContext()},type:e.TransportItemType.EVENT},m={name:f.payload.name,attributes:f.payload.attributes,domain:f.payload.domain};if(!d&&r.dedupe&&!i(u)&&v(m,u))return void t.debug("Skipping event push because it is the same as the last one\n",f.payload);u=m,t.debug("Pushing event\n",f),s.execute(f)}catch(e){t.error("Error pushing event",e)}}}}(0,t,r,s,o,u))}const J="1.13.3";const q="_faroInternal";function Q(e){e.config.isolate?e.internalLogger.debug("Skipping registering internal Faro instance on global object"):(e.internalLogger.debug("Registering internal Faro instance on global object"),Object.defineProperty(L,q,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function Y(){return q in L}function Z(n,t,r,i,a,s,o){return t.debug("Initializing Faro"),e.faro={api:s,config:r,instrumentations:o,internalLogger:t,metas:i,pause:a.pause,transports:a,unpatchedConsole:n,unpause:a.unpause},Q(e.faro),function(e){if(e.config.preventGlobalExposure)e.internalLogger.debug("Skipping registering public Faro instance in the global scope");else{if(e.internalLogger.debug(`Registering public faro reference in the global scope using "${e.config.globalObjectKey}" key`),e.config.globalObjectKey in L)return void e.internalLogger.warn(`Skipping global registration due to key "${e.config.globalObjectKey}" being used already. Please set "globalObjectKey" to something else or set "preventGlobalExposure" to "true"`);Object.defineProperty(L,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}(e.faro),e.faro}e.faro={};return e.BaseExtension=G,e.BaseInstrumentation=class extends G{constructor(){super(...arguments),this.api={},this.transports={}}},e.BaseTransport=class extends G{isBatched(){return!1}getIgnoreUrls(){return[]}},e.Conventions={EventNames:{CLICK:"click",NAVIGATION:"navigation",SESSION_START:"session_start",VIEW_CHANGED:"view_changed"}},e.EVENT_CLICK="click",e.EVENT_NAVIGATION="navigation",e.EVENT_OVERRIDES_SERVICE_NAME="service_name_override",e.EVENT_ROUTE_CHANGE="route_change",e.EVENT_SESSION_EXTEND="session_extend",e.EVENT_SESSION_RESUME="session_resume",e.EVENT_SESSION_START="session_start",e.EVENT_VIEW_CHANGED="view_changed",e.VERSION=J,e.allLogLevels=I,e.createInternalLogger=V,e.createPromiseBuffer=function(e){const{size:n,concurrency:t}=e,r=[];let i=0;const a=()=>{if(i<t&&r.length){const{producer:e,resolve:n,reject:t}=r.shift();i++,e().then((e=>{i--,a(),n(e)}),(e=>{i--,a(),t(e)}))}};return{add:e=>{if(r.length+i>=n)throw new Error("Task buffer full");return new Promise(((n,t)=>{r.push({producer:e,resolve:n,reject:t}),a()}))}}},e.dateNow=function(){return Date.now()},e.deepEqual=v,e.defaultBatchingConfig={enabled:!0,sendTimeout:250,itemLimit:50},e.defaultErrorArgsSerializer=e=>e.map((e=>o(e)?N(e):String(e))).join(" "),e.defaultExceptionType=U,e.defaultGlobalObjectKey="faro",e.defaultInternalLoggerLevel=P,e.defaultLogArgsSerializer=H,e.defaultLogLevel=y,e.defaultUnpatchedConsole=B,e.genShortID=function(e=10){return Array.from(Array(e)).map((()=>O[Math.floor(59*Math.random())])).join("")},e.getCircularDependencyReplacer=S,e.getCurrentTimestamp=b,e.getInternalFaroFromGlobalObject=function(){return L[q]},e.getTransportBody=function(n){let t={meta:{}};return void 0!==n[0]&&(t.meta=n[0].meta),n.forEach((n=>{switch(n.type){case e.TransportItemType.LOG:case e.TransportItemType.EVENT:case e.TransportItemType.EXCEPTION:case e.TransportItemType.MEASUREMENT:const r=A[n.type],i=t[r];t=Object.assign(Object.assign({},t),{[r]:void 0===i?[n.payload]:[...i,n.payload]});break;case e.TransportItemType.TRACE:t=Object.assign(Object.assign({},t),{traces:z(t.traces,n.payload.resourceSpans)})}})),t},e.globalObject=L,e.initializeFaro=function(e){const n=D(e),t=$(n,e);if(Y()&&!e.isolate)return void t.error('Faro is already registered. Either add instrumentations, transports etc. to the global faro instance or use the "isolate" property');t.debug("Initializing");const r=function(e,n){let t=[],r=[];const i=()=>t.reduce(((e,n)=>Object.assign(e,u(n)?n():n)),{}),a=()=>{if(r.length){const e=i();r.forEach((n=>n(e)))}};return{add:(...e)=>{n.debug("Adding metas\n",e),t.push(...e),a()},remove:(...e)=>{n.debug("Removing metas\n",e),t=t.filter((n=>!e.includes(n))),a()},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 i()}}}(0,t),i=C(n,t,e,r),a=X(0,t,e,r,i),s=function(e,n,t,r,i,a){n.debug("Initializing instrumentations");const s=[];return{add:(...o)=>{n.debug("Adding instrumentations"),o.forEach((o=>{n.debug(`Adding "${o.name}" instrumentation`),s.some((e=>e.name===o.name))?n.warn(`Instrumentation ${o.name} is already added`):(o.unpatchedConsole=e,o.internalLogger=n,o.config=t,o.metas=r,o.transports=i,o.api=a,s.push(o),o.initialize())}))},get instrumentations(){return[...s]},remove:(...e)=>{n.debug("Removing instrumentations"),e.forEach((e=>{var t,r;n.debug(`Removing "${e.name}" instrumentation`);const i=s.reduce(((n,t,r)=>null===n&&t.name===e.name?r:null),null);i?(null===(r=(t=s[i]).destroy)||void 0===r||r.call(t),s.splice(i,1)):n.warn(`Instrumentation "${e.name}" is not added`)}))}}}(n,t,e,r,i,a),o=Z(n,t,e,r,i,a,s);return function(e){var n,t;const r={sdk:{version:J},app:{bundleId:e.config.app.name&&(i=e.config.app.name,null==L?void 0:L[`__faroBundleId_${i}`])}};var i;const a=null===(n=e.config.sessionTracking)||void 0===n?void 0:n.session;a&&e.api.setSession(a),e.config.app&&(r.app=Object.assign(Object.assign({},e.config.app),r.app)),e.config.user&&(r.user=e.config.user),e.config.view&&(r.view=e.config.view),e.metas.add(r,...null!==(t=e.config.metas)&&void 0!==t?t:[])}(o),function(e){e.transports.add(...e.config.transports),e.transports.addBeforeSendHooks(e.config.beforeSend),e.transports.addIgnoreErrorsPatterns(e.config.ignoreErrors)}(o),function(e){e.instrumentations.add(...e.config.instrumentations)}(o),o},e.internalGlobalObjectKey=q,e.isArray=l,e.isBoolean=e=>n(e,"boolean"),e.isDomError=e=>t(e,"DOMError"),e.isDomException=e=>t(e,"DOMException"),e.isElement=e=>p&&r(e,Element),e.isElementDefined=p,e.isEmpty=m,e.isError=g,e.isErrorDefined=d,e.isErrorEvent=e=>t(e,"ErrorEvent"),e.isEvent=e=>c&&r(e,Event),e.isEventDefined=c,e.isFunction=u,e.isInstanceOf=r,e.isInt=e=>s(e)&&Number.isInteger(e),e.isInternalFaroOnGlobalObject=Y,e.isMap=e=>f&&r(e,Map),e.isMapDefined=f,e.isNull=i,e.isNumber=s,e.isObject=o,e.isPrimitive=e=>!o(e)&&!u(e),e.isRegExp=e=>t(e,"RegExp"),e.isString=a,e.isSymbol=e=>n(e,"symbol"),e.isSyntheticEvent=e=>o(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e,e.isThenable=e=>u(null==e?void 0:e.then),e.isToString=t,e.isTypeof=n,e.isUndefined=e=>n(e,"undefined"),e.noop=T,e.setInternalFaroOnGlobalObject=Q,e.stringifyExternalJson=N,e.stringifyObjectValues=j,e.transportItemTypeToBodyKey=A,e.unknownString="unknown",e}({});
|
|
1
|
+
var GrafanaFaroCore=function(e){"use strict";function n(e,n){return typeof e===n}function t(e,n){return Object.prototype.toString.call(e)===`[object ${n}]`}function r(e,n){try{return e instanceof n}catch(e){return!1}}const i=e=>n(e,"null"),a=e=>n(e,"string"),s=e=>n(e,"number")&&!isNaN(e)||n(e,"bigint"),o=e=>!i(e)&&n(e,"object"),l=e=>n(e,"function"),u=e=>t(e,"Array"),c="undefined"!=typeof Event,d="undefined"!=typeof Error,g=e=>d&&r(e,Error),p="undefined"!=typeof Element,f="undefined"!=typeof Map;function m(e){return null==e||(u(e)||a(e)?0===e.length:!!o(e)&&0===Object.keys(e).length)}function v(e,t){if(e===t)return!0;if(n(e,"number")&&isNaN(e))return n(t,"number")&&isNaN(t);const r=u(e),i=u(t);if(r!==i)return!1;if(r&&i){const n=e.length;if(n!==t.length)return!1;for(let r=n;0!=r--;)if(!v(e[r],t[r]))return!1;return!0}const a=o(e),s=o(t);if(a!==s)return!1;if(e&&t&&a&&s){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;for(let r of n)if(!v(e[r],t[r]))return!1;return!0}return!1}function b(){return(new Date).toISOString()}function h(e){return new Date(e).toISOString()}var E;e.LogLevel=void 0,(E=e.LogLevel||(e.LogLevel={})).TRACE="trace",E.DEBUG="debug",E.INFO="info",E.LOG="log",E.WARN="warn",E.ERROR="error";const y=e.LogLevel.LOG,I=[e.LogLevel.TRACE,e.LogLevel.DEBUG,e.LogLevel.INFO,e.LogLevel.LOG,e.LogLevel.WARN,e.LogLevel.ERROR];function T(){}const O="abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789";const L="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:void 0;function S(){const e=new WeakSet;return function(n,t){if(o(t)&&null!==t){if(e.has(t))return null;e.add(t)}return t}}function N(e={}){return JSON.stringify(null!=e?e:{},S())}function j(e={}){const n={};for(const[t,r]of Object.entries(e))n[t]=o(r)&&null!==r?N(r):String(r);return n}class R{constructor(e,n){var t,r;this.signalBuffer=[],this.itemLimit=null!==(t=null==n?void 0:n.itemLimit)&&void 0!==t?t:50,this.sendTimeout=null!==(r=null==n?void 0:n.sendTimeout)&&void 0!==r?r:250,this.paused=(null==n?void 0:n.paused)||!1,this.sendFn=e,this.flushInterval=-1,this.paused||this.start(),document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&this.flush()}))}addItem(e){this.paused||(this.signalBuffer.push(e),this.signalBuffer.length>=this.itemLimit&&this.flush())}start(){this.paused=!1,this.sendTimeout>0&&(this.flushInterval=window.setInterval((()=>this.flush()),this.sendTimeout))}pause(){this.paused=!0,clearInterval(this.flushInterval)}groupItems(e){const n=new Map;return e.forEach((e=>{const t=JSON.stringify(e.meta);let r=n.get(t);r=void 0===r?[e]:[...r,e],n.set(t,r)})),Array.from(n.values())}flush(){if(this.paused||0===this.signalBuffer.length)return;this.groupItems(this.signalBuffer).forEach(this.sendFn),this.signalBuffer=[]}}var x;e.TransportItemType=void 0,(x=e.TransportItemType||(e.TransportItemType={})).EXCEPTION="exception",x.LOG="log",x.MEASUREMENT="measurement",x.TRACE="trace",x.EVENT="event";const A={[e.TransportItemType.EXCEPTION]:"exceptions",[e.TransportItemType.LOG]:"logs",[e.TransportItemType.MEASUREMENT]:"measurements",[e.TransportItemType.TRACE]:"traces",[e.TransportItemType.EVENT]:"events"};function w(n){return t=>{if(t.type===e.TransportItemType.EXCEPTION&&t.payload){const e=t.payload,r=`${e.type}: ${e.value}`;if(function(e,n){return e.some((e=>a(e)?n.includes(e):!!n.match(e)))}(n,r))return null}return t}}function C(e,n,t,r){var i;n.debug("Initializing transports");const a=[];let s=t.paused,o=[];const l=e=>{let n=e;for(const e of o){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 a)n.debug(`Transporting item using ${e.name}\n`,t),e.isBatched()&&e.send(t)};let c;(null===(i=t.batching)||void 0===i?void 0:i.enabled)&&(c=new R(u,{sendTimeout:t.batching.sendTimeout,itemLimit:t.batching.itemLimit,paused:s}));return{add:(...i)=>{n.debug("Adding transports"),i.forEach((i=>{n.debug(`Adding "${i.name}" transport`);a.some((e=>e===i))?n.warn(`Transport ${i.name} is already added`):(i.unpatchedConsole=e,i.internalLogger=n,i.config=t,i.metas=r,a.push(i))}))},addBeforeSendHooks:(...e)=>{n.debug("Adding beforeSendHooks\n",o),e.forEach((e=>{e&&o.push(e)}))},addIgnoreErrorsPatterns:(...e)=>{n.debug("Adding ignoreErrorsPatterns\n",e),e.forEach((e=>{e&&o.push(w(e))}))},getBeforeSendHooks:()=>[...o],execute:e=>{var r;s||((null===(r=t.batching)||void 0===r?void 0:r.enabled)&&(null==c||c.addItem(e)),(e=>{var r,i;if((null===(r=t.batching)||void 0===r?void 0:r.enabled)&&a.every((e=>e.isBatched())))return;const[s]=l([e]);if(void 0!==s)for(const e of a)n.debug(`Transporting item using ${e.name}\n`,s),e.isBatched()?(null===(i=t.batching)||void 0===i?void 0:i.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=a.indexOf(e);-1!==t?a.splice(t,1):n.warn(`Transport "${e.name}" is not added`)}))},removeBeforeSendHooks:(...e)=>{o.filter((n=>!e.includes(n)))},get transports(){return[...a]},unpause:()=>{n.debug("Unpausing transports"),null==c||c.start(),s=!1}}}var k;e.InternalLoggerLevel=void 0,(k=e.InternalLoggerLevel||(e.InternalLoggerLevel={}))[k.OFF=0]="OFF",k[k.ERROR=1]="ERROR",k[k.WARN=2]="WARN",k[k.INFO=3]="INFO",k[k.VERBOSE=4]="VERBOSE";const _={debug:T,error:T,info:T,prefix:"Faro",warn:T},P=e.InternalLoggerLevel.ERROR,B=Object.assign({},console);let F=B;function D(e){var n;return F=null!==(n=e.unpatchedConsole)&&void 0!==n?n:F,F}function V(n=B,t=P){const r=_;return t>e.InternalLoggerLevel.OFF&&(r.error=t>=e.InternalLoggerLevel.ERROR?function(...e){n.error(`${r.prefix}\n`,...e)}:T,r.warn=t>=e.InternalLoggerLevel.WARN?function(...e){n.warn(`${r.prefix}\n`,...e)}:T,r.info=t>=e.InternalLoggerLevel.INFO?function(...e){n.info(`${r.prefix}\n`,...e)}:T,r.debug=t>=e.InternalLoggerLevel.VERBOSE?function(...e){n.debug(`${r.prefix}\n`,...e)}:T),r}let M=_;function $(e,n){return M=V(e,n.internalLoggerLevel),M}class G{constructor(){this.unpatchedConsole=B,this.internalLogger=_,this.config={},this.metas={}}logDebug(...e){this.internalLogger.debug(`${this.name}\n`,...e)}logInfo(...e){this.internalLogger.info(`${this.name}\n`,...e)}logWarn(...e){this.internalLogger.warn(`${this.name}\n`,...e)}logError(...e){this.internalLogger.error(`${this.name}\n`,...e)}}function z(e,n){var t,r;if(void 0===n)return e;if(void 0===e)return{resourceSpans:n};const i=null===(t=e.resourceSpans)||void 0===t?void 0:t[0];if(void 0===i)return e;const a=(null==i?void 0:i.scopeSpans)||[],s=(null===(r=null==n?void 0:n[0])||void 0===r?void 0:r.scopeSpans)||[];return Object.assign(Object.assign({},e),{resourceSpans:[Object.assign(Object.assign({},i),{scopeSpans:[...a,...s]})]})}const U="Error";let K;function W(e){let n=e.cause;return g(n)?n=e.cause.toString():null!==n&&(o(e.cause)||u(e.cause))?n=N(e.cause):null!=n&&(n=e.cause.toString()),null==n?{}:{cause:n}}const H=e=>e.map((e=>{try{return String(e)}catch(e){return""}})).join(" ");function X(n,t,r,s,o){t.debug("Initializing API");const l=function(n,t,r,i,a){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 r={type:e.TransportItemType.TRACE,payload:n,meta:i.value};t.debug("Pushing trace\n",r),a.execute(r)}catch(e){t.error("Error pushing trace\n",e)}}}}(0,t,0,s,o);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},l),function(n,t,r,a,s,o){var l;t.debug("Initializing exceptions API");let u=null;K=null!==(l=r.parseStacktrace)&&void 0!==l?l:K;const c=e=>{t.debug("Changing stacktrace parser"),K=null!=e?e:K};return c(r.parseStacktrace),{changeStacktraceParser:c,getStacktraceParser:()=>K,pushError:(n,{skipDedupe:l,stackFrames:c,type:d,context:g,spanContext:p,timestampOverwriteMs:f}={})=>{d=d||n.name||U;const m={meta:a.value,payload:{type:d,value:n.message,timestamp:f?h(f):b(),trace:p?{trace_id:p.traceId,span_id:p.spanId}:o.getTraceContext(),context:j(Object.assign(Object.assign({},W(n)),null!=g?g:{}))},type:e.TransportItemType.EXCEPTION};(null==(c=null!=c?c:n.stack?null==K?void 0:K(n).frames:void 0)?void 0:c.length)&&(m.payload.stacktrace={frames:c});const E={type:m.payload.type,value:m.payload.value,stackTrace:m.payload.stacktrace,context:m.payload.context};l||!r.dedupe||i(u)||!v(E,u)?(u=E,t.debug("Pushing exception\n",m),s.execute(m)):t.debug("Skipping error push because it is the same as the last one\n",m.payload)}}}(0,t,r,s,o,l)),function(e,n,t,r){let i,s,o,l;n.debug("Initializing meta API");const u=e=>{s&&r.remove(s),s={user:e},r.add(s)},c=(e,n)=>{var t;const a=null==n?void 0:n.overrides,s=a?{overrides:Object.assign(Object.assign({},null===(t=null==i?void 0:i.session)||void 0===t?void 0:t.overrides),a)}:{};i&&r.remove(i),i={session:Object.assign(Object.assign({},m(e)?void 0:e),s)},r.add(i)},d=()=>r.value.session,g=()=>r.value.page;return{setUser:u,resetUser:u,setSession:c,resetSession:c,getSession:d,setView:(e,n)=>{var t;if((null==n?void 0:n.overrides)&&c(d(),{overrides:n.overrides}),(null===(t=null==o?void 0:o.view)||void 0===t?void 0:t.name)===(null==e?void 0:e.name))return;const i=o;o={view:e},r.add(o),i&&r.remove(i)},getView:()=>r.value.view,setPage:e=>{var n;const t=a(e)?Object.assign(Object.assign({},null!==(n=null==l?void 0:l.page)&&void 0!==n?n:g()),{id:e}):e;l&&r.remove(l),l={page:t},r.add(l)},getPage:g}}(0,t,0,s)),function(n,t,r,a,s,o){var l;t.debug("Initializing logs API");let u=null;const c=null!==(l=r.logArgsSerializer)&&void 0!==l?l:H;return{pushLog:(n,{context:l,level:d,skipDedupe:g,spanContext:p,timestampOverwriteMs:f}={})=>{try{const m={type:e.TransportItemType.LOG,payload:{message:c(n),level:null!=d?d:y,context:j(l),timestamp:f?h(f):b(),trace:p?{trace_id:p.traceId,span_id:p.spanId}:o.getTraceContext()},meta:a.value},E={message:m.payload.message,level:m.payload.level,context:m.payload.context};if(!g&&r.dedupe&&!i(u)&&v(E,u))return void t.debug("Skipping log push because it is the same as the last one\n",m.payload);u=E,t.debug("Pushing log\n",m),s.execute(m)}catch(e){t.error("Error pushing log\n",e)}}}}(0,t,r,s,o,l)),function(n,t,r,a,s,o){t.debug("Initializing measurements API");let l=null;return{pushMeasurement:(n,{skipDedupe:u,context:c,spanContext:d,timestampOverwriteMs:g}={})=>{try{const p={type:e.TransportItemType.MEASUREMENT,payload:Object.assign(Object.assign({},n),{trace:d?{trace_id:d.traceId,span_id:d.spanId}:o.getTraceContext(),timestamp:g?h(g):b(),context:j(c)}),meta:a.value},f={type:p.payload.type,values:p.payload.values,context:p.payload.context};if(!u&&r.dedupe&&!i(l)&&v(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,r,s,o,l)),function(n,t,r,a,s,o){let l=null;return{pushEvent:(n,u,c,{skipDedupe:d,spanContext:g,timestampOverwriteMs:p}={})=>{try{const f={meta:a.value,payload:{name:n,domain:null!=c?c:r.eventDomain,attributes:j(u),timestamp:p?h(p):b(),trace:g?{trace_id:g.traceId,span_id:g.spanId}:o.getTraceContext()},type:e.TransportItemType.EVENT},m={name:f.payload.name,attributes:f.payload.attributes,domain:f.payload.domain};if(!d&&r.dedupe&&!i(l)&&v(m,l))return void t.debug("Skipping event push because it is the same as the last one\n",f.payload);l=m,t.debug("Pushing event\n",f),s.execute(f)}catch(e){t.error("Error pushing event",e)}}}}(0,t,r,s,o,l))}const J="1.14.0";const q="_faroInternal";function Q(e){e.config.isolate?e.internalLogger.debug("Skipping registering internal Faro instance on global object"):(e.internalLogger.debug("Registering internal Faro instance on global object"),Object.defineProperty(L,q,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function Y(){return q in L}function Z(n,t,r,i,a,s,o){return t.debug("Initializing Faro"),e.faro={api:s,config:r,instrumentations:o,internalLogger:t,metas:i,pause:a.pause,transports:a,unpatchedConsole:n,unpause:a.unpause},Q(e.faro),function(e){if(e.config.preventGlobalExposure)e.internalLogger.debug("Skipping registering public Faro instance in the global scope");else{if(e.internalLogger.debug(`Registering public faro reference in the global scope using "${e.config.globalObjectKey}" key`),e.config.globalObjectKey in L)return void e.internalLogger.warn(`Skipping global registration due to key "${e.config.globalObjectKey}" being used already. Please set "globalObjectKey" to something else or set "preventGlobalExposure" to "true"`);Object.defineProperty(L,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}(e.faro),e.faro}e.faro={};return e.BaseExtension=G,e.BaseInstrumentation=class extends G{constructor(){super(...arguments),this.api={},this.transports={}}},e.BaseTransport=class extends G{isBatched(){return!1}getIgnoreUrls(){return[]}},e.Conventions={EventNames:{CLICK:"click",NAVIGATION:"navigation",SESSION_START:"session_start",VIEW_CHANGED:"view_changed"}},e.EVENT_CLICK="click",e.EVENT_NAVIGATION="navigation",e.EVENT_OVERRIDES_SERVICE_NAME="service_name_override",e.EVENT_ROUTE_CHANGE="route_change",e.EVENT_SESSION_EXTEND="session_extend",e.EVENT_SESSION_RESUME="session_resume",e.EVENT_SESSION_START="session_start",e.EVENT_VIEW_CHANGED="view_changed",e.VERSION=J,e.allLogLevels=I,e.createInternalLogger=V,e.createPromiseBuffer=function(e){const{size:n,concurrency:t}=e,r=[];let i=0;const a=()=>{if(i<t&&r.length){const{producer:e,resolve:n,reject:t}=r.shift();i++,e().then((e=>{i--,a(),n(e)}),(e=>{i--,a(),t(e)}))}};return{add:e=>{if(r.length+i>=n)throw new Error("Task buffer full");return new Promise(((n,t)=>{r.push({producer:e,resolve:n,reject:t}),a()}))}}},e.dateNow=function(){return Date.now()},e.deepEqual=v,e.defaultBatchingConfig={enabled:!0,sendTimeout:250,itemLimit:50},e.defaultErrorArgsSerializer=e=>e.map((e=>o(e)?N(e):String(e))).join(" "),e.defaultExceptionType=U,e.defaultGlobalObjectKey="faro",e.defaultInternalLoggerLevel=P,e.defaultLogArgsSerializer=H,e.defaultLogLevel=y,e.defaultUnpatchedConsole=B,e.genShortID=function(e=10){return Array.from(Array(e)).map((()=>O[Math.floor(59*Math.random())])).join("")},e.getCircularDependencyReplacer=S,e.getCurrentTimestamp=b,e.getInternalFaroFromGlobalObject=function(){return L[q]},e.getTransportBody=function(n){let t={meta:{}};return void 0!==n[0]&&(t.meta=n[0].meta),n.forEach((n=>{switch(n.type){case e.TransportItemType.LOG:case e.TransportItemType.EVENT:case e.TransportItemType.EXCEPTION:case e.TransportItemType.MEASUREMENT:const r=A[n.type],i=t[r];t=Object.assign(Object.assign({},t),{[r]:void 0===i?[n.payload]:[...i,n.payload]});break;case e.TransportItemType.TRACE:t=Object.assign(Object.assign({},t),{traces:z(t.traces,n.payload.resourceSpans)})}})),t},e.globalObject=L,e.initializeFaro=function(e){const n=D(e),t=$(n,e);if(Y()&&!e.isolate)return void t.error('Faro is already registered. Either add instrumentations, transports etc. to the global faro instance or use the "isolate" property');t.debug("Initializing");const r=function(e,n){let t=[],r=[];const i=()=>t.reduce(((e,n)=>Object.assign(e,l(n)?n():n)),{}),a=()=>{if(r.length){const e=i();r.forEach((n=>n(e)))}};return{add:(...e)=>{n.debug("Adding metas\n",e),t.push(...e),a()},remove:(...e)=>{n.debug("Removing metas\n",e),t=t.filter((n=>!e.includes(n))),a()},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 i()}}}(0,t),i=C(n,t,e,r),a=X(0,t,e,r,i),s=function(e,n,t,r,i,a){n.debug("Initializing instrumentations");const s=[];return{add:(...o)=>{n.debug("Adding instrumentations"),o.forEach((o=>{n.debug(`Adding "${o.name}" instrumentation`),s.some((e=>e.name===o.name))?n.warn(`Instrumentation ${o.name} is already added`):(o.unpatchedConsole=e,o.internalLogger=n,o.config=t,o.metas=r,o.transports=i,o.api=a,s.push(o),o.initialize())}))},get instrumentations(){return[...s]},remove:(...e)=>{n.debug("Removing instrumentations"),e.forEach((e=>{var t,r;n.debug(`Removing "${e.name}" instrumentation`);const i=s.reduce(((n,t,r)=>null===n&&t.name===e.name?r:null),null);i?(null===(r=(t=s[i]).destroy)||void 0===r||r.call(t),s.splice(i,1)):n.warn(`Instrumentation "${e.name}" is not added`)}))}}}(n,t,e,r,i,a),o=Z(n,t,e,r,i,a,s);return function(e){var n,t;const r={sdk:{version:J},app:{bundleId:e.config.app.name&&(i=e.config.app.name,null==L?void 0:L[`__faroBundleId_${i}`])}};var i;const a=null===(n=e.config.sessionTracking)||void 0===n?void 0:n.session;a&&e.api.setSession(a),e.config.app&&(r.app=Object.assign(Object.assign({},e.config.app),r.app)),e.config.user&&(r.user=e.config.user),e.config.view&&(r.view=e.config.view),e.metas.add(r,...null!==(t=e.config.metas)&&void 0!==t?t:[])}(o),function(e){e.transports.add(...e.config.transports),e.transports.addBeforeSendHooks(e.config.beforeSend),e.transports.addIgnoreErrorsPatterns(e.config.ignoreErrors)}(o),function(e){e.instrumentations.add(...e.config.instrumentations)}(o),o},e.internalGlobalObjectKey=q,e.isArray=u,e.isBoolean=e=>n(e,"boolean"),e.isDomError=e=>t(e,"DOMError"),e.isDomException=e=>t(e,"DOMException"),e.isElement=e=>p&&r(e,Element),e.isElementDefined=p,e.isEmpty=m,e.isError=g,e.isErrorDefined=d,e.isErrorEvent=e=>t(e,"ErrorEvent"),e.isEvent=e=>c&&r(e,Event),e.isEventDefined=c,e.isFunction=l,e.isInstanceOf=r,e.isInt=e=>s(e)&&Number.isInteger(e),e.isInternalFaroOnGlobalObject=Y,e.isMap=e=>f&&r(e,Map),e.isMapDefined=f,e.isNull=i,e.isNumber=s,e.isObject=o,e.isPrimitive=e=>!o(e)&&!l(e),e.isRegExp=e=>t(e,"RegExp"),e.isString=a,e.isSymbol=e=>n(e,"symbol"),e.isSyntheticEvent=e=>o(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e,e.isThenable=e=>l(null==e?void 0:e.then),e.isToString=t,e.isTypeof=n,e.isUndefined=e=>n(e,"undefined"),e.noop=T,e.setInternalFaroOnGlobalObject=Q,e.stringifyExternalJson=N,e.stringifyObjectValues=j,e.transportItemTypeToBodyKey=A,e.unknownString="unknown",e}({});
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import type { MetaOverrides, MetaPage, MetaSession, MetaUser, MetaView } from '../../metas';
|
|
2
|
+
type OverridesAvailableThroughApi = Pick<MetaOverrides, 'serviceName'>;
|
|
2
3
|
export interface MetaAPI {
|
|
3
4
|
setUser: (user?: MetaUser | undefined) => void;
|
|
4
5
|
resetUser: () => void;
|
|
5
6
|
setSession: (session?: MetaSession | undefined, options?: {
|
|
6
|
-
overrides:
|
|
7
|
+
overrides: OverridesAvailableThroughApi;
|
|
7
8
|
}) => void;
|
|
8
9
|
resetSession: () => void;
|
|
9
10
|
getSession: () => MetaSession | undefined;
|
|
10
11
|
setView: (view?: MetaView | undefined, options?: {
|
|
11
|
-
overrides:
|
|
12
|
+
overrides: OverridesAvailableThroughApi;
|
|
12
13
|
}) => void;
|
|
13
14
|
getView: () => MetaView | undefined;
|
|
14
15
|
/**
|
|
15
16
|
* If a string is provided, it will be used as the page id.
|
|
16
|
-
* @returns
|
|
17
17
|
*/
|
|
18
18
|
setPage: (page?: MetaPage | string | undefined) => void;
|
|
19
19
|
getPage: () => MetaPage | undefined;
|
|
20
20
|
}
|
|
21
|
+
export {};
|
|
@@ -138,12 +138,28 @@ export interface Config<P = APIEvent> {
|
|
|
138
138
|
* Track web vitals attribution data (default: false)
|
|
139
139
|
*/
|
|
140
140
|
trackWebVitalsAttribution?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Configuration for the web vitals instrumentation
|
|
143
|
+
*/
|
|
144
|
+
webVitalsInstrumentation?: {
|
|
145
|
+
/**
|
|
146
|
+
* Report all changes for web vitals (default: false)
|
|
147
|
+
*
|
|
148
|
+
* In most cases, you only want the callback function to be called when the metric is ready to be reported.
|
|
149
|
+
* However, it is possible to report every change (e.g. each larger layout shift as it happens)
|
|
150
|
+
* by setting reportAllChanges to true.
|
|
151
|
+
*
|
|
152
|
+
* This can be useful when debugging, but in general using reportAllChanges is not needed (or recommended)
|
|
153
|
+
* for measuring these metrics in production.
|
|
154
|
+
*/
|
|
155
|
+
reportAllChanges?: boolean;
|
|
156
|
+
};
|
|
141
157
|
/**
|
|
142
158
|
* Configuration for the console instrumentation
|
|
143
159
|
*/
|
|
144
160
|
consoleInstrumentation?: {
|
|
145
161
|
/**
|
|
146
|
-
* Configure what console levels should be captured by Faro. By default the
|
|
162
|
+
* Configure what console levels should be captured by Faro. By default the following levels
|
|
147
163
|
* are disabled: console.debug, console.trace, console.log
|
|
148
164
|
*
|
|
149
165
|
* If you want to collect all levels set captureConsoleDisabledLevels: [];
|
|
@@ -162,6 +178,9 @@ export interface Config<P = APIEvent> {
|
|
|
162
178
|
*/
|
|
163
179
|
errorSerializer?: LogArgsSerializer;
|
|
164
180
|
};
|
|
181
|
+
/**
|
|
182
|
+
* Configuration for the page tracking
|
|
183
|
+
*/
|
|
165
184
|
pageTracking?: {
|
|
166
185
|
/**
|
|
167
186
|
* The page meta for initial page settings
|
|
@@ -172,6 +191,19 @@ export interface Config<P = APIEvent> {
|
|
|
172
191
|
*/
|
|
173
192
|
generatePageId?: (location: Location) => string;
|
|
174
193
|
};
|
|
194
|
+
/**
|
|
195
|
+
* Configuration for the location tracking (Grafana cloud only)
|
|
196
|
+
*/
|
|
197
|
+
geoLocationTracking?: {
|
|
198
|
+
/**
|
|
199
|
+
* Enable or disable geolocation tracking.
|
|
200
|
+
* Geolocation tracking must be enabled in the Grafana Cloud settings first.
|
|
201
|
+
* It cannot be enabled solely on the client side.
|
|
202
|
+
* This option allows control over tracking on the client side to comply with user
|
|
203
|
+
* privacy requirements.
|
|
204
|
+
*/
|
|
205
|
+
enabled?: boolean;
|
|
206
|
+
};
|
|
175
207
|
}
|
|
176
208
|
export type Patterns = Array<string | RegExp>;
|
|
177
209
|
export {};
|
|
@@ -27,9 +27,33 @@ export interface MetaApp {
|
|
|
27
27
|
bundleId?: string;
|
|
28
28
|
}
|
|
29
29
|
export interface MetaUser {
|
|
30
|
+
/**
|
|
31
|
+
* User email address.
|
|
32
|
+
*/
|
|
30
33
|
email?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Unique identifier
|
|
36
|
+
*/
|
|
31
37
|
id?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Short name or login/username of the user.
|
|
40
|
+
*/
|
|
32
41
|
username?: string;
|
|
42
|
+
/**
|
|
43
|
+
* User’s full name
|
|
44
|
+
*/
|
|
45
|
+
fullName?: string;
|
|
46
|
+
/**
|
|
47
|
+
* comma separated list of user roles. "admin",editor" etc.
|
|
48
|
+
*/
|
|
49
|
+
roles?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Unique user hash to correlate information for a user in anonymized form.
|
|
52
|
+
*/
|
|
53
|
+
hash?: string;
|
|
54
|
+
/**
|
|
55
|
+
* arbitrary user attributes, must be of type string.
|
|
56
|
+
*/
|
|
33
57
|
attributes?: MetaAttributes;
|
|
34
58
|
}
|
|
35
59
|
export interface MetaSession {
|
|
@@ -75,9 +99,20 @@ export interface Meta {
|
|
|
75
99
|
k6?: MetaK6;
|
|
76
100
|
}
|
|
77
101
|
/**
|
|
78
|
-
*
|
|
102
|
+
* MetaOverrides are instructions that allow the receiver to override certain properties (Grafana Cloud only).
|
|
79
103
|
*/
|
|
80
104
|
export type MetaOverrides = {
|
|
105
|
+
/**
|
|
106
|
+
* New service name (Grafana Cloud only)
|
|
107
|
+
*/
|
|
81
108
|
serviceName?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Enable or disable geolocation tracking (Grafana Cloud only).
|
|
111
|
+
* Geolocation tracking must be enabled in the Grafana Cloud settings first.
|
|
112
|
+
* It cannot be enabled solely on the client side.
|
|
113
|
+
* This option allows control over tracking on the client side to comply with user
|
|
114
|
+
* privacy requirements.
|
|
115
|
+
*/
|
|
116
|
+
geoLocationTrackingEnabled?: boolean;
|
|
82
117
|
};
|
|
83
118
|
export {};
|
|
@@ -4,7 +4,7 @@ import type { Transport, TransportItem } from '../transports';
|
|
|
4
4
|
export declare class MockTransport extends BaseTransport implements Transport {
|
|
5
5
|
private ignoreURLs;
|
|
6
6
|
readonly name = "@grafana/transport-mock";
|
|
7
|
-
readonly version = "1.
|
|
7
|
+
readonly version = "1.14.0";
|
|
8
8
|
items: TransportItem[];
|
|
9
9
|
constructor(ignoreURLs?: Patterns);
|
|
10
10
|
send(items: TransportItem[]): void | Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.14.0";
|
|
@@ -29,12 +29,18 @@ function initializeMetaAPI(_unpatchedConsole, internalLogger, _config, metas, _t
|
|
|
29
29
|
metas.add(metaUser);
|
|
30
30
|
};
|
|
31
31
|
var setSession = function (session, options) {
|
|
32
|
-
var
|
|
32
|
+
var _a;
|
|
33
|
+
var newOverrides = options === null || options === void 0 ? void 0 : options.overrides;
|
|
34
|
+
var overrides = newOverrides
|
|
35
|
+
? {
|
|
36
|
+
overrides: __assign(__assign({}, (_a = metaSession === null || metaSession === void 0 ? void 0 : metaSession.session) === null || _a === void 0 ? void 0 : _a.overrides), newOverrides),
|
|
37
|
+
}
|
|
38
|
+
: {};
|
|
33
39
|
if (metaSession) {
|
|
34
40
|
metas.remove(metaSession);
|
|
35
41
|
}
|
|
36
42
|
metaSession = {
|
|
37
|
-
session: __assign(__assign({}, ((0, is_1.isEmpty)(session) ? undefined : session)),
|
|
43
|
+
session: __assign(__assign({}, ((0, is_1.isEmpty)(session) ? undefined : session)), overrides),
|
|
38
44
|
};
|
|
39
45
|
metas.add(metaSession);
|
|
40
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/meta/initialize.ts"],"names":[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AI,YAAY,EAAE;YAChB,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;SAC5B;IACH,CAAC,CAAC;IAEF,IAAM,OAAO,GAAuB,cAAM,OAAA,KAAK,CAAC,KAAK,CAAC,IAAI,EAAhB,CAAgB,CAAC;IAE3D,IAAM,OAAO,GAAuB,UAAC,IAAI;;QACvC,IAAM,QAAQ,GAAG,IAAA,aAAQ,EAAC,IAAI,CAAC;YAC7B,CAAC,uBAIM,CAAC,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,mCAAI,OAAO,EAAE,CAAC,KAChC,EAAE,EAAE,IAAI,IAEZ,CAAC,CAAC,IAAI,CAAC;QAET,IAAI,QAAQ,EAAE;YACZ,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;SACxB;QAED,QAAQ,GAAG;YACT,IAAI,EAAE,QAAQ;SACf,CAAC;QAEF,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACtB,CAAC,CAAC;IAEF,IAAM,OAAO,GAAuB,cAAM,OAAA,KAAK,CAAC,KAAK,CAAC,IAAI,EAAhB,CAAgB,CAAC;IAE3D,OAAO;QACL,OAAO,SAAA;QACP,SAAS,EAAE,OAA+B;QAC1C,UAAU,YAAA;QACV,YAAY,EAAE,UAAqC;QACnD,UAAU,YAAA;QACV,OAAO,SAAA;QACP,OAAO,SAAA;QACP,OAAO,SAAA;QACP,OAAO,SAAA;KACR,CAAC;AACJ,CAAC;AAjHD,8CAiHC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Meta, Metas } from '../../metas';\nimport type { Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { isEmpty, isString } from '../../utils/is';\n\nimport type { MetaAPI } from './types';\n\nexport function initializeMetaAPI(\n _unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n _config: Config,\n metas: Metas,\n _transports: Transports\n): MetaAPI {\n internalLogger.debug('Initializing meta API');\n\n let metaSession: Partial<Meta> | undefined = undefined;\n let metaUser: Partial<Meta> | undefined = undefined;\n let metaView: Partial<Meta> | undefined = undefined;\n let metaPage: Partial<Meta> | undefined = undefined;\n\n const setUser: MetaAPI['setUser'] = (user) => {\n if (metaUser) {\n metas.remove(metaUser);\n }\n\n metaUser = {\n user,\n };\n\n metas.add(metaUser);\n };\n\n const setSession: MetaAPI['setSession'] = (session, options) => {\n const newOverrides = options?.overrides;\n const overrides = newOverrides\n ? {\n overrides: {\n ...metaSession?.session?.overrides,\n ...newOverrides,\n },\n }\n : {};\n\n if (metaSession) {\n metas.remove(metaSession);\n }\n\n metaSession = {\n session: {\n // if session is undefined, session manager force creates a new session\n ...(isEmpty(session) ? undefined : session),\n ...overrides,\n },\n };\n\n metas.add(metaSession);\n };\n\n const getSession: MetaAPI['getSession'] = () => metas.value.session;\n\n const setView: MetaAPI['setView'] = (view, options) => {\n if (options?.overrides) {\n setSession(getSession(), { overrides: options.overrides });\n }\n\n if (metaView?.view?.name === view?.name) {\n return;\n }\n\n const previousView = metaView;\n\n metaView = {\n view,\n };\n\n metas.add(metaView);\n\n if (previousView) {\n metas.remove(previousView);\n }\n };\n\n const getView: MetaAPI['getView'] = () => metas.value.view;\n\n const setPage: MetaAPI['setPage'] = (page) => {\n const pageMeta = isString(page)\n ? {\n // metaPage is available once setPage() has been called.\n // This is because page self updating metas like page need to be added as a function\n // Thus we call getPage in case metaPage is empty\n ...(metaPage?.page ?? getPage()),\n id: page,\n }\n : page;\n\n if (metaPage) {\n metas.remove(metaPage);\n }\n\n metaPage = {\n page: pageMeta,\n };\n\n metas.add(metaPage);\n };\n\n const getPage: MetaAPI['getPage'] = () => metas.value.page;\n\n return {\n setUser,\n resetUser: setUser as MetaAPI['resetUser'],\n setSession,\n resetSession: setSession as MetaAPI['resetSession'],\n getSession,\n setView,\n getView,\n setPage,\n getPage,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/meta/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { MetaOverrides, MetaPage, MetaSession, MetaUser, MetaView } from '../../metas';\n\nexport interface MetaAPI {\n setUser: (user?: MetaUser | undefined) => void;\n resetUser: () => void;\n setSession: (\n session?: MetaSession | undefined,\n options?: {\n overrides:
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/meta/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { MetaOverrides, MetaPage, MetaSession, MetaUser, MetaView } from '../../metas';\n\ntype OverridesAvailableThroughApi = Pick<MetaOverrides, 'serviceName'>;\n\nexport interface MetaAPI {\n setUser: (user?: MetaUser | undefined) => void;\n resetUser: () => void;\n setSession: (\n session?: MetaSession | undefined,\n options?: {\n overrides: OverridesAvailableThroughApi;\n }\n ) => void;\n resetSession: () => void;\n getSession: () => MetaSession | undefined;\n setView: (\n view?: MetaView | undefined,\n options?: {\n overrides: OverridesAvailableThroughApi;\n }\n ) => void;\n getView: () => MetaView | undefined;\n /**\n * If a string is provided, it will be used as the page id.\n */\n setPage: (page?: MetaPage | string | undefined) => void;\n getPage: () => MetaPage | undefined;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { APIEvent, LogArgsSerializer, StacktraceParser } from '../api';\nimport type { Instrumentation } from '../instrumentations';\nimport type { InternalLoggerLevel } from '../internalLogger';\nimport type { Meta, MetaApp, MetaItem, MetaPage, MetaSession, MetaUser, MetaView } from '../metas';\nimport type { BatchExecutorOptions, BeforeSendHook, Transport } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\nimport type { LogLevel } from '../utils';\n\ntype SamplingContext = {\n metas: Meta;\n};\n\nexport interface Config<P = APIEvent> {\n /**\n * Application metadata\n */\n app: MetaApp;\n\n /**\n * Set max number and max interval for signals to be batched before sending\n */\n batching?: BatchExecutorOptions;\n\n /**\n * A flag for toggling deduplication for signals\n */\n dedupe: boolean;\n\n /**\n * The key (name) to use for the global Faro object (default: 'faro')\n */\n globalObjectKey: string;\n\n /**\n * The (custom) instrumentations to use with Faro\n */\n instrumentations: Instrumentation[];\n\n /**\n * The level of information printed to console for internal messages (default: LogLevel.ERROR)\n */\n internalLoggerLevel: InternalLoggerLevel;\n\n /**\n * Isolate Faro instance from other Faro instances on the same page. (default: false)\n */\n isolate: boolean;\n\n /**\n * Custom function to serialize log arguments\n */\n logArgsSerializer?: LogArgsSerializer;\n\n /**\n * Add custom Metas during Faro initialization\n */\n metas: MetaItem[];\n\n /**\n * Custom function used to parse stack traces\n */\n parseStacktrace: StacktraceParser;\n\n /**\n * Pause sending data (default: false)\n */\n paused: boolean;\n\n /**\n * Prevent Faro from exposing itself to the global object (default: false)\n */\n preventGlobalExposure: boolean;\n\n /**\n * The transports to use for sending beacons\n */\n transports: Transport[];\n\n /**\n * Some instrumentations might override the default console methods but Faro instance provides a\n * way to access the unmodified console methods.\n *\n * faro.unpatchedConsole.log('This is a log');\n * faro.unpatchedConsole.warn('This is a warning');\n */\n unpatchedConsole: UnpatchedConsole;\n\n /**\n * Function which invoked before pushing event to transport. Can be used to modify or filter events\n */\n beforeSend?: BeforeSendHook<P>;\n\n /**\n * Error message patterns for errors that should be ignored\n */\n ignoreErrors?: Patterns;\n\n /**\n * Path patterns for Endpoints that should be ignored form being tracked\n */\n ignoreUrls?: Patterns;\n\n /**\n * Configuration for the built in session tracker\n */\n sessionTracking?: {\n /**\n * Enable session tracking (default: true)\n */\n enabled?: boolean;\n /**\n * Wether to use sticky sessions (default: false)\n */\n persistent?: boolean;\n /**\n * Session metadata object to be used when initializing session tracking\n */\n session?: MetaSession;\n /**\n * How long is a sticky session valid for recurring users (default: 15 minutes)\n */\n maxSessionPersistenceTime?: number;\n /**\n * Called each time a session changes. This can be when a new session is created or when an existing session is updated.\n * @param oldSession\n * @param newSession\n */\n onSessionChange?: (oldSession: MetaSession | null, newSession: MetaSession) => void;\n /**\n * Then sampling rate for the session based sampler (default: 1). If a session is not part of a sample, no signals for this session are tracked.\n */\n samplingRate?: number;\n /**\n * Custom sampler function if custom sampling logic is needed.\n * @param context\n */\n sampler?: (context: SamplingContext) => number;\n /**\n * Custom function to generate session id. If available Faro uses this function instead of the internal one.\n */\n generateSessionId?: () => string;\n };\n\n /**\n * Meta object for user data\n */\n user?: MetaUser;\n\n /**\n * Meta object for view data\n */\n view?: MetaView;\n\n eventDomain?: string;\n\n /**\n * Only resource timings for fetch and xhr requests are tracked by default. Set this to true to track all resources (default: false).\n */\n trackResources?: boolean;\n\n /**\n * Track web vitals attribution data (default: false)\n */\n trackWebVitalsAttribution?: boolean;\n\n /**\n * Configuration for the console instrumentation\n */\n consoleInstrumentation?: {\n /**\n * Configure what console levels should be captured by Faro. By default the
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { APIEvent, LogArgsSerializer, StacktraceParser } from '../api';\nimport type { Instrumentation } from '../instrumentations';\nimport type { InternalLoggerLevel } from '../internalLogger';\nimport type { Meta, MetaApp, MetaItem, MetaPage, MetaSession, MetaUser, MetaView } from '../metas';\nimport type { BatchExecutorOptions, BeforeSendHook, Transport } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\nimport type { LogLevel } from '../utils';\n\ntype SamplingContext = {\n metas: Meta;\n};\n\nexport interface Config<P = APIEvent> {\n /**\n * Application metadata\n */\n app: MetaApp;\n\n /**\n * Set max number and max interval for signals to be batched before sending\n */\n batching?: BatchExecutorOptions;\n\n /**\n * A flag for toggling deduplication for signals\n */\n dedupe: boolean;\n\n /**\n * The key (name) to use for the global Faro object (default: 'faro')\n */\n globalObjectKey: string;\n\n /**\n * The (custom) instrumentations to use with Faro\n */\n instrumentations: Instrumentation[];\n\n /**\n * The level of information printed to console for internal messages (default: LogLevel.ERROR)\n */\n internalLoggerLevel: InternalLoggerLevel;\n\n /**\n * Isolate Faro instance from other Faro instances on the same page. (default: false)\n */\n isolate: boolean;\n\n /**\n * Custom function to serialize log arguments\n */\n logArgsSerializer?: LogArgsSerializer;\n\n /**\n * Add custom Metas during Faro initialization\n */\n metas: MetaItem[];\n\n /**\n * Custom function used to parse stack traces\n */\n parseStacktrace: StacktraceParser;\n\n /**\n * Pause sending data (default: false)\n */\n paused: boolean;\n\n /**\n * Prevent Faro from exposing itself to the global object (default: false)\n */\n preventGlobalExposure: boolean;\n\n /**\n * The transports to use for sending beacons\n */\n transports: Transport[];\n\n /**\n * Some instrumentations might override the default console methods but Faro instance provides a\n * way to access the unmodified console methods.\n *\n * faro.unpatchedConsole.log('This is a log');\n * faro.unpatchedConsole.warn('This is a warning');\n */\n unpatchedConsole: UnpatchedConsole;\n\n /**\n * Function which invoked before pushing event to transport. Can be used to modify or filter events\n */\n beforeSend?: BeforeSendHook<P>;\n\n /**\n * Error message patterns for errors that should be ignored\n */\n ignoreErrors?: Patterns;\n\n /**\n * Path patterns for Endpoints that should be ignored form being tracked\n */\n ignoreUrls?: Patterns;\n\n /**\n * Configuration for the built in session tracker\n */\n sessionTracking?: {\n /**\n * Enable session tracking (default: true)\n */\n enabled?: boolean;\n /**\n * Wether to use sticky sessions (default: false)\n */\n persistent?: boolean;\n /**\n * Session metadata object to be used when initializing session tracking\n */\n session?: MetaSession;\n /**\n * How long is a sticky session valid for recurring users (default: 15 minutes)\n */\n maxSessionPersistenceTime?: number;\n /**\n * Called each time a session changes. This can be when a new session is created or when an existing session is updated.\n * @param oldSession\n * @param newSession\n */\n onSessionChange?: (oldSession: MetaSession | null, newSession: MetaSession) => void;\n /**\n * Then sampling rate for the session based sampler (default: 1). If a session is not part of a sample, no signals for this session are tracked.\n */\n samplingRate?: number;\n /**\n * Custom sampler function if custom sampling logic is needed.\n * @param context\n */\n sampler?: (context: SamplingContext) => number;\n /**\n * Custom function to generate session id. If available Faro uses this function instead of the internal one.\n */\n generateSessionId?: () => string;\n };\n\n /**\n * Meta object for user data\n */\n user?: MetaUser;\n\n /**\n * Meta object for view data\n */\n view?: MetaView;\n\n eventDomain?: string;\n\n /**\n * Only resource timings for fetch and xhr requests are tracked by default. Set this to true to track all resources (default: false).\n */\n trackResources?: boolean;\n\n /**\n * Track web vitals attribution data (default: false)\n */\n trackWebVitalsAttribution?: boolean;\n\n /**\n * Configuration for the web vitals instrumentation\n */\n webVitalsInstrumentation?: {\n /**\n * Report all changes for web vitals (default: false)\n *\n * In most cases, you only want the callback function to be called when the metric is ready to be reported.\n * However, it is possible to report every change (e.g. each larger layout shift as it happens)\n * by setting reportAllChanges to true.\n *\n * This can be useful when debugging, but in general using reportAllChanges is not needed (or recommended)\n * for measuring these metrics in production.\n */\n reportAllChanges?: boolean;\n };\n\n /**\n * Configuration for the console instrumentation\n */\n consoleInstrumentation?: {\n /**\n * Configure what console levels should be captured by Faro. By default the following levels\n * are disabled: console.debug, console.trace, console.log\n *\n * If you want to collect all levels set captureConsoleDisabledLevels: [];\n * If you want to disable only some levels set captureConsoleDisabledLevels: [LogLevel.DEBUG, LogLevel.TRACE];\n */\n disabledLevels?: LogLevel[];\n /*\n * By default, Faro sends an error for console.error calls. If you want to send a log instead, set this to true.\n */\n consoleErrorAsLog?: boolean;\n\n /**\n * If true, use the default Faro error serializer for console.error calls. If false, simply call toString() on the error arguments.\n * If enabled, payloads containing serialized errors may become very large. If left disabled, some error details may be lost.\n * (default: false)\n */\n serializeErrors?: boolean;\n\n /**\n * Custom function to serialize Error arguments\n */\n errorSerializer?: LogArgsSerializer;\n };\n\n /**\n * Configuration for the page tracking\n */\n pageTracking?: {\n /**\n * The page meta for initial page settings\n */\n page?: MetaPage;\n\n /**\n * Allows to provide a template for the page id\n */\n generatePageId?: (location: Location) => string;\n };\n\n /**\n * Configuration for the location tracking (Grafana cloud only)\n */\n geoLocationTracking?: {\n /**\n * Enable or disable geolocation tracking.\n * Geolocation tracking must be enabled in the Grafana Cloud settings first.\n * It cannot be enabled solely on the client side.\n * This option allows control over tracking on the client side to comply with user\n * privacy requirements.\n */\n enabled?: boolean;\n };\n}\n\nexport type Patterns = Array<string | RegExp>;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/metas/types.ts"],"names":[],"mappings":"","sourcesContent":["export type MetaGetter<P = Partial<Meta>> = () => P;\n\nexport type MetaItem<P = Partial<Meta>> = P | MetaGetter<P>;\n\nexport type MetasListener = (value: Meta) => void;\n\nexport interface Metas {\n add: (...getters: MetaItem[]) => void;\n remove: (...getters: MetaItem[]) => void;\n addListener: (listener: MetasListener) => void;\n removeListener: (listener: MetasListener) => void;\n value: Meta;\n}\n\nexport type MetaAttributes = Record<string, string>;\n\nexport interface MetaSDKIntegration {\n name?: string;\n version?: string;\n}\n\nexport interface MetaSDK {\n name?: string;\n version?: string;\n integrations?: MetaSDKIntegration[];\n}\n\nexport interface MetaApp {\n name?: string;\n namespace?: string;\n release?: string;\n version?: string;\n environment?: string;\n bundleId?: string;\n}\n\nexport interface MetaUser {\n email?: string;\n id?: string;\n username?: string;\n attributes?: MetaAttributes;\n}\n\nexport interface MetaSession {\n id?: string;\n attributes?: MetaAttributes;\n overrides?: MetaOverrides;\n}\n\nexport interface MetaPage {\n id?: string;\n url?: string;\n attributes?: MetaAttributes;\n}\n\ninterface NavigatorUABrandVersion {\n brand?: string;\n version?: string;\n}\n\nexport interface MetaBrowser {\n name?: string;\n version?: string;\n os?: string;\n mobile?: boolean;\n userAgent?: string;\n language?: string;\n brands?: NavigatorUABrandVersion[] | string;\n viewportWidth?: string;\n viewportHeight?: string;\n}\n\nexport interface MetaView {\n name: string;\n}\n\nexport interface MetaK6 {\n isK6Browser?: boolean;\n testRunId?: string;\n}\n\nexport interface Meta {\n sdk?: MetaSDK;\n app?: MetaApp;\n user?: MetaUser;\n session?: MetaSession;\n page?: MetaPage;\n browser?: MetaBrowser;\n view?: MetaView;\n k6?: MetaK6;\n}\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/metas/types.ts"],"names":[],"mappings":"","sourcesContent":["export type MetaGetter<P = Partial<Meta>> = () => P;\n\nexport type MetaItem<P = Partial<Meta>> = P | MetaGetter<P>;\n\nexport type MetasListener = (value: Meta) => void;\n\nexport interface Metas {\n add: (...getters: MetaItem[]) => void;\n remove: (...getters: MetaItem[]) => void;\n addListener: (listener: MetasListener) => void;\n removeListener: (listener: MetasListener) => void;\n value: Meta;\n}\n\nexport type MetaAttributes = Record<string, string>;\n\nexport interface MetaSDKIntegration {\n name?: string;\n version?: string;\n}\n\nexport interface MetaSDK {\n name?: string;\n version?: string;\n integrations?: MetaSDKIntegration[];\n}\n\nexport interface MetaApp {\n name?: string;\n namespace?: string;\n release?: string;\n version?: string;\n environment?: string;\n bundleId?: string;\n}\n\nexport interface MetaUser {\n /**\n * User email address.\n */\n email?: string;\n /**\n * Unique identifier\n */\n id?: string;\n /**\n * Short name or login/username of the user.\n */\n username?: string;\n /**\n * User’s full name\n */\n fullName?: string;\n /**\n * comma separated list of user roles. \"admin\",editor\" etc.\n */\n roles?: string;\n /**\n * Unique user hash to correlate information for a user in anonymized form.\n */\n hash?: string;\n /**\n * arbitrary user attributes, must be of type string.\n */\n attributes?: MetaAttributes;\n}\n\nexport interface MetaSession {\n id?: string;\n attributes?: MetaAttributes;\n overrides?: MetaOverrides;\n}\n\nexport interface MetaPage {\n id?: string;\n url?: string;\n attributes?: MetaAttributes;\n}\n\ninterface NavigatorUABrandVersion {\n brand?: string;\n version?: string;\n}\n\nexport interface MetaBrowser {\n name?: string;\n version?: string;\n os?: string;\n mobile?: boolean;\n userAgent?: string;\n language?: string;\n brands?: NavigatorUABrandVersion[] | string;\n viewportWidth?: string;\n viewportHeight?: string;\n}\n\nexport interface MetaView {\n name: string;\n}\n\nexport interface MetaK6 {\n isK6Browser?: boolean;\n testRunId?: string;\n}\n\nexport interface Meta {\n sdk?: MetaSDK;\n app?: MetaApp;\n user?: MetaUser;\n session?: MetaSession;\n page?: MetaPage;\n browser?: MetaBrowser;\n view?: MetaView;\n k6?: MetaK6;\n}\n\n/**\n * MetaOverrides are instructions that allow the receiver to override certain properties (Grafana Cloud only).\n */\nexport type MetaOverrides = {\n /**\n * New service name (Grafana Cloud only)\n */\n serviceName?: string;\n\n /**\n * Enable or disable geolocation tracking (Grafana Cloud only).\n * Geolocation tracking must be enabled in the Grafana Cloud settings first.\n * It cannot be enabled solely on the client side.\n * This option allows control over tracking on the client side to comply with user\n * privacy requirements.\n */\n geoLocationTrackingEnabled?: boolean;\n};\n"]}
|
package/dist/cjs/version.js
CHANGED
package/dist/cjs/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.14.0';\n"]}
|
|
@@ -15,12 +15,18 @@ export function initializeMetaAPI(_unpatchedConsole, internalLogger, _config, me
|
|
|
15
15
|
metas.add(metaUser);
|
|
16
16
|
};
|
|
17
17
|
const setSession = (session, options) => {
|
|
18
|
-
|
|
18
|
+
var _a;
|
|
19
|
+
const newOverrides = options === null || options === void 0 ? void 0 : options.overrides;
|
|
20
|
+
const overrides = newOverrides
|
|
21
|
+
? {
|
|
22
|
+
overrides: Object.assign(Object.assign({}, (_a = metaSession === null || metaSession === void 0 ? void 0 : metaSession.session) === null || _a === void 0 ? void 0 : _a.overrides), newOverrides),
|
|
23
|
+
}
|
|
24
|
+
: {};
|
|
19
25
|
if (metaSession) {
|
|
20
26
|
metas.remove(metaSession);
|
|
21
27
|
}
|
|
22
28
|
metaSession = {
|
|
23
|
-
session: Object.assign(Object.assign({}, (isEmpty(session) ? undefined : session)),
|
|
29
|
+
session: Object.assign(Object.assign({}, (isEmpty(session) ? undefined : session)), overrides),
|
|
24
30
|
};
|
|
25
31
|
metas.add(metaSession);
|
|
26
32
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/meta/initialize.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAInD,MAAM,UAAU,iBAAiB,CAC/B,iBAAmC,EACnC,cAA8B,EAC9B,OAAe,EACf,KAAY,EACZ,WAAuB;IAEvB,cAAc,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAE9C,IAAI,WAAW,GAA8B,SAAS,CAAC;IACvD,IAAI,QAAQ,GAA8B,SAAS,CAAC;IACpD,IAAI,QAAQ,GAA8B,SAAS,CAAC;IACpD,IAAI,QAAQ,GAA8B,SAAS,CAAC;IAEpD,MAAM,OAAO,GAAuB,CAAC,IAAI,EAAE,EAAE;QAC3C,IAAI,QAAQ,EAAE;YACZ,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;SACxB;QAED,QAAQ,GAAG;YACT,IAAI;SACL,CAAC;QAEF,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACtB,CAAC,CAAC;IAEF,MAAM,UAAU,GAA0B,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE
|
|
1
|
+
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/meta/initialize.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAInD,MAAM,UAAU,iBAAiB,CAC/B,iBAAmC,EACnC,cAA8B,EAC9B,OAAe,EACf,KAAY,EAC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qC;QACnD,UAAU;QACV,OAAO;QACP,OAAO;QACP,OAAO;QACP,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Meta, Metas } from '../../metas';\nimport type { Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { isEmpty, isString } from '../../utils/is';\n\nimport type { MetaAPI } from './types';\n\nexport function initializeMetaAPI(\n _unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n _config: Config,\n metas: Metas,\n _transports: Transports\n): MetaAPI {\n internalLogger.debug('Initializing meta API');\n\n let metaSession: Partial<Meta> | undefined = undefined;\n let metaUser: Partial<Meta> | undefined = undefined;\n let metaView: Partial<Meta> | undefined = undefined;\n let metaPage: Partial<Meta> | undefined = undefined;\n\n const setUser: MetaAPI['setUser'] = (user) => {\n if (metaUser) {\n metas.remove(metaUser);\n }\n\n metaUser = {\n user,\n };\n\n metas.add(metaUser);\n };\n\n const setSession: MetaAPI['setSession'] = (session, options) => {\n const newOverrides = options?.overrides;\n const overrides = newOverrides\n ? {\n overrides: {\n ...metaSession?.session?.overrides,\n ...newOverrides,\n },\n }\n : {};\n\n if (metaSession) {\n metas.remove(metaSession);\n }\n\n metaSession = {\n session: {\n // if session is undefined, session manager force creates a new session\n ...(isEmpty(session) ? undefined : session),\n ...overrides,\n },\n };\n\n metas.add(metaSession);\n };\n\n const getSession: MetaAPI['getSession'] = () => metas.value.session;\n\n const setView: MetaAPI['setView'] = (view, options) => {\n if (options?.overrides) {\n setSession(getSession(), { overrides: options.overrides });\n }\n\n if (metaView?.view?.name === view?.name) {\n return;\n }\n\n const previousView = metaView;\n\n metaView = {\n view,\n };\n\n metas.add(metaView);\n\n if (previousView) {\n metas.remove(previousView);\n }\n };\n\n const getView: MetaAPI['getView'] = () => metas.value.view;\n\n const setPage: MetaAPI['setPage'] = (page) => {\n const pageMeta = isString(page)\n ? {\n // metaPage is available once setPage() has been called.\n // This is because page self updating metas like page need to be added as a function\n // Thus we call getPage in case metaPage is empty\n ...(metaPage?.page ?? getPage()),\n id: page,\n }\n : page;\n\n if (metaPage) {\n metas.remove(metaPage);\n }\n\n metaPage = {\n page: pageMeta,\n };\n\n metas.add(metaPage);\n };\n\n const getPage: MetaAPI['getPage'] = () => metas.value.page;\n\n return {\n setUser,\n resetUser: setUser as MetaAPI['resetUser'],\n setSession,\n resetSession: setSession as MetaAPI['resetSession'],\n getSession,\n setView,\n getView,\n setPage,\n getPage,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/meta/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { MetaOverrides, MetaPage, MetaSession, MetaUser, MetaView } from '../../metas';\n\nexport interface MetaAPI {\n setUser: (user?: MetaUser | undefined) => void;\n resetUser: () => void;\n setSession: (\n session?: MetaSession | undefined,\n options?: {\n overrides:
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/meta/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { MetaOverrides, MetaPage, MetaSession, MetaUser, MetaView } from '../../metas';\n\ntype OverridesAvailableThroughApi = Pick<MetaOverrides, 'serviceName'>;\n\nexport interface MetaAPI {\n setUser: (user?: MetaUser | undefined) => void;\n resetUser: () => void;\n setSession: (\n session?: MetaSession | undefined,\n options?: {\n overrides: OverridesAvailableThroughApi;\n }\n ) => void;\n resetSession: () => void;\n getSession: () => MetaSession | undefined;\n setView: (\n view?: MetaView | undefined,\n options?: {\n overrides: OverridesAvailableThroughApi;\n }\n ) => void;\n getView: () => MetaView | undefined;\n /**\n * If a string is provided, it will be used as the page id.\n */\n setPage: (page?: MetaPage | string | undefined) => void;\n getPage: () => MetaPage | undefined;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { APIEvent, LogArgsSerializer, StacktraceParser } from '../api';\nimport type { Instrumentation } from '../instrumentations';\nimport type { InternalLoggerLevel } from '../internalLogger';\nimport type { Meta, MetaApp, MetaItem, MetaPage, MetaSession, MetaUser, MetaView } from '../metas';\nimport type { BatchExecutorOptions, BeforeSendHook, Transport } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\nimport type { LogLevel } from '../utils';\n\ntype SamplingContext = {\n metas: Meta;\n};\n\nexport interface Config<P = APIEvent> {\n /**\n * Application metadata\n */\n app: MetaApp;\n\n /**\n * Set max number and max interval for signals to be batched before sending\n */\n batching?: BatchExecutorOptions;\n\n /**\n * A flag for toggling deduplication for signals\n */\n dedupe: boolean;\n\n /**\n * The key (name) to use for the global Faro object (default: 'faro')\n */\n globalObjectKey: string;\n\n /**\n * The (custom) instrumentations to use with Faro\n */\n instrumentations: Instrumentation[];\n\n /**\n * The level of information printed to console for internal messages (default: LogLevel.ERROR)\n */\n internalLoggerLevel: InternalLoggerLevel;\n\n /**\n * Isolate Faro instance from other Faro instances on the same page. (default: false)\n */\n isolate: boolean;\n\n /**\n * Custom function to serialize log arguments\n */\n logArgsSerializer?: LogArgsSerializer;\n\n /**\n * Add custom Metas during Faro initialization\n */\n metas: MetaItem[];\n\n /**\n * Custom function used to parse stack traces\n */\n parseStacktrace: StacktraceParser;\n\n /**\n * Pause sending data (default: false)\n */\n paused: boolean;\n\n /**\n * Prevent Faro from exposing itself to the global object (default: false)\n */\n preventGlobalExposure: boolean;\n\n /**\n * The transports to use for sending beacons\n */\n transports: Transport[];\n\n /**\n * Some instrumentations might override the default console methods but Faro instance provides a\n * way to access the unmodified console methods.\n *\n * faro.unpatchedConsole.log('This is a log');\n * faro.unpatchedConsole.warn('This is a warning');\n */\n unpatchedConsole: UnpatchedConsole;\n\n /**\n * Function which invoked before pushing event to transport. Can be used to modify or filter events\n */\n beforeSend?: BeforeSendHook<P>;\n\n /**\n * Error message patterns for errors that should be ignored\n */\n ignoreErrors?: Patterns;\n\n /**\n * Path patterns for Endpoints that should be ignored form being tracked\n */\n ignoreUrls?: Patterns;\n\n /**\n * Configuration for the built in session tracker\n */\n sessionTracking?: {\n /**\n * Enable session tracking (default: true)\n */\n enabled?: boolean;\n /**\n * Wether to use sticky sessions (default: false)\n */\n persistent?: boolean;\n /**\n * Session metadata object to be used when initializing session tracking\n */\n session?: MetaSession;\n /**\n * How long is a sticky session valid for recurring users (default: 15 minutes)\n */\n maxSessionPersistenceTime?: number;\n /**\n * Called each time a session changes. This can be when a new session is created or when an existing session is updated.\n * @param oldSession\n * @param newSession\n */\n onSessionChange?: (oldSession: MetaSession | null, newSession: MetaSession) => void;\n /**\n * Then sampling rate for the session based sampler (default: 1). If a session is not part of a sample, no signals for this session are tracked.\n */\n samplingRate?: number;\n /**\n * Custom sampler function if custom sampling logic is needed.\n * @param context\n */\n sampler?: (context: SamplingContext) => number;\n /**\n * Custom function to generate session id. If available Faro uses this function instead of the internal one.\n */\n generateSessionId?: () => string;\n };\n\n /**\n * Meta object for user data\n */\n user?: MetaUser;\n\n /**\n * Meta object for view data\n */\n view?: MetaView;\n\n eventDomain?: string;\n\n /**\n * Only resource timings for fetch and xhr requests are tracked by default. Set this to true to track all resources (default: false).\n */\n trackResources?: boolean;\n\n /**\n * Track web vitals attribution data (default: false)\n */\n trackWebVitalsAttribution?: boolean;\n\n /**\n * Configuration for the console instrumentation\n */\n consoleInstrumentation?: {\n /**\n * Configure what console levels should be captured by Faro. By default the
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { APIEvent, LogArgsSerializer, StacktraceParser } from '../api';\nimport type { Instrumentation } from '../instrumentations';\nimport type { InternalLoggerLevel } from '../internalLogger';\nimport type { Meta, MetaApp, MetaItem, MetaPage, MetaSession, MetaUser, MetaView } from '../metas';\nimport type { BatchExecutorOptions, BeforeSendHook, Transport } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\nimport type { LogLevel } from '../utils';\n\ntype SamplingContext = {\n metas: Meta;\n};\n\nexport interface Config<P = APIEvent> {\n /**\n * Application metadata\n */\n app: MetaApp;\n\n /**\n * Set max number and max interval for signals to be batched before sending\n */\n batching?: BatchExecutorOptions;\n\n /**\n * A flag for toggling deduplication for signals\n */\n dedupe: boolean;\n\n /**\n * The key (name) to use for the global Faro object (default: 'faro')\n */\n globalObjectKey: string;\n\n /**\n * The (custom) instrumentations to use with Faro\n */\n instrumentations: Instrumentation[];\n\n /**\n * The level of information printed to console for internal messages (default: LogLevel.ERROR)\n */\n internalLoggerLevel: InternalLoggerLevel;\n\n /**\n * Isolate Faro instance from other Faro instances on the same page. (default: false)\n */\n isolate: boolean;\n\n /**\n * Custom function to serialize log arguments\n */\n logArgsSerializer?: LogArgsSerializer;\n\n /**\n * Add custom Metas during Faro initialization\n */\n metas: MetaItem[];\n\n /**\n * Custom function used to parse stack traces\n */\n parseStacktrace: StacktraceParser;\n\n /**\n * Pause sending data (default: false)\n */\n paused: boolean;\n\n /**\n * Prevent Faro from exposing itself to the global object (default: false)\n */\n preventGlobalExposure: boolean;\n\n /**\n * The transports to use for sending beacons\n */\n transports: Transport[];\n\n /**\n * Some instrumentations might override the default console methods but Faro instance provides a\n * way to access the unmodified console methods.\n *\n * faro.unpatchedConsole.log('This is a log');\n * faro.unpatchedConsole.warn('This is a warning');\n */\n unpatchedConsole: UnpatchedConsole;\n\n /**\n * Function which invoked before pushing event to transport. Can be used to modify or filter events\n */\n beforeSend?: BeforeSendHook<P>;\n\n /**\n * Error message patterns for errors that should be ignored\n */\n ignoreErrors?: Patterns;\n\n /**\n * Path patterns for Endpoints that should be ignored form being tracked\n */\n ignoreUrls?: Patterns;\n\n /**\n * Configuration for the built in session tracker\n */\n sessionTracking?: {\n /**\n * Enable session tracking (default: true)\n */\n enabled?: boolean;\n /**\n * Wether to use sticky sessions (default: false)\n */\n persistent?: boolean;\n /**\n * Session metadata object to be used when initializing session tracking\n */\n session?: MetaSession;\n /**\n * How long is a sticky session valid for recurring users (default: 15 minutes)\n */\n maxSessionPersistenceTime?: number;\n /**\n * Called each time a session changes. This can be when a new session is created or when an existing session is updated.\n * @param oldSession\n * @param newSession\n */\n onSessionChange?: (oldSession: MetaSession | null, newSession: MetaSession) => void;\n /**\n * Then sampling rate for the session based sampler (default: 1). If a session is not part of a sample, no signals for this session are tracked.\n */\n samplingRate?: number;\n /**\n * Custom sampler function if custom sampling logic is needed.\n * @param context\n */\n sampler?: (context: SamplingContext) => number;\n /**\n * Custom function to generate session id. If available Faro uses this function instead of the internal one.\n */\n generateSessionId?: () => string;\n };\n\n /**\n * Meta object for user data\n */\n user?: MetaUser;\n\n /**\n * Meta object for view data\n */\n view?: MetaView;\n\n eventDomain?: string;\n\n /**\n * Only resource timings for fetch and xhr requests are tracked by default. Set this to true to track all resources (default: false).\n */\n trackResources?: boolean;\n\n /**\n * Track web vitals attribution data (default: false)\n */\n trackWebVitalsAttribution?: boolean;\n\n /**\n * Configuration for the web vitals instrumentation\n */\n webVitalsInstrumentation?: {\n /**\n * Report all changes for web vitals (default: false)\n *\n * In most cases, you only want the callback function to be called when the metric is ready to be reported.\n * However, it is possible to report every change (e.g. each larger layout shift as it happens)\n * by setting reportAllChanges to true.\n *\n * This can be useful when debugging, but in general using reportAllChanges is not needed (or recommended)\n * for measuring these metrics in production.\n */\n reportAllChanges?: boolean;\n };\n\n /**\n * Configuration for the console instrumentation\n */\n consoleInstrumentation?: {\n /**\n * Configure what console levels should be captured by Faro. By default the following levels\n * are disabled: console.debug, console.trace, console.log\n *\n * If you want to collect all levels set captureConsoleDisabledLevels: [];\n * If you want to disable only some levels set captureConsoleDisabledLevels: [LogLevel.DEBUG, LogLevel.TRACE];\n */\n disabledLevels?: LogLevel[];\n /*\n * By default, Faro sends an error for console.error calls. If you want to send a log instead, set this to true.\n */\n consoleErrorAsLog?: boolean;\n\n /**\n * If true, use the default Faro error serializer for console.error calls. If false, simply call toString() on the error arguments.\n * If enabled, payloads containing serialized errors may become very large. If left disabled, some error details may be lost.\n * (default: false)\n */\n serializeErrors?: boolean;\n\n /**\n * Custom function to serialize Error arguments\n */\n errorSerializer?: LogArgsSerializer;\n };\n\n /**\n * Configuration for the page tracking\n */\n pageTracking?: {\n /**\n * The page meta for initial page settings\n */\n page?: MetaPage;\n\n /**\n * Allows to provide a template for the page id\n */\n generatePageId?: (location: Location) => string;\n };\n\n /**\n * Configuration for the location tracking (Grafana cloud only)\n */\n geoLocationTracking?: {\n /**\n * Enable or disable geolocation tracking.\n * Geolocation tracking must be enabled in the Grafana Cloud settings first.\n * It cannot be enabled solely on the client side.\n * This option allows control over tracking on the client side to comply with user\n * privacy requirements.\n */\n enabled?: boolean;\n };\n}\n\nexport type Patterns = Array<string | RegExp>;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/metas/types.ts"],"names":[],"mappings":"","sourcesContent":["export type MetaGetter<P = Partial<Meta>> = () => P;\n\nexport type MetaItem<P = Partial<Meta>> = P | MetaGetter<P>;\n\nexport type MetasListener = (value: Meta) => void;\n\nexport interface Metas {\n add: (...getters: MetaItem[]) => void;\n remove: (...getters: MetaItem[]) => void;\n addListener: (listener: MetasListener) => void;\n removeListener: (listener: MetasListener) => void;\n value: Meta;\n}\n\nexport type MetaAttributes = Record<string, string>;\n\nexport interface MetaSDKIntegration {\n name?: string;\n version?: string;\n}\n\nexport interface MetaSDK {\n name?: string;\n version?: string;\n integrations?: MetaSDKIntegration[];\n}\n\nexport interface MetaApp {\n name?: string;\n namespace?: string;\n release?: string;\n version?: string;\n environment?: string;\n bundleId?: string;\n}\n\nexport interface MetaUser {\n email?: string;\n id?: string;\n username?: string;\n attributes?: MetaAttributes;\n}\n\nexport interface MetaSession {\n id?: string;\n attributes?: MetaAttributes;\n overrides?: MetaOverrides;\n}\n\nexport interface MetaPage {\n id?: string;\n url?: string;\n attributes?: MetaAttributes;\n}\n\ninterface NavigatorUABrandVersion {\n brand?: string;\n version?: string;\n}\n\nexport interface MetaBrowser {\n name?: string;\n version?: string;\n os?: string;\n mobile?: boolean;\n userAgent?: string;\n language?: string;\n brands?: NavigatorUABrandVersion[] | string;\n viewportWidth?: string;\n viewportHeight?: string;\n}\n\nexport interface MetaView {\n name: string;\n}\n\nexport interface MetaK6 {\n isK6Browser?: boolean;\n testRunId?: string;\n}\n\nexport interface Meta {\n sdk?: MetaSDK;\n app?: MetaApp;\n user?: MetaUser;\n session?: MetaSession;\n page?: MetaPage;\n browser?: MetaBrowser;\n view?: MetaView;\n k6?: MetaK6;\n}\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/metas/types.ts"],"names":[],"mappings":"","sourcesContent":["export type MetaGetter<P = Partial<Meta>> = () => P;\n\nexport type MetaItem<P = Partial<Meta>> = P | MetaGetter<P>;\n\nexport type MetasListener = (value: Meta) => void;\n\nexport interface Metas {\n add: (...getters: MetaItem[]) => void;\n remove: (...getters: MetaItem[]) => void;\n addListener: (listener: MetasListener) => void;\n removeListener: (listener: MetasListener) => void;\n value: Meta;\n}\n\nexport type MetaAttributes = Record<string, string>;\n\nexport interface MetaSDKIntegration {\n name?: string;\n version?: string;\n}\n\nexport interface MetaSDK {\n name?: string;\n version?: string;\n integrations?: MetaSDKIntegration[];\n}\n\nexport interface MetaApp {\n name?: string;\n namespace?: string;\n release?: string;\n version?: string;\n environment?: string;\n bundleId?: string;\n}\n\nexport interface MetaUser {\n /**\n * User email address.\n */\n email?: string;\n /**\n * Unique identifier\n */\n id?: string;\n /**\n * Short name or login/username of the user.\n */\n username?: string;\n /**\n * User’s full name\n */\n fullName?: string;\n /**\n * comma separated list of user roles. \"admin\",editor\" etc.\n */\n roles?: string;\n /**\n * Unique user hash to correlate information for a user in anonymized form.\n */\n hash?: string;\n /**\n * arbitrary user attributes, must be of type string.\n */\n attributes?: MetaAttributes;\n}\n\nexport interface MetaSession {\n id?: string;\n attributes?: MetaAttributes;\n overrides?: MetaOverrides;\n}\n\nexport interface MetaPage {\n id?: string;\n url?: string;\n attributes?: MetaAttributes;\n}\n\ninterface NavigatorUABrandVersion {\n brand?: string;\n version?: string;\n}\n\nexport interface MetaBrowser {\n name?: string;\n version?: string;\n os?: string;\n mobile?: boolean;\n userAgent?: string;\n language?: string;\n brands?: NavigatorUABrandVersion[] | string;\n viewportWidth?: string;\n viewportHeight?: string;\n}\n\nexport interface MetaView {\n name: string;\n}\n\nexport interface MetaK6 {\n isK6Browser?: boolean;\n testRunId?: string;\n}\n\nexport interface Meta {\n sdk?: MetaSDK;\n app?: MetaApp;\n user?: MetaUser;\n session?: MetaSession;\n page?: MetaPage;\n browser?: MetaBrowser;\n view?: MetaView;\n k6?: MetaK6;\n}\n\n/**\n * MetaOverrides are instructions that allow the receiver to override certain properties (Grafana Cloud only).\n */\nexport type MetaOverrides = {\n /**\n * New service name (Grafana Cloud only)\n */\n serviceName?: string;\n\n /**\n * Enable or disable geolocation tracking (Grafana Cloud only).\n * Geolocation tracking must be enabled in the Grafana Cloud settings first.\n * It cannot be enabled solely on the client side.\n * This option allows control over tracking on the client side to comply with user\n * privacy requirements.\n */\n geoLocationTrackingEnabled?: boolean;\n};\n"]}
|
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.14.0';\n"]}
|
|
@@ -29,12 +29,18 @@ function initializeMetaAPI(_unpatchedConsole, internalLogger, _config, metas, _t
|
|
|
29
29
|
metas.add(metaUser);
|
|
30
30
|
};
|
|
31
31
|
var setSession = function (session, options) {
|
|
32
|
-
var
|
|
32
|
+
var _a;
|
|
33
|
+
var newOverrides = options === null || options === void 0 ? void 0 : options.overrides;
|
|
34
|
+
var overrides = newOverrides
|
|
35
|
+
? {
|
|
36
|
+
overrides: __assign(__assign({}, (_a = metaSession === null || metaSession === void 0 ? void 0 : metaSession.session) === null || _a === void 0 ? void 0 : _a.overrides), newOverrides),
|
|
37
|
+
}
|
|
38
|
+
: {};
|
|
33
39
|
if (metaSession) {
|
|
34
40
|
metas.remove(metaSession);
|
|
35
41
|
}
|
|
36
42
|
metaSession = {
|
|
37
|
-
session: __assign(__assign({}, ((0, is_1.isEmpty)(session) ? undefined : session)),
|
|
43
|
+
session: __assign(__assign({}, ((0, is_1.isEmpty)(session) ? undefined : session)), overrides),
|
|
38
44
|
};
|
|
39
45
|
metas.add(metaSession);
|
|
40
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../../../src/api/meta/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAKA,qCAAmD;AAInD,SAAgB,iBAAiB,CAC/B,iBAAmC,EACnC,cAA8B,EAC9B,OAAe,EACf,KAAY,EACZ,WAAuB;IAEvB,cAAc,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAE9C,IAAI,WAAW,GAA8B,SAAS,CAAC;IACvD,IAAI,QAAQ,GAA8B,SAAS,CAAC;IACpD,IAAI,QAAQ,GAA8B,SAAS,CAAC;IACpD,IAAI,QAAQ,GAA8B,SAAS,CAAC;IAEpD,IAAM,OAAO,GAAuB,UAAC,IAAI;QACvC,IAAI,QAAQ,EAAE;YACZ,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;SACxB;QAED,QAAQ,GAAG;YACT,IAAI,MAAA;SACL,CAAC;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AAC,CAAC;SACxB;QAED,QAAQ,GAAG;YACT,IAAI,EAAE,QAAQ;SACf,CAAC;QAEF,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACtB,CAAC,CAAC;IAEF,IAAM,OAAO,GAAuB,cAAM,OAAA,KAAK,CAAC,KAAK,CAAC,IAAI,EAAhB,CAAgB,CAAC;IAE3D,OAAO;QACL,OAAO,SAAA;QACP,SAAS,EAAE,OAA+B;QAC1C,UAAU,YAAA;QACV,YAAY,EAAE,UAAqC;QACnD,UAAU,YAAA;QACV,OAAO,SAAA;QACP,OAAO,SAAA;QACP,OAAO,SAAA;QACP,OAAO,SAAA;KACR,CAAC;AACJ,CAAC;AAjHD,8CAiHC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Meta, Metas } from '../../metas';\nimport type { Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { isEmpty, isString } from '../../utils/is';\n\nimport type { MetaAPI } from './types';\n\nexport function initializeMetaAPI(\n _unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n _config: Config,\n metas: Metas,\n _transports: Transports\n): MetaAPI {\n internalLogger.debug('Initializing meta API');\n\n let metaSession: Partial<Meta> | undefined = undefined;\n let metaUser: Partial<Meta> | undefined = undefined;\n let metaView: Partial<Meta> | undefined = undefined;\n let metaPage: Partial<Meta> | undefined = undefined;\n\n const setUser: MetaAPI['setUser'] = (user) => {\n if (metaUser) {\n metas.remove(metaUser);\n }\n\n metaUser = {\n user,\n };\n\n metas.add(metaUser);\n };\n\n const setSession: MetaAPI['setSession'] = (session, options) => {\n const newOverrides = options?.overrides;\n const overrides = newOverrides\n ? {\n overrides: {\n ...metaSession?.session?.overrides,\n ...newOverrides,\n },\n }\n : {};\n\n if (metaSession) {\n metas.remove(metaSession);\n }\n\n metaSession = {\n session: {\n // if session is undefined, session manager force creates a new session\n ...(isEmpty(session) ? undefined : session),\n ...overrides,\n },\n };\n\n metas.add(metaSession);\n };\n\n const getSession: MetaAPI['getSession'] = () => metas.value.session;\n\n const setView: MetaAPI['setView'] = (view, options) => {\n if (options?.overrides) {\n setSession(getSession(), { overrides: options.overrides });\n }\n\n if (metaView?.view?.name === view?.name) {\n return;\n }\n\n const previousView = metaView;\n\n metaView = {\n view,\n };\n\n metas.add(metaView);\n\n if (previousView) {\n metas.remove(previousView);\n }\n };\n\n const getView: MetaAPI['getView'] = () => metas.value.view;\n\n const setPage: MetaAPI['setPage'] = (page) => {\n const pageMeta = isString(page)\n ? {\n // metaPage is available once setPage() has been called.\n // This is because page self updating metas like page need to be added as a function\n // Thus we call getPage in case metaPage is empty\n ...(metaPage?.page ?? getPage()),\n id: page,\n }\n : page;\n\n if (metaPage) {\n metas.remove(metaPage);\n }\n\n metaPage = {\n page: pageMeta,\n };\n\n metas.add(metaPage);\n };\n\n const getPage: MetaAPI['getPage'] = () => metas.value.page;\n\n return {\n setUser,\n resetUser: setUser as MetaAPI['resetUser'],\n setSession,\n resetSession: setSession as MetaAPI['resetSession'],\n getSession,\n setView,\n getView,\n setPage,\n getPage,\n };\n}\n"]}
|
|
@@ -73,6 +73,34 @@ describe('Meta API', function () {
|
|
|
73
73
|
api.setSession(undefined, { overrides: overrides });
|
|
74
74
|
expect(api.getSession()).toEqual({ overrides: overrides });
|
|
75
75
|
});
|
|
76
|
+
it('merges the new overrides with the existing session meta overrides', function () {
|
|
77
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
78
|
+
var initialSession = { id: 'my-session' };
|
|
79
|
+
var mc = (0, testUtils_1.mockConfig)({
|
|
80
|
+
sessionTracking: {
|
|
81
|
+
session: initialSession,
|
|
82
|
+
},
|
|
83
|
+
geoLocationTracking: {
|
|
84
|
+
enabled: false,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
// mockConfig is the result of calling makeCoreConfig in faro-web-sdk package.
|
|
88
|
+
// It it reads the geoLocationTracking properties it adds them to the sessionTracking.session.overrides object.
|
|
89
|
+
mc.sessionTracking.session.overrides = { geoLocationTrackingEnabled: false };
|
|
90
|
+
var api = (0, faro_core_1.initializeFaro)(mc).api;
|
|
91
|
+
expect((_a = api.getSession()) === null || _a === void 0 ? void 0 : _a.id).toEqual(initialSession.id);
|
|
92
|
+
expect((_b = api.getSession()) === null || _b === void 0 ? void 0 : _b.overrides).toBeDefined();
|
|
93
|
+
expect((_c = api.getSession()) === null || _c === void 0 ? void 0 : _c.overrides).toStrictEqual({ geoLocationTrackingEnabled: false });
|
|
94
|
+
var overrides = { serviceName: 'service-1' };
|
|
95
|
+
var newSession = { id: 'my-new-session' };
|
|
96
|
+
api.setSession(newSession, { overrides: overrides });
|
|
97
|
+
expect((_d = api.getSession()) === null || _d === void 0 ? void 0 : _d.id).toEqual(newSession.id);
|
|
98
|
+
expect((_e = api.getSession()) === null || _e === void 0 ? void 0 : _e.overrides).toStrictEqual(__assign(__assign({}, overrides), { geoLocationTrackingEnabled: false }));
|
|
99
|
+
var newOverrides = { serviceName: 'service-2' };
|
|
100
|
+
api.setSession(newSession, { overrides: newOverrides });
|
|
101
|
+
expect((_f = api.getSession()) === null || _f === void 0 ? void 0 : _f.id).toEqual(newSession.id);
|
|
102
|
+
expect((_g = api.getSession()) === null || _g === void 0 ? void 0 : _g.overrides).toStrictEqual(__assign(__assign({}, newOverrides), { geoLocationTrackingEnabled: false }));
|
|
103
|
+
});
|
|
76
104
|
});
|
|
77
105
|
describe('setPage / getPage', function () {
|
|
78
106
|
it('updates the page meta when setPage(meta) is called', function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initilialize.test.js","sourceRoot":"","sources":["../../../../../../src/api/meta/initilialize.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,gDAAoD;AACpD,8DAA8D;AAE9D,IAAM,cAAc,GAAG,MAAM,CAAC;AAE9B,QAAQ,CAAC,UAAU,EAAE;IACnB,IAAM,OAAO,GAAG,kBAAkB,CAAC;IAEnC,UAAU,CAA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;YAE7C,IAAM,WAAW,GAAG,EAAE,GAAG,EAAE,4BAA4B,EAAE,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC;YACzG,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YACzB,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;YAEjD,IAAM,SAAS,GAAG,gBAAgB,CAAC;YACnC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YACvB,MAAM,CAAC,MAAA,GAAG,CAAC,OAAO,EAAE,0CAAE,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,iDAAiD,EAAE;YAC5C,IAAA,GAAG,GAAK,IAAA,0BAAc,EAAC,IAAA,sBAAU,GAAE,CAAC,IAAjC,CAAkC;YAE7C,IAAM,IAAI,GAAG,EAAE,GAAG,EAAE,4BAA4B,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC;YAClE,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAClB,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;QAEH,sFAAsF;QACtF,0GAA0G;QAC1G,gFAAgF;QAChF,oLAAoL;IACtL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { initializeFaro } from '@grafana/faro-core';\nimport { mockConfig } from '@grafana/faro-core/src/testUtils';\n\nconst originalWindow = window;\n\ndescribe('Meta API', () => {\n const mockUrl = 'http://dummy.com';\n\n beforeEach(() => {\n window = Object.create(window);\n Object.defineProperty(window, 'location', {\n value: {\n href: mockUrl,\n },\n writable: true, // possibility to override\n });\n });\n\n beforeEach(() => {\n jest.resetModules();\n jest.clearAllMocks();\n jest.restoreAllMocks();\n });\n\n afterAll(() => {\n window = originalWindow;\n });\n\n describe('setView', () => {\n it('updates the view meta if the new view meta is different to the previous one', () => {\n const { api } = initializeFaro(mockConfig());\n\n const view = { name: 'my-view' };\n api.setView(view);\n let previousView = api.getView();\n expect(previousView).toEqual(view);\n\n const newView = { name: 'my-new-view' };\n api.setView(newView);\n previousView = api.getView();\n expect(previousView).toEqual(newView);\n });\n\n it('does not update the view meta if the new view meta is identical to the previous one', () => {\n const { api } = initializeFaro(mockConfig());\n\n const view = { name: 'my-view' };\n api.setView(view);\n let previousView = api.getView();\n expect(previousView).toEqual(view);\n\n const newView = { name: 'my-view' };\n api.setView(newView);\n previousView = api.getView();\n expect(previousView).toEqual(view);\n });\n });\n\n describe('setSession', () => {\n it('adds overrides to the session meta if provided via the setView() function call', () => {\n const initialSession = { id: 'my-session' };\n\n const { api } = initializeFaro(mockConfig({ sessionTracking: { enabled: false, session: initialSession } }));\n\n expect(api.getSession()).toEqual(initialSession);\n\n let overrides = { serviceName: 'service-1' };\n\n const newSession = { id: 'my-new-session', attributes: { hello: 'world' } };\n api.setSession(newSession, { overrides });\n expect(api.getSession()).toEqual({ ...newSession, overrides });\n\n overrides = { serviceName: 'service-2' };\n api.setSession({}, { overrides });\n expect(api.getSession()).toEqual({ overrides });\n\n overrides = { serviceName: 'service-3' };\n api.setSession(undefined, { overrides });\n expect(api.getSession()).toEqual({ overrides });\n });\n });\n\n describe('setPage / getPage', () => {\n it('updates the page meta when setPage(meta) is called', () => {\n const { api } = initializeFaro(mockConfig());\n\n const page = { url: 'http://example.com/my-page', id: 'my-page' };\n api.setPage(page);\n expect(api.getPage()).toEqual(page);\n\n const newPage = { url: 'http://example.com/my-new-page', id: 'my-new-page' };\n api.setPage(newPage);\n expect(api.getPage()).toEqual(newPage);\n });\n\n it('updates the page id if the parameter of setPage is a string', () => {\n const { api } = initializeFaro(mockConfig());\n\n const initialPage = { url: 'http://example.com/my-page', id: 'my-page', attributes: { hello: 'world' } };\n api.setPage(initialPage);\n expect(api.getPage()).toStrictEqual(initialPage);\n\n const newPageId = 'my-new-page-id';\n api.setPage(newPageId);\n expect(api.getPage()?.id).toEqual(newPageId);\n });\n\n it('gets the page meta when getPage(meta) is called', () => {\n const { api } = initializeFaro(mockConfig());\n\n const page = { url: 'http://example.com/my-page', id: 'my-page' };\n api.setPage(page);\n expect(api.getPage()).toEqual(page);\n });\n\n // Note: there's an integration test in the web-sdk that tests the following scenario:\n // >>> it'sets the page meta correctly when setPage() is called and the locally cached meta is not set <<<\n // This is because it needs web-sdk functions to be able to test the integration\n // you can find it in the pageMeta test file: https://github.com/grafana/faro-web-sdk/blob/3c2ba0f8ea8bfdfb39cd79b704d9a6c07bc7834e/packages/web-sdk/src/metas/page/meta.test.ts#L10\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"initilialize.test.js","sourceRoot":"","sources":["../../../../../../src/api/meta/initilialize.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,gDAAoD;AACpD,8DAA8D;AAE9D,IAAM,cAAc,GAAG,MAAM,CAAC;AAE9B,QAAQ,CAAC,UAAU,EAAE;IACnB,IAAM,OAAO,GAAG,kBAAkB,CAAC;IAEnC,UAAU,CAAC;QACT,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC/B,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE;YACxC,KAAK,EAAE;gBACL,IAAI,EAAE,OAAO;aACd;YACD,QAAQ,EAAE,IAAI,EAAE,0BAA0B;SAC3C,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,UAAU,CAAC;QACT,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC;QACP,MAAM,GAAG,cAAc,CAAC;IAC1B,CAAC,CAAC,CAAC;IAEH,QAAQ,CA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,EAAE,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC;YACzG,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YACzB,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;YAEjD,IAAM,SAAS,GAAG,gBAAgB,CAAC;YACnC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YACvB,MAAM,CAAC,MAAA,GAAG,CAAC,OAAO,EAAE,0CAAE,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,iDAAiD,EAAE;YAC5C,IAAA,GAAG,GAAK,IAAA,0BAAc,EAAC,IAAA,sBAAU,GAAE,CAAC,IAAjC,CAAkC;YAE7C,IAAM,IAAI,GAAG,EAAE,GAAG,EAAE,4BAA4B,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC;YAClE,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAClB,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;QAEH,sFAAsF;QACtF,0GAA0G;QAC1G,gFAAgF;QAChF,oLAAoL;IACtL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { initializeFaro } from '@grafana/faro-core';\nimport { mockConfig } from '@grafana/faro-core/src/testUtils';\n\nconst originalWindow = window;\n\ndescribe('Meta API', () => {\n const mockUrl = 'http://dummy.com';\n\n beforeEach(() => {\n window = Object.create(window);\n Object.defineProperty(window, 'location', {\n value: {\n href: mockUrl,\n },\n writable: true, // possibility to override\n });\n });\n\n beforeEach(() => {\n jest.resetModules();\n jest.clearAllMocks();\n jest.restoreAllMocks();\n });\n\n afterAll(() => {\n window = originalWindow;\n });\n\n describe('setView', () => {\n it('updates the view meta if the new view meta is different to the previous one', () => {\n const { api } = initializeFaro(mockConfig());\n\n const view = { name: 'my-view' };\n api.setView(view);\n let previousView = api.getView();\n expect(previousView).toEqual(view);\n\n const newView = { name: 'my-new-view' };\n api.setView(newView);\n previousView = api.getView();\n expect(previousView).toEqual(newView);\n });\n\n it('does not update the view meta if the new view meta is identical to the previous one', () => {\n const { api } = initializeFaro(mockConfig());\n\n const view = { name: 'my-view' };\n api.setView(view);\n let previousView = api.getView();\n expect(previousView).toEqual(view);\n\n const newView = { name: 'my-view' };\n api.setView(newView);\n previousView = api.getView();\n expect(previousView).toEqual(view);\n });\n });\n\n describe('setSession', () => {\n it('adds overrides to the session meta if provided via the setView() function call', () => {\n const initialSession = { id: 'my-session' };\n\n const { api } = initializeFaro(mockConfig({ sessionTracking: { enabled: false, session: initialSession } }));\n\n expect(api.getSession()).toEqual(initialSession);\n\n let overrides = { serviceName: 'service-1' };\n\n const newSession = { id: 'my-new-session', attributes: { hello: 'world' } };\n api.setSession(newSession, { overrides });\n expect(api.getSession()).toEqual({ ...newSession, overrides });\n\n overrides = { serviceName: 'service-2' };\n api.setSession({}, { overrides });\n expect(api.getSession()).toEqual({ overrides });\n\n overrides = { serviceName: 'service-3' };\n api.setSession(undefined, { overrides });\n expect(api.getSession()).toEqual({ overrides });\n });\n\n it('merges the new overrides with the existing session meta overrides', () => {\n const initialSession = { id: 'my-session' };\n\n const mc = mockConfig({\n sessionTracking: {\n session: initialSession,\n },\n geoLocationTracking: {\n enabled: false,\n },\n });\n\n // mockConfig is the result of calling makeCoreConfig in faro-web-sdk package.\n // It it reads the geoLocationTracking properties it adds them to the sessionTracking.session.overrides object.\n mc.sessionTracking!.session!.overrides = { geoLocationTrackingEnabled: false };\n\n const { api } = initializeFaro(mc);\n\n expect(api.getSession()?.id).toEqual(initialSession.id);\n expect(api.getSession()?.overrides).toBeDefined();\n expect(api.getSession()?.overrides).toStrictEqual({ geoLocationTrackingEnabled: false });\n\n const overrides = { serviceName: 'service-1' };\n const newSession = { id: 'my-new-session' };\n api.setSession(newSession, { overrides });\n expect(api.getSession()?.id).toEqual(newSession.id);\n expect(api.getSession()?.overrides).toStrictEqual({ ...overrides, geoLocationTrackingEnabled: false });\n\n const newOverrides = { serviceName: 'service-2' };\n api.setSession(newSession, { overrides: newOverrides });\n expect(api.getSession()?.id).toEqual(newSession.id);\n expect(api.getSession()?.overrides).toStrictEqual({ ...newOverrides, geoLocationTrackingEnabled: false });\n });\n });\n\n describe('setPage / getPage', () => {\n it('updates the page meta when setPage(meta) is called', () => {\n const { api } = initializeFaro(mockConfig());\n\n const page = { url: 'http://example.com/my-page', id: 'my-page' };\n api.setPage(page);\n expect(api.getPage()).toEqual(page);\n\n const newPage = { url: 'http://example.com/my-new-page', id: 'my-new-page' };\n api.setPage(newPage);\n expect(api.getPage()).toEqual(newPage);\n });\n\n it('updates the page id if the parameter of setPage is a string', () => {\n const { api } = initializeFaro(mockConfig());\n\n const initialPage = { url: 'http://example.com/my-page', id: 'my-page', attributes: { hello: 'world' } };\n api.setPage(initialPage);\n expect(api.getPage()).toStrictEqual(initialPage);\n\n const newPageId = 'my-new-page-id';\n api.setPage(newPageId);\n expect(api.getPage()?.id).toEqual(newPageId);\n });\n\n it('gets the page meta when getPage(meta) is called', () => {\n const { api } = initializeFaro(mockConfig());\n\n const page = { url: 'http://example.com/my-page', id: 'my-page' };\n api.setPage(page);\n expect(api.getPage()).toEqual(page);\n });\n\n // Note: there's an integration test in the web-sdk that tests the following scenario:\n // >>> it'sets the page meta correctly when setPage() is called and the locally cached meta is not set <<<\n // This is because it needs web-sdk functions to be able to test the integration\n // you can find it in the pageMeta test file: https://github.com/grafana/faro-web-sdk/blob/3c2ba0f8ea8bfdfb39cd79b704d9a6c07bc7834e/packages/web-sdk/src/metas/page/meta.test.ts#L10\n });\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/api/meta/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { MetaOverrides, MetaPage, MetaSession, MetaUser, MetaView } from '../../metas';\n\nexport interface MetaAPI {\n setUser: (user?: MetaUser | undefined) => void;\n resetUser: () => void;\n setSession: (\n session?: MetaSession | undefined,\n options?: {\n overrides:
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/api/meta/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { MetaOverrides, MetaPage, MetaSession, MetaUser, MetaView } from '../../metas';\n\ntype OverridesAvailableThroughApi = Pick<MetaOverrides, 'serviceName'>;\n\nexport interface MetaAPI {\n setUser: (user?: MetaUser | undefined) => void;\n resetUser: () => void;\n setSession: (\n session?: MetaSession | undefined,\n options?: {\n overrides: OverridesAvailableThroughApi;\n }\n ) => void;\n resetSession: () => void;\n getSession: () => MetaSession | undefined;\n setView: (\n view?: MetaView | undefined,\n options?: {\n overrides: OverridesAvailableThroughApi;\n }\n ) => void;\n getView: () => MetaView | undefined;\n /**\n * If a string is provided, it will be used as the page id.\n */\n setPage: (page?: MetaPage | string | undefined) => void;\n getPage: () => MetaPage | undefined;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/config/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { APIEvent, LogArgsSerializer, StacktraceParser } from '../api';\nimport type { Instrumentation } from '../instrumentations';\nimport type { InternalLoggerLevel } from '../internalLogger';\nimport type { Meta, MetaApp, MetaItem, MetaPage, MetaSession, MetaUser, MetaView } from '../metas';\nimport type { BatchExecutorOptions, BeforeSendHook, Transport } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\nimport type { LogLevel } from '../utils';\n\ntype SamplingContext = {\n metas: Meta;\n};\n\nexport interface Config<P = APIEvent> {\n /**\n * Application metadata\n */\n app: MetaApp;\n\n /**\n * Set max number and max interval for signals to be batched before sending\n */\n batching?: BatchExecutorOptions;\n\n /**\n * A flag for toggling deduplication for signals\n */\n dedupe: boolean;\n\n /**\n * The key (name) to use for the global Faro object (default: 'faro')\n */\n globalObjectKey: string;\n\n /**\n * The (custom) instrumentations to use with Faro\n */\n instrumentations: Instrumentation[];\n\n /**\n * The level of information printed to console for internal messages (default: LogLevel.ERROR)\n */\n internalLoggerLevel: InternalLoggerLevel;\n\n /**\n * Isolate Faro instance from other Faro instances on the same page. (default: false)\n */\n isolate: boolean;\n\n /**\n * Custom function to serialize log arguments\n */\n logArgsSerializer?: LogArgsSerializer;\n\n /**\n * Add custom Metas during Faro initialization\n */\n metas: MetaItem[];\n\n /**\n * Custom function used to parse stack traces\n */\n parseStacktrace: StacktraceParser;\n\n /**\n * Pause sending data (default: false)\n */\n paused: boolean;\n\n /**\n * Prevent Faro from exposing itself to the global object (default: false)\n */\n preventGlobalExposure: boolean;\n\n /**\n * The transports to use for sending beacons\n */\n transports: Transport[];\n\n /**\n * Some instrumentations might override the default console methods but Faro instance provides a\n * way to access the unmodified console methods.\n *\n * faro.unpatchedConsole.log('This is a log');\n * faro.unpatchedConsole.warn('This is a warning');\n */\n unpatchedConsole: UnpatchedConsole;\n\n /**\n * Function which invoked before pushing event to transport. Can be used to modify or filter events\n */\n beforeSend?: BeforeSendHook<P>;\n\n /**\n * Error message patterns for errors that should be ignored\n */\n ignoreErrors?: Patterns;\n\n /**\n * Path patterns for Endpoints that should be ignored form being tracked\n */\n ignoreUrls?: Patterns;\n\n /**\n * Configuration for the built in session tracker\n */\n sessionTracking?: {\n /**\n * Enable session tracking (default: true)\n */\n enabled?: boolean;\n /**\n * Wether to use sticky sessions (default: false)\n */\n persistent?: boolean;\n /**\n * Session metadata object to be used when initializing session tracking\n */\n session?: MetaSession;\n /**\n * How long is a sticky session valid for recurring users (default: 15 minutes)\n */\n maxSessionPersistenceTime?: number;\n /**\n * Called each time a session changes. This can be when a new session is created or when an existing session is updated.\n * @param oldSession\n * @param newSession\n */\n onSessionChange?: (oldSession: MetaSession | null, newSession: MetaSession) => void;\n /**\n * Then sampling rate for the session based sampler (default: 1). If a session is not part of a sample, no signals for this session are tracked.\n */\n samplingRate?: number;\n /**\n * Custom sampler function if custom sampling logic is needed.\n * @param context\n */\n sampler?: (context: SamplingContext) => number;\n /**\n * Custom function to generate session id. If available Faro uses this function instead of the internal one.\n */\n generateSessionId?: () => string;\n };\n\n /**\n * Meta object for user data\n */\n user?: MetaUser;\n\n /**\n * Meta object for view data\n */\n view?: MetaView;\n\n eventDomain?: string;\n\n /**\n * Only resource timings for fetch and xhr requests are tracked by default. Set this to true to track all resources (default: false).\n */\n trackResources?: boolean;\n\n /**\n * Track web vitals attribution data (default: false)\n */\n trackWebVitalsAttribution?: boolean;\n\n /**\n * Configuration for the console instrumentation\n */\n consoleInstrumentation?: {\n /**\n * Configure what console levels should be captured by Faro. By default the
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/config/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { APIEvent, LogArgsSerializer, StacktraceParser } from '../api';\nimport type { Instrumentation } from '../instrumentations';\nimport type { InternalLoggerLevel } from '../internalLogger';\nimport type { Meta, MetaApp, MetaItem, MetaPage, MetaSession, MetaUser, MetaView } from '../metas';\nimport type { BatchExecutorOptions, BeforeSendHook, Transport } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\nimport type { LogLevel } from '../utils';\n\ntype SamplingContext = {\n metas: Meta;\n};\n\nexport interface Config<P = APIEvent> {\n /**\n * Application metadata\n */\n app: MetaApp;\n\n /**\n * Set max number and max interval for signals to be batched before sending\n */\n batching?: BatchExecutorOptions;\n\n /**\n * A flag for toggling deduplication for signals\n */\n dedupe: boolean;\n\n /**\n * The key (name) to use for the global Faro object (default: 'faro')\n */\n globalObjectKey: string;\n\n /**\n * The (custom) instrumentations to use with Faro\n */\n instrumentations: Instrumentation[];\n\n /**\n * The level of information printed to console for internal messages (default: LogLevel.ERROR)\n */\n internalLoggerLevel: InternalLoggerLevel;\n\n /**\n * Isolate Faro instance from other Faro instances on the same page. (default: false)\n */\n isolate: boolean;\n\n /**\n * Custom function to serialize log arguments\n */\n logArgsSerializer?: LogArgsSerializer;\n\n /**\n * Add custom Metas during Faro initialization\n */\n metas: MetaItem[];\n\n /**\n * Custom function used to parse stack traces\n */\n parseStacktrace: StacktraceParser;\n\n /**\n * Pause sending data (default: false)\n */\n paused: boolean;\n\n /**\n * Prevent Faro from exposing itself to the global object (default: false)\n */\n preventGlobalExposure: boolean;\n\n /**\n * The transports to use for sending beacons\n */\n transports: Transport[];\n\n /**\n * Some instrumentations might override the default console methods but Faro instance provides a\n * way to access the unmodified console methods.\n *\n * faro.unpatchedConsole.log('This is a log');\n * faro.unpatchedConsole.warn('This is a warning');\n */\n unpatchedConsole: UnpatchedConsole;\n\n /**\n * Function which invoked before pushing event to transport. Can be used to modify or filter events\n */\n beforeSend?: BeforeSendHook<P>;\n\n /**\n * Error message patterns for errors that should be ignored\n */\n ignoreErrors?: Patterns;\n\n /**\n * Path patterns for Endpoints that should be ignored form being tracked\n */\n ignoreUrls?: Patterns;\n\n /**\n * Configuration for the built in session tracker\n */\n sessionTracking?: {\n /**\n * Enable session tracking (default: true)\n */\n enabled?: boolean;\n /**\n * Wether to use sticky sessions (default: false)\n */\n persistent?: boolean;\n /**\n * Session metadata object to be used when initializing session tracking\n */\n session?: MetaSession;\n /**\n * How long is a sticky session valid for recurring users (default: 15 minutes)\n */\n maxSessionPersistenceTime?: number;\n /**\n * Called each time a session changes. This can be when a new session is created or when an existing session is updated.\n * @param oldSession\n * @param newSession\n */\n onSessionChange?: (oldSession: MetaSession | null, newSession: MetaSession) => void;\n /**\n * Then sampling rate for the session based sampler (default: 1). If a session is not part of a sample, no signals for this session are tracked.\n */\n samplingRate?: number;\n /**\n * Custom sampler function if custom sampling logic is needed.\n * @param context\n */\n sampler?: (context: SamplingContext) => number;\n /**\n * Custom function to generate session id. If available Faro uses this function instead of the internal one.\n */\n generateSessionId?: () => string;\n };\n\n /**\n * Meta object for user data\n */\n user?: MetaUser;\n\n /**\n * Meta object for view data\n */\n view?: MetaView;\n\n eventDomain?: string;\n\n /**\n * Only resource timings for fetch and xhr requests are tracked by default. Set this to true to track all resources (default: false).\n */\n trackResources?: boolean;\n\n /**\n * Track web vitals attribution data (default: false)\n */\n trackWebVitalsAttribution?: boolean;\n\n /**\n * Configuration for the web vitals instrumentation\n */\n webVitalsInstrumentation?: {\n /**\n * Report all changes for web vitals (default: false)\n *\n * In most cases, you only want the callback function to be called when the metric is ready to be reported.\n * However, it is possible to report every change (e.g. each larger layout shift as it happens)\n * by setting reportAllChanges to true.\n *\n * This can be useful when debugging, but in general using reportAllChanges is not needed (or recommended)\n * for measuring these metrics in production.\n */\n reportAllChanges?: boolean;\n };\n\n /**\n * Configuration for the console instrumentation\n */\n consoleInstrumentation?: {\n /**\n * Configure what console levels should be captured by Faro. By default the following levels\n * are disabled: console.debug, console.trace, console.log\n *\n * If you want to collect all levels set captureConsoleDisabledLevels: [];\n * If you want to disable only some levels set captureConsoleDisabledLevels: [LogLevel.DEBUG, LogLevel.TRACE];\n */\n disabledLevels?: LogLevel[];\n /*\n * By default, Faro sends an error for console.error calls. If you want to send a log instead, set this to true.\n */\n consoleErrorAsLog?: boolean;\n\n /**\n * If true, use the default Faro error serializer for console.error calls. If false, simply call toString() on the error arguments.\n * If enabled, payloads containing serialized errors may become very large. If left disabled, some error details may be lost.\n * (default: false)\n */\n serializeErrors?: boolean;\n\n /**\n * Custom function to serialize Error arguments\n */\n errorSerializer?: LogArgsSerializer;\n };\n\n /**\n * Configuration for the page tracking\n */\n pageTracking?: {\n /**\n * The page meta for initial page settings\n */\n page?: MetaPage;\n\n /**\n * Allows to provide a template for the page id\n */\n generatePageId?: (location: Location) => string;\n };\n\n /**\n * Configuration for the location tracking (Grafana cloud only)\n */\n geoLocationTracking?: {\n /**\n * Enable or disable geolocation tracking.\n * Geolocation tracking must be enabled in the Grafana Cloud settings first.\n * It cannot be enabled solely on the client side.\n * This option allows control over tracking on the client side to comply with user\n * privacy requirements.\n */\n enabled?: boolean;\n };\n}\n\nexport type Patterns = Array<string | RegExp>;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/metas/types.ts"],"names":[],"mappings":"","sourcesContent":["export type MetaGetter<P = Partial<Meta>> = () => P;\n\nexport type MetaItem<P = Partial<Meta>> = P | MetaGetter<P>;\n\nexport type MetasListener = (value: Meta) => void;\n\nexport interface Metas {\n add: (...getters: MetaItem[]) => void;\n remove: (...getters: MetaItem[]) => void;\n addListener: (listener: MetasListener) => void;\n removeListener: (listener: MetasListener) => void;\n value: Meta;\n}\n\nexport type MetaAttributes = Record<string, string>;\n\nexport interface MetaSDKIntegration {\n name?: string;\n version?: string;\n}\n\nexport interface MetaSDK {\n name?: string;\n version?: string;\n integrations?: MetaSDKIntegration[];\n}\n\nexport interface MetaApp {\n name?: string;\n namespace?: string;\n release?: string;\n version?: string;\n environment?: string;\n bundleId?: string;\n}\n\nexport interface MetaUser {\n email?: string;\n id?: string;\n username?: string;\n attributes?: MetaAttributes;\n}\n\nexport interface MetaSession {\n id?: string;\n attributes?: MetaAttributes;\n overrides?: MetaOverrides;\n}\n\nexport interface MetaPage {\n id?: string;\n url?: string;\n attributes?: MetaAttributes;\n}\n\ninterface NavigatorUABrandVersion {\n brand?: string;\n version?: string;\n}\n\nexport interface MetaBrowser {\n name?: string;\n version?: string;\n os?: string;\n mobile?: boolean;\n userAgent?: string;\n language?: string;\n brands?: NavigatorUABrandVersion[] | string;\n viewportWidth?: string;\n viewportHeight?: string;\n}\n\nexport interface MetaView {\n name: string;\n}\n\nexport interface MetaK6 {\n isK6Browser?: boolean;\n testRunId?: string;\n}\n\nexport interface Meta {\n sdk?: MetaSDK;\n app?: MetaApp;\n user?: MetaUser;\n session?: MetaSession;\n page?: MetaPage;\n browser?: MetaBrowser;\n view?: MetaView;\n k6?: MetaK6;\n}\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/metas/types.ts"],"names":[],"mappings":"","sourcesContent":["export type MetaGetter<P = Partial<Meta>> = () => P;\n\nexport type MetaItem<P = Partial<Meta>> = P | MetaGetter<P>;\n\nexport type MetasListener = (value: Meta) => void;\n\nexport interface Metas {\n add: (...getters: MetaItem[]) => void;\n remove: (...getters: MetaItem[]) => void;\n addListener: (listener: MetasListener) => void;\n removeListener: (listener: MetasListener) => void;\n value: Meta;\n}\n\nexport type MetaAttributes = Record<string, string>;\n\nexport interface MetaSDKIntegration {\n name?: string;\n version?: string;\n}\n\nexport interface MetaSDK {\n name?: string;\n version?: string;\n integrations?: MetaSDKIntegration[];\n}\n\nexport interface MetaApp {\n name?: string;\n namespace?: string;\n release?: string;\n version?: string;\n environment?: string;\n bundleId?: string;\n}\n\nexport interface MetaUser {\n /**\n * User email address.\n */\n email?: string;\n /**\n * Unique identifier\n */\n id?: string;\n /**\n * Short name or login/username of the user.\n */\n username?: string;\n /**\n * User’s full name\n */\n fullName?: string;\n /**\n * comma separated list of user roles. \"admin\",editor\" etc.\n */\n roles?: string;\n /**\n * Unique user hash to correlate information for a user in anonymized form.\n */\n hash?: string;\n /**\n * arbitrary user attributes, must be of type string.\n */\n attributes?: MetaAttributes;\n}\n\nexport interface MetaSession {\n id?: string;\n attributes?: MetaAttributes;\n overrides?: MetaOverrides;\n}\n\nexport interface MetaPage {\n id?: string;\n url?: string;\n attributes?: MetaAttributes;\n}\n\ninterface NavigatorUABrandVersion {\n brand?: string;\n version?: string;\n}\n\nexport interface MetaBrowser {\n name?: string;\n version?: string;\n os?: string;\n mobile?: boolean;\n userAgent?: string;\n language?: string;\n brands?: NavigatorUABrandVersion[] | string;\n viewportWidth?: string;\n viewportHeight?: string;\n}\n\nexport interface MetaView {\n name: string;\n}\n\nexport interface MetaK6 {\n isK6Browser?: boolean;\n testRunId?: string;\n}\n\nexport interface Meta {\n sdk?: MetaSDK;\n app?: MetaApp;\n user?: MetaUser;\n session?: MetaSession;\n page?: MetaPage;\n browser?: MetaBrowser;\n view?: MetaView;\n k6?: MetaK6;\n}\n\n/**\n * MetaOverrides are instructions that allow the receiver to override certain properties (Grafana Cloud only).\n */\nexport type MetaOverrides = {\n /**\n * New service name (Grafana Cloud only)\n */\n serviceName?: string;\n\n /**\n * Enable or disable geolocation tracking (Grafana Cloud only).\n * Geolocation tracking must be enabled in the Grafana Cloud settings first.\n * It cannot be enabled solely on the client side.\n * This option allows control over tracking on the client side to comply with user\n * privacy requirements.\n */\n geoLocationTrackingEnabled?: boolean;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.14.0';\n"]}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import type { MetaOverrides, MetaPage, MetaSession, MetaUser, MetaView } from '../../metas';
|
|
2
|
+
type OverridesAvailableThroughApi = Pick<MetaOverrides, 'serviceName'>;
|
|
2
3
|
export interface MetaAPI {
|
|
3
4
|
setUser: (user?: MetaUser | undefined) => void;
|
|
4
5
|
resetUser: () => void;
|
|
5
6
|
setSession: (session?: MetaSession | undefined, options?: {
|
|
6
|
-
overrides:
|
|
7
|
+
overrides: OverridesAvailableThroughApi;
|
|
7
8
|
}) => void;
|
|
8
9
|
resetSession: () => void;
|
|
9
10
|
getSession: () => MetaSession | undefined;
|
|
10
11
|
setView: (view?: MetaView | undefined, options?: {
|
|
11
|
-
overrides:
|
|
12
|
+
overrides: OverridesAvailableThroughApi;
|
|
12
13
|
}) => void;
|
|
13
14
|
getView: () => MetaView | undefined;
|
|
14
15
|
/**
|
|
15
16
|
* If a string is provided, it will be used as the page id.
|
|
16
|
-
* @returns
|
|
17
17
|
*/
|
|
18
18
|
setPage: (page?: MetaPage | string | undefined) => void;
|
|
19
19
|
getPage: () => MetaPage | undefined;
|
|
20
20
|
}
|
|
21
|
+
export {};
|
|
@@ -138,12 +138,28 @@ export interface Config<P = APIEvent> {
|
|
|
138
138
|
* Track web vitals attribution data (default: false)
|
|
139
139
|
*/
|
|
140
140
|
trackWebVitalsAttribution?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Configuration for the web vitals instrumentation
|
|
143
|
+
*/
|
|
144
|
+
webVitalsInstrumentation?: {
|
|
145
|
+
/**
|
|
146
|
+
* Report all changes for web vitals (default: false)
|
|
147
|
+
*
|
|
148
|
+
* In most cases, you only want the callback function to be called when the metric is ready to be reported.
|
|
149
|
+
* However, it is possible to report every change (e.g. each larger layout shift as it happens)
|
|
150
|
+
* by setting reportAllChanges to true.
|
|
151
|
+
*
|
|
152
|
+
* This can be useful when debugging, but in general using reportAllChanges is not needed (or recommended)
|
|
153
|
+
* for measuring these metrics in production.
|
|
154
|
+
*/
|
|
155
|
+
reportAllChanges?: boolean;
|
|
156
|
+
};
|
|
141
157
|
/**
|
|
142
158
|
* Configuration for the console instrumentation
|
|
143
159
|
*/
|
|
144
160
|
consoleInstrumentation?: {
|
|
145
161
|
/**
|
|
146
|
-
* Configure what console levels should be captured by Faro. By default the
|
|
162
|
+
* Configure what console levels should be captured by Faro. By default the following levels
|
|
147
163
|
* are disabled: console.debug, console.trace, console.log
|
|
148
164
|
*
|
|
149
165
|
* If you want to collect all levels set captureConsoleDisabledLevels: [];
|
|
@@ -162,6 +178,9 @@ export interface Config<P = APIEvent> {
|
|
|
162
178
|
*/
|
|
163
179
|
errorSerializer?: LogArgsSerializer;
|
|
164
180
|
};
|
|
181
|
+
/**
|
|
182
|
+
* Configuration for the page tracking
|
|
183
|
+
*/
|
|
165
184
|
pageTracking?: {
|
|
166
185
|
/**
|
|
167
186
|
* The page meta for initial page settings
|
|
@@ -172,6 +191,19 @@ export interface Config<P = APIEvent> {
|
|
|
172
191
|
*/
|
|
173
192
|
generatePageId?: (location: Location) => string;
|
|
174
193
|
};
|
|
194
|
+
/**
|
|
195
|
+
* Configuration for the location tracking (Grafana cloud only)
|
|
196
|
+
*/
|
|
197
|
+
geoLocationTracking?: {
|
|
198
|
+
/**
|
|
199
|
+
* Enable or disable geolocation tracking.
|
|
200
|
+
* Geolocation tracking must be enabled in the Grafana Cloud settings first.
|
|
201
|
+
* It cannot be enabled solely on the client side.
|
|
202
|
+
* This option allows control over tracking on the client side to comply with user
|
|
203
|
+
* privacy requirements.
|
|
204
|
+
*/
|
|
205
|
+
enabled?: boolean;
|
|
206
|
+
};
|
|
175
207
|
}
|
|
176
208
|
export type Patterns = Array<string | RegExp>;
|
|
177
209
|
export {};
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import type { MetaOverrides, MetaPage, MetaSession, MetaUser, MetaView } from '../../metas';
|
|
2
|
+
type OverridesAvailableThroughApi = Pick<MetaOverrides, 'serviceName'>;
|
|
2
3
|
export interface MetaAPI {
|
|
3
4
|
setUser: (user?: MetaUser | undefined) => void;
|
|
4
5
|
resetUser: () => void;
|
|
5
6
|
setSession: (session?: MetaSession | undefined, options?: {
|
|
6
|
-
overrides:
|
|
7
|
+
overrides: OverridesAvailableThroughApi;
|
|
7
8
|
}) => void;
|
|
8
9
|
resetSession: () => void;
|
|
9
10
|
getSession: () => MetaSession | undefined;
|
|
10
11
|
setView: (view?: MetaView | undefined, options?: {
|
|
11
|
-
overrides:
|
|
12
|
+
overrides: OverridesAvailableThroughApi;
|
|
12
13
|
}) => void;
|
|
13
14
|
getView: () => MetaView | undefined;
|
|
14
15
|
/**
|
|
15
16
|
* If a string is provided, it will be used as the page id.
|
|
16
|
-
* @returns
|
|
17
17
|
*/
|
|
18
18
|
setPage: (page?: MetaPage | string | undefined) => void;
|
|
19
19
|
getPage: () => MetaPage | undefined;
|
|
20
20
|
}
|
|
21
|
+
export {};
|
|
@@ -138,12 +138,28 @@ export interface Config<P = APIEvent> {
|
|
|
138
138
|
* Track web vitals attribution data (default: false)
|
|
139
139
|
*/
|
|
140
140
|
trackWebVitalsAttribution?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Configuration for the web vitals instrumentation
|
|
143
|
+
*/
|
|
144
|
+
webVitalsInstrumentation?: {
|
|
145
|
+
/**
|
|
146
|
+
* Report all changes for web vitals (default: false)
|
|
147
|
+
*
|
|
148
|
+
* In most cases, you only want the callback function to be called when the metric is ready to be reported.
|
|
149
|
+
* However, it is possible to report every change (e.g. each larger layout shift as it happens)
|
|
150
|
+
* by setting reportAllChanges to true.
|
|
151
|
+
*
|
|
152
|
+
* This can be useful when debugging, but in general using reportAllChanges is not needed (or recommended)
|
|
153
|
+
* for measuring these metrics in production.
|
|
154
|
+
*/
|
|
155
|
+
reportAllChanges?: boolean;
|
|
156
|
+
};
|
|
141
157
|
/**
|
|
142
158
|
* Configuration for the console instrumentation
|
|
143
159
|
*/
|
|
144
160
|
consoleInstrumentation?: {
|
|
145
161
|
/**
|
|
146
|
-
* Configure what console levels should be captured by Faro. By default the
|
|
162
|
+
* Configure what console levels should be captured by Faro. By default the following levels
|
|
147
163
|
* are disabled: console.debug, console.trace, console.log
|
|
148
164
|
*
|
|
149
165
|
* If you want to collect all levels set captureConsoleDisabledLevels: [];
|
|
@@ -162,6 +178,9 @@ export interface Config<P = APIEvent> {
|
|
|
162
178
|
*/
|
|
163
179
|
errorSerializer?: LogArgsSerializer;
|
|
164
180
|
};
|
|
181
|
+
/**
|
|
182
|
+
* Configuration for the page tracking
|
|
183
|
+
*/
|
|
165
184
|
pageTracking?: {
|
|
166
185
|
/**
|
|
167
186
|
* The page meta for initial page settings
|
|
@@ -172,6 +191,19 @@ export interface Config<P = APIEvent> {
|
|
|
172
191
|
*/
|
|
173
192
|
generatePageId?: (location: Location) => string;
|
|
174
193
|
};
|
|
194
|
+
/**
|
|
195
|
+
* Configuration for the location tracking (Grafana cloud only)
|
|
196
|
+
*/
|
|
197
|
+
geoLocationTracking?: {
|
|
198
|
+
/**
|
|
199
|
+
* Enable or disable geolocation tracking.
|
|
200
|
+
* Geolocation tracking must be enabled in the Grafana Cloud settings first.
|
|
201
|
+
* It cannot be enabled solely on the client side.
|
|
202
|
+
* This option allows control over tracking on the client side to comply with user
|
|
203
|
+
* privacy requirements.
|
|
204
|
+
*/
|
|
205
|
+
enabled?: boolean;
|
|
206
|
+
};
|
|
175
207
|
}
|
|
176
208
|
export type Patterns = Array<string | RegExp>;
|
|
177
209
|
export {};
|
|
@@ -27,9 +27,33 @@ export interface MetaApp {
|
|
|
27
27
|
bundleId?: string;
|
|
28
28
|
}
|
|
29
29
|
export interface MetaUser {
|
|
30
|
+
/**
|
|
31
|
+
* User email address.
|
|
32
|
+
*/
|
|
30
33
|
email?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Unique identifier
|
|
36
|
+
*/
|
|
31
37
|
id?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Short name or login/username of the user.
|
|
40
|
+
*/
|
|
32
41
|
username?: string;
|
|
42
|
+
/**
|
|
43
|
+
* User’s full name
|
|
44
|
+
*/
|
|
45
|
+
fullName?: string;
|
|
46
|
+
/**
|
|
47
|
+
* comma separated list of user roles. "admin",editor" etc.
|
|
48
|
+
*/
|
|
49
|
+
roles?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Unique user hash to correlate information for a user in anonymized form.
|
|
52
|
+
*/
|
|
53
|
+
hash?: string;
|
|
54
|
+
/**
|
|
55
|
+
* arbitrary user attributes, must be of type string.
|
|
56
|
+
*/
|
|
33
57
|
attributes?: MetaAttributes;
|
|
34
58
|
}
|
|
35
59
|
export interface MetaSession {
|
|
@@ -75,9 +99,20 @@ export interface Meta {
|
|
|
75
99
|
k6?: MetaK6;
|
|
76
100
|
}
|
|
77
101
|
/**
|
|
78
|
-
*
|
|
102
|
+
* MetaOverrides are instructions that allow the receiver to override certain properties (Grafana Cloud only).
|
|
79
103
|
*/
|
|
80
104
|
export type MetaOverrides = {
|
|
105
|
+
/**
|
|
106
|
+
* New service name (Grafana Cloud only)
|
|
107
|
+
*/
|
|
81
108
|
serviceName?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Enable or disable geolocation tracking (Grafana Cloud only).
|
|
111
|
+
* Geolocation tracking must be enabled in the Grafana Cloud settings first.
|
|
112
|
+
* It cannot be enabled solely on the client side.
|
|
113
|
+
* This option allows control over tracking on the client side to comply with user
|
|
114
|
+
* privacy requirements.
|
|
115
|
+
*/
|
|
116
|
+
geoLocationTrackingEnabled?: boolean;
|
|
82
117
|
};
|
|
83
118
|
export {};
|
|
@@ -4,7 +4,7 @@ import type { Transport, TransportItem } from '../transports';
|
|
|
4
4
|
export declare class MockTransport extends BaseTransport implements Transport {
|
|
5
5
|
private ignoreURLs;
|
|
6
6
|
readonly name = "@grafana/transport-mock";
|
|
7
|
-
readonly version = "1.
|
|
7
|
+
readonly version = "1.14.0";
|
|
8
8
|
items: TransportItem[];
|
|
9
9
|
constructor(ignoreURLs?: Patterns);
|
|
10
10
|
send(items: TransportItem[]): void | Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.14.0";
|
|
@@ -27,9 +27,33 @@ export interface MetaApp {
|
|
|
27
27
|
bundleId?: string;
|
|
28
28
|
}
|
|
29
29
|
export interface MetaUser {
|
|
30
|
+
/**
|
|
31
|
+
* User email address.
|
|
32
|
+
*/
|
|
30
33
|
email?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Unique identifier
|
|
36
|
+
*/
|
|
31
37
|
id?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Short name or login/username of the user.
|
|
40
|
+
*/
|
|
32
41
|
username?: string;
|
|
42
|
+
/**
|
|
43
|
+
* User’s full name
|
|
44
|
+
*/
|
|
45
|
+
fullName?: string;
|
|
46
|
+
/**
|
|
47
|
+
* comma separated list of user roles. "admin",editor" etc.
|
|
48
|
+
*/
|
|
49
|
+
roles?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Unique user hash to correlate information for a user in anonymized form.
|
|
52
|
+
*/
|
|
53
|
+
hash?: string;
|
|
54
|
+
/**
|
|
55
|
+
* arbitrary user attributes, must be of type string.
|
|
56
|
+
*/
|
|
33
57
|
attributes?: MetaAttributes;
|
|
34
58
|
}
|
|
35
59
|
export interface MetaSession {
|
|
@@ -75,9 +99,20 @@ export interface Meta {
|
|
|
75
99
|
k6?: MetaK6;
|
|
76
100
|
}
|
|
77
101
|
/**
|
|
78
|
-
*
|
|
102
|
+
* MetaOverrides are instructions that allow the receiver to override certain properties (Grafana Cloud only).
|
|
79
103
|
*/
|
|
80
104
|
export type MetaOverrides = {
|
|
105
|
+
/**
|
|
106
|
+
* New service name (Grafana Cloud only)
|
|
107
|
+
*/
|
|
81
108
|
serviceName?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Enable or disable geolocation tracking (Grafana Cloud only).
|
|
111
|
+
* Geolocation tracking must be enabled in the Grafana Cloud settings first.
|
|
112
|
+
* It cannot be enabled solely on the client side.
|
|
113
|
+
* This option allows control over tracking on the client side to comply with user
|
|
114
|
+
* privacy requirements.
|
|
115
|
+
*/
|
|
116
|
+
geoLocationTrackingEnabled?: boolean;
|
|
82
117
|
};
|
|
83
118
|
export {};
|
|
@@ -4,7 +4,7 @@ import type { Transport, TransportItem } from '../transports';
|
|
|
4
4
|
export declare class MockTransport extends BaseTransport implements Transport {
|
|
5
5
|
private ignoreURLs;
|
|
6
6
|
readonly name = "@grafana/transport-mock";
|
|
7
|
-
readonly version = "1.
|
|
7
|
+
readonly version = "1.14.0";
|
|
8
8
|
items: TransportItem[];
|
|
9
9
|
constructor(ignoreURLs?: Patterns);
|
|
10
10
|
send(items: TransportItem[]): void | Promise<void>;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.14.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/faro-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"description": "Core package of Faro.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.0.0"
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "27e390456e4449ca286a70b9d74022b0e960074e"
|
|
67
67
|
}
|