@grafana/faro-core 1.7.0 → 1.7.2
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/README.md +10 -9
- package/dist/bundle/faro-core.iife.js +1 -1
- package/dist/bundle/types/api/index.d.ts +1 -1
- package/dist/bundle/types/api/logs/index.d.ts +1 -1
- package/dist/bundle/types/api/logs/types.d.ts +1 -0
- package/dist/bundle/types/config/types.d.ts +2 -1
- package/dist/bundle/types/testUtils/mockTransport.d.ts +1 -1
- package/dist/bundle/types/version.d.ts +1 -1
- package/dist/cjs/api/index.js.map +1 -1
- package/dist/cjs/api/logs/index.js.map +1 -1
- package/dist/cjs/api/logs/initialize.js +14 -10
- package/dist/cjs/api/logs/initialize.js.map +1 -1
- package/dist/cjs/api/logs/types.js.map +1 -1
- package/dist/cjs/config/types.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/api/index.js.map +1 -1
- package/dist/esm/api/logs/index.js.map +1 -1
- package/dist/esm/api/logs/initialize.js +12 -10
- package/dist/esm/api/logs/initialize.js.map +1 -1
- package/dist/esm/api/logs/types.js.map +1 -1
- package/dist/esm/config/types.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/spec/core/src/api/index.js.map +1 -1
- package/dist/spec/core/src/api/logs/index.js.map +1 -1
- package/dist/spec/core/src/api/logs/initialize.js +14 -10
- package/dist/spec/core/src/api/logs/initialize.js.map +1 -1
- package/dist/spec/core/src/api/logs/initialize.test.js +17 -1
- package/dist/spec/core/src/api/logs/initialize.test.js.map +1 -1
- package/dist/spec/core/src/api/logs/types.js.map +1 -1
- package/dist/spec/core/src/config/types.js.map +1 -1
- package/dist/spec/core/src/version.js +1 -1
- package/dist/spec/core/src/version.js.map +1 -1
- package/dist/types/api/index.d.ts +1 -1
- package/dist/types/api/logs/index.d.ts +1 -1
- package/dist/types/api/logs/types.d.ts +1 -0
- package/dist/types/config/types.d.ts +2 -1
- package/dist/types/core/src/api/index.d.ts +1 -1
- package/dist/types/core/src/api/logs/index.d.ts +1 -1
- package/dist/types/core/src/api/logs/types.d.ts +1 -0
- package/dist/types/core/src/config/types.d.ts +2 -1
- package/dist/types/core/src/testUtils/mockTransport.d.ts +1 -1
- package/dist/types/core/src/version.d.ts +1 -1
- package/dist/types/testUtils/mockTransport.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -40,15 +40,16 @@ Faro Web SDK requires a configuration object parameter with the following proper
|
|
|
40
40
|
|
|
41
41
|
Besides the mandatory properties, Faro configuration also supports the following optional properties:
|
|
42
42
|
|
|
43
|
-
| Property
|
|
44
|
-
|
|
|
45
|
-
| `beforeSend`
|
|
46
|
-
| `eventDomain`
|
|
47
|
-
| `ignoreErrors`
|
|
48
|
-
| `ignoreUrls`
|
|
49
|
-
| `
|
|
50
|
-
| `
|
|
51
|
-
| `
|
|
43
|
+
| Property | Description | Type | Default Value |
|
|
44
|
+
| ------------------- | -------------------------------------------------------------------------------------- | ------------------- | ------------- |
|
|
45
|
+
| `beforeSend` | Hook invoked before pushing event to transport. Can be used to modify or filter events | `BeforeSendHook` | `undefined` |
|
|
46
|
+
| `eventDomain` | event.domain attribute of an event, to be set on every event item as default | `string` | `undefined` |
|
|
47
|
+
| `ignoreErrors` | Error message patterns for errors that should be ignored | `Patterns` | `[]` |
|
|
48
|
+
| `ignoreUrls` | Path patterns for Endpoints that should be ignored form being tracked. | `Patterns` | `[]` |
|
|
49
|
+
| `logArgsSerializer` | A function used to serialize log arguments | `LogArgsSerializer` | `undefined` |
|
|
50
|
+
| `session` | Session metadata | `Session` | `undefined` |
|
|
51
|
+
| `user` | User metadata | `User` | `undefined` |
|
|
52
|
+
| `view` | View metadata | `View` | `undefined` |
|
|
52
53
|
|
|
53
54
|
## Faro instance
|
|
54
55
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var GrafanaFaroCore=function(e){"use strict";function n(e,n){return typeof e===n}function t(e,n){return Object.prototype.toString.call(e)===`[object ${n}]`}function r(e,n){try{return e instanceof n}catch(e){return!1}}const a=e=>n(e,"null"),i=e=>n(e,"string"),o=e=>n(e,"number")&&!isNaN(e)||n(e,"bigint"),s=e=>!a(e)&&n(e,"object"),l=e=>n(e,"function"),u=e=>t(e,"Array"),c="undefined"!=typeof Event,d="undefined"!=typeof Error,g="undefined"!=typeof Element,p="undefined"!=typeof Map;function f(e,t){if(e===t)return!0;if(n(e,"number")&&isNaN(e))return n(t,"number")&&isNaN(t);const r=u(e),a=u(t);if(r!==a)return!1;if(r&&a){const n=e.length;if(n!==t.length)return!1;for(let r=n;0!=r--;)if(!f(e[r],t[r]))return!1;return!0}const i=s(e),o=s(t);if(i!==o)return!1;if(e&&t&&i&&o){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;for(let r of n)if(!f(e[r],t[r]))return!1;return!0}return!1}function m(){return(new Date).toISOString()}var v;e.LogLevel=void 0,(v=e.LogLevel||(e.LogLevel={})).TRACE="trace",v.DEBUG="debug",v.INFO="info",v.LOG="log",v.WARN="warn",v.ERROR="error";const h=e.LogLevel.LOG,b=[e.LogLevel.TRACE,e.LogLevel.DEBUG,e.LogLevel.INFO,e.LogLevel.LOG,e.LogLevel.WARN,e.LogLevel.ERROR];function E(){}const y="abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789";class T{constructor(e,n){var t,r;this.signalBuffer=[],this.itemLimit=null!==(t=null==n?void 0:n.itemLimit)&&void 0!==t?t:50,this.sendTimeout=null!==(r=null==n?void 0:n.sendTimeout)&&void 0!==r?r:250,this.paused=(null==n?void 0:n.paused)||!1,this.sendFn=e,this.flushInterval=-1,this.paused||this.start(),document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&this.flush()}))}addItem(e){this.paused||(this.signalBuffer.push(e),this.signalBuffer.length>=this.itemLimit&&this.flush())}start(){this.paused=!1,this.sendTimeout>0&&(this.flushInterval=window.setInterval((()=>this.flush()),this.sendTimeout))}pause(){this.paused=!0,clearInterval(this.flushInterval)}groupItems(e){const n=new Map;return e.forEach((e=>{const t=JSON.stringify(e.meta);let r=n.get(t);r=void 0===r?[e]:[...r,e],n.set(t,r)})),Array.from(n.values())}flush(){if(this.paused||0===this.signalBuffer.length)return;this.groupItems(this.signalBuffer).forEach(this.sendFn),this.signalBuffer=[]}}var I;e.TransportItemType=void 0,(I=e.TransportItemType||(e.TransportItemType={})).EXCEPTION="exception",I.LOG="log",I.MEASUREMENT="measurement",I.TRACE="trace",I.EVENT="event";const O={[e.TransportItemType.EXCEPTION]:"exceptions",[e.TransportItemType.LOG]:"logs",[e.TransportItemType.MEASUREMENT]:"measurements",[e.TransportItemType.TRACE]:"traces",[e.TransportItemType.EVENT]:"events"};function L(n){return t=>{if(t.type===e.TransportItemType.EXCEPTION&&t.payload){const e=t.payload,r=`${e.type}: ${e.value}`;if(function(e,n){return e.some((e=>i(e)?n.includes(e):!!n.match(e)))}(n,r))return null}return t}}function S(e,n,t,r){var a;n.debug("Initializing transports");const i=[];let o=t.paused,s=[];const l=e=>{let n=e;for(const e of s){const t=n.map(e).filter(Boolean);if(0===t.length)return[];n=t}return n},u=e=>{const t=l(e);if(0!==t.length)for(const e of i)n.debug(`Transporting item using ${e.name}\n`,t),e.isBatched()&&e.send(t)};let c;(null===(a=t.batching)||void 0===a?void 0:a.enabled)&&(c=new T(u,{sendTimeout:t.batching.sendTimeout,itemLimit:t.batching.itemLimit,paused:o}));return{add:(...a)=>{n.debug("Adding transports"),a.forEach((a=>{n.debug(`Adding "${a.name}" transport`);i.some((e=>e===a))?n.warn(`Transport ${a.name} is already added`):(a.unpatchedConsole=e,a.internalLogger=n,a.config=t,a.metas=r,i.push(a))}))},addBeforeSendHooks:(...e)=>{n.debug("Adding beforeSendHooks\n",s),e.forEach((e=>{e&&s.push(e)}))},addIgnoreErrorsPatterns:(...e)=>{n.debug("Adding ignoreErrorsPatterns\n",e),e.forEach((e=>{e&&s.push(L(e))}))},getBeforeSendHooks:()=>[...s],execute:e=>{var r;o||((null===(r=t.batching)||void 0===r?void 0:r.enabled)&&(null==c||c.addItem(e)),(e=>{var r,a;if((null===(r=t.batching)||void 0===r?void 0:r.enabled)&&i.every((e=>e.isBatched())))return;const[o]=l([e]);if(void 0!==o)for(const e of i)n.debug(`Transporting item using ${e.name}\n`,o),e.isBatched()?(null===(a=t.batching)||void 0===a?void 0:a.enabled)||e.send([o]):e.send(o)})(e))},isPaused:()=>o,pause:()=>{n.debug("Pausing transports"),null==c||c.pause(),o=!0},remove:(...e)=>{n.debug("Removing transports"),e.forEach((e=>{n.debug(`Removing "${e.name}" transport`);const t=i.indexOf(e);-1!==t?i.splice(t,1):n.warn(`Transport "${e.name}" is not added`)}))},removeBeforeSendHooks:(...e)=>{s.filter((n=>!e.includes(n)))},get transports(){return[...i]},unpause:()=>{n.debug("Unpausing transports"),null==c||c.start(),o=!1}}}var N;e.InternalLoggerLevel=void 0,(N=e.InternalLoggerLevel||(e.InternalLoggerLevel={}))[N.OFF=0]="OFF",N[N.ERROR=1]="ERROR",N[N.WARN=2]="WARN",N[N.INFO=3]="INFO",N[N.VERBOSE=4]="VERBOSE";const x={debug:E,error:E,info:E,prefix:"Faro",warn:E},R=e.InternalLoggerLevel.ERROR,j=Object.assign({},console);let A=j;function C(e){var n;return A=null!==(n=e.unpatchedConsole)&&void 0!==n?n:A,A}function k(n=j,t=R){const r=x;return t>e.InternalLoggerLevel.OFF&&(r.error=t>=e.InternalLoggerLevel.ERROR?function(...e){n.error(`${r.prefix}\n`,...e)}:E,r.warn=t>=e.InternalLoggerLevel.WARN?function(...e){n.warn(`${r.prefix}\n`,...e)}:E,r.info=t>=e.InternalLoggerLevel.INFO?function(...e){n.info(`${r.prefix}\n`,...e)}:E,r.debug=t>=e.InternalLoggerLevel.VERBOSE?function(...e){n.debug(`${r.prefix}\n`,...e)}:E),r}let w=x;function _(e,n){return w=k(e,n.internalLoggerLevel),w}class P{constructor(){this.unpatchedConsole=j,this.internalLogger=x,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 B(e,n){var t,r;if(void 0===n)return e;if(void 0===e)return{resourceSpans:n};const a=null===(t=e.resourceSpans)||void 0===t?void 0:t[0];if(void 0===a)return e;const i=(null==a?void 0:a.scopeSpans)||[],o=(null===(r=null==n?void 0:n[0])||void 0===r?void 0:r.scopeSpans)||[];return Object.assign(Object.assign({},e),{resourceSpans:[Object.assign(Object.assign({},a),{scopeSpans:[...i,...o]})]})}const F="Error";let D;function G(n,t,r,i,o){t.debug("Initializing API");const s=function(n,t,r,a,i){let o;return t.debug("Initializing traces API"),{getOTEL:()=>o,getTraceContext:()=>{const e=null==o?void 0:o.trace.getSpanContext(o.context.active());return e?{trace_id:e.traceId,span_id:e.spanId}:void 0},initOTEL:(e,n)=>{t.debug("Initializing OpenTelemetry"),o={trace:e,context:n}},isOTELInitialized:()=>!!o,pushTraces:n=>{try{const r={type:e.TransportItemType.TRACE,payload:n,meta:a.value};t.debug("Pushing trace\n",r),i.execute(r)}catch(e){t.error("Error pushing trace\n",e)}}}}(0,t,0,i,o);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},s),function(n,t,r,i,o,s){var l;t.debug("Initializing exceptions API");let u=null;D=null!==(l=r.parseStacktrace)&&void 0!==l?l:D;const c=e=>{t.debug("Changing stacktrace parser"),D=null!=e?e:D};return c(r.parseStacktrace),{changeStacktraceParser:c,getStacktraceParser:()=>D,pushError:(n,{skipDedupe:l,stackFrames:c,type:d,context:g,spanContext:p}={})=>{d=d||n.name||F;const v={meta:i.value,payload:{type:d,value:n.message,timestamp:m(),trace:p?{trace_id:p.traceId,span_id:p.spanId}:s.getTraceContext(),context:null!=g?g:{}},type:e.TransportItemType.EXCEPTION};(null==(c=null!=c?c:n.stack?null==D?void 0:D(n).frames:void 0)?void 0:c.length)&&(v.payload.stacktrace={frames:c});const h={type:v.payload.type,value:v.payload.value,stackTrace:v.payload.stacktrace,context:v.payload.context};l||!r.dedupe||a(u)||!f(h,u)?(u=h,t.debug("Pushing exception\n",v),o.execute(v)):t.debug("Skipping error push because it is the same as the last one\n",v.payload)}}}(0,t,r,i,o,s)),function(e,n,t,r,a){let i,o,s;n.debug("Initializing meta API");const l=e=>{o&&r.remove(o),o={user:e},r.add(o)},u=e=>{i&&r.remove(i),i={session:e},r.add(i)};return{setUser:l,resetUser:l,setSession:u,resetSession:u,getSession:()=>r.value.session,setView:e=>{var n;if((null===(n=null==s?void 0:s.view)||void 0===n?void 0:n.name)===(null==e?void 0:e.name))return;const t=s;s={view:e},r.add(s),t&&r.remove(t)},getView:()=>r.value.view}}(0,t,0,i)),function(n,t,r,i,o,s){t.debug("Initializing logs API");let l=null;return{pushLog:(n,{context:u,level:c,skipDedupe:d,spanContext:g}={})=>{try{const p={type:e.TransportItemType.LOG,payload:{message:n.map((e=>{try{return String(e)}catch(e){return""}})).join(" "),level:null!=c?c:h,context:null!=u?u:{},timestamp:m(),trace:g?{trace_id:g.traceId,span_id:g.spanId}:s.getTraceContext()},meta:i.value},v={message:p.payload.message,level:p.payload.level,context:p.payload.context};if(!d&&r.dedupe&&!a(l)&&f(v,l))return void t.debug("Skipping log push because it is the same as the last one\n",p.payload);l=v,t.debug("Pushing log\n",p),o.execute(p)}catch(e){t.error("Error pushing log\n",e)}}}}(0,t,r,i,o,s)),function(n,t,r,i,o,s){t.debug("Initializing measurements API");let l=null;return{pushMeasurement:(n,{skipDedupe:u,context:c,spanContext:d}={})=>{var g;try{const p={type:e.TransportItemType.MEASUREMENT,payload:Object.assign(Object.assign({},n),{trace:d?{trace_id:d.traceId,span_id:d.spanId}:s.getTraceContext(),timestamp:null!==(g=n.timestamp)&&void 0!==g?g:m(),context:null!=c?c:{}}),meta:i.value},v={type:p.payload.type,values:p.payload.values,context:p.payload.context};if(!u&&r.dedupe&&!a(l)&&f(v,l))return void t.debug("Skipping measurement push because it is the same as the last one\n",p.payload);l=v,t.debug("Pushing measurement\n",p),o.execute(p)}catch(e){t.error("Error pushing measurement\n",e)}}}}(0,t,r,i,o,s)),function(n,t,r,i,o,s){let l=null;return{pushEvent:(n,u,c,{skipDedupe:d,spanContext:g}={})=>{try{const p={meta:i.value,payload:{name:n,domain:null!=c?c:r.eventDomain,attributes:u,timestamp:m(),trace:g?{trace_id:g.traceId,span_id:g.spanId}:s.getTraceContext()},type:e.TransportItemType.EVENT},v={name:p.payload.name,attributes:p.payload.attributes,domain:p.payload.domain};if(!d&&r.dedupe&&!a(l)&&f(v,l))return void t.debug("Skipping event push because it is the same as the last one\n",p.payload);l=v,t.debug("Pushing event\n",p),o.execute(p)}catch(e){t.error("Error pushing event",e)}}}}(0,t,r,i,o,s))}const $="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:void 0;const V="1.7.0";const M="_faroInternal";function z(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($,M,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function U(){return M in $}function K(n,t,r,a,i,o,s){return t.debug("Initializing Faro"),e.faro={api:o,config:r,instrumentations:s,internalLogger:t,metas:a,pause:i.pause,transports:i,unpatchedConsole:n,unpause:i.unpause},z(e.faro),function(e){if(e.config.preventGlobalExposure)e.internalLogger.debug("Skipping registering public Faro instance in the global scope");else{if(e.internalLogger.debug(`Registering public faro reference in the global scope using "${e.config.globalObjectKey}" key`),e.config.globalObjectKey in $)return void e.internalLogger.warn(`Skipping global registration due to key "${e.config.globalObjectKey}" being used already. Please set "globalObjectKey" to something else or set "preventGlobalExposure" to "true"`);Object.defineProperty($,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}(e.faro),e.faro}e.faro={};return e.BaseExtension=P,e.BaseInstrumentation=class extends P{constructor(){super(...arguments),this.api={},this.transports={}}},e.BaseTransport=class extends P{isBatched(){return!1}getIgnoreUrls(){return[]}},e.Conventions={EventNames:{CLICK:"click",NAVIGATION:"navigation",SESSION_START:"session_start",VIEW_CHANGED:"view_changed"}},e.EVENT_CLICK="click",e.EVENT_NAVIGATION="navigation",e.EVENT_ROUTE_CHANGE="route_change",e.EVENT_SESSION_EXTEND="session_extend",e.EVENT_SESSION_RESUME="session_resume",e.EVENT_SESSION_START="session_start",e.EVENT_VIEW_CHANGED="view_changed",e.VERSION=V,e.allLogLevels=b,e.createInternalLogger=k,e.createPromiseBuffer=function(e){const{size:n,concurrency:t}=e,r=[];let a=0;const i=()=>{if(a<t&&r.length){const{producer:e,resolve:n,reject:t}=r.shift();a++,e().then((e=>{a--,i(),n(e)}),(e=>{a--,i(),t(e)}))}};return{add:e=>{if(r.length+a>=n)throw new Error("Task buffer full");return new Promise(((n,t)=>{r.push({producer:e,resolve:n,reject:t}),i()}))}}},e.dateNow=function(){return Date.now()},e.deepEqual=f,e.defaultBatchingConfig={enabled:!0,sendTimeout:250,itemLimit:50},e.defaultExceptionType=F,e.defaultGlobalObjectKey="faro",e.defaultInternalLoggerLevel=R,e.defaultLogLevel=h,e.defaultUnpatchedConsole=j,e.genShortID=function(e=10){return Array.from(Array(e)).map((()=>y[Math.floor(Math.random()*y.length)])).join("")},e.getCurrentTimestamp=m,e.getInternalFaroFromGlobalObject=function(){return $[M]},e.getTransportBody=function(n){let t={meta:{}};return void 0!==n[0]&&(t.meta=n[0].meta),n.forEach((n=>{switch(n.type){case e.TransportItemType.LOG:case e.TransportItemType.EVENT:case e.TransportItemType.EXCEPTION:case e.TransportItemType.MEASUREMENT:const r=O[n.type],a=t[r];t=Object.assign(Object.assign({},t),{[r]:void 0===a?[n.payload]:[...a,n.payload]});break;case e.TransportItemType.TRACE:t=Object.assign(Object.assign({},t),{traces:B(t.traces,n.payload.resourceSpans)})}})),t},e.globalObject=$,e.initializeFaro=function(e){const n=C(e),t=_(n,e);if(U()&&!e.isolate)return void t.error('Faro is already registered. Either add instrumentations, transports etc. to the global faro instance or use the "isolate" property');t.debug("Initializing");const r=function(e,n,t){let r=[],a=[];const i=()=>r.reduce(((e,n)=>Object.assign(e,l(n)?n():n)),{}),o=()=>{if(a.length){const e=i();a.forEach((n=>n(e)))}};return{add:(...e)=>{n.debug("Adding metas\n",e),r.push(...e),o()},remove:(...e)=>{n.debug("Removing metas\n",e),r=r.filter((n=>!e.includes(n))),o()},addListener:e=>{n.debug("Adding metas listener\n",e),a.push(e)},removeListener:e=>{n.debug("Removing metas listener\n",e),a=a.filter((n=>n!==e))},get value(){return i()}}}(0,t),a=S(n,t,e,r),i=G(0,t,e,r,a),o=function(e,n,t,r,a,i){n.debug("Initializing instrumentations");const o=[];return{add:(...s)=>{n.debug("Adding instrumentations"),s.forEach((s=>{n.debug(`Adding "${s.name}" instrumentation`),o.some((e=>e.name===s.name))?n.warn(`Instrumentation ${s.name} is already added`):(s.unpatchedConsole=e,s.internalLogger=n,s.config=t,s.metas=r,s.transports=a,s.api=i,o.push(s),s.initialize())}))},get instrumentations(){return[...o]},remove:(...e)=>{n.debug("Removing instrumentations"),e.forEach((e=>{var t,r;n.debug(`Removing "${e.name}" instrumentation`);const a=o.reduce(((n,t,r)=>null===n&&t.name===e.name?r:null),null);a?(null===(r=(t=o[a]).destroy)||void 0===r||r.call(t),o.splice(a,1)):n.warn(`Instrumentation "${e.name}" is not added`)}))}}}(n,t,e,r,a,i),s=K(n,t,e,r,a,i,o);return function(e){var n,t;const r={sdk:{version:V}},a=null===(n=e.config.sessionTracking)||void 0===n?void 0:n.session;a&&e.api.setSession(a),e.config.app&&(r.app=e.config.app),e.config.user&&(r.user=e.config.user),e.config.view&&(r.view=e.config.view),e.metas.add(r,...null!==(t=e.config.metas)&&void 0!==t?t:[])}(s),function(e){e.transports.add(...e.config.transports),e.transports.addBeforeSendHooks(e.config.beforeSend),e.transports.addIgnoreErrorsPatterns(e.config.ignoreErrors)}(s),function(e){e.instrumentations.add(...e.config.instrumentations)}(s),s},e.internalGlobalObjectKey=M,e.isArray=u,e.isBoolean=e=>n(e,"boolean"),e.isDomError=e=>t(e,"DOMError"),e.isDomException=e=>t(e,"DOMException"),e.isElement=e=>g&&r(e,Element),e.isElementDefined=g,e.isError=e=>d&&r(e,Error),e.isErrorDefined=d,e.isErrorEvent=e=>t(e,"ErrorEvent"),e.isEvent=e=>c&&r(e,Event),e.isEventDefined=c,e.isFunction=l,e.isInstanceOf=r,e.isInt=e=>o(e)&&Number.isInteger(e),e.isInternalFaroOnGlobalObject=U,e.isMap=e=>p&&r(e,Map),e.isMapDefined=p,e.isNull=a,e.isNumber=o,e.isObject=s,e.isPrimitive=e=>!s(e)&&!l(e),e.isRegExp=e=>t(e,"RegExp"),e.isString=i,e.isSymbol=e=>n(e,"symbol"),e.isSyntheticEvent=e=>s(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e,e.isThenable=e=>l(null==e?void 0:e.then),e.isToString=t,e.isTypeof=n,e.isUndefined=e=>n(e,"undefined"),e.noop=E,e.setInternalFaroOnGlobalObject=z,e.transportItemTypeToBodyKey=O,e}({});
|
|
1
|
+
var GrafanaFaroCore=function(e){"use strict";function n(e,n){return typeof e===n}function t(e,n){return Object.prototype.toString.call(e)===`[object ${n}]`}function r(e,n){try{return e instanceof n}catch(e){return!1}}const a=e=>n(e,"null"),i=e=>n(e,"string"),o=e=>n(e,"number")&&!isNaN(e)||n(e,"bigint"),s=e=>!a(e)&&n(e,"object"),l=e=>n(e,"function"),u=e=>t(e,"Array"),c="undefined"!=typeof Event,d="undefined"!=typeof Error,g="undefined"!=typeof Element,p="undefined"!=typeof Map;function f(e,t){if(e===t)return!0;if(n(e,"number")&&isNaN(e))return n(t,"number")&&isNaN(t);const r=u(e),a=u(t);if(r!==a)return!1;if(r&&a){const n=e.length;if(n!==t.length)return!1;for(let r=n;0!=r--;)if(!f(e[r],t[r]))return!1;return!0}const i=s(e),o=s(t);if(i!==o)return!1;if(e&&t&&i&&o){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;for(let r of n)if(!f(e[r],t[r]))return!1;return!0}return!1}function m(){return(new Date).toISOString()}var v;e.LogLevel=void 0,(v=e.LogLevel||(e.LogLevel={})).TRACE="trace",v.DEBUG="debug",v.INFO="info",v.LOG="log",v.WARN="warn",v.ERROR="error";const h=e.LogLevel.LOG,b=[e.LogLevel.TRACE,e.LogLevel.DEBUG,e.LogLevel.INFO,e.LogLevel.LOG,e.LogLevel.WARN,e.LogLevel.ERROR];function E(){}const y="abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ0123456789";class T{constructor(e,n){var t,r;this.signalBuffer=[],this.itemLimit=null!==(t=null==n?void 0:n.itemLimit)&&void 0!==t?t:50,this.sendTimeout=null!==(r=null==n?void 0:n.sendTimeout)&&void 0!==r?r:250,this.paused=(null==n?void 0:n.paused)||!1,this.sendFn=e,this.flushInterval=-1,this.paused||this.start(),document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&this.flush()}))}addItem(e){this.paused||(this.signalBuffer.push(e),this.signalBuffer.length>=this.itemLimit&&this.flush())}start(){this.paused=!1,this.sendTimeout>0&&(this.flushInterval=window.setInterval((()=>this.flush()),this.sendTimeout))}pause(){this.paused=!0,clearInterval(this.flushInterval)}groupItems(e){const n=new Map;return e.forEach((e=>{const t=JSON.stringify(e.meta);let r=n.get(t);r=void 0===r?[e]:[...r,e],n.set(t,r)})),Array.from(n.values())}flush(){if(this.paused||0===this.signalBuffer.length)return;this.groupItems(this.signalBuffer).forEach(this.sendFn),this.signalBuffer=[]}}var I;e.TransportItemType=void 0,(I=e.TransportItemType||(e.TransportItemType={})).EXCEPTION="exception",I.LOG="log",I.MEASUREMENT="measurement",I.TRACE="trace",I.EVENT="event";const O={[e.TransportItemType.EXCEPTION]:"exceptions",[e.TransportItemType.LOG]:"logs",[e.TransportItemType.MEASUREMENT]:"measurements",[e.TransportItemType.TRACE]:"traces",[e.TransportItemType.EVENT]:"events"};function L(n){return t=>{if(t.type===e.TransportItemType.EXCEPTION&&t.payload){const e=t.payload,r=`${e.type}: ${e.value}`;if(function(e,n){return e.some((e=>i(e)?n.includes(e):!!n.match(e)))}(n,r))return null}return t}}function S(e,n,t,r){var a;n.debug("Initializing transports");const i=[];let o=t.paused,s=[];const l=e=>{let n=e;for(const e of s){const t=n.map(e).filter(Boolean);if(0===t.length)return[];n=t}return n},u=e=>{const t=l(e);if(0!==t.length)for(const e of i)n.debug(`Transporting item using ${e.name}\n`,t),e.isBatched()&&e.send(t)};let c;(null===(a=t.batching)||void 0===a?void 0:a.enabled)&&(c=new T(u,{sendTimeout:t.batching.sendTimeout,itemLimit:t.batching.itemLimit,paused:o}));return{add:(...a)=>{n.debug("Adding transports"),a.forEach((a=>{n.debug(`Adding "${a.name}" transport`);i.some((e=>e===a))?n.warn(`Transport ${a.name} is already added`):(a.unpatchedConsole=e,a.internalLogger=n,a.config=t,a.metas=r,i.push(a))}))},addBeforeSendHooks:(...e)=>{n.debug("Adding beforeSendHooks\n",s),e.forEach((e=>{e&&s.push(e)}))},addIgnoreErrorsPatterns:(...e)=>{n.debug("Adding ignoreErrorsPatterns\n",e),e.forEach((e=>{e&&s.push(L(e))}))},getBeforeSendHooks:()=>[...s],execute:e=>{var r;o||((null===(r=t.batching)||void 0===r?void 0:r.enabled)&&(null==c||c.addItem(e)),(e=>{var r,a;if((null===(r=t.batching)||void 0===r?void 0:r.enabled)&&i.every((e=>e.isBatched())))return;const[o]=l([e]);if(void 0!==o)for(const e of i)n.debug(`Transporting item using ${e.name}\n`,o),e.isBatched()?(null===(a=t.batching)||void 0===a?void 0:a.enabled)||e.send([o]):e.send(o)})(e))},isPaused:()=>o,pause:()=>{n.debug("Pausing transports"),null==c||c.pause(),o=!0},remove:(...e)=>{n.debug("Removing transports"),e.forEach((e=>{n.debug(`Removing "${e.name}" transport`);const t=i.indexOf(e);-1!==t?i.splice(t,1):n.warn(`Transport "${e.name}" is not added`)}))},removeBeforeSendHooks:(...e)=>{s.filter((n=>!e.includes(n)))},get transports(){return[...i]},unpause:()=>{n.debug("Unpausing transports"),null==c||c.start(),o=!1}}}var N;e.InternalLoggerLevel=void 0,(N=e.InternalLoggerLevel||(e.InternalLoggerLevel={}))[N.OFF=0]="OFF",N[N.ERROR=1]="ERROR",N[N.WARN=2]="WARN",N[N.INFO=3]="INFO",N[N.VERBOSE=4]="VERBOSE";const x={debug:E,error:E,info:E,prefix:"Faro",warn:E},R=e.InternalLoggerLevel.ERROR,A=Object.assign({},console);let j=A;function C(e){var n;return j=null!==(n=e.unpatchedConsole)&&void 0!==n?n:j,j}function k(n=A,t=R){const r=x;return t>e.InternalLoggerLevel.OFF&&(r.error=t>=e.InternalLoggerLevel.ERROR?function(...e){n.error(`${r.prefix}\n`,...e)}:E,r.warn=t>=e.InternalLoggerLevel.WARN?function(...e){n.warn(`${r.prefix}\n`,...e)}:E,r.info=t>=e.InternalLoggerLevel.INFO?function(...e){n.info(`${r.prefix}\n`,...e)}:E,r.debug=t>=e.InternalLoggerLevel.VERBOSE?function(...e){n.debug(`${r.prefix}\n`,...e)}:E),r}let w=x;function _(e,n){return w=k(e,n.internalLoggerLevel),w}class P{constructor(){this.unpatchedConsole=A,this.internalLogger=x,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 B(e,n){var t,r;if(void 0===n)return e;if(void 0===e)return{resourceSpans:n};const a=null===(t=e.resourceSpans)||void 0===t?void 0:t[0];if(void 0===a)return e;const i=(null==a?void 0:a.scopeSpans)||[],o=(null===(r=null==n?void 0:n[0])||void 0===r?void 0:r.scopeSpans)||[];return Object.assign(Object.assign({},e),{resourceSpans:[Object.assign(Object.assign({},a),{scopeSpans:[...i,...o]})]})}const F="Error";let D;function G(n,t,r,i,o){t.debug("Initializing API");const s=function(n,t,r,a,i){let o;return t.debug("Initializing traces API"),{getOTEL:()=>o,getTraceContext:()=>{const e=null==o?void 0:o.trace.getSpanContext(o.context.active());return e?{trace_id:e.traceId,span_id:e.spanId}:void 0},initOTEL:(e,n)=>{t.debug("Initializing OpenTelemetry"),o={trace:e,context:n}},isOTELInitialized:()=>!!o,pushTraces:n=>{try{const r={type:e.TransportItemType.TRACE,payload:n,meta:a.value};t.debug("Pushing trace\n",r),i.execute(r)}catch(e){t.error("Error pushing trace\n",e)}}}}(0,t,0,i,o);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},s),function(n,t,r,i,o,s){var l;t.debug("Initializing exceptions API");let u=null;D=null!==(l=r.parseStacktrace)&&void 0!==l?l:D;const c=e=>{t.debug("Changing stacktrace parser"),D=null!=e?e:D};return c(r.parseStacktrace),{changeStacktraceParser:c,getStacktraceParser:()=>D,pushError:(n,{skipDedupe:l,stackFrames:c,type:d,context:g,spanContext:p}={})=>{d=d||n.name||F;const v={meta:i.value,payload:{type:d,value:n.message,timestamp:m(),trace:p?{trace_id:p.traceId,span_id:p.spanId}:s.getTraceContext(),context:null!=g?g:{}},type:e.TransportItemType.EXCEPTION};(null==(c=null!=c?c:n.stack?null==D?void 0:D(n).frames:void 0)?void 0:c.length)&&(v.payload.stacktrace={frames:c});const h={type:v.payload.type,value:v.payload.value,stackTrace:v.payload.stacktrace,context:v.payload.context};l||!r.dedupe||a(u)||!f(h,u)?(u=h,t.debug("Pushing exception\n",v),o.execute(v)):t.debug("Skipping error push because it is the same as the last one\n",v.payload)}}}(0,t,r,i,o,s)),function(e,n,t,r,a){let i,o,s;n.debug("Initializing meta API");const l=e=>{o&&r.remove(o),o={user:e},r.add(o)},u=e=>{i&&r.remove(i),i={session:e},r.add(i)};return{setUser:l,resetUser:l,setSession:u,resetSession:u,getSession:()=>r.value.session,setView:e=>{var n;if((null===(n=null==s?void 0:s.view)||void 0===n?void 0:n.name)===(null==e?void 0:e.name))return;const t=s;s={view:e},r.add(s),t&&r.remove(t)},getView:()=>r.value.view}}(0,t,0,i)),function(n,t,r,i,o,s){var l;t.debug("Initializing logs API");let u=null;const c=null!==(l=r.logArgsSerializer)&&void 0!==l?l:e=>e.map((e=>{try{return String(e)}catch(e){return""}})).join(" ");return{pushLog:(n,{context:l,level:d,skipDedupe:g,spanContext:p}={})=>{try{const v={type:e.TransportItemType.LOG,payload:{message:c(n),level:null!=d?d:h,context:null!=l?l:{},timestamp:m(),trace:p?{trace_id:p.traceId,span_id:p.spanId}:s.getTraceContext()},meta:i.value},b={message:v.payload.message,level:v.payload.level,context:v.payload.context};if(!g&&r.dedupe&&!a(u)&&f(b,u))return void t.debug("Skipping log push because it is the same as the last one\n",v.payload);u=b,t.debug("Pushing log\n",v),o.execute(v)}catch(e){t.error("Error pushing log\n",e)}}}}(0,t,r,i,o,s)),function(n,t,r,i,o,s){t.debug("Initializing measurements API");let l=null;return{pushMeasurement:(n,{skipDedupe:u,context:c,spanContext:d}={})=>{var g;try{const p={type:e.TransportItemType.MEASUREMENT,payload:Object.assign(Object.assign({},n),{trace:d?{trace_id:d.traceId,span_id:d.spanId}:s.getTraceContext(),timestamp:null!==(g=n.timestamp)&&void 0!==g?g:m(),context:null!=c?c:{}}),meta:i.value},v={type:p.payload.type,values:p.payload.values,context:p.payload.context};if(!u&&r.dedupe&&!a(l)&&f(v,l))return void t.debug("Skipping measurement push because it is the same as the last one\n",p.payload);l=v,t.debug("Pushing measurement\n",p),o.execute(p)}catch(e){t.error("Error pushing measurement\n",e)}}}}(0,t,r,i,o,s)),function(n,t,r,i,o,s){let l=null;return{pushEvent:(n,u,c,{skipDedupe:d,spanContext:g}={})=>{try{const p={meta:i.value,payload:{name:n,domain:null!=c?c:r.eventDomain,attributes:u,timestamp:m(),trace:g?{trace_id:g.traceId,span_id:g.spanId}:s.getTraceContext()},type:e.TransportItemType.EVENT},v={name:p.payload.name,attributes:p.payload.attributes,domain:p.payload.domain};if(!d&&r.dedupe&&!a(l)&&f(v,l))return void t.debug("Skipping event push because it is the same as the last one\n",p.payload);l=v,t.debug("Pushing event\n",p),o.execute(p)}catch(e){t.error("Error pushing event",e)}}}}(0,t,r,i,o,s))}const $="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:void 0;const V="1.7.2";const M="_faroInternal";function z(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($,M,{configurable:!1,enumerable:!1,writable:!1,value:e}))}function U(){return M in $}function K(n,t,r,a,i,o,s){return t.debug("Initializing Faro"),e.faro={api:o,config:r,instrumentations:s,internalLogger:t,metas:a,pause:i.pause,transports:i,unpatchedConsole:n,unpause:i.unpause},z(e.faro),function(e){if(e.config.preventGlobalExposure)e.internalLogger.debug("Skipping registering public Faro instance in the global scope");else{if(e.internalLogger.debug(`Registering public faro reference in the global scope using "${e.config.globalObjectKey}" key`),e.config.globalObjectKey in $)return void e.internalLogger.warn(`Skipping global registration due to key "${e.config.globalObjectKey}" being used already. Please set "globalObjectKey" to something else or set "preventGlobalExposure" to "true"`);Object.defineProperty($,e.config.globalObjectKey,{configurable:!1,writable:!1,value:e})}}(e.faro),e.faro}e.faro={};return e.BaseExtension=P,e.BaseInstrumentation=class extends P{constructor(){super(...arguments),this.api={},this.transports={}}},e.BaseTransport=class extends P{isBatched(){return!1}getIgnoreUrls(){return[]}},e.Conventions={EventNames:{CLICK:"click",NAVIGATION:"navigation",SESSION_START:"session_start",VIEW_CHANGED:"view_changed"}},e.EVENT_CLICK="click",e.EVENT_NAVIGATION="navigation",e.EVENT_ROUTE_CHANGE="route_change",e.EVENT_SESSION_EXTEND="session_extend",e.EVENT_SESSION_RESUME="session_resume",e.EVENT_SESSION_START="session_start",e.EVENT_VIEW_CHANGED="view_changed",e.VERSION=V,e.allLogLevels=b,e.createInternalLogger=k,e.createPromiseBuffer=function(e){const{size:n,concurrency:t}=e,r=[];let a=0;const i=()=>{if(a<t&&r.length){const{producer:e,resolve:n,reject:t}=r.shift();a++,e().then((e=>{a--,i(),n(e)}),(e=>{a--,i(),t(e)}))}};return{add:e=>{if(r.length+a>=n)throw new Error("Task buffer full");return new Promise(((n,t)=>{r.push({producer:e,resolve:n,reject:t}),i()}))}}},e.dateNow=function(){return Date.now()},e.deepEqual=f,e.defaultBatchingConfig={enabled:!0,sendTimeout:250,itemLimit:50},e.defaultExceptionType=F,e.defaultGlobalObjectKey="faro",e.defaultInternalLoggerLevel=R,e.defaultLogLevel=h,e.defaultUnpatchedConsole=A,e.genShortID=function(e=10){return Array.from(Array(e)).map((()=>y[Math.floor(Math.random()*y.length)])).join("")},e.getCurrentTimestamp=m,e.getInternalFaroFromGlobalObject=function(){return $[M]},e.getTransportBody=function(n){let t={meta:{}};return void 0!==n[0]&&(t.meta=n[0].meta),n.forEach((n=>{switch(n.type){case e.TransportItemType.LOG:case e.TransportItemType.EVENT:case e.TransportItemType.EXCEPTION:case e.TransportItemType.MEASUREMENT:const r=O[n.type],a=t[r];t=Object.assign(Object.assign({},t),{[r]:void 0===a?[n.payload]:[...a,n.payload]});break;case e.TransportItemType.TRACE:t=Object.assign(Object.assign({},t),{traces:B(t.traces,n.payload.resourceSpans)})}})),t},e.globalObject=$,e.initializeFaro=function(e){const n=C(e),t=_(n,e);if(U()&&!e.isolate)return void t.error('Faro is already registered. Either add instrumentations, transports etc. to the global faro instance or use the "isolate" property');t.debug("Initializing");const r=function(e,n,t){let r=[],a=[];const i=()=>r.reduce(((e,n)=>Object.assign(e,l(n)?n():n)),{}),o=()=>{if(a.length){const e=i();a.forEach((n=>n(e)))}};return{add:(...e)=>{n.debug("Adding metas\n",e),r.push(...e),o()},remove:(...e)=>{n.debug("Removing metas\n",e),r=r.filter((n=>!e.includes(n))),o()},addListener:e=>{n.debug("Adding metas listener\n",e),a.push(e)},removeListener:e=>{n.debug("Removing metas listener\n",e),a=a.filter((n=>n!==e))},get value(){return i()}}}(0,t),a=S(n,t,e,r),i=G(0,t,e,r,a),o=function(e,n,t,r,a,i){n.debug("Initializing instrumentations");const o=[];return{add:(...s)=>{n.debug("Adding instrumentations"),s.forEach((s=>{n.debug(`Adding "${s.name}" instrumentation`),o.some((e=>e.name===s.name))?n.warn(`Instrumentation ${s.name} is already added`):(s.unpatchedConsole=e,s.internalLogger=n,s.config=t,s.metas=r,s.transports=a,s.api=i,o.push(s),s.initialize())}))},get instrumentations(){return[...o]},remove:(...e)=>{n.debug("Removing instrumentations"),e.forEach((e=>{var t,r;n.debug(`Removing "${e.name}" instrumentation`);const a=o.reduce(((n,t,r)=>null===n&&t.name===e.name?r:null),null);a?(null===(r=(t=o[a]).destroy)||void 0===r||r.call(t),o.splice(a,1)):n.warn(`Instrumentation "${e.name}" is not added`)}))}}}(n,t,e,r,a,i),s=K(n,t,e,r,a,i,o);return function(e){var n,t;const r={sdk:{version:V}},a=null===(n=e.config.sessionTracking)||void 0===n?void 0:n.session;a&&e.api.setSession(a),e.config.app&&(r.app=e.config.app),e.config.user&&(r.user=e.config.user),e.config.view&&(r.view=e.config.view),e.metas.add(r,...null!==(t=e.config.metas)&&void 0!==t?t:[])}(s),function(e){e.transports.add(...e.config.transports),e.transports.addBeforeSendHooks(e.config.beforeSend),e.transports.addIgnoreErrorsPatterns(e.config.ignoreErrors)}(s),function(e){e.instrumentations.add(...e.config.instrumentations)}(s),s},e.internalGlobalObjectKey=M,e.isArray=u,e.isBoolean=e=>n(e,"boolean"),e.isDomError=e=>t(e,"DOMError"),e.isDomException=e=>t(e,"DOMException"),e.isElement=e=>g&&r(e,Element),e.isElementDefined=g,e.isError=e=>d&&r(e,Error),e.isErrorDefined=d,e.isErrorEvent=e=>t(e,"ErrorEvent"),e.isEvent=e=>c&&r(e,Event),e.isEventDefined=c,e.isFunction=l,e.isInstanceOf=r,e.isInt=e=>o(e)&&Number.isInteger(e),e.isInternalFaroOnGlobalObject=U,e.isMap=e=>p&&r(e,Map),e.isMapDefined=p,e.isNull=a,e.isNumber=o,e.isObject=s,e.isPrimitive=e=>!s(e)&&!l(e),e.isRegExp=e=>t(e,"RegExp"),e.isString=i,e.isSymbol=e=>n(e,"symbol"),e.isSyntheticEvent=e=>s(e)&&"nativeEvent"in e&&"preventDefault"in e&&"stopPropagation"in e,e.isThenable=e=>l(null==e?void 0:e.then),e.isToString=t,e.isTypeof=n,e.isUndefined=e=>n(e,"undefined"),e.noop=E,e.setInternalFaroOnGlobalObject=z,e.transportItemTypeToBodyKey=O,e}({});
|
|
@@ -3,7 +3,7 @@ export type { API, APIEvent } from './types';
|
|
|
3
3
|
export type { EventAttributes, EventEvent, EventsAPI } from './events';
|
|
4
4
|
export { defaultExceptionType } from './exceptions';
|
|
5
5
|
export type { ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, PushErrorOptions, Stacktrace, StacktraceParser, } from './exceptions';
|
|
6
|
-
export type { LogContext, LogEvent, LogsAPI, PushLogOptions } from './logs';
|
|
6
|
+
export type { LogContext, LogEvent, LogArgsSerializer, LogsAPI, PushLogOptions } from './logs';
|
|
7
7
|
export type { MeasurementEvent, MeasurementsAPI, PushMeasurementOptions } from './measurements';
|
|
8
8
|
export type { MetaAPI } from './meta';
|
|
9
9
|
export type { OTELApi, TraceContext, TraceEvent, TracesAPI } from './traces';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { initializeLogsAPI } from './initialize';
|
|
2
|
-
export type { LogContext, LogEvent, LogsAPI, PushLogOptions } from './types';
|
|
2
|
+
export type { LogContext, LogEvent, LogArgsSerializer, LogsAPI, PushLogOptions } from './types';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { APIEvent, StacktraceParser } from '../api';
|
|
1
|
+
import type { APIEvent, LogArgsSerializer, StacktraceParser } from '../api';
|
|
2
2
|
import type { Instrumentation } from '../instrumentations';
|
|
3
3
|
import type { InternalLoggerLevel } from '../internalLogger';
|
|
4
4
|
import type { Meta, MetaApp, MetaItem, MetaSession, MetaUser, MetaView } from '../metas';
|
|
@@ -15,6 +15,7 @@ export interface Config<P = APIEvent> {
|
|
|
15
15
|
instrumentations: Instrumentation[];
|
|
16
16
|
internalLoggerLevel: InternalLoggerLevel;
|
|
17
17
|
isolate: boolean;
|
|
18
|
+
logArgsSerializer?: LogArgsSerializer;
|
|
18
19
|
metas: MetaItem[];
|
|
19
20
|
parseStacktrace: StacktraceParser;
|
|
20
21
|
paused: boolean;
|
|
@@ -4,7 +4,7 @@ import type { Transport, TransportItem } from '../transports';
|
|
|
4
4
|
export declare class MockTransport extends BaseTransport implements Transport {
|
|
5
5
|
private ignoreURLs;
|
|
6
6
|
readonly name = "@grafana/transport-mock";
|
|
7
|
-
readonly version = "1.7.
|
|
7
|
+
readonly version = "1.7.2";
|
|
8
8
|
items: TransportItem[];
|
|
9
9
|
constructor(ignoreURLs?: Patterns);
|
|
10
10
|
send(items: TransportItem[]): void | Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.7.
|
|
1
|
+
export declare const VERSION = "1.7.2";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAApC,2GAAA,aAAa,OAAA;AAKtB,2CAAoD;AAA3C,kHAAA,oBAAoB,OAAA","sourcesContent":["export { initializeAPI } from './initialize';\nexport type { API, APIEvent } from './types';\n\nexport type { EventAttributes, EventEvent, EventsAPI } from './events';\n\nexport { defaultExceptionType } from './exceptions';\nexport type {\n ExceptionEvent,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n PushErrorOptions,\n Stacktrace,\n StacktraceParser,\n} from './exceptions';\n\nexport type { LogContext, LogEvent, LogsAPI, PushLogOptions } from './logs';\n\nexport type { MeasurementEvent, MeasurementsAPI, PushMeasurementOptions } from './measurements';\n\nexport type { MetaAPI } from './meta';\n\nexport type { OTELApi, TraceContext, TraceEvent, TracesAPI } from './traces';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAApC,2GAAA,aAAa,OAAA;AAKtB,2CAAoD;AAA3C,kHAAA,oBAAoB,OAAA","sourcesContent":["export { initializeAPI } from './initialize';\nexport type { API, APIEvent } from './types';\n\nexport type { EventAttributes, EventEvent, EventsAPI } from './events';\n\nexport { defaultExceptionType } from './exceptions';\nexport type {\n ExceptionEvent,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n PushErrorOptions,\n Stacktrace,\n StacktraceParser,\n} from './exceptions';\n\nexport type { LogContext, LogEvent, LogArgsSerializer, LogsAPI, PushLogOptions } from './logs';\n\nexport type { MeasurementEvent, MeasurementsAPI, PushMeasurementOptions } from './measurements';\n\nexport type { MetaAPI } from './meta';\n\nexport type { OTELApi, TraceContext, TraceEvent, TracesAPI } from './traces';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/api/logs/index.ts"],"names":[],"mappings":";;;AAAA,2CAAiD;AAAxC,+GAAA,iBAAiB,OAAA","sourcesContent":["export { initializeLogsAPI } from './initialize';\n\nexport type { LogContext, LogEvent, LogsAPI, PushLogOptions } from './types';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/api/logs/index.ts"],"names":[],"mappings":";;;AAAA,2CAAiD;AAAxC,+GAAA,iBAAiB,OAAA","sourcesContent":["export { initializeLogsAPI } from './initialize';\n\nexport type { LogContext, LogEvent, LogArgsSerializer, LogsAPI, PushLogOptions } from './types';\n"]}
|
|
@@ -4,24 +4,28 @@ exports.initializeLogsAPI = void 0;
|
|
|
4
4
|
var transports_1 = require("../../transports");
|
|
5
5
|
var utils_1 = require("../../utils");
|
|
6
6
|
function initializeLogsAPI(_unpatchedConsole, internalLogger, config, metas, transports, tracesApi) {
|
|
7
|
+
var _a;
|
|
7
8
|
internalLogger.debug('Initializing logs API');
|
|
8
9
|
var lastPayload = null;
|
|
10
|
+
var logArgsSerializer = (_a = config.logArgsSerializer) !== null && _a !== void 0 ? _a : (function (args) {
|
|
11
|
+
return args
|
|
12
|
+
.map(function (arg) {
|
|
13
|
+
try {
|
|
14
|
+
return String(arg);
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
return '';
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
.join(' ');
|
|
21
|
+
});
|
|
9
22
|
var pushLog = function (args, _a) {
|
|
10
23
|
var _b = _a === void 0 ? {} : _a, context = _b.context, level = _b.level, skipDedupe = _b.skipDedupe, spanContext = _b.spanContext;
|
|
11
24
|
try {
|
|
12
25
|
var item = {
|
|
13
26
|
type: transports_1.TransportItemType.LOG,
|
|
14
27
|
payload: {
|
|
15
|
-
message: args
|
|
16
|
-
.map(function (arg) {
|
|
17
|
-
try {
|
|
18
|
-
return String(arg);
|
|
19
|
-
}
|
|
20
|
-
catch (err) {
|
|
21
|
-
return '';
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
.join(' '),
|
|
28
|
+
message: logArgsSerializer(args),
|
|
25
29
|
level: level !== null && level !== void 0 ? level : utils_1.defaultLogLevel,
|
|
26
30
|
context: context !== null && context !== void 0 ? context : {},
|
|
27
31
|
timestamp: (0, utils_1.getCurrentTimestamp)(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/logs/initialize.ts"],"names":[],"mappings":";;;AAGA,+CAAoE;AAGpE,qCAAsF;AAKtF,SAAgB,iBAAiB,CAC/B,iBAAmC,EACnC,cAA8B,EAC9B,MAAc,EACd,KAAY,EACZ,UAAsB,EACtB,SAAoB
|
|
1
|
+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EAAE;iBAChC;gBACD,IAAI,EAAE,KAAK,CAAC,KAAK;aAClB,CAAC;YAEF,IAAM,cAAc,GAAG;gBACrB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;gBAC7B,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;gBACzB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;aAC9B,CAAC;YAEF,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,IAAA,cAAM,EAAC,WAAW,CAAC,IAAI,IAAA,iBAAS,EAAC,cAAc,EAAE,WAAW,CAAC,EAAE;gBAClG,cAAc,CAAC,KAAK,CAAC,4DAA4D,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBAEjG,OAAO;aACR;YAED,WAAW,GAAG,cAAc,CAAC;YAE7B,cAAc,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;YAE5C,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAC1B;QAAC,OAAO,GAAG,EAAE;YACZ,cAAc,CAAC,KAAK,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;SAClD;IACH,CAAC,CAAC;IAEF,OAAO;QACL,OAAO,SAAA;KACR,CAAC;AACJ,CAAC;AArED,8CAqEC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItem, TransportItemType } from '../../transports';\nimport type { Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { deepEqual, defaultLogLevel, getCurrentTimestamp, isNull } from '../../utils';\nimport type { TracesAPI } from '../traces';\n\nimport type { LogEvent, LogsAPI } from './types';\n\nexport function initializeLogsAPI(\n _unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas,\n transports: Transports,\n tracesApi: TracesAPI\n): LogsAPI {\n internalLogger.debug('Initializing logs API');\n\n let lastPayload: Pick<LogEvent, 'message' | 'level' | 'context'> | null = null;\n\n const logArgsSerializer =\n config.logArgsSerializer ??\n ((args) =>\n args\n .map((arg) => {\n try {\n return String(arg);\n } catch (err) {\n return '';\n }\n })\n .join(' '));\n\n const pushLog: LogsAPI['pushLog'] = (args, { context, level, skipDedupe, spanContext } = {}) => {\n try {\n const item: TransportItem<LogEvent> = {\n type: TransportItemType.LOG,\n payload: {\n message: logArgsSerializer(args),\n level: level ?? defaultLogLevel,\n context: context ?? {},\n timestamp: getCurrentTimestamp(),\n trace: spanContext\n ? {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n }\n : tracesApi.getTraceContext(),\n },\n meta: metas.value,\n };\n\n const testingPayload = {\n message: item.payload.message,\n level: item.payload.level,\n context: item.payload.context,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping log 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 log\\n', item);\n\n transports.execute(item);\n } catch (err) {\n internalLogger.error('Error pushing log\\n', err);\n }\n };\n\n return {\n pushLog,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/logs/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { LogLevel } from '../../utils';\nimport type { TraceContext } from '../traces';\n\nexport type LogContext = Record<string, string>;\n\nexport interface LogEvent {\n context: LogContext;\n level: LogLevel;\n message: string;\n timestamp: string;\n\n trace?: TraceContext;\n}\n\nexport interface PushLogOptions {\n context?: LogContext;\n level?: LogLevel;\n skipDedupe?: boolean;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n}\n\nexport interface LogsAPI {\n pushLog: (args: unknown[], options?: PushLogOptions) => void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/logs/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { LogLevel } from '../../utils';\nimport type { TraceContext } from '../traces';\n\nexport type LogContext = Record<string, string>;\n\nexport interface LogEvent {\n context: LogContext;\n level: LogLevel;\n message: string;\n timestamp: string;\n\n trace?: TraceContext;\n}\n\nexport interface PushLogOptions {\n context?: LogContext;\n level?: LogLevel;\n skipDedupe?: boolean;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n}\n\nexport interface LogsAPI {\n pushLog: (args: unknown[], options?: PushLogOptions) => void;\n}\n\nexport type LogArgsSerializer = (args: unknown[]) => string;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { APIEvent, StacktraceParser } from '../api';\nimport type { Instrumentation } from '../instrumentations';\nimport type { InternalLoggerLevel } from '../internalLogger';\nimport type { Meta, MetaApp, MetaItem, MetaSession, MetaUser, MetaView } from '../metas';\nimport type { BatchExecutorOptions, BeforeSendHook, Transport } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\n\ntype SamplingContext = {\n metas: Meta;\n};\n\nexport interface Config<P = APIEvent> {\n app: MetaApp;\n batching?: BatchExecutorOptions;\n dedupe: boolean;\n globalObjectKey: string;\n instrumentations: Instrumentation[];\n internalLoggerLevel: InternalLoggerLevel;\n isolate: boolean;\n metas: MetaItem[];\n parseStacktrace: StacktraceParser;\n paused: boolean;\n preventGlobalExposure: boolean;\n transports: Transport[];\n unpatchedConsole: UnpatchedConsole;\n\n beforeSend?: BeforeSendHook<P>;\n ignoreErrors?: Patterns;\n ignoreUrls?: Patterns;\n sessionTracking?: {\n enabled?: boolean;\n persistent?: boolean;\n session?: MetaSession;\n maxSessionPersistenceTime?: number;\n onSessionChange?: (oldSession: MetaSession | null, newSession: MetaSession) => void;\n samplingRate?: number;\n sampler?: (context: SamplingContext) => number;\n generateSessionId?: () => string;\n };\n\n user?: MetaUser;\n view?: MetaView;\n eventDomain?: string;\n\n trackResources?: boolean;\n}\n\nexport type Patterns = Array<string | RegExp>;\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { APIEvent, LogArgsSerializer, StacktraceParser } from '../api';\nimport type { Instrumentation } from '../instrumentations';\nimport type { InternalLoggerLevel } from '../internalLogger';\nimport type { Meta, MetaApp, MetaItem, MetaSession, MetaUser, MetaView } from '../metas';\nimport type { BatchExecutorOptions, BeforeSendHook, Transport } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\n\ntype SamplingContext = {\n metas: Meta;\n};\n\nexport interface Config<P = APIEvent> {\n app: MetaApp;\n batching?: BatchExecutorOptions;\n dedupe: boolean;\n globalObjectKey: string;\n instrumentations: Instrumentation[];\n internalLoggerLevel: InternalLoggerLevel;\n isolate: boolean;\n logArgsSerializer?: LogArgsSerializer;\n metas: MetaItem[];\n parseStacktrace: StacktraceParser;\n paused: boolean;\n preventGlobalExposure: boolean;\n transports: Transport[];\n unpatchedConsole: UnpatchedConsole;\n\n beforeSend?: BeforeSendHook<P>;\n ignoreErrors?: Patterns;\n ignoreUrls?: Patterns;\n sessionTracking?: {\n enabled?: boolean;\n persistent?: boolean;\n session?: MetaSession;\n maxSessionPersistenceTime?: number;\n onSessionChange?: (oldSession: MetaSession | null, newSession: MetaSession) => void;\n samplingRate?: number;\n sampler?: (context: SamplingContext) => number;\n generateSessionId?: () => string;\n };\n\n user?: MetaUser;\n view?: MetaView;\n eventDomain?: string;\n\n trackResources?: boolean;\n}\n\nexport type Patterns = Array<string | RegExp>;\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 = '1.7.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.7.2';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAK7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { initializeAPI } from './initialize';\nexport type { API, APIEvent } from './types';\n\nexport type { EventAttributes, EventEvent, EventsAPI } from './events';\n\nexport { defaultExceptionType } from './exceptions';\nexport type {\n ExceptionEvent,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n PushErrorOptions,\n Stacktrace,\n StacktraceParser,\n} from './exceptions';\n\nexport type { LogContext, LogEvent, LogsAPI, PushLogOptions } from './logs';\n\nexport type { MeasurementEvent, MeasurementsAPI, PushMeasurementOptions } from './measurements';\n\nexport type { MetaAPI } from './meta';\n\nexport type { OTELApi, TraceContext, TraceEvent, TracesAPI } from './traces';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAK7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { initializeAPI } from './initialize';\nexport type { API, APIEvent } from './types';\n\nexport type { EventAttributes, EventEvent, EventsAPI } from './events';\n\nexport { defaultExceptionType } from './exceptions';\nexport type {\n ExceptionEvent,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n PushErrorOptions,\n Stacktrace,\n StacktraceParser,\n} from './exceptions';\n\nexport type { LogContext, LogEvent, LogArgsSerializer, LogsAPI, PushLogOptions } from './logs';\n\nexport type { MeasurementEvent, MeasurementsAPI, PushMeasurementOptions } from './measurements';\n\nexport type { MetaAPI } from './meta';\n\nexport type { OTELApi, TraceContext, TraceEvent, TracesAPI } from './traces';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/api/logs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { initializeLogsAPI } from './initialize';\n\nexport type { LogContext, LogEvent, LogsAPI, PushLogOptions } from './types';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/api/logs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { initializeLogsAPI } from './initialize';\n\nexport type { LogContext, LogEvent, LogArgsSerializer, LogsAPI, PushLogOptions } from './types';\n"]}
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import { TransportItemType } from '../../transports';
|
|
2
2
|
import { deepEqual, defaultLogLevel, getCurrentTimestamp, isNull } from '../../utils';
|
|
3
3
|
export function initializeLogsAPI(_unpatchedConsole, internalLogger, config, metas, transports, tracesApi) {
|
|
4
|
+
var _a;
|
|
4
5
|
internalLogger.debug('Initializing logs API');
|
|
5
6
|
let lastPayload = null;
|
|
7
|
+
const logArgsSerializer = (_a = config.logArgsSerializer) !== null && _a !== void 0 ? _a : ((args) => args
|
|
8
|
+
.map((arg) => {
|
|
9
|
+
try {
|
|
10
|
+
return String(arg);
|
|
11
|
+
}
|
|
12
|
+
catch (err) {
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
.join(' '));
|
|
6
17
|
const pushLog = (args, { context, level, skipDedupe, spanContext } = {}) => {
|
|
7
18
|
try {
|
|
8
19
|
const item = {
|
|
9
20
|
type: TransportItemType.LOG,
|
|
10
21
|
payload: {
|
|
11
|
-
message: args
|
|
12
|
-
.map((arg) => {
|
|
13
|
-
try {
|
|
14
|
-
return String(arg);
|
|
15
|
-
}
|
|
16
|
-
catch (err) {
|
|
17
|
-
return '';
|
|
18
|
-
}
|
|
19
|
-
})
|
|
20
|
-
.join(' '),
|
|
22
|
+
message: logArgsSerializer(args),
|
|
21
23
|
level: level !== null && level !== void 0 ? level : defaultLogLevel,
|
|
22
24
|
context: context !== null && context !== void 0 ? context : {},
|
|
23
25
|
timestamp: getCurrentTimestamp(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/logs/initialize.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGpE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAKtF,MAAM,UAAU,iBAAiB,CAC/B,iBAAmC,EACnC,cAA8B,EAC9B,MAAc,EACd,KAAY,EACZ,UAAsB,EACtB,SAAoB
|
|
1
|
+
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/logs/initialize.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGpE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAKtF,MAAM,UAAU,iBAAiB,CAC/B,iBAAmC,EACnC,cAA8B,EAC9B,MAAc,EACd,KAAY,EACZ,UAAsB,EACtB,SAAoB;;IAEpB,cAAc,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAE9C,IAAI,WAAW,GAA2D,IAAI,CAAC;IAE/E,MAAM,iBAAiB,GACrB,MAAA,MAAM,CAAC,iBA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ClG,cAAc,CAAC,KAAK,CAAC,4DAA4D,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBAEjG,OAAO;aACR;YAED,WAAW,GAAG,cAAc,CAAC;YAE7B,cAAc,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;YAE5C,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAC1B;QAAC,OAAO,GAAG,EAAE;YACZ,cAAc,CAAC,KAAK,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;SAClD;IACH,CAAC,CAAC;IAEF,OAAO;QACL,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItem, TransportItemType } from '../../transports';\nimport type { Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { deepEqual, defaultLogLevel, getCurrentTimestamp, isNull } from '../../utils';\nimport type { TracesAPI } from '../traces';\n\nimport type { LogEvent, LogsAPI } from './types';\n\nexport function initializeLogsAPI(\n _unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas,\n transports: Transports,\n tracesApi: TracesAPI\n): LogsAPI {\n internalLogger.debug('Initializing logs API');\n\n let lastPayload: Pick<LogEvent, 'message' | 'level' | 'context'> | null = null;\n\n const logArgsSerializer =\n config.logArgsSerializer ??\n ((args) =>\n args\n .map((arg) => {\n try {\n return String(arg);\n } catch (err) {\n return '';\n }\n })\n .join(' '));\n\n const pushLog: LogsAPI['pushLog'] = (args, { context, level, skipDedupe, spanContext } = {}) => {\n try {\n const item: TransportItem<LogEvent> = {\n type: TransportItemType.LOG,\n payload: {\n message: logArgsSerializer(args),\n level: level ?? defaultLogLevel,\n context: context ?? {},\n timestamp: getCurrentTimestamp(),\n trace: spanContext\n ? {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n }\n : tracesApi.getTraceContext(),\n },\n meta: metas.value,\n };\n\n const testingPayload = {\n message: item.payload.message,\n level: item.payload.level,\n context: item.payload.context,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping log 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 log\\n', item);\n\n transports.execute(item);\n } catch (err) {\n internalLogger.error('Error pushing log\\n', err);\n }\n };\n\n return {\n pushLog,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/logs/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { LogLevel } from '../../utils';\nimport type { TraceContext } from '../traces';\n\nexport type LogContext = Record<string, string>;\n\nexport interface LogEvent {\n context: LogContext;\n level: LogLevel;\n message: string;\n timestamp: string;\n\n trace?: TraceContext;\n}\n\nexport interface PushLogOptions {\n context?: LogContext;\n level?: LogLevel;\n skipDedupe?: boolean;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n}\n\nexport interface LogsAPI {\n pushLog: (args: unknown[], options?: PushLogOptions) => void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/logs/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { LogLevel } from '../../utils';\nimport type { TraceContext } from '../traces';\n\nexport type LogContext = Record<string, string>;\n\nexport interface LogEvent {\n context: LogContext;\n level: LogLevel;\n message: string;\n timestamp: string;\n\n trace?: TraceContext;\n}\n\nexport interface PushLogOptions {\n context?: LogContext;\n level?: LogLevel;\n skipDedupe?: boolean;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n}\n\nexport interface LogsAPI {\n pushLog: (args: unknown[], options?: PushLogOptions) => void;\n}\n\nexport type LogArgsSerializer = (args: unknown[]) => string;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { APIEvent, StacktraceParser } from '../api';\nimport type { Instrumentation } from '../instrumentations';\nimport type { InternalLoggerLevel } from '../internalLogger';\nimport type { Meta, MetaApp, MetaItem, MetaSession, MetaUser, MetaView } from '../metas';\nimport type { BatchExecutorOptions, BeforeSendHook, Transport } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\n\ntype SamplingContext = {\n metas: Meta;\n};\n\nexport interface Config<P = APIEvent> {\n app: MetaApp;\n batching?: BatchExecutorOptions;\n dedupe: boolean;\n globalObjectKey: string;\n instrumentations: Instrumentation[];\n internalLoggerLevel: InternalLoggerLevel;\n isolate: boolean;\n metas: MetaItem[];\n parseStacktrace: StacktraceParser;\n paused: boolean;\n preventGlobalExposure: boolean;\n transports: Transport[];\n unpatchedConsole: UnpatchedConsole;\n\n beforeSend?: BeforeSendHook<P>;\n ignoreErrors?: Patterns;\n ignoreUrls?: Patterns;\n sessionTracking?: {\n enabled?: boolean;\n persistent?: boolean;\n session?: MetaSession;\n maxSessionPersistenceTime?: number;\n onSessionChange?: (oldSession: MetaSession | null, newSession: MetaSession) => void;\n samplingRate?: number;\n sampler?: (context: SamplingContext) => number;\n generateSessionId?: () => string;\n };\n\n user?: MetaUser;\n view?: MetaView;\n eventDomain?: string;\n\n trackResources?: boolean;\n}\n\nexport type Patterns = Array<string | RegExp>;\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { APIEvent, LogArgsSerializer, StacktraceParser } from '../api';\nimport type { Instrumentation } from '../instrumentations';\nimport type { InternalLoggerLevel } from '../internalLogger';\nimport type { Meta, MetaApp, MetaItem, MetaSession, MetaUser, MetaView } from '../metas';\nimport type { BatchExecutorOptions, BeforeSendHook, Transport } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\n\ntype SamplingContext = {\n metas: Meta;\n};\n\nexport interface Config<P = APIEvent> {\n app: MetaApp;\n batching?: BatchExecutorOptions;\n dedupe: boolean;\n globalObjectKey: string;\n instrumentations: Instrumentation[];\n internalLoggerLevel: InternalLoggerLevel;\n isolate: boolean;\n logArgsSerializer?: LogArgsSerializer;\n metas: MetaItem[];\n parseStacktrace: StacktraceParser;\n paused: boolean;\n preventGlobalExposure: boolean;\n transports: Transport[];\n unpatchedConsole: UnpatchedConsole;\n\n beforeSend?: BeforeSendHook<P>;\n ignoreErrors?: Patterns;\n ignoreUrls?: Patterns;\n sessionTracking?: {\n enabled?: boolean;\n persistent?: boolean;\n session?: MetaSession;\n maxSessionPersistenceTime?: number;\n onSessionChange?: (oldSession: MetaSession | null, newSession: MetaSession) => void;\n samplingRate?: number;\n sampler?: (context: SamplingContext) => number;\n generateSessionId?: () => string;\n };\n\n user?: MetaUser;\n view?: MetaView;\n eventDomain?: string;\n\n trackResources?: boolean;\n}\n\nexport type Patterns = Array<string | RegExp>;\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 = '1.7.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.7.2';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/api/index.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAApC,2GAAA,aAAa,OAAA;AAKtB,2CAAoD;AAA3C,kHAAA,oBAAoB,OAAA","sourcesContent":["export { initializeAPI } from './initialize';\nexport type { API, APIEvent } from './types';\n\nexport type { EventAttributes, EventEvent, EventsAPI } from './events';\n\nexport { defaultExceptionType } from './exceptions';\nexport type {\n ExceptionEvent,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n PushErrorOptions,\n Stacktrace,\n StacktraceParser,\n} from './exceptions';\n\nexport type { LogContext, LogEvent, LogsAPI, PushLogOptions } from './logs';\n\nexport type { MeasurementEvent, MeasurementsAPI, PushMeasurementOptions } from './measurements';\n\nexport type { MetaAPI } from './meta';\n\nexport type { OTELApi, TraceContext, TraceEvent, TracesAPI } from './traces';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/api/index.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAApC,2GAAA,aAAa,OAAA;AAKtB,2CAAoD;AAA3C,kHAAA,oBAAoB,OAAA","sourcesContent":["export { initializeAPI } from './initialize';\nexport type { API, APIEvent } from './types';\n\nexport type { EventAttributes, EventEvent, EventsAPI } from './events';\n\nexport { defaultExceptionType } from './exceptions';\nexport type {\n ExceptionEvent,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n PushErrorOptions,\n Stacktrace,\n StacktraceParser,\n} from './exceptions';\n\nexport type { LogContext, LogEvent, LogArgsSerializer, LogsAPI, PushLogOptions } from './logs';\n\nexport type { MeasurementEvent, MeasurementsAPI, PushMeasurementOptions } from './measurements';\n\nexport type { MetaAPI } from './meta';\n\nexport type { OTELApi, TraceContext, TraceEvent, TracesAPI } from './traces';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/api/logs/index.ts"],"names":[],"mappings":";;;AAAA,2CAAiD;AAAxC,+GAAA,iBAAiB,OAAA","sourcesContent":["export { initializeLogsAPI } from './initialize';\n\nexport type { LogContext, LogEvent, LogsAPI, PushLogOptions } from './types';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/api/logs/index.ts"],"names":[],"mappings":";;;AAAA,2CAAiD;AAAxC,+GAAA,iBAAiB,OAAA","sourcesContent":["export { initializeLogsAPI } from './initialize';\n\nexport type { LogContext, LogEvent, LogArgsSerializer, LogsAPI, PushLogOptions } from './types';\n"]}
|
|
@@ -4,24 +4,28 @@ exports.initializeLogsAPI = void 0;
|
|
|
4
4
|
var transports_1 = require("../../transports");
|
|
5
5
|
var utils_1 = require("../../utils");
|
|
6
6
|
function initializeLogsAPI(_unpatchedConsole, internalLogger, config, metas, transports, tracesApi) {
|
|
7
|
+
var _a;
|
|
7
8
|
internalLogger.debug('Initializing logs API');
|
|
8
9
|
var lastPayload = null;
|
|
10
|
+
var logArgsSerializer = (_a = config.logArgsSerializer) !== null && _a !== void 0 ? _a : (function (args) {
|
|
11
|
+
return args
|
|
12
|
+
.map(function (arg) {
|
|
13
|
+
try {
|
|
14
|
+
return String(arg);
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
return '';
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
.join(' ');
|
|
21
|
+
});
|
|
9
22
|
var pushLog = function (args, _a) {
|
|
10
23
|
var _b = _a === void 0 ? {} : _a, context = _b.context, level = _b.level, skipDedupe = _b.skipDedupe, spanContext = _b.spanContext;
|
|
11
24
|
try {
|
|
12
25
|
var item = {
|
|
13
26
|
type: transports_1.TransportItemType.LOG,
|
|
14
27
|
payload: {
|
|
15
|
-
message: args
|
|
16
|
-
.map(function (arg) {
|
|
17
|
-
try {
|
|
18
|
-
return String(arg);
|
|
19
|
-
}
|
|
20
|
-
catch (err) {
|
|
21
|
-
return '';
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
.join(' '),
|
|
28
|
+
message: logArgsSerializer(args),
|
|
25
29
|
level: level !== null && level !== void 0 ? level : utils_1.defaultLogLevel,
|
|
26
30
|
context: context !== null && context !== void 0 ? context : {},
|
|
27
31
|
timestamp: (0, utils_1.getCurrentTimestamp)(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../../../src/api/logs/initialize.ts"],"names":[],"mappings":";;;AAGA,+CAAoE;AAGpE,qCAAsF;AAKtF,SAAgB,iBAAiB,CAC/B,iBAAmC,EACnC,cAA8B,EAC9B,MAAc,EACd,KAAY,EACZ,UAAsB,EACtB,SAAoB
|
|
1
|
+
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../../../src/api/logs/initialize.ts"],"names":[],"mappings":";;;AAGA,+CAAoE;AAGpE,qCAAsF;AAKtF,SAAgB,iBAAiB,CAC/B,iBAAmC,EACnC,cAA8B,EAC9B,MAAc,EACd,KAAY,EACZ,UAAsB,EACtB,SAAoB;;IAEpB,cAAc,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAE9C,IAAI,WAAW,GAA2D,IAAI,CAAC;IAE/E,IAAM,iBAAiB,GACrB,MAAA,MAAM,CAAC,iBAAiB,mCACxB,CAAC,UAAC,IAAI;QACJ,OAAA,IAAI;aACD,GAAG,CAAC,UAAC,GAAG;YACP,IAAI;gBACF,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;aACpB;YAAC,OAAO,GAAG,EAAE;gBACZ,OAAO,EAAE,CAAC;aACX;QACH,CAAC,CAAC;aACD,IAAI,CAAC,GAAG,CAAC;IARZ,CAQY,CAAC,CAAC;IAElB,IAAM,OAAO,GAAuB,UAAC,IAAI,EAAE,EAAgD;YAAhD,qBAA8C,EAAE,KAAA,EAA9C,OAAO,aAAA,EAAE,KAAK,WAAA,EAAE,UAAU,gBAAA,EAAE,WAAW,iBAAA;QAClF,IAAI;YACF,IAAM,IAAI,GAA4B;gBACpC,IAAI,EAAE,8BAAiB,CAAC,GAAG;gBAC3B,OAAO,EAAE;oBACP,OAAO,EAAE,iBAAiB,CAAC,IAAI,CAAC;oBAChC,KAAK,EAAE,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,uBAAe;oBAC/B,OAAO,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE;oBACtB,SAAS,EAAE,IAAA,2BAAmB,GAAE;oBAChC,KAAK,EAAE,WAAW;wBAChB,CAAC,CAAC;4BACE,QAAQ,EAAE,WAAW,CAAC,OAAO;4BAC7B,OAAO,EAAE,WAAW,CAAC,MAAM;yBAC5B;wBACH,CAAC,CAAC,SAAS,CAAC,eAAe,EAAE;iBAChC;gBACD,IAAI,EAAE,KAAK,CAAC,KAAK;aAClB,CAAC;YAEF,IAAM,cAAc,GAAG;gBACrB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;gBAC7B,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;gBACzB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;aAC9B,CAAC;YAEF,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,IAAA,cAAM,EAAC,WAAW,CAAC,IAAI,IAAA,iBAAS,EAAC,cAAc,EAAE,WAAW,CAAC,EAAE;gBAClG,cAAc,CAAC,KAAK,CAAC,4DAA4D,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBAEjG,OAAO;aACR;YAED,WAAW,GAAG,cAAc,CAAC;YAE7B,cAAc,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;YAE5C,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAC1B;QAAC,OAAO,GAAG,EAAE;YACZ,cAAc,CAAC,KAAK,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;SAClD;IACH,CAAC,CAAC;IAEF,OAAO;QACL,OAAO,SAAA;KACR,CAAC;AACJ,CAAC;AArED,8CAqEC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItem, TransportItemType } from '../../transports';\nimport type { Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { deepEqual, defaultLogLevel, getCurrentTimestamp, isNull } from '../../utils';\nimport type { TracesAPI } from '../traces';\n\nimport type { LogEvent, LogsAPI } from './types';\n\nexport function initializeLogsAPI(\n _unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas,\n transports: Transports,\n tracesApi: TracesAPI\n): LogsAPI {\n internalLogger.debug('Initializing logs API');\n\n let lastPayload: Pick<LogEvent, 'message' | 'level' | 'context'> | null = null;\n\n const logArgsSerializer =\n config.logArgsSerializer ??\n ((args) =>\n args\n .map((arg) => {\n try {\n return String(arg);\n } catch (err) {\n return '';\n }\n })\n .join(' '));\n\n const pushLog: LogsAPI['pushLog'] = (args, { context, level, skipDedupe, spanContext } = {}) => {\n try {\n const item: TransportItem<LogEvent> = {\n type: TransportItemType.LOG,\n payload: {\n message: logArgsSerializer(args),\n level: level ?? defaultLogLevel,\n context: context ?? {},\n timestamp: getCurrentTimestamp(),\n trace: spanContext\n ? {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n }\n : tracesApi.getTraceContext(),\n },\n meta: metas.value,\n };\n\n const testingPayload = {\n message: item.payload.message,\n level: item.payload.level,\n context: item.payload.context,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping log 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 log\\n', item);\n\n transports.execute(item);\n } catch (err) {\n internalLogger.error('Error pushing log\\n', err);\n }\n };\n\n return {\n pushLog,\n };\n}\n"]}
|
|
@@ -5,11 +5,12 @@ var testUtils_1 = require("../../testUtils");
|
|
|
5
5
|
var utils_1 = require("../../utils");
|
|
6
6
|
describe('api.logs', function () {
|
|
7
7
|
function createAPI(_a) {
|
|
8
|
-
var _b = _a === void 0 ? { dedupe: true } : _a, dedupe = _b.dedupe;
|
|
8
|
+
var _b = _a === void 0 ? { dedupe: true } : _a, dedupe = _b.dedupe, logArgsSerializer = _b.logArgsSerializer;
|
|
9
9
|
var transport = new testUtils_1.MockTransport();
|
|
10
10
|
var config = (0, testUtils_1.mockConfig)({
|
|
11
11
|
dedupe: dedupe,
|
|
12
12
|
transports: [transport],
|
|
13
|
+
logArgsSerializer: logArgsSerializer,
|
|
13
14
|
});
|
|
14
15
|
var api = (0, initialize_1.initializeFaro)(config).api;
|
|
15
16
|
return [api, transport];
|
|
@@ -90,6 +91,21 @@ describe('api.logs', function () {
|
|
|
90
91
|
});
|
|
91
92
|
});
|
|
92
93
|
});
|
|
94
|
+
describe('Serializing', function () {
|
|
95
|
+
it('serializes log arguments via String', function () {
|
|
96
|
+
var _a;
|
|
97
|
+
api.pushLog([1, 'test', { a: 1 }]);
|
|
98
|
+
expect(((_a = transport.items[0]) === null || _a === void 0 ? void 0 : _a.payload).message).toBe('1 test [object Object]');
|
|
99
|
+
});
|
|
100
|
+
it('uses custom logArgsSerializer', function () {
|
|
101
|
+
var _a;
|
|
102
|
+
var _b;
|
|
103
|
+
var logArgsSerializer = function (args) { return JSON.stringify(args); };
|
|
104
|
+
_a = createAPI({ dedupe: true, logArgsSerializer: logArgsSerializer }), api = _a[0], transport = _a[1];
|
|
105
|
+
api.pushLog([1, 'test', { a: 1 }]);
|
|
106
|
+
expect(((_b = transport.items[0]) === null || _b === void 0 ? void 0 : _b.payload).message).toBe('[1,"test",{"a":1}]');
|
|
107
|
+
});
|
|
108
|
+
});
|
|
93
109
|
});
|
|
94
110
|
});
|
|
95
111
|
//# sourceMappingURL=initialize.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.test.js","sourceRoot":"","sources":["../../../../../../src/api/logs/initialize.test.ts"],"names":[],"mappings":";;AAAA,+CAAkD;AAClD,6CAA4D;AAC5D,qCAAuC;AAKvC,QAAQ,CAA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,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;gBACnC,MAAM,CAAC,CAAC,MAAA,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,0CAAE,OAAoB,CAAA,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YACvF,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { initializeFaro } from '../../initialize';\nimport { mockConfig, MockTransport } from '../../testUtils';\nimport { LogLevel } from '../../utils';\nimport type { API } from '../types';\n\nimport type { LogArgsSerializer, LogEvent, PushLogOptions } from './types';\n\ndescribe('api.logs', () => {\n function createAPI(\n { dedupe, logArgsSerializer }: { dedupe: boolean; logArgsSerializer?: LogArgsSerializer } = { dedupe: true }\n ): [API, MockTransport] {\n const transport = new MockTransport();\n const config = mockConfig({\n dedupe,\n transports: [transport],\n logArgsSerializer,\n });\n\n const { api } = initializeFaro(config);\n\n return [api, transport];\n }\n\n describe('pushLog', () => {\n let api: API;\n let transport: MockTransport;\n\n beforeEach(() => {\n [api, transport] = createAPI();\n });\n\n describe('Filtering', () => {\n it('filters the same event', () => {\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n });\n\n it(\"doesn't filter events with partially same message\", () => {\n api.pushLog(['test', 'another test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter events with same message and different level\", () => {\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test'], {\n level: LogLevel.INFO,\n });\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter events with same message and same level but different context\", () => {\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test'], {\n context: {\n a: '1',\n },\n });\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"filters an event and doesn't filter the next different one\", () => {\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test'], {\n level: LogLevel.ERROR,\n });\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter when dedupe is false\", () => {\n [api, transport] = createAPI({ dedupe: false });\n\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(2);\n });\n\n it(\"doesn't filter when skipDedupe is true\", () => {\n api.pushLog(['test']);\n expect(transport.items).toHaveLength(1);\n\n api.pushLog(['test'], { skipDedupe: true });\n expect(transport.items).toHaveLength(2);\n });\n\n it('uses traceId and spanId from custom context', () => {\n const spanContext: PushLogOptions['spanContext'] = {\n traceId: 'my-trace-id',\n spanId: 'my-span-id',\n };\n\n api.pushLog(['test'], { spanContext });\n expect(transport.items).toHaveLength(1);\n\n expect((transport.items[0]?.payload as LogEvent).trace).toStrictEqual({\n trace_id: 'my-trace-id',\n span_id: 'my-span-id',\n });\n });\n });\n describe('Serializing', () => {\n it('serializes log arguments via String', () => {\n api.pushLog([1, 'test', { a: 1 }]);\n expect((transport.items[0]?.payload as LogEvent).message).toBe('1 test [object Object]');\n });\n\n it('uses custom logArgsSerializer', () => {\n const logArgsSerializer: LogArgsSerializer = (args) => JSON.stringify(args);\n\n [api, transport] = createAPI({ dedupe: true, logArgsSerializer });\n\n api.pushLog([1, 'test', { a: 1 }]);\n expect((transport.items[0]?.payload as LogEvent).message).toBe('[1,\"test\",{\"a\":1}]');\n });\n });\n });\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/api/logs/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { LogLevel } from '../../utils';\nimport type { TraceContext } from '../traces';\n\nexport type LogContext = Record<string, string>;\n\nexport interface LogEvent {\n context: LogContext;\n level: LogLevel;\n message: string;\n timestamp: string;\n\n trace?: TraceContext;\n}\n\nexport interface PushLogOptions {\n context?: LogContext;\n level?: LogLevel;\n skipDedupe?: boolean;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n}\n\nexport interface LogsAPI {\n pushLog: (args: unknown[], options?: PushLogOptions) => void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/api/logs/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { LogLevel } from '../../utils';\nimport type { TraceContext } from '../traces';\n\nexport type LogContext = Record<string, string>;\n\nexport interface LogEvent {\n context: LogContext;\n level: LogLevel;\n message: string;\n timestamp: string;\n\n trace?: TraceContext;\n}\n\nexport interface PushLogOptions {\n context?: LogContext;\n level?: LogLevel;\n skipDedupe?: boolean;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n}\n\nexport interface LogsAPI {\n pushLog: (args: unknown[], options?: PushLogOptions) => void;\n}\n\nexport type LogArgsSerializer = (args: unknown[]) => string;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/config/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { APIEvent, StacktraceParser } from '../api';\nimport type { Instrumentation } from '../instrumentations';\nimport type { InternalLoggerLevel } from '../internalLogger';\nimport type { Meta, MetaApp, MetaItem, MetaSession, MetaUser, MetaView } from '../metas';\nimport type { BatchExecutorOptions, BeforeSendHook, Transport } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\n\ntype SamplingContext = {\n metas: Meta;\n};\n\nexport interface Config<P = APIEvent> {\n app: MetaApp;\n batching?: BatchExecutorOptions;\n dedupe: boolean;\n globalObjectKey: string;\n instrumentations: Instrumentation[];\n internalLoggerLevel: InternalLoggerLevel;\n isolate: boolean;\n metas: MetaItem[];\n parseStacktrace: StacktraceParser;\n paused: boolean;\n preventGlobalExposure: boolean;\n transports: Transport[];\n unpatchedConsole: UnpatchedConsole;\n\n beforeSend?: BeforeSendHook<P>;\n ignoreErrors?: Patterns;\n ignoreUrls?: Patterns;\n sessionTracking?: {\n enabled?: boolean;\n persistent?: boolean;\n session?: MetaSession;\n maxSessionPersistenceTime?: number;\n onSessionChange?: (oldSession: MetaSession | null, newSession: MetaSession) => void;\n samplingRate?: number;\n sampler?: (context: SamplingContext) => number;\n generateSessionId?: () => string;\n };\n\n user?: MetaUser;\n view?: MetaView;\n eventDomain?: string;\n\n trackResources?: boolean;\n}\n\nexport type Patterns = Array<string | RegExp>;\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/config/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { APIEvent, LogArgsSerializer, StacktraceParser } from '../api';\nimport type { Instrumentation } from '../instrumentations';\nimport type { InternalLoggerLevel } from '../internalLogger';\nimport type { Meta, MetaApp, MetaItem, MetaSession, MetaUser, MetaView } from '../metas';\nimport type { BatchExecutorOptions, BeforeSendHook, Transport } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\n\ntype SamplingContext = {\n metas: Meta;\n};\n\nexport interface Config<P = APIEvent> {\n app: MetaApp;\n batching?: BatchExecutorOptions;\n dedupe: boolean;\n globalObjectKey: string;\n instrumentations: Instrumentation[];\n internalLoggerLevel: InternalLoggerLevel;\n isolate: boolean;\n logArgsSerializer?: LogArgsSerializer;\n metas: MetaItem[];\n parseStacktrace: StacktraceParser;\n paused: boolean;\n preventGlobalExposure: boolean;\n transports: Transport[];\n unpatchedConsole: UnpatchedConsole;\n\n beforeSend?: BeforeSendHook<P>;\n ignoreErrors?: Patterns;\n ignoreUrls?: Patterns;\n sessionTracking?: {\n enabled?: boolean;\n persistent?: boolean;\n session?: MetaSession;\n maxSessionPersistenceTime?: number;\n onSessionChange?: (oldSession: MetaSession | null, newSession: MetaSession) => void;\n samplingRate?: number;\n sampler?: (context: SamplingContext) => number;\n generateSessionId?: () => string;\n };\n\n user?: MetaUser;\n view?: MetaView;\n eventDomain?: string;\n\n trackResources?: boolean;\n}\n\nexport type Patterns = Array<string | RegExp>;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.7.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../../src/version.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACzB,QAAA,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// auto-generated by bin/genVersion.ts\nexport const VERSION = '1.7.2';\n"]}
|
|
@@ -3,7 +3,7 @@ export type { API, APIEvent } from './types';
|
|
|
3
3
|
export type { EventAttributes, EventEvent, EventsAPI } from './events';
|
|
4
4
|
export { defaultExceptionType } from './exceptions';
|
|
5
5
|
export type { ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, PushErrorOptions, Stacktrace, StacktraceParser, } from './exceptions';
|
|
6
|
-
export type { LogContext, LogEvent, LogsAPI, PushLogOptions } from './logs';
|
|
6
|
+
export type { LogContext, LogEvent, LogArgsSerializer, LogsAPI, PushLogOptions } from './logs';
|
|
7
7
|
export type { MeasurementEvent, MeasurementsAPI, PushMeasurementOptions } from './measurements';
|
|
8
8
|
export type { MetaAPI } from './meta';
|
|
9
9
|
export type { OTELApi, TraceContext, TraceEvent, TracesAPI } from './traces';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { initializeLogsAPI } from './initialize';
|
|
2
|
-
export type { LogContext, LogEvent, LogsAPI, PushLogOptions } from './types';
|
|
2
|
+
export type { LogContext, LogEvent, LogArgsSerializer, LogsAPI, PushLogOptions } from './types';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { APIEvent, StacktraceParser } from '../api';
|
|
1
|
+
import type { APIEvent, LogArgsSerializer, StacktraceParser } from '../api';
|
|
2
2
|
import type { Instrumentation } from '../instrumentations';
|
|
3
3
|
import type { InternalLoggerLevel } from '../internalLogger';
|
|
4
4
|
import type { Meta, MetaApp, MetaItem, MetaSession, MetaUser, MetaView } from '../metas';
|
|
@@ -15,6 +15,7 @@ export interface Config<P = APIEvent> {
|
|
|
15
15
|
instrumentations: Instrumentation[];
|
|
16
16
|
internalLoggerLevel: InternalLoggerLevel;
|
|
17
17
|
isolate: boolean;
|
|
18
|
+
logArgsSerializer?: LogArgsSerializer;
|
|
18
19
|
metas: MetaItem[];
|
|
19
20
|
parseStacktrace: StacktraceParser;
|
|
20
21
|
paused: boolean;
|
|
@@ -3,7 +3,7 @@ export type { API, APIEvent } from './types';
|
|
|
3
3
|
export type { EventAttributes, EventEvent, EventsAPI } from './events';
|
|
4
4
|
export { defaultExceptionType } from './exceptions';
|
|
5
5
|
export type { ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, PushErrorOptions, Stacktrace, StacktraceParser, } from './exceptions';
|
|
6
|
-
export type { LogContext, LogEvent, LogsAPI, PushLogOptions } from './logs';
|
|
6
|
+
export type { LogContext, LogEvent, LogArgsSerializer, LogsAPI, PushLogOptions } from './logs';
|
|
7
7
|
export type { MeasurementEvent, MeasurementsAPI, PushMeasurementOptions } from './measurements';
|
|
8
8
|
export type { MetaAPI } from './meta';
|
|
9
9
|
export type { OTELApi, TraceContext, TraceEvent, TracesAPI } from './traces';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { initializeLogsAPI } from './initialize';
|
|
2
|
-
export type { LogContext, LogEvent, LogsAPI, PushLogOptions } from './types';
|
|
2
|
+
export type { LogContext, LogEvent, LogArgsSerializer, LogsAPI, PushLogOptions } from './types';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { APIEvent, StacktraceParser } from '../api';
|
|
1
|
+
import type { APIEvent, LogArgsSerializer, StacktraceParser } from '../api';
|
|
2
2
|
import type { Instrumentation } from '../instrumentations';
|
|
3
3
|
import type { InternalLoggerLevel } from '../internalLogger';
|
|
4
4
|
import type { Meta, MetaApp, MetaItem, MetaSession, MetaUser, MetaView } from '../metas';
|
|
@@ -15,6 +15,7 @@ export interface Config<P = APIEvent> {
|
|
|
15
15
|
instrumentations: Instrumentation[];
|
|
16
16
|
internalLoggerLevel: InternalLoggerLevel;
|
|
17
17
|
isolate: boolean;
|
|
18
|
+
logArgsSerializer?: LogArgsSerializer;
|
|
18
19
|
metas: MetaItem[];
|
|
19
20
|
parseStacktrace: StacktraceParser;
|
|
20
21
|
paused: boolean;
|
|
@@ -4,7 +4,7 @@ import type { Transport, TransportItem } from '../transports';
|
|
|
4
4
|
export declare class MockTransport extends BaseTransport implements Transport {
|
|
5
5
|
private ignoreURLs;
|
|
6
6
|
readonly name = "@grafana/transport-mock";
|
|
7
|
-
readonly version = "1.7.
|
|
7
|
+
readonly version = "1.7.2";
|
|
8
8
|
items: TransportItem[];
|
|
9
9
|
constructor(ignoreURLs?: Patterns);
|
|
10
10
|
send(items: TransportItem[]): void | Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.7.
|
|
1
|
+
export declare const VERSION = "1.7.2";
|
|
@@ -4,7 +4,7 @@ import type { Transport, TransportItem } from '../transports';
|
|
|
4
4
|
export declare class MockTransport extends BaseTransport implements Transport {
|
|
5
5
|
private ignoreURLs;
|
|
6
6
|
readonly name = "@grafana/transport-mock";
|
|
7
|
-
readonly version = "1.7.
|
|
7
|
+
readonly version = "1.7.2";
|
|
8
8
|
items: TransportItem[];
|
|
9
9
|
constructor(ignoreURLs?: Patterns);
|
|
10
10
|
send(items: TransportItem[]): void | Promise<void>;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.7.
|
|
1
|
+
export declare const VERSION = "1.7.2";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/faro-core",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"description": "Core package of Faro.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"observability",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "1561e10c2a8e46fd765589d7aaf38e68731edd23"
|
|
61
61
|
}
|