@grafana/faro-core 1.9.1 → 1.10.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.
- package/dist/bundle/faro-core.iife.js +1 -1
- package/dist/bundle/types/api/exceptions/index.d.ts +1 -1
- package/dist/bundle/types/api/exceptions/types.d.ts +4 -1
- package/dist/bundle/types/consts.d.ts +1 -0
- package/dist/bundle/types/index.d.ts +1 -0
- package/dist/bundle/types/testUtils/mockTransport.d.ts +1 -1
- package/dist/bundle/types/version.d.ts +1 -1
- package/dist/cjs/api/exceptions/index.js.map +1 -1
- package/dist/cjs/api/exceptions/initialize.js +27 -1
- package/dist/cjs/api/exceptions/initialize.js.map +1 -1
- package/dist/cjs/api/exceptions/types.js.map +1 -1
- package/dist/cjs/consts.js +5 -0
- package/dist/cjs/consts.js.map +1 -0
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/api/exceptions/index.js.map +1 -1
- package/dist/esm/api/exceptions/initialize.js +17 -2
- package/dist/esm/api/exceptions/initialize.js.map +1 -1
- package/dist/esm/api/exceptions/types.js.map +1 -1
- package/dist/esm/consts.js +2 -0
- package/dist/esm/consts.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/spec/core/src/api/exceptions/index.js.map +1 -1
- package/dist/spec/core/src/api/exceptions/initialize.js +27 -1
- package/dist/spec/core/src/api/exceptions/initialize.js.map +1 -1
- package/dist/spec/core/src/api/exceptions/initialize.test.js +31 -0
- package/dist/spec/core/src/api/exceptions/initialize.test.js.map +1 -1
- package/dist/spec/core/src/api/exceptions/types.js.map +1 -1
- package/dist/spec/core/src/consts.js +5 -0
- package/dist/spec/core/src/consts.js.map +1 -0
- package/dist/spec/core/src/index.js +3 -1
- package/dist/spec/core/src/index.js.map +1 -1
- package/dist/spec/core/src/version.js +1 -1
- package/dist/spec/core/src/version.js.map +1 -1
- package/dist/types/api/exceptions/index.d.ts +1 -1
- package/dist/types/api/exceptions/types.d.ts +4 -1
- package/dist/types/consts.d.ts +1 -0
- package/dist/types/core/src/api/exceptions/index.d.ts +1 -1
- package/dist/types/core/src/api/exceptions/types.d.ts +4 -1
- package/dist/types/core/src/consts.d.ts +1 -0
- package/dist/types/core/src/index.d.ts +1 -0
- package/dist/types/core/src/testUtils/mockTransport.d.ts +1 -1
- package/dist/types/core/src/version.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/testUtils/mockTransport.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
var GrafanaFaroCore=function(e){"use strict";function n(e,n){return typeof e===n}function t(e,n){return Object.prototype.toString.call(e)===`[object ${n}]`}function r(e,n){try{return e instanceof n}catch(e){return!1}}const a=e=>n(e,"null"),i=e=>n(e,"string"),o=e=>n(e,"number")&&!isNaN(e)||n(e,"bigint"),s=e=>!a(e)&&n(e,"object"),l=e=>n(e,"function"),u=e=>t(e,"Array"),c="undefined"!=typeof Event,d="undefined"!=typeof Error,g="undefined"!=typeof Element,p="undefined"!=typeof Map;function f(e,t){if(e===t)return!0;if(n(e,"number")&&isNaN(e))return n(t,"number")&&isNaN(t);const r=u(e),a=u(t);if(r!==a)return!1;if(r&&a){const n=e.length;if(n!==t.length)return!1;for(let r=n;0!=r--;)if(!f(e[r],t[r]))return!1;return!0}const i=s(e),o=s(t);if(i!==o)return!1;if(e&&t&&i&&o){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;for(let r of n)if(!f(e[r],t[r]))return!1;return!0}return!1}function m(){return(new Date).toISOString()}function v(e){return new Date(e).toISOString()}var b;e.LogLevel=void 0,(b=e.LogLevel||(e.LogLevel={})).TRACE="trace",b.DEBUG="debug",b.INFO="info",b.LOG="log",b.WARN="warn",b.ERROR="error";const h=e.LogLevel.LOG,E=[e.LogLevel.TRACE,e.LogLevel.DEBUG,e.LogLevel.INFO,e.LogLevel.LOG,e.LogLevel.WARN,e.LogLevel.ERROR];function y(){}const I="abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789";const T="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:void 0;class O{constructor(e,n){var t,r;this.signalBuffer=[],this.itemLimit=null!==(t=null==n?void 0:n.itemLimit)&&void 0!==t?t:50,this.sendTimeout=null!==(r=null==n?void 0:n.sendTimeout)&&void 0!==r?r:250,this.paused=(null==n?void 0:n.paused)||!1,this.sendFn=e,this.flushInterval=-1,this.paused||this.start(),document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&this.flush()}))}addItem(e){this.paused||(this.signalBuffer.push(e),this.signalBuffer.length>=this.itemLimit&&this.flush())}start(){this.paused=!1,this.sendTimeout>0&&(this.flushInterval=window.setInterval((()=>this.flush()),this.sendTimeout))}pause(){this.paused=!0,clearInterval(this.flushInterval)}groupItems(e){const n=new Map;return e.forEach((e=>{const t=JSON.stringify(e.meta);let r=n.get(t);r=void 0===r?[e]:[...r,e],n.set(t,r)})),Array.from(n.values())}flush(){if(this.paused||0===this.signalBuffer.length)return;this.groupItems(this.signalBuffer).forEach(this.sendFn),this.signalBuffer=[]}}var L;e.TransportItemType=void 0,(L=e.TransportItemType||(e.TransportItemType={})).EXCEPTION="exception",L.LOG="log",L.MEASUREMENT="measurement",L.TRACE="trace",L.EVENT="event";const S={[e.TransportItemType.EXCEPTION]:"exceptions",[e.TransportItemType.LOG]:"logs",[e.TransportItemType.MEASUREMENT]:"measurements",[e.TransportItemType.TRACE]:"traces",[e.TransportItemType.EVENT]:"events"};function N(n){return t=>{if(t.type===e.TransportItemType.EXCEPTION&&t.payload){const e=t.payload,r=`${e.type}: ${e.value}`;if(function(e,n){return e.some((e=>i(e)?n.includes(e):!!n.match(e)))}(n,r))return null}return t}}function x(e,n,t,r){var a;n.debug("Initializing transports");const i=[];let o=t.paused,s=[];const l=e=>{let n=e;for(const e of s){const t=n.map(e).filter(Boolean);if(0===t.length)return[];n=t}return n},u=e=>{const t=l(e);if(0!==t.length)for(const e of i)n.debug(`Transporting item using ${e.name}\n`,t),e.isBatched()&&e.send(t)};let c;(null===(a=t.batching)||void 0===a?void 0:a.enabled)&&(c=new O(u,{sendTimeout:t.batching.sendTimeout,itemLimit:t.batching.itemLimit,paused:o}));return{add:(...a)=>{n.debug("Adding transports"),a.forEach((a=>{n.debug(`Adding "${a.name}" transport`);i.some((e=>e===a))?n.warn(`Transport ${a.name} is already added`):(a.unpatchedConsole=e,a.internalLogger=n,a.config=t,a.metas=r,i.push(a))}))},addBeforeSendHooks:(...e)=>{n.debug("Adding beforeSendHooks\n",s),e.forEach((e=>{e&&s.push(e)}))},addIgnoreErrorsPatterns:(...e)=>{n.debug("Adding ignoreErrorsPatterns\n",e),e.forEach((e=>{e&&s.push(N(e))}))},getBeforeSendHooks:()=>[...s],execute:e=>{var r;o||((null===(r=t.batching)||void 0===r?void 0:r.enabled)&&(null==c||c.addItem(e)),(e=>{var r,a;if((null===(r=t.batching)||void 0===r?void 0:r.enabled)&&i.every((e=>e.isBatched())))return;const[o]=l([e]);if(void 0!==o)for(const e of i)n.debug(`Transporting item using ${e.name}\n`,o),e.isBatched()?(null===(a=t.batching)||void 0===a?void 0:a.enabled)||e.send([o]):e.send(o)})(e))},isPaused:()=>o,pause:()=>{n.debug("Pausing transports"),null==c||c.pause(),o=!0},remove:(...e)=>{n.debug("Removing transports"),e.forEach((e=>{n.debug(`Removing "${e.name}" transport`);const t=i.indexOf(e);-1!==t?i.splice(t,1):n.warn(`Transport "${e.name}" is not added`)}))},removeBeforeSendHooks:(...e)=>{s.filter((n=>!e.includes(n)))},get transports(){return[...i]},unpause:()=>{n.debug("Unpausing transports"),null==c||c.start(),o=!1}}}var R;e.InternalLoggerLevel=void 0,(R=e.InternalLoggerLevel||(e.InternalLoggerLevel={}))[R.OFF=0]="OFF",R[R.ERROR=1]="ERROR",R[R.WARN=2]="WARN",R[R.INFO=3]="INFO",R[R.VERBOSE=4]="VERBOSE";const j={debug:y,error:y,info:y,prefix:"Faro",warn:y},A=e.InternalLoggerLevel.ERROR,C=Object.assign({},console);let w=C;function k(e){var n;return w=null!==(n=e.unpatchedConsole)&&void 0!==n?n:w,w}function _(n=C,t=A){const r=j;return t>e.InternalLoggerLevel.OFF&&(r.error=t>=e.InternalLoggerLevel.ERROR?function(...e){n.error(`${r.prefix}\n`,...e)}:y,r.warn=t>=e.InternalLoggerLevel.WARN?function(...e){n.warn(`${r.prefix}\n`,...e)}:y,r.info=t>=e.InternalLoggerLevel.INFO?function(...e){n.info(`${r.prefix}\n`,...e)}:y,r.debug=t>=e.InternalLoggerLevel.VERBOSE?function(...e){n.debug(`${r.prefix}\n`,...e)}:y),r}let P=j;function B(e,n){return P=_(e,n.internalLoggerLevel),P}class F{constructor(){this.unpatchedConsole=C,this.internalLogger=j,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 D(e,n){var t,r;if(void 0===n)return e;if(void 0===e)return{resourceSpans:n};const a=null===(t=e.resourceSpans)||void 0===t?void 0:t[0];if(void 0===a)return e;const i=(null==a?void 0:a.scopeSpans)||[],o=(null===(r=null==n?void 0:n[0])||void 0===r?void 0:r.scopeSpans)||[];return Object.assign(Object.assign({},e),{resourceSpans:[Object.assign(Object.assign({},a),{scopeSpans:[...i,...o]})]})}const M="Error";let $;const G=e=>e.map((e=>{try{return String(e)}catch(e){return""}})).join(" ");function V(n,t,r,i,o){t.debug("Initializing API");const s=function(n,t,r,a,i){let o;return t.debug("Initializing traces API"),{getOTEL:()=>o,getTraceContext:()=>{const e=null==o?void 0:o.trace.getSpanContext(o.context.active());return e?{trace_id:e.traceId,span_id:e.spanId}:void 0},initOTEL:(e,n)=>{t.debug("Initializing OpenTelemetry"),o={trace:e,context:n}},isOTELInitialized:()=>!!o,pushTraces:n=>{try{const r={type:e.TransportItemType.TRACE,payload:n,meta:a.value};t.debug("Pushing trace\n",r),i.execute(r)}catch(e){t.error("Error pushing trace\n",e)}}}}(0,t,0,i,o);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},s),function(n,t,r,i,o,s){var l;t.debug("Initializing exceptions API");let u=null;$=null!==(l=r.parseStacktrace)&&void 0!==l?l:$;const c=e=>{t.debug("Changing stacktrace parser"),$=null!=e?e:$};return c(r.parseStacktrace),{changeStacktraceParser:c,getStacktraceParser:()=>$,pushError:(n,{skipDedupe:l,stackFrames:c,type:d,context:g,spanContext:p,timestampOverwriteMs:b}={})=>{d=d||n.name||M;const h={meta:i.value,payload:{type:d,value:n.message,timestamp:b?v(b):m(),trace:p?{trace_id:p.traceId,span_id:p.spanId}:s.getTraceContext(),context:null!=g?g:{}},type:e.TransportItemType.EXCEPTION};(null==(c=null!=c?c:n.stack?null==$?void 0:$(n).frames:void 0)?void 0:c.length)&&(h.payload.stacktrace={frames:c});const E={type:h.payload.type,value:h.payload.value,stackTrace:h.payload.stacktrace,context:h.payload.context};l||!r.dedupe||a(u)||!f(E,u)?(u=E,t.debug("Pushing exception\n",h),o.execute(h)):t.debug("Skipping error push because it is the same as the last one\n",h.payload)}}}(0,t,r,i,o,s)),function(e,n,t,r){let a,i,o;n.debug("Initializing meta API");const s=e=>{i&&r.remove(i),i={user:e},r.add(i)},l=e=>{a&&r.remove(a),a={session:e},r.add(a)};return{setUser:s,resetUser:s,setSession:l,resetSession:l,getSession:()=>r.value.session,setView:e=>{var n;if((null===(n=null==o?void 0:o.view)||void 0===n?void 0:n.name)===(null==e?void 0:e.name))return;const t=o;o={view:e},r.add(o),t&&r.remove(t)},getView:()=>r.value.view}}(0,t,0,i)),function(n,t,r,i,o,s){var l;t.debug("Initializing logs API");let u=null;const c=null!==(l=r.logArgsSerializer)&&void 0!==l?l:G;return{pushLog:(n,{context:l,level:d,skipDedupe:g,spanContext:p,timestampOverwriteMs:b}={})=>{try{const E={type:e.TransportItemType.LOG,payload:{message:c(n),level:null!=d?d:h,context:null!=l?l:{},timestamp:b?v(b):m(),trace:p?{trace_id:p.traceId,span_id:p.spanId}:s.getTraceContext()},meta:i.value},y={message:E.payload.message,level:E.payload.level,context:E.payload.context};if(!g&&r.dedupe&&!a(u)&&f(y,u))return void t.debug("Skipping log push because it is the same as the last one\n",E.payload);u=y,t.debug("Pushing log\n",E),o.execute(E)}catch(e){t.error("Error pushing log\n",e)}}}}(0,t,r,i,o,s)),function(n,t,r,i,o,s){t.debug("Initializing measurements API");let l=null;return{pushMeasurement:(n,{skipDedupe:u,context:c,spanContext:d,timestampOverwriteMs:g}={})=>{try{const p={type:e.TransportItemType.MEASUREMENT,payload:Object.assign(Object.assign({},n),{trace:d?{trace_id:d.traceId,span_id:d.spanId}:s.getTraceContext(),timestamp:g?v(g):m(),context:null!=c?c:{}}),meta:i.value},b={type:p.payload.type,values:p.payload.values,context:p.payload.context};if(!u&&r.dedupe&&!a(l)&&f(b,l))return void t.debug("Skipping measurement push because it is the same as the last one\n",p.payload);l=b,t.debug("Pushing measurement\n",p),o.execute(p)}catch(e){t.error("Error pushing measurement\n",e)}}}}(0,t,r,i,o,s)),function(n,t,r,i,o,s){let l=null;return{pushEvent:(n,u,c,{skipDedupe:d,spanContext:g,timestampOverwriteMs:p}={})=>{try{const b={meta:i.value,payload:{name:n,domain:null!=c?c:r.eventDomain,attributes:u,timestamp:p?v(p):m(),trace:g?{trace_id:g.traceId,span_id:g.spanId}:s.getTraceContext()},type:e.TransportItemType.EVENT},h={name:b.payload.name,attributes:b.payload.attributes,domain:b.payload.domain};if(!d&&r.dedupe&&!a(l)&&f(h,l))return void t.debug("Skipping event push because it is the same as the last one\n",b.payload);l=h,t.debug("Pushing event\n",b),o.execute(b)}catch(e){t.error("Error pushing event",e)}}}}(0,t,r,i,o,s))}const z="1.9.1";const U="_faroInternal";function K(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(T,U,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function H(){return U in T}function W(n,t,r,a,i,o,s){return t.debug("Initializing Faro"),e.faro={api:o,config:r,instrumentations:s,internalLogger:t,metas:a,pause:i.pause,transports:i,unpatchedConsole:n,unpause:i.unpause},K(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 T)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(T,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}(e.faro),e.faro}e.faro={};return e.BaseExtension=F,e.BaseInstrumentation=class extends F{constructor(){super(...arguments),this.api={},this.transports={}}},e.BaseTransport=class extends F{isBatched(){return!1}getIgnoreUrls(){return[]}},e.Conventions={EventNames:{CLICK:"click",NAVIGATION:"navigation",SESSION_START:"session_start",VIEW_CHANGED:"view_changed"}},e.EVENT_CLICK="click",e.EVENT_NAVIGATION="navigation",e.EVENT_ROUTE_CHANGE="route_change",e.EVENT_SESSION_EXTEND="session_extend",e.EVENT_SESSION_RESUME="session_resume",e.EVENT_SESSION_START="session_start",e.EVENT_VIEW_CHANGED="view_changed",e.VERSION=z,e.allLogLevels=E,e.createInternalLogger=_,e.createPromiseBuffer=function(e){const{size:n,concurrency:t}=e,r=[];let a=0;const i=()=>{if(a<t&&r.length){const{producer:e,resolve:n,reject:t}=r.shift();a++,e().then((e=>{a--,i(),n(e)}),(e=>{a--,i(),t(e)}))}};return{add:e=>{if(r.length+a>=n)throw new Error("Task buffer full");return new Promise(((n,t)=>{r.push({producer:e,resolve:n,reject:t}),i()}))}}},e.dateNow=function(){return Date.now()},e.deepEqual=f,e.defaultBatchingConfig={enabled:!0,sendTimeout:250,itemLimit:50},e.defaultExceptionType=M,e.defaultGlobalObjectKey="faro",e.defaultInternalLoggerLevel=A,e.defaultLogArgsSerializer=G,e.defaultLogLevel=h,e.defaultUnpatchedConsole=C,e.genShortID=function(e=10){return Array.from(Array(e)).map((()=>I[Math.floor(59*Math.random())])).join("")},e.getCurrentTimestamp=m,e.getInternalFaroFromGlobalObject=function(){return T[U]},e.getTransportBody=function(n){let t={meta:{}};return void 0!==n[0]&&(t.meta=n[0].meta),n.forEach((n=>{switch(n.type){case e.TransportItemType.LOG:case e.TransportItemType.EVENT:case e.TransportItemType.EXCEPTION:case e.TransportItemType.MEASUREMENT:const r=S[n.type],a=t[r];t=Object.assign(Object.assign({},t),{[r]:void 0===a?[n.payload]:[...a,n.payload]});break;case e.TransportItemType.TRACE:t=Object.assign(Object.assign({},t),{traces:D(t.traces,n.payload.resourceSpans)})}})),t},e.globalObject=T,e.initializeFaro=function(e){const n=k(e),t=B(n,e);if(H()&&!e.isolate)return void t.error('Faro is already registered. Either add instrumentations, transports etc. to the global faro instance or use the "isolate" property');t.debug("Initializing");const r=function(e,n){let t=[],r=[];const a=()=>t.reduce(((e,n)=>Object.assign(e,l(n)?n():n)),{}),i=()=>{if(r.length){const e=a();r.forEach((n=>n(e)))}};return{add:(...e)=>{n.debug("Adding metas\n",e),t.push(...e),i()},remove:(...e)=>{n.debug("Removing metas\n",e),t=t.filter((n=>!e.includes(n))),i()},addListener:e=>{n.debug("Adding metas listener\n",e),r.push(e)},removeListener:e=>{n.debug("Removing metas listener\n",e),r=r.filter((n=>n!==e))},get value(){return a()}}}(0,t),a=x(n,t,e,r),i=V(0,t,e,r,a),o=function(e,n,t,r,a,i){n.debug("Initializing instrumentations");const o=[];return{add:(...s)=>{n.debug("Adding instrumentations"),s.forEach((s=>{n.debug(`Adding "${s.name}" instrumentation`),o.some((e=>e.name===s.name))?n.warn(`Instrumentation ${s.name} is already added`):(s.unpatchedConsole=e,s.internalLogger=n,s.config=t,s.metas=r,s.transports=a,s.api=i,o.push(s),s.initialize())}))},get instrumentations(){return[...o]},remove:(...e)=>{n.debug("Removing instrumentations"),e.forEach((e=>{var t,r;n.debug(`Removing "${e.name}" instrumentation`);const a=o.reduce(((n,t,r)=>null===n&&t.name===e.name?r:null),null);a?(null===(r=(t=o[a]).destroy)||void 0===r||r.call(t),o.splice(a,1)):n.warn(`Instrumentation "${e.name}" is not added`)}))}}}(n,t,e,r,a,i),s=W(n,t,e,r,a,i,o);return function(e){var n,t;const r={sdk:{version:z},app:{bundleId:e.config.app.name&&(a=e.config.app.name,null==T?void 0:T[`__faroBundleId_${a}`])}};var a;const i=null===(n=e.config.sessionTracking)||void 0===n?void 0:n.session;i&&e.api.setSession(i),e.config.app&&(r.app=Object.assign(Object.assign({},e.config.app),r.app)),e.config.user&&(r.user=e.config.user),e.config.view&&(r.view=e.config.view),e.metas.add(r,...null!==(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=U,e.isArray=u,e.isBoolean=e=>n(e,"boolean"),e.isDomError=e=>t(e,"DOMError"),e.isDomException=e=>t(e,"DOMException"),e.isElement=e=>g&&r(e,Element),e.isElementDefined=g,e.isError=e=>d&&r(e,Error),e.isErrorDefined=d,e.isErrorEvent=e=>t(e,"ErrorEvent"),e.isEvent=e=>c&&r(e,Event),e.isEventDefined=c,e.isFunction=l,e.isInstanceOf=r,e.isInt=e=>o(e)&&Number.isInteger(e),e.isInternalFaroOnGlobalObject=H,e.isMap=e=>p&&r(e,Map),e.isMapDefined=p,e.isNull=a,e.isNumber=o,e.isObject=s,e.isPrimitive=e=>!s(e)&&!l(e),e.isRegExp=e=>t(e,"RegExp"),e.isString=i,e.isSymbol=e=>n(e,"symbol"),e.isSyntheticEvent=e=>s(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e,e.isThenable=e=>l(null==e?void 0:e.then),e.isToString=t,e.isTypeof=n,e.isUndefined=e=>n(e,"undefined"),e.noop=y,e.setInternalFaroOnGlobalObject=K,e.transportItemTypeToBodyKey=S,e}({});
|
|
1
|
+
var GrafanaFaroCore=function(e){"use strict";function n(e,n){return typeof e===n}function t(e,n){return Object.prototype.toString.call(e)===`[object ${n}]`}function r(e,n){try{return e instanceof n}catch(e){return!1}}const a=e=>n(e,"null"),i=e=>n(e,"string"),o=e=>n(e,"number")&&!isNaN(e)||n(e,"bigint"),s=e=>!a(e)&&n(e,"object"),u=e=>n(e,"function"),l=e=>t(e,"Array"),c="undefined"!=typeof Event,d="undefined"!=typeof Error,g=e=>d&&r(e,Error),p="undefined"!=typeof Element,f="undefined"!=typeof Map;function m(e,t){if(e===t)return!0;if(n(e,"number")&&isNaN(e))return n(t,"number")&&isNaN(t);const r=l(e),a=l(t);if(r!==a)return!1;if(r&&a){const n=e.length;if(n!==t.length)return!1;for(let r=n;0!=r--;)if(!m(e[r],t[r]))return!1;return!0}const i=s(e),o=s(t);if(i!==o)return!1;if(e&&t&&i&&o){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;for(let r of n)if(!m(e[r],t[r]))return!1;return!0}return!1}function v(){return(new Date).toISOString()}function b(e){return new Date(e).toISOString()}var h;e.LogLevel=void 0,(h=e.LogLevel||(e.LogLevel={})).TRACE="trace",h.DEBUG="debug",h.INFO="info",h.LOG="log",h.WARN="warn",h.ERROR="error";const E=e.LogLevel.LOG,y=[e.LogLevel.TRACE,e.LogLevel.DEBUG,e.LogLevel.INFO,e.LogLevel.LOG,e.LogLevel.WARN,e.LogLevel.ERROR];function I(){}const T="abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789";const O="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:void 0;class L{constructor(e,n){var t,r;this.signalBuffer=[],this.itemLimit=null!==(t=null==n?void 0:n.itemLimit)&&void 0!==t?t:50,this.sendTimeout=null!==(r=null==n?void 0:n.sendTimeout)&&void 0!==r?r:250,this.paused=(null==n?void 0:n.paused)||!1,this.sendFn=e,this.flushInterval=-1,this.paused||this.start(),document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&this.flush()}))}addItem(e){this.paused||(this.signalBuffer.push(e),this.signalBuffer.length>=this.itemLimit&&this.flush())}start(){this.paused=!1,this.sendTimeout>0&&(this.flushInterval=window.setInterval((()=>this.flush()),this.sendTimeout))}pause(){this.paused=!0,clearInterval(this.flushInterval)}groupItems(e){const n=new Map;return e.forEach((e=>{const t=JSON.stringify(e.meta);let r=n.get(t);r=void 0===r?[e]:[...r,e],n.set(t,r)})),Array.from(n.values())}flush(){if(this.paused||0===this.signalBuffer.length)return;this.groupItems(this.signalBuffer).forEach(this.sendFn),this.signalBuffer=[]}}var S;e.TransportItemType=void 0,(S=e.TransportItemType||(e.TransportItemType={})).EXCEPTION="exception",S.LOG="log",S.MEASUREMENT="measurement",S.TRACE="trace",S.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 x(n){return t=>{if(t.type===e.TransportItemType.EXCEPTION&&t.payload){const e=t.payload,r=`${e.type}: ${e.value}`;if(function(e,n){return e.some((e=>i(e)?n.includes(e):!!n.match(e)))}(n,r))return null}return t}}function R(e,n,t,r){var a;n.debug("Initializing transports");const i=[];let o=t.paused,s=[];const u=e=>{let n=e;for(const e of s){const t=n.map(e).filter(Boolean);if(0===t.length)return[];n=t}return n},l=e=>{const t=u(e);if(0!==t.length)for(const e of i)n.debug(`Transporting item using ${e.name}\n`,t),e.isBatched()&&e.send(t)};let c;(null===(a=t.batching)||void 0===a?void 0:a.enabled)&&(c=new L(l,{sendTimeout:t.batching.sendTimeout,itemLimit:t.batching.itemLimit,paused:o}));return{add:(...a)=>{n.debug("Adding transports"),a.forEach((a=>{n.debug(`Adding "${a.name}" transport`);i.some((e=>e===a))?n.warn(`Transport ${a.name} is already added`):(a.unpatchedConsole=e,a.internalLogger=n,a.config=t,a.metas=r,i.push(a))}))},addBeforeSendHooks:(...e)=>{n.debug("Adding beforeSendHooks\n",s),e.forEach((e=>{e&&s.push(e)}))},addIgnoreErrorsPatterns:(...e)=>{n.debug("Adding ignoreErrorsPatterns\n",e),e.forEach((e=>{e&&s.push(x(e))}))},getBeforeSendHooks:()=>[...s],execute:e=>{var r;o||((null===(r=t.batching)||void 0===r?void 0:r.enabled)&&(null==c||c.addItem(e)),(e=>{var r,a;if((null===(r=t.batching)||void 0===r?void 0:r.enabled)&&i.every((e=>e.isBatched())))return;const[o]=u([e]);if(void 0!==o)for(const e of i)n.debug(`Transporting item using ${e.name}\n`,o),e.isBatched()?(null===(a=t.batching)||void 0===a?void 0:a.enabled)||e.send([o]):e.send(o)})(e))},isPaused:()=>o,pause:()=>{n.debug("Pausing transports"),null==c||c.pause(),o=!0},remove:(...e)=>{n.debug("Removing transports"),e.forEach((e=>{n.debug(`Removing "${e.name}" transport`);const t=i.indexOf(e);-1!==t?i.splice(t,1):n.warn(`Transport "${e.name}" is not added`)}))},removeBeforeSendHooks:(...e)=>{s.filter((n=>!e.includes(n)))},get transports(){return[...i]},unpause:()=>{n.debug("Unpausing transports"),null==c||c.start(),o=!1}}}var j;e.InternalLoggerLevel=void 0,(j=e.InternalLoggerLevel||(e.InternalLoggerLevel={}))[j.OFF=0]="OFF",j[j.ERROR=1]="ERROR",j[j.WARN=2]="WARN",j[j.INFO=3]="INFO",j[j.VERBOSE=4]="VERBOSE";const A={debug:I,error:I,info:I,prefix:"Faro",warn:I},w=e.InternalLoggerLevel.ERROR,C=Object.assign({},console);let k=C;function _(e){var n;return k=null!==(n=e.unpatchedConsole)&&void 0!==n?n:k,k}function P(n=C,t=w){const r=A;return t>e.InternalLoggerLevel.OFF&&(r.error=t>=e.InternalLoggerLevel.ERROR?function(...e){n.error(`${r.prefix}\n`,...e)}:I,r.warn=t>=e.InternalLoggerLevel.WARN?function(...e){n.warn(`${r.prefix}\n`,...e)}:I,r.info=t>=e.InternalLoggerLevel.INFO?function(...e){n.info(`${r.prefix}\n`,...e)}:I,r.debug=t>=e.InternalLoggerLevel.VERBOSE?function(...e){n.debug(`${r.prefix}\n`,...e)}:I),r}let B=A;function F(e,n){return B=P(e,n.internalLoggerLevel),B}class D{constructor(){this.unpatchedConsole=C,this.internalLogger=A,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 M(e,n){var t,r;if(void 0===n)return e;if(void 0===e)return{resourceSpans:n};const a=null===(t=e.resourceSpans)||void 0===t?void 0:t[0];if(void 0===a)return e;const i=(null==a?void 0:a.scopeSpans)||[],o=(null===(r=null==n?void 0:n[0])||void 0===r?void 0:r.scopeSpans)||[];return Object.assign(Object.assign({},e),{resourceSpans:[Object.assign(Object.assign({},a),{scopeSpans:[...i,...o]})]})}const $="Error";let G;function V(e){let n=e.cause;return g(n)?n=e.cause.toString():null!==n&&(s(e.cause)||l(e.cause))?n=JSON.stringify(e.cause):null!=n&&(n=e.cause.toString()),null==n?{}:{cause:n}}const z=e=>e.map((e=>{try{return String(e)}catch(e){return""}})).join(" ");function U(n,t,r,i,o){t.debug("Initializing API");const s=function(n,t,r,a,i){let o;return t.debug("Initializing traces API"),{getOTEL:()=>o,getTraceContext:()=>{const e=null==o?void 0:o.trace.getSpanContext(o.context.active());return e?{trace_id:e.traceId,span_id:e.spanId}:void 0},initOTEL:(e,n)=>{t.debug("Initializing OpenTelemetry"),o={trace:e,context:n}},isOTELInitialized:()=>!!o,pushTraces:n=>{try{const r={type:e.TransportItemType.TRACE,payload:n,meta:a.value};t.debug("Pushing trace\n",r),i.execute(r)}catch(e){t.error("Error pushing trace\n",e)}}}}(0,t,0,i,o);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},s),function(n,t,r,i,o,s){var u;t.debug("Initializing exceptions API");let l=null;G=null!==(u=r.parseStacktrace)&&void 0!==u?u:G;const c=e=>{t.debug("Changing stacktrace parser"),G=null!=e?e:G};return c(r.parseStacktrace),{changeStacktraceParser:c,getStacktraceParser:()=>G,pushError:(n,{skipDedupe:u,stackFrames:c,type:d,context:g,spanContext:p,timestampOverwriteMs:f}={})=>{d=d||n.name||$;const h={meta:i.value,payload:{type:d,value:n.message,timestamp:f?b(f):v(),trace:p?{trace_id:p.traceId,span_id:p.spanId}:s.getTraceContext(),context:Object.assign(Object.assign({},V(n)),null!=g?g:{})},type:e.TransportItemType.EXCEPTION};(null==(c=null!=c?c:n.stack?null==G?void 0:G(n).frames:void 0)?void 0:c.length)&&(h.payload.stacktrace={frames:c});const E={type:h.payload.type,value:h.payload.value,stackTrace:h.payload.stacktrace,context:h.payload.context};u||!r.dedupe||a(l)||!m(E,l)?(l=E,t.debug("Pushing exception\n",h),o.execute(h)):t.debug("Skipping error push because it is the same as the last one\n",h.payload)}}}(0,t,r,i,o,s)),function(e,n,t,r){let a,i,o;n.debug("Initializing meta API");const s=e=>{i&&r.remove(i),i={user:e},r.add(i)},u=e=>{a&&r.remove(a),a={session:e},r.add(a)};return{setUser:s,resetUser:s,setSession:u,resetSession:u,getSession:()=>r.value.session,setView:e=>{var n;if((null===(n=null==o?void 0:o.view)||void 0===n?void 0:n.name)===(null==e?void 0:e.name))return;const t=o;o={view:e},r.add(o),t&&r.remove(t)},getView:()=>r.value.view}}(0,t,0,i)),function(n,t,r,i,o,s){var u;t.debug("Initializing logs API");let l=null;const c=null!==(u=r.logArgsSerializer)&&void 0!==u?u:z;return{pushLog:(n,{context:u,level:d,skipDedupe:g,spanContext:p,timestampOverwriteMs:f}={})=>{try{const h={type:e.TransportItemType.LOG,payload:{message:c(n),level:null!=d?d:E,context:null!=u?u:{},timestamp:f?b(f):v(),trace:p?{trace_id:p.traceId,span_id:p.spanId}:s.getTraceContext()},meta:i.value},y={message:h.payload.message,level:h.payload.level,context:h.payload.context};if(!g&&r.dedupe&&!a(l)&&m(y,l))return void t.debug("Skipping log push because it is the same as the last one\n",h.payload);l=y,t.debug("Pushing log\n",h),o.execute(h)}catch(e){t.error("Error pushing log\n",e)}}}}(0,t,r,i,o,s)),function(n,t,r,i,o,s){t.debug("Initializing measurements API");let u=null;return{pushMeasurement:(n,{skipDedupe:l,context:c,spanContext:d,timestampOverwriteMs:g}={})=>{try{const p={type:e.TransportItemType.MEASUREMENT,payload:Object.assign(Object.assign({},n),{trace:d?{trace_id:d.traceId,span_id:d.spanId}:s.getTraceContext(),timestamp:g?b(g):v(),context:null!=c?c:{}}),meta:i.value},f={type:p.payload.type,values:p.payload.values,context:p.payload.context};if(!l&&r.dedupe&&!a(u)&&m(f,u))return void t.debug("Skipping measurement push because it is the same as the last one\n",p.payload);u=f,t.debug("Pushing measurement\n",p),o.execute(p)}catch(e){t.error("Error pushing measurement\n",e)}}}}(0,t,r,i,o,s)),function(n,t,r,i,o,s){let u=null;return{pushEvent:(n,l,c,{skipDedupe:d,spanContext:g,timestampOverwriteMs:p}={})=>{try{const f={meta:i.value,payload:{name:n,domain:null!=c?c:r.eventDomain,attributes:l,timestamp:p?b(p):v(),trace:g?{trace_id:g.traceId,span_id:g.spanId}:s.getTraceContext()},type:e.TransportItemType.EVENT},h={name:f.payload.name,attributes:f.payload.attributes,domain:f.payload.domain};if(!d&&r.dedupe&&!a(u)&&m(h,u))return void t.debug("Skipping event push because it is the same as the last one\n",f.payload);u=h,t.debug("Pushing event\n",f),o.execute(f)}catch(e){t.error("Error pushing event",e)}}}}(0,t,r,i,o,s))}const K="1.10.1";const H="_faroInternal";function W(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(O,H,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function X(){return H in O}function J(n,t,r,a,i,o,s){return t.debug("Initializing Faro"),e.faro={api:o,config:r,instrumentations:s,internalLogger:t,metas:a,pause:i.pause,transports:i,unpatchedConsole:n,unpause:i.unpause},W(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 O)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(O,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}(e.faro),e.faro}e.faro={};return e.BaseExtension=D,e.BaseInstrumentation=class extends D{constructor(){super(...arguments),this.api={},this.transports={}}},e.BaseTransport=class extends D{isBatched(){return!1}getIgnoreUrls(){return[]}},e.Conventions={EventNames:{CLICK:"click",NAVIGATION:"navigation",SESSION_START:"session_start",VIEW_CHANGED:"view_changed"}},e.EVENT_CLICK="click",e.EVENT_NAVIGATION="navigation",e.EVENT_ROUTE_CHANGE="route_change",e.EVENT_SESSION_EXTEND="session_extend",e.EVENT_SESSION_RESUME="session_resume",e.EVENT_SESSION_START="session_start",e.EVENT_VIEW_CHANGED="view_changed",e.VERSION=K,e.allLogLevels=y,e.createInternalLogger=P,e.createPromiseBuffer=function(e){const{size:n,concurrency:t}=e,r=[];let a=0;const i=()=>{if(a<t&&r.length){const{producer:e,resolve:n,reject:t}=r.shift();a++,e().then((e=>{a--,i(),n(e)}),(e=>{a--,i(),t(e)}))}};return{add:e=>{if(r.length+a>=n)throw new Error("Task buffer full");return new Promise(((n,t)=>{r.push({producer:e,resolve:n,reject:t}),i()}))}}},e.dateNow=function(){return Date.now()},e.deepEqual=m,e.defaultBatchingConfig={enabled:!0,sendTimeout:250,itemLimit:50},e.defaultExceptionType=$,e.defaultGlobalObjectKey="faro",e.defaultInternalLoggerLevel=w,e.defaultLogArgsSerializer=z,e.defaultLogLevel=E,e.defaultUnpatchedConsole=C,e.genShortID=function(e=10){return Array.from(Array(e)).map((()=>T[Math.floor(59*Math.random())])).join("")},e.getCurrentTimestamp=v,e.getInternalFaroFromGlobalObject=function(){return O[H]},e.getTransportBody=function(n){let t={meta:{}};return void 0!==n[0]&&(t.meta=n[0].meta),n.forEach((n=>{switch(n.type){case e.TransportItemType.LOG:case e.TransportItemType.EVENT:case e.TransportItemType.EXCEPTION:case e.TransportItemType.MEASUREMENT:const r=N[n.type],a=t[r];t=Object.assign(Object.assign({},t),{[r]:void 0===a?[n.payload]:[...a,n.payload]});break;case e.TransportItemType.TRACE:t=Object.assign(Object.assign({},t),{traces:M(t.traces,n.payload.resourceSpans)})}})),t},e.globalObject=O,e.initializeFaro=function(e){const n=_(e),t=F(n,e);if(X()&&!e.isolate)return void t.error('Faro is already registered. Either add instrumentations, transports etc. to the global faro instance or use the "isolate" property');t.debug("Initializing");const r=function(e,n){let t=[],r=[];const a=()=>t.reduce(((e,n)=>Object.assign(e,u(n)?n():n)),{}),i=()=>{if(r.length){const e=a();r.forEach((n=>n(e)))}};return{add:(...e)=>{n.debug("Adding metas\n",e),t.push(...e),i()},remove:(...e)=>{n.debug("Removing metas\n",e),t=t.filter((n=>!e.includes(n))),i()},addListener:e=>{n.debug("Adding metas listener\n",e),r.push(e)},removeListener:e=>{n.debug("Removing metas listener\n",e),r=r.filter((n=>n!==e))},get value(){return a()}}}(0,t),a=R(n,t,e,r),i=U(0,t,e,r,a),o=function(e,n,t,r,a,i){n.debug("Initializing instrumentations");const o=[];return{add:(...s)=>{n.debug("Adding instrumentations"),s.forEach((s=>{n.debug(`Adding "${s.name}" instrumentation`),o.some((e=>e.name===s.name))?n.warn(`Instrumentation ${s.name} is already added`):(s.unpatchedConsole=e,s.internalLogger=n,s.config=t,s.metas=r,s.transports=a,s.api=i,o.push(s),s.initialize())}))},get instrumentations(){return[...o]},remove:(...e)=>{n.debug("Removing instrumentations"),e.forEach((e=>{var t,r;n.debug(`Removing "${e.name}" instrumentation`);const a=o.reduce(((n,t,r)=>null===n&&t.name===e.name?r:null),null);a?(null===(r=(t=o[a]).destroy)||void 0===r||r.call(t),o.splice(a,1)):n.warn(`Instrumentation "${e.name}" is not added`)}))}}}(n,t,e,r,a,i),s=J(n,t,e,r,a,i,o);return function(e){var n,t;const r={sdk:{version:K},app:{bundleId:e.config.app.name&&(a=e.config.app.name,null==O?void 0:O[`__faroBundleId_${a}`])}};var a;const i=null===(n=e.config.sessionTracking)||void 0===n?void 0:n.session;i&&e.api.setSession(i),e.config.app&&(r.app=Object.assign(Object.assign({},e.config.app),r.app)),e.config.user&&(r.user=e.config.user),e.config.view&&(r.view=e.config.view),e.metas.add(r,...null!==(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=H,e.isArray=l,e.isBoolean=e=>n(e,"boolean"),e.isDomError=e=>t(e,"DOMError"),e.isDomException=e=>t(e,"DOMException"),e.isElement=e=>p&&r(e,Element),e.isElementDefined=p,e.isError=g,e.isErrorDefined=d,e.isErrorEvent=e=>t(e,"ErrorEvent"),e.isEvent=e=>c&&r(e,Event),e.isEventDefined=c,e.isFunction=u,e.isInstanceOf=r,e.isInt=e=>o(e)&&Number.isInteger(e),e.isInternalFaroOnGlobalObject=X,e.isMap=e=>f&&r(e,Map),e.isMapDefined=f,e.isNull=a,e.isNumber=o,e.isObject=s,e.isPrimitive=e=>!s(e)&&!u(e),e.isRegExp=e=>t(e,"RegExp"),e.isString=i,e.isSymbol=e=>n(e,"symbol"),e.isSyntheticEvent=e=>s(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e,e.isThenable=e=>u(null==e?void 0:e.then),e.isToString=t,e.isTypeof=n,e.isUndefined=e=>n(e,"undefined"),e.noop=I,e.setInternalFaroOnGlobalObject=W,e.transportItemTypeToBodyKey=N,e.unknownString="unknown",e}({});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { defaultExceptionType } from './const';
|
|
2
2
|
export { initializeExceptionsAPI } from './initialize';
|
|
3
|
-
export type { ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, PushErrorOptions, Stacktrace, StacktraceParser, } from './types';
|
|
3
|
+
export type { ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, PushErrorOptions, Stacktrace, StacktraceParser, ErrorWithIndexProperties, } from './types';
|
|
@@ -32,8 +32,11 @@ export interface PushErrorOptions {
|
|
|
32
32
|
spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;
|
|
33
33
|
timestampOverwriteMs?: number;
|
|
34
34
|
}
|
|
35
|
+
export type ErrorWithIndexProperties = Error & {
|
|
36
|
+
cause?: any;
|
|
37
|
+
};
|
|
35
38
|
export interface ExceptionsAPI {
|
|
36
39
|
changeStacktraceParser: (stacktraceParser: StacktraceParser) => void;
|
|
37
40
|
getStacktraceParser: () => StacktraceParser | undefined;
|
|
38
|
-
pushError: (value:
|
|
41
|
+
pushError: (value: ErrorWithIndexProperties, options?: PushErrorOptions) => void;
|
|
39
42
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const unknownString = "unknown";
|
|
@@ -22,3 +22,4 @@ export type { UnpatchedConsole } from './unpatchedConsole';
|
|
|
22
22
|
export { allLogLevels, createPromiseBuffer, deepEqual, defaultLogLevel, genShortID, getCurrentTimestamp, isArray, isBoolean, isDomError, isDomException, isElement, isElementDefined, isError, isErrorDefined, isErrorEvent, isEvent, isEventDefined, isFunction, isInstanceOf, isInt, isMap, isMapDefined, isNull, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isSyntheticEvent, isThenable, isToString, isTypeof, isUndefined, LogLevel, noop, dateNow, } from './utils';
|
|
23
23
|
export type { BaseObject, BaseObjectKey, BaseObjectPrimitiveValue, BaseObjectValue, BufferItem, PromiseBuffer, PromiseBufferOptions, PromiseProducer, } from './utils';
|
|
24
24
|
export { VERSION } from './version';
|
|
25
|
+
export { unknownString } from './consts';
|
|
@@ -4,7 +4,7 @@ import type { Transport, TransportItem } from '../transports';
|
|
|
4
4
|
export declare class MockTransport extends BaseTransport implements Transport {
|
|
5
5
|
private ignoreURLs;
|
|
6
6
|
readonly name = "@grafana/transport-mock";
|
|
7
|
-
readonly version = "1.
|
|
7
|
+
readonly version = "1.10.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
|
+
export declare const VERSION = "1.10.1";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/api/exceptions/index.ts"],"names":[],"mappings":";;;AAAA,iCAA+C;AAAtC,6GAAA,oBAAoB,OAAA;AAE7B,2CAAuD;AAA9C,qHAAA,uBAAuB,OAAA","sourcesContent":["export { defaultExceptionType } from './const';\n\nexport { initializeExceptionsAPI } from './initialize';\n\nexport type {\n ExceptionEvent,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n PushErrorOptions,\n Stacktrace,\n StacktraceParser,\n} from './types';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/api/exceptions/index.ts"],"names":[],"mappings":";;;AAAA,iCAA+C;AAAtC,6GAAA,oBAAoB,OAAA;AAE7B,2CAAuD;AAA9C,qHAAA,uBAAuB,OAAA","sourcesContent":["export { defaultExceptionType } from './const';\n\nexport { initializeExceptionsAPI } from './initialize';\n\nexport type {\n ExceptionEvent,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n PushErrorOptions,\n Stacktrace,\n StacktraceParser,\n ErrorWithIndexProperties,\n} from './types';\n"]}
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.initializeExceptionsAPI = void 0;
|
|
4
15
|
var transports_1 = require("../../transports");
|
|
@@ -31,7 +42,7 @@ function initializeExceptionsAPI(_unpatchedConsole, internalLogger, config, meta
|
|
|
31
42
|
span_id: spanContext.spanId,
|
|
32
43
|
}
|
|
33
44
|
: tracesApi.getTraceContext(),
|
|
34
|
-
context: context !== null && context !== void 0 ? context : {},
|
|
45
|
+
context: __assign(__assign({}, parseCause(error)), (context !== null && context !== void 0 ? context : {})),
|
|
35
46
|
},
|
|
36
47
|
type: transports_1.TransportItemType.EXCEPTION,
|
|
37
48
|
};
|
|
@@ -63,4 +74,19 @@ function initializeExceptionsAPI(_unpatchedConsole, internalLogger, config, meta
|
|
|
63
74
|
};
|
|
64
75
|
}
|
|
65
76
|
exports.initializeExceptionsAPI = initializeExceptionsAPI;
|
|
77
|
+
function parseCause(error) {
|
|
78
|
+
var cause = error.cause;
|
|
79
|
+
if ((0, utils_1.isError)(cause)) {
|
|
80
|
+
cause = error.cause.toString();
|
|
81
|
+
// typeof operator on null returns "object". This is a well-known quirk in JavaScript and is considered a bug that cannot be fixed due to backward compatibility issues.
|
|
82
|
+
// MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#typeof_null
|
|
83
|
+
}
|
|
84
|
+
else if (cause !== null && ((0, utils_1.isObject)(error.cause) || (0, utils_1.isArray)(error.cause))) {
|
|
85
|
+
cause = JSON.stringify(error.cause);
|
|
86
|
+
}
|
|
87
|
+
else if (cause != null) {
|
|
88
|
+
cause = error.cause.toString();
|
|
89
|
+
}
|
|
90
|
+
return cause == null ? {} : { cause: cause };
|
|
91
|
+
}
|
|
66
92
|
//# sourceMappingURL=initialize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/exceptions/initialize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/exceptions/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAGA,+CAAqD;AAGrD,qCAAiG;AACjG,yCAAwD;AAGxD,iCAA+C;AAG/C,IAAI,gBAA8C,CAAC;AAEnD,SAAgB,uBAAuB,CACrC,iBAAmC,EACnC,cAA8B,EAC9B,MAAc,EACd,KAAY,EACZ,UAAsB,EACtB,SAAoB;;IAEpB,cAAc,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAEpD,IAAI,WAAW,GAA6E,IAAI,CAAC;IAEjG,gBAAgB,GAAG,MAAA,MAAM,CAAC,eAAe,mCAAI,gBAAgB,CAAC;IAE9D,IAAM,sBAAsB,GAA4C,UAAC,mBAAmB;QAC1F,cAAc,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAEnD,gBAAgB,GAAG,mBAAmB,aAAnB,mBAAmB,cAAnB,mBAAmB,GAAI,gBAAgB,CAAC;IAC7D,CAAC,CAAC;IAEF,IAAM,mBAAmB,GAAyC,cAAM,OAA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;KACrC;SAAM,IAAI,KAAK,IAAI,IAAI,EAAE;QACxB,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;KAChC;IAED,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,OAAA,EAAE,CAAC;AACxC,CAAC","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, isArray, isError, isNull, isObject } from '../../utils';\nimport { timestampToIsoString } from '../../utils/date';\nimport type { TracesAPI } from '../traces';\n\nimport { defaultExceptionType } from './const';\nimport type { ErrorWithIndexProperties, ExceptionEvent, ExceptionsAPI, StacktraceParser } from './types';\n\nlet stacktraceParser: StacktraceParser | undefined;\n\nexport function initializeExceptionsAPI(\n _unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas,\n transports: Transports,\n tracesApi: TracesAPI\n): ExceptionsAPI {\n internalLogger.debug('Initializing exceptions API');\n\n let lastPayload: Pick<ExceptionEvent, 'type' | 'value' | 'stacktrace' | 'context'> | null = null;\n\n stacktraceParser = config.parseStacktrace ?? stacktraceParser;\n\n const changeStacktraceParser: ExceptionsAPI['changeStacktraceParser'] = (newStacktraceParser) => {\n internalLogger.debug('Changing stacktrace parser');\n\n stacktraceParser = newStacktraceParser ?? stacktraceParser;\n };\n\n const getStacktraceParser: ExceptionsAPI['getStacktraceParser'] = () => stacktraceParser;\n\n const pushError: ExceptionsAPI['pushError'] = (\n error,\n { skipDedupe, stackFrames, type, context, spanContext, timestampOverwriteMs } = {}\n ) => {\n type = type || error.name || defaultExceptionType;\n\n const item: TransportItem<ExceptionEvent> = {\n meta: metas.value,\n payload: {\n type,\n value: error.message,\n timestamp: timestampOverwriteMs ? timestampToIsoString(timestampOverwriteMs) : getCurrentTimestamp(),\n trace: spanContext\n ? {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n }\n : tracesApi.getTraceContext(),\n context: {\n ...parseCause(error),\n ...(context ?? {}),\n },\n },\n type: TransportItemType.EXCEPTION,\n };\n\n stackFrames = stackFrames ?? (error.stack ? stacktraceParser?.(error).frames : undefined);\n\n if (stackFrames?.length) {\n item.payload.stacktrace = {\n frames: stackFrames,\n };\n }\n\n const testingPayload = {\n type: item.payload.type,\n value: item.payload.value,\n stackTrace: item.payload.stacktrace,\n context: item.payload.context,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping error push because it is the same as the last one\\n', item.payload);\n\n return;\n }\n\n lastPayload = testingPayload;\n\n internalLogger.debug('Pushing exception\\n', item);\n\n transports.execute(item);\n };\n\n changeStacktraceParser(config.parseStacktrace);\n\n return {\n changeStacktraceParser,\n getStacktraceParser,\n pushError,\n };\n}\nfunction parseCause(error: ErrorWithIndexProperties): {} | { cause: string } {\n let cause = error.cause;\n\n if (isError(cause)) {\n cause = error.cause.toString();\n // typeof operator on null returns \"object\". This is a well-known quirk in JavaScript and is considered a bug that cannot be fixed due to backward compatibility issues.\n // MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#typeof_null\n } else if (cause !== null && (isObject(error.cause) || isArray(error.cause))) {\n cause = JSON.stringify(error.cause);\n } else if (cause != null) {\n cause = error.cause.toString();\n }\n\n return cause == null ? {} : { cause };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/exceptions/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { TraceContext } from '../traces';\n\nexport type StacktraceParser = (err: ExtendedError) => Stacktrace;\n\nexport interface ExceptionStackFrame {\n filename: string;\n function: string;\n\n colno?: number;\n lineno?: number;\n\n bundleid?: string;\n}\n\nexport interface ExtendedError extends Error {\n columnNumber?: number;\n stacktrace?: Error['stack'];\n}\n\nexport interface Stacktrace {\n frames: ExceptionStackFrame[];\n}\n\nexport type ExceptionContext = Record<string, string>;\n\nexport interface ExceptionEvent {\n timestamp: string;\n type: string;\n value: string;\n\n stacktrace?: Stacktrace;\n trace?: TraceContext;\n context?: ExceptionContext;\n}\n\nexport interface PushErrorOptions {\n skipDedupe?: boolean;\n stackFrames?: ExceptionStackFrame[];\n type?: string;\n context?: ExceptionContext;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n timestampOverwriteMs?: number;\n}\n\nexport interface ExceptionsAPI {\n changeStacktraceParser: (stacktraceParser: StacktraceParser) => void;\n getStacktraceParser: () => StacktraceParser | undefined;\n pushError: (value:
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/exceptions/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { TraceContext } from '../traces';\n\nexport type StacktraceParser = (err: ExtendedError) => Stacktrace;\n\nexport interface ExceptionStackFrame {\n filename: string;\n function: string;\n\n colno?: number;\n lineno?: number;\n\n bundleid?: string;\n}\n\nexport interface ExtendedError extends Error {\n columnNumber?: number;\n stacktrace?: Error['stack'];\n}\n\nexport interface Stacktrace {\n frames: ExceptionStackFrame[];\n}\n\nexport type ExceptionContext = Record<string, string>;\n\nexport interface ExceptionEvent {\n timestamp: string;\n type: string;\n value: string;\n\n stacktrace?: Stacktrace;\n trace?: TraceContext;\n context?: ExceptionContext;\n}\n\nexport interface PushErrorOptions {\n skipDedupe?: boolean;\n stackFrames?: ExceptionStackFrame[];\n type?: string;\n context?: ExceptionContext;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n timestampOverwriteMs?: number;\n}\n\n// ts type is missing the cause property\nexport type ErrorWithIndexProperties = Error & {\n cause?: any;\n};\n\nexport interface ExceptionsAPI {\n changeStacktraceParser: (stacktraceParser: StacktraceParser) => void;\n getStacktraceParser: () => StacktraceParser | undefined;\n pushError: (value: ErrorWithIndexProperties, options?: PushErrorOptions) => void;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.js","sourceRoot":"","sources":["../../src/consts.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG,SAAS,CAAC","sourcesContent":["export const unknownString = 'unknown';\n"]}
|
package/dist/cjs/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.isSymbol = exports.isString = exports.isRegExp = exports.isPrimitive = exports.isObject = exports.isNumber = exports.isNull = exports.isMapDefined = exports.isMap = exports.isInt = exports.isInstanceOf = exports.isFunction = exports.isEventDefined = exports.isEvent = exports.isErrorEvent = exports.isErrorDefined = exports.isError = exports.isElementDefined = exports.isElement = exports.isDomException = exports.isDomError = exports.isBoolean = exports.isArray = exports.getCurrentTimestamp = exports.genShortID = exports.defaultLogLevel = exports.deepEqual = exports.createPromiseBuffer = exports.allLogLevels = exports.defaultUnpatchedConsole = exports.transportItemTypeToBodyKey = exports.TransportItemType = exports.getTransportBody = exports.BaseTransport = exports.setInternalFaroOnGlobalObject = exports.isInternalFaroOnGlobalObject = exports.internalGlobalObjectKey = exports.getInternalFaroFromGlobalObject = exports.faro = exports.InternalLoggerLevel = exports.defaultInternalLoggerLevel = exports.createInternalLogger = exports.BaseInstrumentation = exports.defaultGlobalObjectKey = exports.defaultBatchingConfig = exports.initializeFaro = exports.globalObject = exports.BaseExtension = exports.defaultLogArgsSerializer = exports.defaultExceptionType = void 0;
|
|
18
|
-
exports.VERSION = exports.dateNow = exports.noop = exports.LogLevel = exports.isUndefined = exports.isTypeof = exports.isToString = exports.isThenable = exports.isSyntheticEvent = void 0;
|
|
18
|
+
exports.unknownString = exports.VERSION = exports.dateNow = exports.noop = exports.LogLevel = exports.isUndefined = exports.isTypeof = exports.isToString = exports.isThenable = exports.isSyntheticEvent = void 0;
|
|
19
19
|
var api_1 = require("./api");
|
|
20
20
|
Object.defineProperty(exports, "defaultExceptionType", { enumerable: true, get: function () { return api_1.defaultExceptionType; } });
|
|
21
21
|
Object.defineProperty(exports, "defaultLogArgsSerializer", { enumerable: true, get: function () { return api_1.defaultLogArgsSerializer; } });
|
|
@@ -88,4 +88,6 @@ Object.defineProperty(exports, "noop", { enumerable: true, get: function () { re
|
|
|
88
88
|
Object.defineProperty(exports, "dateNow", { enumerable: true, get: function () { return utils_1.dateNow; } });
|
|
89
89
|
var version_1 = require("./version");
|
|
90
90
|
Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return version_1.VERSION; } });
|
|
91
|
+
var consts_1 = require("./consts");
|
|
92
|
+
Object.defineProperty(exports, "unknownString", { enumerable: true, get: function () { return consts_1.unknownString; } });
|
|
91
93
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,6BAAuE;AAA9D,2GAAA,oBAAoB,OAAA;AAAE,+GAAA,wBAAwB,OAAA;AA8BvD,2CAA6C;AAApC,2GAAA,aAAa,OAAA;AAGtB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AAGrB,2CAA8C;AAArC,4GAAA,cAAc,OAAA;AAEvB,mCAAyE;AAAhE,+GAAA,qBAAqB,OAAA;AAAE,gHAAA,sBAAsB,OAAA;AAGtD,uDAAyD;AAAhD,uHAAA,mBAAmB,OAAA;AAG5B,mDAAyG;AAAhG,sHAAA,oBAAoB,OAAA;AAAE,4HAAA,0BAA0B,OAAA;AAAE,qHAAA,mBAAmB,OAAA;AAmB9E,6BAMe;AALb,2FAAA,IAAI,OAAA;AAC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AaT,qCAAoC;AAA3B,kGAAA,OAAO,OAAA","sourcesContent":["export { defaultExceptionType, defaultLogArgsSerializer } from './api';\nexport type {\n API,\n APIEvent,\n EventAttributes,\n EventEvent,\n EventsAPI,\n ExceptionEvent,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n LogArgsSerializer,\n LogContext,\n LogEvent,\n LogsAPI,\n MeasurementEvent,\n MeasurementsAPI,\n MetaAPI,\n OTELApi,\n PushErrorOptions,\n PushEventOptions,\n PushLogOptions,\n PushMeasurementOptions,\n Stacktrace,\n StacktraceParser,\n TraceContext,\n TraceEvent,\n TracesAPI,\n} from './api';\n\nexport { BaseExtension } from './extensions';\nexport type { Extension } from './extensions';\n\nexport { globalObject } from './globalObject';\nexport type { GlobalObject } from './globalObject';\n\nexport { initializeFaro } from './initialize';\n\nexport { defaultBatchingConfig, defaultGlobalObjectKey } from './config';\nexport type { Config, Patterns } from './config';\n\nexport { BaseInstrumentation } from './instrumentations';\nexport type { Instrumentation, Instrumentations } from './instrumentations';\n\nexport { createInternalLogger, defaultInternalLoggerLevel, InternalLoggerLevel } from './internalLogger';\nexport type { InternalLogger } from './internalLogger';\n\nexport type {\n Meta,\n MetaApp,\n MetaAttributes,\n MetaBrowser,\n MetaGetter,\n MetaItem,\n MetaPage,\n Metas,\n MetaSDK,\n MetaSDKIntegration,\n MetaSession,\n MetaUser,\n MetaView,\n} from './metas';\n\nexport {\n faro,\n getInternalFaroFromGlobalObject,\n internalGlobalObjectKey,\n isInternalFaroOnGlobalObject,\n setInternalFaroOnGlobalObject,\n} from './sdk';\nexport type { Faro } from './sdk';\n\nexport * from './semantic';\n\nexport { BaseTransport, getTransportBody, TransportItemType, transportItemTypeToBodyKey } from './transports';\nexport type {\n BeforeSendHook,\n SendFn,\n Transport,\n TransportBody,\n TransportItem,\n TransportItemPayload,\n Transports,\n} from './transports';\n\nexport { defaultUnpatchedConsole } from './unpatchedConsole';\nexport type { UnpatchedConsole } from './unpatchedConsole';\n\nexport {\n allLogLevels,\n createPromiseBuffer,\n deepEqual,\n defaultLogLevel,\n genShortID,\n getCurrentTimestamp,\n isArray,\n isBoolean,\n isDomError,\n isDomException,\n isElement,\n isElementDefined,\n isError,\n isErrorDefined,\n isErrorEvent,\n isEvent,\n isEventDefined,\n isFunction,\n isInstanceOf,\n isInt,\n isMap,\n isMapDefined,\n isNull,\n isNumber,\n isObject,\n isPrimitive,\n isRegExp,\n isString,\n isSymbol,\n isSyntheticEvent,\n isThenable,\n isToString,\n isTypeof,\n isUndefined,\n LogLevel,\n noop,\n dateNow,\n} from './utils';\nexport type {\n BaseObject,\n BaseObjectKey,\n BaseObjectPrimitiveValue,\n BaseObjectValue,\n BufferItem,\n PromiseBuffer,\n PromiseBufferOptions,\n PromiseProducer,\n} from './utils';\n\nexport { VERSION } from './version';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,6BAAuE;AAA9D,2GAAA,oBAAoB,OAAA;AAAE,+GAAA,wBAAwB,OAAA;AA8BvD,2CAA6C;AAApC,2GAAA,aAAa,OAAA;AAGtB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AAGrB,2CAA8C;AAArC,4GAAA,cAAc,OAAA;AAEvB,mCAAyE;AAAhE,+GAAA,qBAAqB,OAAA;AAAE,gHAAA,sBAAsB,OAAA;AAGtD,uDAAyD;AAAhD,uHAAA,mBAAmB,OAAA;AAG5B,mDAAyG;AAAhG,sHAAA,oBAAoB,OAAA;AAAE,4HAAA,0BAA0B,OAAA;AAAE,qHAAA,mBAAmB,OAAA;AAmB9E,6BAMe;AALb,2FAAA,IAAI,OAAA;AACJ,sHAAA,+BAA+B,OAAA;AAC/B,8GAAA,uBAAuB,OAAA;AACvB,mHAAA,4BAA4B,OAAA;AAC5B,oHAAA,6BAA6B,OAAA;AAI/B,6CAA2B;AAE3B,2CAA8G;AAArG,2GAAA,aAAa,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AAAE,+GAAA,iBAAiB,OAAA;AAAE,wHAAA,0BAA0B,OAAA;AAWvF,uDAA6D;AAApD,2HAAA,uBAAuB,OAAA;AAGhC,iCAsCiB;AArCf,qGAAA,YAAY,OAAA;AACZ,4GAAA,mBAAmB,OAAA;AACnB,kGAAA,SAAS,OAAA;AACT,wGAAA,eAAe,OAAA;AACf,mGAAA,UAAU,OAAA;AACV,4GAAA,mBAAmB,OAAA;AACnB,gGAAA,OAAO,OAAA;AACP,kGAAA,SAAS,OAAA;AACT,mGAAA,UAAU,OAAA;AACV,uGAAA,cAAc,OAAA;AACd,kGAAA,SAAS,OAAA;AACT,yGAAA,gBAAgB,OAAA;AAChB,gGAAA,OAAO,OAAA;AACP,uGAAA,cAAc,OAAA;AACd,qGAAA,YAAY,OAAA;AACZ,gGAAA,OAAO,OAAA;AACP,uGAAA,cAAc,OAAA;AACd,mGAAA,UAAU,OAAA;AACV,qGAAA,YAAY,OAAA;AACZ,8FAAA,KAAK,OAAA;AACL,8FAAA,KAAK,OAAA;AACL,qGAAA,YAAY,OAAA;AACZ,+FAAA,MAAM,OAAA;AACN,iGAAA,QAAQ,OAAA;AACR,iGAAA,QAAQ,OAAA;AACR,oGAAA,WAAW,OAAA;AACX,iGAAA,QAAQ,OAAA;AACR,iGAAA,QAAQ,OAAA;AACR,iGAAA,QAAQ,OAAA;AACR,yGAAA,gBAAgB,OAAA;AAChB,mGAAA,UAAU,OAAA;AACV,mGAAA,UAAU,OAAA;AACV,iGAAA,QAAQ,OAAA;AACR,oGAAA,WAAW,OAAA;AACX,iGAAA,QAAQ,OAAA;AACR,6FAAA,IAAI,OAAA;AACJ,gGAAA,OAAO,OAAA;AAaT,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAEhB,mCAAyC;AAAhC,uGAAA,aAAa,OAAA","sourcesContent":["export { defaultExceptionType, defaultLogArgsSerializer } from './api';\nexport type {\n API,\n APIEvent,\n EventAttributes,\n EventEvent,\n EventsAPI,\n ExceptionEvent,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n LogArgsSerializer,\n LogContext,\n LogEvent,\n LogsAPI,\n MeasurementEvent,\n MeasurementsAPI,\n MetaAPI,\n OTELApi,\n PushErrorOptions,\n PushEventOptions,\n PushLogOptions,\n PushMeasurementOptions,\n Stacktrace,\n StacktraceParser,\n TraceContext,\n TraceEvent,\n TracesAPI,\n} from './api';\n\nexport { BaseExtension } from './extensions';\nexport type { Extension } from './extensions';\n\nexport { globalObject } from './globalObject';\nexport type { GlobalObject } from './globalObject';\n\nexport { initializeFaro } from './initialize';\n\nexport { defaultBatchingConfig, defaultGlobalObjectKey } from './config';\nexport type { Config, Patterns } from './config';\n\nexport { BaseInstrumentation } from './instrumentations';\nexport type { Instrumentation, Instrumentations } from './instrumentations';\n\nexport { createInternalLogger, defaultInternalLoggerLevel, InternalLoggerLevel } from './internalLogger';\nexport type { InternalLogger } from './internalLogger';\n\nexport type {\n Meta,\n MetaApp,\n MetaAttributes,\n MetaBrowser,\n MetaGetter,\n MetaItem,\n MetaPage,\n Metas,\n MetaSDK,\n MetaSDKIntegration,\n MetaSession,\n MetaUser,\n MetaView,\n} from './metas';\n\nexport {\n faro,\n getInternalFaroFromGlobalObject,\n internalGlobalObjectKey,\n isInternalFaroOnGlobalObject,\n setInternalFaroOnGlobalObject,\n} from './sdk';\nexport type { Faro } from './sdk';\n\nexport * from './semantic';\n\nexport { BaseTransport, getTransportBody, TransportItemType, transportItemTypeToBodyKey } from './transports';\nexport type {\n BeforeSendHook,\n SendFn,\n Transport,\n TransportBody,\n TransportItem,\n TransportItemPayload,\n Transports,\n} from './transports';\n\nexport { defaultUnpatchedConsole } from './unpatchedConsole';\nexport type { UnpatchedConsole } from './unpatchedConsole';\n\nexport {\n allLogLevels,\n createPromiseBuffer,\n deepEqual,\n defaultLogLevel,\n genShortID,\n getCurrentTimestamp,\n isArray,\n isBoolean,\n isDomError,\n isDomException,\n isElement,\n isElementDefined,\n isError,\n isErrorDefined,\n isErrorEvent,\n isEvent,\n isEventDefined,\n isFunction,\n isInstanceOf,\n isInt,\n isMap,\n isMapDefined,\n isNull,\n isNumber,\n isObject,\n isPrimitive,\n isRegExp,\n isString,\n isSymbol,\n isSyntheticEvent,\n isThenable,\n isToString,\n isTypeof,\n isUndefined,\n LogLevel,\n noop,\n dateNow,\n} from './utils';\nexport type {\n BaseObject,\n BaseObjectKey,\n BaseObjectPrimitiveValue,\n BaseObjectValue,\n BufferItem,\n PromiseBuffer,\n PromiseBufferOptions,\n PromiseProducer,\n} from './utils';\n\nexport { VERSION } from './version';\n\nexport { unknownString } from './consts';\n"]}
|
package/dist/cjs/version.js
CHANGED
package/dist/cjs/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.10.1';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/api/exceptions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { defaultExceptionType } from './const';\n\nexport { initializeExceptionsAPI } from './initialize';\n\nexport type {\n ExceptionEvent,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n PushErrorOptions,\n Stacktrace,\n StacktraceParser,\n} from './types';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/api/exceptions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { defaultExceptionType } from './const';\n\nexport { initializeExceptionsAPI } from './initialize';\n\nexport type {\n ExceptionEvent,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n PushErrorOptions,\n Stacktrace,\n StacktraceParser,\n ErrorWithIndexProperties,\n} from './types';\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TransportItemType } from '../../transports';
|
|
2
|
-
import { deepEqual, getCurrentTimestamp, isNull } from '../../utils';
|
|
2
|
+
import { deepEqual, getCurrentTimestamp, isArray, isError, isNull, isObject } from '../../utils';
|
|
3
3
|
import { timestampToIsoString } from '../../utils/date';
|
|
4
4
|
import { defaultExceptionType } from './const';
|
|
5
5
|
let stacktraceParser;
|
|
@@ -27,7 +27,7 @@ export function initializeExceptionsAPI(_unpatchedConsole, internalLogger, confi
|
|
|
27
27
|
span_id: spanContext.spanId,
|
|
28
28
|
}
|
|
29
29
|
: tracesApi.getTraceContext(),
|
|
30
|
-
context: context !== null && context !== void 0 ? context : {},
|
|
30
|
+
context: Object.assign(Object.assign({}, parseCause(error)), (context !== null && context !== void 0 ? context : {})),
|
|
31
31
|
},
|
|
32
32
|
type: TransportItemType.EXCEPTION,
|
|
33
33
|
};
|
|
@@ -58,4 +58,19 @@ export function initializeExceptionsAPI(_unpatchedConsole, internalLogger, confi
|
|
|
58
58
|
pushError,
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
+
function parseCause(error) {
|
|
62
|
+
let cause = error.cause;
|
|
63
|
+
if (isError(cause)) {
|
|
64
|
+
cause = error.cause.toString();
|
|
65
|
+
// typeof operator on null returns "object". This is a well-known quirk in JavaScript and is considered a bug that cannot be fixed due to backward compatibility issues.
|
|
66
|
+
// MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#typeof_null
|
|
67
|
+
}
|
|
68
|
+
else if (cause !== null && (isObject(error.cause) || isArray(error.cause))) {
|
|
69
|
+
cause = JSON.stringify(error.cause);
|
|
70
|
+
}
|
|
71
|
+
else if (cause != null) {
|
|
72
|
+
cause = error.cause.toString();
|
|
73
|
+
}
|
|
74
|
+
return cause == null ? {} : { cause };
|
|
75
|
+
}
|
|
61
76
|
//# sourceMappingURL=initialize.js.map
|
|
@@ -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,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
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,SAAS,EAAE,mBAAmB,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjG,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAG/C,IAAI,gBAA8C,CAAC;AAEnD,MAAM,UAAU,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,MAAM,sBAAsB,GAA4C,CAAC,mBAAmB,EAAE,EAAE;QAC9F,cAAc,CAAC,KAAK,CAAC,4BAA4B,CAAC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C;KACrC;SAAM,IAAI,KAAK,IAAI,IAAI,EAAE;QACxB,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;KAChC;IAED,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;AACxC,CAAC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItemType } from '../../transports';\nimport type { TransportItem, Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { deepEqual, getCurrentTimestamp, isArray, isError, isNull, isObject } from '../../utils';\nimport { timestampToIsoString } from '../../utils/date';\nimport type { TracesAPI } from '../traces';\n\nimport { defaultExceptionType } from './const';\nimport type { ErrorWithIndexProperties, ExceptionEvent, ExceptionsAPI, StacktraceParser } from './types';\n\nlet stacktraceParser: StacktraceParser | undefined;\n\nexport function initializeExceptionsAPI(\n _unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas,\n transports: Transports,\n tracesApi: TracesAPI\n): ExceptionsAPI {\n internalLogger.debug('Initializing exceptions API');\n\n let lastPayload: Pick<ExceptionEvent, 'type' | 'value' | 'stacktrace' | 'context'> | null = null;\n\n stacktraceParser = config.parseStacktrace ?? stacktraceParser;\n\n const changeStacktraceParser: ExceptionsAPI['changeStacktraceParser'] = (newStacktraceParser) => {\n internalLogger.debug('Changing stacktrace parser');\n\n stacktraceParser = newStacktraceParser ?? stacktraceParser;\n };\n\n const getStacktraceParser: ExceptionsAPI['getStacktraceParser'] = () => stacktraceParser;\n\n const pushError: ExceptionsAPI['pushError'] = (\n error,\n { skipDedupe, stackFrames, type, context, spanContext, timestampOverwriteMs } = {}\n ) => {\n type = type || error.name || defaultExceptionType;\n\n const item: TransportItem<ExceptionEvent> = {\n meta: metas.value,\n payload: {\n type,\n value: error.message,\n timestamp: timestampOverwriteMs ? timestampToIsoString(timestampOverwriteMs) : getCurrentTimestamp(),\n trace: spanContext\n ? {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n }\n : tracesApi.getTraceContext(),\n context: {\n ...parseCause(error),\n ...(context ?? {}),\n },\n },\n type: TransportItemType.EXCEPTION,\n };\n\n stackFrames = stackFrames ?? (error.stack ? stacktraceParser?.(error).frames : undefined);\n\n if (stackFrames?.length) {\n item.payload.stacktrace = {\n frames: stackFrames,\n };\n }\n\n const testingPayload = {\n type: item.payload.type,\n value: item.payload.value,\n stackTrace: item.payload.stacktrace,\n context: item.payload.context,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping error push because it is the same as the last one\\n', item.payload);\n\n return;\n }\n\n lastPayload = testingPayload;\n\n internalLogger.debug('Pushing exception\\n', item);\n\n transports.execute(item);\n };\n\n changeStacktraceParser(config.parseStacktrace);\n\n return {\n changeStacktraceParser,\n getStacktraceParser,\n pushError,\n };\n}\nfunction parseCause(error: ErrorWithIndexProperties): {} | { cause: string } {\n let cause = error.cause;\n\n if (isError(cause)) {\n cause = error.cause.toString();\n // typeof operator on null returns \"object\". This is a well-known quirk in JavaScript and is considered a bug that cannot be fixed due to backward compatibility issues.\n // MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#typeof_null\n } else if (cause !== null && (isObject(error.cause) || isArray(error.cause))) {\n cause = JSON.stringify(error.cause);\n } else if (cause != null) {\n cause = error.cause.toString();\n }\n\n return cause == null ? {} : { cause };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/exceptions/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { TraceContext } from '../traces';\n\nexport type StacktraceParser = (err: ExtendedError) => Stacktrace;\n\nexport interface ExceptionStackFrame {\n filename: string;\n function: string;\n\n colno?: number;\n lineno?: number;\n\n bundleid?: string;\n}\n\nexport interface ExtendedError extends Error {\n columnNumber?: number;\n stacktrace?: Error['stack'];\n}\n\nexport interface Stacktrace {\n frames: ExceptionStackFrame[];\n}\n\nexport type ExceptionContext = Record<string, string>;\n\nexport interface ExceptionEvent {\n timestamp: string;\n type: string;\n value: string;\n\n stacktrace?: Stacktrace;\n trace?: TraceContext;\n context?: ExceptionContext;\n}\n\nexport interface PushErrorOptions {\n skipDedupe?: boolean;\n stackFrames?: ExceptionStackFrame[];\n type?: string;\n context?: ExceptionContext;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n timestampOverwriteMs?: number;\n}\n\nexport interface ExceptionsAPI {\n changeStacktraceParser: (stacktraceParser: StacktraceParser) => void;\n getStacktraceParser: () => StacktraceParser | undefined;\n pushError: (value:
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/exceptions/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { TraceContext } from '../traces';\n\nexport type StacktraceParser = (err: ExtendedError) => Stacktrace;\n\nexport interface ExceptionStackFrame {\n filename: string;\n function: string;\n\n colno?: number;\n lineno?: number;\n\n bundleid?: string;\n}\n\nexport interface ExtendedError extends Error {\n columnNumber?: number;\n stacktrace?: Error['stack'];\n}\n\nexport interface Stacktrace {\n frames: ExceptionStackFrame[];\n}\n\nexport type ExceptionContext = Record<string, string>;\n\nexport interface ExceptionEvent {\n timestamp: string;\n type: string;\n value: string;\n\n stacktrace?: Stacktrace;\n trace?: TraceContext;\n context?: ExceptionContext;\n}\n\nexport interface PushErrorOptions {\n skipDedupe?: boolean;\n stackFrames?: ExceptionStackFrame[];\n type?: string;\n context?: ExceptionContext;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n timestampOverwriteMs?: number;\n}\n\n// ts type is missing the cause property\nexport type ErrorWithIndexProperties = Error & {\n cause?: any;\n};\n\nexport interface ExceptionsAPI {\n changeStacktraceParser: (stacktraceParser: StacktraceParser) => void;\n getStacktraceParser: () => StacktraceParser | undefined;\n pushError: (value: ErrorWithIndexProperties, options?: PushErrorOptions) => void;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.js","sourceRoot":"","sources":["../../src/consts.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC","sourcesContent":["export const unknownString = 'unknown';\n"]}
|
package/dist/esm/index.js
CHANGED
|
@@ -11,4 +11,5 @@ export { BaseTransport, getTransportBody, TransportItemType, transportItemTypeTo
|
|
|
11
11
|
export { defaultUnpatchedConsole } from './unpatchedConsole';
|
|
12
12
|
export { allLogLevels, createPromiseBuffer, deepEqual, defaultLogLevel, genShortID, getCurrentTimestamp, isArray, isBoolean, isDomError, isDomException, isElement, isElementDefined, isError, isErrorDefined, isErrorEvent, isEvent, isEventDefined, isFunction, isInstanceOf, isInt, isMap, isMapDefined, isNull, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isSyntheticEvent, isThenable, isToString, isTypeof, isUndefined, LogLevel, noop, dateNow, } from './utils';
|
|
13
13
|
export { VERSION } from './version';
|
|
14
|
+
export { unknownString } from './consts';
|
|
14
15
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,OAAO,CAAC;AA8BvE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAGzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAGzD,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAmBzG,OAAO,EACL,IAAI,EACJ,+BAA+B,EAC/B,uBAAuB,EACvB,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,OAAO,CAAC;AAGf,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAW9G,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAG7D,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,SAAS,EACT,eAAe,EACf,UAAU,EACV,mBAAmB,EACnB,OAAO,EACP,SAAS,EACT,UAAU,EACV,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,cAAc,EACd,YAAY,EACZ,OAAO,EACP,cAAc,EACd,UAAU,EACV,YAAY,EACZ,KAAK,EACL,KAAK,EACL,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,IAAI,EACJ,OAAO,GACR,MAAM,SAAS,CAAC;AAYjB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC","sourcesContent":["export { defaultExceptionType, defaultLogArgsSerializer } from './api';\nexport type {\n API,\n APIEvent,\n EventAttributes,\n EventEvent,\n EventsAPI,\n ExceptionEvent,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n LogArgsSerializer,\n LogContext,\n LogEvent,\n LogsAPI,\n MeasurementEvent,\n MeasurementsAPI,\n MetaAPI,\n OTELApi,\n PushErrorOptions,\n PushEventOptions,\n PushLogOptions,\n PushMeasurementOptions,\n Stacktrace,\n StacktraceParser,\n TraceContext,\n TraceEvent,\n TracesAPI,\n} from './api';\n\nexport { BaseExtension } from './extensions';\nexport type { Extension } from './extensions';\n\nexport { globalObject } from './globalObject';\nexport type { GlobalObject } from './globalObject';\n\nexport { initializeFaro } from './initialize';\n\nexport { defaultBatchingConfig, defaultGlobalObjectKey } from './config';\nexport type { Config, Patterns } from './config';\n\nexport { BaseInstrumentation } from './instrumentations';\nexport type { Instrumentation, Instrumentations } from './instrumentations';\n\nexport { createInternalLogger, defaultInternalLoggerLevel, InternalLoggerLevel } from './internalLogger';\nexport type { InternalLogger } from './internalLogger';\n\nexport type {\n Meta,\n MetaApp,\n MetaAttributes,\n MetaBrowser,\n MetaGetter,\n MetaItem,\n MetaPage,\n Metas,\n MetaSDK,\n MetaSDKIntegration,\n MetaSession,\n MetaUser,\n MetaView,\n} from './metas';\n\nexport {\n faro,\n getInternalFaroFromGlobalObject,\n internalGlobalObjectKey,\n isInternalFaroOnGlobalObject,\n setInternalFaroOnGlobalObject,\n} from './sdk';\nexport type { Faro } from './sdk';\n\nexport * from './semantic';\n\nexport { BaseTransport, getTransportBody, TransportItemType, transportItemTypeToBodyKey } from './transports';\nexport type {\n BeforeSendHook,\n SendFn,\n Transport,\n TransportBody,\n TransportItem,\n TransportItemPayload,\n Transports,\n} from './transports';\n\nexport { defaultUnpatchedConsole } from './unpatchedConsole';\nexport type { UnpatchedConsole } from './unpatchedConsole';\n\nexport {\n allLogLevels,\n createPromiseBuffer,\n deepEqual,\n defaultLogLevel,\n genShortID,\n getCurrentTimestamp,\n isArray,\n isBoolean,\n isDomError,\n isDomException,\n isElement,\n isElementDefined,\n isError,\n isErrorDefined,\n isErrorEvent,\n isEvent,\n isEventDefined,\n isFunction,\n isInstanceOf,\n isInt,\n isMap,\n isMapDefined,\n isNull,\n isNumber,\n isObject,\n isPrimitive,\n isRegExp,\n isString,\n isSymbol,\n isSyntheticEvent,\n isThenable,\n isToString,\n isTypeof,\n isUndefined,\n LogLevel,\n noop,\n dateNow,\n} from './utils';\nexport type {\n BaseObject,\n BaseObjectKey,\n BaseObjectPrimitiveValue,\n BaseObjectValue,\n BufferItem,\n PromiseBuffer,\n PromiseBufferOptions,\n PromiseProducer,\n} from './utils';\n\nexport { VERSION } from './version';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,OAAO,CAAC;AA8BvE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAGzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAGzD,OAAO,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAmBzG,OAAO,EACL,IAAI,EACJ,+BAA+B,EAC/B,uBAAuB,EACvB,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,OAAO,CAAC;AAGf,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAW9G,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAG7D,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,SAAS,EACT,eAAe,EACf,UAAU,EACV,mBAAmB,EACnB,OAAO,EACP,SAAS,EACT,UAAU,EACV,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,cAAc,EACd,YAAY,EACZ,OAAO,EACP,cAAc,EACd,UAAU,EACV,YAAY,EACZ,KAAK,EACL,KAAK,EACL,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,IAAI,EACJ,OAAO,GACR,MAAM,SAAS,CAAC;AAYjB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC","sourcesContent":["export { defaultExceptionType, defaultLogArgsSerializer } from './api';\nexport type {\n API,\n APIEvent,\n EventAttributes,\n EventEvent,\n EventsAPI,\n ExceptionEvent,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n LogArgsSerializer,\n LogContext,\n LogEvent,\n LogsAPI,\n MeasurementEvent,\n MeasurementsAPI,\n MetaAPI,\n OTELApi,\n PushErrorOptions,\n PushEventOptions,\n PushLogOptions,\n PushMeasurementOptions,\n Stacktrace,\n StacktraceParser,\n TraceContext,\n TraceEvent,\n TracesAPI,\n} from './api';\n\nexport { BaseExtension } from './extensions';\nexport type { Extension } from './extensions';\n\nexport { globalObject } from './globalObject';\nexport type { GlobalObject } from './globalObject';\n\nexport { initializeFaro } from './initialize';\n\nexport { defaultBatchingConfig, defaultGlobalObjectKey } from './config';\nexport type { Config, Patterns } from './config';\n\nexport { BaseInstrumentation } from './instrumentations';\nexport type { Instrumentation, Instrumentations } from './instrumentations';\n\nexport { createInternalLogger, defaultInternalLoggerLevel, InternalLoggerLevel } from './internalLogger';\nexport type { InternalLogger } from './internalLogger';\n\nexport type {\n Meta,\n MetaApp,\n MetaAttributes,\n MetaBrowser,\n MetaGetter,\n MetaItem,\n MetaPage,\n Metas,\n MetaSDK,\n MetaSDKIntegration,\n MetaSession,\n MetaUser,\n MetaView,\n} from './metas';\n\nexport {\n faro,\n getInternalFaroFromGlobalObject,\n internalGlobalObjectKey,\n isInternalFaroOnGlobalObject,\n setInternalFaroOnGlobalObject,\n} from './sdk';\nexport type { Faro } from './sdk';\n\nexport * from './semantic';\n\nexport { BaseTransport, getTransportBody, TransportItemType, transportItemTypeToBodyKey } from './transports';\nexport type {\n BeforeSendHook,\n SendFn,\n Transport,\n TransportBody,\n TransportItem,\n TransportItemPayload,\n Transports,\n} from './transports';\n\nexport { defaultUnpatchedConsole } from './unpatchedConsole';\nexport type { UnpatchedConsole } from './unpatchedConsole';\n\nexport {\n allLogLevels,\n createPromiseBuffer,\n deepEqual,\n defaultLogLevel,\n genShortID,\n getCurrentTimestamp,\n isArray,\n isBoolean,\n isDomError,\n isDomException,\n isElement,\n isElementDefined,\n isError,\n isErrorDefined,\n isErrorEvent,\n isEvent,\n isEventDefined,\n isFunction,\n isInstanceOf,\n isInt,\n isMap,\n isMapDefined,\n isNull,\n isNumber,\n isObject,\n isPrimitive,\n isRegExp,\n isString,\n isSymbol,\n isSyntheticEvent,\n isThenable,\n isToString,\n isTypeof,\n isUndefined,\n LogLevel,\n noop,\n dateNow,\n} from './utils';\nexport type {\n BaseObject,\n BaseObjectKey,\n BaseObjectPrimitiveValue,\n BaseObjectValue,\n BufferItem,\n PromiseBuffer,\n PromiseBufferOptions,\n PromiseProducer,\n} from './utils';\n\nexport { VERSION } from './version';\n\nexport { unknownString } from './consts';\n"]}
|
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.10.1';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/api/exceptions/index.ts"],"names":[],"mappings":";;;AAAA,iCAA+C;AAAtC,6GAAA,oBAAoB,OAAA;AAE7B,2CAAuD;AAA9C,qHAAA,uBAAuB,OAAA","sourcesContent":["export { defaultExceptionType } from './const';\n\nexport { initializeExceptionsAPI } from './initialize';\n\nexport type {\n ExceptionEvent,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n PushErrorOptions,\n Stacktrace,\n StacktraceParser,\n} from './types';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/api/exceptions/index.ts"],"names":[],"mappings":";;;AAAA,iCAA+C;AAAtC,6GAAA,oBAAoB,OAAA;AAE7B,2CAAuD;AAA9C,qHAAA,uBAAuB,OAAA","sourcesContent":["export { defaultExceptionType } from './const';\n\nexport { initializeExceptionsAPI } from './initialize';\n\nexport type {\n ExceptionEvent,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n PushErrorOptions,\n Stacktrace,\n StacktraceParser,\n ErrorWithIndexProperties,\n} from './types';\n"]}
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.initializeExceptionsAPI = void 0;
|
|
4
15
|
var transports_1 = require("../../transports");
|
|
@@ -31,7 +42,7 @@ function initializeExceptionsAPI(_unpatchedConsole, internalLogger, config, meta
|
|
|
31
42
|
span_id: spanContext.spanId,
|
|
32
43
|
}
|
|
33
44
|
: tracesApi.getTraceContext(),
|
|
34
|
-
context: context !== null && context !== void 0 ? context : {},
|
|
45
|
+
context: __assign(__assign({}, parseCause(error)), (context !== null && context !== void 0 ? context : {})),
|
|
35
46
|
},
|
|
36
47
|
type: transports_1.TransportItemType.EXCEPTION,
|
|
37
48
|
};
|
|
@@ -63,4 +74,19 @@ function initializeExceptionsAPI(_unpatchedConsole, internalLogger, config, meta
|
|
|
63
74
|
};
|
|
64
75
|
}
|
|
65
76
|
exports.initializeExceptionsAPI = initializeExceptionsAPI;
|
|
77
|
+
function parseCause(error) {
|
|
78
|
+
var cause = error.cause;
|
|
79
|
+
if ((0, utils_1.isError)(cause)) {
|
|
80
|
+
cause = error.cause.toString();
|
|
81
|
+
// typeof operator on null returns "object". This is a well-known quirk in JavaScript and is considered a bug that cannot be fixed due to backward compatibility issues.
|
|
82
|
+
// MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#typeof_null
|
|
83
|
+
}
|
|
84
|
+
else if (cause !== null && ((0, utils_1.isObject)(error.cause) || (0, utils_1.isArray)(error.cause))) {
|
|
85
|
+
cause = JSON.stringify(error.cause);
|
|
86
|
+
}
|
|
87
|
+
else if (cause != null) {
|
|
88
|
+
cause = error.cause.toString();
|
|
89
|
+
}
|
|
90
|
+
return cause == null ? {} : { cause: cause };
|
|
91
|
+
}
|
|
66
92
|
//# sourceMappingURL=initialize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../../../src/api/exceptions/initialize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../../../src/api/exceptions/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAGA,+CAAqD;AAGrD,qCAAiG;AACjG,yCAAwD;AAGxD,iCAA+C;AAG/C,IAAI,gBAA8C,CAAC;AAEnD,SAAgB,uBAAuB,CACrC,iBAAmC,EACnC,cAA8B,EAC9B,MAAc,EACd,KAAY,EACZ,UAA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D,IAAI,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAExB,IAAI,IAAA,eAAO,EAAC,KAAK,CAAC,EAAE;QAClB,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC/B,wKAAwK;QACxK,sGAAsG;KACvG;SAAM,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,IAAA,gBAAQ,EAAC,KAAK,CAAC,KAAK,CAAC,IAAI,IAAA,eAAO,EAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE;QAC5E,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KACrC;SAAM,IAAI,KAAK,IAAI,IAAI,EAAE;QACxB,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;KAChC;IAED,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,OAAA,EAAE,CAAC;AACxC,CAAC","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, isArray, isError, isNull, isObject } from '../../utils';\nimport { timestampToIsoString } from '../../utils/date';\nimport type { TracesAPI } from '../traces';\n\nimport { defaultExceptionType } from './const';\nimport type { ErrorWithIndexProperties, ExceptionEvent, ExceptionsAPI, StacktraceParser } from './types';\n\nlet stacktraceParser: StacktraceParser | undefined;\n\nexport function initializeExceptionsAPI(\n _unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas,\n transports: Transports,\n tracesApi: TracesAPI\n): ExceptionsAPI {\n internalLogger.debug('Initializing exceptions API');\n\n let lastPayload: Pick<ExceptionEvent, 'type' | 'value' | 'stacktrace' | 'context'> | null = null;\n\n stacktraceParser = config.parseStacktrace ?? stacktraceParser;\n\n const changeStacktraceParser: ExceptionsAPI['changeStacktraceParser'] = (newStacktraceParser) => {\n internalLogger.debug('Changing stacktrace parser');\n\n stacktraceParser = newStacktraceParser ?? stacktraceParser;\n };\n\n const getStacktraceParser: ExceptionsAPI['getStacktraceParser'] = () => stacktraceParser;\n\n const pushError: ExceptionsAPI['pushError'] = (\n error,\n { skipDedupe, stackFrames, type, context, spanContext, timestampOverwriteMs } = {}\n ) => {\n type = type || error.name || defaultExceptionType;\n\n const item: TransportItem<ExceptionEvent> = {\n meta: metas.value,\n payload: {\n type,\n value: error.message,\n timestamp: timestampOverwriteMs ? timestampToIsoString(timestampOverwriteMs) : getCurrentTimestamp(),\n trace: spanContext\n ? {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n }\n : tracesApi.getTraceContext(),\n context: {\n ...parseCause(error),\n ...(context ?? {}),\n },\n },\n type: TransportItemType.EXCEPTION,\n };\n\n stackFrames = stackFrames ?? (error.stack ? stacktraceParser?.(error).frames : undefined);\n\n if (stackFrames?.length) {\n item.payload.stacktrace = {\n frames: stackFrames,\n };\n }\n\n const testingPayload = {\n type: item.payload.type,\n value: item.payload.value,\n stackTrace: item.payload.stacktrace,\n context: item.payload.context,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping error push because it is the same as the last one\\n', item.payload);\n\n return;\n }\n\n lastPayload = testingPayload;\n\n internalLogger.debug('Pushing exception\\n', item);\n\n transports.execute(item);\n };\n\n changeStacktraceParser(config.parseStacktrace);\n\n return {\n changeStacktraceParser,\n getStacktraceParser,\n pushError,\n };\n}\nfunction parseCause(error: ErrorWithIndexProperties): {} | { cause: string } {\n let cause = error.cause;\n\n if (isError(cause)) {\n cause = error.cause.toString();\n // typeof operator on null returns \"object\". This is a well-known quirk in JavaScript and is considered a bug that cannot be fixed due to backward compatibility issues.\n // MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#typeof_null\n } else if (cause !== null && (isObject(error.cause) || isArray(error.cause))) {\n cause = JSON.stringify(error.cause);\n } else if (cause != null) {\n cause = error.cause.toString();\n }\n\n return cause == null ? {} : { cause };\n}\n"]}
|
|
@@ -160,6 +160,37 @@ describe('api.exceptions', function () {
|
|
|
160
160
|
expect(transport.items).toHaveLength(1);
|
|
161
161
|
expect(((_a = transport.items[0]) === null || _a === void 0 ? void 0 : _a.payload).timestamp).toBe('1970-01-01T00:00:00.123Z');
|
|
162
162
|
});
|
|
163
|
+
it('Adds error cause to error context', function () {
|
|
164
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
165
|
+
// @ts-expect-error cause is missing in TS type Error
|
|
166
|
+
var error = new Error('test', { cause: 'foo' });
|
|
167
|
+
// @ts-expect-error cause is missing in TS type Error
|
|
168
|
+
var error2 = new Error('test2', { cause: [1, 3] });
|
|
169
|
+
// @ts-expect-error cause is missing in TS type Error
|
|
170
|
+
var error3 = new Error('test3', { cause: { a: 'b' } });
|
|
171
|
+
// @ts-expect-error cause is missing in TS type Error
|
|
172
|
+
var error4 = new Error('test4', { cause: new Error('original error') });
|
|
173
|
+
// @ts-expect-error cause is missing in TS type Error
|
|
174
|
+
var error5 = new Error('test5', { cause: null });
|
|
175
|
+
// @ts-expect-error cause is missing in TS type Error
|
|
176
|
+
var error6 = new Error('test6', { cause: undefined });
|
|
177
|
+
var error7 = new Error('test6');
|
|
178
|
+
api.pushError(error);
|
|
179
|
+
api.pushError(error2);
|
|
180
|
+
api.pushError(error3);
|
|
181
|
+
api.pushError(error4);
|
|
182
|
+
api.pushError(error5);
|
|
183
|
+
api.pushError(error6);
|
|
184
|
+
api.pushError(error7);
|
|
185
|
+
expect(transport.items).toHaveLength(7);
|
|
186
|
+
expect((_b = (_a = transport.items[0]) === null || _a === void 0 ? void 0 : _a.payload) === null || _b === void 0 ? void 0 : _b.context).toEqual({ cause: 'foo' });
|
|
187
|
+
expect((_d = (_c = transport.items[1]) === null || _c === void 0 ? void 0 : _c.payload) === null || _d === void 0 ? void 0 : _d.context).toEqual({ cause: '[1,3]' });
|
|
188
|
+
expect((_f = (_e = transport.items[2]) === null || _e === void 0 ? void 0 : _e.payload) === null || _f === void 0 ? void 0 : _f.context).toEqual({ cause: '{"a":"b"}' });
|
|
189
|
+
expect((_h = (_g = transport.items[3]) === null || _g === void 0 ? void 0 : _g.payload) === null || _h === void 0 ? void 0 : _h.context).toEqual({ cause: 'Error: original error' });
|
|
190
|
+
expect((_k = (_j = transport.items[4]) === null || _j === void 0 ? void 0 : _j.payload) === null || _k === void 0 ? void 0 : _k.context).toEqual({});
|
|
191
|
+
expect((_m = (_l = transport.items[5]) === null || _l === void 0 ? void 0 : _l.payload) === null || _m === void 0 ? void 0 : _m.context).toEqual({});
|
|
192
|
+
expect((_p = (_o = transport.items[5]) === null || _o === void 0 ? void 0 : _o.payload) === null || _p === void 0 ? void 0 : _p.context).toEqual({});
|
|
193
|
+
});
|
|
163
194
|
});
|
|
164
195
|
});
|
|
165
196
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.test.js","sourceRoot":"","sources":["../../../../../../src/api/exceptions/initialize.test.ts"],"names":[],"mappings":";;AAAA,+CAAkD;AAClD,6CAA4D;AAC5D,+CAAqD;AAKrD,QAAQ,CAAC,gBAAgB,EAAE;IACzB,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,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AAC,KAAK,CAAC,CAAC,CAAC,0CAAE,OAA0B,CAAA,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;YACrG,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 { TransportItemType } from '../../transports';\nimport type { API } from '../types';\n\nimport type { ExceptionEvent, ExceptionStackFrame, PushErrorOptions } from './types';\n\ndescribe('api.exceptions', () => {\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('pushError', () => {\n let api: API;\n let transport: MockTransport;\n\n beforeEach(() => {\n [api, transport] = createAPI();\n });\n\n it('error with overrides', () => {\n const frames: ExceptionStackFrame[] = [\n {\n filename: 'foo.js',\n function: 'FooFn',\n colno: 4,\n lineno: 23,\n },\n {\n filename: 'bar.js',\n function: 'BarFn',\n colno: 6,\n lineno: 52,\n },\n ];\n\n const additionalContext = {\n message: 'React error boundary',\n componentStackTrace: 'componentStackTrace',\n };\n\n api.pushError(new Error('test exception'), {\n stackFrames: frames,\n type: 'TestError',\n context: additionalContext,\n });\n\n expect(transport.items).toHaveLength(1);\n\n const payload = transport.items[0];\n expect(payload?.payload).toBeTruthy();\n expect(payload?.type).toEqual(TransportItemType.EXCEPTION);\n\n const evt = payload?.payload as ExceptionEvent;\n expect(evt.type).toEqual('TestError');\n expect(evt.value).toEqual('test exception');\n expect(evt.stacktrace).toEqual({ frames });\n expect(evt.context).toEqual(additionalContext);\n });\n\n it('error without overrides', () => {\n const err = new Error('test');\n api.pushError(err);\n expect(transport.items).toHaveLength(1);\n\n const payload = transport.items[0];\n expect(payload?.meta.app?.name).toEqual('test');\n expect(payload?.payload).toBeTruthy();\n expect(payload?.type).toEqual(TransportItemType.EXCEPTION);\n\n const evt = payload?.payload as ExceptionEvent;\n expect(evt.type).toEqual('Error');\n expect(evt.value).toEqual('test');\n expect(evt.timestamp).toBeTruthy();\n\n const stacktrace = evt.stacktrace;\n expect(stacktrace).toBeTruthy();\n expect(stacktrace?.frames.length).toBeGreaterThan(3);\n expect(stacktrace?.frames[0]?.filename).toEqual('Error: test');\n });\n\n describe('Filtering', () => {\n it('filters the same event', () => {\n const error = new Error('test');\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n });\n\n it(\"doesn't filter events with same message and different stacktrace\", () => {\n const error1 = new Error('test');\n const error2 = new Error('test');\n\n api.pushError(error1);\n expect(transport.items).toHaveLength(1);\n\n api.pushError(error2);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter events with other message and same stacktrace\", () => {\n const error = new Error('test');\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n error.message = 'test2';\n api.pushError(error);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter events with same message and same stacktrace but different type\", () => {\n const error = new Error('test');\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n error.name = 'Another Type';\n api.pushError(error);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"filters an event and doesn't filter the next different one\", () => {\n const error = new Error('test');\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n error.name = 'Another Type';\n api.pushError(error);\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 error = new Error('test');\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n api.pushError(error);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter when skipDedupe is true\", () => {\n const error = new Error('test');\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n api.pushError(error, {\n skipDedupe: true,\n });\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter events with same message, same stacktrace, same type but different context\", () => {\n const error = new Error('test');\n\n api.pushError(error, { context: { foo: 'bar' } });\n expect(transport.items).toHaveLength(1);\n\n api.pushError(error, { context: { bar: 'baz' } });\n expect(transport.items).toHaveLength(2);\n });\n\n it('uses traceId and spanId from custom context', () => {\n const spanContext: PushErrorOptions['spanContext'] = {\n traceId: 'my-trace-id',\n spanId: 'my-span-id',\n };\n\n const error = new Error('test');\n\n api.pushError(error, { spanContext });\n expect(transport.items).toHaveLength(1);\n expect((transport.items[0]?.payload as ExceptionEvent).trace).toStrictEqual({\n trace_id: 'my-trace-id',\n span_id: 'my-span-id',\n });\n });\n\n it('Sets the timestamp to the provided custom timestamp', () => {\n api.pushEvent('test', undefined, undefined, { timestampOverwriteMs: 123 });\n expect(transport.items).toHaveLength(1);\n expect((transport.items[0]?.payload as ExceptionEvent).timestamp).toBe('1970-01-01T00:00:00.123Z');\n });\n });\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"initialize.test.js","sourceRoot":"","sources":["../../../../../../src/api/exceptions/initialize.test.ts"],"names":[],"mappings":";;AAAA,+CAAkD;AAClD,6CAA4D;AAC5D,+CAAqD;AAKrD,QAAQ,CAAC,gBAAgB,EAAE;IACzB,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,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AAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { initializeFaro } from '../../initialize';\nimport { mockConfig, MockTransport } from '../../testUtils';\nimport { TransportItemType } from '../../transports';\nimport type { API } from '../types';\n\nimport type { ExceptionEvent, ExceptionStackFrame, PushErrorOptions } from './types';\n\ndescribe('api.exceptions', () => {\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('pushError', () => {\n let api: API;\n let transport: MockTransport;\n\n beforeEach(() => {\n [api, transport] = createAPI();\n });\n\n it('error with overrides', () => {\n const frames: ExceptionStackFrame[] = [\n {\n filename: 'foo.js',\n function: 'FooFn',\n colno: 4,\n lineno: 23,\n },\n {\n filename: 'bar.js',\n function: 'BarFn',\n colno: 6,\n lineno: 52,\n },\n ];\n\n const additionalContext = {\n message: 'React error boundary',\n componentStackTrace: 'componentStackTrace',\n };\n\n api.pushError(new Error('test exception'), {\n stackFrames: frames,\n type: 'TestError',\n context: additionalContext,\n });\n\n expect(transport.items).toHaveLength(1);\n\n const payload = transport.items[0];\n expect(payload?.payload).toBeTruthy();\n expect(payload?.type).toEqual(TransportItemType.EXCEPTION);\n\n const evt = payload?.payload as ExceptionEvent;\n expect(evt.type).toEqual('TestError');\n expect(evt.value).toEqual('test exception');\n expect(evt.stacktrace).toEqual({ frames });\n expect(evt.context).toEqual(additionalContext);\n });\n\n it('error without overrides', () => {\n const err = new Error('test');\n api.pushError(err);\n expect(transport.items).toHaveLength(1);\n\n const payload = transport.items[0];\n expect(payload?.meta.app?.name).toEqual('test');\n expect(payload?.payload).toBeTruthy();\n expect(payload?.type).toEqual(TransportItemType.EXCEPTION);\n\n const evt = payload?.payload as ExceptionEvent;\n expect(evt.type).toEqual('Error');\n expect(evt.value).toEqual('test');\n expect(evt.timestamp).toBeTruthy();\n\n const stacktrace = evt.stacktrace;\n expect(stacktrace).toBeTruthy();\n expect(stacktrace?.frames.length).toBeGreaterThan(3);\n expect(stacktrace?.frames[0]?.filename).toEqual('Error: test');\n });\n\n describe('Filtering', () => {\n it('filters the same event', () => {\n const error = new Error('test');\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n });\n\n it(\"doesn't filter events with same message and different stacktrace\", () => {\n const error1 = new Error('test');\n const error2 = new Error('test');\n\n api.pushError(error1);\n expect(transport.items).toHaveLength(1);\n\n api.pushError(error2);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter events with other message and same stacktrace\", () => {\n const error = new Error('test');\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n error.message = 'test2';\n api.pushError(error);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter events with same message and same stacktrace but different type\", () => {\n const error = new Error('test');\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n error.name = 'Another Type';\n api.pushError(error);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"filters an event and doesn't filter the next different one\", () => {\n const error = new Error('test');\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n error.name = 'Another Type';\n api.pushError(error);\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 error = new Error('test');\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n api.pushError(error);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter when skipDedupe is true\", () => {\n const error = new Error('test');\n\n api.pushError(error);\n expect(transport.items).toHaveLength(1);\n\n api.pushError(error, {\n skipDedupe: true,\n });\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter events with same message, same stacktrace, same type but different context\", () => {\n const error = new Error('test');\n\n api.pushError(error, { context: { foo: 'bar' } });\n expect(transport.items).toHaveLength(1);\n\n api.pushError(error, { context: { bar: 'baz' } });\n expect(transport.items).toHaveLength(2);\n });\n\n it('uses traceId and spanId from custom context', () => {\n const spanContext: PushErrorOptions['spanContext'] = {\n traceId: 'my-trace-id',\n spanId: 'my-span-id',\n };\n\n const error = new Error('test');\n\n api.pushError(error, { spanContext });\n expect(transport.items).toHaveLength(1);\n expect((transport.items[0]?.payload as ExceptionEvent).trace).toStrictEqual({\n trace_id: 'my-trace-id',\n span_id: 'my-span-id',\n });\n });\n\n it('Sets the timestamp to the provided custom timestamp', () => {\n api.pushEvent('test', undefined, undefined, { timestampOverwriteMs: 123 });\n expect(transport.items).toHaveLength(1);\n expect((transport.items[0]?.payload as ExceptionEvent).timestamp).toBe('1970-01-01T00:00:00.123Z');\n });\n\n it('Adds error cause to error context', () => {\n // @ts-expect-error cause is missing in TS type Error\n const error = new Error('test', { cause: 'foo' });\n // @ts-expect-error cause is missing in TS type Error\n const error2 = new Error('test2', { cause: [1, 3] });\n // @ts-expect-error cause is missing in TS type Error\n const error3 = new Error('test3', { cause: { a: 'b' } });\n // @ts-expect-error cause is missing in TS type Error\n const error4 = new Error('test4', { cause: new Error('original error') });\n // @ts-expect-error cause is missing in TS type Error\n const error5 = new Error('test5', { cause: null });\n // @ts-expect-error cause is missing in TS type Error\n const error6 = new Error('test6', { cause: undefined });\n const error7 = new Error('test6');\n\n api.pushError(error);\n api.pushError(error2);\n api.pushError(error3);\n api.pushError(error4);\n api.pushError(error5);\n api.pushError(error6);\n api.pushError(error7);\n\n expect(transport.items).toHaveLength(7);\n\n expect((transport.items[0]?.payload as ExceptionEvent)?.context).toEqual({ cause: 'foo' });\n expect((transport.items[1]?.payload as ExceptionEvent)?.context).toEqual({ cause: '[1,3]' });\n expect((transport.items[2]?.payload as ExceptionEvent)?.context).toEqual({ cause: '{\"a\":\"b\"}' });\n expect((transport.items[3]?.payload as ExceptionEvent)?.context).toEqual({ cause: 'Error: original error' });\n expect((transport.items[4]?.payload as ExceptionEvent)?.context).toEqual({});\n expect((transport.items[5]?.payload as ExceptionEvent)?.context).toEqual({});\n expect((transport.items[5]?.payload as ExceptionEvent)?.context).toEqual({});\n });\n });\n });\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/api/exceptions/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { TraceContext } from '../traces';\n\nexport type StacktraceParser = (err: ExtendedError) => Stacktrace;\n\nexport interface ExceptionStackFrame {\n filename: string;\n function: string;\n\n colno?: number;\n lineno?: number;\n\n bundleid?: string;\n}\n\nexport interface ExtendedError extends Error {\n columnNumber?: number;\n stacktrace?: Error['stack'];\n}\n\nexport interface Stacktrace {\n frames: ExceptionStackFrame[];\n}\n\nexport type ExceptionContext = Record<string, string>;\n\nexport interface ExceptionEvent {\n timestamp: string;\n type: string;\n value: string;\n\n stacktrace?: Stacktrace;\n trace?: TraceContext;\n context?: ExceptionContext;\n}\n\nexport interface PushErrorOptions {\n skipDedupe?: boolean;\n stackFrames?: ExceptionStackFrame[];\n type?: string;\n context?: ExceptionContext;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n timestampOverwriteMs?: number;\n}\n\nexport interface ExceptionsAPI {\n changeStacktraceParser: (stacktraceParser: StacktraceParser) => void;\n getStacktraceParser: () => StacktraceParser | undefined;\n pushError: (value:
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/api/exceptions/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { TraceContext } from '../traces';\n\nexport type StacktraceParser = (err: ExtendedError) => Stacktrace;\n\nexport interface ExceptionStackFrame {\n filename: string;\n function: string;\n\n colno?: number;\n lineno?: number;\n\n bundleid?: string;\n}\n\nexport interface ExtendedError extends Error {\n columnNumber?: number;\n stacktrace?: Error['stack'];\n}\n\nexport interface Stacktrace {\n frames: ExceptionStackFrame[];\n}\n\nexport type ExceptionContext = Record<string, string>;\n\nexport interface ExceptionEvent {\n timestamp: string;\n type: string;\n value: string;\n\n stacktrace?: Stacktrace;\n trace?: TraceContext;\n context?: ExceptionContext;\n}\n\nexport interface PushErrorOptions {\n skipDedupe?: boolean;\n stackFrames?: ExceptionStackFrame[];\n type?: string;\n context?: ExceptionContext;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n timestampOverwriteMs?: number;\n}\n\n// ts type is missing the cause property\nexport type ErrorWithIndexProperties = Error & {\n cause?: any;\n};\n\nexport interface ExceptionsAPI {\n changeStacktraceParser: (stacktraceParser: StacktraceParser) => void;\n getStacktraceParser: () => StacktraceParser | undefined;\n pushError: (value: ErrorWithIndexProperties, options?: PushErrorOptions) => void;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.js","sourceRoot":"","sources":["../../../../src/consts.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG,SAAS,CAAC","sourcesContent":["export const unknownString = 'unknown';\n"]}
|
|
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.isSymbol = exports.isString = exports.isRegExp = exports.isPrimitive = exports.isObject = exports.isNumber = exports.isNull = exports.isMapDefined = exports.isMap = exports.isInt = exports.isInstanceOf = exports.isFunction = exports.isEventDefined = exports.isEvent = exports.isErrorEvent = exports.isErrorDefined = exports.isError = exports.isElementDefined = exports.isElement = exports.isDomException = exports.isDomError = exports.isBoolean = exports.isArray = exports.getCurrentTimestamp = exports.genShortID = exports.defaultLogLevel = exports.deepEqual = exports.createPromiseBuffer = exports.allLogLevels = exports.defaultUnpatchedConsole = exports.transportItemTypeToBodyKey = exports.TransportItemType = exports.getTransportBody = exports.BaseTransport = exports.setInternalFaroOnGlobalObject = exports.isInternalFaroOnGlobalObject = exports.internalGlobalObjectKey = exports.getInternalFaroFromGlobalObject = exports.faro = exports.InternalLoggerLevel = exports.defaultInternalLoggerLevel = exports.createInternalLogger = exports.BaseInstrumentation = exports.defaultGlobalObjectKey = exports.defaultBatchingConfig = exports.initializeFaro = exports.globalObject = exports.BaseExtension = exports.defaultLogArgsSerializer = exports.defaultExceptionType = void 0;
|
|
18
|
-
exports.VERSION = exports.dateNow = exports.noop = exports.LogLevel = exports.isUndefined = exports.isTypeof = exports.isToString = exports.isThenable = exports.isSyntheticEvent = void 0;
|
|
18
|
+
exports.unknownString = exports.VERSION = exports.dateNow = exports.noop = exports.LogLevel = exports.isUndefined = exports.isTypeof = exports.isToString = exports.isThenable = exports.isSyntheticEvent = void 0;
|
|
19
19
|
var api_1 = require("./api");
|
|
20
20
|
Object.defineProperty(exports, "defaultExceptionType", { enumerable: true, get: function () { return api_1.defaultExceptionType; } });
|
|
21
21
|
Object.defineProperty(exports, "defaultLogArgsSerializer", { enumerable: true, get: function () { return api_1.defaultLogArgsSerializer; } });
|
|
@@ -88,4 +88,6 @@ Object.defineProperty(exports, "noop", { enumerable: true, get: function () { re
|
|
|
88
88
|
Object.defineProperty(exports, "dateNow", { enumerable: true, get: function () { return utils_1.dateNow; } });
|
|
89
89
|
var version_1 = require("./version");
|
|
90
90
|
Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return version_1.VERSION; } });
|
|
91
|
+
var consts_1 = require("./consts");
|
|
92
|
+
Object.defineProperty(exports, "unknownString", { enumerable: true, get: function () { return consts_1.unknownString; } });
|
|
91
93
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,6BAAuE;AAA9D,2GAAA,oBAAoB,OAAA;AAAE,+GAAA,wBAAwB,OAAA;AA8BvD,2CAA6C;AAApC,2GAAA,a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AACN,iGAAA,QAAQ,OAAA;AACR,iGAAA,QAAQ,OAAA;AACR,oGAAA,WAAW,OAAA;AACX,iGAAA,QAAQ,OAAA;AACR,iGAAA,QAAQ,OAAA;AACR,iGAAA,QAAQ,OAAA;AACR,yGAAA,gBAAgB,OAAA;AAChB,mGAAA,UAAU,OAAA;AACV,mGAAA,UAAU,OAAA;AACV,iGAAA,QAAQ,OAAA;AACR,oGAAA,WAAW,OAAA;AACX,iGAAA,QAAQ,OAAA;AACR,6FAAA,IAAI,OAAA;AACJ,gGAAA,OAAO,OAAA;AAaT,qCAAoC;AAA3B,kGAAA,OAAO,OAAA","sourcesContent":["export { defaultExceptionType, defaultLogArgsSerializer } from './api';\nexport type {\n API,\n APIEvent,\n EventAttributes,\n EventEvent,\n EventsAPI,\n ExceptionEvent,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n LogArgsSerializer,\n LogContext,\n LogEvent,\n LogsAPI,\n MeasurementEvent,\n MeasurementsAPI,\n MetaAPI,\n OTELApi,\n PushErrorOptions,\n PushEventOptions,\n PushLogOptions,\n PushMeasurementOptions,\n Stacktrace,\n StacktraceParser,\n TraceContext,\n TraceEvent,\n TracesAPI,\n} from './api';\n\nexport { BaseExtension } from './extensions';\nexport type { Extension } from './extensions';\n\nexport { globalObject } from './globalObject';\nexport type { GlobalObject } from './globalObject';\n\nexport { initializeFaro } from './initialize';\n\nexport { defaultBatchingConfig, defaultGlobalObjectKey } from './config';\nexport type { Config, Patterns } from './config';\n\nexport { BaseInstrumentation } from './instrumentations';\nexport type { Instrumentation, Instrumentations } from './instrumentations';\n\nexport { createInternalLogger, defaultInternalLoggerLevel, InternalLoggerLevel } from './internalLogger';\nexport type { InternalLogger } from './internalLogger';\n\nexport type {\n Meta,\n MetaApp,\n MetaAttributes,\n MetaBrowser,\n MetaGetter,\n MetaItem,\n MetaPage,\n Metas,\n MetaSDK,\n MetaSDKIntegration,\n MetaSession,\n MetaUser,\n MetaView,\n} from './metas';\n\nexport {\n faro,\n getInternalFaroFromGlobalObject,\n internalGlobalObjectKey,\n isInternalFaroOnGlobalObject,\n setInternalFaroOnGlobalObject,\n} from './sdk';\nexport type { Faro } from './sdk';\n\nexport * from './semantic';\n\nexport { BaseTransport, getTransportBody, TransportItemType, transportItemTypeToBodyKey } from './transports';\nexport type {\n BeforeSendHook,\n SendFn,\n Transport,\n TransportBody,\n TransportItem,\n TransportItemPayload,\n Transports,\n} from './transports';\n\nexport { defaultUnpatchedConsole } from './unpatchedConsole';\nexport type { UnpatchedConsole } from './unpatchedConsole';\n\nexport {\n allLogLevels,\n createPromiseBuffer,\n deepEqual,\n defaultLogLevel,\n genShortID,\n getCurrentTimestamp,\n isArray,\n isBoolean,\n isDomError,\n isDomException,\n isElement,\n isElementDefined,\n isError,\n isErrorDefined,\n isErrorEvent,\n isEvent,\n isEventDefined,\n isFunction,\n isInstanceOf,\n isInt,\n isMap,\n isMapDefined,\n isNull,\n isNumber,\n isObject,\n isPrimitive,\n isRegExp,\n isString,\n isSymbol,\n isSyntheticEvent,\n isThenable,\n isToString,\n isTypeof,\n isUndefined,\n LogLevel,\n noop,\n dateNow,\n} from './utils';\nexport type {\n BaseObject,\n BaseObjectKey,\n BaseObjectPrimitiveValue,\n BaseObjectValue,\n BufferItem,\n PromiseBuffer,\n PromiseBufferOptions,\n PromiseProducer,\n} from './utils';\n\nexport { VERSION } from './version';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,6BAAuE;AAA9D,2GAAA,oBAAoB,OAAA;AAAE,+GAAA,wBAAwB,OAAA;AA8BvD,2CAA6C;AAApC,2GAAA,aAAa,OAAA;AAGtB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AAGrB,2CAA8C;AAArC,4GAAA,cAAc,OAAA;AAEvB,mCAAyE;AAAhE,+GAAA,qBAAqB,OAAA;AAAE,gHAAA,sBAAsB,OAAA;AAGtD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OAAA;AAChB,mGAAA,UAAU,OAAA;AACV,mGAAA,UAAU,OAAA;AACV,iGAAA,QAAQ,OAAA;AACR,oGAAA,WAAW,OAAA;AACX,iGAAA,QAAQ,OAAA;AACR,6FAAA,IAAI,OAAA;AACJ,gGAAA,OAAO,OAAA;AAaT,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAEhB,mCAAyC;AAAhC,uGAAA,aAAa,OAAA","sourcesContent":["export { defaultExceptionType, defaultLogArgsSerializer } from './api';\nexport type {\n API,\n APIEvent,\n EventAttributes,\n EventEvent,\n EventsAPI,\n ExceptionEvent,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n LogArgsSerializer,\n LogContext,\n LogEvent,\n LogsAPI,\n MeasurementEvent,\n MeasurementsAPI,\n MetaAPI,\n OTELApi,\n PushErrorOptions,\n PushEventOptions,\n PushLogOptions,\n PushMeasurementOptions,\n Stacktrace,\n StacktraceParser,\n TraceContext,\n TraceEvent,\n TracesAPI,\n} from './api';\n\nexport { BaseExtension } from './extensions';\nexport type { Extension } from './extensions';\n\nexport { globalObject } from './globalObject';\nexport type { GlobalObject } from './globalObject';\n\nexport { initializeFaro } from './initialize';\n\nexport { defaultBatchingConfig, defaultGlobalObjectKey } from './config';\nexport type { Config, Patterns } from './config';\n\nexport { BaseInstrumentation } from './instrumentations';\nexport type { Instrumentation, Instrumentations } from './instrumentations';\n\nexport { createInternalLogger, defaultInternalLoggerLevel, InternalLoggerLevel } from './internalLogger';\nexport type { InternalLogger } from './internalLogger';\n\nexport type {\n Meta,\n MetaApp,\n MetaAttributes,\n MetaBrowser,\n MetaGetter,\n MetaItem,\n MetaPage,\n Metas,\n MetaSDK,\n MetaSDKIntegration,\n MetaSession,\n MetaUser,\n MetaView,\n} from './metas';\n\nexport {\n faro,\n getInternalFaroFromGlobalObject,\n internalGlobalObjectKey,\n isInternalFaroOnGlobalObject,\n setInternalFaroOnGlobalObject,\n} from './sdk';\nexport type { Faro } from './sdk';\n\nexport * from './semantic';\n\nexport { BaseTransport, getTransportBody, TransportItemType, transportItemTypeToBodyKey } from './transports';\nexport type {\n BeforeSendHook,\n SendFn,\n Transport,\n TransportBody,\n TransportItem,\n TransportItemPayload,\n Transports,\n} from './transports';\n\nexport { defaultUnpatchedConsole } from './unpatchedConsole';\nexport type { UnpatchedConsole } from './unpatchedConsole';\n\nexport {\n allLogLevels,\n createPromiseBuffer,\n deepEqual,\n defaultLogLevel,\n genShortID,\n getCurrentTimestamp,\n isArray,\n isBoolean,\n isDomError,\n isDomException,\n isElement,\n isElementDefined,\n isError,\n isErrorDefined,\n isErrorEvent,\n isEvent,\n isEventDefined,\n isFunction,\n isInstanceOf,\n isInt,\n isMap,\n isMapDefined,\n isNull,\n isNumber,\n isObject,\n isPrimitive,\n isRegExp,\n isString,\n isSymbol,\n isSyntheticEvent,\n isThenable,\n isToString,\n isTypeof,\n isUndefined,\n LogLevel,\n noop,\n dateNow,\n} from './utils';\nexport type {\n BaseObject,\n BaseObjectKey,\n BaseObjectPrimitiveValue,\n BaseObjectValue,\n BufferItem,\n PromiseBuffer,\n PromiseBufferOptions,\n PromiseProducer,\n} from './utils';\n\nexport { VERSION } from './version';\n\nexport { unknownString } from './consts';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.10.1';\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { defaultExceptionType } from './const';
|
|
2
2
|
export { initializeExceptionsAPI } from './initialize';
|
|
3
|
-
export type { ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, PushErrorOptions, Stacktrace, StacktraceParser, } from './types';
|
|
3
|
+
export type { ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, PushErrorOptions, Stacktrace, StacktraceParser, ErrorWithIndexProperties, } from './types';
|
|
@@ -32,8 +32,11 @@ export interface PushErrorOptions {
|
|
|
32
32
|
spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;
|
|
33
33
|
timestampOverwriteMs?: number;
|
|
34
34
|
}
|
|
35
|
+
export type ErrorWithIndexProperties = Error & {
|
|
36
|
+
cause?: any;
|
|
37
|
+
};
|
|
35
38
|
export interface ExceptionsAPI {
|
|
36
39
|
changeStacktraceParser: (stacktraceParser: StacktraceParser) => void;
|
|
37
40
|
getStacktraceParser: () => StacktraceParser | undefined;
|
|
38
|
-
pushError: (value:
|
|
41
|
+
pushError: (value: ErrorWithIndexProperties, options?: PushErrorOptions) => void;
|
|
39
42
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const unknownString = "unknown";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { defaultExceptionType } from './const';
|
|
2
2
|
export { initializeExceptionsAPI } from './initialize';
|
|
3
|
-
export type { ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, PushErrorOptions, Stacktrace, StacktraceParser, } from './types';
|
|
3
|
+
export type { ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, PushErrorOptions, Stacktrace, StacktraceParser, ErrorWithIndexProperties, } from './types';
|
|
@@ -32,8 +32,11 @@ export interface PushErrorOptions {
|
|
|
32
32
|
spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;
|
|
33
33
|
timestampOverwriteMs?: number;
|
|
34
34
|
}
|
|
35
|
+
export type ErrorWithIndexProperties = Error & {
|
|
36
|
+
cause?: any;
|
|
37
|
+
};
|
|
35
38
|
export interface ExceptionsAPI {
|
|
36
39
|
changeStacktraceParser: (stacktraceParser: StacktraceParser) => void;
|
|
37
40
|
getStacktraceParser: () => StacktraceParser | undefined;
|
|
38
|
-
pushError: (value:
|
|
41
|
+
pushError: (value: ErrorWithIndexProperties, options?: PushErrorOptions) => void;
|
|
39
42
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const unknownString = "unknown";
|
|
@@ -22,3 +22,4 @@ export type { UnpatchedConsole } from './unpatchedConsole';
|
|
|
22
22
|
export { allLogLevels, createPromiseBuffer, deepEqual, defaultLogLevel, genShortID, getCurrentTimestamp, isArray, isBoolean, isDomError, isDomException, isElement, isElementDefined, isError, isErrorDefined, isErrorEvent, isEvent, isEventDefined, isFunction, isInstanceOf, isInt, isMap, isMapDefined, isNull, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isSyntheticEvent, isThenable, isToString, isTypeof, isUndefined, LogLevel, noop, dateNow, } from './utils';
|
|
23
23
|
export type { BaseObject, BaseObjectKey, BaseObjectPrimitiveValue, BaseObjectValue, BufferItem, PromiseBuffer, PromiseBufferOptions, PromiseProducer, } from './utils';
|
|
24
24
|
export { VERSION } from './version';
|
|
25
|
+
export { unknownString } from './consts';
|
|
@@ -4,7 +4,7 @@ import type { Transport, TransportItem } from '../transports';
|
|
|
4
4
|
export declare class MockTransport extends BaseTransport implements Transport {
|
|
5
5
|
private ignoreURLs;
|
|
6
6
|
readonly name = "@grafana/transport-mock";
|
|
7
|
-
readonly version = "1.
|
|
7
|
+
readonly version = "1.10.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
|
+
export declare const VERSION = "1.10.1";
|
package/dist/types/index.d.ts
CHANGED
|
@@ -22,3 +22,4 @@ export type { UnpatchedConsole } from './unpatchedConsole';
|
|
|
22
22
|
export { allLogLevels, createPromiseBuffer, deepEqual, defaultLogLevel, genShortID, getCurrentTimestamp, isArray, isBoolean, isDomError, isDomException, isElement, isElementDefined, isError, isErrorDefined, isErrorEvent, isEvent, isEventDefined, isFunction, isInstanceOf, isInt, isMap, isMapDefined, isNull, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isSyntheticEvent, isThenable, isToString, isTypeof, isUndefined, LogLevel, noop, dateNow, } from './utils';
|
|
23
23
|
export type { BaseObject, BaseObjectKey, BaseObjectPrimitiveValue, BaseObjectValue, BufferItem, PromiseBuffer, PromiseBufferOptions, PromiseProducer, } from './utils';
|
|
24
24
|
export { VERSION } from './version';
|
|
25
|
+
export { unknownString } from './consts';
|
|
@@ -4,7 +4,7 @@ import type { Transport, TransportItem } from '../transports';
|
|
|
4
4
|
export declare class MockTransport extends BaseTransport implements Transport {
|
|
5
5
|
private ignoreURLs;
|
|
6
6
|
readonly name = "@grafana/transport-mock";
|
|
7
|
-
readonly version = "1.
|
|
7
|
+
readonly version = "1.10.1";
|
|
8
8
|
items: TransportItem[];
|
|
9
9
|
constructor(ignoreURLs?: Patterns);
|
|
10
10
|
send(items: TransportItem[]): void | Promise<void>;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.10.1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/faro-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.1",
|
|
4
4
|
"description": "Core package of Faro.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"observability",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@opentelemetry/api": "^1.9.0",
|
|
55
|
-
"@opentelemetry/otlp-transformer": "^0.
|
|
55
|
+
"@opentelemetry/otlp-transformer": "^0.53.0"
|
|
56
56
|
},
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "b0f480e48d5dd405b4650c9d26e3648454806411"
|
|
61
61
|
}
|