@grafana/faro-core 1.1.4 → 1.2.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 (29) hide show
  1. package/README.md +10 -0
  2. package/dist/bundle/faro-core.iife.js +1 -1
  3. package/dist/cjs/api/exceptions/initialize.js.map +1 -1
  4. package/dist/cjs/api/measurements/initialize.js +3 -2
  5. package/dist/cjs/api/measurements/initialize.js.map +1 -1
  6. package/dist/cjs/api/measurements/types.js.map +1 -1
  7. package/dist/cjs/version.js +1 -1
  8. package/dist/cjs/version.js.map +1 -1
  9. package/dist/esm/api/exceptions/initialize.js.map +1 -1
  10. package/dist/esm/api/measurements/initialize.js +3 -2
  11. package/dist/esm/api/measurements/initialize.js.map +1 -1
  12. package/dist/esm/api/measurements/types.js.map +1 -1
  13. package/dist/esm/version.js +1 -1
  14. package/dist/esm/version.js.map +1 -1
  15. package/dist/spec/core/src/api/exceptions/initialize.js.map +1 -1
  16. package/dist/spec/core/src/api/measurements/initialize.js +3 -2
  17. package/dist/spec/core/src/api/measurements/initialize.js.map +1 -1
  18. package/dist/spec/core/src/api/measurements/initialize.test.js +25 -0
  19. package/dist/spec/core/src/api/measurements/initialize.test.js.map +1 -1
  20. package/dist/spec/core/src/api/measurements/types.js.map +1 -1
  21. package/dist/spec/core/src/version.js +1 -1
  22. package/dist/spec/core/src/version.js.map +1 -1
  23. package/dist/types/api/measurements/types.d.ts +3 -0
  24. package/dist/types/core/src/api/measurements/types.d.ts +3 -0
  25. package/dist/types/core/src/testUtils/mockTransport.d.ts +1 -1
  26. package/dist/types/core/src/version.d.ts +1 -1
  27. package/dist/types/testUtils/mockTransport.d.ts +1 -1
  28. package/dist/types/version.d.ts +1 -1
  29. package/package.json +2 -2
package/README.md CHANGED
@@ -177,6 +177,16 @@ The `api` property on the Faro instance contains all the necessary methods to pu
177
177
  },
178
178
  { skipDedupe: true }
179
179
  );
180
+
181
+ faro.api.pushMeasurement(
182
+ {
183
+ type: 'custom',
184
+ values: {
185
+ my_custom_metric: Math.random(),
186
+ },
187
+ },
188
+ { context: { hello: 'world' } }
189
+ );
180
190
  ```
181
191
 
182
192
  ## Traces
@@ -1 +1 @@
1
- var GrafanaFaroCore=function(e){"use strict";function t(e,t){return typeof e===t}function n(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function r(e,t){try{return e instanceof t}catch(e){return!1}}const a=e=>t(e,"undefined"),o=e=>t(e,"null"),i=e=>t(e,"string"),s=e=>t(e,"number")&&!isNaN(e)||t(e,"bigint"),u=e=>!o(e)&&t(e,"object"),l=e=>t(e,"function"),c=e=>n(e,"Array"),g=!a(Event),d="undefined"!=typeof Error,p="undefined"!=typeof Element,f="undefined"!=typeof Map;function m(e,n){if(e===n)return!0;if(t(e,"number")&&isNaN(e))return t(n,"number")&&isNaN(n);const r=c(e),a=c(n);if(r!==a)return!1;if(r&&a){const t=e.length;if(t!==n.length)return!1;for(let r=t;0!=r--;)if(!m(e[r],n[r]))return!1;return!0}const o=u(e),i=u(n);if(o!==i)return!1;if(e&&n&&o&&i){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(!m(e[r],n[r]))return!1;return!0}return!1}function h(){return(new Date).toISOString()}var v;e.LogLevel=void 0,(v=e.LogLevel||(e.LogLevel={})).TRACE="trace",v.DEBUG="debug",v.INFO="info",v.LOG="log",v.WARN="warn",v.ERROR="error";const b=e.LogLevel.LOG,y=[e.LogLevel.TRACE,e.LogLevel.DEBUG,e.LogLevel.INFO,e.LogLevel.LOG,e.LogLevel.WARN,e.LogLevel.ERROR];function E(){}const T="abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789";var I={},L={get exports(){return I},set exports(e){I=e}},O={};({get exports(){return O},set exports(e){O=e}}).exports=function(e,t){var n,r,a,o,i,s,u,l;for(n=3&e.length,r=e.length-n,a=t,i=3432918353,s=461845907,l=0;l<r;)u=255&e.charCodeAt(l)|(255&e.charCodeAt(++l))<<8|(255&e.charCodeAt(++l))<<16|(255&e.charCodeAt(++l))<<24,++l,a=27492+(65535&(o=5*(65535&(a=(a^=u=(65535&(u=(u=(65535&u)*i+(((u>>>16)*i&65535)<<16)&4294967295)<<15|u>>>17))*s+(((u>>>16)*s&65535)<<16)&4294967295)<<13|a>>>19))+((5*(a>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(u=0,n){case 3:u^=(255&e.charCodeAt(l+2))<<16;case 2:u^=(255&e.charCodeAt(l+1))<<8;case 1:a^=u=(65535&(u=(u=(65535&(u^=255&e.charCodeAt(l)))*i+(((u>>>16)*i&65535)<<16)&4294967295)<<15|u>>>17))*s+(((u>>>16)*s&65535)<<16)&4294967295}return a^=e.length,a=2246822507*(65535&(a^=a>>>16))+((2246822507*(a>>>16)&65535)<<16)&4294967295,a=3266489909*(65535&(a^=a>>>13))+((3266489909*(a>>>16)&65535)<<16)&4294967295,(a^=a>>>16)>>>0};var A={};!function(e){e.exports=function(e,t){for(var n,r=e.length,a=t^r,o=0;r>=4;)n=1540483477*(65535&(n=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(n>>>16)&65535)<<16),a=1540483477*(65535&a)+((1540483477*(a>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:a^=(255&e.charCodeAt(o+2))<<16;case 2:a^=(255&e.charCodeAt(o+1))<<8;case 1:a=1540483477*(65535&(a^=255&e.charCodeAt(o)))+((1540483477*(a>>>16)&65535)<<16)}return a=1540483477*(65535&(a^=a>>>13))+((1540483477*(a>>>16)&65535)<<16),(a^=a>>>15)>>>0}}({get exports(){return A},set exports(e){A=e}});var S=O,x=A;L.exports=S;var R=I.murmur3=S;I.murmur2=x;class C{constructor(e,t){var n,r;this.signalBuffer=[],this.itemLimit=null!==(n=null==t?void 0:t.itemLimit)&&void 0!==n?n:50,this.sendTimeout=null!==(r=null==t?void 0:t.sendTimeout)&&void 0!==r?r:250,this.paused=(null==t?void 0:t.paused)||!1,this.sendFn=e,this.flushInterval=-1,this.paused||this.start(),document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&this.flush()}))}addItem(e){this.paused||(this.signalBuffer.push(e),this.signalBuffer.length>=this.itemLimit&&this.flush())}start(){this.paused=!1,this.sendTimeout>0&&(this.flushInterval=window.setInterval((()=>this.flush()),this.sendTimeout))}pause(){this.paused=!0,clearInterval(this.flushInterval)}groupItems(e){const t=new Map;return e.forEach((e=>{const n=R(JSON.stringify(e.meta));let r=t.get(n);r=void 0===r?[e]:[...r,e],t.set(n,r)})),Array.from(t.values())}flush(){if(this.paused||0===this.signalBuffer.length)return;this.groupItems(this.signalBuffer).forEach(this.sendFn),this.signalBuffer=[]}}var j;e.TransportItemType=void 0,(j=e.TransportItemType||(e.TransportItemType={})).EXCEPTION="exception",j.LOG="log",j.MEASUREMENT="measurement",j.TRACE="trace",j.EVENT="event";const N={[e.TransportItemType.EXCEPTION]:"exceptions",[e.TransportItemType.LOG]:"logs",[e.TransportItemType.MEASUREMENT]:"measurements",[e.TransportItemType.TRACE]:"traces",[e.TransportItemType.EVENT]:"events"};function k(t){return n=>{if(n.type===e.TransportItemType.EXCEPTION&&n.payload){const e=n.payload,r=`${e.type}: ${e.value}`;if(function(e,t){return e.some((e=>i(e)?t.includes(e):!!t.match(e)))}(t,r))return null}return n}}var w;e.InternalLoggerLevel=void 0,(w=e.InternalLoggerLevel||(e.InternalLoggerLevel={}))[w.OFF=0]="OFF",w[w.ERROR=1]="ERROR",w[w.WARN=2]="WARN",w[w.INFO=3]="INFO",w[w.VERBOSE=4]="VERBOSE";const P={debug:E,error:E,info:E,prefix:"Faro",warn:E},B=e.InternalLoggerLevel.ERROR,F=Object.assign({},console);let $=F;function D(e){var t;return $=null!==(t=e.unpatchedConsole)&&void 0!==t?t:$,$}function G(t=F,n=B){const r=P;return n>e.InternalLoggerLevel.OFF&&(r.error=n>=e.InternalLoggerLevel.ERROR?function(...e){t.error(`${r.prefix}\n`,...e)}:E,r.warn=n>=e.InternalLoggerLevel.WARN?function(...e){t.warn(`${r.prefix}\n`,...e)}:E,r.info=n>=e.InternalLoggerLevel.INFO?function(...e){t.info(`${r.prefix}\n`,...e)}:E,r.debug=n>=e.InternalLoggerLevel.VERBOSE?function(...e){t.debug(`${r.prefix}\n`,...e)}:E),r}let M=P;function z(e,t){return M=G(e,t.internalLoggerLevel),M}class U{constructor(){this.unpatchedConsole=F,this.internalLogger=P,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 V(e,t){var n,r;if(void 0===t)return e;if(void 0===e)return{resourceSpans:t};const a=null===(n=e.resourceSpans)||void 0===n?void 0:n[0];if(void 0===a)return e;const o=(null==a?void 0:a.scopeSpans)||[],i=(null===(r=null==t?void 0:t[0])||void 0===r?void 0:r.scopeSpans)||[];return Object.assign(Object.assign({},e),{resourceSpans:[Object.assign(Object.assign({},a),{scopeSpans:[...o,...i]})]})}const K="Error";let W;function H(t,n,r,a,i){n.debug("Initializing API");const s=function(t,n,r,a,o){let i;return n.debug("Initializing traces API"),{getOTEL:()=>i,getTraceContext:()=>{const e=null==i?void 0:i.trace.getSpanContext(i.context.active());return e?{trace_id:e.traceId,span_id:e.spanId}:void 0},initOTEL:(e,t)=>{n.debug("Initializing OpenTelemetry"),i={trace:e,context:t}},isOTELInitialized:()=>!!i,pushTraces:t=>{try{const r={type:e.TransportItemType.TRACE,payload:t,meta:a.value};n.debug("Pushing trace\n",r),o.execute(r)}catch(e){n.error("Error pushing trace\n",e)}}}}(0,n,0,a,i);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},s),function(t,n,r,a,i,s){var u;n.debug("Initializing exceptions API");let l=null;W=null!==(u=r.parseStacktrace)&&void 0!==u?u:W;const c=e=>{n.debug("Changing stacktrace parser"),W=null!=e?e:W};return c(r.parseStacktrace),{changeStacktraceParser:c,getStacktraceParser:()=>W,pushError:(t,{skipDedupe:u,stackFrames:c,type:g,context:d}={})=>{g=g||t.name||K;const p={meta:a.value,payload:{type:g,value:t.message,timestamp:h(),trace:s.getTraceContext(),context:null!=d?d:{}},type:e.TransportItemType.EXCEPTION};(null==(c=null!=c?c:t.stack?null==W?void 0:W(t).frames:void 0)?void 0:c.length)&&(p.payload.stacktrace={frames:c});const f={type:p.payload.type,value:p.payload.value,stackTrace:p.payload.stacktrace,context:p.payload.context};u||!r.dedupe||o(l)||!m(f,l)?(l=f,n.debug("Pushing exception\n",p),i.execute(p)):n.debug("Skipping error push because it is the same as the last one\n",p.payload)}}}(0,n,r,a,i,s)),function(e,t,n,r,a){let o,i,s;t.debug("Initializing meta API");const u=e=>{i&&r.remove(i),i={user:e},r.add(i)},l=e=>{o&&r.remove(o),o={session:e},r.add(o)};return{setUser:u,resetUser:u,setSession:l,resetSession:l,getSession:()=>r.value.session,setView:e=>{s&&r.remove(s),s={view:e},r.add(s)},getView:()=>r.value.view}}(0,n,0,a)),function(t,n,r,a,i,s){n.debug("Initializing logs API");let u=null;return{pushLog:(t,{context:l,level:c,skipDedupe:g}={})=>{try{const d={type:e.TransportItemType.LOG,payload:{message:t.map((e=>{try{return String(e)}catch(e){return""}})).join(" "),level:null!=c?c:b,context:null!=l?l:{},timestamp:h(),trace:s.getTraceContext()},meta:a.value},p={message:d.payload.message,level:d.payload.level,context:d.payload.context};if(!g&&r.dedupe&&!o(u)&&m(p,u))return void n.debug("Skipping log push because it is the same as the last one\n",d.payload);u=p,n.debug("Pushing log\n",d),i.execute(d)}catch(e){n.error("Error pushing log\n",e)}}}}(0,n,r,a,i,s)),function(t,n,r,a,i,s){n.debug("Initializing measurements API");let u=null;return{pushMeasurement:(t,{skipDedupe:l}={})=>{var c;try{const g={type:e.TransportItemType.MEASUREMENT,payload:Object.assign(Object.assign({},t),{trace:s.getTraceContext(),timestamp:null!==(c=t.timestamp)&&void 0!==c?c:h()}),meta:a.value},d={type:g.payload.type,values:g.payload.values};if(!l&&r.dedupe&&!o(u)&&m(d,u))return void n.debug("Skipping measurement push because it is the same as the last one\n",g.payload);u=d,n.debug("Pushing measurement\n",g),i.execute(g)}catch(e){n.error("Error pushing measurement\n",e)}}}}(0,n,r,a,i,s)),function(t,n,r,a,i,s){let u=null;return{pushEvent:(t,l,c,{skipDedupe:g}={})=>{try{const d={meta:a.value,payload:{name:t,domain:null!=c?c:r.eventDomain,attributes:l,timestamp:h(),trace:s.getTraceContext()},type:e.TransportItemType.EVENT},p={name:d.payload.name,attributes:d.payload.attributes,domain:d.payload.domain};if(!g&&r.dedupe&&!o(u)&&m(p,u))return void n.debug("Skipping event push because it is the same as the last one\n",d.payload);u=p,n.debug("Pushing event\n",d),i.execute(d)}catch(e){n.error("Error pushing event",e)}}}}(0,n,r,a,i,s))}const _="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:void 0;const X="1.1.4";const q="_faroInternal";function J(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(_,q,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function Q(){return q in _}function Y(t,n,r,a,o,i,s){return n.debug("Initializing Faro"),e.faro={api:i,config:r,instrumentations:s,internalLogger:n,metas:a,pause:o.pause,transports:o,unpatchedConsole:t,unpause:o.unpause},J(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 _)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(_,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}(e.faro),e.faro}e.faro={};return e.BaseExtension=U,e.BaseInstrumentation=class extends U{constructor(){super(...arguments),this.api={},this.transports={}}},e.BaseTransport=class extends U{isBatched(){return!1}getIgnoreUrls(){return[]}},e.Conventions={EventNames:{CLICK:"click",NAVIGATION:"navigation",SESSION_START:"session_start",VIEW_CHANGED:"view_changed"}},e.VERSION=X,e.allLogLevels=y,e.createInternalLogger=G,e.createPromiseBuffer=function(e){const{size:t,concurrency:n}=e,r=[];let a=0;const o=()=>{if(a<n&&r.length){const{producer:e,resolve:t,reject:n}=r.shift();a++,e().then((e=>{a--,o(),t(e)}),(e=>{a--,o(),n(e)}))}};return{add:e=>{if(r.length+a>=t)throw new Error("Task buffer full");return new Promise(((t,n)=>{r.push({producer:e,resolve:t,reject:n}),o()}))}}},e.deepEqual=m,e.defaultBatchingConfig={enabled:!0,sendTimeout:250,itemLimit:50},e.defaultExceptionType=K,e.defaultGlobalObjectKey="faro",e.defaultInternalLoggerLevel=B,e.defaultLogLevel=b,e.defaultUnpatchedConsole=F,e.genShortID=function(e=10){return Array.from(Array(e)).map((()=>T[Math.floor(Math.random()*T.length)])).join("")},e.getCurrentTimestamp=h,e.getInternalFaroFromGlobalObject=function(){return _[q]},e.getTransportBody=function(t){let n={meta:{}};return void 0!==t[0]&&(n.meta=t[0].meta),t.forEach((t=>{switch(t.type){case e.TransportItemType.LOG:case e.TransportItemType.EVENT:case e.TransportItemType.EXCEPTION:case e.TransportItemType.MEASUREMENT:const r=N[t.type],a=n[r];n=Object.assign(Object.assign({},n),{[r]:void 0===a?[t.payload]:[...a,t.payload]});break;case e.TransportItemType.TRACE:n=Object.assign(Object.assign({},n),{traces:V(n.traces,t.payload.resourceSpans)})}})),n},e.globalObject=_,e.initializeFaro=function(e){const t=D(e),n=z(t,e);if(Q()&&!e.isolate)return void n.error('Faro is already registered. Either add instrumentations, transports etc. to the global faro instance or use the "isolate" property');n.debug("Initializing");const r=function(e,t,n){let r=[],a=[];const o=()=>r.reduce(((e,t)=>Object.assign(e,l(t)?t():t)),{}),i=()=>{if(a.length){const e=o();a.forEach((t=>t(e)))}};return{add:(...e)=>{t.debug("Adding metas\n",e),r.push(...e),i()},remove:(...e)=>{t.debug("Removing metas\n",e),r=r.filter((t=>!e.includes(t))),i()},addListener:e=>{t.debug("Adding metas listener\n",e),a.push(e)},removeListener:e=>{t.debug("Removing metas listener\n",e),a=a.filter((t=>t!==e))},get value(){return o()}}}(0,n),a=function(e,t,n,r){var a;t.debug("Initializing transports");const o=[];let i=n.paused,s=[];const u=e=>{let t=e;for(const e of s){const n=t.map(e).filter(Boolean);if(0===n.length)return[];t=n}return t},l=e=>{const n=u(e);if(0!==n.length)for(const e of o)t.debug(`Transporting item using ${e.name}\n`,n),e.isBatched()&&e.send(n)},c=e=>{var r;const[a]=u([e]);if(void 0!==a)for(const e of o)t.debug(`Transporting item using ${e.name}\n`,a),e.isBatched()?(null===(r=n.batching)||void 0===r?void 0:r.enabled)||e.send([a]):e.send(a)};let g;return(null===(a=n.batching)||void 0===a?void 0:a.enabled)&&(g=new C(l,{sendTimeout:n.batching.sendTimeout,itemLimit:n.batching.itemLimit,paused:i})),{add:(...a)=>{t.debug("Adding transports"),a.forEach((a=>{t.debug(`Adding "${a.name}" transport`),o.some((e=>e===a))?t.warn(`Transport ${a.name} is already added`):(a.unpatchedConsole=e,a.internalLogger=t,a.config=n,a.metas=r,o.push(a))}))},addBeforeSendHooks:(...e)=>{t.debug("Adding beforeSendHooks\n",s),e.forEach((e=>{e&&s.push(e)}))},addIgnoreErrorsPatterns:(...e)=>{t.debug("Adding ignoreErrorsPatterns\n",e),e.forEach((e=>{e&&s.push(k(e))}))},getBeforeSendHooks:()=>[...s],execute:e=>{var t;i||((null===(t=n.batching)||void 0===t?void 0:t.enabled)?(null==g||g.addItem(e),c(e)):c(e))},isPaused:()=>i,pause:()=>{t.debug("Pausing transports"),null==g||g.pause(),i=!0},remove:(...e)=>{t.debug("Removing transports"),e.forEach((e=>{t.debug(`Removing "${e.name}" transport`);const n=o.indexOf(e);-1!==n?o.splice(n,1):t.warn(`Transport "${e.name}" is not added`)}))},removeBeforeSendHooks:(...e)=>{s.filter((t=>!e.includes(t)))},get transports(){return[...o]},unpause:()=>{t.debug("Unpausing transports"),null==g||g.start(),i=!1}}}(t,n,e,r),o=H(0,n,e,r,a),i=function(e,t,n,r,a,o){t.debug("Initializing instrumentations");const i=[];return{add:(...s)=>{t.debug("Adding instrumentations"),s.forEach((s=>{t.debug(`Adding "${s.name}" instrumentation`),i.some((e=>e.name===s.name))?t.warn(`Instrumentation ${s.name} is already added`):(s.unpatchedConsole=e,s.internalLogger=t,s.config=n,s.metas=r,s.transports=a,s.api=o,i.push(s),s.initialize())}))},get instrumentations(){return[...i]},remove:(...e)=>{t.debug("Removing instrumentations"),e.forEach((e=>{var n,r;t.debug(`Removing "${e.name}" instrumentation`);const a=i.reduce(((t,n,r)=>null===t&&n.name===e.name?r:null),null);a?(null===(r=(n=i[a]).destroy)||void 0===r||r.call(n),i.splice(a,1)):t.warn(`Instrumentation "${e.name}" is not added`)}))}}}(t,n,e,r,a,o),s=Y(t,n,e,r,a,o,i);return function(e){var t;const n={sdk:{name:"@grafana/faro-core",version:X,integrations:e.config.instrumentations.map((({name:e,version:t})=>({name:e,version:t})))}};e.config.session&&e.api.setSession(e.config.session),e.config.app&&(n.app=e.config.app),e.config.user&&(n.user=e.config.user),e.config.view&&(n.view=e.config.view),e.metas.add(n,...null!==(t=e.config.metas)&&void 0!==t?t:[])}(s),function(e){e.transports.add(...e.config.transports),e.transports.addBeforeSendHooks(e.config.beforeSend),e.transports.addIgnoreErrorsPatterns(e.config.ignoreErrors)}(s),function(e){e.instrumentations.add(...e.config.instrumentations)}(s),s},e.internalGlobalObjectKey=q,e.isArray=c,e.isBoolean=e=>t(e,"boolean"),e.isDomError=e=>n(e,"DOMError"),e.isDomException=e=>n(e,"DOMException"),e.isElement=e=>p&&r(e,Element),e.isElementDefined=p,e.isError=e=>d&&r(e,Error),e.isErrorDefined=d,e.isErrorEvent=e=>n(e,"ErrorEvent"),e.isEvent=e=>g&&r(e,Event),e.isEventDefined=g,e.isFunction=l,e.isInstanceOf=r,e.isInt=e=>s(e)&&Number.isInteger(e),e.isInternalFaroOnGlobalObject=Q,e.isMap=e=>f&&r(e,Map),e.isMapDefined=f,e.isNull=o,e.isNumber=s,e.isObject=u,e.isPrimitive=e=>!u(e)&&!l(e),e.isRegExp=e=>n(e,"RegExp"),e.isString=i,e.isSymbol=e=>t(e,"symbol"),e.isSyntheticEvent=e=>u(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e,e.isThenable=e=>l(null==e?void 0:e.then),e.isToString=n,e.isTypeof=t,e.isUndefined=a,e.noop=E,e.setInternalFaroOnGlobalObject=J,e.transportItemTypeToBodyKey=N,e}({});
1
+ var GrafanaFaroCore=function(e){"use strict";function t(e,t){return typeof e===t}function n(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function r(e,t){try{return e instanceof t}catch(e){return!1}}const a=e=>t(e,"undefined"),o=e=>t(e,"null"),i=e=>t(e,"string"),s=e=>t(e,"number")&&!isNaN(e)||t(e,"bigint"),u=e=>!o(e)&&t(e,"object"),l=e=>t(e,"function"),c=e=>n(e,"Array"),g=!a(Event),d="undefined"!=typeof Error,p="undefined"!=typeof Element,f="undefined"!=typeof Map;function m(e,n){if(e===n)return!0;if(t(e,"number")&&isNaN(e))return t(n,"number")&&isNaN(n);const r=c(e),a=c(n);if(r!==a)return!1;if(r&&a){const t=e.length;if(t!==n.length)return!1;for(let r=t;0!=r--;)if(!m(e[r],n[r]))return!1;return!0}const o=u(e),i=u(n);if(o!==i)return!1;if(e&&n&&o&&i){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(!m(e[r],n[r]))return!1;return!0}return!1}function h(){return(new Date).toISOString()}var v;e.LogLevel=void 0,(v=e.LogLevel||(e.LogLevel={})).TRACE="trace",v.DEBUG="debug",v.INFO="info",v.LOG="log",v.WARN="warn",v.ERROR="error";const b=e.LogLevel.LOG,y=[e.LogLevel.TRACE,e.LogLevel.DEBUG,e.LogLevel.INFO,e.LogLevel.LOG,e.LogLevel.WARN,e.LogLevel.ERROR];function E(){}const T="abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789";var I={},L={get exports(){return I},set exports(e){I=e}},O={};({get exports(){return O},set exports(e){O=e}}).exports=function(e,t){var n,r,a,o,i,s,u,l;for(n=3&e.length,r=e.length-n,a=t,i=3432918353,s=461845907,l=0;l<r;)u=255&e.charCodeAt(l)|(255&e.charCodeAt(++l))<<8|(255&e.charCodeAt(++l))<<16|(255&e.charCodeAt(++l))<<24,++l,a=27492+(65535&(o=5*(65535&(a=(a^=u=(65535&(u=(u=(65535&u)*i+(((u>>>16)*i&65535)<<16)&4294967295)<<15|u>>>17))*s+(((u>>>16)*s&65535)<<16)&4294967295)<<13|a>>>19))+((5*(a>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(u=0,n){case 3:u^=(255&e.charCodeAt(l+2))<<16;case 2:u^=(255&e.charCodeAt(l+1))<<8;case 1:a^=u=(65535&(u=(u=(65535&(u^=255&e.charCodeAt(l)))*i+(((u>>>16)*i&65535)<<16)&4294967295)<<15|u>>>17))*s+(((u>>>16)*s&65535)<<16)&4294967295}return a^=e.length,a=2246822507*(65535&(a^=a>>>16))+((2246822507*(a>>>16)&65535)<<16)&4294967295,a=3266489909*(65535&(a^=a>>>13))+((3266489909*(a>>>16)&65535)<<16)&4294967295,(a^=a>>>16)>>>0};var x={};!function(e){e.exports=function(e,t){for(var n,r=e.length,a=t^r,o=0;r>=4;)n=1540483477*(65535&(n=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(n>>>16)&65535)<<16),a=1540483477*(65535&a)+((1540483477*(a>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:a^=(255&e.charCodeAt(o+2))<<16;case 2:a^=(255&e.charCodeAt(o+1))<<8;case 1:a=1540483477*(65535&(a^=255&e.charCodeAt(o)))+((1540483477*(a>>>16)&65535)<<16)}return a=1540483477*(65535&(a^=a>>>13))+((1540483477*(a>>>16)&65535)<<16),(a^=a>>>15)>>>0}}({get exports(){return x},set exports(e){x=e}});var A=O,S=x;L.exports=A;var R=I.murmur3=A;I.murmur2=S;class C{constructor(e,t){var n,r;this.signalBuffer=[],this.itemLimit=null!==(n=null==t?void 0:t.itemLimit)&&void 0!==n?n:50,this.sendTimeout=null!==(r=null==t?void 0:t.sendTimeout)&&void 0!==r?r:250,this.paused=(null==t?void 0:t.paused)||!1,this.sendFn=e,this.flushInterval=-1,this.paused||this.start(),document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&this.flush()}))}addItem(e){this.paused||(this.signalBuffer.push(e),this.signalBuffer.length>=this.itemLimit&&this.flush())}start(){this.paused=!1,this.sendTimeout>0&&(this.flushInterval=window.setInterval((()=>this.flush()),this.sendTimeout))}pause(){this.paused=!0,clearInterval(this.flushInterval)}groupItems(e){const t=new Map;return e.forEach((e=>{const n=R(JSON.stringify(e.meta));let r=t.get(n);r=void 0===r?[e]:[...r,e],t.set(n,r)})),Array.from(t.values())}flush(){if(this.paused||0===this.signalBuffer.length)return;this.groupItems(this.signalBuffer).forEach(this.sendFn),this.signalBuffer=[]}}var j;e.TransportItemType=void 0,(j=e.TransportItemType||(e.TransportItemType={})).EXCEPTION="exception",j.LOG="log",j.MEASUREMENT="measurement",j.TRACE="trace",j.EVENT="event";const N={[e.TransportItemType.EXCEPTION]:"exceptions",[e.TransportItemType.LOG]:"logs",[e.TransportItemType.MEASUREMENT]:"measurements",[e.TransportItemType.TRACE]:"traces",[e.TransportItemType.EVENT]:"events"};function k(t){return n=>{if(n.type===e.TransportItemType.EXCEPTION&&n.payload){const e=n.payload,r=`${e.type}: ${e.value}`;if(function(e,t){return e.some((e=>i(e)?t.includes(e):!!t.match(e)))}(t,r))return null}return n}}var w;e.InternalLoggerLevel=void 0,(w=e.InternalLoggerLevel||(e.InternalLoggerLevel={}))[w.OFF=0]="OFF",w[w.ERROR=1]="ERROR",w[w.WARN=2]="WARN",w[w.INFO=3]="INFO",w[w.VERBOSE=4]="VERBOSE";const P={debug:E,error:E,info:E,prefix:"Faro",warn:E},B=e.InternalLoggerLevel.ERROR,F=Object.assign({},console);let $=F;function D(e){var t;return $=null!==(t=e.unpatchedConsole)&&void 0!==t?t:$,$}function G(t=F,n=B){const r=P;return n>e.InternalLoggerLevel.OFF&&(r.error=n>=e.InternalLoggerLevel.ERROR?function(...e){t.error(`${r.prefix}\n`,...e)}:E,r.warn=n>=e.InternalLoggerLevel.WARN?function(...e){t.warn(`${r.prefix}\n`,...e)}:E,r.info=n>=e.InternalLoggerLevel.INFO?function(...e){t.info(`${r.prefix}\n`,...e)}:E,r.debug=n>=e.InternalLoggerLevel.VERBOSE?function(...e){t.debug(`${r.prefix}\n`,...e)}:E),r}let M=P;function z(e,t){return M=G(e,t.internalLoggerLevel),M}class U{constructor(){this.unpatchedConsole=F,this.internalLogger=P,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 V(e,t){var n,r;if(void 0===t)return e;if(void 0===e)return{resourceSpans:t};const a=null===(n=e.resourceSpans)||void 0===n?void 0:n[0];if(void 0===a)return e;const o=(null==a?void 0:a.scopeSpans)||[],i=(null===(r=null==t?void 0:t[0])||void 0===r?void 0:r.scopeSpans)||[];return Object.assign(Object.assign({},e),{resourceSpans:[Object.assign(Object.assign({},a),{scopeSpans:[...o,...i]})]})}const K="Error";let W;function H(t,n,r,a,i){n.debug("Initializing API");const s=function(t,n,r,a,o){let i;return n.debug("Initializing traces API"),{getOTEL:()=>i,getTraceContext:()=>{const e=null==i?void 0:i.trace.getSpanContext(i.context.active());return e?{trace_id:e.traceId,span_id:e.spanId}:void 0},initOTEL:(e,t)=>{n.debug("Initializing OpenTelemetry"),i={trace:e,context:t}},isOTELInitialized:()=>!!i,pushTraces:t=>{try{const r={type:e.TransportItemType.TRACE,payload:t,meta:a.value};n.debug("Pushing trace\n",r),o.execute(r)}catch(e){n.error("Error pushing trace\n",e)}}}}(0,n,0,a,i);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},s),function(t,n,r,a,i,s){var u;n.debug("Initializing exceptions API");let l=null;W=null!==(u=r.parseStacktrace)&&void 0!==u?u:W;const c=e=>{n.debug("Changing stacktrace parser"),W=null!=e?e:W};return c(r.parseStacktrace),{changeStacktraceParser:c,getStacktraceParser:()=>W,pushError:(t,{skipDedupe:u,stackFrames:c,type:g,context:d}={})=>{g=g||t.name||K;const p={meta:a.value,payload:{type:g,value:t.message,timestamp:h(),trace:s.getTraceContext(),context:null!=d?d:{}},type:e.TransportItemType.EXCEPTION};(null==(c=null!=c?c:t.stack?null==W?void 0:W(t).frames:void 0)?void 0:c.length)&&(p.payload.stacktrace={frames:c});const f={type:p.payload.type,value:p.payload.value,stackTrace:p.payload.stacktrace,context:p.payload.context};u||!r.dedupe||o(l)||!m(f,l)?(l=f,n.debug("Pushing exception\n",p),i.execute(p)):n.debug("Skipping error push because it is the same as the last one\n",p.payload)}}}(0,n,r,a,i,s)),function(e,t,n,r,a){let o,i,s;t.debug("Initializing meta API");const u=e=>{i&&r.remove(i),i={user:e},r.add(i)},l=e=>{o&&r.remove(o),o={session:e},r.add(o)};return{setUser:u,resetUser:u,setSession:l,resetSession:l,getSession:()=>r.value.session,setView:e=>{s&&r.remove(s),s={view:e},r.add(s)},getView:()=>r.value.view}}(0,n,0,a)),function(t,n,r,a,i,s){n.debug("Initializing logs API");let u=null;return{pushLog:(t,{context:l,level:c,skipDedupe:g}={})=>{try{const d={type:e.TransportItemType.LOG,payload:{message:t.map((e=>{try{return String(e)}catch(e){return""}})).join(" "),level:null!=c?c:b,context:null!=l?l:{},timestamp:h(),trace:s.getTraceContext()},meta:a.value},p={message:d.payload.message,level:d.payload.level,context:d.payload.context};if(!g&&r.dedupe&&!o(u)&&m(p,u))return void n.debug("Skipping log push because it is the same as the last one\n",d.payload);u=p,n.debug("Pushing log\n",d),i.execute(d)}catch(e){n.error("Error pushing log\n",e)}}}}(0,n,r,a,i,s)),function(t,n,r,a,i,s){n.debug("Initializing measurements API");let u=null;return{pushMeasurement:(t,{skipDedupe:l,context:c}={})=>{var g;try{const d={type:e.TransportItemType.MEASUREMENT,payload:Object.assign(Object.assign({},t),{trace:s.getTraceContext(),timestamp:null!==(g=t.timestamp)&&void 0!==g?g:h(),context:null!=c?c:{}}),meta:a.value},p={type:d.payload.type,values:d.payload.values,context:d.payload.context};if(!l&&r.dedupe&&!o(u)&&m(p,u))return void n.debug("Skipping measurement push because it is the same as the last one\n",d.payload);u=p,n.debug("Pushing measurement\n",d),i.execute(d)}catch(e){n.error("Error pushing measurement\n",e)}}}}(0,n,r,a,i,s)),function(t,n,r,a,i,s){let u=null;return{pushEvent:(t,l,c,{skipDedupe:g}={})=>{try{const d={meta:a.value,payload:{name:t,domain:null!=c?c:r.eventDomain,attributes:l,timestamp:h(),trace:s.getTraceContext()},type:e.TransportItemType.EVENT},p={name:d.payload.name,attributes:d.payload.attributes,domain:d.payload.domain};if(!g&&r.dedupe&&!o(u)&&m(p,u))return void n.debug("Skipping event push because it is the same as the last one\n",d.payload);u=p,n.debug("Pushing event\n",d),i.execute(d)}catch(e){n.error("Error pushing event",e)}}}}(0,n,r,a,i,s))}const _="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:void 0;const X="1.2.1";const q="_faroInternal";function J(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(_,q,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function Q(){return q in _}function Y(t,n,r,a,o,i,s){return n.debug("Initializing Faro"),e.faro={api:i,config:r,instrumentations:s,internalLogger:n,metas:a,pause:o.pause,transports:o,unpatchedConsole:t,unpause:o.unpause},J(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 _)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(_,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}(e.faro),e.faro}e.faro={};return e.BaseExtension=U,e.BaseInstrumentation=class extends U{constructor(){super(...arguments),this.api={},this.transports={}}},e.BaseTransport=class extends U{isBatched(){return!1}getIgnoreUrls(){return[]}},e.Conventions={EventNames:{CLICK:"click",NAVIGATION:"navigation",SESSION_START:"session_start",VIEW_CHANGED:"view_changed"}},e.VERSION=X,e.allLogLevels=y,e.createInternalLogger=G,e.createPromiseBuffer=function(e){const{size:t,concurrency:n}=e,r=[];let a=0;const o=()=>{if(a<n&&r.length){const{producer:e,resolve:t,reject:n}=r.shift();a++,e().then((e=>{a--,o(),t(e)}),(e=>{a--,o(),n(e)}))}};return{add:e=>{if(r.length+a>=t)throw new Error("Task buffer full");return new Promise(((t,n)=>{r.push({producer:e,resolve:t,reject:n}),o()}))}}},e.deepEqual=m,e.defaultBatchingConfig={enabled:!0,sendTimeout:250,itemLimit:50},e.defaultExceptionType=K,e.defaultGlobalObjectKey="faro",e.defaultInternalLoggerLevel=B,e.defaultLogLevel=b,e.defaultUnpatchedConsole=F,e.genShortID=function(e=10){return Array.from(Array(e)).map((()=>T[Math.floor(Math.random()*T.length)])).join("")},e.getCurrentTimestamp=h,e.getInternalFaroFromGlobalObject=function(){return _[q]},e.getTransportBody=function(t){let n={meta:{}};return void 0!==t[0]&&(n.meta=t[0].meta),t.forEach((t=>{switch(t.type){case e.TransportItemType.LOG:case e.TransportItemType.EVENT:case e.TransportItemType.EXCEPTION:case e.TransportItemType.MEASUREMENT:const r=N[t.type],a=n[r];n=Object.assign(Object.assign({},n),{[r]:void 0===a?[t.payload]:[...a,t.payload]});break;case e.TransportItemType.TRACE:n=Object.assign(Object.assign({},n),{traces:V(n.traces,t.payload.resourceSpans)})}})),n},e.globalObject=_,e.initializeFaro=function(e){const t=D(e),n=z(t,e);if(Q()&&!e.isolate)return void n.error('Faro is already registered. Either add instrumentations, transports etc. to the global faro instance or use the "isolate" property');n.debug("Initializing");const r=function(e,t,n){let r=[],a=[];const o=()=>r.reduce(((e,t)=>Object.assign(e,l(t)?t():t)),{}),i=()=>{if(a.length){const e=o();a.forEach((t=>t(e)))}};return{add:(...e)=>{t.debug("Adding metas\n",e),r.push(...e),i()},remove:(...e)=>{t.debug("Removing metas\n",e),r=r.filter((t=>!e.includes(t))),i()},addListener:e=>{t.debug("Adding metas listener\n",e),a.push(e)},removeListener:e=>{t.debug("Removing metas listener\n",e),a=a.filter((t=>t!==e))},get value(){return o()}}}(0,n),a=function(e,t,n,r){var a;t.debug("Initializing transports");const o=[];let i=n.paused,s=[];const u=e=>{let t=e;for(const e of s){const n=t.map(e).filter(Boolean);if(0===n.length)return[];t=n}return t},l=e=>{const n=u(e);if(0!==n.length)for(const e of o)t.debug(`Transporting item using ${e.name}\n`,n),e.isBatched()&&e.send(n)},c=e=>{var r;const[a]=u([e]);if(void 0!==a)for(const e of o)t.debug(`Transporting item using ${e.name}\n`,a),e.isBatched()?(null===(r=n.batching)||void 0===r?void 0:r.enabled)||e.send([a]):e.send(a)};let g;return(null===(a=n.batching)||void 0===a?void 0:a.enabled)&&(g=new C(l,{sendTimeout:n.batching.sendTimeout,itemLimit:n.batching.itemLimit,paused:i})),{add:(...a)=>{t.debug("Adding transports"),a.forEach((a=>{t.debug(`Adding "${a.name}" transport`),o.some((e=>e===a))?t.warn(`Transport ${a.name} is already added`):(a.unpatchedConsole=e,a.internalLogger=t,a.config=n,a.metas=r,o.push(a))}))},addBeforeSendHooks:(...e)=>{t.debug("Adding beforeSendHooks\n",s),e.forEach((e=>{e&&s.push(e)}))},addIgnoreErrorsPatterns:(...e)=>{t.debug("Adding ignoreErrorsPatterns\n",e),e.forEach((e=>{e&&s.push(k(e))}))},getBeforeSendHooks:()=>[...s],execute:e=>{var t;i||((null===(t=n.batching)||void 0===t?void 0:t.enabled)?(null==g||g.addItem(e),c(e)):c(e))},isPaused:()=>i,pause:()=>{t.debug("Pausing transports"),null==g||g.pause(),i=!0},remove:(...e)=>{t.debug("Removing transports"),e.forEach((e=>{t.debug(`Removing "${e.name}" transport`);const n=o.indexOf(e);-1!==n?o.splice(n,1):t.warn(`Transport "${e.name}" is not added`)}))},removeBeforeSendHooks:(...e)=>{s.filter((t=>!e.includes(t)))},get transports(){return[...o]},unpause:()=>{t.debug("Unpausing transports"),null==g||g.start(),i=!1}}}(t,n,e,r),o=H(0,n,e,r,a),i=function(e,t,n,r,a,o){t.debug("Initializing instrumentations");const i=[];return{add:(...s)=>{t.debug("Adding instrumentations"),s.forEach((s=>{t.debug(`Adding "${s.name}" instrumentation`),i.some((e=>e.name===s.name))?t.warn(`Instrumentation ${s.name} is already added`):(s.unpatchedConsole=e,s.internalLogger=t,s.config=n,s.metas=r,s.transports=a,s.api=o,i.push(s),s.initialize())}))},get instrumentations(){return[...i]},remove:(...e)=>{t.debug("Removing instrumentations"),e.forEach((e=>{var n,r;t.debug(`Removing "${e.name}" instrumentation`);const a=i.reduce(((t,n,r)=>null===t&&n.name===e.name?r:null),null);a?(null===(r=(n=i[a]).destroy)||void 0===r||r.call(n),i.splice(a,1)):t.warn(`Instrumentation "${e.name}" is not added`)}))}}}(t,n,e,r,a,o),s=Y(t,n,e,r,a,o,i);return function(e){var t;const n={sdk:{name:"@grafana/faro-core",version:X,integrations:e.config.instrumentations.map((({name:e,version:t})=>({name:e,version:t})))}};e.config.session&&e.api.setSession(e.config.session),e.config.app&&(n.app=e.config.app),e.config.user&&(n.user=e.config.user),e.config.view&&(n.view=e.config.view),e.metas.add(n,...null!==(t=e.config.metas)&&void 0!==t?t:[])}(s),function(e){e.transports.add(...e.config.transports),e.transports.addBeforeSendHooks(e.config.beforeSend),e.transports.addIgnoreErrorsPatterns(e.config.ignoreErrors)}(s),function(e){e.instrumentations.add(...e.config.instrumentations)}(s),s},e.internalGlobalObjectKey=q,e.isArray=c,e.isBoolean=e=>t(e,"boolean"),e.isDomError=e=>n(e,"DOMError"),e.isDomException=e=>n(e,"DOMException"),e.isElement=e=>p&&r(e,Element),e.isElementDefined=p,e.isError=e=>d&&r(e,Error),e.isErrorDefined=d,e.isErrorEvent=e=>n(e,"ErrorEvent"),e.isEvent=e=>g&&r(e,Event),e.isEventDefined=g,e.isFunction=l,e.isInstanceOf=r,e.isInt=e=>s(e)&&Number.isInteger(e),e.isInternalFaroOnGlobalObject=Q,e.isMap=e=>f&&r(e,Map),e.isMapDefined=f,e.isNull=o,e.isNumber=s,e.isObject=u,e.isPrimitive=e=>!u(e)&&!l(e),e.isRegExp=e=>n(e,"RegExp"),e.isString=i,e.isSymbol=e=>t(e,"symbol"),e.isSyntheticEvent=e=>u(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e,e.isThenable=e=>l(null==e?void 0:e.then),e.isToString=n,e.isTypeof=t,e.isUndefined=a,e.noop=E,e.setInternalFaroOnGlobalObject=J,e.transportItemTypeToBodyKey=N,e}({});
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/exceptions/initialize.ts"],"names":[],"mappings":";;;AAGA,+CAAqD;AAGrD,qCAAqE;AAGrE,iCAA+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B,uBAAhB,gBAAgB,CAAG,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAE1F,IAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM,EAAE;YACvB,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG;gBACxB,MAAM,EAAE,WAAW;aACpB,CAAC;SACH;QAED,IAAM,cAAc,GAAG;YACrB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;YACvB,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;YACzB,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU;YACnC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;SAC9B,CAAC;QAEF,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,IAAA,cAAM,EAAC,WAAW,CAAC,IAAI,IAAA,iBAAS,EAAC,cAAc,EAAE,WAAW,CAAC,EAAE;YAClG,cAAc,CAAC,KAAK,CAAC,8DAA8D,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YAEnG,OAAO;SACR;QAED,WAAW,GAAG,cAAc,CAAC;QAE7B,cAAc,CAAC,KAAK,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC;QAElD,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC,CAAC;IAEF,sBAAsB,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAE/C,OAAO;QACL,sBAAsB,wBAAA;QACtB,mBAAmB,qBAAA;QACnB,SAAS,WAAA;KACV,CAAC;AACJ,CAAC;AAxED,0DAwEC","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 { deepEqual, getCurrentTimestamp, isNull } from '../../utils';\nimport type { TracesAPI } from '../traces';\n\nimport { defaultExceptionType } from './const';\nimport type { 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'> | 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'] = (error, { skipDedupe, stackFrames, type, context } = {}) => {\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: getCurrentTimestamp(),\n trace: tracesApi.getTraceContext(),\n context: context ?? {},\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"]}
1
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AAC;QAEF,WAAW,GAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAG,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAE1F,IAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM,EAAE;YACvB,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG;gBACxB,MAAM,EAAE,WAAW;aACpB,CAAC;SACH;QAED,IAAM,cAAc,GAAG;YACrB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;YACvB,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;YACzB,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU;YACnC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;SAC9B,CAAC;QAEF,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,IAAA,cAAM,EAAC,WAAW,CAAC,IAAI,IAAA,iBAAS,EAAC,cAAc,EAAE,WAAW,CAAC,EAAE;YAClG,cAAc,CAAC,KAAK,CAAC,8DAA8D,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YAEnG,OAAO;SACR;QAED,WAAW,GAAG,cAAc,CAAC;QAE7B,cAAc,CAAC,KAAK,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC;QAElD,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC,CAAC;IAEF,sBAAsB,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAE/C,OAAO;QACL,sBAAsB,wBAAA;QACtB,mBAAmB,qBAAA;QACnB,SAAS,WAAA;KACV,CAAC;AACJ,CAAC;AAxED,0DAwEC","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 { deepEqual, getCurrentTimestamp, isNull } from '../../utils';\nimport type { TracesAPI } from '../traces';\n\nimport { defaultExceptionType } from './const';\nimport type { 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'] = (error, { skipDedupe, stackFrames, type, context } = {}) => {\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: getCurrentTimestamp(),\n trace: tracesApi.getTraceContext(),\n context: context ?? {},\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"]}
@@ -19,16 +19,17 @@ function initializeMeasurementsAPI(_unpatchedConsole, internalLogger, config, me
19
19
  var lastPayload = null;
20
20
  var pushMeasurement = function (payload, _a) {
21
21
  var _b;
22
- var _c = _a === void 0 ? {} : _a, skipDedupe = _c.skipDedupe;
22
+ var _c = _a === void 0 ? {} : _a, skipDedupe = _c.skipDedupe, context = _c.context;
23
23
  try {
24
24
  var item = {
25
25
  type: transports_1.TransportItemType.MEASUREMENT,
26
- payload: __assign(__assign({}, payload), { trace: tracesApi.getTraceContext(), timestamp: (_b = payload.timestamp) !== null && _b !== void 0 ? _b : (0, utils_1.getCurrentTimestamp)() }),
26
+ payload: __assign(__assign({}, payload), { trace: tracesApi.getTraceContext(), timestamp: (_b = payload.timestamp) !== null && _b !== void 0 ? _b : (0, utils_1.getCurrentTimestamp)(), context: context !== null && context !== void 0 ? context : {} }),
27
27
  meta: metas.value,
28
28
  };
29
29
  var testingPayload = {
30
30
  type: item.payload.type,
31
31
  values: item.payload.values,
32
+ context: item.payload.context,
32
33
  };
33
34
  if (!skipDedupe && config.dedupe && !(0, utils_1.isNull)(lastPayload) && (0, utils_1.deepEqual)(testingPayload, lastPayload)) {
34
35
  internalLogger.debug('Skipping measurement push because it is the same as the last one\n', item.payload);
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/measurements/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAGA,+CAAoE;AAGpE,qCAAqE;AAKrE,SAAgB,yBAAyB,CACvC,iBAAmC,EACnC,cAA8B,EAC9B,MAAc,EACd,KAAY,EACZ,UAAsB,EACtB,SAAoB;IAEpB,cAAc,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAEtD,IAAI,WAAW,GAAqD,IAAI,CAAC;IAEzE,IAAM,eAAe,GAAuC,UAAC,OAAO,EAAE,EAAmB;;YAAnB,qBAAiB,EAAE,KAAA,EAAjB,UAAU,gBAAA;QAChF,IAAI;YACF,IAAM,IAAI,GAAoC;gBAC5C,IAAI,EAAE,8BAAiB,CAAC,WAAW;gBACnC,OAAO,wBACF,OAAO,KACV,KAAK,EAAE,SAAS,CAAC,eAAe,EAAE,EAClC,SAAS,EAAE,MAAA,OAAO,CAAC,SAAS,mCAAI,IAAA,2BAAmB,GAAE,GACtD;gBACD,IAAI,EAAE,KAAK,CAAC,KAAK;aAClB,CAAC;YAEF,IAAM,cAAc,GAAG;gBACrB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;gBACvB,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM;aAC5B,CAAC;YAEF,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,IAAA,cAAM,EAAC,WAAW,CAAC,IAAI,IAAA,iBAAS,EAAC,cAAc,EAAE,WAAW,CAAC,EAAE;gBAClG,cAAc,CAAC,KAAK,CAAC,oEAAoE,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBAEzG,OAAO;aACR;YAED,WAAW,GAAG,cAAc,CAAC;YAE7B,cAAc,CAAC,KAAK,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAC;YAEpD,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAC1B;QAAC,OAAO,GAAG,EAAE;YACZ,cAAc,CAAC,KAAK,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;SAC1D;IACH,CAAC,CAAC;IAEF,OAAO;QACL,eAAe,iBAAA;KAChB,CAAC;AACJ,CAAC;AAhDD,8DAgDC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItem, TransportItemType } from '../../transports';\nimport type { Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { deepEqual, getCurrentTimestamp, isNull } from '../../utils';\nimport type { TracesAPI } from '../traces';\n\nimport type { MeasurementEvent, MeasurementsAPI } from './types';\n\nexport function initializeMeasurementsAPI(\n _unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas,\n transports: Transports,\n tracesApi: TracesAPI\n): MeasurementsAPI {\n internalLogger.debug('Initializing measurements API');\n\n let lastPayload: Pick<MeasurementEvent, 'type' | 'values'> | null = null;\n\n const pushMeasurement: MeasurementsAPI['pushMeasurement'] = (payload, { skipDedupe } = {}) => {\n try {\n const item: TransportItem<MeasurementEvent> = {\n type: TransportItemType.MEASUREMENT,\n payload: {\n ...payload,\n trace: tracesApi.getTraceContext(),\n timestamp: payload.timestamp ?? getCurrentTimestamp(),\n },\n meta: metas.value,\n };\n\n const testingPayload = {\n type: item.payload.type,\n values: item.payload.values,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping measurement 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 measurement\\n', item);\n\n transports.execute(item);\n } catch (err) {\n internalLogger.error('Error pushing measurement\\n', err);\n }\n };\n\n return {\n pushMeasurement,\n };\n}\n"]}
1
+ {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/measurements/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAGA,+CAAoE;AAGpE,qCAAqE;AAKrE,SAAgB,yBAAyB,CACvC,iBAAmC,EACnC,cAA8B,EAC9B,MAAc,EACd,KAAY,EACZ,UAAsB,EACtB,SAAoB;IAEpB,cAAc,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAEtD,IAAI,WAAW,GAAiE,IAAI,CAAC;IAErF,IAAM,eAAe,GAAuC,UAAC,OAAO,EAAE,EAA4B;;YAA5B,qBAA0B,EAAE,KAAA,EAA1B,UAAU,gBAAA,EAAE,OAAO,aAAA;QACzF,IAAI;YACF,IAAM,IAAI,GAAoC;gBAC5C,IAAI,EAAE,8BAAiB,CAAC,WAAW;gBACnC,OAAO,wBACF,OAAO,KACV,KAAK,EAAE,SAAS,CAAC,eAAe,EAAE,EAClC,SAAS,EAAE,MAAA,OAAO,CAAC,SAAS,mCAAI,IAAA,2BAAmB,GAAE,EACrD,OAAO,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,GACvB;gBACD,IAAI,EAAE,KAAK,CAAC,KAAK;aAClB,CAAC;YAEF,IAAM,cAAc,GAAG;gBACrB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;gBACvB,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM;gBAC3B,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;aAC9B,CAAC;YAEF,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,IAAA,cAAM,EAAC,WAAW,CAAC,IAAI,IAAA,iBAAS,EAAC,cAAc,EAAE,WAAW,CAAC,EAAE;gBAClG,cAAc,CAAC,KAAK,CAAC,oEAAoE,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBAEzG,OAAO;aACR;YAED,WAAW,GAAG,cAAc,CAAC;YAE7B,cAAc,CAAC,KAAK,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAC;YAEpD,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAC1B;QAAC,OAAO,GAAG,EAAE;YACZ,cAAc,CAAC,KAAK,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;SAC1D;IACH,CAAC,CAAC;IAEF,OAAO;QACL,eAAe,iBAAA;KAChB,CAAC;AACJ,CAAC;AAlDD,8DAkDC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItem, TransportItemType } from '../../transports';\nimport type { Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { deepEqual, getCurrentTimestamp, isNull } from '../../utils';\nimport type { TracesAPI } from '../traces';\n\nimport type { MeasurementEvent, MeasurementsAPI } from './types';\n\nexport function initializeMeasurementsAPI(\n _unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas,\n transports: Transports,\n tracesApi: TracesAPI\n): MeasurementsAPI {\n internalLogger.debug('Initializing measurements API');\n\n let lastPayload: Pick<MeasurementEvent, 'type' | 'values' | 'context'> | null = null;\n\n const pushMeasurement: MeasurementsAPI['pushMeasurement'] = (payload, { skipDedupe, context } = {}) => {\n try {\n const item: TransportItem<MeasurementEvent> = {\n type: TransportItemType.MEASUREMENT,\n payload: {\n ...payload,\n trace: tracesApi.getTraceContext(),\n timestamp: payload.timestamp ?? getCurrentTimestamp(),\n context: context ?? {},\n },\n meta: metas.value,\n };\n\n const testingPayload = {\n type: item.payload.type,\n values: item.payload.values,\n context: item.payload.context,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping measurement 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 measurement\\n', item);\n\n transports.execute(item);\n } catch (err) {\n internalLogger.error('Error pushing measurement\\n', err);\n }\n };\n\n return {\n pushMeasurement,\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/measurements/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TraceContext } from '../traces';\n\nexport interface MeasurementEvent<V extends { [label: string]: number } = { [label: string]: number }> {\n type: string;\n values: V;\n\n timestamp: string;\n trace?: TraceContext;\n}\n\nexport interface PushMeasurementOptions {\n skipDedupe?: boolean;\n}\n\nexport interface MeasurementsAPI {\n pushMeasurement: (\n // TODO: change this back once we have aligned the measurement event types: See: https://github.com/grafana/faro-web-sdk/issues/110\n payload: Omit<MeasurementEvent, 'timestamp'> & Partial<Pick<MeasurementEvent, 'timestamp'>>,\n options?: PushMeasurementOptions\n ) => void;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/measurements/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TraceContext } from '../traces';\n\nexport type MeasurementContext = Record<string, string>;\n\nexport interface MeasurementEvent<V extends { [label: string]: number } = { [label: string]: number }> {\n type: string;\n values: V;\n\n timestamp: string;\n trace?: TraceContext;\n context?: MeasurementContext;\n}\n\nexport interface PushMeasurementOptions {\n skipDedupe?: boolean;\n context?: MeasurementContext;\n}\n\nexport interface MeasurementsAPI {\n pushMeasurement: (\n payload: Omit<MeasurementEvent, 'timestamp'> & Partial<Pick<MeasurementEvent, 'timestamp'>>,\n options?: PushMeasurementOptions\n ) => void;\n}\n"]}
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // auto-generated by bin/genVersion.ts
5
- exports.VERSION = '1.1.4';
5
+ exports.VERSION = '1.2.1';
6
6
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.1.4';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.2.1';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/exceptions/initialize.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,EAAE,S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AI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAG,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAE1F,IAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM,EAAE;YACvB,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG;gBACxB,MAAM,EAAE,WAAW;aACpB,CAAC;SACH;QAED,MAAM,cAAc,GAAG;YACrB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;YACvB,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;YACzB,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU;YACnC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;SAC9B,CAAC;QAEF,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,SAAS,CAAC,cAAc,EAAE,WAAW,CAAC,EAAE;YAClG,cAAc,CAAC,KAAK,CAAC,8DAA8D,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YAEnG,OAAO;SACR;QAED,WAAW,GAAG,cAAc,CAAC;QAE7B,cAAc,CAAC,KAAK,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC;QAElD,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC,CAAC;IAEF,sBAAsB,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAE/C,OAAO;QACL,sBAAsB;QACtB,mBAAmB;QACnB,SAAS;KACV,CAAC;AACJ,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 { deepEqual, getCurrentTimestamp, isNull } from '../../utils';\nimport type { TracesAPI } from '../traces';\n\nimport { defaultExceptionType } from './const';\nimport type { 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'> | 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'] = (error, { skipDedupe, stackFrames, type, context } = {}) => {\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: getCurrentTimestamp(),\n trace: tracesApi.getTraceContext(),\n context: context ?? {},\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 push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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 { deepEqual, getCurrentTimestamp, isNull } from '../../utils';\nimport type { TracesAPI } from '../traces';\n\nimport { defaultExceptionType } from './const';\nimport type { 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'] = (error, { skipDedupe, stackFrames, type, context } = {}) => {\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: getCurrentTimestamp(),\n trace: tracesApi.getTraceContext(),\n context: context ?? {},\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"]}
@@ -3,17 +3,18 @@ import { deepEqual, getCurrentTimestamp, isNull } from '../../utils';
3
3
  export function initializeMeasurementsAPI(_unpatchedConsole, internalLogger, config, metas, transports, tracesApi) {
4
4
  internalLogger.debug('Initializing measurements API');
5
5
  let lastPayload = null;
6
- const pushMeasurement = (payload, { skipDedupe } = {}) => {
6
+ const pushMeasurement = (payload, { skipDedupe, context } = {}) => {
7
7
  var _a;
8
8
  try {
9
9
  const item = {
10
10
  type: TransportItemType.MEASUREMENT,
11
- payload: Object.assign(Object.assign({}, payload), { trace: tracesApi.getTraceContext(), timestamp: (_a = payload.timestamp) !== null && _a !== void 0 ? _a : getCurrentTimestamp() }),
11
+ payload: Object.assign(Object.assign({}, payload), { trace: tracesApi.getTraceContext(), timestamp: (_a = payload.timestamp) !== null && _a !== void 0 ? _a : getCurrentTimestamp(), context: context !== null && context !== void 0 ? context : {} }),
12
12
  meta: metas.value,
13
13
  };
14
14
  const testingPayload = {
15
15
  type: item.payload.type,
16
16
  values: item.payload.values,
17
+ context: item.payload.context,
17
18
  };
18
19
  if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {
19
20
  internalLogger.debug('Skipping measurement push because it is the same as the last one\n', item.payload);
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/measurements/initialize.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGpE,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAKrE,MAAM,UAAU,yBAAyB,CACvC,iBAAmC,EACnC,cAA8B,EAC9B,MAAc,EACd,KAAY,EACZ,UAAsB,EACtB,SAAoB;IAEpB,cAAc,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAEtD,IAAI,WAAW,GAAqD,IAAI,CAAC;IAEzE,MAAM,eAAe,GAAuC,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,EAAE,EAAE;;QAC3F,IAAI;YACF,MAAM,IAAI,GAAoC;gBAC5C,IAAI,EAAE,iBAAiB,CAAC,WAAW;gBACnC,OAAO,kCACF,OAAO,KACV,KAAK,EAAE,SAAS,CAAC,eAAe,EAAE,EAClC,SAAS,EAAE,MAAA,OAAO,CAAC,SAAS,mCAAI,mBAAmB,EAAE,GACtD;gBACD,IAAI,EAAE,KAAK,CAAC,KAAK;aAClB,CAAC;YAEF,MAAM,cAAc,GAAG;gBACrB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;gBACvB,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM;aAC5B,CAAC;YAEF,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,SAAS,CAAC,cAAc,EAAE,WAAW,CAAC,EAAE;gBAClG,cAAc,CAAC,KAAK,CAAC,oEAAoE,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBAEzG,OAAO;aACR;YAED,WAAW,GAAG,cAAc,CAAC;YAE7B,cAAc,CAAC,KAAK,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAC;YAEpD,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAC1B;QAAC,OAAO,GAAG,EAAE;YACZ,cAAc,CAAC,KAAK,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;SAC1D;IACH,CAAC,CAAC;IAEF,OAAO;QACL,eAAe;KAChB,CAAC;AACJ,CAAC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItem, TransportItemType } from '../../transports';\nimport type { Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { deepEqual, getCurrentTimestamp, isNull } from '../../utils';\nimport type { TracesAPI } from '../traces';\n\nimport type { MeasurementEvent, MeasurementsAPI } from './types';\n\nexport function initializeMeasurementsAPI(\n _unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas,\n transports: Transports,\n tracesApi: TracesAPI\n): MeasurementsAPI {\n internalLogger.debug('Initializing measurements API');\n\n let lastPayload: Pick<MeasurementEvent, 'type' | 'values'> | null = null;\n\n const pushMeasurement: MeasurementsAPI['pushMeasurement'] = (payload, { skipDedupe } = {}) => {\n try {\n const item: TransportItem<MeasurementEvent> = {\n type: TransportItemType.MEASUREMENT,\n payload: {\n ...payload,\n trace: tracesApi.getTraceContext(),\n timestamp: payload.timestamp ?? getCurrentTimestamp(),\n },\n meta: metas.value,\n };\n\n const testingPayload = {\n type: item.payload.type,\n values: item.payload.values,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping measurement 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 measurement\\n', item);\n\n transports.execute(item);\n } catch (err) {\n internalLogger.error('Error pushing measurement\\n', err);\n }\n };\n\n return {\n pushMeasurement,\n };\n}\n"]}
1
+ {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/measurements/initialize.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGpE,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAKrE,MAAM,UAAU,yBAAyB,CACvC,iBAAmC,EACnC,cAA8B,EAC9B,MAAc,EACd,KAAY,EACZ,UAAsB,EACtB,SAAoB;IAEpB,cAA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{ Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItem, TransportItemType } from '../../transports';\nimport type { Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { deepEqual, getCurrentTimestamp, isNull } from '../../utils';\nimport type { TracesAPI } from '../traces';\n\nimport type { MeasurementEvent, MeasurementsAPI } from './types';\n\nexport function initializeMeasurementsAPI(\n _unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas,\n transports: Transports,\n tracesApi: TracesAPI\n): MeasurementsAPI {\n internalLogger.debug('Initializing measurements API');\n\n let lastPayload: Pick<MeasurementEvent, 'type' | 'values' | 'context'> | null = null;\n\n const pushMeasurement: MeasurementsAPI['pushMeasurement'] = (payload, { skipDedupe, context } = {}) => {\n try {\n const item: TransportItem<MeasurementEvent> = {\n type: TransportItemType.MEASUREMENT,\n payload: {\n ...payload,\n trace: tracesApi.getTraceContext(),\n timestamp: payload.timestamp ?? getCurrentTimestamp(),\n context: context ?? {},\n },\n meta: metas.value,\n };\n\n const testingPayload = {\n type: item.payload.type,\n values: item.payload.values,\n context: item.payload.context,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping measurement 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 measurement\\n', item);\n\n transports.execute(item);\n } catch (err) {\n internalLogger.error('Error pushing measurement\\n', err);\n }\n };\n\n return {\n pushMeasurement,\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/measurements/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TraceContext } from '../traces';\n\nexport interface MeasurementEvent<V extends { [label: string]: number } = { [label: string]: number }> {\n type: string;\n values: V;\n\n timestamp: string;\n trace?: TraceContext;\n}\n\nexport interface PushMeasurementOptions {\n skipDedupe?: boolean;\n}\n\nexport interface MeasurementsAPI {\n pushMeasurement: (\n // TODO: change this back once we have aligned the measurement event types: See: https://github.com/grafana/faro-web-sdk/issues/110\n payload: Omit<MeasurementEvent, 'timestamp'> & Partial<Pick<MeasurementEvent, 'timestamp'>>,\n options?: PushMeasurementOptions\n ) => void;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/measurements/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TraceContext } from '../traces';\n\nexport type MeasurementContext = Record<string, string>;\n\nexport interface MeasurementEvent<V extends { [label: string]: number } = { [label: string]: number }> {\n type: string;\n values: V;\n\n timestamp: string;\n trace?: TraceContext;\n context?: MeasurementContext;\n}\n\nexport interface PushMeasurementOptions {\n skipDedupe?: boolean;\n context?: MeasurementContext;\n}\n\nexport interface MeasurementsAPI {\n pushMeasurement: (\n payload: Omit<MeasurementEvent, 'timestamp'> & Partial<Pick<MeasurementEvent, 'timestamp'>>,\n options?: PushMeasurementOptions\n ) => void;\n}\n"]}
@@ -1,3 +1,3 @@
1
1
  // auto-generated by bin/genVersion.ts
2
- export const VERSION = '1.1.4';
2
+ export const VERSION = '1.2.1';
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.1.4';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.2.1';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../../../src/api/exceptions/initialize.ts"],"names":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AK,CAAC,KAAK,CAAC,CAAC,CAAC,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAG,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAE1F,IAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM,EAAE;YACvB,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG;gBACxB,MAAM,EAAE,WAAW;aACpB,CAAC;SACH;QAED,IAAM,cAAc,GAAG;YACrB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;YACvB,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;YACzB,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU;YACnC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;SAC9B,CAAC;QAEF,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,IAAA,cAAM,EAAC,WAAW,CAAC,IAAI,IAAA,iBAAS,EAAC,cAAc,EAAE,WAAW,CAAC,EAAE;YAClG,cAAc,CAAC,KAAK,CAAC,8DAA8D,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YAEnG,OAAO;SACR;QAED,WAAW,GAAG,cAAc,CAAC;QAE7B,cAAc,CAAC,KAAK,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC;QAElD,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC,CAAC;IAEF,sBAAsB,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAE/C,OAAO;QACL,sBAAsB,wBAAA;QACtB,mBAAmB,qBAAA;QACnB,SAAS,WAAA;KACV,CAAC;AACJ,CAAC;AAxED,0DAwEC","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 { deepEqual, getCurrentTimestamp, isNull } from '../../utils';\nimport type { TracesAPI } from '../traces';\n\nimport { defaultExceptionType } from './const';\nimport type { 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'> | 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'] = (error, { skipDedupe, stackFrames, type, context } = {}) => {\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: getCurrentTimestamp(),\n trace: tracesApi.getTraceContext(),\n context: context ?? {},\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"]}
1
+ {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../../../src/api/exceptions/initialize.ts"],"names":[],"mappings":";;;AAGA,+CAAqD;AAGrD,qCAAqE;AAGrE,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,UAAC,KAAK,EAAE,EAA+C;YAA/C,qBAA6C,EAAE,KAAA,EAA7C,UAAU,gBAAA,EAAE,WAAW,iBAAA,EAAE,IAAI,UAAA,EAAE,OAAO,aAAA;QAC5F,IAAI,GAAG,IAAI,IAAI,KAAK,CAAC,IAAI,IAAI,4BAAoB,CAAC;QAElD,IAAM,IAAI,GAAkC;YAC1C,IAAI,EAAE,KAAK,CAAC,KAAK;YACjB,OAAO,EAAE;gBACP,IAAI,MAAA;gBACJ,KAAK,EAAE,KAAK,CAAC,OAAO;gBACpB,SAAS,EAAE,IAAA,2BAAmB,GAAE;gBAChC,KAAK,EAAE,SAAS,CAAC,eAAe,EAAE;gBAClC,OAAO,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI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ger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItemType } from '../../transports';\nimport type { TransportItem, Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { deepEqual, getCurrentTimestamp, isNull } from '../../utils';\nimport type { TracesAPI } from '../traces';\n\nimport { defaultExceptionType } from './const';\nimport type { 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'] = (error, { skipDedupe, stackFrames, type, context } = {}) => {\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: getCurrentTimestamp(),\n trace: tracesApi.getTraceContext(),\n context: context ?? {},\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"]}
@@ -19,16 +19,17 @@ function initializeMeasurementsAPI(_unpatchedConsole, internalLogger, config, me
19
19
  var lastPayload = null;
20
20
  var pushMeasurement = function (payload, _a) {
21
21
  var _b;
22
- var _c = _a === void 0 ? {} : _a, skipDedupe = _c.skipDedupe;
22
+ var _c = _a === void 0 ? {} : _a, skipDedupe = _c.skipDedupe, context = _c.context;
23
23
  try {
24
24
  var item = {
25
25
  type: transports_1.TransportItemType.MEASUREMENT,
26
- payload: __assign(__assign({}, payload), { trace: tracesApi.getTraceContext(), timestamp: (_b = payload.timestamp) !== null && _b !== void 0 ? _b : (0, utils_1.getCurrentTimestamp)() }),
26
+ payload: __assign(__assign({}, payload), { trace: tracesApi.getTraceContext(), timestamp: (_b = payload.timestamp) !== null && _b !== void 0 ? _b : (0, utils_1.getCurrentTimestamp)(), context: context !== null && context !== void 0 ? context : {} }),
27
27
  meta: metas.value,
28
28
  };
29
29
  var testingPayload = {
30
30
  type: item.payload.type,
31
31
  values: item.payload.values,
32
+ context: item.payload.context,
32
33
  };
33
34
  if (!skipDedupe && config.dedupe && !(0, utils_1.isNull)(lastPayload) && (0, utils_1.deepEqual)(testingPayload, lastPayload)) {
34
35
  internalLogger.debug('Skipping measurement push because it is the same as the last one\n', item.payload);
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../../../src/api/measurements/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAGA,+CAAoE;AAGpE,qCAAqE;AAKrE,SAAgB,yBAAyB,CACvC,iBAAmC,EACnC,cAA8B,EAC9B,MAAc,EACd,KAAY,EACZ,UAAsB,EACtB,SAAoB;IAEpB,cAAc,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAEtD,IAAI,WAAW,GAAqD,IAAI,CAAC;IAEzE,IAAM,eAAe,GAAuC,UAAC,OAAO,EAAE,EAAmB;;YAAnB,qBAAiB,EAAE,KAAA,EAAjB,UAAU,gBAAA;QAChF,IAAI;YACF,IAAM,IAAI,GAAoC;gBAC5C,IAAI,EAAE,8BAAiB,CAAC,WAAW;gBACnC,OAAO,wBACF,OAAO,KACV,KAAK,EAAE,SAAS,CAAC,eAAe,EAAE,EAClC,SAAS,EAAE,MAAA,OAAO,CAAC,SAAS,mCAAI,IAAA,2BAAmB,GAAE,GACtD;gBACD,IAAI,EAAE,KAAK,CAAC,KAAK;aAClB,CAAC;YAEF,IAAM,cAAc,GAAG;gBACrB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;gBACvB,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM;aAC5B,CAAC;YAEF,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,IAAA,cAAM,EAAC,WAAW,CAAC,IAAI,IAAA,iBAAS,EAAC,cAAc,EAAE,WAAW,CAAC,EAAE;gBAClG,cAAc,CAAC,KAAK,CAAC,oEAAoE,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBAEzG,OAAO;aACR;YAED,WAAW,GAAG,cAAc,CAAC;YAE7B,cAAc,CAAC,KAAK,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAC;YAEpD,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAC1B;QAAC,OAAO,GAAG,EAAE;YACZ,cAAc,CAAC,KAAK,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;SAC1D;IACH,CAAC,CAAC;IAEF,OAAO;QACL,eAAe,iBAAA;KAChB,CAAC;AACJ,CAAC;AAhDD,8DAgDC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItem, TransportItemType } from '../../transports';\nimport type { Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { deepEqual, getCurrentTimestamp, isNull } from '../../utils';\nimport type { TracesAPI } from '../traces';\n\nimport type { MeasurementEvent, MeasurementsAPI } from './types';\n\nexport function initializeMeasurementsAPI(\n _unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas,\n transports: Transports,\n tracesApi: TracesAPI\n): MeasurementsAPI {\n internalLogger.debug('Initializing measurements API');\n\n let lastPayload: Pick<MeasurementEvent, 'type' | 'values'> | null = null;\n\n const pushMeasurement: MeasurementsAPI['pushMeasurement'] = (payload, { skipDedupe } = {}) => {\n try {\n const item: TransportItem<MeasurementEvent> = {\n type: TransportItemType.MEASUREMENT,\n payload: {\n ...payload,\n trace: tracesApi.getTraceContext(),\n timestamp: payload.timestamp ?? getCurrentTimestamp(),\n },\n meta: metas.value,\n };\n\n const testingPayload = {\n type: item.payload.type,\n values: item.payload.values,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping measurement 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 measurement\\n', item);\n\n transports.execute(item);\n } catch (err) {\n internalLogger.error('Error pushing measurement\\n', err);\n }\n };\n\n return {\n pushMeasurement,\n };\n}\n"]}
1
+ {"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../../../src/api/measurements/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAGA,+CAAoE;AAGpE,qCAAqE;AAKrE,SAAgB,yBAAyB,CACvC,iBAAmC,EACnC,cAA8B,EAC9B,MAAc,EACd,KAAY,EACZ,UAAsB,EACtB,SAAoB;IAEpB,cAAc,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAEtD,IAAI,WAAW,GAAiE,IAAI,CAAC;IAErF,IAAM,eAAe,GAAuC,UAAC,OAAO,EAAE,EAA4B;;YAA5B,qBAA0B,EAAE,KAAA,EAA1B,UAAU,gBAAA,EAAE,OAAO,aAAA;QACzF,IAAI;YACF,IAAM,IAAI,GAAoC;gBAC5C,IAAI,EAAE,8BAAiB,CAAC,WAAW;gBACnC,OAAO,wBACF,OAAO,KACV,KAAK,EAAE,SAAS,CAAC,eAAe,EAAE,EAClC,SAAS,EAAE,MAAA,OAAO,CAAC,SAAS,mCAAI,IAAA,2BAAmB,GAAE,EACrD,OAAO,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,GACvB;gBACD,IAAI,EAAE,KAAK,CAAC,KAAK;aAClB,CAAC;YAEF,IAAM,cAAc,GAAG;gBACrB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;gBACvB,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM;gBAC3B,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;aAC9B,CAAC;YAEF,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,IAAA,cAAM,EAAC,WAAW,CAAC,IAAI,IAAA,iBAAS,EAAC,cAAc,EAAE,WAAW,CAAC,EAAE;gBAClG,cAAc,CAAC,KAAK,CAAC,oEAAoE,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBAEzG,OAAO;aACR;YAED,WAAW,GAAG,cAAc,CAAC;YAE7B,cAAc,CAAC,KAAK,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAC;YAEpD,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAC1B;QAAC,OAAO,GAAG,EAAE;YACZ,cAAc,CAAC,KAAK,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;SAC1D;IACH,CAAC,CAAC;IAEF,OAAO;QACL,eAAe,iBAAA;KAChB,CAAC;AACJ,CAAC;AAlDD,8DAkDC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItem, TransportItemType } from '../../transports';\nimport type { Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { deepEqual, getCurrentTimestamp, isNull } from '../../utils';\nimport type { TracesAPI } from '../traces';\n\nimport type { MeasurementEvent, MeasurementsAPI } from './types';\n\nexport function initializeMeasurementsAPI(\n _unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas,\n transports: Transports,\n tracesApi: TracesAPI\n): MeasurementsAPI {\n internalLogger.debug('Initializing measurements API');\n\n let lastPayload: Pick<MeasurementEvent, 'type' | 'values' | 'context'> | null = null;\n\n const pushMeasurement: MeasurementsAPI['pushMeasurement'] = (payload, { skipDedupe, context } = {}) => {\n try {\n const item: TransportItem<MeasurementEvent> = {\n type: TransportItemType.MEASUREMENT,\n payload: {\n ...payload,\n trace: tracesApi.getTraceContext(),\n timestamp: payload.timestamp ?? getCurrentTimestamp(),\n context: context ?? {},\n },\n meta: metas.value,\n };\n\n const testingPayload = {\n type: item.payload.type,\n values: item.payload.values,\n context: item.payload.context,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping measurement 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 measurement\\n', item);\n\n transports.execute(item);\n } catch (err) {\n internalLogger.error('Error pushing measurement\\n', err);\n }\n };\n\n return {\n pushMeasurement,\n };\n}\n"]}
@@ -44,6 +44,31 @@ describe('api.measurements', function () {
44
44
  api.pushMeasurement(measurement);
45
45
  expect(transport.items).toHaveLength(1);
46
46
  });
47
+ it('filters the same measurement with the same context', function () {
48
+ var measurement = {
49
+ type: 'custom',
50
+ values: {
51
+ a: 1,
52
+ },
53
+ };
54
+ var context = { foo: 'bar' };
55
+ api.pushMeasurement(measurement, { context: context });
56
+ expect(transport.items).toHaveLength(1);
57
+ api.pushMeasurement(measurement, { context: context });
58
+ expect(transport.items).toHaveLength(1);
59
+ });
60
+ it("doesn't filter events with different context", function () {
61
+ var measurement = {
62
+ type: 'custom',
63
+ values: {
64
+ a: 1,
65
+ },
66
+ };
67
+ api.pushMeasurement(measurement, { context: { foo: 'bar' } });
68
+ expect(transport.items).toHaveLength(1);
69
+ api.pushMeasurement(measurement, { context: { bar: 'baz' } });
70
+ expect(transport.items).toHaveLength(2);
71
+ });
47
72
  it("doesn't filter measurements with same type and partially same values", function () {
48
73
  var measurement1 = {
49
74
  type: 'custom',
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.test.js","sourceRoot":"","sources":["../../../../../../src/api/measurements/initialize.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+CAAkD;AAClD,6CAA4D;AAG5D,QAAQ,CAAC,kBAAkB,EAAE;IAC3B,SAAS,SAAS,CAAC,EAAkD;YAAlD,qBAAkC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAA,EAAhD,MAAM,YAAA;QACzB,IAAM,SAAS,GAAG,IAAI,yBAAa,EAAE,CAAC;QACtC,IAAM,MAAM,GAAG,IAAA,sBAAU,EAAC;YACxB,MAAM,QAAA;YACN,UAAU,EAAE,CAAC,SAAS,CAAC;SACxB,CAAC,CAAC;QAEK,IAAA,GAAG,GAAK,IAAA,2BAAc,EAAC,MAAM,CAAC,IAA3B,CAA4B;QAEvC,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAC1B,CAAC;IAED,QAAQ,CAAC,iBAAiB,EAAE;QAC1B,IAAI,GAAQ,CAAC;QACb,IAAI,SAAwB,CAAC;QAE7B,UAAU,CAAC;;YACT,KAAmB,SAAS,EAAE,EAA7B,GAAG,QAAA,EAAE,SAAS,QAAA,CAAgB;QACjC,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,WAAW,EAAE;YACpB,EAAE,CAAC,8BAA8B,EAAE;gBACjC,IAAM,WAAW,GAAG;oBAClB,IAAI,EAAE,QAAQ;oBACd,MAAM,EA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C,CAAC,CAAC,CAAC;YAC1C,CAAC,CAAC,CAAC;YAEH,EAAE,CAAC,wCAAwC,EAAE;gBAC3C,IAAM,WAAW,GAAG;oBAClB,IAAI,EAAE,QAAQ;oBACd,MAAM,EAAE;wBACN,CAAC,EAAE,CAAC;qBACL;iBACF,CAAC;gBAEF,GAAG,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;gBACjC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;gBAExC,GAAG,CAAC,eAAe,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;gBACvD,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAC1C,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { initializeFaro } from '../../initialize';\nimport { mockConfig, MockTransport } from '../../testUtils';\nimport type { API } from '../types';\n\ndescribe('api.measurements', () => {\n function createAPI({ dedupe }: { dedupe: boolean } = { dedupe: true }): [API, MockTransport] {\n const transport = new MockTransport();\n const config = mockConfig({\n dedupe,\n transports: [transport],\n });\n\n const { api } = initializeFaro(config);\n\n return [api, transport];\n }\n\n describe('pushMeasurement', () => {\n let api: API;\n let transport: MockTransport;\n\n beforeEach(() => {\n [api, transport] = createAPI();\n });\n\n describe('Filtering', () => {\n it('filters the same measurement', () => {\n const measurement = {\n type: 'custom',\n values: {\n a: 1,\n },\n };\n\n api.pushMeasurement(measurement);\n expect(transport.items).toHaveLength(1);\n\n api.pushMeasurement(measurement);\n expect(transport.items).toHaveLength(1);\n });\n\n it(\"doesn't filter measurements with same type and partially same values\", () => {\n const measurement1 = {\n type: 'custom',\n values: {\n a: 1,\n },\n };\n\n const measurement2 = {\n ...measurement1,\n values: {\n ...measurement1.values,\n b: 2,\n },\n };\n\n api.pushMeasurement(measurement1);\n expect(transport.items).toHaveLength(1);\n\n api.pushMeasurement(measurement2);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter measurements with different type and same values\", () => {\n const measurement1 = {\n type: 'custom',\n values: {\n a: 1,\n },\n };\n\n const measurement2 = {\n ...measurement1,\n type: 'web-vitals',\n };\n\n api.pushMeasurement(measurement1);\n expect(transport.items).toHaveLength(1);\n\n api.pushMeasurement(measurement2);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"filters a measurement and doesn't filter the next different one\", () => {\n const measurement1 = {\n type: 'custom',\n values: {\n a: 1,\n },\n };\n\n const measurement2 = {\n ...measurement1,\n type: 'web-vitals',\n };\n\n api.pushMeasurement(measurement1);\n expect(transport.items).toHaveLength(1);\n\n api.pushMeasurement(measurement1);\n expect(transport.items).toHaveLength(1);\n\n api.pushMeasurement(measurement2);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter when dedupe is false\", () => {\n [api, transport] = createAPI({ dedupe: false });\n\n const measurement = {\n type: 'custom',\n values: {\n a: 1,\n },\n };\n\n api.pushMeasurement(measurement);\n expect(transport.items).toHaveLength(1);\n\n api.pushMeasurement(measurement);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter when skipDedupe is true\", () => {\n const measurement = {\n type: 'custom',\n values: {\n a: 1,\n },\n };\n\n api.pushMeasurement(measurement);\n expect(transport.items).toHaveLength(1);\n\n api.pushMeasurement(measurement, { skipDedupe: true });\n expect(transport.items).toHaveLength(2);\n });\n });\n });\n});\n"]}
1
+ {"version":3,"file":"initialize.test.js","sourceRoot":"","sources":["../../../../../../src/api/measurements/initialize.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+CAAkD;AAClD,6CAA4D;AAG5D,QAAQ,CAAC,kBAAkB,EAAE;IAC3B,SAAS,SAAS,CAAC,EAAkD;YAAlD,qBAAkC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAA,EAAhD,MAAM,YAAA;QACzB,IAAM,SA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AAC,qCAAqC,EAAE;;gBACxC,KAAmB,SAAS,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAA9C,GAAG,QAAA,EAAE,SAAS,QAAA,CAAiC;gBAEhD,IAAM,WAAW,GAAG;oBAClB,IAAI,EAAE,QAAQ;oBACd,MAAM,EAAE;wBACN,CAAC,EAAE,CAAC;qBACL;iBACF,CAAC;gBAEF,GAAG,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;gBACjC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;gBAExC,GAAG,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;gBACjC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAC1C,CAAC,CAAC,CAAC;YAEH,EAAE,CAAC,wCAAwC,EAAE;gBAC3C,IAAM,WAAW,GAAG;oBAClB,IAAI,EAAE,QAAQ;oBACd,MAAM,EAAE;wBACN,CAAC,EAAE,CAAC;qBACL;iBACF,CAAC;gBAEF,GAAG,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;gBACjC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;gBAExC,GAAG,CAAC,eAAe,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;gBACvD,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAC1C,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { initializeFaro } from '../../initialize';\nimport { mockConfig, MockTransport } from '../../testUtils';\nimport type { API } from '../types';\n\ndescribe('api.measurements', () => {\n function createAPI({ dedupe }: { dedupe: boolean } = { dedupe: true }): [API, MockTransport] {\n const transport = new MockTransport();\n const config = mockConfig({\n dedupe,\n transports: [transport],\n });\n\n const { api } = initializeFaro(config);\n\n return [api, transport];\n }\n\n describe('pushMeasurement', () => {\n let api: API;\n let transport: MockTransport;\n\n beforeEach(() => {\n [api, transport] = createAPI();\n });\n\n describe('Filtering', () => {\n it('filters the same measurement', () => {\n const measurement = {\n type: 'custom',\n values: {\n a: 1,\n },\n };\n\n api.pushMeasurement(measurement);\n expect(transport.items).toHaveLength(1);\n\n api.pushMeasurement(measurement);\n expect(transport.items).toHaveLength(1);\n });\n\n it('filters the same measurement with the same context', () => {\n const measurement = {\n type: 'custom',\n values: {\n a: 1,\n },\n };\n\n const context = { foo: 'bar' };\n\n api.pushMeasurement(measurement, { context });\n expect(transport.items).toHaveLength(1);\n\n api.pushMeasurement(measurement, { context });\n expect(transport.items).toHaveLength(1);\n });\n\n it(\"doesn't filter events with different context\", () => {\n const measurement = {\n type: 'custom',\n values: {\n a: 1,\n },\n };\n\n api.pushMeasurement(measurement, { context: { foo: 'bar' } });\n expect(transport.items).toHaveLength(1);\n\n api.pushMeasurement(measurement, { context: { bar: 'baz' } });\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter measurements with same type and partially same values\", () => {\n const measurement1 = {\n type: 'custom',\n values: {\n a: 1,\n },\n };\n\n const measurement2 = {\n ...measurement1,\n values: {\n ...measurement1.values,\n b: 2,\n },\n };\n\n api.pushMeasurement(measurement1);\n expect(transport.items).toHaveLength(1);\n\n api.pushMeasurement(measurement2);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter measurements with different type and same values\", () => {\n const measurement1 = {\n type: 'custom',\n values: {\n a: 1,\n },\n };\n\n const measurement2 = {\n ...measurement1,\n type: 'web-vitals',\n };\n\n api.pushMeasurement(measurement1);\n expect(transport.items).toHaveLength(1);\n\n api.pushMeasurement(measurement2);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"filters a measurement and doesn't filter the next different one\", () => {\n const measurement1 = {\n type: 'custom',\n values: {\n a: 1,\n },\n };\n\n const measurement2 = {\n ...measurement1,\n type: 'web-vitals',\n };\n\n api.pushMeasurement(measurement1);\n expect(transport.items).toHaveLength(1);\n\n api.pushMeasurement(measurement1);\n expect(transport.items).toHaveLength(1);\n\n api.pushMeasurement(measurement2);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter when dedupe is false\", () => {\n [api, transport] = createAPI({ dedupe: false });\n\n const measurement = {\n type: 'custom',\n values: {\n a: 1,\n },\n };\n\n api.pushMeasurement(measurement);\n expect(transport.items).toHaveLength(1);\n\n api.pushMeasurement(measurement);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter when skipDedupe is true\", () => {\n const measurement = {\n type: 'custom',\n values: {\n a: 1,\n },\n };\n\n api.pushMeasurement(measurement);\n expect(transport.items).toHaveLength(1);\n\n api.pushMeasurement(measurement, { skipDedupe: true });\n expect(transport.items).toHaveLength(2);\n });\n });\n });\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/api/measurements/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TraceContext } from '../traces';\n\nexport interface MeasurementEvent<V extends { [label: string]: number } = { [label: string]: number }> {\n type: string;\n values: V;\n\n timestamp: string;\n trace?: TraceContext;\n}\n\nexport interface PushMeasurementOptions {\n skipDedupe?: boolean;\n}\n\nexport interface MeasurementsAPI {\n pushMeasurement: (\n // TODO: change this back once we have aligned the measurement event types: See: https://github.com/grafana/faro-web-sdk/issues/110\n payload: Omit<MeasurementEvent, 'timestamp'> & Partial<Pick<MeasurementEvent, 'timestamp'>>,\n options?: PushMeasurementOptions\n ) => void;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/api/measurements/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TraceContext } from '../traces';\n\nexport type MeasurementContext = Record<string, string>;\n\nexport interface MeasurementEvent<V extends { [label: string]: number } = { [label: string]: number }> {\n type: string;\n values: V;\n\n timestamp: string;\n trace?: TraceContext;\n context?: MeasurementContext;\n}\n\nexport interface PushMeasurementOptions {\n skipDedupe?: boolean;\n context?: MeasurementContext;\n}\n\nexport interface MeasurementsAPI {\n pushMeasurement: (\n payload: Omit<MeasurementEvent, 'timestamp'> & Partial<Pick<MeasurementEvent, 'timestamp'>>,\n options?: PushMeasurementOptions\n ) => void;\n}\n"]}
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // auto-generated by bin/genVersion.ts
5
- exports.VERSION = '1.1.4';
5
+ exports.VERSION = '1.2.1';
6
6
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.1.4';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.2.1';\n"]}
@@ -1,4 +1,5 @@
1
1
  import type { TraceContext } from '../traces';
2
+ export type MeasurementContext = Record<string, string>;
2
3
  export interface MeasurementEvent<V extends {
3
4
  [label: string]: number;
4
5
  } = {
@@ -8,9 +9,11 @@ export interface MeasurementEvent<V extends {
8
9
  values: V;
9
10
  timestamp: string;
10
11
  trace?: TraceContext;
12
+ context?: MeasurementContext;
11
13
  }
12
14
  export interface PushMeasurementOptions {
13
15
  skipDedupe?: boolean;
16
+ context?: MeasurementContext;
14
17
  }
15
18
  export interface MeasurementsAPI {
16
19
  pushMeasurement: (payload: Omit<MeasurementEvent, 'timestamp'> & Partial<Pick<MeasurementEvent, 'timestamp'>>, options?: PushMeasurementOptions) => void;
@@ -1,4 +1,5 @@
1
1
  import type { TraceContext } from '../traces';
2
+ export type MeasurementContext = Record<string, string>;
2
3
  export interface MeasurementEvent<V extends {
3
4
  [label: string]: number;
4
5
  } = {
@@ -8,9 +9,11 @@ export interface MeasurementEvent<V extends {
8
9
  values: V;
9
10
  timestamp: string;
10
11
  trace?: TraceContext;
12
+ context?: MeasurementContext;
11
13
  }
12
14
  export interface PushMeasurementOptions {
13
15
  skipDedupe?: boolean;
16
+ context?: MeasurementContext;
14
17
  }
15
18
  export interface MeasurementsAPI {
16
19
  pushMeasurement: (payload: Omit<MeasurementEvent, 'timestamp'> & Partial<Pick<MeasurementEvent, 'timestamp'>>, options?: PushMeasurementOptions) => void;
@@ -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.1.4";
7
+ readonly version = "1.2.1";
8
8
  items: TransportItem[];
9
9
  constructor(ignoreURLs?: Patterns);
10
10
  send(items: TransportItem[]): void | Promise<void>;
@@ -1 +1 @@
1
- export declare const VERSION = "1.1.4";
1
+ export declare const VERSION = "1.2.1";
@@ -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.1.4";
7
+ readonly version = "1.2.1";
8
8
  items: TransportItem[];
9
9
  constructor(ignoreURLs?: Patterns);
10
10
  send(items: TransportItem[]): void | Promise<void>;
@@ -1 +1 @@
1
- export declare const VERSION = "1.1.4";
1
+ export declare const VERSION = "1.2.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/faro-core",
3
- "version": "1.1.4",
3
+ "version": "1.2.1",
4
4
  "description": "Core package of Faro.",
5
5
  "keywords": [
6
6
  "observability",
@@ -62,5 +62,5 @@
62
62
  "publishConfig": {
63
63
  "access": "public"
64
64
  },
65
- "gitHead": "b9428185508120a7a92e5c1caf23292aeb066d0c"
65
+ "gitHead": "8bc51d9bd142485d0dd5d5fbf1dfe805aa96bcc8"
66
66
  }