@grafana/faro-core 1.13.3 → 1.14.1

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.
Files changed (83) hide show
  1. package/dist/bundle/faro-core.iife.js +1 -1
  2. package/dist/bundle/types/api/meta/types.d.ts +4 -3
  3. package/dist/bundle/types/api/utils.d.ts +2 -0
  4. package/dist/bundle/types/config/types.d.ts +33 -1
  5. package/dist/bundle/types/metas/types.d.ts +36 -1
  6. package/dist/bundle/types/testUtils/mockTransport.d.ts +1 -1
  7. package/dist/bundle/types/transports/initialize.d.ts +2 -4
  8. package/dist/bundle/types/transports/types.d.ts +0 -1
  9. package/dist/bundle/types/version.d.ts +1 -1
  10. package/dist/cjs/api/exceptions/initialize.js +10 -2
  11. package/dist/cjs/api/exceptions/initialize.js.map +1 -1
  12. package/dist/cjs/api/meta/initialize.js +8 -2
  13. package/dist/cjs/api/meta/initialize.js.map +1 -1
  14. package/dist/cjs/api/meta/types.js.map +1 -1
  15. package/dist/cjs/api/utils.js +11 -0
  16. package/dist/cjs/api/utils.js.map +1 -0
  17. package/dist/cjs/config/types.js.map +1 -1
  18. package/dist/cjs/metas/types.js.map +1 -1
  19. package/dist/cjs/transports/initialize.js +1 -35
  20. package/dist/cjs/transports/initialize.js.map +1 -1
  21. package/dist/cjs/transports/registerInitial.js +0 -1
  22. package/dist/cjs/transports/registerInitial.js.map +1 -1
  23. package/dist/cjs/transports/types.js.map +1 -1
  24. package/dist/cjs/version.js +1 -1
  25. package/dist/cjs/version.js.map +1 -1
  26. package/dist/esm/api/exceptions/initialize.js +10 -2
  27. package/dist/esm/api/exceptions/initialize.js.map +1 -1
  28. package/dist/esm/api/meta/initialize.js +8 -2
  29. package/dist/esm/api/meta/initialize.js.map +1 -1
  30. package/dist/esm/api/meta/types.js.map +1 -1
  31. package/dist/esm/api/utils.js +7 -0
  32. package/dist/esm/api/utils.js.map +1 -0
  33. package/dist/esm/config/types.js.map +1 -1
  34. package/dist/esm/metas/types.js.map +1 -1
  35. package/dist/esm/transports/initialize.js +0 -28
  36. package/dist/esm/transports/initialize.js.map +1 -1
  37. package/dist/esm/transports/registerInitial.js +0 -1
  38. package/dist/esm/transports/registerInitial.js.map +1 -1
  39. package/dist/esm/transports/types.js.map +1 -1
  40. package/dist/esm/version.js +1 -1
  41. package/dist/esm/version.js.map +1 -1
  42. package/dist/spec/core/src/api/exceptions/initialize.js +10 -2
  43. package/dist/spec/core/src/api/exceptions/initialize.js.map +1 -1
  44. package/dist/spec/core/src/api/exceptions/initialize.test.js +21 -0
  45. package/dist/spec/core/src/api/exceptions/initialize.test.js.map +1 -1
  46. package/dist/spec/core/src/api/meta/initialize.js +8 -2
  47. package/dist/spec/core/src/api/meta/initialize.js.map +1 -1
  48. package/dist/spec/core/src/api/meta/initilialize.test.js +28 -0
  49. package/dist/spec/core/src/api/meta/initilialize.test.js.map +1 -1
  50. package/dist/spec/core/src/api/meta/types.js.map +1 -1
  51. package/dist/spec/core/src/api/utils.js +11 -0
  52. package/dist/spec/core/src/api/utils.js.map +1 -0
  53. package/dist/spec/core/src/api/utils.test.js +20 -0
  54. package/dist/spec/core/src/api/utils.test.js.map +1 -0
  55. package/dist/spec/core/src/config/types.js.map +1 -1
  56. package/dist/spec/core/src/metas/types.js.map +1 -1
  57. package/dist/spec/core/src/transports/initialize.js +1 -35
  58. package/dist/spec/core/src/transports/initialize.js.map +1 -1
  59. package/dist/spec/core/src/transports/registerInitial.js +0 -1
  60. package/dist/spec/core/src/transports/registerInitial.js.map +1 -1
  61. package/dist/spec/core/src/transports/transports.test.js +0 -16
  62. package/dist/spec/core/src/transports/transports.test.js.map +1 -1
  63. package/dist/spec/core/src/transports/types.js.map +1 -1
  64. package/dist/spec/core/src/version.js +1 -1
  65. package/dist/spec/core/src/version.js.map +1 -1
  66. package/dist/types/api/meta/types.d.ts +4 -3
  67. package/dist/types/api/utils.d.ts +2 -0
  68. package/dist/types/config/types.d.ts +33 -1
  69. package/dist/types/core/src/api/meta/types.d.ts +4 -3
  70. package/dist/types/core/src/api/utils.d.ts +2 -0
  71. package/dist/types/core/src/api/utils.test.d.ts +1 -0
  72. package/dist/types/core/src/config/types.d.ts +33 -1
  73. package/dist/types/core/src/metas/types.d.ts +36 -1
  74. package/dist/types/core/src/testUtils/mockTransport.d.ts +1 -1
  75. package/dist/types/core/src/transports/initialize.d.ts +2 -4
  76. package/dist/types/core/src/transports/types.d.ts +0 -1
  77. package/dist/types/core/src/version.d.ts +1 -1
  78. package/dist/types/metas/types.d.ts +36 -1
  79. package/dist/types/testUtils/mockTransport.d.ts +1 -1
  80. package/dist/types/transports/initialize.d.ts +2 -4
  81. package/dist/types/transports/types.d.ts +0 -1
  82. package/dist/types/version.d.ts +1 -1
  83. 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";class n{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=[]}}function t(e,t,r,i){var a;t.debug("Initializing transports");const s=[];let o=r.paused,l=[];const u=e=>{let n=e;for(const e of l){const t=n.map(e).filter(Boolean);if(0===t.length)return[];n=t}return n},c=e=>{const n=u(e);if(0!==n.length)for(const e of s)t.debug(`Transporting item using ${e.name}\n`,n),e.isBatched()&&e.send(n)};let d;(null===(a=r.batching)||void 0===a?void 0:a.enabled)&&(d=new n(c,{sendTimeout:r.batching.sendTimeout,itemLimit:r.batching.itemLimit,paused:o}));return{add:(...n)=>{t.debug("Adding transports"),n.forEach((n=>{t.debug(`Adding "${n.name}" transport`);s.some((e=>e===n))?t.warn(`Transport ${n.name} is already added`):(n.unpatchedConsole=e,n.internalLogger=t,n.config=r,n.metas=i,s.push(n))}))},addBeforeSendHooks:(...e)=>{t.debug("Adding beforeSendHooks\n",l),e.forEach((e=>{e&&l.push(e)}))},getBeforeSendHooks:()=>[...l],execute:e=>{var n;o||((null===(n=r.batching)||void 0===n?void 0:n.enabled)&&(null==d||d.addItem(e)),(e=>{var n,i;if((null===(n=r.batching)||void 0===n?void 0:n.enabled)&&s.every((e=>e.isBatched())))return;const[a]=u([e]);if(void 0!==a)for(const e of s)t.debug(`Transporting item using ${e.name}\n`,a),e.isBatched()?(null===(i=r.batching)||void 0===i?void 0:i.enabled)||e.send([a]):e.send(a)})(e))},isPaused:()=>o,pause:()=>{t.debug("Pausing transports"),null==d||d.pause(),o=!0},remove:(...e)=>{t.debug("Removing transports"),e.forEach((e=>{t.debug(`Removing "${e.name}" transport`);const n=s.indexOf(e);-1!==n?s.splice(n,1):t.warn(`Transport "${e.name}" is not added`)}))},removeBeforeSendHooks:(...e)=>{l.filter((n=>!e.includes(n)))},get transports(){return[...s]},unpause:()=>{t.debug("Unpausing transports"),null==d||d.start(),o=!1}}}function r(e,n){return typeof e===n}function i(e,n){return Object.prototype.toString.call(e)===`[object ${n}]`}function a(e,n){try{return e instanceof n}catch(e){return!1}}const s=e=>r(e,"null"),o=e=>r(e,"string"),l=e=>r(e,"number")&&!isNaN(e)||r(e,"bigint"),u=e=>!s(e)&&r(e,"object"),c=e=>r(e,"function"),d=e=>i(e,"Array"),g="undefined"!=typeof Event,p="undefined"!=typeof Error,f=e=>p&&a(e,Error),m="undefined"!=typeof Element,v="undefined"!=typeof Map;function b(e){return null==e||(d(e)||o(e)?0===e.length:!!u(e)&&0===Object.keys(e).length)}function h(e,n){if(e===n)return!0;if(r(e,"number")&&isNaN(e))return r(n,"number")&&isNaN(n);const t=d(e),i=d(n);if(t!==i)return!1;if(t&&i){const t=e.length;if(t!==n.length)return!1;for(let r=t;0!=r--;)if(!h(e[r],n[r]))return!1;return!0}const a=u(e),s=u(n);if(a!==s)return!1;if(e&&n&&a&&s){const t=Object.keys(e),r=Object.keys(n);if(t.length!==r.length)return!1;for(let e of t)if(!r.includes(e))return!1;for(let r of t)if(!h(e[r],n[r]))return!1;return!0}return!1}function E(){return(new Date).toISOString()}function y(e){return new Date(e).toISOString()}var I;e.LogLevel=void 0,(I=e.LogLevel||(e.LogLevel={})).TRACE="trace",I.DEBUG="debug",I.INFO="info",I.LOG="log",I.WARN="warn",I.ERROR="error";const T=e.LogLevel.LOG,O=[e.LogLevel.TRACE,e.LogLevel.DEBUG,e.LogLevel.INFO,e.LogLevel.LOG,e.LogLevel.WARN,e.LogLevel.ERROR];function L(){}const S="abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789";const j="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:void 0;function N(){const e=new WeakSet;return function(n,t){if(u(t)&&null!==t){if(e.has(t))return null;e.add(t)}return t}}function R(e={}){return JSON.stringify(null!=e?e:{},N())}function x(e={}){const n={};for(const[t,r]of Object.entries(e))n[t]=u(r)&&null!==r?R(r):String(r);return n}var A;e.InternalLoggerLevel=void 0,(A=e.InternalLoggerLevel||(e.InternalLoggerLevel={}))[A.OFF=0]="OFF",A[A.ERROR=1]="ERROR",A[A.WARN=2]="WARN",A[A.INFO=3]="INFO",A[A.VERBOSE=4]="VERBOSE";const k={debug:L,error:L,info:L,prefix:"Faro",warn:L},w=e.InternalLoggerLevel.ERROR,C=Object.assign({},console);let _=C;function B(e){var n;return _=null!==(n=e.unpatchedConsole)&&void 0!==n?n:_,_}function P(n=C,t=w){const r=k;return t>e.InternalLoggerLevel.OFF&&(r.error=t>=e.InternalLoggerLevel.ERROR?function(...e){n.error(`${r.prefix}\n`,...e)}:L,r.warn=t>=e.InternalLoggerLevel.WARN?function(...e){n.warn(`${r.prefix}\n`,...e)}:L,r.info=t>=e.InternalLoggerLevel.INFO?function(...e){n.info(`${r.prefix}\n`,...e)}:L,r.debug=t>=e.InternalLoggerLevel.VERBOSE?function(...e){n.debug(`${r.prefix}\n`,...e)}:L),r}let F=k;function D(e,n){return F=P(e,n.internalLoggerLevel),F}class V{constructor(){this.unpatchedConsole=C,this.internalLogger=k,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)}}var M;e.TransportItemType=void 0,(M=e.TransportItemType||(e.TransportItemType={})).EXCEPTION="exception",M.LOG="log",M.MEASUREMENT="measurement",M.TRACE="trace",M.EVENT="event";const G={[e.TransportItemType.EXCEPTION]:"exceptions",[e.TransportItemType.LOG]:"logs",[e.TransportItemType.MEASUREMENT]:"measurements",[e.TransportItemType.TRACE]:"traces",[e.TransportItemType.EVENT]:"events"};function $(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 z="Error";let U;function K(n,t,r,i,a,l){var u;t.debug("Initializing exceptions API");let c=null;U=null!==(u=r.parseStacktrace)&&void 0!==u?u:U;const d=e=>{t.debug("Changing stacktrace parser"),U=null!=e?e:U},{ignoreErrors:g=[]}=r;return d(r.parseStacktrace),{changeStacktraceParser:d,getStacktraceParser:()=>U,pushError:(n,{skipDedupe:u,stackFrames:d,type:p,context:f,spanContext:m,timestampOverwriteMs:v}={})=>{if(function(e,n){const{message:t,name:r,stack:i}=n;return a=e,s=t+" "+r+" "+i,a.some((e=>o(e)?s.includes(e):!!s.match(e)));var a,s}(g,n))return;const b={meta:i.value,payload:{type:p||n.name||z,value:n.message,timestamp:v?y(v):E(),trace:m?{trace_id:m.traceId,span_id:m.spanId}:l.getTraceContext(),context:x(Object.assign(Object.assign({},W(n)),null!=f?f:{}))},type:e.TransportItemType.EXCEPTION};(null==(d=null!=d?d:n.stack?null==U?void 0:U(n).frames:void 0)?void 0:d.length)&&(b.payload.stacktrace={frames:d});const I={type:b.payload.type,value:b.payload.value,stackTrace:b.payload.stacktrace,context:b.payload.context};u||!r.dedupe||s(c)||!h(I,c)?(c=I,t.debug("Pushing exception\n",b),a.execute(b)):t.debug("Skipping error push because it is the same as the last one\n",b.payload)}}}function W(e){let n=e.cause;return f(n)?n=e.cause.toString():null!==n&&(u(e.cause)||d(e.cause))?n=R(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,i,a){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,i,a);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},l),K(0,t,r,i,a,l)),function(e,n,t,r){let i,a,s,l;n.debug("Initializing meta API");const u=e=>{a&&r.remove(a),a={user:e},r.add(a)},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({},b(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==s?void 0:s.view)||void 0===t?void 0:t.name)===(null==e?void 0:e.name))return;const i=s;s={view:e},r.add(s),i&&r.remove(i)},getView:()=>r.value.view,setPage:e=>{var n;const t=o(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,i)),function(n,t,r,i,a,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:T,context:x(l),timestamp:f?y(f):E(),trace:p?{trace_id:p.traceId,span_id:p.spanId}:o.getTraceContext()},meta:i.value},v={message:m.payload.message,level:m.payload.level,context:m.payload.context};if(!g&&r.dedupe&&!s(u)&&h(v,u))return void t.debug("Skipping log push because it is the same as the last one\n",m.payload);u=v,t.debug("Pushing log\n",m),a.execute(m)}catch(e){t.error("Error pushing log\n",e)}}}}(0,t,r,i,a,l)),function(n,t,r,i,a,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?y(g):E(),context:x(c)}),meta:i.value},f={type:p.payload.type,values:p.payload.values,context:p.payload.context};if(!u&&r.dedupe&&!s(l)&&h(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),a.execute(p)}catch(e){t.error("Error pushing measurement\n",e)}}}}(0,t,r,i,a,l)),function(n,t,r,i,a,o){let l=null;return{pushEvent:(n,u,c,{skipDedupe:d,spanContext:g,timestampOverwriteMs:p}={})=>{try{const f={meta:i.value,payload:{name:n,domain:null!=c?c:r.eventDomain,attributes:x(u),timestamp:p?y(p):E(),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&&!s(l)&&h(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),a.execute(f)}catch(e){t.error("Error pushing event",e)}}}}(0,t,r,i,a,l))}const J="1.14.1";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(j,q,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function Y(){return q in j}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 j)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(j,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}(e.faro),e.faro}e.faro={};return e.BaseExtension=V,e.BaseInstrumentation=class extends V{constructor(){super(...arguments),this.api={},this.transports={}}},e.BaseTransport=class extends V{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=O,e.createInternalLogger=P,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=h,e.defaultBatchingConfig={enabled:!0,sendTimeout:250,itemLimit:50},e.defaultErrorArgsSerializer=e=>e.map((e=>u(e)?R(e):String(e))).join(" "),e.defaultExceptionType=z,e.defaultGlobalObjectKey="faro",e.defaultInternalLoggerLevel=w,e.defaultLogArgsSerializer=H,e.defaultLogLevel=T,e.defaultUnpatchedConsole=C,e.genShortID=function(e=10){return Array.from(Array(e)).map((()=>S[Math.floor(59*Math.random())])).join("")},e.getCircularDependencyReplacer=N,e.getCurrentTimestamp=E,e.getInternalFaroFromGlobalObject=function(){return j[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=G[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:$(t.traces,n.payload.resourceSpans)})}})),t},e.globalObject=j,e.initializeFaro=function(e){const n=B(e),r=D(n,e);if(Y()&&!e.isolate)return void r.error('Faro is already registered. Either add instrumentations, transports etc. to the global faro instance or use the "isolate" property');r.debug("Initializing");const i=function(e,n){let t=[],r=[];const i=()=>t.reduce(((e,n)=>Object.assign(e,c(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,r),a=t(n,r,e,i),s=X(0,r,e,i,a),o=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,r,e,i,a,s),l=Z(n,r,e,i,a,s,o);return function(e){var n,t;const r={sdk:{version:J},app:{bundleId:e.config.app.name&&(i=e.config.app.name,null==j?void 0:j[`__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:[])}(l),function(e){e.transports.add(...e.config.transports),e.transports.addBeforeSendHooks(e.config.beforeSend)}(l),function(e){e.instrumentations.add(...e.config.instrumentations)}(l),l},e.internalGlobalObjectKey=q,e.isArray=d,e.isBoolean=e=>r(e,"boolean"),e.isDomError=e=>i(e,"DOMError"),e.isDomException=e=>i(e,"DOMException"),e.isElement=e=>m&&a(e,Element),e.isElementDefined=m,e.isEmpty=b,e.isError=f,e.isErrorDefined=p,e.isErrorEvent=e=>i(e,"ErrorEvent"),e.isEvent=e=>g&&a(e,Event),e.isEventDefined=g,e.isFunction=c,e.isInstanceOf=a,e.isInt=e=>l(e)&&Number.isInteger(e),e.isInternalFaroOnGlobalObject=Y,e.isMap=e=>v&&a(e,Map),e.isMapDefined=v,e.isNull=s,e.isNumber=l,e.isObject=u,e.isPrimitive=e=>!u(e)&&!c(e),e.isRegExp=e=>i(e,"RegExp"),e.isString=o,e.isSymbol=e=>r(e,"symbol"),e.isSyntheticEvent=e=>u(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e,e.isThenable=e=>c(null==e?void 0:e.then),e.isToString=i,e.isTypeof=r,e.isUndefined=e=>r(e,"undefined"),e.noop=L,e.setInternalFaroOnGlobalObject=Q,e.stringifyExternalJson=R,e.stringifyObjectValues=x,e.transportItemTypeToBodyKey=G,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: MetaOverrides;
7
+ overrides: OverridesAvailableThroughApi;
7
8
  }) => void;
8
9
  resetSession: () => void;
9
10
  getSession: () => MetaSession | undefined;
10
11
  setView: (view?: MetaView | undefined, options?: {
11
- overrides: MetaOverrides;
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 {};
@@ -0,0 +1,2 @@
1
+ import type { Patterns } from '../config/types';
2
+ export declare function shouldIgnoreEvent(patterns: Patterns, msg: string): boolean;
@@ -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 follwoing levels
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
- * Overrides are instructions that allow the receiver to override certain properties.
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.13.3";
7
+ readonly version = "1.14.1";
8
8
  items: TransportItem[];
9
9
  constructor(ignoreURLs?: Patterns);
10
10
  send(items: TransportItem[]): void | Promise<void>;
@@ -1,8 +1,6 @@
1
- import type { Config, Patterns } from '../config';
1
+ import type { Config } from '../config';
2
2
  import type { InternalLogger } from '../internalLogger';
3
3
  import type { Metas } from '../metas';
4
4
  import type { UnpatchedConsole } from '../unpatchedConsole';
5
- import type { BeforeSendHook, Transports } from './types';
6
- export declare function shouldIgnoreEvent(patterns: Patterns, msg: string): boolean;
7
- export declare function createBeforeSendHookFromIgnorePatterns(patterns: Patterns): BeforeSendHook;
5
+ import type { Transports } from './types';
8
6
  export declare function initializeTransports(unpatchedConsole: UnpatchedConsole, internalLogger: InternalLogger, config: Config, metas: Metas): Transports;
@@ -28,7 +28,6 @@ export interface TransportBody {
28
28
  export interface Transports {
29
29
  add: (...transports: Transport[]) => void;
30
30
  addBeforeSendHooks: (...hooks: Array<BeforeSendHook | undefined>) => void;
31
- addIgnoreErrorsPatterns: (...ignoreErrorsPatterns: Array<Patterns | undefined>) => void;
32
31
  execute: (transportItem: TransportItem) => void;
33
32
  getBeforeSendHooks: () => BeforeSendHook[];
34
33
  isPaused: () => boolean;
@@ -1 +1 @@
1
- export declare const VERSION = "1.13.3";
1
+ export declare const VERSION = "1.14.1";
@@ -15,6 +15,7 @@ exports.initializeExceptionsAPI = void 0;
15
15
  var transports_1 = require("../../transports");
16
16
  var utils_1 = require("../../utils");
17
17
  var date_1 = require("../../utils/date");
18
+ var utils_2 = require("../utils");
18
19
  var const_1 = require("./const");
19
20
  var stacktraceParser;
20
21
  function initializeExceptionsAPI(_unpatchedConsole, internalLogger, config, metas, transports, tracesApi) {
@@ -27,13 +28,16 @@ function initializeExceptionsAPI(_unpatchedConsole, internalLogger, config, meta
27
28
  stacktraceParser = newStacktraceParser !== null && newStacktraceParser !== void 0 ? newStacktraceParser : stacktraceParser;
28
29
  };
29
30
  var getStacktraceParser = function () { return stacktraceParser; };
31
+ var _b = config.ignoreErrors, ignoreErrors = _b === void 0 ? [] : _b;
30
32
  var pushError = function (error, _a) {
31
33
  var _b = _a === void 0 ? {} : _a, skipDedupe = _b.skipDedupe, stackFrames = _b.stackFrames, type = _b.type, context = _b.context, spanContext = _b.spanContext, timestampOverwriteMs = _b.timestampOverwriteMs;
32
- type = type || error.name || const_1.defaultExceptionType;
34
+ if (isErrorIgnored(ignoreErrors, error)) {
35
+ return;
36
+ }
33
37
  var item = {
34
38
  meta: metas.value,
35
39
  payload: {
36
- type: type,
40
+ type: type || error.name || const_1.defaultExceptionType,
37
41
  value: error.message,
38
42
  timestamp: timestampOverwriteMs ? (0, date_1.timestampToIsoString)(timestampOverwriteMs) : (0, utils_1.getCurrentTimestamp)(),
39
43
  trace: spanContext
@@ -89,4 +93,8 @@ function parseCause(error) {
89
93
  }
90
94
  return cause == null ? {} : { cause: cause };
91
95
  }
96
+ function isErrorIgnored(ignoreErrors, error) {
97
+ var message = error.message, name = error.name, stack = error.stack;
98
+ return (0, utils_2.shouldIgnoreEvent)(ignoreErrors, message + ' ' + name + ' ' + stack);
99
+ }
92
100
  //# sourceMappingURL=initialize.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/exceptions/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAGA,+CAAqD;AAGrD,qCASqB;AACrB,yCAAwD;AAGxD,iCAA+C;AAG/C,IAAI,gBAA8C,CAAC;AAEnD,SAAgB,uBAAuB,CACrC,iBAAmC,EACnC,cAA8B,EAC9B,MAAc,EACd,KAAY,EACZ,UAAsB,EACtB,SAAoB;;IAEpB,cAAc,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAEpD,IAAI,WAAW,GAA6E,IAAI,CAAC;IAEjG,gBAAgB,GAAG,MAAA,MAAM,CAAC,eAAe,mCAAI,gBAAgB,CAAC;IAE9D,IAAM,sBAAsB,GAA4C,UAAC,mBAAmB;QAC1F,cAAc,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAEnD,gBAAgB,GAAG,mBAAmB,aAAnB,mBAAmB,cAAnB,mBAAmB,GAAI,gBAAgB,CAAC;IAC7D,CAAC,CAAC;IAEF,IAAM,mBAAmB,GAAyC,cAAM,OAAA,gBAAgB,EAAhB,CAAgB,CAAC;IAEzF,IAAM,SAAS,GAA+B,UAC5C,KAAK,EACL,EAAkF;YAAlF,qBAAgF,EAAE,KAAA,EAAhF,UAAU,gBAAA,EAAE,WAAW,iBAAA,EAAE,IAAI,UAAA,EAAE,OAAO,aAAA,EAAE,WAAW,iBAAA,EAA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AK,OAAA,EAAE,CAAC;AACxC,CAAC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItemType } from '../../transports';\nimport type { TransportItem, Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport {\n deepEqual,\n getCurrentTimestamp,\n isArray,\n isError,\n isNull,\n isObject,\n stringifyExternalJson,\n stringifyObjectValues,\n} from '../../utils';\nimport { timestampToIsoString } from '../../utils/date';\nimport type { TracesAPI } from '../traces';\n\nimport { defaultExceptionType } from './const';\nimport type { ErrorWithIndexProperties, ExceptionEvent, ExceptionsAPI, StacktraceParser } from './types';\n\nlet stacktraceParser: StacktraceParser | undefined;\n\nexport function initializeExceptionsAPI(\n _unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas,\n transports: Transports,\n tracesApi: TracesAPI\n): ExceptionsAPI {\n internalLogger.debug('Initializing exceptions API');\n\n let lastPayload: Pick<ExceptionEvent, 'type' | 'value' | 'stacktrace' | 'context'> | null = null;\n\n stacktraceParser = config.parseStacktrace ?? stacktraceParser;\n\n const changeStacktraceParser: ExceptionsAPI['changeStacktraceParser'] = (newStacktraceParser) => {\n internalLogger.debug('Changing stacktrace parser');\n\n stacktraceParser = newStacktraceParser ?? stacktraceParser;\n };\n\n const getStacktraceParser: ExceptionsAPI['getStacktraceParser'] = () => stacktraceParser;\n\n const pushError: ExceptionsAPI['pushError'] = (\n error,\n { skipDedupe, stackFrames, type, context, spanContext, timestampOverwriteMs } = {}\n ) => {\n type = type || error.name || defaultExceptionType;\n\n const item: TransportItem<ExceptionEvent> = {\n meta: metas.value,\n payload: {\n type,\n value: error.message,\n timestamp: timestampOverwriteMs ? timestampToIsoString(timestampOverwriteMs) : getCurrentTimestamp(),\n trace: spanContext\n ? {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n }\n : tracesApi.getTraceContext(),\n context: stringifyObjectValues({\n ...parseCause(error),\n ...(context ?? {}),\n }),\n },\n type: TransportItemType.EXCEPTION,\n };\n\n stackFrames = stackFrames ?? (error.stack ? stacktraceParser?.(error).frames : undefined);\n\n if (stackFrames?.length) {\n item.payload.stacktrace = {\n frames: stackFrames,\n };\n }\n\n const testingPayload = {\n type: item.payload.type,\n value: item.payload.value,\n stackTrace: item.payload.stacktrace,\n context: item.payload.context,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping error push because it is the same as the last one\\n', item.payload);\n\n return;\n }\n\n lastPayload = testingPayload;\n\n internalLogger.debug('Pushing exception\\n', item);\n\n transports.execute(item);\n };\n\n changeStacktraceParser(config.parseStacktrace);\n\n return {\n changeStacktraceParser,\n getStacktraceParser,\n pushError,\n };\n}\nfunction parseCause(error: ErrorWithIndexProperties): {} | { cause: string } {\n let cause = error.cause;\n\n if (isError(cause)) {\n cause = error.cause.toString();\n // typeof operator on null returns \"object\". This is a well-known quirk in JavaScript and is considered a bug that cannot be fixed due to backward compatibility issues.\n // MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#typeof_null\n } else if (cause !== null && (isObject(error.cause) || isArray(error.cause))) {\n cause = stringifyExternalJson(error.cause);\n } else if (cause != null) {\n cause = error.cause.toString();\n }\n\n return cause == null ? {} : { cause };\n}\n"]}
1
+ {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/exceptions/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAGA,+CAAqD;AAGrD,qCASqB;AACrB,yCAAwD;AAExD,kCAA6C;AAE7C,iCAA+C;AAG/C,IAAI,gBAA8C,CAAC;AAEnD,SAAgB,uBAAuB,CACrC,iBAAmC,EACnC,cAA8B,EAC9B,MAAc,EACd,KAAY,EACZ,UAAsB,EACtB,SAAoB;;IAEpB,cAAc,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAEpD,IAAI,WAAW,G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vFD,0DAuFC;AAED,SAAS,UAAU,CAAC,KAA+B;IACjD,IAAI,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAExB,IAAI,IAAA,eAAO,EAAC,KAAK,CAAC,EAAE;QAClB,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC/B,wKAAwK;QACxK,sGAAsG;KACvG;SAAM,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,IAAA,gBAAQ,EAAC,KAAK,CAAC,KAAK,CAAC,IAAI,IAAA,eAAO,EAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE;QAC5E,KAAK,GAAG,IAAA,6BAAqB,EAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KAC5C;SAAM,IAAI,KAAK,IAAI,IAAI,EAAE;QACxB,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;KAChC;IAED,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,OAAA,EAAE,CAAC;AACxC,CAAC;AAED,SAAS,cAAc,CAAC,YAAsB,EAAE,KAA+B;IACrE,IAAA,OAAO,GAAkB,KAAK,QAAvB,EAAE,IAAI,GAAY,KAAK,KAAjB,EAAE,KAAK,GAAK,KAAK,MAAV,CAAW;IACvC,OAAO,IAAA,yBAAiB,EAAC,YAAY,EAAE,OAAO,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import type { Config, Patterns } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItemType } from '../../transports';\nimport type { TransportItem, Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport {\n deepEqual,\n getCurrentTimestamp,\n isArray,\n isError,\n isNull,\n isObject,\n stringifyExternalJson,\n stringifyObjectValues,\n} from '../../utils';\nimport { timestampToIsoString } from '../../utils/date';\nimport type { TracesAPI } from '../traces';\nimport { shouldIgnoreEvent } from '../utils';\n\nimport { defaultExceptionType } from './const';\nimport type { ErrorWithIndexProperties, ExceptionEvent, ExceptionsAPI, StacktraceParser } from './types';\n\nlet stacktraceParser: StacktraceParser | undefined;\n\nexport function initializeExceptionsAPI(\n _unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas,\n transports: Transports,\n tracesApi: TracesAPI\n): ExceptionsAPI {\n internalLogger.debug('Initializing exceptions API');\n\n let lastPayload: Pick<ExceptionEvent, 'type' | 'value' | 'stacktrace' | 'context'> | null = null;\n\n stacktraceParser = config.parseStacktrace ?? stacktraceParser;\n\n const changeStacktraceParser: ExceptionsAPI['changeStacktraceParser'] = (newStacktraceParser) => {\n internalLogger.debug('Changing stacktrace parser');\n\n stacktraceParser = newStacktraceParser ?? stacktraceParser;\n };\n\n const getStacktraceParser: ExceptionsAPI['getStacktraceParser'] = () => stacktraceParser;\n\n const { ignoreErrors = [] } = config;\n\n const pushError: ExceptionsAPI['pushError'] = (\n error,\n { skipDedupe, stackFrames, type, context, spanContext, timestampOverwriteMs } = {}\n ) => {\n if (isErrorIgnored(ignoreErrors, error)) {\n return;\n }\n\n const item: TransportItem<ExceptionEvent> = {\n meta: metas.value,\n payload: {\n type: type || error.name || defaultExceptionType,\n value: error.message,\n timestamp: timestampOverwriteMs ? timestampToIsoString(timestampOverwriteMs) : getCurrentTimestamp(),\n trace: spanContext\n ? {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n }\n : tracesApi.getTraceContext(),\n context: stringifyObjectValues({\n ...parseCause(error),\n ...(context ?? {}),\n }),\n },\n type: TransportItemType.EXCEPTION,\n };\n\n stackFrames = stackFrames ?? (error.stack ? stacktraceParser?.(error).frames : undefined);\n\n if (stackFrames?.length) {\n item.payload.stacktrace = {\n frames: stackFrames,\n };\n }\n\n const testingPayload = {\n type: item.payload.type,\n value: item.payload.value,\n stackTrace: item.payload.stacktrace,\n context: item.payload.context,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping error push because it is the same as the last one\\n', item.payload);\n\n return;\n }\n\n lastPayload = testingPayload;\n\n internalLogger.debug('Pushing exception\\n', item);\n\n transports.execute(item);\n };\n\n changeStacktraceParser(config.parseStacktrace);\n\n return {\n changeStacktraceParser,\n getStacktraceParser,\n pushError,\n };\n}\n\nfunction parseCause(error: ErrorWithIndexProperties): {} | { cause: string } {\n let cause = error.cause;\n\n if (isError(cause)) {\n cause = error.cause.toString();\n // typeof operator on null returns \"object\". This is a well-known quirk in JavaScript and is considered a bug that cannot be fixed due to backward compatibility issues.\n // MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#typeof_null\n } else if (cause !== null && (isObject(error.cause) || isArray(error.cause))) {\n cause = stringifyExternalJson(error.cause);\n } else if (cause != null) {\n cause = error.cause.toString();\n }\n\n return cause == null ? {} : { cause };\n}\n\nfunction isErrorIgnored(ignoreErrors: Patterns, error: ErrorWithIndexProperties): boolean {\n const { message, name, stack } = error;\n return shouldIgnoreEvent(ignoreErrors, message + ' ' + name + ' ' + stack);\n}\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 overrides = options === null || options === void 0 ? void 0 : options.overrides;
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)), (overrides ? { overrides: overrides } : {})),
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;QAEF,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACtB,CAAC,CAAC;IAEF,IAAM,UAAU,GAA0B,UAAC,OAAO,EAAE,OAAO;QACzD,IAAM,SAAS,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAC;QAErC,IAAI,WAAW,EAAE;YACf,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;SAC3B;QAED,WAAW,GAAG;YACZ,OAAO,wBAEF,CAAC,IAAA,YAAO,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,GACxC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,WAAA,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CACpC;SACF,CAAC;QAEF,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,C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AC,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;AAzGD,8CAyGC","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 overrides = options?.overrides;\n\n if (metaSession) {\n metas.remove(metaSession);\n }\n\n metaSession = {\n session: {\n // if session is empty, session manager force creates a new session\n ...(isEmpty(session) ? undefined : session),\n ...(overrides ? { 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
+ {"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;QAEF,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACtB,CAAC,CAAC;IAEF,IAAM,UAAU,GAA0B,UAAC,OAAO,EAAE,OAAO;;QACzD,IAAM,YAAY,GA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F,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: MetaOverrides;\n }\n ) => void;\n resetSession: () => void;\n getSession: () => MetaSession | undefined;\n setView: (\n view?: MetaView | undefined,\n options?: {\n overrides: MetaOverrides;\n }\n ) => void;\n getView: () => MetaView | undefined;\n /**\n * If a string is provided, it will be used as the page id.\n * @returns\n */\n setPage: (page?: MetaPage | string | undefined) => void;\n getPage: () => MetaPage | undefined;\n}\n"]}
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"]}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.shouldIgnoreEvent = void 0;
4
+ var is_1 = require("../utils/is");
5
+ function shouldIgnoreEvent(patterns, msg) {
6
+ return patterns.some(function (pattern) {
7
+ return (0, is_1.isString)(pattern) ? msg.includes(pattern) : !!msg.match(pattern);
8
+ });
9
+ }
10
+ exports.shouldIgnoreEvent = shouldIgnoreEvent;
11
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/api/utils.ts"],"names":[],"mappings":";;;AACA,kCAAuC;AAEvC,SAAgB,iBAAiB,CAAC,QAAkB,EAAE,GAAW;IAC/D,OAAO,QAAQ,CAAC,IAAI,CAAC,UAAC,OAAO;QAC3B,OAAO,IAAA,aAAQ,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;AACL,CAAC;AAJD,8CAIC","sourcesContent":["import type { Patterns } from '../config/types';\nimport { isString } from '../utils/is';\n\nexport function shouldIgnoreEvent(patterns: Patterns, msg: string): boolean {\n return patterns.some((pattern) => {\n return isString(pattern) ? msg.includes(pattern) : !!msg.match(pattern);\n });\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 follwoing 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 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\nexport type Patterns = Array<string | RegExp>;\n"]}
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 * Overrides are instructions that allow the receiver to override certain properties.\n */\nexport type MetaOverrides = {\n serviceName?: string;\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"]}
@@ -9,29 +9,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
9
9
  return to.concat(ar || Array.prototype.slice.call(from));
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.initializeTransports = exports.createBeforeSendHookFromIgnorePatterns = exports.shouldIgnoreEvent = void 0;
13
- var utils_1 = require("../utils");
12
+ exports.initializeTransports = void 0;
14
13
  var batchExecutor_1 = require("./batchExecutor");
15
- var const_1 = require("./const");
16
- function shouldIgnoreEvent(patterns, msg) {
17
- return patterns.some(function (pattern) {
18
- return (0, utils_1.isString)(pattern) ? msg.includes(pattern) : !!msg.match(pattern);
19
- });
20
- }
21
- exports.shouldIgnoreEvent = shouldIgnoreEvent;
22
- function createBeforeSendHookFromIgnorePatterns(patterns) {
23
- return function (item) {
24
- if (item.type === const_1.TransportItemType.EXCEPTION && item.payload) {
25
- var evt = item.payload;
26
- var msg = "".concat(evt.type, ": ").concat(evt.value);
27
- if (shouldIgnoreEvent(patterns, msg)) {
28
- return null;
29
- }
30
- }
31
- return item;
32
- };
33
- }
34
- exports.createBeforeSendHookFromIgnorePatterns = createBeforeSendHookFromIgnorePatterns;
35
14
  function initializeTransports(unpatchedConsole, internalLogger, config, metas) {
36
15
  var _a;
37
16
  internalLogger.debug('Initializing transports');
@@ -70,18 +49,6 @@ function initializeTransports(unpatchedConsole, internalLogger, config, metas) {
70
49
  }
71
50
  });
72
51
  };
73
- var addIgnoreErrorsPatterns = function () {
74
- var ignoreErrorsPatterns = [];
75
- for (var _i = 0; _i < arguments.length; _i++) {
76
- ignoreErrorsPatterns[_i] = arguments[_i];
77
- }
78
- internalLogger.debug('Adding ignoreErrorsPatterns\n', ignoreErrorsPatterns);
79
- ignoreErrorsPatterns.forEach(function (ignoreErrorsPattern) {
80
- if (ignoreErrorsPattern) {
81
- beforeSendHooks.push(createBeforeSendHookFromIgnorePatterns(ignoreErrorsPattern));
82
- }
83
- });
84
- };
85
52
  var applyBeforeSendHooks = function (items) {
86
53
  var filteredItems = items;
87
54
  for (var _i = 0, beforeSendHooks_1 = beforeSendHooks; _i < beforeSendHooks_1.length; _i++) {
@@ -191,7 +158,6 @@ function initializeTransports(unpatchedConsole, internalLogger, config, metas) {
191
158
  return {
192
159
  add: add,
193
160
  addBeforeSendHooks: addBeforeSendHooks,
194
- addIgnoreErrorsPatterns: addIgnoreErrorsPatterns,
195
161
  getBeforeSendHooks: getBeforeSendHooks,
196
162
  execute: execute,
197
163
  isPaused: isPaused,
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../src/transports/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;;AAMA,kCAAoC;AAEpC,iDAAgD;AAChD,iCAA4C;AAG5C,SAAgB,iBAAiB,C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AA;QACH,kBAAkB,oBAAA;QAClB,uBAAuB,yBAAA;QACvB,kBAAkB,oBAAA;QAClB,OAAO,SAAA;QACP,QAAQ,UAAA;QACR,KAAK,OAAA;QACL,MAAM,QAAA;QACN,qBAAqB,uBAAA;QACrB,IAAI,UAAU;YACZ,yBAAW,UAAU,QAAE;QACzB,CAAC;QACD,OAAO,SAAA;KACR,CAAC;AACJ,CAAC;AAhMD,oDAgMC","sourcesContent":["import type { TransportItem } from '..';\nimport type { ExceptionEvent } from '../api';\nimport type { Config, Patterns } from '../config';\nimport type { InternalLogger } from '../internalLogger';\nimport type { Metas } from '../metas';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\nimport { isString } from '../utils';\n\nimport { BatchExecutor } from './batchExecutor';\nimport { TransportItemType } from './const';\nimport type { BeforeSendHook, Transport, Transports } from './types';\n\nexport function shouldIgnoreEvent(patterns: Patterns, msg: string): boolean {\n return patterns.some((pattern) => {\n return isString(pattern) ? msg.includes(pattern) : !!msg.match(pattern);\n });\n}\n\nexport function createBeforeSendHookFromIgnorePatterns(patterns: Patterns): BeforeSendHook {\n return (item: TransportItem) => {\n if (item.type === TransportItemType.EXCEPTION && item.payload) {\n const evt = item.payload as ExceptionEvent;\n const msg = `${evt.type}: ${evt.value}`;\n\n if (shouldIgnoreEvent(patterns, msg)) {\n return null;\n }\n }\n\n return item;\n };\n}\n\nexport function initializeTransports(\n unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas\n): Transports {\n internalLogger.debug('Initializing transports');\n\n const transports: Transport[] = [];\n\n let paused = config.paused;\n\n let beforeSendHooks: BeforeSendHook[] = [];\n\n const add: Transports['add'] = (...newTransports) => {\n internalLogger.debug('Adding transports');\n\n newTransports.forEach((newTransport) => {\n internalLogger.debug(`Adding \"${newTransport.name}\" transport`);\n\n const exists = transports.some((existingTransport) => existingTransport === newTransport);\n\n if (exists) {\n internalLogger.warn(`Transport ${newTransport.name} is already added`);\n\n return;\n }\n\n newTransport.unpatchedConsole = unpatchedConsole;\n newTransport.internalLogger = internalLogger;\n newTransport.config = config;\n newTransport.metas = metas;\n\n transports.push(newTransport);\n });\n };\n\n const addBeforeSendHooks: Transports['addBeforeSendHooks'] = (...newBeforeSendHooks) => {\n internalLogger.debug('Adding beforeSendHooks\\n', beforeSendHooks);\n\n newBeforeSendHooks.forEach((beforeSendHook) => {\n if (beforeSendHook) {\n beforeSendHooks.push(beforeSendHook);\n }\n });\n };\n\n const addIgnoreErrorsPatterns: Transports['addIgnoreErrorsPatterns'] = (...ignoreErrorsPatterns) => {\n internalLogger.debug('Adding ignoreErrorsPatterns\\n', ignoreErrorsPatterns);\n\n ignoreErrorsPatterns.forEach((ignoreErrorsPattern) => {\n if (ignoreErrorsPattern) {\n beforeSendHooks.push(createBeforeSendHookFromIgnorePatterns(ignoreErrorsPattern));\n }\n });\n };\n\n const applyBeforeSendHooks = (items: TransportItem[]): TransportItem[] => {\n let filteredItems = items;\n for (const hook of beforeSendHooks) {\n const modified = filteredItems.map(hook).filter(Boolean) as TransportItem[];\n\n if (modified.length === 0) {\n return [];\n }\n\n filteredItems = modified;\n }\n return filteredItems;\n };\n\n const batchedSend = (items: TransportItem[]) => {\n const filteredItems = applyBeforeSendHooks(items);\n\n if (filteredItems.length === 0) {\n return;\n }\n\n for (const transport of transports) {\n internalLogger.debug(`Transporting item using ${transport.name}\\n`, filteredItems);\n if (transport.isBatched()) {\n transport.send(filteredItems);\n }\n }\n };\n\n const instantSend = (item: TransportItem) => {\n // prevent all beforeSend hooks being executed twice if batching is enabled.\n if (config.batching?.enabled && transports.every((transport) => transport.isBatched())) {\n return;\n }\n\n const [filteredItem] = applyBeforeSendHooks([item]);\n\n if (filteredItem === undefined) {\n return;\n }\n\n for (const transport of transports) {\n internalLogger.debug(`Transporting item using ${transport.name}\\n`, filteredItem);\n if (!transport.isBatched()) {\n transport.send(filteredItem);\n } else if (!config.batching?.enabled) {\n transport.send([filteredItem]);\n }\n }\n };\n\n let batchExecutor: BatchExecutor | undefined;\n\n if (config.batching?.enabled) {\n batchExecutor = new BatchExecutor(batchedSend, {\n sendTimeout: config.batching.sendTimeout,\n itemLimit: config.batching.itemLimit,\n paused,\n });\n }\n\n // Send a signal to the appropriate transports\n //\n // 1. If SDK is paused, early return\n // 2. If batching is not enabled send the signal to all transports\n // instantly.\n // 3i. If batching is enabled, enqueue the signal\n // 3ii. Send the signal instantly to all un-batched transports\n const execute: Transports['execute'] = (item) => {\n if (paused) {\n return;\n }\n\n if (config.batching?.enabled) {\n batchExecutor?.addItem(item);\n }\n\n instantSend(item);\n };\n\n const getBeforeSendHooks: Transports['getBeforeSendHooks'] = () => [...beforeSendHooks];\n\n const isPaused: Transports['isPaused'] = () => paused;\n\n const pause: Transports['pause'] = () => {\n internalLogger.debug('Pausing transports');\n batchExecutor?.pause();\n\n paused = true;\n };\n\n const remove: Transports['remove'] = (...transportsToRemove) => {\n internalLogger.debug('Removing transports');\n\n transportsToRemove.forEach((transportToRemove) => {\n internalLogger.debug(`Removing \"${transportToRemove.name}\" transport`);\n\n const existingTransportIndex = transports.indexOf(transportToRemove);\n\n if (existingTransportIndex === -1) {\n internalLogger.warn(`Transport \"${transportToRemove.name}\" is not added`);\n\n return;\n }\n\n transports.splice(existingTransportIndex, 1);\n });\n };\n\n const removeBeforeSendHooks: Transports['removeBeforeSendHooks'] = (...beforeSendHooksToRemove) => {\n beforeSendHooks.filter((beforeSendHook) => !beforeSendHooksToRemove.includes(beforeSendHook));\n };\n\n const unpause: Transports['unpause'] = () => {\n internalLogger.debug('Unpausing transports');\n batchExecutor?.start();\n\n paused = false;\n };\n\n return {\n add,\n addBeforeSendHooks,\n addIgnoreErrorsPatterns,\n getBeforeSendHooks,\n execute,\n isPaused,\n pause,\n remove,\n removeBeforeSendHooks,\n get transports() {\n return [...transports];\n },\n unpause,\n };\n}\n"]}
1
+ {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../src/transports/initialize.ts"],"names":[],"mappings":";;;;;;;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AAsB,CAAC,CAAC;QAC7C,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,KAAK,EAAE,CAAC;QAEvB,MAAM,GAAG,KAAK,CAAC;IACjB,CAAC,CAAC;IAEF,OAAO;QACL,GAAG,KAAA;QACH,kBAAkB,oBAAA;QAClB,kBAAkB,oBAAA;QAClB,OAAO,SAAA;QACP,QAAQ,UAAA;QACR,KAAK,OAAA;QACL,MAAM,QAAA;QACN,qBAAqB,uBAAA;QACrB,IAAI,UAAU;YACZ,yBAAW,UAAU,QAAE;QACzB,CAAC;QACD,OAAO,SAAA;KACR,CAAC;AACJ,CAAC;AArLD,oDAqLC","sourcesContent":["import type { TransportItem } from '..';\nimport type { Config } from '../config';\nimport type { InternalLogger } from '../internalLogger';\nimport type { Metas } from '../metas';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\n\nimport { BatchExecutor } from './batchExecutor';\nimport type { BeforeSendHook, Transport, Transports } from './types';\n\nexport function initializeTransports(\n unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas\n): Transports {\n internalLogger.debug('Initializing transports');\n\n const transports: Transport[] = [];\n\n let paused = config.paused;\n\n let beforeSendHooks: BeforeSendHook[] = [];\n\n const add: Transports['add'] = (...newTransports) => {\n internalLogger.debug('Adding transports');\n\n newTransports.forEach((newTransport) => {\n internalLogger.debug(`Adding \"${newTransport.name}\" transport`);\n\n const exists = transports.some((existingTransport) => existingTransport === newTransport);\n\n if (exists) {\n internalLogger.warn(`Transport ${newTransport.name} is already added`);\n\n return;\n }\n\n newTransport.unpatchedConsole = unpatchedConsole;\n newTransport.internalLogger = internalLogger;\n newTransport.config = config;\n newTransport.metas = metas;\n\n transports.push(newTransport);\n });\n };\n\n const addBeforeSendHooks: Transports['addBeforeSendHooks'] = (...newBeforeSendHooks) => {\n internalLogger.debug('Adding beforeSendHooks\\n', beforeSendHooks);\n\n newBeforeSendHooks.forEach((beforeSendHook) => {\n if (beforeSendHook) {\n beforeSendHooks.push(beforeSendHook);\n }\n });\n };\n\n const applyBeforeSendHooks = (items: TransportItem[]): TransportItem[] => {\n let filteredItems = items;\n for (const hook of beforeSendHooks) {\n const modified = filteredItems.map(hook).filter(Boolean) as TransportItem[];\n\n if (modified.length === 0) {\n return [];\n }\n\n filteredItems = modified;\n }\n return filteredItems;\n };\n\n const batchedSend = (items: TransportItem[]) => {\n const filteredItems = applyBeforeSendHooks(items);\n\n if (filteredItems.length === 0) {\n return;\n }\n\n for (const transport of transports) {\n internalLogger.debug(`Transporting item using ${transport.name}\\n`, filteredItems);\n if (transport.isBatched()) {\n transport.send(filteredItems);\n }\n }\n };\n\n const instantSend = (item: TransportItem) => {\n // prevent all beforeSend hooks being executed twice if batching is enabled.\n if (config.batching?.enabled && transports.every((transport) => transport.isBatched())) {\n return;\n }\n\n const [filteredItem] = applyBeforeSendHooks([item]);\n\n if (filteredItem === undefined) {\n return;\n }\n\n for (const transport of transports) {\n internalLogger.debug(`Transporting item using ${transport.name}\\n`, filteredItem);\n if (!transport.isBatched()) {\n transport.send(filteredItem);\n } else if (!config.batching?.enabled) {\n transport.send([filteredItem]);\n }\n }\n };\n\n let batchExecutor: BatchExecutor | undefined;\n\n if (config.batching?.enabled) {\n batchExecutor = new BatchExecutor(batchedSend, {\n sendTimeout: config.batching.sendTimeout,\n itemLimit: config.batching.itemLimit,\n paused,\n });\n }\n\n // Send a signal to the appropriate transports\n //\n // 1. If SDK is paused, early return\n // 2. If batching is not enabled send the signal to all transports\n // instantly.\n // 3i. If batching is enabled, enqueue the signal\n // 3ii. Send the signal instantly to all un-batched transports\n const execute: Transports['execute'] = (item) => {\n if (paused) {\n return;\n }\n\n if (config.batching?.enabled) {\n batchExecutor?.addItem(item);\n }\n\n instantSend(item);\n };\n\n const getBeforeSendHooks: Transports['getBeforeSendHooks'] = () => [...beforeSendHooks];\n\n const isPaused: Transports['isPaused'] = () => paused;\n\n const pause: Transports['pause'] = () => {\n internalLogger.debug('Pausing transports');\n batchExecutor?.pause();\n\n paused = true;\n };\n\n const remove: Transports['remove'] = (...transportsToRemove) => {\n internalLogger.debug('Removing transports');\n\n transportsToRemove.forEach((transportToRemove) => {\n internalLogger.debug(`Removing \"${transportToRemove.name}\" transport`);\n\n const existingTransportIndex = transports.indexOf(transportToRemove);\n\n if (existingTransportIndex === -1) {\n internalLogger.warn(`Transport \"${transportToRemove.name}\" is not added`);\n\n return;\n }\n\n transports.splice(existingTransportIndex, 1);\n });\n };\n\n const removeBeforeSendHooks: Transports['removeBeforeSendHooks'] = (...beforeSendHooksToRemove) => {\n beforeSendHooks.filter((beforeSendHook) => !beforeSendHooksToRemove.includes(beforeSendHook));\n };\n\n const unpause: Transports['unpause'] = () => {\n internalLogger.debug('Unpausing transports');\n batchExecutor?.start();\n\n paused = false;\n };\n\n return {\n add,\n addBeforeSendHooks,\n getBeforeSendHooks,\n execute,\n isPaused,\n pause,\n remove,\n removeBeforeSendHooks,\n get transports() {\n return [...transports];\n },\n unpause,\n };\n}\n"]}
@@ -5,7 +5,6 @@ function registerInitialTransports(faro) {
5
5
  var _a;
6
6
  (_a = faro.transports).add.apply(_a, faro.config.transports);
7
7
  faro.transports.addBeforeSendHooks(faro.config.beforeSend);
8
- faro.transports.addIgnoreErrorsPatterns(faro.config.ignoreErrors);
9
8
  }
10
9
  exports.registerInitialTransports = registerInitialTransports;
11
10
  //# sourceMappingURL=registerInitial.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registerInitial.js","sourceRoot":"","sources":["../../../src/transports/registerInitial.ts"],"names":[],"mappings":";;;AAEA,SAAgB,yBAAyB,CAAC,IAAU;;IAClD,CAAA,KAAA,IAAI,CAAC,UAAU,CAAA,CAAC,GAAG,WAAI,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;IAC/C,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC3D,IAAI,CAAC,UAAU,CAAC,uBAAuB,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AACpE,CAAC;AAJD,8DAIC","sourcesContent":["import type { Faro } from '../sdk';\n\nexport function registerInitialTransports(faro: Faro): void {\n faro.transports.add(...faro.config.transports);\n faro.transports.addBeforeSendHooks(faro.config.beforeSend);\n faro.transports.addIgnoreErrorsPatterns(faro.config.ignoreErrors);\n}\n"]}
1
+ {"version":3,"file":"registerInitial.js","sourceRoot":"","sources":["../../../src/transports/registerInitial.ts"],"names":[],"mappings":";;;AAEA,SAAgB,yBAAyB,CAAC,IAAU;;IAClD,CAAA,KAAA,IAAI,CAAC,UAAU,CAAA,CAAC,GAAG,WAAI,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;IAC/C,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AAC7D,CAAC;AAHD,8DAGC","sourcesContent":["import type { Faro } from '../sdk';\n\nexport function registerInitialTransports(faro: Faro): void {\n faro.transports.add(...faro.config.transports);\n faro.transports.addBeforeSendHooks(faro.config.beforeSend);\n}\n"]}