@grafana/faro-core 2.2.3 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle/faro-core.iife.js +1 -1
- package/dist/bundle/types/api/exceptions/types.d.ts +2 -0
- package/dist/bundle/types/index.d.ts +1 -1
- package/dist/bundle/types/testUtils/mockTransport.d.ts +1 -1
- package/dist/bundle/types/utils/index.d.ts +1 -0
- package/dist/bundle/types/utils/sampling.d.ts +1 -0
- package/dist/bundle/types/version.d.ts +1 -1
- package/dist/cjs/api/exceptions/initialize.js +4 -3
- package/dist/cjs/api/exceptions/initialize.js.map +1 -1
- package/dist/cjs/api/exceptions/types.js.map +1 -1
- package/dist/cjs/index.js +3 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/index.js +3 -1
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/sampling.js +7 -0
- package/dist/cjs/utils/sampling.js.map +1 -0
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/api/exceptions/initialize.js +4 -3
- package/dist/esm/api/exceptions/initialize.js.map +1 -1
- package/dist/esm/api/exceptions/types.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/sampling.js +4 -0
- package/dist/esm/utils/sampling.js.map +1 -0
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/spec/core/src/api/exceptions/initialize.js +4 -3
- package/dist/spec/core/src/api/exceptions/initialize.js.map +1 -1
- package/dist/spec/core/src/api/exceptions/initialize.test.js +21 -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/index.js +3 -2
- package/dist/spec/core/src/index.js.map +1 -1
- package/dist/spec/core/src/utils/index.js +3 -1
- package/dist/spec/core/src/utils/index.js.map +1 -1
- package/dist/spec/core/src/utils/sampling.js +7 -0
- package/dist/spec/core/src/utils/sampling.js.map +1 -0
- package/dist/spec/core/src/utils/sampling.test.js +17 -0
- package/dist/spec/core/src/utils/sampling.test.js.map +1 -0
- package/dist/spec/core/src/version.js +1 -1
- package/dist/spec/core/src/version.js.map +1 -1
- package/dist/types/api/exceptions/types.d.ts +2 -0
- package/dist/types/core/src/api/exceptions/types.d.ts +2 -0
- package/dist/types/core/src/index.d.ts +1 -1
- package/dist/types/core/src/testUtils/mockTransport.d.ts +1 -1
- package/dist/types/core/src/utils/index.d.ts +1 -0
- package/dist/types/core/src/utils/sampling.d.ts +1 -0
- package/dist/types/core/src/utils/sampling.test.d.ts +1 -0
- package/dist/types/core/src/version.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/testUtils/mockTransport.d.ts +1 -1
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/sampling.d.ts +1 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
var GrafanaFaroCore=function(e){"use strict";class t{constructor(e,t){var n,r;this.signalBuffer=[],this.itemLimit=null!==(n=null==t?void 0:t.itemLimit)&&void 0!==n?n:50,this.sendTimeout=null!==(r=null==t?void 0:t.sendTimeout)&&void 0!==r?r:250,this.paused=(null==t?void 0:t.paused)||!1,this.sendFn=e,this.flushInterval=-1,this.paused||this.start(),document.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&this.flush()})}addItem(e){this.paused||(this.signalBuffer.push(e),this.signalBuffer.length>=this.itemLimit&&this.flush())}start(){this.paused=!1,this.sendTimeout>0&&(this.flushInterval=window.setInterval(()=>this.flush(),this.sendTimeout))}pause(){this.paused=!0,clearInterval(this.flushInterval)}groupItems(e){const t=new Map;return e.forEach(e=>{const n=JSON.stringify(e.meta);let r=t.get(n);r=void 0===r?[e]:[...r,e],t.set(n,r)}),Array.from(t.values())}flush(){if(this.paused||0===this.signalBuffer.length)return;this.groupItems(this.signalBuffer).forEach(this.sendFn),this.signalBuffer=[]}}var n;e.TransportItemType=void 0,(n=e.TransportItemType||(e.TransportItemType={})).EXCEPTION="exception",n.LOG="log",n.MEASUREMENT="measurement",n.TRACE="trace",n.EVENT="event";const r={[e.TransportItemType.EXCEPTION]:"exceptions",[e.TransportItemType.LOG]:"logs",[e.TransportItemType.MEASUREMENT]:"measurements",[e.TransportItemType.TRACE]:"traces",[e.TransportItemType.EVENT]:"events"};function s(e,n,r,s){var a;n.debug("Initializing transports");const o=[];let u=r.paused,c=[];const l=e=>{let t=e;for(const e of c){const n=t.map(e).filter(Boolean);if(0===n.length)return[];t=i(n,r)}return t},d=e=>{const t=l(e);if(0!==t.length)for(const e of o)n.debug(`Transporting item using ${e.name}\n`,t),e.isBatched()&&e.send(t)};let g;(null===(a=r.batching)||void 0===a?void 0:a.enabled)&&(g=new t(d,{sendTimeout:r.batching.sendTimeout,itemLimit:r.batching.itemLimit,paused:u}));return{add:(...t)=>{n.debug("Adding transports"),t.forEach(t=>{n.debug(`Adding "${t.name}" transport`);o.some(e=>e===t)?n.warn(`Transport ${t.name} is already added`):(t.unpatchedConsole=e,t.internalLogger=n,t.config=r,t.metas=s,o.push(t))})},addBeforeSendHooks:(...e)=>{n.debug("Adding beforeSendHooks\n",c),e.forEach(e=>{e&&c.push(e)})},getBeforeSendHooks:()=>[...c],execute:e=>{var t;u||((null===(t=r.batching)||void 0===t?void 0:t.enabled)&&(null==g||g.addItem(e)),(e=>{var t,s;if((null===(t=r.batching)||void 0===t?void 0:t.enabled)&&o.every(e=>e.isBatched()))return;const[i]=l([e]);if(void 0!==i)for(const e of o)n.debug(`Transporting item using ${e.name}\n`,i),e.isBatched()?(null===(s=r.batching)||void 0===s?void 0:s.enabled)||e.send([i]):e.send(i)})(e))},isPaused:()=>u,pause:()=>{n.debug("Pausing transports"),null==g||g.pause(),u=!0},remove:(...e)=>{n.debug("Removing transports"),e.forEach(e=>{n.debug(`Removing "${e.name}" transport`);const t=o.indexOf(e);-1!==t?o.splice(t,1):n.warn(`Transport "${e.name}" is not added`)})},removeBeforeSendHooks:(...e)=>{c.filter(t=>!e.includes(t))},get transports(){return[...o]},unpause:()=>{n.debug("Unpausing transports"),null==g||g.start(),u=!1}}}function i(t,n){if(n.preserveOriginalError)for(const n of t)n.type===e.TransportItemType.EXCEPTION&&delete n.payload.originalError;return t}function a(e,t){return typeof e===t}function o(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function u(e,t){try{return e instanceof t}catch(e){return!1}}const c=e=>a(e,"null"),l=e=>a(e,"string"),d=e=>a(e,"number")&&!isNaN(e)||a(e,"bigint"),g=e=>!c(e)&&a(e,"object"),p=e=>a(e,"function"),f=e=>o(e,"Array"),m="undefined"!=typeof Event,b="undefined"!=typeof Error,h=e=>b&&u(e,Error),v="undefined"!=typeof Element,E="undefined"!=typeof Map;function y(e){return null==e||(f(e)||l(e)?0===e.length:!!g(e)&&0===Object.keys(e).length)}function I(e,t){if(e===t)return!0;if(a(e,"number")&&isNaN(e))return a(t,"number")&&isNaN(t);const n=f(e),r=f(t);if(n!==r)return!1;if(n&&r){const n=e.length;if(n!==t.length)return!1;for(let r=n;0!==r--;)if(!I(e[r],t[r]))return!1;return!0}const s=g(e),i=g(t);if(s!==i)return!1;if(e&&t&&s&&i){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(!I(e[r],t[r]))return!1;return!0}return!1}function T(){return Date.now()}function O(){return(new Date).toISOString()}function S(e){return new Date(e).toISOString()}var A;e.LogLevel=void 0,(A=e.LogLevel||(e.LogLevel={})).TRACE="trace",A.DEBUG="debug",A.INFO="info",A.LOG="log",A.WARN="warn",A.ERROR="error";const L=e.LogLevel.LOG,j=[e.LogLevel.TRACE,e.LogLevel.DEBUG,e.LogLevel.INFO,e.LogLevel.LOG,e.LogLevel.WARN,e.LogLevel.ERROR];function _(){}const x="abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789";function N(e=10){return Array.from(Array(e)).map(()=>x[Math.floor(59*Math.random())]).join("")}const w="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:void 0;function R(){const e=new WeakSet;return function(t,n){if(g(n)&&null!==n){if(e.has(n))return null;e.add(n)}return n}}function U(e={}){return JSON.stringify(null!=e?e:{},R())}function k(e={}){const t={};for(const[n,r]of Object.entries(e))t[n]=g(r)&&null!==r?U(r):String(r);return t}class C{constructor(){this.subscribers=[]}subscribe(e){return this.subscribers.push(e),{unsubscribe:()=>this.unsubscribe(e)}}unsubscribe(e){this.subscribers=this.subscribers.filter(t=>t!==e)}notify(e){this.subscribers.forEach(t=>t(e))}first(){const e=new C,t=t=>{e.notify(t),n.unsubscribe()},n=this.subscribe(t),r=e.unsubscribe.bind(e);return this.withUnsubscribeOverride(e,r,t)}takeWhile(e){const t=new C,n=r=>{e(r)?t.notify(r):t.unsubscribe(n)};this.subscribe(n);const r=t.unsubscribe.bind(t);return this.withUnsubscribeOverride(t,r,n)}filter(e){const t=new C,n=n=>{e(n)&&t.notify(n)};this.subscribe(n);const r=t.unsubscribe.bind(t);return this.withUnsubscribeOverride(t,r,n)}merge(...e){const t=new C,n=[];e.forEach(e=>{const r=e.subscribe(e=>{t.notify(e)});n.push(r)});const r=t.unsubscribeAll.bind(t);return t.unsubscribe=()=>{n.forEach(e=>e.unsubscribe()),r()},t}withUnsubscribeOverride(e,t,n){return e.unsubscribe=e=>{t(e),this.unsubscribe(n)},e}unsubscribeAll(){this.subscribers=[]}}var B;e.InternalLoggerLevel=void 0,(B=e.InternalLoggerLevel||(e.InternalLoggerLevel={}))[B.OFF=0]="OFF",B[B.ERROR=1]="ERROR",B[B.WARN=2]="WARN",B[B.INFO=3]="INFO",B[B.VERBOSE=4]="VERBOSE";const P={debug:_,error:_,info:_,prefix:"Faro",warn:_},M=e.InternalLoggerLevel.ERROR,F=Object.assign({},console);let D=F;function V(e){var t;return D=null!==(t=e.unpatchedConsole)&&void 0!==t?t:D,D}function $(t=F,n=M){const r=P;return n>e.InternalLoggerLevel.OFF&&(r.error=n>=e.InternalLoggerLevel.ERROR?function(...e){t.error(`${r.prefix}\n`,...e)}:_,r.warn=n>=e.InternalLoggerLevel.WARN?function(...e){t.warn(`${r.prefix}\n`,...e)}:_,r.info=n>=e.InternalLoggerLevel.INFO?function(...e){t.info(`${r.prefix}\n`,...e)}:_,r.debug=n>=e.InternalLoggerLevel.VERBOSE?function(...e){t.debug(`${r.prefix}\n`,...e)}:_),r}let z=P;function G(e,t){return z=$(e,t.internalLoggerLevel),z}class H{constructor(){this.unpatchedConsole=F,this.internalLogger=P,this.config={},this.metas={}}logDebug(...e){this.internalLogger.debug(`${this.name}\n`,...e)}logInfo(...e){this.internalLogger.info(`${this.name}\n`,...e)}logWarn(...e){this.internalLogger.warn(`${this.name}\n`,...e)}logError(...e){this.internalLogger.error(`${this.name}\n`,...e)}}function K(e,t){var n,r;if(void 0===t)return e;if(void 0===e)return{resourceSpans:t};const s=null===(n=e.resourceSpans)||void 0===n?void 0:n[0];if(void 0===s)return e;const i=(null==s?void 0:s.scopeSpans)||[],a=(null===(r=null==t?void 0:t[0])||void 0===r?void 0:r.scopeSpans)||[];return Object.assign(Object.assign({},e),{resourceSpans:[Object.assign(Object.assign({},s),{scopeSpans:[...i,...a]})]})}const W={Normal:"normal",Critical:"critical"};var X;e.UserActionState=void 0,(X=e.UserActionState||(e.UserActionState={}))[X.Started=0]="Started",X[X.Halted=1]="Halted",X[X.Cancelled=2]="Cancelled",X[X.Ended=3]="Ended";class J{constructor(){this.buffer=[]}addItem(e){this.buffer.push(e)}flushBuffer(e){if(p(e))for(const t of this.buffer)e(t);this.buffer.length=0}size(){return this.buffer.length}}class q extends C{constructor({name:t,parentId:n,trigger:r,transports:s,attributes:i,trackUserActionsExcludeItem:a,importance:o=W.Normal,pushEvent:u}){super(),this.name=t,this.attributes=i,this.id=N(),this.trigger=r,this.parentId=null!=n?n:this.id,this.trackUserActionsExcludeItem=a,this.importance=o,this._pushEvent=u,this._itemBuffer=new J,this._transports=s,this._state=e.UserActionState.Started,this._start()}addItem(t){return this._state===e.UserActionState.Started&&(this._itemBuffer.addItem(t),!0)}_start(){this._state=e.UserActionState.Started,this._state===e.UserActionState.Started&&(this.startTime=T())}halt(){this._state===e.UserActionState.Started&&(this._state=e.UserActionState.Halted,this.notify(this._state))}cancel(){this._state===e.UserActionState.Started&&this._itemBuffer.flushBuffer(e=>{this._transports.execute(e)}),this._state=e.UserActionState.Cancelled,this.notify(this._state)}end(){if(this._state===e.UserActionState.Cancelled)return;const t=T(),n=t-this.startTime;this._state=e.UserActionState.Ended,this._itemBuffer.flushBuffer(t=>{if(function(t,n){return(null==n?void 0:n(t))||t.type===e.TransportItemType.MEASUREMENT&&"web-vitals"===t.payload.type}(t,this.trackUserActionsExcludeItem))return void this._transports.execute(t);const n=Object.assign(Object.assign({},t),{payload:Object.assign(Object.assign({},t.payload),{action:{parentId:this.id,name:this.name}})});this._transports.execute(n)}),this._state=e.UserActionState.Ended,this.notify(this._state),this._pushEvent("faro.user.action",Object.assign({userActionName:this.name,userActionStartTime:this.startTime.toString(),userActionEndTime:t.toString(),userActionDuration:n.toString(),userActionTrigger:this.trigger,userActionImportance:this.importance},k(this.attributes)),void 0,{timestampOverwriteMs:this.startTime,customPayloadTransformer:e=>(e.action={id:this.id,name:this.name},e)})}getState(){return this._state}}const Q=new C;function Y(t,n){if(!t)return!1;return(null==t?void 0:t.getState())===e.UserActionState.Started&&(t.addItem(n),!0)}const Z="Error";let ee;function te({internalLogger:t,config:n,metas:r,transports:s,tracesApi:i,userActionsApi:a}){var o;t.debug("Initializing exceptions API");let u=null;ee=null!==(o=n.parseStacktrace)&&void 0!==o?o:ee;const d=e=>{t.debug("Changing stacktrace parser"),ee=null!=e?e:ee},{ignoreErrors:p=[],preserveOriginalError:m}=n;return d(n.parseStacktrace),{changeStacktraceParser:d,getStacktraceParser:()=>ee,pushError:(o,{skipDedupe:d,stackFrames:b,type:v,context:E,spanContext:T,timestampOverwriteMs:A,originalError:L}={})=>{if(!function(e,t){const{message:n,name:r,stack:s}=t;return i=e,a=n+" "+r+" "+s,i.some(e=>l(e)?a.includes(e):!!a.match(e));var i,a}(p,null!=L?L:o))try{const l=k(Object.assign(Object.assign({},function(e){let t=e.cause;h(t)?t=e.cause.toString():null!==t&&(g(e.cause)||f(e.cause))?t=U(e.cause):null!=t&&(t=e.cause.toString());return null==t?{}:{cause:t}}(null!=L?L:o)),null!=E?E:{})),p={meta:r.value,payload:Object.assign(Object.assign({type:v||o.name||Z,value:o.message,timestamp:A?S(A):O(),trace:T?{trace_id:T.traceId,span_id:T.spanId}:i.getTraceContext()},y(l)?{}:{context:l}),m?{originalError:L}:{}),type:e.TransportItemType.EXCEPTION};(null==(b=null!=b?b:o.stack?null==ee?void 0:ee(o).frames:void 0)?void 0:b.length)&&(p.payload.stacktrace={frames:b});const j={type:p.payload.type,value:p.payload.value,stackTrace:p.payload.stacktrace,context:p.payload.context};if(!d&&n.dedupe&&!c(u)&&I(j,u))return void t.debug("Skipping error push because it is the same as the last one\n",p.payload);u=j,t.debug("Pushing exception\n",p),Y(a.getActiveUserAction(),p)||s.execute(p)}catch(e){t.error("Error pushing event",e)}}}}const ne=e=>e.map(e=>{try{return String(e)}catch(e){return""}}).join(" ");function re(t,n,r,s,i){n.debug("Initializing API");let a=null;const o=function({transports:t,internalLogger:n,config:r,pushEvent:s}){var i;const a=null===(i=r.userActionsInstrumentation)||void 0===i?void 0:i.excludeItem;let o;const u=()=>o;return{startUserAction:(r,i,c)=>{if(void 0===u()){const n=new q({name:r,transports:t,attributes:i,trigger:(null==c?void 0:c.triggerName)||"faroApiCall",importance:(null==c?void 0:c.importance)||W.Normal,trackUserActionsExcludeItem:a,pushEvent:s});return n.filter(t=>[e.UserActionState.Ended,e.UserActionState.Cancelled].includes(t)).first().subscribe(()=>{o=void 0}),Q.notify({type:"user_action_start",userAction:n}),o=n,o}n.error("Attempted to create a new user action while one is already running. This is not possible.")},getActiveUserAction:u}}({transports:i,config:r,internalLogger:n,pushEvent:(e,t,r,s)=>{a?a(e,t,r,s):n.warn("pushEventImpl is not initialized. Event dropped:",{name:e,attributes:t,domain:r,options:s})}}),u=function(t,n,r,s,i){let a;return n.debug("Initializing traces API"),{getOTEL:()=>a,getTraceContext:()=>{const e=null==a?void 0:a.trace.getSpanContext(a.context.active());return e?{trace_id:e.traceId,span_id:e.spanId}:void 0},initOTEL:(e,t)=>{n.debug("Initializing OpenTelemetry"),a={trace:e,context:t}},isOTELInitialized:()=>!!a,pushTraces:t=>{try{const r={type:e.TransportItemType.TRACE,payload:t,meta:s.value};n.debug("Pushing trace\n",r),i.execute(r)}catch(e){n.error("Error pushing trace\n",e)}}}}(0,n,0,s,i),d={internalLogger:n,userActionsApi:o,config:r,metas:s,transports:i,tracesApi:u},g=function({internalLogger:t,config:n,metas:r,transports:s,tracesApi:i,userActionsApi:a}){let o=null;return{pushEvent:(u,l,d,{skipDedupe:g,spanContext:p,timestampOverwriteMs:f,customPayloadTransformer:m=e=>e}={})=>{try{const b=k(l),h={meta:r.value,payload:m({name:u,domain:null!=d?d:n.eventDomain,attributes:y(b)?void 0:b,timestamp:f?S(f):O(),trace:p?{trace_id:p.traceId,span_id:p.spanId}:i.getTraceContext()}),type:e.TransportItemType.EVENT},v={name:h.payload.name,attributes:h.payload.attributes,domain:h.payload.domain};if(!g&&n.dedupe&&!c(o)&&I(v,o))return void t.debug("Skipping event push because it is the same as the last one\n",h.payload);o=v,t.debug("Pushing event\n",h),Y(a.getActiveUserAction(),h)||s.execute(h)}catch(e){t.error("Error pushing event",e)}}}}(d);return a=g.pushEvent,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},u),te(d)),function({internalLogger:e,metas:t}){let n,r,s,i;e.debug("Initializing meta API");const a=e=>{r&&t.remove(r),r={user:e},t.add(r)},o=(e,r)=>{var s;const i=null==r?void 0:r.overrides,a=i?{overrides:Object.assign(Object.assign({},null===(s=null==n?void 0:n.session)||void 0===s?void 0:s.overrides),i)}:{};n&&t.remove(n),n={session:Object.assign(Object.assign({},y(e)?void 0:e),a)},t.add(n)},u=()=>t.value.session,c=()=>t.value.page;return{setUser:a,resetUser:a,setSession:o,resetSession:o,getSession:u,setView:(e,n)=>{var r;if((null==n?void 0:n.overrides)&&o(u(),{overrides:n.overrides}),(null===(r=null==s?void 0:s.view)||void 0===r?void 0:r.name)===(null==e?void 0:e.name))return;const i=s;s={view:e},t.add(s),i&&t.remove(i)},getView:()=>t.value.view,setPage:e=>{var n;const r=l(e)?Object.assign(Object.assign({},null!==(n=null==i?void 0:i.page)&&void 0!==n?n:c()),{id:e}):e;i&&t.remove(i),i={page:r},t.add(i)},getPage:c}}(d)),function({internalLogger:t,config:n,metas:r,transports:s,tracesApi:i,userActionsApi:a}){var o;t.debug("Initializing logs API");let u=null;const l=null!==(o=n.logArgsSerializer)&&void 0!==o?o:ne;return{pushLog:(o,{context:d,level:g,skipDedupe:p,spanContext:f,timestampOverwriteMs:m}={})=>{try{const b=k(d),h={type:e.TransportItemType.LOG,payload:{message:l(o),level:null!=g?g:L,context:y(b)?void 0:b,timestamp:m?S(m):O(),trace:f?{trace_id:f.traceId,span_id:f.spanId}:i.getTraceContext()},meta:r.value},v={message:h.payload.message,level:h.payload.level,context:h.payload.context};if(!p&&n.dedupe&&!c(u)&&I(v,u))return void t.debug("Skipping log push because it is the same as the last one\n",h.payload);u=v,t.debug("Pushing log\n",h),Y(a.getActiveUserAction(),h)||s.execute(h)}catch(e){t.error("Error pushing log\n",e)}}}}(d)),function({internalLogger:t,config:n,metas:r,transports:s,tracesApi:i,userActionsApi:a}){t.debug("Initializing measurements API");let o=null;return{pushMeasurement:(u,{skipDedupe:l,context:d,spanContext:g,timestampOverwriteMs:p}={})=>{try{const f=k(d),m={type:e.TransportItemType.MEASUREMENT,payload:Object.assign(Object.assign({},u),{trace:g?{trace_id:g.traceId,span_id:g.spanId}:i.getTraceContext(),timestamp:p?S(p):O(),context:y(f)?void 0:f}),meta:r.value},b={type:m.payload.type,values:m.payload.values,context:m.payload.context};if(!l&&n.dedupe&&!c(o)&&I(b,o))return void t.debug("Skipping measurement push because it is the same as the last one\n",m.payload);o=b,t.debug("Pushing measurement\n",m),Y(a.getActiveUserAction(),m)||s.execute(m)}catch(e){t.error("Error pushing measurement\n",e)}}}}(d)),g),o)}const se="2.2.3";const ie="_faroInternal";function ae(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(w,ie,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function oe(){return ie in w}function ue(t,n,r,s,i,a,o){return n.debug("Initializing Faro"),e.faro={api:a,config:r,instrumentations:o,internalLogger:n,metas:s,pause:i.pause,transports:i,unpatchedConsole:t,unpause:i.unpause},ae(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 w)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(w,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}(e.faro),e.faro}e.faro={};return e.BaseExtension=H,e.BaseInstrumentation=class extends H{constructor(){super(...arguments),this.api={},this.transports={}}},e.BaseTransport=class extends H{isBatched(){return!1}getIgnoreUrls(){return[]}},e.EVENT_CLICK="click",e.EVENT_NAVIGATION="navigation",e.EVENT_OVERRIDES_SERVICE_NAME="service_name_override",e.EVENT_ROUTE_CHANGE="route_change",e.EVENT_SESSION_EXTEND="session_extend",e.EVENT_SESSION_RESUME="session_resume",e.EVENT_SESSION_START="session_start",e.EVENT_VIEW_CHANGED="view_changed",e.Observable=C,e.UserActionImportance=W,e.VERSION=se,e.allLogLevels=j,e.createInternalLogger=$,e.createPromiseBuffer=function(e){const{size:t,concurrency:n}=e,r=[];let s=0;const i=()=>{if(s<n&&r.length){const{producer:e,resolve:t,reject:n}=r.shift();s++,e().then(e=>{s--,i(),t(e)},e=>{s--,i(),n(e)})}};return{add:e=>{if(r.length+s>=t)throw new Error("Task buffer full");return new Promise((t,n)=>{r.push({producer:e,resolve:t,reject:n}),i()})}}},e.dateNow=T,e.deepEqual=I,e.defaultBatchingConfig={enabled:!0,sendTimeout:250,itemLimit:50},e.defaultErrorArgsSerializer=e=>e.map(e=>g(e)?U(e):String(e)).join(" "),e.defaultExceptionType=Z,e.defaultGlobalObjectKey="faro",e.defaultInternalLoggerLevel=M,e.defaultLogArgsSerializer=ne,e.defaultLogLevel=L,e.defaultUnpatchedConsole=F,e.genShortID=N,e.getCircularDependencyReplacer=R,e.getCurrentTimestamp=O,e.getInternalFaroFromGlobalObject=function(){return w[ie]},e.getTransportBody=function(t){let n={meta:{}};return void 0!==t[0]&&(n.meta=t[0].meta),t.forEach(t=>{switch(t.type){case e.TransportItemType.LOG:case e.TransportItemType.EVENT:case e.TransportItemType.EXCEPTION:case e.TransportItemType.MEASUREMENT:{const e=r[t.type],s=n[e];n=Object.assign(Object.assign({},n),{[e]:void 0===s?[t.payload]:[...s,t.payload]});break}case e.TransportItemType.TRACE:n=Object.assign(Object.assign({},n),{traces:K(n.traces,t.payload.resourceSpans)})}}),n},e.globalObject=w,e.initializeFaro=function(e){const t=V(e),n=G(t,e);if(oe()&&!e.isolate)return void n.error('Faro is already registered. Either add instrumentations, transports etc. to the global faro instance or use the "isolate" property');n.debug("Initializing");const r=function(e,t){let n=[],r=[];const s=()=>n.reduce((e,t)=>Object.assign(e,p(t)?t():t),{}),i=()=>{if(r.length){const e=s();r.forEach(t=>t(e))}};return{add:(...e)=>{t.debug("Adding metas\n",e),n.push(...e),i()},remove:(...e)=>{t.debug("Removing metas\n",e),n=n.filter(t=>!e.includes(t)),i()},addListener:e=>{t.debug("Adding metas listener\n",e),r.push(e)},removeListener:e=>{t.debug("Removing metas listener\n",e),r=r.filter(t=>t!==e)},get value(){return s()}}}(0,n),i=s(t,n,e,r),a=re(0,n,e,r,i),o=function(e,t,n,r,s,i){t.debug("Initializing instrumentations");const a=[];return{add:(...o)=>{t.debug("Adding instrumentations"),o.forEach(o=>{t.debug(`Adding "${o.name}" instrumentation`),a.some(e=>e.name===o.name)?t.warn(`Instrumentation ${o.name} is already added`):(o.unpatchedConsole=e,o.internalLogger=t,o.config=n,o.metas=r,o.transports=s,o.api=i,a.push(o),o.initialize())})},get instrumentations(){return[...a]},remove:(...e)=>{t.debug("Removing instrumentations"),e.forEach(e=>{var n,r;t.debug(`Removing "${e.name}" instrumentation`);const s=a.reduce((t,n,r)=>null===t&&n.name===e.name?r:null,null);null!==s?(null===(r=(n=a[s]).destroy)||void 0===r||r.call(n),a.splice(s,1)):t.warn(`Instrumentation "${e.name}" is not added`)})}}}(t,n,e,r,i,a),u=ue(t,n,e,r,i,a,o);return function(e){var t,n;const r={sdk:{version:se,name:"faro"},app:{bundleId:e.config.app.name&&(s=e.config.app.name,null==w?void 0:w[`__faroBundleId_${s}`])}};var s;const i=null===(t=e.config.sessionTracking)||void 0===t?void 0:t.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!==(n=e.config.metas)&&void 0!==n?n:[])}(u),function(e){e.transports.add(...e.config.transports),e.transports.addBeforeSendHooks(e.config.beforeSend)}(u),function(e){e.instrumentations.add(...e.config.instrumentations)}(u),u},e.internalGlobalObjectKey=ie,e.isArray=f,e.isBoolean=e=>a(e,"boolean"),e.isDomError=e=>o(e,"DOMError"),e.isDomException=e=>o(e,"DOMException"),e.isElement=e=>v&&u(e,Element),e.isElementDefined=v,e.isEmpty=y,e.isError=h,e.isErrorDefined=b,e.isErrorEvent=e=>o(e,"ErrorEvent"),e.isEvent=e=>m&&u(e,Event),e.isEventDefined=m,e.isFunction=p,e.isInstanceOf=u,e.isInt=e=>d(e)&&Number.isInteger(e),e.isInternalFaroOnGlobalObject=oe,e.isMap=e=>E&&u(e,Map),e.isMapDefined=E,e.isNull=c,e.isNumber=d,e.isObject=g,e.isPrimitive=e=>!g(e)&&!p(e),e.isRegExp=e=>o(e,"RegExp"),e.isString=l,e.isSymbol=e=>a(e,"symbol"),e.isSyntheticEvent=e=>g(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e,e.isThenable=e=>p(null==e?void 0:e.then),e.isToString=o,e.isTypeof=a,e.isUndefined=e=>a(e,"undefined"),e.noop=_,e.setInternalFaroOnGlobalObject=ae,e.stringifyExternalJson=U,e.stringifyObjectValues=k,e.transportItemTypeToBodyKey=r,e.unknownString="unknown",e.userActionsMessageBus=Q,e}({});
|
|
1
|
+
var GrafanaFaroCore=function(e){"use strict";class t{constructor(e,t){var n,r;this.signalBuffer=[],this.itemLimit=null!==(n=null==t?void 0:t.itemLimit)&&void 0!==n?n:50,this.sendTimeout=null!==(r=null==t?void 0:t.sendTimeout)&&void 0!==r?r:250,this.paused=(null==t?void 0:t.paused)||!1,this.sendFn=e,this.flushInterval=-1,this.paused||this.start(),document.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&this.flush()})}addItem(e){this.paused||(this.signalBuffer.push(e),this.signalBuffer.length>=this.itemLimit&&this.flush())}start(){this.paused=!1,this.sendTimeout>0&&(this.flushInterval=window.setInterval(()=>this.flush(),this.sendTimeout))}pause(){this.paused=!0,clearInterval(this.flushInterval)}groupItems(e){const t=new Map;return e.forEach(e=>{const n=JSON.stringify(e.meta);let r=t.get(n);r=void 0===r?[e]:[...r,e],t.set(n,r)}),Array.from(t.values())}flush(){if(this.paused||0===this.signalBuffer.length)return;this.groupItems(this.signalBuffer).forEach(this.sendFn),this.signalBuffer=[]}}var n;e.TransportItemType=void 0,(n=e.TransportItemType||(e.TransportItemType={})).EXCEPTION="exception",n.LOG="log",n.MEASUREMENT="measurement",n.TRACE="trace",n.EVENT="event";const r={[e.TransportItemType.EXCEPTION]:"exceptions",[e.TransportItemType.LOG]:"logs",[e.TransportItemType.MEASUREMENT]:"measurements",[e.TransportItemType.TRACE]:"traces",[e.TransportItemType.EVENT]:"events"};function i(e,n,r,i){var a;n.debug("Initializing transports");const o=[];let u=r.paused,c=[];const l=e=>{let t=e;for(const e of c){const n=t.map(e).filter(Boolean);if(0===n.length)return[];t=s(n,r)}return t},d=e=>{const t=l(e);if(0!==t.length)for(const e of o)n.debug(`Transporting item using ${e.name}\n`,t),e.isBatched()&&e.send(t)};let g;(null===(a=r.batching)||void 0===a?void 0:a.enabled)&&(g=new t(d,{sendTimeout:r.batching.sendTimeout,itemLimit:r.batching.itemLimit,paused:u}));return{add:(...t)=>{n.debug("Adding transports"),t.forEach(t=>{n.debug(`Adding "${t.name}" transport`);o.some(e=>e===t)?n.warn(`Transport ${t.name} is already added`):(t.unpatchedConsole=e,t.internalLogger=n,t.config=r,t.metas=i,o.push(t))})},addBeforeSendHooks:(...e)=>{n.debug("Adding beforeSendHooks\n",c),e.forEach(e=>{e&&c.push(e)})},getBeforeSendHooks:()=>[...c],execute:e=>{var t;u||((null===(t=r.batching)||void 0===t?void 0:t.enabled)&&(null==g||g.addItem(e)),(e=>{var t,i;if((null===(t=r.batching)||void 0===t?void 0:t.enabled)&&o.every(e=>e.isBatched()))return;const[s]=l([e]);if(void 0!==s)for(const e of o)n.debug(`Transporting item using ${e.name}\n`,s),e.isBatched()?(null===(i=r.batching)||void 0===i?void 0:i.enabled)||e.send([s]):e.send(s)})(e))},isPaused:()=>u,pause:()=>{n.debug("Pausing transports"),null==g||g.pause(),u=!0},remove:(...e)=>{n.debug("Removing transports"),e.forEach(e=>{n.debug(`Removing "${e.name}" transport`);const t=o.indexOf(e);-1!==t?o.splice(t,1):n.warn(`Transport "${e.name}" is not added`)})},removeBeforeSendHooks:(...e)=>{c.filter(t=>!e.includes(t))},get transports(){return[...o]},unpause:()=>{n.debug("Unpausing transports"),null==g||g.start(),u=!1}}}function s(t,n){if(n.preserveOriginalError)for(const n of t)n.type===e.TransportItemType.EXCEPTION&&delete n.payload.originalError;return t}function a(e,t){return typeof e===t}function o(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function u(e,t){try{return e instanceof t}catch(e){return!1}}const c=e=>a(e,"null"),l=e=>a(e,"string"),d=e=>a(e,"number")&&!isNaN(e)||a(e,"bigint"),g=e=>!c(e)&&a(e,"object"),p=e=>a(e,"function"),f=e=>o(e,"Array"),m="undefined"!=typeof Event,b="undefined"!=typeof Error,h=e=>b&&u(e,Error),v="undefined"!=typeof Element,E="undefined"!=typeof Map;function y(e){return null==e||(f(e)||l(e)?0===e.length:!!g(e)&&0===Object.keys(e).length)}function I(e,t){if(e===t)return!0;if(a(e,"number")&&isNaN(e))return a(t,"number")&&isNaN(t);const n=f(e),r=f(t);if(n!==r)return!1;if(n&&r){const n=e.length;if(n!==t.length)return!1;for(let r=n;0!==r--;)if(!I(e[r],t[r]))return!1;return!0}const i=g(e),s=g(t);if(i!==s)return!1;if(e&&t&&i&&s){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;for(let r of n)if(!I(e[r],t[r]))return!1;return!0}return!1}function O(){return Date.now()}function T(){return(new Date).toISOString()}function S(e){return new Date(e).toISOString()}var A;e.LogLevel=void 0,(A=e.LogLevel||(e.LogLevel={})).TRACE="trace",A.DEBUG="debug",A.INFO="info",A.LOG="log",A.WARN="warn",A.ERROR="error";const L=e.LogLevel.LOG,j=[e.LogLevel.TRACE,e.LogLevel.DEBUG,e.LogLevel.INFO,e.LogLevel.LOG,e.LogLevel.WARN,e.LogLevel.ERROR];function _(){}const x="abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789";function N(e=10){return Array.from(Array(e)).map(()=>x[Math.floor(59*Math.random())]).join("")}const w="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:void 0;function R(){const e=new WeakSet;return function(t,n){if(g(n)&&null!==n){if(e.has(n))return null;e.add(n)}return n}}function U(e={}){return JSON.stringify(null!=e?e:{},R())}function k(e={}){const t={};for(const[n,r]of Object.entries(e))t[n]=g(r)&&null!==r?U(r):String(r);return t}class C{constructor(){this.subscribers=[]}subscribe(e){return this.subscribers.push(e),{unsubscribe:()=>this.unsubscribe(e)}}unsubscribe(e){this.subscribers=this.subscribers.filter(t=>t!==e)}notify(e){this.subscribers.forEach(t=>t(e))}first(){const e=new C,t=t=>{e.notify(t),n.unsubscribe()},n=this.subscribe(t),r=e.unsubscribe.bind(e);return this.withUnsubscribeOverride(e,r,t)}takeWhile(e){const t=new C,n=r=>{e(r)?t.notify(r):t.unsubscribe(n)};this.subscribe(n);const r=t.unsubscribe.bind(t);return this.withUnsubscribeOverride(t,r,n)}filter(e){const t=new C,n=n=>{e(n)&&t.notify(n)};this.subscribe(n);const r=t.unsubscribe.bind(t);return this.withUnsubscribeOverride(t,r,n)}merge(...e){const t=new C,n=[];e.forEach(e=>{const r=e.subscribe(e=>{t.notify(e)});n.push(r)});const r=t.unsubscribeAll.bind(t);return t.unsubscribe=()=>{n.forEach(e=>e.unsubscribe()),r()},t}withUnsubscribeOverride(e,t,n){return e.unsubscribe=e=>{t(e),this.unsubscribe(n)},e}unsubscribeAll(){this.subscribers=[]}}var B;e.InternalLoggerLevel=void 0,(B=e.InternalLoggerLevel||(e.InternalLoggerLevel={}))[B.OFF=0]="OFF",B[B.ERROR=1]="ERROR",B[B.WARN=2]="WARN",B[B.INFO=3]="INFO",B[B.VERBOSE=4]="VERBOSE";const P={debug:_,error:_,info:_,prefix:"Faro",warn:_},M=e.InternalLoggerLevel.ERROR,F=Object.assign({},console);let D=F;function V(e){var t;return D=null!==(t=e.unpatchedConsole)&&void 0!==t?t:D,D}function $(t=F,n=M){const r=P;return n>e.InternalLoggerLevel.OFF&&(r.error=n>=e.InternalLoggerLevel.ERROR?function(...e){t.error(`${r.prefix}\n`,...e)}:_,r.warn=n>=e.InternalLoggerLevel.WARN?function(...e){t.warn(`${r.prefix}\n`,...e)}:_,r.info=n>=e.InternalLoggerLevel.INFO?function(...e){t.info(`${r.prefix}\n`,...e)}:_,r.debug=n>=e.InternalLoggerLevel.VERBOSE?function(...e){t.debug(`${r.prefix}\n`,...e)}:_),r}let z=P;function G(e,t){return z=$(e,t.internalLoggerLevel),z}class H{constructor(){this.unpatchedConsole=F,this.internalLogger=P,this.config={},this.metas={}}logDebug(...e){this.internalLogger.debug(`${this.name}\n`,...e)}logInfo(...e){this.internalLogger.info(`${this.name}\n`,...e)}logWarn(...e){this.internalLogger.warn(`${this.name}\n`,...e)}logError(...e){this.internalLogger.error(`${this.name}\n`,...e)}}function K(e,t){var n,r;if(void 0===t)return e;if(void 0===e)return{resourceSpans:t};const i=null===(n=e.resourceSpans)||void 0===n?void 0:n[0];if(void 0===i)return e;const s=(null==i?void 0:i.scopeSpans)||[],a=(null===(r=null==t?void 0:t[0])||void 0===r?void 0:r.scopeSpans)||[];return Object.assign(Object.assign({},e),{resourceSpans:[Object.assign(Object.assign({},i),{scopeSpans:[...s,...a]})]})}const W={Normal:"normal",Critical:"critical"};var X;e.UserActionState=void 0,(X=e.UserActionState||(e.UserActionState={}))[X.Started=0]="Started",X[X.Halted=1]="Halted",X[X.Cancelled=2]="Cancelled",X[X.Ended=3]="Ended";class J{constructor(){this.buffer=[]}addItem(e){this.buffer.push(e)}flushBuffer(e){if(p(e))for(const t of this.buffer)e(t);this.buffer.length=0}size(){return this.buffer.length}}class q extends C{constructor({name:t,parentId:n,trigger:r,transports:i,attributes:s,trackUserActionsExcludeItem:a,importance:o=W.Normal,pushEvent:u}){super(),this.name=t,this.attributes=s,this.id=N(),this.trigger=r,this.parentId=null!=n?n:this.id,this.trackUserActionsExcludeItem=a,this.importance=o,this._pushEvent=u,this._itemBuffer=new J,this._transports=i,this._state=e.UserActionState.Started,this._start()}addItem(t){return this._state===e.UserActionState.Started&&(this._itemBuffer.addItem(t),!0)}_start(){this._state=e.UserActionState.Started,this._state===e.UserActionState.Started&&(this.startTime=O())}halt(){this._state===e.UserActionState.Started&&(this._state=e.UserActionState.Halted,this.notify(this._state))}cancel(){this._state===e.UserActionState.Started&&this._itemBuffer.flushBuffer(e=>{this._transports.execute(e)}),this._state=e.UserActionState.Cancelled,this.notify(this._state)}end(){if(this._state===e.UserActionState.Cancelled)return;const t=O(),n=t-this.startTime;this._state=e.UserActionState.Ended,this._itemBuffer.flushBuffer(t=>{if(function(t,n){return(null==n?void 0:n(t))||t.type===e.TransportItemType.MEASUREMENT&&"web-vitals"===t.payload.type}(t,this.trackUserActionsExcludeItem))return void this._transports.execute(t);const n=Object.assign(Object.assign({},t),{payload:Object.assign(Object.assign({},t.payload),{action:{parentId:this.id,name:this.name}})});this._transports.execute(n)}),this._state=e.UserActionState.Ended,this.notify(this._state),this._pushEvent("faro.user.action",Object.assign({userActionName:this.name,userActionStartTime:this.startTime.toString(),userActionEndTime:t.toString(),userActionDuration:n.toString(),userActionTrigger:this.trigger,userActionImportance:this.importance},k(this.attributes)),void 0,{timestampOverwriteMs:this.startTime,customPayloadTransformer:e=>(e.action={id:this.id,name:this.name},e)})}getState(){return this._state}}const Q=new C;function Y(t,n){if(!t)return!1;return(null==t?void 0:t.getState())===e.UserActionState.Started&&(t.addItem(n),!0)}const Z="Error";let ee;function te({internalLogger:t,config:n,metas:r,transports:i,tracesApi:s,userActionsApi:a}){var o;t.debug("Initializing exceptions API");let u=null;ee=null!==(o=n.parseStacktrace)&&void 0!==o?o:ee;const d=e=>{t.debug("Changing stacktrace parser"),ee=null!=e?e:ee},{ignoreErrors:p=[],preserveOriginalError:m}=n;return d(n.parseStacktrace),{changeStacktraceParser:d,getStacktraceParser:()=>ee,pushError:(o,{skipDedupe:d,stackFrames:b,type:v,context:E,spanContext:O,timestampOverwriteMs:A,originalError:L,fingerprint:j}={})=>{if(!function(e,t){const{message:n,name:r,stack:i}=t;return s=e,a=n+" "+r+" "+i,s.some(e=>l(e)?a.includes(e):!!a.match(e));var s,a}(p,null!=L?L:o))try{const l=k(Object.assign(Object.assign({},function(e){let t=e.cause;h(t)?t=e.cause.toString():null!==t&&(g(e.cause)||f(e.cause))?t=U(e.cause):null!=t&&(t=e.cause.toString());return null==t?{}:{cause:t}}(null!=L?L:o)),null!=E?E:{})),p={meta:r.value,payload:Object.assign(Object.assign(Object.assign({type:v||o.name||Z,value:o.message,timestamp:A?S(A):T(),trace:O?{trace_id:O.traceId,span_id:O.spanId}:s.getTraceContext()},y(l)?{}:{context:l}),m?{originalError:L}:{}),j?{fingerprint:j}:{}),type:e.TransportItemType.EXCEPTION};(null==(b=null!=b?b:o.stack?null==ee?void 0:ee(o).frames:void 0)?void 0:b.length)&&(p.payload.stacktrace={frames:b});const _={type:p.payload.type,value:p.payload.value,stackTrace:p.payload.stacktrace,context:p.payload.context,fingerprint:p.payload.fingerprint};if(!d&&n.dedupe&&!c(u)&&I(_,u))return void t.debug("Skipping error push because it is the same as the last one\n",p.payload);u=_,t.debug("Pushing exception\n",p),Y(a.getActiveUserAction(),p)||i.execute(p)}catch(e){t.error("Error pushing event",e)}}}}const ne=e=>e.map(e=>{try{return String(e)}catch(e){return""}}).join(" ");function re(t,n,r,i,s){n.debug("Initializing API");let a=null;const o=function({transports:t,internalLogger:n,config:r,pushEvent:i}){var s;const a=null===(s=r.userActionsInstrumentation)||void 0===s?void 0:s.excludeItem;let o;const u=()=>o;return{startUserAction:(r,s,c)=>{if(void 0===u()){const n=new q({name:r,transports:t,attributes:s,trigger:(null==c?void 0:c.triggerName)||"faroApiCall",importance:(null==c?void 0:c.importance)||W.Normal,trackUserActionsExcludeItem:a,pushEvent:i});return n.filter(t=>[e.UserActionState.Ended,e.UserActionState.Cancelled].includes(t)).first().subscribe(()=>{o=void 0}),Q.notify({type:"user_action_start",userAction:n}),o=n,o}n.error("Attempted to create a new user action while one is already running. This is not possible.")},getActiveUserAction:u}}({transports:s,config:r,internalLogger:n,pushEvent:(e,t,r,i)=>{a?a(e,t,r,i):n.warn("pushEventImpl is not initialized. Event dropped:",{name:e,attributes:t,domain:r,options:i})}}),u=function(t,n,r,i,s){let a;return n.debug("Initializing traces API"),{getOTEL:()=>a,getTraceContext:()=>{const e=null==a?void 0:a.trace.getSpanContext(a.context.active());return e?{trace_id:e.traceId,span_id:e.spanId}:void 0},initOTEL:(e,t)=>{n.debug("Initializing OpenTelemetry"),a={trace:e,context:t}},isOTELInitialized:()=>!!a,pushTraces:t=>{try{const r={type:e.TransportItemType.TRACE,payload:t,meta:i.value};n.debug("Pushing trace\n",r),s.execute(r)}catch(e){n.error("Error pushing trace\n",e)}}}}(0,n,0,i,s),d={internalLogger:n,userActionsApi:o,config:r,metas:i,transports:s,tracesApi:u},g=function({internalLogger:t,config:n,metas:r,transports:i,tracesApi:s,userActionsApi:a}){let o=null;return{pushEvent:(u,l,d,{skipDedupe:g,spanContext:p,timestampOverwriteMs:f,customPayloadTransformer:m=e=>e}={})=>{try{const b=k(l),h={meta:r.value,payload:m({name:u,domain:null!=d?d:n.eventDomain,attributes:y(b)?void 0:b,timestamp:f?S(f):T(),trace:p?{trace_id:p.traceId,span_id:p.spanId}:s.getTraceContext()}),type:e.TransportItemType.EVENT},v={name:h.payload.name,attributes:h.payload.attributes,domain:h.payload.domain};if(!g&&n.dedupe&&!c(o)&&I(v,o))return void t.debug("Skipping event push because it is the same as the last one\n",h.payload);o=v,t.debug("Pushing event\n",h),Y(a.getActiveUserAction(),h)||i.execute(h)}catch(e){t.error("Error pushing event",e)}}}}(d);return a=g.pushEvent,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},u),te(d)),function({internalLogger:e,metas:t}){let n,r,i,s;e.debug("Initializing meta API");const a=e=>{r&&t.remove(r),r={user:e},t.add(r)},o=(e,r)=>{var i;const s=null==r?void 0:r.overrides,a=s?{overrides:Object.assign(Object.assign({},null===(i=null==n?void 0:n.session)||void 0===i?void 0:i.overrides),s)}:{};n&&t.remove(n),n={session:Object.assign(Object.assign({},y(e)?void 0:e),a)},t.add(n)},u=()=>t.value.session,c=()=>t.value.page;return{setUser:a,resetUser:a,setSession:o,resetSession:o,getSession:u,setView:(e,n)=>{var r;if((null==n?void 0:n.overrides)&&o(u(),{overrides:n.overrides}),(null===(r=null==i?void 0:i.view)||void 0===r?void 0:r.name)===(null==e?void 0:e.name))return;const s=i;i={view:e},t.add(i),s&&t.remove(s)},getView:()=>t.value.view,setPage:e=>{var n;const r=l(e)?Object.assign(Object.assign({},null!==(n=null==s?void 0:s.page)&&void 0!==n?n:c()),{id:e}):e;s&&t.remove(s),s={page:r},t.add(s)},getPage:c}}(d)),function({internalLogger:t,config:n,metas:r,transports:i,tracesApi:s,userActionsApi:a}){var o;t.debug("Initializing logs API");let u=null;const l=null!==(o=n.logArgsSerializer)&&void 0!==o?o:ne;return{pushLog:(o,{context:d,level:g,skipDedupe:p,spanContext:f,timestampOverwriteMs:m}={})=>{try{const b=k(d),h={type:e.TransportItemType.LOG,payload:{message:l(o),level:null!=g?g:L,context:y(b)?void 0:b,timestamp:m?S(m):T(),trace:f?{trace_id:f.traceId,span_id:f.spanId}:s.getTraceContext()},meta:r.value},v={message:h.payload.message,level:h.payload.level,context:h.payload.context};if(!p&&n.dedupe&&!c(u)&&I(v,u))return void t.debug("Skipping log push because it is the same as the last one\n",h.payload);u=v,t.debug("Pushing log\n",h),Y(a.getActiveUserAction(),h)||i.execute(h)}catch(e){t.error("Error pushing log\n",e)}}}}(d)),function({internalLogger:t,config:n,metas:r,transports:i,tracesApi:s,userActionsApi:a}){t.debug("Initializing measurements API");let o=null;return{pushMeasurement:(u,{skipDedupe:l,context:d,spanContext:g,timestampOverwriteMs:p}={})=>{try{const f=k(d),m={type:e.TransportItemType.MEASUREMENT,payload:Object.assign(Object.assign({},u),{trace:g?{trace_id:g.traceId,span_id:g.spanId}:s.getTraceContext(),timestamp:p?S(p):T(),context:y(f)?void 0:f}),meta:r.value},b={type:m.payload.type,values:m.payload.values,context:m.payload.context};if(!l&&n.dedupe&&!c(o)&&I(b,o))return void t.debug("Skipping measurement push because it is the same as the last one\n",m.payload);o=b,t.debug("Pushing measurement\n",m),Y(a.getActiveUserAction(),m)||i.execute(m)}catch(e){t.error("Error pushing measurement\n",e)}}}}(d)),g),o)}const ie="2.3.0";const se="_faroInternal";function ae(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(w,se,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function oe(){return se in w}function ue(t,n,r,i,s,a,o){return n.debug("Initializing Faro"),e.faro={api:a,config:r,instrumentations:o,internalLogger:n,metas:i,pause:s.pause,transports:s,unpatchedConsole:t,unpause:s.unpause},ae(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 w)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(w,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}(e.faro),e.faro}e.faro={};return e.BaseExtension=H,e.BaseInstrumentation=class extends H{constructor(){super(...arguments),this.api={},this.transports={}}},e.BaseTransport=class extends H{isBatched(){return!1}getIgnoreUrls(){return[]}},e.EVENT_CLICK="click",e.EVENT_NAVIGATION="navigation",e.EVENT_OVERRIDES_SERVICE_NAME="service_name_override",e.EVENT_ROUTE_CHANGE="route_change",e.EVENT_SESSION_EXTEND="session_extend",e.EVENT_SESSION_RESUME="session_resume",e.EVENT_SESSION_START="session_start",e.EVENT_VIEW_CHANGED="view_changed",e.Observable=C,e.UserActionImportance=W,e.VERSION=ie,e.allLogLevels=j,e.clampSamplingRate=function(e){return Math.min(1,Math.max(0,e))},e.createInternalLogger=$,e.createPromiseBuffer=function(e){const{size:t,concurrency:n}=e,r=[];let i=0;const s=()=>{if(i<n&&r.length){const{producer:e,resolve:t,reject:n}=r.shift();i++,e().then(e=>{i--,s(),t(e)},e=>{i--,s(),n(e)})}};return{add:e=>{if(r.length+i>=t)throw new Error("Task buffer full");return new Promise((t,n)=>{r.push({producer:e,resolve:t,reject:n}),s()})}}},e.dateNow=O,e.deepEqual=I,e.defaultBatchingConfig={enabled:!0,sendTimeout:250,itemLimit:50},e.defaultErrorArgsSerializer=e=>e.map(e=>g(e)?U(e):String(e)).join(" "),e.defaultExceptionType=Z,e.defaultGlobalObjectKey="faro",e.defaultInternalLoggerLevel=M,e.defaultLogArgsSerializer=ne,e.defaultLogLevel=L,e.defaultUnpatchedConsole=F,e.genShortID=N,e.getCircularDependencyReplacer=R,e.getCurrentTimestamp=T,e.getInternalFaroFromGlobalObject=function(){return w[se]},e.getTransportBody=function(t){let n={meta:{}};return void 0!==t[0]&&(n.meta=t[0].meta),t.forEach(t=>{switch(t.type){case e.TransportItemType.LOG:case e.TransportItemType.EVENT:case e.TransportItemType.EXCEPTION:case e.TransportItemType.MEASUREMENT:{const e=r[t.type],i=n[e];n=Object.assign(Object.assign({},n),{[e]:void 0===i?[t.payload]:[...i,t.payload]});break}case e.TransportItemType.TRACE:n=Object.assign(Object.assign({},n),{traces:K(n.traces,t.payload.resourceSpans)})}}),n},e.globalObject=w,e.initializeFaro=function(e){const t=V(e),n=G(t,e);if(oe()&&!e.isolate)return void n.error('Faro is already registered. Either add instrumentations, transports etc. to the global faro instance or use the "isolate" property');n.debug("Initializing");const r=function(e,t){let n=[],r=[];const i=()=>n.reduce((e,t)=>Object.assign(e,p(t)?t():t),{}),s=()=>{if(r.length){const e=i();r.forEach(t=>t(e))}};return{add:(...e)=>{t.debug("Adding metas\n",e),n.push(...e),s()},remove:(...e)=>{t.debug("Removing metas\n",e),n=n.filter(t=>!e.includes(t)),s()},addListener:e=>{t.debug("Adding metas listener\n",e),r.push(e)},removeListener:e=>{t.debug("Removing metas listener\n",e),r=r.filter(t=>t!==e)},get value(){return i()}}}(0,n),s=i(t,n,e,r),a=re(0,n,e,r,s),o=function(e,t,n,r,i,s){t.debug("Initializing instrumentations");const a=[];return{add:(...o)=>{t.debug("Adding instrumentations"),o.forEach(o=>{t.debug(`Adding "${o.name}" instrumentation`),a.some(e=>e.name===o.name)?t.warn(`Instrumentation ${o.name} is already added`):(o.unpatchedConsole=e,o.internalLogger=t,o.config=n,o.metas=r,o.transports=i,o.api=s,a.push(o),o.initialize())})},get instrumentations(){return[...a]},remove:(...e)=>{t.debug("Removing instrumentations"),e.forEach(e=>{var n,r;t.debug(`Removing "${e.name}" instrumentation`);const i=a.reduce((t,n,r)=>null===t&&n.name===e.name?r:null,null);null!==i?(null===(r=(n=a[i]).destroy)||void 0===r||r.call(n),a.splice(i,1)):t.warn(`Instrumentation "${e.name}" is not added`)})}}}(t,n,e,r,s,a),u=ue(t,n,e,r,s,a,o);return function(e){var t,n;const r={sdk:{version:ie,name:"faro"},app:{bundleId:e.config.app.name&&(i=e.config.app.name,null==w?void 0:w[`__faroBundleId_${i}`])}};var i;const s=null===(t=e.config.sessionTracking)||void 0===t?void 0:t.session;s&&e.api.setSession(s),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!==(n=e.config.metas)&&void 0!==n?n:[])}(u),function(e){e.transports.add(...e.config.transports),e.transports.addBeforeSendHooks(e.config.beforeSend)}(u),function(e){e.instrumentations.add(...e.config.instrumentations)}(u),u},e.internalGlobalObjectKey=se,e.isArray=f,e.isBoolean=e=>a(e,"boolean"),e.isDomError=e=>o(e,"DOMError"),e.isDomException=e=>o(e,"DOMException"),e.isElement=e=>v&&u(e,Element),e.isElementDefined=v,e.isEmpty=y,e.isError=h,e.isErrorDefined=b,e.isErrorEvent=e=>o(e,"ErrorEvent"),e.isEvent=e=>m&&u(e,Event),e.isEventDefined=m,e.isFunction=p,e.isInstanceOf=u,e.isInt=e=>d(e)&&Number.isInteger(e),e.isInternalFaroOnGlobalObject=oe,e.isMap=e=>E&&u(e,Map),e.isMapDefined=E,e.isNull=c,e.isNumber=d,e.isObject=g,e.isPrimitive=e=>!g(e)&&!p(e),e.isRegExp=e=>o(e,"RegExp"),e.isString=l,e.isSymbol=e=>a(e,"symbol"),e.isSyntheticEvent=e=>g(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e,e.isThenable=e=>p(null==e?void 0:e.then),e.isToString=o,e.isTypeof=a,e.isUndefined=e=>a(e,"undefined"),e.noop=_,e.setInternalFaroOnGlobalObject=ae,e.stringifyExternalJson=U,e.stringifyObjectValues=k,e.transportItemTypeToBodyKey=r,e.unknownString="unknown",e.userActionsMessageBus=Q,e}({});
|
|
@@ -21,6 +21,7 @@ export interface ExceptionEventDefault {
|
|
|
21
21
|
timestamp: string;
|
|
22
22
|
type: string;
|
|
23
23
|
value: string;
|
|
24
|
+
fingerprint?: string;
|
|
24
25
|
stacktrace?: Stacktrace;
|
|
25
26
|
trace?: TraceContext;
|
|
26
27
|
context?: ExceptionContext;
|
|
@@ -36,6 +37,7 @@ export type ExceptionEventExtended = ExceptionEventDefault & {
|
|
|
36
37
|
};
|
|
37
38
|
export type ExceptionEvent<EXTENDED = ExceptionEventDefault> = EXTENDED extends boolean ? ExceptionEventExtended : ExceptionEventDefault;
|
|
38
39
|
export interface PushErrorOptions {
|
|
40
|
+
fingerprint?: string;
|
|
39
41
|
skipDedupe?: boolean;
|
|
40
42
|
stackFrames?: ExceptionStackFrame[];
|
|
41
43
|
type?: string;
|
|
@@ -19,7 +19,7 @@ export { BaseTransport, getTransportBody, TransportItemType, transportItemTypeTo
|
|
|
19
19
|
export type { BeforeSendHook, SendFn, Transport, TransportBody, TransportItem, TransportItemPayload, Transports, } from './transports';
|
|
20
20
|
export { defaultUnpatchedConsole } from './unpatchedConsole';
|
|
21
21
|
export type { UnpatchedConsole } from './unpatchedConsole';
|
|
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, isEmpty, getCircularDependencyReplacer, stringifyExternalJson, stringifyObjectValues, Observable, } from './utils';
|
|
22
|
+
export { allLogLevels, clampSamplingRate, 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, isEmpty, getCircularDependencyReplacer, stringifyExternalJson, stringifyObjectValues, Observable, } from './utils';
|
|
23
23
|
export type { BaseObject, BaseObjectKey, BaseObjectPrimitiveValue, BaseObjectValue, BufferItem, PromiseBuffer, PromiseBufferOptions, PromiseProducer, Subscription, } from './utils';
|
|
24
24
|
export { VERSION } from './version';
|
|
25
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 = "2.
|
|
7
|
+
readonly version = "2.3.0";
|
|
8
8
|
items: TransportItem[];
|
|
9
9
|
constructor(ignoreURLs?: Patterns);
|
|
10
10
|
send(items: TransportItem[]): void | Promise<void>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type { BaseObject, BaseObjectKey, BaseObjectPrimitiveValue, BaseObjectValue } from './baseObject';
|
|
2
|
+
export { clampSamplingRate } from './sampling';
|
|
2
3
|
export { deepEqual } from './deepEqual';
|
|
3
4
|
export { getCurrentTimestamp } from './date';
|
|
4
5
|
export { 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, isEmpty, } from './is';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function clampSamplingRate(samplingRate: number): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "2.
|
|
1
|
+
export declare const VERSION = "2.3.0";
|
|
@@ -32,7 +32,7 @@ function initializeExceptionsAPI(_a) {
|
|
|
32
32
|
var getStacktraceParser = function () { return stacktraceParser; };
|
|
33
33
|
var _c = config.ignoreErrors, ignoreErrors = _c === void 0 ? [] : _c, preserveOriginalError = config.preserveOriginalError;
|
|
34
34
|
var pushError = function (error, _a) {
|
|
35
|
-
var _b = _a === void 0 ? {} : _a, skipDedupe = _b.skipDedupe, stackFrames = _b.stackFrames, type = _b.type, context = _b.context, spanContext = _b.spanContext, timestampOverwriteMs = _b.timestampOverwriteMs, originalError = _b.originalError;
|
|
35
|
+
var _b = _a === void 0 ? {} : _a, skipDedupe = _b.skipDedupe, stackFrames = _b.stackFrames, type = _b.type, context = _b.context, spanContext = _b.spanContext, timestampOverwriteMs = _b.timestampOverwriteMs, originalError = _b.originalError, fingerprint = _b.fingerprint;
|
|
36
36
|
if (isErrorIgnored(ignoreErrors, originalError !== null && originalError !== void 0 ? originalError : error)) {
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
@@ -40,12 +40,12 @@ function initializeExceptionsAPI(_a) {
|
|
|
40
40
|
var ctx = (0, utils_1.stringifyObjectValues)(__assign(__assign({}, parseCause(originalError !== null && originalError !== void 0 ? originalError : error)), (context !== null && context !== void 0 ? context : {})));
|
|
41
41
|
var item = {
|
|
42
42
|
meta: metas.value,
|
|
43
|
-
payload: __assign(__assign({ type: type || error.name || const_1.defaultExceptionType, value: error.message, timestamp: timestampOverwriteMs ? (0, date_1.timestampToIsoString)(timestampOverwriteMs) : (0, utils_1.getCurrentTimestamp)(), trace: spanContext
|
|
43
|
+
payload: __assign(__assign(__assign({ type: type || error.name || const_1.defaultExceptionType, value: error.message, timestamp: timestampOverwriteMs ? (0, date_1.timestampToIsoString)(timestampOverwriteMs) : (0, utils_1.getCurrentTimestamp)(), trace: spanContext
|
|
44
44
|
? {
|
|
45
45
|
trace_id: spanContext.traceId,
|
|
46
46
|
span_id: spanContext.spanId,
|
|
47
47
|
}
|
|
48
|
-
: tracesApi.getTraceContext() }, ((0, utils_1.isEmpty)(ctx) ? {} : { context: ctx })), (preserveOriginalError ? { originalError: originalError } : {})),
|
|
48
|
+
: tracesApi.getTraceContext() }, ((0, utils_1.isEmpty)(ctx) ? {} : { context: ctx })), (preserveOriginalError ? { originalError: originalError } : {})), (fingerprint ? { fingerprint: fingerprint } : {})),
|
|
49
49
|
type: transports_1.TransportItemType.EXCEPTION,
|
|
50
50
|
};
|
|
51
51
|
stackFrames = stackFrames !== null && stackFrames !== void 0 ? stackFrames : (error.stack ? stacktraceParser === null || stacktraceParser === void 0 ? void 0 : stacktraceParser(error).frames : undefined);
|
|
@@ -59,6 +59,7 @@ function initializeExceptionsAPI(_a) {
|
|
|
59
59
|
value: item.payload.value,
|
|
60
60
|
stackTrace: item.payload.stacktrace,
|
|
61
61
|
context: item.payload.context,
|
|
62
|
+
fingerprint: item.payload.fingerprint,
|
|
62
63
|
};
|
|
63
64
|
if (!skipDedupe && config.dedupe && !(0, utils_1.isNull)(lastPayload) && (0, utils_1.deepEqual)(testingPayload, lastPayload)) {
|
|
64
65
|
internalLogger.debug('Skipping error push because it is the same as the last one\n', item.payload);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/exceptions/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;;;AA4BA,
|
|
1
|
+
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/exceptions/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;;;AA4BA,0DAyGC;AAlID,+CAAqD;AAGrD,qCAUqB;AACrB,yCAAwD;AAGxD,wDAAsE;AACtE,kCAA6C;AAE7C,iCAA+C;AAG/C,IAAI,gBAA8C,CAAC;AAEnD,SAAgB,uBAAuB,CAAC,EAevC;;QAdC,cAAc,oBAAA,EACd,MAAM,YAAA,EACN,KAAK,WAAA,EACL,UAAU,gBAAA,EACV,SAAS,eAAA,EACT,cAAc,oBAAA;IAUd,cAAc,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAEpD,IAAI,WAAW,GAA6F,IAAI,CAAC;IAEjH,gBAAgB,GAAG,MAAA,MAAM,CAAC,eAAe,mCAAI,gBAAgB,CAAC;IAE9D,IAAM,sBAAsB,GAA4C,UAAC,mBAAmB;QAC1F,cAAc,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAEnD,gBAAgB,GAAG,mBAAmB,aAAnB,mBAAmB,cAAnB,mBAAmB,GAAI,gBAAgB,CAAC;IAC7D,CAAC,CAAC;IAEF,IAAM,mBAAmB,GAAyC,cAAM,OAAA,gBAAgB,EAAhB,CAAgB,CAAC;IAEjF,IAAA,KAA6C,MAAM,aAAlC,EAAjB,YAAY,mBAAG,EAAE,KAAA,EAAE,qBAAqB,GAAK,MAAM,sBAAX,CAAY;IAE5D,IAAM,SAAS,GAA+B,UAC5C,KAAK,EACL,EAA8G;YAA9G,qBAA4G,EAAE,KAAA,EAA5G,UAAU,gBAAA,EAAE,WAAW,iBAAA,EAAE,IAAI,UAAA,EAAE,OAAO,aAAA,EAAE,WAAW,iBAAA,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CAAC,CAAC;IAEF,sBAAsB,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAE/C,OAAO;QACL,sBAAsB,wBAAA;QACtB,mBAAmB,qBAAA;QACnB,SAAS,WAAA;KACV,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,KAA+B;IACjD,IAAI,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAExB,IAAI,IAAA,eAAO,EAAC,KAAK,CAAC,EAAE,CAAC;QACnB,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC/B,wKAAwK;QACxK,sGAAsG;IACxG,CAAC;SAAM,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,IAAA,gBAAQ,EAAC,KAAK,CAAC,KAAK,CAAC,IAAI,IAAA,eAAO,EAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QAC7E,KAAK,GAAG,IAAA,6BAAqB,EAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;SAAM,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QACzB,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IACjC,CAAC;IAED,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,OAAA,EAAE,CAAC;AACxC,CAAC;AAED,SAAS,cAAc,CAAC,YAAsB,EAAE,KAA+B;IACrE,IAAA,OAAO,GAAkB,KAAK,QAAvB,EAAE,IAAI,GAAY,KAAK,KAAjB,EAAE,KAAK,GAAK,KAAK,MAAV,CAAW;IACvC,OAAO,IAAA,yBAAiB,EAAC,YAAY,EAAE,OAAO,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import type { Config, Patterns } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItemType } from '../../transports';\nimport type { TransportItem, Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport {\n deepEqual,\n getCurrentTimestamp,\n isArray,\n isEmpty,\n isError,\n isNull,\n isObject,\n stringifyExternalJson,\n stringifyObjectValues,\n} from '../../utils';\nimport { timestampToIsoString } from '../../utils/date';\nimport type { TracesAPI } from '../traces';\nimport type { UserActionsAPI } from '../userActions';\nimport { addItemToUserActionBuffer } from '../userActions/initialize';\nimport { shouldIgnoreEvent } from '../utils';\n\nimport { defaultExceptionType } from './const';\nimport type { ErrorWithIndexProperties, ExceptionEvent, ExceptionsAPI, StacktraceParser } from './types';\n\nlet stacktraceParser: StacktraceParser | undefined;\n\nexport function initializeExceptionsAPI({\n internalLogger,\n config,\n metas,\n transports,\n tracesApi,\n userActionsApi,\n}: {\n unpatchedConsole: UnpatchedConsole;\n internalLogger: InternalLogger;\n config: Config;\n metas: Metas;\n transports: Transports;\n tracesApi: TracesAPI;\n userActionsApi: UserActionsAPI;\n}): ExceptionsAPI {\n internalLogger.debug('Initializing exceptions API');\n\n let lastPayload: Pick<ExceptionEvent, 'type' | 'value' | 'stacktrace' | 'context' | 'fingerprint'> | null = null;\n\n stacktraceParser = config.parseStacktrace ?? stacktraceParser;\n\n const changeStacktraceParser: ExceptionsAPI['changeStacktraceParser'] = (newStacktraceParser) => {\n internalLogger.debug('Changing stacktrace parser');\n\n stacktraceParser = newStacktraceParser ?? stacktraceParser;\n };\n\n const getStacktraceParser: ExceptionsAPI['getStacktraceParser'] = () => stacktraceParser;\n\n const { ignoreErrors = [], preserveOriginalError } = config;\n\n const pushError: ExceptionsAPI['pushError'] = (\n error,\n { skipDedupe, stackFrames, type, context, spanContext, timestampOverwriteMs, originalError, fingerprint } = {}\n ) => {\n if (isErrorIgnored(ignoreErrors, originalError ?? error)) {\n return;\n }\n try {\n const ctx = stringifyObjectValues({\n ...parseCause(originalError ?? error),\n ...(context ?? {}),\n });\n\n const item: TransportItem<ExceptionEvent<typeof preserveOriginalError>> = {\n meta: metas.value,\n payload: {\n type: type || error.name || defaultExceptionType,\n value: error.message,\n timestamp: timestampOverwriteMs ? timestampToIsoString(timestampOverwriteMs) : getCurrentTimestamp(),\n trace: spanContext\n ? {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n }\n : tracesApi.getTraceContext(),\n ...(isEmpty(ctx) ? {} : { context: ctx }),\n ...(preserveOriginalError ? { originalError } : {}),\n ...(fingerprint ? { fingerprint } : {}),\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 fingerprint: item.payload.fingerprint,\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 if (!addItemToUserActionBuffer(userActionsApi.getActiveUserAction(), item)) {\n transports.execute(item);\n }\n } catch (err) {\n internalLogger.error('Error pushing event', err);\n }\n };\n\n changeStacktraceParser(config.parseStacktrace);\n\n return {\n changeStacktraceParser,\n getStacktraceParser,\n pushError,\n };\n}\n\nfunction parseCause(error: ErrorWithIndexProperties): {} | { cause: string } {\n let cause = error.cause;\n\n if (isError(cause)) {\n cause = error.cause.toString();\n // typeof operator on null returns \"object\". This is a well-known quirk in JavaScript and is considered a bug that cannot be fixed due to backward compatibility issues.\n // MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#typeof_null\n } else if (cause !== null && (isObject(error.cause) || isArray(error.cause))) {\n cause = stringifyExternalJson(error.cause);\n } else if (cause != null) {\n cause = error.cause.toString();\n }\n\n return cause == null ? {} : { cause };\n}\n\nfunction isErrorIgnored(ignoreErrors: Patterns, error: ErrorWithIndexProperties): boolean {\n const { message, name, stack } = error;\n return shouldIgnoreEvent(ignoreErrors, message + ' ' + name + ' ' + stack);\n}\n"]}
|
|
@@ -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';\nimport type { UserAction } from '../types';\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 ExceptionEventDefault {\n timestamp: string;\n type: string;\n value: string;\n\n stacktrace?: Stacktrace;\n trace?: TraceContext;\n context?: ExceptionContext;\n\n action?: UserAction;\n}\n\n/**\n * The ExceptionEventExtended type is used to represent an exception event with an additional error\n * property and is only meant for client side use. The additional property is removed by Faro before\n * sending the event to the transport.\n */\nexport type ExceptionEventExtended = ExceptionEventDefault & {\n originalError?: Error;\n};\n\nexport type ExceptionEvent<EXTENDED = ExceptionEventDefault> = EXTENDED extends boolean\n ? ExceptionEventExtended\n : ExceptionEventDefault;\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 * Retains the original error object in the payload after parsing.\n * This is primarily for internal, advanced use cases.\n * Faro users should not need to use this option.\n */\n originalError?: Error;\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"]}
|
|
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';\nimport type { UserAction } from '../types';\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 ExceptionEventDefault {\n timestamp: string;\n type: string;\n value: string;\n\n fingerprint?: string;\n stacktrace?: Stacktrace;\n trace?: TraceContext;\n context?: ExceptionContext;\n\n action?: UserAction;\n}\n\n/**\n * The ExceptionEventExtended type is used to represent an exception event with an additional error\n * property and is only meant for client side use. The additional property is removed by Faro before\n * sending the event to the transport.\n */\nexport type ExceptionEventExtended = ExceptionEventDefault & {\n originalError?: Error;\n};\n\nexport type ExceptionEvent<EXTENDED = ExceptionEventDefault> = EXTENDED extends boolean\n ? ExceptionEventExtended\n : ExceptionEventDefault;\n\nexport interface PushErrorOptions {\n fingerprint?: string;\n skipDedupe?: boolean;\n stackFrames?: ExceptionStackFrame[];\n type?: string;\n context?: ExceptionContext;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n timestampOverwriteMs?: number;\n /**\n * Retains the original error object in the payload after parsing.\n * This is primarily for internal, advanced use cases.\n * Faro users should not need to use this option.\n */\n originalError?: Error;\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"]}
|
package/dist/cjs/index.js
CHANGED
|
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
18
|
-
exports.unknownString = exports.VERSION = exports.Observable = exports.stringifyObjectValues = exports.stringifyExternalJson = exports.getCircularDependencyReplacer = exports.isEmpty = exports.dateNow = exports.noop = exports.LogLevel = exports.isUndefined = exports.isTypeof = exports.isToString = exports.isThenable = exports.isSyntheticEvent = exports.isSymbol = exports.isString = exports.isRegExp = exports.isPrimitive = void 0;
|
|
17
|
+
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.clampSamplingRate = 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.userActionsMessageBus = exports.UserActionState = exports.UserActionImportance = exports.defaultErrorArgsSerializer = exports.defaultLogArgsSerializer = exports.defaultExceptionType = void 0;
|
|
18
|
+
exports.unknownString = exports.VERSION = exports.Observable = exports.stringifyObjectValues = exports.stringifyExternalJson = exports.getCircularDependencyReplacer = exports.isEmpty = exports.dateNow = exports.noop = exports.LogLevel = exports.isUndefined = exports.isTypeof = exports.isToString = exports.isThenable = exports.isSyntheticEvent = exports.isSymbol = exports.isString = exports.isRegExp = exports.isPrimitive = exports.isObject = 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; } });
|
|
@@ -54,6 +54,7 @@ var unpatchedConsole_1 = require("./unpatchedConsole");
|
|
|
54
54
|
Object.defineProperty(exports, "defaultUnpatchedConsole", { enumerable: true, get: function () { return unpatchedConsole_1.defaultUnpatchedConsole; } });
|
|
55
55
|
var utils_1 = require("./utils");
|
|
56
56
|
Object.defineProperty(exports, "allLogLevels", { enumerable: true, get: function () { return utils_1.allLogLevels; } });
|
|
57
|
+
Object.defineProperty(exports, "clampSamplingRate", { enumerable: true, get: function () { return utils_1.clampSamplingRate; } });
|
|
57
58
|
Object.defineProperty(exports, "createPromiseBuffer", { enumerable: true, get: function () { return utils_1.createPromiseBuffer; } });
|
|
58
59
|
Object.defineProperty(exports, "deepEqual", { enumerable: true, get: function () { return utils_1.deepEqual; } });
|
|
59
60
|
Object.defineProperty(exports, "defaultLogLevel", { enumerable: true, get: function () { return utils_1.defaultLogLevel; } });
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,6BAQe;AAPb,2GAAA,oBAAoB,OAAA;AACpB,+GAAA,wBAAwB,OAAA;AACxB,iHAAA,0BAA0B,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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;AACP,gGAAA,OAAO,OAAA;AACP,sHAAA,6BAA6B,OAAA;AAC7B,8GAAA,qBAAqB,OAAA;AACrB,8GAAA,qBAAqB,OAAA;AACrB,mGAAA,UAAU,OAAA;AAcZ,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAEhB,mCAAyC;AAAhC,uGAAA,aAAa,OAAA","sourcesContent":["export {\n defaultExceptionType,\n defaultLogArgsSerializer,\n defaultErrorArgsSerializer,\n UserActionImportance,\n type UserActionImportanceType,\n UserActionState,\n userActionsMessageBus,\n} from './api';\nexport type {\n API,\n APIEvent,\n EventAttributes,\n EventEvent,\n EventsAPI,\n ExceptionEvent,\n ExceptionEventExtended,\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 UserAction,\n UserActionInterface,\n UserActionInternalInterface,\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 MetaOverrides,\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 clampSamplingRate,\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 isEmpty,\n getCircularDependencyReplacer,\n stringifyExternalJson,\n stringifyObjectValues,\n Observable,\n} from './utils';\nexport type {\n BaseObject,\n BaseObjectKey,\n BaseObjectPrimitiveValue,\n BaseObjectValue,\n BufferItem,\n PromiseBuffer,\n PromiseBufferOptions,\n PromiseProducer,\n Subscription,\n} from './utils';\n\nexport { VERSION } from './version';\n\nexport { unknownString } from './consts';\n"]}
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Observable = exports.stringifyObjectValues = exports.stringifyExternalJson = exports.getCircularDependencyReplacer = exports.dateNow = exports.getBundleId = exports.genShortID = exports.createPromiseBuffer = exports.noop = exports.LogLevel = exports.defaultLogLevel = exports.allLogLevels = exports.isEmpty = exports.isUndefined = exports.isTypeof = exports.isToString = exports.isThenable = exports.isSyntheticEvent = 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.deepEqual = void 0;
|
|
3
|
+
exports.Observable = exports.stringifyObjectValues = exports.stringifyExternalJson = exports.getCircularDependencyReplacer = exports.dateNow = exports.getBundleId = exports.genShortID = exports.createPromiseBuffer = exports.noop = exports.LogLevel = exports.defaultLogLevel = exports.allLogLevels = exports.isEmpty = exports.isUndefined = exports.isTypeof = exports.isToString = exports.isThenable = exports.isSyntheticEvent = 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.deepEqual = exports.clampSamplingRate = void 0;
|
|
4
|
+
var sampling_1 = require("./sampling");
|
|
5
|
+
Object.defineProperty(exports, "clampSamplingRate", { enumerable: true, get: function () { return sampling_1.clampSamplingRate; } });
|
|
4
6
|
var deepEqual_1 = require("./deepEqual");
|
|
5
7
|
Object.defineProperty(exports, "deepEqual", { enumerable: true, get: function () { return deepEqual_1.deepEqual; } });
|
|
6
8
|
var date_1 = require("./date");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAEA,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAElB,+BAA6C;AAApC,2GAAA,mBAAmB,OAAA;AAE5B,2BA8Bc;AA7BZ,6FAAA,OAAO,OAAA;AACP,+FAAA,SAAS,OAAA;AACT,gGAAA,UAAU,OAAA;AACV,oGAAA,cAAc,OAAA;AACd,+FAAA,SAAS,OAAA;AACT,sGAAA,gBAAgB,OAAA;AAChB,6FAAA,OAAO,OAAA;AACP,oGAAA,cAAc,OAAA;AACd,kGAAA,YAAY,OAAA;AACZ,6FAAA,OAAO,OAAA;AACP,oGAAA,cAAc,OAAA;AACd,gGAAA,UAAU,OAAA;AACV,kGAAA,YAAY,OAAA;AACZ,2FAAA,KAAK,OAAA;AACL,2FAAA,KAAK,OAAA;AACL,kGAAA,YAAY,OAAA;AACZ,4FAAA,MAAM,OAAA;AACN,8FAAA,QAAQ,OAAA;AACR,8FAAA,QAAQ,OAAA;AACR,iGAAA,WAAW,OAAA;AACX,8FAAA,QAAQ,OAAA;AACR,8FAAA,QAAQ,OAAA;AACR,8FAAA,QAAQ,OAAA;AACR,sGAAA,gBAAgB,OAAA;AAChB,gGAAA,UAAU,OAAA;AACV,gGAAA,UAAU,OAAA;AACV,8FAAA,QAAQ,OAAA;AACR,iGAAA,WAAW,OAAA;AACX,6FAAA,OAAO,OAAA;AAIT,yCAAsE;AAA7D,yGAAA,YAAY,OAAA;AAAE,4GAAA,eAAe,OAAA;AAAE,qGAAA,QAAQ,OAAA;AAEhD,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AAEb,iDAAsD;AAA7C,oHAAA,mBAAmB,OAAA;AAG5B,qCAAuC;AAA9B,qGAAA,UAAU,OAAA;AAEnB,2CAA2C;AAAlC,yGAAA,WAAW,OAAA;AAEpB,+BAAiC;AAAxB,+FAAA,OAAO,OAAA;AAEhB,+BAAqG;AAA5F,qHAAA,6BAA6B,OAAA;AAAE,6GAAA,qBAAqB,OAAA;AAAE,6GAAA,qBAAqB,OAAA;AAEpF,uCAAwC;AAA/B,sGAAA,UAAU,OAAA","sourcesContent":["export type { BaseObject, BaseObjectKey, BaseObjectPrimitiveValue, BaseObjectValue } from './baseObject';\n\nexport { deepEqual } from './deepEqual';\n\nexport { getCurrentTimestamp } from './date';\n\nexport {\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 isEmpty,\n} from './is';\nexport type { IsFnHelper } from './is';\n\nexport { allLogLevels, defaultLogLevel, LogLevel } from './logLevels';\n\nexport { noop } from './noop';\n\nexport { createPromiseBuffer } from './promiseBuffer';\nexport type { BufferItem, PromiseBuffer, PromiseBufferOptions, PromiseProducer } from './promiseBuffer';\n\nexport { genShortID } from './shortId';\n\nexport { getBundleId } from './sourceMaps';\n\nexport { dateNow } from './date';\n\nexport { getCircularDependencyReplacer, stringifyExternalJson, stringifyObjectValues } from './json';\n\nexport { Observable } from './reactive';\nexport type { Subscription } from './reactive';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAEA,uCAA+C;AAAtC,6GAAA,iBAAiB,OAAA;AAE1B,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAElB,+BAA6C;AAApC,2GAAA,mBAAmB,OAAA;AAE5B,2BA8Bc;AA7BZ,6FAAA,OAAO,OAAA;AACP,+FAAA,SAAS,OAAA;AACT,gGAAA,UAAU,OAAA;AACV,oGAAA,cAAc,OAAA;AACd,+FAAA,SAAS,OAAA;AACT,sGAAA,gBAAgB,OAAA;AAChB,6FAAA,OAAO,OAAA;AACP,oGAAA,cAAc,OAAA;AACd,kGAAA,YAAY,OAAA;AACZ,6FAAA,OAAO,OAAA;AACP,oGAAA,cAAc,OAAA;AACd,gGAAA,UAAU,OAAA;AACV,kGAAA,YAAY,OAAA;AACZ,2FAAA,KAAK,OAAA;AACL,2FAAA,KAAK,OAAA;AACL,kGAAA,YAAY,OAAA;AACZ,4FAAA,MAAM,OAAA;AACN,8FAAA,QAAQ,OAAA;AACR,8FAAA,QAAQ,OAAA;AACR,iGAAA,WAAW,OAAA;AACX,8FAAA,QAAQ,OAAA;AACR,8FAAA,QAAQ,OAAA;AACR,8FAAA,QAAQ,OAAA;AACR,sGAAA,gBAAgB,OAAA;AAChB,gGAAA,UAAU,OAAA;AACV,gGAAA,UAAU,OAAA;AACV,8FAAA,QAAQ,OAAA;AACR,iGAAA,WAAW,OAAA;AACX,6FAAA,OAAO,OAAA;AAIT,yCAAsE;AAA7D,yGAAA,YAAY,OAAA;AAAE,4GAAA,eAAe,OAAA;AAAE,qGAAA,QAAQ,OAAA;AAEhD,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AAEb,iDAAsD;AAA7C,oHAAA,mBAAmB,OAAA;AAG5B,qCAAuC;AAA9B,qGAAA,UAAU,OAAA;AAEnB,2CAA2C;AAAlC,yGAAA,WAAW,OAAA;AAEpB,+BAAiC;AAAxB,+FAAA,OAAO,OAAA;AAEhB,+BAAqG;AAA5F,qHAAA,6BAA6B,OAAA;AAAE,6GAAA,qBAAqB,OAAA;AAAE,6GAAA,qBAAqB,OAAA;AAEpF,uCAAwC;AAA/B,sGAAA,UAAU,OAAA","sourcesContent":["export type { BaseObject, BaseObjectKey, BaseObjectPrimitiveValue, BaseObjectValue } from './baseObject';\n\nexport { clampSamplingRate } from './sampling';\n\nexport { deepEqual } from './deepEqual';\n\nexport { getCurrentTimestamp } from './date';\n\nexport {\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 isEmpty,\n} from './is';\nexport type { IsFnHelper } from './is';\n\nexport { allLogLevels, defaultLogLevel, LogLevel } from './logLevels';\n\nexport { noop } from './noop';\n\nexport { createPromiseBuffer } from './promiseBuffer';\nexport type { BufferItem, PromiseBuffer, PromiseBufferOptions, PromiseProducer } from './promiseBuffer';\n\nexport { genShortID } from './shortId';\n\nexport { getBundleId } from './sourceMaps';\n\nexport { dateNow } from './date';\n\nexport { getCircularDependencyReplacer, stringifyExternalJson, stringifyObjectValues } from './json';\n\nexport { Observable } from './reactive';\nexport type { Subscription } from './reactive';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sampling.js","sourceRoot":"","sources":["../../../src/utils/sampling.ts"],"names":[],"mappings":";;AAAA,8CAEC;AAFD,SAAgB,iBAAiB,CAAC,YAAoB;IACpD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC;AAChD,CAAC","sourcesContent":["export function clampSamplingRate(samplingRate: number): number {\n return Math.min(1, Math.max(0, samplingRate));\n}\n"]}
|
package/dist/cjs/version.js
CHANGED
package/dist/cjs/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '2.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '2.3.0';\n"]}
|
|
@@ -16,7 +16,7 @@ export function initializeExceptionsAPI({ internalLogger, config, metas, transpo
|
|
|
16
16
|
};
|
|
17
17
|
const getStacktraceParser = () => stacktraceParser;
|
|
18
18
|
const { ignoreErrors = [], preserveOriginalError } = config;
|
|
19
|
-
const pushError = (error, { skipDedupe, stackFrames, type, context, spanContext, timestampOverwriteMs, originalError } = {}) => {
|
|
19
|
+
const pushError = (error, { skipDedupe, stackFrames, type, context, spanContext, timestampOverwriteMs, originalError, fingerprint } = {}) => {
|
|
20
20
|
if (isErrorIgnored(ignoreErrors, originalError !== null && originalError !== void 0 ? originalError : error)) {
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
@@ -24,12 +24,12 @@ export function initializeExceptionsAPI({ internalLogger, config, metas, transpo
|
|
|
24
24
|
const ctx = stringifyObjectValues(Object.assign(Object.assign({}, parseCause(originalError !== null && originalError !== void 0 ? originalError : error)), (context !== null && context !== void 0 ? context : {})));
|
|
25
25
|
const item = {
|
|
26
26
|
meta: metas.value,
|
|
27
|
-
payload: Object.assign(Object.assign({ type: type || error.name || defaultExceptionType, value: error.message, timestamp: timestampOverwriteMs ? timestampToIsoString(timestampOverwriteMs) : getCurrentTimestamp(), trace: spanContext
|
|
27
|
+
payload: Object.assign(Object.assign(Object.assign({ type: type || error.name || defaultExceptionType, value: error.message, timestamp: timestampOverwriteMs ? timestampToIsoString(timestampOverwriteMs) : getCurrentTimestamp(), trace: spanContext
|
|
28
28
|
? {
|
|
29
29
|
trace_id: spanContext.traceId,
|
|
30
30
|
span_id: spanContext.spanId,
|
|
31
31
|
}
|
|
32
|
-
: tracesApi.getTraceContext() }, (isEmpty(ctx) ? {} : { context: ctx })), (preserveOriginalError ? { originalError } : {})),
|
|
32
|
+
: tracesApi.getTraceContext() }, (isEmpty(ctx) ? {} : { context: ctx })), (preserveOriginalError ? { originalError } : {})), (fingerprint ? { fingerprint } : {})),
|
|
33
33
|
type: TransportItemType.EXCEPTION,
|
|
34
34
|
};
|
|
35
35
|
stackFrames = stackFrames !== null && stackFrames !== void 0 ? stackFrames : (error.stack ? stacktraceParser === null || stacktraceParser === void 0 ? void 0 : stacktraceParser(error).frames : undefined);
|
|
@@ -43,6 +43,7 @@ export function initializeExceptionsAPI({ internalLogger, config, metas, transpo
|
|
|
43
43
|
value: item.payload.value,
|
|
44
44
|
stackTrace: item.payload.stacktrace,
|
|
45
45
|
context: item.payload.context,
|
|
46
|
+
fingerprint: item.payload.fingerprint,
|
|
46
47
|
};
|
|
47
48
|
if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {
|
|
48
49
|
internalLogger.debug('Skipping error push because it is the same as the last one\n', item.payload);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/exceptions/initialize.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,OAAO,EACP,OAAO,EACP,OAAO,EACP,MAAM,EACN,QAAQ,EACR,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAG/C,IAAI,gBAA8C,CAAC;AAEnD,MAAM,UAAU,uBAAuB,CAAC,EACtC,cAAc,EACd,MAAM,EACN,KAAK,EACL,UAAU,EACV,SAAS,EACT,cAAc,GASf;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AAC;QACnD,CAAC;IACH,CAAC,CAAC;IAEF,sBAAsB,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAE/C,OAAO;QACL,sBAAsB;QACtB,mBAAmB;QACnB,SAAS;KACV,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,KAA+B;IACjD,IAAI,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAExB,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACnB,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC/B,wKAAwK;QACxK,sGAAsG;IACxG,CAAC;SAAM,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QAC7E,KAAK,GAAG,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;SAAM,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QACzB,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IACjC,CAAC;IAED,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;AACxC,CAAC;AAED,SAAS,cAAc,CAAC,YAAsB,EAAE,KAA+B;IAC7E,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IACvC,OAAO,iBAAiB,CAAC,YAAY,EAAE,OAAO,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import type { Config, Patterns } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItemType } from '../../transports';\nimport type { TransportItem, Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport {\n deepEqual,\n getCurrentTimestamp,\n isArray,\n isEmpty,\n isError,\n isNull,\n isObject,\n stringifyExternalJson,\n stringifyObjectValues,\n} from '../../utils';\nimport { timestampToIsoString } from '../../utils/date';\nimport type { TracesAPI } from '../traces';\nimport type { UserActionsAPI } from '../userActions';\nimport { addItemToUserActionBuffer } from '../userActions/initialize';\nimport { shouldIgnoreEvent } from '../utils';\n\nimport { defaultExceptionType } from './const';\nimport type { ErrorWithIndexProperties, ExceptionEvent, ExceptionsAPI, StacktraceParser } from './types';\n\nlet stacktraceParser: StacktraceParser | undefined;\n\nexport function initializeExceptionsAPI({\n internalLogger,\n config,\n metas,\n transports,\n tracesApi,\n userActionsApi,\n}: {\n unpatchedConsole: UnpatchedConsole;\n internalLogger: InternalLogger;\n config: Config;\n metas: Metas;\n transports: Transports;\n tracesApi: TracesAPI;\n userActionsApi: UserActionsAPI;\n}): ExceptionsAPI {\n internalLogger.debug('Initializing exceptions API');\n\n let lastPayload: Pick<ExceptionEvent, 'type' | 'value' | 'stacktrace' | 'context' | 'fingerprint'> | null = null;\n\n stacktraceParser = config.parseStacktrace ?? stacktraceParser;\n\n const changeStacktraceParser: ExceptionsAPI['changeStacktraceParser'] = (newStacktraceParser) => {\n internalLogger.debug('Changing stacktrace parser');\n\n stacktraceParser = newStacktraceParser ?? stacktraceParser;\n };\n\n const getStacktraceParser: ExceptionsAPI['getStacktraceParser'] = () => stacktraceParser;\n\n const { ignoreErrors = [], preserveOriginalError } = config;\n\n const pushError: ExceptionsAPI['pushError'] = (\n error,\n { skipDedupe, stackFrames, type, context, spanContext, timestampOverwriteMs, originalError, fingerprint } = {}\n ) => {\n if (isErrorIgnored(ignoreErrors, originalError ?? error)) {\n return;\n }\n try {\n const ctx = stringifyObjectValues({\n ...parseCause(originalError ?? error),\n ...(context ?? {}),\n });\n\n const item: TransportItem<ExceptionEvent<typeof preserveOriginalError>> = {\n meta: metas.value,\n payload: {\n type: type || error.name || defaultExceptionType,\n value: error.message,\n timestamp: timestampOverwriteMs ? timestampToIsoString(timestampOverwriteMs) : getCurrentTimestamp(),\n trace: spanContext\n ? {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n }\n : tracesApi.getTraceContext(),\n ...(isEmpty(ctx) ? {} : { context: ctx }),\n ...(preserveOriginalError ? { originalError } : {}),\n ...(fingerprint ? { fingerprint } : {}),\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 fingerprint: item.payload.fingerprint,\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 if (!addItemToUserActionBuffer(userActionsApi.getActiveUserAction(), item)) {\n transports.execute(item);\n }\n } catch (err) {\n internalLogger.error('Error pushing event', err);\n }\n };\n\n changeStacktraceParser(config.parseStacktrace);\n\n return {\n changeStacktraceParser,\n getStacktraceParser,\n pushError,\n };\n}\n\nfunction parseCause(error: ErrorWithIndexProperties): {} | { cause: string } {\n let cause = error.cause;\n\n if (isError(cause)) {\n cause = error.cause.toString();\n // typeof operator on null returns \"object\". This is a well-known quirk in JavaScript and is considered a bug that cannot be fixed due to backward compatibility issues.\n // MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#typeof_null\n } else if (cause !== null && (isObject(error.cause) || isArray(error.cause))) {\n cause = stringifyExternalJson(error.cause);\n } else if (cause != null) {\n cause = error.cause.toString();\n }\n\n return cause == null ? {} : { cause };\n}\n\nfunction isErrorIgnored(ignoreErrors: Patterns, error: ErrorWithIndexProperties): boolean {\n const { message, name, stack } = error;\n return shouldIgnoreEvent(ignoreErrors, message + ' ' + name + ' ' + stack);\n}\n"]}
|
|
@@ -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';\nimport type { UserAction } from '../types';\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 ExceptionEventDefault {\n timestamp: string;\n type: string;\n value: string;\n\n stacktrace?: Stacktrace;\n trace?: TraceContext;\n context?: ExceptionContext;\n\n action?: UserAction;\n}\n\n/**\n * The ExceptionEventExtended type is used to represent an exception event with an additional error\n * property and is only meant for client side use. The additional property is removed by Faro before\n * sending the event to the transport.\n */\nexport type ExceptionEventExtended = ExceptionEventDefault & {\n originalError?: Error;\n};\n\nexport type ExceptionEvent<EXTENDED = ExceptionEventDefault> = EXTENDED extends boolean\n ? ExceptionEventExtended\n : ExceptionEventDefault;\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 * Retains the original error object in the payload after parsing.\n * This is primarily for internal, advanced use cases.\n * Faro users should not need to use this option.\n */\n originalError?: Error;\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"]}
|
|
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';\nimport type { UserAction } from '../types';\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 ExceptionEventDefault {\n timestamp: string;\n type: string;\n value: string;\n\n fingerprint?: string;\n stacktrace?: Stacktrace;\n trace?: TraceContext;\n context?: ExceptionContext;\n\n action?: UserAction;\n}\n\n/**\n * The ExceptionEventExtended type is used to represent an exception event with an additional error\n * property and is only meant for client side use. The additional property is removed by Faro before\n * sending the event to the transport.\n */\nexport type ExceptionEventExtended = ExceptionEventDefault & {\n originalError?: Error;\n};\n\nexport type ExceptionEvent<EXTENDED = ExceptionEventDefault> = EXTENDED extends boolean\n ? ExceptionEventExtended\n : ExceptionEventDefault;\n\nexport interface PushErrorOptions {\n fingerprint?: string;\n skipDedupe?: boolean;\n stackFrames?: ExceptionStackFrame[];\n type?: string;\n context?: ExceptionContext;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n timestampOverwriteMs?: number;\n /**\n * Retains the original error object in the payload after parsing.\n * This is primarily for internal, advanced use cases.\n * Faro users should not need to use this option.\n */\n originalError?: Error;\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"]}
|
package/dist/esm/index.js
CHANGED
|
@@ -9,7 +9,7 @@ export { faro, getInternalFaroFromGlobalObject, internalGlobalObjectKey, isInter
|
|
|
9
9
|
export * from './semantic';
|
|
10
10
|
export { BaseTransport, getTransportBody, TransportItemType, transportItemTypeToBodyKey } from './transports';
|
|
11
11
|
export { defaultUnpatchedConsole } from './unpatchedConsole';
|
|
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, isEmpty, getCircularDependencyReplacer, stringifyExternalJson, stringifyObjectValues, Observable, } from './utils';
|
|
12
|
+
export { allLogLevels, clampSamplingRate, 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, isEmpty, getCircularDependencyReplacer, stringifyExternalJson, stringifyObjectValues, Observable, } from './utils';
|
|
13
13
|
export { VERSION } from './version';
|
|
14
14
|
export { unknownString } from './consts';
|
|
15
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,EACL,oBAAoB,EACpB,wBAAwB,EACxB,0BAA0B,EAC1B,oBAAoB,EAEpB,eAAe,EACf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AAM,WAAW,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC","sourcesContent":["export {\n defaultExceptionType,\n defaultLogArgsSerializer,\n defaultErrorArgsSerializer,\n UserActionImportance,\n type UserActionImportanceType,\n UserActionState,\n userActionsMessageBus,\n} from './api';\nexport type {\n API,\n APIEvent,\n EventAttributes,\n EventEvent,\n EventsAPI,\n ExceptionEvent,\n ExceptionEventExtended,\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 UserAction,\n UserActionInterface,\n UserActionInternalInterface,\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 MetaOverrides,\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 isEmpty,\n getCircularDependencyReplacer,\n stringifyExternalJson,\n stringifyObjectValues,\n Observable,\n} from './utils';\nexport type {\n BaseObject,\n BaseObjectKey,\n BaseObjectPrimitiveValue,\n BaseObjectValue,\n BufferItem,\n PromiseBuffer,\n PromiseBufferOptions,\n PromiseProducer,\n Subscription,\n} from './utils';\n\nexport { VERSION } from './version';\n\nexport { unknownString } from './consts';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,0BAA0B,EAC1B,oBAAoB,EAEpB,eAAe,EACf,qBAAqB,GACtB,MAAM,OAAO,CAAC;AAkCf,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;AAoBzG,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,iBAAiB,EACjB,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,EACP,OAAO,EACP,6BAA6B,EAC7B,qBAAqB,EACrB,qBAAqB,EACrB,UAAU,GACX,MAAM,SAAS,CAAC;AAajB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC","sourcesContent":["export {\n defaultExceptionType,\n defaultLogArgsSerializer,\n defaultErrorArgsSerializer,\n UserActionImportance,\n type UserActionImportanceType,\n UserActionState,\n userActionsMessageBus,\n} from './api';\nexport type {\n API,\n APIEvent,\n EventAttributes,\n EventEvent,\n EventsAPI,\n ExceptionEvent,\n ExceptionEventExtended,\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 UserAction,\n UserActionInterface,\n UserActionInternalInterface,\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 MetaOverrides,\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 clampSamplingRate,\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 isEmpty,\n getCircularDependencyReplacer,\n stringifyExternalJson,\n stringifyObjectValues,\n Observable,\n} from './utils';\nexport type {\n BaseObject,\n BaseObjectKey,\n BaseObjectPrimitiveValue,\n BaseObjectValue,\n BufferItem,\n PromiseBuffer,\n PromiseBufferOptions,\n PromiseProducer,\n Subscription,\n} from './utils';\n\nexport { VERSION } from './version';\n\nexport { unknownString } from './consts';\n"]}
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { clampSamplingRate } from './sampling';
|
|
1
2
|
export { deepEqual } from './deepEqual';
|
|
2
3
|
export { getCurrentTimestamp } from './date';
|
|
3
4
|
export { 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, isEmpty, } from './is';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAE7C,OAAO,EACL,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,OAAO,GACR,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGtD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAC;AAErG,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC","sourcesContent":["export type { BaseObject, BaseObjectKey, BaseObjectPrimitiveValue, BaseObjectValue } from './baseObject';\n\nexport { deepEqual } from './deepEqual';\n\nexport { getCurrentTimestamp } from './date';\n\nexport {\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 isEmpty,\n} from './is';\nexport type { IsFnHelper } from './is';\n\nexport { allLogLevels, defaultLogLevel, LogLevel } from './logLevels';\n\nexport { noop } from './noop';\n\nexport { createPromiseBuffer } from './promiseBuffer';\nexport type { BufferItem, PromiseBuffer, PromiseBufferOptions, PromiseProducer } from './promiseBuffer';\n\nexport { genShortID } from './shortId';\n\nexport { getBundleId } from './sourceMaps';\n\nexport { dateNow } from './date';\n\nexport { getCircularDependencyReplacer, stringifyExternalJson, stringifyObjectValues } from './json';\n\nexport { Observable } from './reactive';\nexport type { Subscription } from './reactive';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAE7C,OAAO,EACL,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,OAAO,GACR,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGtD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEjC,OAAO,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAC;AAErG,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC","sourcesContent":["export type { BaseObject, BaseObjectKey, BaseObjectPrimitiveValue, BaseObjectValue } from './baseObject';\n\nexport { clampSamplingRate } from './sampling';\n\nexport { deepEqual } from './deepEqual';\n\nexport { getCurrentTimestamp } from './date';\n\nexport {\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 isEmpty,\n} from './is';\nexport type { IsFnHelper } from './is';\n\nexport { allLogLevels, defaultLogLevel, LogLevel } from './logLevels';\n\nexport { noop } from './noop';\n\nexport { createPromiseBuffer } from './promiseBuffer';\nexport type { BufferItem, PromiseBuffer, PromiseBufferOptions, PromiseProducer } from './promiseBuffer';\n\nexport { genShortID } from './shortId';\n\nexport { getBundleId } from './sourceMaps';\n\nexport { dateNow } from './date';\n\nexport { getCircularDependencyReplacer, stringifyExternalJson, stringifyObjectValues } from './json';\n\nexport { Observable } from './reactive';\nexport type { Subscription } from './reactive';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sampling.js","sourceRoot":"","sources":["../../../src/utils/sampling.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,iBAAiB,CAAC,YAAoB;IACpD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC;AAChD,CAAC","sourcesContent":["export function clampSamplingRate(samplingRate: number): number {\n return Math.min(1, Math.max(0, samplingRate));\n}\n"]}
|
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '2.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '2.3.0';\n"]}
|