@exceptionless/core
Advanced tools
Comparing version
@@ -400,3 +400,3 @@ import { DefaultLastReferenceIdManager } from "../lastReferenceIdManager/DefaultLastReferenceIdManager.js"; | ||
get userAgent() { | ||
return "exceptionless-js/3.0.4"; | ||
return "exceptionless-js/3.0.5"; | ||
} | ||
@@ -403,0 +403,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
var S=class{constructor(){this._lastReferenceId=null}getLast(){return this._lastReferenceId}clearLast(){this._lastReferenceId=null}setLast(e){this._lastReferenceId=e}};var x=class{trace(e){this.log("debug",e)}info(e){this.log("info",e)}warn(e){this.log("warn",e)}error(e){this.log("error",e)}log(e,t){if(console){let i=`Exceptionless:${new Date().toISOString()} [${e}] ${t}`,r=console[e];r?r(i):console.log&&console.log(i)}}};var _=class{trace(e){}info(e){}warn(e){}error(e){}};var G=(c=>(c.Error="@error",c.SimpleError="@simple_error",c.RequestInfo="@request",c.TraceLog="@trace",c.EnvironmentInfo="@environment",c.UserInfo="@user",c.UserDescription="@user_description",c.Version="@version",c.Level="@level",c.SubmissionMethod="@submission_method",c.ManualStackingInfo="@stack",c))(G||{});function F(s){if(!s||s.length===0)return 0;let e=0;for(let t=0;t<s.length;t++){let i=s.charCodeAt(t);e=(e<<5)-e+i,e|=0}return e}function te(s,e){let t={},i=(s||"").split("; ");for(let r of i){let n=r.split("=");y(n[0],e||[])||(t[n[0]]=n[1])}return d(t)?null:t}function b(){function s(){return Math.floor((1+Math.random())*65536).toString(16).substring(1)}return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}function ie(s){if(!s)return null;let t=/(v?((\d+)\.(\d+)(\.(\d+))?)(?:-([\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*))?(?:\+([\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*))?)/.exec(s);return t&&t.length>0?t[0]:null}function re(s,e){if(!s||s.length===0)return{};let t=s.split("&");if(t.length===0)return{};let i={};for(let r of t){let n=r.split("=");(!e||!y(n[0],e))&&(i[decodeURIComponent(n[0])]=decodeURIComponent(n[1]))}return d(i)?{}:i}function ne(){return Math.floor(Math.random()*9007199254740992)}function y(s,e,t=!0){if(typeof s!="string")return!1;let i=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;return s=(t?s.toLowerCase():s).replace(i,""),(e||[]).some(r=>{if(typeof r!="string")return!1;if(r&&(r=(t?r.toLowerCase():r).replace(i,"")),!r)return s==null;if(r==="*")return!0;if(s==null)return!1;let n=r[0]==="*";n&&(r=r.slice(1));let o=r[r.length-1]==="*";return o&&(r=r.substring(0,r.length-1)),n&&o?r.length<=s.length&&s.indexOf(r,0)!==-1:n?Z(s,r):o?V(s,r):s===r})}function d(s){if(s==null)return!0;if(typeof s=="object")return Array.isArray(s)?s.length===0:s instanceof Date?!1:Object.getOwnPropertyNames(s).length===0;if(typeof s=="string"){let e=s.trim();return e.length===0||e==="{}"||e==="[]"}return!1}function V(s,e){return s.substring(0,e.length)===e}function Z(s,e){return s.indexOf(e,s.length-e.length)!==-1}function X(s,e=10){function t(n){if(n==null)return!1;switch(typeof n){case"function":return!0;case"object":switch(Object.prototype.toString.call(n)){case"[object AsyncGenerator]":case"[object Generator]":case"[object ArrayBuffer]":case"[object Buffer]":case"[object DataView]":case"[object Promise]":case"[object WeakMap]":case"[object WeakSet]":return!0}if("writeBigInt64LE"in n)return!0;break}return!1}function i(n){function o(a){return a!==null&&typeof a=="object"&&typeof a.toJSON=="function"}if(typeof n=="bigint")return`${n.toString()}n`;if(typeof n=="object"){if(Array.isArray(n)||n instanceof Date)return n;if(n instanceof Map){let l={};for(let[g,u]of n)l[g]=u;return l}if(n instanceof RegExp)return n.toString();if(n instanceof Set)return Array.from(n);let a=Object.getPrototypeOf(Uint8Array);return n instanceof a?Array.from(n):o(n)?i(n.toJSON()):n}return typeof n=="symbol"?n.description:n}function r(n,o,a=10,l=new WeakSet,g=!1){if(n==null)return n;if(a>o||t(n))return;let u=i(n);if(typeof u=="object"){if(a==o)return;if(Array.isArray(u)){let E=g?a+1:a;return u.map(K=>r(K,o,E,l,!0))}if(u instanceof Date)return u;if(Object.prototype.toString.call(u)==="[object Object]"){if(l.has(u))return;l.add(u)}let c=new Set([...Object.getOwnPropertyNames(u),...Object.getOwnPropertySymbols(u)]);for(let E in u)c.add(E);let z={};for(let E of c){let K=i(E),ee=u[E];z[K]=r(ee,o,a+1,l)}return z}return u}if(!(e<0))return r(s,e,0)}function h(s,e,t=10){function i(n,o){return JSON.stringify(n,(a,l)=>{if(!y(a,o))return l})}if(s===void 0)return s;let r=X(s,t);return i(r,e||[])}function W(s,e=!1){if(typeof s=="boolean")return s;if(s===null||typeof s!="number"&&typeof s!="string")return e;switch((s+"").toLowerCase().trim()){case"true":case"yes":case"1":return!0;case"false":case"no":case"0":case null:return!1}return e}function se(s,e="Unknown Error"){if(s==null){let i=new Error(e);return i.stack=void 0,i}if(s instanceof Error)return s;if(typeof s=="string"){let i=new Error(s);return i.stack=void 0,i}let t=new Error(h(s)||e);return t.stack=void 0,t}function f(s){typeof s=="object"&&"unref"in s&&s.unref()}var w=class{constructor(e=6e4){this.priority=100;this.name="HeartbeatPlugin";this._interval=e>=3e4?e:6e4}startup(){return clearInterval(this._intervalId),this._intervalId=void 0,Promise.resolve()}suspend(){return clearInterval(this._intervalId),this._intervalId=void 0,Promise.resolve()}run(e){if(this._interval<=0)return Promise.resolve();clearInterval(this._intervalId),this._intervalId=void 0;let{config:t}=e.client;if(!t.currentSessionIdentifier){let i=e.event.data?.["@user"];if(!i?.identity)return Promise.resolve();t.currentSessionIdentifier=i.identity}return t.currentSessionIdentifier&&(this._intervalId=setInterval(()=>void e.client.submitSessionHeartbeat(t.currentSessionIdentifier),this._interval),f(this._intervalId)),Promise.resolve()}};var C=class{constructor(){this.priority=25;this.name="SessionIdManagementPlugin"}run(e){let t=e.event,i=t.type==="session",{config:r}=e.client;return(i||!r.currentSessionIdentifier)&&(r.currentSessionIdentifier=b().replaceAll("-","")),i?t.reference_id=r.currentSessionIdentifier:(t.data||(t.data={}),t.data["@ref:session"]=r.currentSessionIdentifier),Promise.resolve()}};var U=class{constructor(){this.priority=10;this.name="ConfigurationDefaultsPlugin"}run(e){let{dataExclusions:t,defaultData:i,defaultTags:r}=e.client.config,n=e.event;if(r&&(n.tags=[...n.tags||[],...r]),i){n.data||(n.data={});for(let o in i){if(n.data[o]!==void 0||d(i[o]))continue;let a=h(i[o],t);d(a)||(n.data[o]=JSON.parse(a))}}return Promise.resolve()}};var k=class{constructor(e=()=>Date.now(),t=3e4){this.priority=1010;this.name="DuplicateCheckerPlugin";this._mergedEvents=[];this._processedHashCodes=[];this._getCurrentTime=e,this._interval=t}startup(){return clearInterval(this._intervalId),this._intervalId=setInterval(()=>void this.submitEvents(),this._interval),f(this._intervalId),Promise.resolve()}async suspend(){clearInterval(this._intervalId),this._intervalId=void 0,await this.submitEvents()}run(e){function t(n){let o=0;for(;n;)n.message&&n.message.length&&(o+=o*397^F(n.message)),n.stack_trace&&n.stack_trace.length&&(o+=o*397^F(JSON.stringify(n.stack_trace))),n=n.inner;return o}let i=e.event.data?.["@error"],r=t(i);if(r){let n=e.event.count||1,o=this._getCurrentTime(),a=this._mergedEvents.filter(l=>l.hashCode===r)[0];if(a&&(a.incrementCount(n),a.updateDate(e.event.date),e.log.info("Ignoring duplicate event with hash: "+r),e.cancelled=!0),!e.cancelled&&this._processedHashCodes.some(l=>l.hash===r&&l.timestamp>=o-this._interval)&&(e.log.trace("Adding event with hash: "+r),this._mergedEvents.push(new O(r,e,n)),e.cancelled=!0),!e.cancelled)for(e.log.trace(`Enqueueing event with hash: ${r} to cache`),this._processedHashCodes.push({hash:r,timestamp:o});this._processedHashCodes.length>50;)this._processedHashCodes.shift()}return Promise.resolve()}async submitEvents(){for(;this._mergedEvents.length>0;)await this._mergedEvents.shift()?.resubmit()}},O=class{constructor(e,t,i){this.hashCode=e,this._context=t,this._count=i}incrementCount(e){this._count+=e}async resubmit(){this._context.event.count=this._count,await this._context.client.config.services.queue.enqueue(this._context.event)}updateDate(e){let t=this._context.event;e&&t.date&&e>t.date&&(t.date=e)}};var L=class{constructor(){this.priority=45;this.name="EventExclusionPlugin"}run(e){let t=e.event,i=e.log,r=e.client.config.settings;if(t.type==="log"){let n=this.getMinLogLevel(r,t.source),o=this.getLogLevel(t.data&&t.data["@level"]);o!==-1&&(o===6||o<n)&&(i.info("Cancelling log event due to minimum log level."),e.cancelled=!0)}else if(t.type==="error"){let n=t.data&&t.data["@error"];for(;!e.cancelled&&n;)this.getTypeAndSourceSetting(r,t.type,n.type,!0)===!1&&(i.info(`Cancelling error from excluded exception type: ${n.type}`),e.cancelled=!0),n=n.inner}else this.getTypeAndSourceSetting(r,t.type,t.source,!0)===!1&&(i.info(`Cancelling event from excluded type: ${t.type} and source: ${t.source}`),e.cancelled=!0);return Promise.resolve()}getLogLevel(e){switch((e||"").toLowerCase().trim()){case"trace":case"true":case"1":case"yes":return 0;case"debug":return 1;case"info":return 2;case"warn":return 3;case"error":return 4;case"fatal":return 5;case"off":case"false":case"0":case"no":return 6;default:return-1}}getMinLogLevel(e,t){return this.getLogLevel(this.getTypeAndSourceSetting(e,"log",t,"other")+"")}getTypeAndSourceSetting(e={},t,i,r){if(!t)return r;i||(i="");let n=t==="log",o=`@@${t}:`,a=e[o+i];if(a)return n?a:W(a);let l=Object.keys(e).sort((g,u)=>u.length-g.length||g.localeCompare(u));for(let g of l){if(!V(g.toLowerCase(),o))continue;let u=g.substring(o.length);if(y(i,[u]))return n?e[g]:W(e[g])}return r}};var R=class{constructor(){this.priority=20;this.name="ReferenceIdPlugin"}run(e){return!e.event.reference_id&&e.event.type==="error"&&(e.event.reference_id=b().replaceAll("-","").substring(0,10)),Promise.resolve()}};var Y=["arguments","column","columnNumber","description","fileName","message","name","number","line","lineNumber","opera#sourceloc","sourceId","sourceURL","stack","stackArray","stacktrace"],T=class{constructor(){this.priority=30;this.name="SimpleErrorPlugin"}async run(e){let t=e.eventContext.getException();if(t&&(e.event.type||(e.event.type="error"),e.event.data&&!e.event.data["@simple_error"])){let i={type:t.name||"Error",message:t.message,stack_trace:t.stack,data:{}},r=e.client.config.dataExclusions.concat(Y),n=h(t,r);d(n)||(i.data["@ext"]=JSON.parse(n)),e.event.data["@simple_error"]=i}return Promise.resolve()}};var $=class{constructor(){this.priority=100;this.name="SubmissionMethodPlugin"}run(e){let t=e.eventContext.getSubmissionMethod();return t&&e.event.data&&(e.event.data["@submission_method"]=t),Promise.resolve()}};var m=class{static async startup(e){for(let t of e.client.config.plugins)if(t.startup)try{await t.startup(e)}catch(i){e.log.error(`Error running plugin startup"${t.name}": ${i instanceof Error?i.message:i+""}`)}}static async suspend(e){for(let t of e.client.config.plugins)if(t.suspend)try{await t.suspend(e)}catch(i){e.log.error(`Error running plugin suspend"${t.name}": ${i instanceof Error?i.message:i+""}`)}}static async run(e){for(let t of e.client.config.plugins){if(e.cancelled)break;if(t.run)try{await t.run(e)}catch(i){e.cancelled=!0,e.log.error(`Error running plugin "${t.name}": ${i instanceof Error?i.message:i+""}. Discarding Event.`)}}}static addDefaultPlugins(e){e.addPlugin(new U),e.addPlugin(new T),e.addPlugin(new R),e.addPlugin(new k),e.addPlugin(new L),e.addPlugin(new $)}};var M=class{constructor(e,t=250){this.config=e;this.maxItems=t;this._handlers=[];this._processingQueue=!1;this.QUEUE_PREFIX="q:";this._lastFileTimestamp=0;this._queue=[];this._loadPersistedEvents=!0}async enqueue(e){let t="The event will not be queued.",i=this.config,r=i.services.log;if(!i.enabled){r.info(`Configuration is disabled. ${t}`);return}if(!i.isValid){r.info(`Invalid Api Key. ${t}`);return}if(this.areQueuedItemsDiscarded()){r.info(`Queue items are currently being discarded. ${t}`);return}let n=await this.enqueueEvent(e),o=`type=${e.type} reference_id=${e.reference_id} source=${e.source} message=${e.message}`;r.info(`Enqueued event: ${n} (${o})`)}async process(){let e="The queue will not be processed",{log:t}=this.config.services;if(!this._processingQueue){if(t.trace("Processing queue..."),!this.config.enabled){t.info(`Configuration is disabled: ${e}`);return}if(!this.config.isValid){t.info(`Invalid Api Key: ${e}`);return}this._processingQueue=!0;try{this._loadPersistedEvents&&(this.config.usePersistedQueueStorage&&await this.loadEvents(),this._loadPersistedEvents=!1);let i=this._queue.slice(0,this.config.submissionBatchSize);if(!i||i.length===0){this._processingQueue=!1;return}t.info(`Sending ${i.length} events to ${this.config.serverUrl}`);let r=i.map(o=>o.event),n=await this.config.services.submissionClient.submitEvents(r);await this.processSubmissionResponse(n,i),await this.eventsPosted(r,n),t.trace("Finished processing queue"),this._processingQueue=!1}catch(i){t.error(`Error processing queue: ${i instanceof Error?i.message:i+""}`),await this.suspendProcessing(),this._processingQueue=!1}}}startup(){return this._queueIntervalId||(this._queueIntervalId=setInterval(()=>void this.onProcessQueue(),1e4),f(this._queueIntervalId)),Promise.resolve()}suspend(){return clearInterval(this._queueIntervalId),this._queueIntervalId=void 0,Promise.resolve()}async suspendProcessing(e,t,i){let r=this.config,n=new Date;(!e||e<=0)&&(e=Math.ceil(n.getMinutes()/15)*15-n.getMinutes()),r.services.log.info(`Suspending processing for ${e} minutes.`),this._suspendProcessingUntil=new Date(n.getTime()+e*6e4),t&&(this._discardQueuedItemsUntil=this._suspendProcessingUntil),i&&await this.removeEvents(this._queue)}onEventsPosted(e){e&&this._handlers.push(e)}async eventsPosted(e,t){let i=this._handlers;for(let r of i)try{await r(e,t)}catch(n){this.config.services.log.error(`Error calling onEventsPosted handler: ${n instanceof Error?n.message:n+""}`)}}areQueuedItemsDiscarded(){return this._discardQueuedItemsUntil&&this._discardQueuedItemsUntil>new Date||!1}isQueueProcessingSuspended(){return this._suspendProcessingUntil&&this._suspendProcessingUntil>new Date||!1}async onProcessQueue(){!this.isQueueProcessingSuspended()&&!this._processingQueue&&await this.process()}async processSubmissionResponse(e,t){let i="The event will not be submitted",r=this.config,n=r.services.log;if(e.status===202){n.info(`Sent ${t.length} events`),await this.removeEvents(t);return}if(e.status===429||e.rateLimitRemaining===0||e.status===503){n.error("Server returned service unavailable"),await this.suspendProcessing();return}if(e.status===402){n.info("Too many events have been submitted, please upgrade your plan"),await this.suspendProcessing(0,!0,!0);return}if(e.status===401||e.status===403){n.info(`Unable to authenticate, please check your configuration. ${i}`),await this.suspendProcessing(15),await this.removeEvents(t);return}if(e.status===400||e.status===404){n.error(`Error while trying to submit data: ${e.message}`),await this.suspendProcessing(60*4),await this.removeEvents(t);return}if(e.status===413){let o="Event submission discarded for being too large.";r.submissionBatchSize>1?(n.error(`${o} Retrying with smaller batch size.`),r.submissionBatchSize=Math.max(1,Math.round(r.submissionBatchSize/1.5))):(n.error(`${o} ${i}`),await this.removeEvents(t));return}n.error(`Error submitting events: ${e.message||"Please check the network tab for more info."}`),await this.suspendProcessing()}async loadEvents(){if(this.config.usePersistedQueueStorage){let{log:e,storage:t}=this.config.services;try{let i=await t.keys();for(let r of i)if(r?.startsWith(this.QUEUE_PREFIX)){let n=await t.getItem(r);n&&this._queue.push({file:r,event:JSON.parse(n)})}}catch(i){e.error(`Error loading queue items from storage: ${i instanceof Error?i.message:i+""}`)}}}async enqueueEvent(e){this._lastFileTimestamp=Math.max(Date.now(),this._lastFileTimestamp+1);let t=`${this.QUEUE_PREFIX}${this._lastFileTimestamp}.json`,{log:i,storage:r}=this.config.services,n=this.config.usePersistedQueueStorage;if(this._queue.push({file:t,event:e})>this.maxItems){i.trace("Removing oldest queue entry: maxItems exceeded");let o=this._queue.shift();if(n&&o)try{await r.removeItem(o.file)}catch(a){i.error(`Error removing oldest queue entry from storage: ${a instanceof Error?a.message:a+""}`)}}if(n)try{await r.setItem(t,JSON.stringify(e))}catch(o){i.error(`Error saving queue entry to storage: ${o instanceof Error?o.message:o+""}`)}return t}async removeEvents(e){let t=e.map(i=>i.file);if(this.config.usePersistedQueueStorage){let{log:i,storage:r}=this.config.services;for(let n of t)try{await r.removeItem(n)}catch(o){i.error(`Error removing queue item from storage: ${o instanceof Error?o.message:o+""}`)}}this._queue=this._queue.filter(i=>!t.includes(i.file))}};var H=class{constructor(e,t){this.settings=e;this.version=t}},I=class I{static async applySavedServerSettings(e){if(!e?.isValid)return;let t=await this.getSavedServerSettings(e);t&&e.applyServerSettings(t)}static async updateSettings(e){if(!e?.enabled||this._isUpdatingSettings)return;this._isUpdatingSettings=!0;let{log:t,storage:i,submissionClient:r}=e.services;try{let n="Unable to update settings";if(!e.isValid){t.error(`${n}: ApiKey is not set`);return}let o=e.settingsVersion;t.trace(`Checking for updated settings from: v${o}`);let a=await r.getSettings(o);if(a.status===304){t.trace("Settings are up-to-date");return}if(!a?.success||!a.data){t.warn(`${n}: ${a.message}`);return}e.applyServerSettings(a.data),await i.setItem(I.SettingsKey,JSON.stringify(a.data)),t.trace(`Updated settings: v${a.data.version}`)}catch(n){t.error(`Error updating settings: ${n instanceof Error?n.message:n+""}`)}finally{this._isUpdatingSettings=!1}}static async getSavedServerSettings(e){let{log:t,storage:i}=e.services;try{let r=await i.getItem(I.SettingsKey);return r&&JSON.parse(r)||new H({},0)}catch(r){return t.error(`Error getting saved settings: ${r instanceof Error?r.message:r+""}`),new H({},0)}}};I.SettingsKey="settings",I._isUpdatingSettings=!1;var v=I;var D=class{constructor(e,t,i,r,n){this.status=e;this.message=t;this.rateLimitRemaining=i;this.settingsVersion=r;this.data=n}get success(){return this.status>=200&&this.status<=299}};var A=class{constructor(e,t=globalThis.fetch?.bind(globalThis)){this.config=e;this.fetch=t;this.RateLimitRemainingHeader="x-ratelimit-remaining";this.ConfigurationVersionHeader="x-exceptionless-configversion"}getSettings(e){let t=`${this.config.serverUrl}/api/v2/projects/config?v=${e}`;return this.apiFetch(t,{method:"GET"})}async submitEvents(e){let t=`${this.config.serverUrl}/api/v2/events`,i=await this.apiFetch(t,{method:"POST",body:JSON.stringify(e)});return await this.updateSettingsVersion(i.settingsVersion),i}async submitUserDescription(e,t){let i=`${this.config.serverUrl}/api/v2/events/by-ref/${encodeURIComponent(e)}/user-description`,r=await this.apiFetch(i,{method:"POST",body:JSON.stringify(t)});return await this.updateSettingsVersion(r.settingsVersion),r}async submitHeartbeat(e,t){let i=`${this.config.heartbeatServerUrl}/api/v2/events/session/heartbeat?id=${e}&close=${t+""}`;return await this.apiFetch(i,{method:"GET"})}async updateSettingsVersion(e){isNaN(e)?this.config.services.log.error("No config version header was returned."):e>this.config.settingsVersion&&await v.updateSettings(this.config)}async apiFetch(e,t){let i={method:t.method,headers:{Accept:"application/json",Authorization:`Bearer ${this.config.apiKey}`,"User-Agent":this.config.userAgent},body:t.body??null};t.method==="POST"&&this.isHeaders(i.headers)&&(i.headers["Content-Type"]="application/json");let r=await this.fetch(e,i),n=parseInt(r.headers.get(this.RateLimitRemainingHeader)||"",10),o=parseInt(r.headers.get(this.ConfigurationVersionHeader)||"",10),a=await r.text(),l=a&&a.length>0?JSON.parse(a):null;return new D(r.status,r.statusText,n,o,l)}isHeaders(e){return e!==void 0}};var j=class{constructor(){this.items=new Map}length(){return Promise.resolve(this.items.size)}clear(){return this.items.clear(),Promise.resolve()}getItem(e){let t=this.items.get(e);return Promise.resolve(t||null)}async key(e){if(e<0)return Promise.resolve(null);let t=await this.keys();if(e>t.length)return Promise.resolve(null);let i=t[e];return Promise.resolve(i||null)}keys(){return Promise.resolve(Array.from(this.items.keys()))}removeItem(e){return this.items.delete(e),Promise.resolve()}setItem(e,t){return this.items.set(e,t),Promise.resolve()}};var q=class{constructor(e="exceptionless-",t=globalThis.localStorage){this.prefix=e;this.storage=t}length(){return Promise.resolve(this.getKeys().length)}clear(){for(let e of this.getKeys())this.storage.removeItem(this.getKey(e));return Promise.resolve()}getItem(e){return Promise.resolve(this.storage.getItem(this.getKey(e)))}key(e){let t=this.getKeys();return Promise.resolve(e<t.length?t[e]:null)}keys(){return Promise.resolve(this.getKeys())}removeItem(e){return this.storage.removeItem(this.getKey(e)),Promise.resolve()}setItem(e,t){return this.storage.setItem(this.getKey(e),t),Promise.resolve()}getKeys(){return Object.keys(this.storage).filter(e=>e.startsWith(this.prefix)).map(e=>e?.substr(this.prefix.length))}getKey(e){return this.prefix+e}};var B=class{constructor(){this.defaultTags=[];this.defaultData={};this.enabled=!0;this.submissionBatchSize=50;this.settings={};this.settingsVersion=0;this.apiKey="";this._serverUrl="https://collector.exceptionless.io";this.configServerUrl="https://config.exceptionless.io";this.heartbeatServerUrl="https://heartbeat.exceptionless.io";this._updateSettingsWhenIdleInterval=12e4;this._dataExclusions=[];this._includePrivateInformation=!0;this._includeUserName=!0;this._includeMachineName=!0;this._includeIpAddress=!0;this._includeHeaders=!0;this._includeCookies=!0;this._includePostData=!0;this._includeQueryString=!0;this._userAgentBotPatterns=[];this._plugins=[];this._subscribers=[];this.usePersistedQueueStorage=!1;this.sessionsEnabled=!1;this.currentSessionIdentifier=null;this.services={lastReferenceIdManager:new S,log:new _,storage:new j,queue:new M(this),submissionClient:new A(this)},m.addDefaultPlugins(this)}get isValid(){return this.apiKey?.length>=10}get serverUrl(){return this._serverUrl}set serverUrl(e){e&&(this._serverUrl=e,this.configServerUrl=e,this.heartbeatServerUrl=e)}get updateSettingsWhenIdleInterval(){return this._updateSettingsWhenIdleInterval}set updateSettingsWhenIdleInterval(e){typeof e=="number"&&(e<=0?e=-1:e>0&&e<12e4&&(e=12e4),this._updateSettingsWhenIdleInterval=e)}get dataExclusions(){let e=this.settings["@@DataExclusions"];return this._dataExclusions.concat(e&&e.split(",")||[])}addDataExclusions(...e){this._dataExclusions=[...this._dataExclusions,...e]}get includePrivateInformation(){return this._includePrivateInformation}set includePrivateInformation(e){let t=e===!0;this._includePrivateInformation=t,this._includeUserName=t,this._includeMachineName=t,this._includeIpAddress=t,this._includeHeaders=t,this._includeCookies=t,this._includePostData=t,this._includeQueryString=t}get includeUserName(){return this._includeUserName}set includeUserName(e){this._includeUserName=e===!0}get includeMachineName(){return this._includeMachineName}set includeMachineName(e){this._includeMachineName=e===!0}get includeIpAddress(){return this._includeIpAddress}set includeIpAddress(e){this._includeIpAddress=e===!0}get includeHeaders(){return this._includeHeaders}set includeHeaders(e){this._includeHeaders=e===!0}get includeCookies(){return this._includeCookies}set includeCookies(e){this._includeCookies=e===!0}get includePostData(){return this._includePostData}set includePostData(e){this._includePostData=e===!0}get includeQueryString(){return this._includeQueryString}set includeQueryString(e){this._includeQueryString=e===!0}get userAgentBotPatterns(){let e=this.settings["@@UserAgentBotPatterns"];return this._userAgentBotPatterns.concat(e&&e.split(",")||[])}addUserAgentBotPatterns(...e){this._userAgentBotPatterns=[...this._userAgentBotPatterns,...e]}get plugins(){return this._plugins.sort((e,t)=>e==null&&t==null?0:e?.priority==null?-1:t?.priority==null?1:e.priority==t.priority?0:e.priority>t.priority?1:-1)}addPlugin(e,t,i){let r=i?{name:e,priority:t,run:i}:e;if(!r||!(r.startup||r.run)){this.services.log.error("Add plugin failed: startup or run method not defined");return}r.name||(r.name=b()),r.priority||(r.priority=0),this._plugins.find(n=>n.name===r.name)||this._plugins.push(r)}removePlugin(e){let t=typeof e=="string"?e:e.name||"";if(!t){this.services.log.error("Remove plugin failed: Plugin name not defined");return}let i=this._plugins;for(let r=0;r<i.length;r++)if(i[r].name===t){i.splice(r,1);break}}get version(){return this.defaultData["@version"]}set version(e){e?this.defaultData["@version"]=e:delete this.defaultData["@version"]}setUserIdentity(e,t){let i=typeof e!="string"?e:{identity:e,name:t},r=!i||!i.identity&&!i.name;r?delete this.defaultData["@user"]:this.defaultData["@user"]=i,this.services.log.info(`user identity: ${r?"null":i.identity}`)}get userAgent(){return"exceptionless-js/3.0.4"}useLocalStorage(){globalThis?.localStorage&&(this.services.storage=new q)}useSessions(e=!0,t=6e4,i=!1){this.sessionsEnabled=!0,i&&this.addPlugin(new C);let r=new w(t);e?this.addPlugin(r):this.removePlugin(r)}applyServerSettings(e){this.originalSettings||(this.originalSettings=JSON.parse(JSON.stringify(this.settings))),this.services.log.trace(`Applying saved settings: v${e.version}`),this.settings=Object.assign(this.originalSettings,e.settings),this.settingsVersion=e.version,this.notifySubscribers()}useDebugLogger(){this.services.log=new x}subscribeServerSettingsChange(e){e&&this._subscribers.push(e)}notifySubscribers(){for(let e of this._subscribers)try{e(this)}catch(t){this.services.log.error(`Error calling subscribe handler: ${t instanceof Error?t.message:t+""}`)}}};var p=class{getException(){return this["@@_Exception"]||null}setException(e){e&&(this["@@_Exception"]=e)}get hasException(){return!!this["@@_Exception"]}markAsUnhandledError(){this["@@_IsUnhandledError"]=!0}get isUnhandledError(){return!!this["@@_IsUnhandledError"]}getSubmissionMethod(){return this["@@_SubmissionMethod"]||null}setSubmissionMethod(e){e&&(this["@@_SubmissionMethod"]=e)}};var P=class{constructor(e){this.client=e}get log(){return this.client.config.services.log}};var Q=class{constructor(e,t,i){this.client=e;this.event=t;this.eventContext=i;this.cancelled=!1;this.eventContext||(this.eventContext=new p)}get log(){return this.client.config.services.log}};var N=class{constructor(e,t,i){this._validIdentifierErrorMessage="must contain between 8 and 100 alphanumeric or '-' characters.";this.target=e,this.client=t,this.context=i||new p}setType(e){return e&&(this.target.type=e),this}setSource(e){return e&&(this.target.source=e),this}setReferenceId(e){if(!this.isValidIdentifier(e))throw new Error(`ReferenceId ${this._validIdentifierErrorMessage}`);return this.target.reference_id=e,this}setEventReference(e,t){if(!e)throw new Error("Invalid name");if(!t||!this.isValidIdentifier(t))throw new Error(`Id ${this._validIdentifierErrorMessage}`);return this.setProperty("@ref:"+e,t),this}setMessage(e){return e&&(this.target.message=e),this}setGeo(e,t){if(e<-90||e>90)throw new Error("Must be a valid latitude value between -90.0 and 90.0.");if(t<-180||t>180)throw new Error("Must be a valid longitude value between -180.0 and 180.0.");return this.target.geo=`${e},${t}`,this}setUserIdentity(e,t){let i=typeof e!="string"?e:{identity:e,name:t};return!i||!i.identity&&!i.name?this:(this.setProperty("@user",i),this)}setUserDescription(e,t){return e&&t&&this.setProperty("@user_description",{email_address:e,description:t}),this}setManualStackingInfo(e,t){if(e){let i={signature_data:e};t&&(i.title=t),this.setProperty("@stack",i)}return this}setManualStackingKey(e,t){if(e){let i={ManualStackingKey:e};this.setManualStackingInfo(i,t)}return this}setValue(e){return e&&(this.target.value=e),this}addTags(...e){return this.target.tags=[...this.target.tags||[],...e],this}setProperty(e,t,i,r){if(!e||t===void 0||t==null)return this;this.target.data||(this.target.data={});let n=this.client.config.dataExclusions.concat(r||[]),o=h(t,n,i);return d(o)||(this.target.data[e]=JSON.parse(o)),this}setContextProperty(e,t){return this.context[e]=t,this}markAsCritical(e){return e&&this.addTags("Critical"),this}submit(){return this.client.submitEvent(this.target,this.context)}isValidIdentifier(e){if(!e)return!0;if(e.length<8||e.length>100)return!1;for(let t=0;t<e.length;t++){let i=e.charCodeAt(t),r=i>=48&&i<=57,n=i>=65&&i<=90||i>=97&&i<=122;if(!(r||n)&&!(i===45))return!1}return!0}};var J=class{constructor(e=new B){this.config=e;this._initialized=!1}async startup(e){if(e&&!this._initialized&&(this._initialized=!0,typeof e=="string"?this.config.apiKey=e:e(this.config),this.config.services.queue.onEventsPosted(()=>Promise.resolve(this.updateSettingsTimer())),await v.applySavedServerSettings(this.config)),!this.config.isValid){this.config.services.log.warn("Exceptionless is not configured and will not process events.");return}this.updateSettingsTimer(!!e),await m.startup(new P(this));let{queue:t}=this.config.services;await t.startup(),this.config.usePersistedQueueStorage&&await t.process(),this.config.sessionsEnabled&&await this.submitSessionStart()}async suspend(){await m.suspend(new P(this));let{queue:e}=this.config.services;await e.suspend(),await e.process(),this.suspendSettingsTimer()}suspendSettingsTimer(){clearTimeout(this._timeoutId),this._timeoutId=void 0,clearInterval(this._intervalId),this._intervalId=void 0}async processQueue(){await this.config.services.queue.process()}updateSettingsTimer(e=!1){if(this.suspendSettingsTimer(),!this.config.isValid)return;let t=this.config.updateSettingsWhenIdleInterval;if(t>0){let i=t;e&&(i=this.config.settingsVersion>0?15e3:5e3),this.config.services.log.info(`Update settings every ${t}ms (${i||0}ms delay)`);let r=()=>void v.updateSettings(this.config);i<t&&(this._timeoutId=setTimeout(r,i),f(this._timeoutId)),this._intervalId=setInterval(r,t),f(this._intervalId)}}createException(e){let t=new p;return t.setException(e),this.createEvent(t).setType("error")}submitException(e){return this.createException(e).submit()}createUnhandledException(e,t){let i=this.createException(e);return i.context.markAsUnhandledError(),i.context.setSubmissionMethod(t||""),i}submitUnhandledException(e,t){return this.createUnhandledException(e,t).submit()}createFeatureUsage(e){return this.createEvent().setType("usage").setSource(e)}submitFeatureUsage(e){return this.createFeatureUsage(e).submit()}createLog(e,t,i){let r=this.createEvent().setType("log");if(i)r=r.setSource(e).setMessage(t).setProperty("@level",i);else if(t)r=r.setSource(e).setMessage(t);else{r=r.setMessage(e);try{let n=this.createLog.caller;r=r.setSource(n&&n.caller&&n.caller.name)}catch(n){this.config.services.log.trace(`Unable to resolve log source: ${n instanceof Error?n.message:n+""}`)}}return r}submitLog(e,t,i){return this.createLog(e,t,i).submit()}createNotFound(e){return this.createEvent().setType("404").setSource(e)}submitNotFound(e){return this.createNotFound(e).submit()}createSessionStart(){return this.createEvent().setType("session")}submitSessionStart(){return this.createSessionStart().submit()}async submitSessionEnd(e){let{currentSessionIdentifier:t,enabled:i,isValid:r,services:n}=this.config,o=e||t;o&&i&&r&&(n.log.info(`Submitting session end: ${o}`),await n.submissionClient.submitHeartbeat(o,!0))}async submitSessionHeartbeat(e){let{currentSessionIdentifier:t,enabled:i,isValid:r,services:n}=this.config,o=e||t;o&&i&&r&&(n.log.info(`Submitting session heartbeat: ${o}`),await n.submissionClient.submitHeartbeat(o,!1))}createEvent(e){return new N({date:new Date},this,e)}async submitEvent(e,t){let i=new Q(this,e,t??new p);if(!e)return i.cancelled=!0,i;if(!this.config.enabled||!this.config.isValid)return this.config.services.log.info("Event submission is currently disabled."),i.cancelled=!0,i;if(e.data||(e.data={}),(!e.tags||!e.tags.length)&&(e.tags=[]),await m.run(i),i.cancelled)return i;let r=i.event;return(!r.type||r.type.length===0)&&(r.type="log"),r.date||(r.date=new Date),await this.config.services.queue.enqueue(r),r.reference_id&&r.reference_id.length>0&&(i.log.info(`Setting last reference id "${r.reference_id}"`),this.config.services.lastReferenceIdManager.setLast(r.reference_id)),i}async updateUserEmailAndDescription(e,t,i){if(!e||!t||!i||!this.config.enabled||!this.config.isValid)return;let r={email_address:t,description:i},n=await this.config.services.submissionClient.submitUserDescription(e,r);n.success||this.config.services.log.error(`Failed to submit user email and description for event "${e}": ${n.status} ${n.message}`)}getLastReferenceId(){return this.config.services.lastReferenceIdManager.getLast()}};export{B as Configuration,U as ConfigurationDefaultsPlugin,x as ConsoleLog,M as DefaultEventQueue,S as DefaultLastReferenceIdManager,A as DefaultSubmissionClient,k as DuplicateCheckerPlugin,N as EventBuilder,p as EventContext,L as EventExclusionPlugin,Q as EventPluginContext,m as EventPluginManager,J as ExceptionlessClient,w as HeartbeatPlugin,Y as IgnoredErrorProperties,j as InMemoryStorage,G as KnownEventDataKeys,q as LocalStorage,_ as NullLog,P as PluginContext,R as ReferenceIdPlugin,D as Response,C as SessionIdManagementPlugin,v as SettingsManager,T as SimpleErrorPlugin,$ as SubmissionMethodPlugin,Z as endsWith,te as getCookies,F as getHashCode,b as guid,d as isEmpty,y as isMatch,re as parseQueryString,ie as parseVersion,X as prune,ne as randomNumber,V as startsWith,h as stringify,W as toBoolean,se as toError}; | ||
var S=class{constructor(){this._lastReferenceId=null}getLast(){return this._lastReferenceId}clearLast(){this._lastReferenceId=null}setLast(e){this._lastReferenceId=e}};var x=class{trace(e){this.log("debug",e)}info(e){this.log("info",e)}warn(e){this.log("warn",e)}error(e){this.log("error",e)}log(e,t){if(console){let i=`Exceptionless:${new Date().toISOString()} [${e}] ${t}`,r=console[e];r?r(i):console.log&&console.log(i)}}};var _=class{trace(e){}info(e){}warn(e){}error(e){}};var G=(c=>(c.Error="@error",c.SimpleError="@simple_error",c.RequestInfo="@request",c.TraceLog="@trace",c.EnvironmentInfo="@environment",c.UserInfo="@user",c.UserDescription="@user_description",c.Version="@version",c.Level="@level",c.SubmissionMethod="@submission_method",c.ManualStackingInfo="@stack",c))(G||{});function F(s){if(!s||s.length===0)return 0;let e=0;for(let t=0;t<s.length;t++){let i=s.charCodeAt(t);e=(e<<5)-e+i,e|=0}return e}function te(s,e){let t={},i=(s||"").split("; ");for(let r of i){let n=r.split("=");y(n[0],e||[])||(t[n[0]]=n[1])}return d(t)?null:t}function b(){function s(){return Math.floor((1+Math.random())*65536).toString(16).substring(1)}return s()+s()+"-"+s()+"-"+s()+"-"+s()+"-"+s()+s()+s()}function ie(s){if(!s)return null;let t=/(v?((\d+)\.(\d+)(\.(\d+))?)(?:-([\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*))?(?:\+([\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*))?)/.exec(s);return t&&t.length>0?t[0]:null}function re(s,e){if(!s||s.length===0)return{};let t=s.split("&");if(t.length===0)return{};let i={};for(let r of t){let n=r.split("=");(!e||!y(n[0],e))&&(i[decodeURIComponent(n[0])]=decodeURIComponent(n[1]))}return d(i)?{}:i}function ne(){return Math.floor(Math.random()*9007199254740992)}function y(s,e,t=!0){if(typeof s!="string")return!1;let i=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;return s=(t?s.toLowerCase():s).replace(i,""),(e||[]).some(r=>{if(typeof r!="string")return!1;if(r&&(r=(t?r.toLowerCase():r).replace(i,"")),!r)return s==null;if(r==="*")return!0;if(s==null)return!1;let n=r[0]==="*";n&&(r=r.slice(1));let o=r[r.length-1]==="*";return o&&(r=r.substring(0,r.length-1)),n&&o?r.length<=s.length&&s.indexOf(r,0)!==-1:n?Z(s,r):o?V(s,r):s===r})}function d(s){if(s==null)return!0;if(typeof s=="object")return Array.isArray(s)?s.length===0:s instanceof Date?!1:Object.getOwnPropertyNames(s).length===0;if(typeof s=="string"){let e=s.trim();return e.length===0||e==="{}"||e==="[]"}return!1}function V(s,e){return s.substring(0,e.length)===e}function Z(s,e){return s.indexOf(e,s.length-e.length)!==-1}function X(s,e=10){function t(n){if(n==null)return!1;switch(typeof n){case"function":return!0;case"object":switch(Object.prototype.toString.call(n)){case"[object AsyncGenerator]":case"[object Generator]":case"[object ArrayBuffer]":case"[object Buffer]":case"[object DataView]":case"[object Promise]":case"[object WeakMap]":case"[object WeakSet]":return!0}if("writeBigInt64LE"in n)return!0;break}return!1}function i(n){function o(a){return a!==null&&typeof a=="object"&&typeof a.toJSON=="function"}if(typeof n=="bigint")return`${n.toString()}n`;if(typeof n=="object"){if(Array.isArray(n)||n instanceof Date)return n;if(n instanceof Map){let l={};for(let[g,u]of n)l[g]=u;return l}if(n instanceof RegExp)return n.toString();if(n instanceof Set)return Array.from(n);let a=Object.getPrototypeOf(Uint8Array);return n instanceof a?Array.from(n):o(n)?i(n.toJSON()):n}return typeof n=="symbol"?n.description:n}function r(n,o,a=10,l=new WeakSet,g=!1){if(n==null)return n;if(a>o||t(n))return;let u=i(n);if(typeof u=="object"){if(a==o)return;if(Array.isArray(u)){let E=g?a+1:a;return u.map(K=>r(K,o,E,l,!0))}if(u instanceof Date)return u;if(Object.prototype.toString.call(u)==="[object Object]"){if(l.has(u))return;l.add(u)}let c=new Set([...Object.getOwnPropertyNames(u),...Object.getOwnPropertySymbols(u)]);for(let E in u)c.add(E);let z={};for(let E of c){let K=i(E),ee=u[E];z[K]=r(ee,o,a+1,l)}return z}return u}if(!(e<0))return r(s,e,0)}function h(s,e,t=10){function i(n,o){return JSON.stringify(n,(a,l)=>{if(!y(a,o))return l})}if(s===void 0)return s;let r=X(s,t);return i(r,e||[])}function W(s,e=!1){if(typeof s=="boolean")return s;if(s===null||typeof s!="number"&&typeof s!="string")return e;switch((s+"").toLowerCase().trim()){case"true":case"yes":case"1":return!0;case"false":case"no":case"0":case null:return!1}return e}function se(s,e="Unknown Error"){if(s==null){let i=new Error(e);return i.stack=void 0,i}if(s instanceof Error)return s;if(typeof s=="string"){let i=new Error(s);return i.stack=void 0,i}let t=new Error(h(s)||e);return t.stack=void 0,t}function f(s){typeof s=="object"&&"unref"in s&&s.unref()}var w=class{constructor(e=6e4){this.priority=100;this.name="HeartbeatPlugin";this._interval=e>=3e4?e:6e4}startup(){return clearInterval(this._intervalId),this._intervalId=void 0,Promise.resolve()}suspend(){return clearInterval(this._intervalId),this._intervalId=void 0,Promise.resolve()}run(e){if(this._interval<=0)return Promise.resolve();clearInterval(this._intervalId),this._intervalId=void 0;let{config:t}=e.client;if(!t.currentSessionIdentifier){let i=e.event.data?.["@user"];if(!i?.identity)return Promise.resolve();t.currentSessionIdentifier=i.identity}return t.currentSessionIdentifier&&(this._intervalId=setInterval(()=>void e.client.submitSessionHeartbeat(t.currentSessionIdentifier),this._interval),f(this._intervalId)),Promise.resolve()}};var C=class{constructor(){this.priority=25;this.name="SessionIdManagementPlugin"}run(e){let t=e.event,i=t.type==="session",{config:r}=e.client;return(i||!r.currentSessionIdentifier)&&(r.currentSessionIdentifier=b().replaceAll("-","")),i?t.reference_id=r.currentSessionIdentifier:(t.data||(t.data={}),t.data["@ref:session"]=r.currentSessionIdentifier),Promise.resolve()}};var U=class{constructor(){this.priority=10;this.name="ConfigurationDefaultsPlugin"}run(e){let{dataExclusions:t,defaultData:i,defaultTags:r}=e.client.config,n=e.event;if(r&&(n.tags=[...n.tags||[],...r]),i){n.data||(n.data={});for(let o in i){if(n.data[o]!==void 0||d(i[o]))continue;let a=h(i[o],t);d(a)||(n.data[o]=JSON.parse(a))}}return Promise.resolve()}};var k=class{constructor(e=()=>Date.now(),t=3e4){this.priority=1010;this.name="DuplicateCheckerPlugin";this._mergedEvents=[];this._processedHashCodes=[];this._getCurrentTime=e,this._interval=t}startup(){return clearInterval(this._intervalId),this._intervalId=setInterval(()=>void this.submitEvents(),this._interval),f(this._intervalId),Promise.resolve()}async suspend(){clearInterval(this._intervalId),this._intervalId=void 0,await this.submitEvents()}run(e){function t(n){let o=0;for(;n;)n.message&&n.message.length&&(o+=o*397^F(n.message)),n.stack_trace&&n.stack_trace.length&&(o+=o*397^F(JSON.stringify(n.stack_trace))),n=n.inner;return o}let i=e.event.data?.["@error"],r=t(i);if(r){let n=e.event.count||1,o=this._getCurrentTime(),a=this._mergedEvents.filter(l=>l.hashCode===r)[0];if(a&&(a.incrementCount(n),a.updateDate(e.event.date),e.log.info("Ignoring duplicate event with hash: "+r),e.cancelled=!0),!e.cancelled&&this._processedHashCodes.some(l=>l.hash===r&&l.timestamp>=o-this._interval)&&(e.log.trace("Adding event with hash: "+r),this._mergedEvents.push(new O(r,e,n)),e.cancelled=!0),!e.cancelled)for(e.log.trace(`Enqueueing event with hash: ${r} to cache`),this._processedHashCodes.push({hash:r,timestamp:o});this._processedHashCodes.length>50;)this._processedHashCodes.shift()}return Promise.resolve()}async submitEvents(){for(;this._mergedEvents.length>0;)await this._mergedEvents.shift()?.resubmit()}},O=class{constructor(e,t,i){this.hashCode=e,this._context=t,this._count=i}incrementCount(e){this._count+=e}async resubmit(){this._context.event.count=this._count,await this._context.client.config.services.queue.enqueue(this._context.event)}updateDate(e){let t=this._context.event;e&&t.date&&e>t.date&&(t.date=e)}};var L=class{constructor(){this.priority=45;this.name="EventExclusionPlugin"}run(e){let t=e.event,i=e.log,r=e.client.config.settings;if(t.type==="log"){let n=this.getMinLogLevel(r,t.source),o=this.getLogLevel(t.data&&t.data["@level"]);o!==-1&&(o===6||o<n)&&(i.info("Cancelling log event due to minimum log level."),e.cancelled=!0)}else if(t.type==="error"){let n=t.data&&t.data["@error"];for(;!e.cancelled&&n;)this.getTypeAndSourceSetting(r,t.type,n.type,!0)===!1&&(i.info(`Cancelling error from excluded exception type: ${n.type}`),e.cancelled=!0),n=n.inner}else this.getTypeAndSourceSetting(r,t.type,t.source,!0)===!1&&(i.info(`Cancelling event from excluded type: ${t.type} and source: ${t.source}`),e.cancelled=!0);return Promise.resolve()}getLogLevel(e){switch((e||"").toLowerCase().trim()){case"trace":case"true":case"1":case"yes":return 0;case"debug":return 1;case"info":return 2;case"warn":return 3;case"error":return 4;case"fatal":return 5;case"off":case"false":case"0":case"no":return 6;default:return-1}}getMinLogLevel(e,t){return this.getLogLevel(this.getTypeAndSourceSetting(e,"log",t,"other")+"")}getTypeAndSourceSetting(e={},t,i,r){if(!t)return r;i||(i="");let n=t==="log",o=`@@${t}:`,a=e[o+i];if(a)return n?a:W(a);let l=Object.keys(e).sort((g,u)=>u.length-g.length||g.localeCompare(u));for(let g of l){if(!V(g.toLowerCase(),o))continue;let u=g.substring(o.length);if(y(i,[u]))return n?e[g]:W(e[g])}return r}};var R=class{constructor(){this.priority=20;this.name="ReferenceIdPlugin"}run(e){return!e.event.reference_id&&e.event.type==="error"&&(e.event.reference_id=b().replaceAll("-","").substring(0,10)),Promise.resolve()}};var Y=["arguments","column","columnNumber","description","fileName","message","name","number","line","lineNumber","opera#sourceloc","sourceId","sourceURL","stack","stackArray","stacktrace"],T=class{constructor(){this.priority=30;this.name="SimpleErrorPlugin"}async run(e){let t=e.eventContext.getException();if(t&&(e.event.type||(e.event.type="error"),e.event.data&&!e.event.data["@simple_error"])){let i={type:t.name||"Error",message:t.message,stack_trace:t.stack,data:{}},r=e.client.config.dataExclusions.concat(Y),n=h(t,r);d(n)||(i.data["@ext"]=JSON.parse(n)),e.event.data["@simple_error"]=i}return Promise.resolve()}};var $=class{constructor(){this.priority=100;this.name="SubmissionMethodPlugin"}run(e){let t=e.eventContext.getSubmissionMethod();return t&&e.event.data&&(e.event.data["@submission_method"]=t),Promise.resolve()}};var m=class{static async startup(e){for(let t of e.client.config.plugins)if(t.startup)try{await t.startup(e)}catch(i){e.log.error(`Error running plugin startup"${t.name}": ${i instanceof Error?i.message:i+""}`)}}static async suspend(e){for(let t of e.client.config.plugins)if(t.suspend)try{await t.suspend(e)}catch(i){e.log.error(`Error running plugin suspend"${t.name}": ${i instanceof Error?i.message:i+""}`)}}static async run(e){for(let t of e.client.config.plugins){if(e.cancelled)break;if(t.run)try{await t.run(e)}catch(i){e.cancelled=!0,e.log.error(`Error running plugin "${t.name}": ${i instanceof Error?i.message:i+""}. Discarding Event.`)}}}static addDefaultPlugins(e){e.addPlugin(new U),e.addPlugin(new T),e.addPlugin(new R),e.addPlugin(new k),e.addPlugin(new L),e.addPlugin(new $)}};var M=class{constructor(e,t=250){this.config=e;this.maxItems=t;this._handlers=[];this._processingQueue=!1;this.QUEUE_PREFIX="q:";this._lastFileTimestamp=0;this._queue=[];this._loadPersistedEvents=!0}async enqueue(e){let t="The event will not be queued.",i=this.config,r=i.services.log;if(!i.enabled){r.info(`Configuration is disabled. ${t}`);return}if(!i.isValid){r.info(`Invalid Api Key. ${t}`);return}if(this.areQueuedItemsDiscarded()){r.info(`Queue items are currently being discarded. ${t}`);return}let n=await this.enqueueEvent(e),o=`type=${e.type} reference_id=${e.reference_id} source=${e.source} message=${e.message}`;r.info(`Enqueued event: ${n} (${o})`)}async process(){let e="The queue will not be processed",{log:t}=this.config.services;if(!this._processingQueue){if(t.trace("Processing queue..."),!this.config.enabled){t.info(`Configuration is disabled: ${e}`);return}if(!this.config.isValid){t.info(`Invalid Api Key: ${e}`);return}this._processingQueue=!0;try{this._loadPersistedEvents&&(this.config.usePersistedQueueStorage&&await this.loadEvents(),this._loadPersistedEvents=!1);let i=this._queue.slice(0,this.config.submissionBatchSize);if(!i||i.length===0){this._processingQueue=!1;return}t.info(`Sending ${i.length} events to ${this.config.serverUrl}`);let r=i.map(o=>o.event),n=await this.config.services.submissionClient.submitEvents(r);await this.processSubmissionResponse(n,i),await this.eventsPosted(r,n),t.trace("Finished processing queue"),this._processingQueue=!1}catch(i){t.error(`Error processing queue: ${i instanceof Error?i.message:i+""}`),await this.suspendProcessing(),this._processingQueue=!1}}}startup(){return this._queueIntervalId||(this._queueIntervalId=setInterval(()=>void this.onProcessQueue(),1e4),f(this._queueIntervalId)),Promise.resolve()}suspend(){return clearInterval(this._queueIntervalId),this._queueIntervalId=void 0,Promise.resolve()}async suspendProcessing(e,t,i){let r=this.config,n=new Date;(!e||e<=0)&&(e=Math.ceil(n.getMinutes()/15)*15-n.getMinutes()),r.services.log.info(`Suspending processing for ${e} minutes.`),this._suspendProcessingUntil=new Date(n.getTime()+e*6e4),t&&(this._discardQueuedItemsUntil=this._suspendProcessingUntil),i&&await this.removeEvents(this._queue)}onEventsPosted(e){e&&this._handlers.push(e)}async eventsPosted(e,t){let i=this._handlers;for(let r of i)try{await r(e,t)}catch(n){this.config.services.log.error(`Error calling onEventsPosted handler: ${n instanceof Error?n.message:n+""}`)}}areQueuedItemsDiscarded(){return this._discardQueuedItemsUntil&&this._discardQueuedItemsUntil>new Date||!1}isQueueProcessingSuspended(){return this._suspendProcessingUntil&&this._suspendProcessingUntil>new Date||!1}async onProcessQueue(){!this.isQueueProcessingSuspended()&&!this._processingQueue&&await this.process()}async processSubmissionResponse(e,t){let i="The event will not be submitted",r=this.config,n=r.services.log;if(e.status===202){n.info(`Sent ${t.length} events`),await this.removeEvents(t);return}if(e.status===429||e.rateLimitRemaining===0||e.status===503){n.error("Server returned service unavailable"),await this.suspendProcessing();return}if(e.status===402){n.info("Too many events have been submitted, please upgrade your plan"),await this.suspendProcessing(0,!0,!0);return}if(e.status===401||e.status===403){n.info(`Unable to authenticate, please check your configuration. ${i}`),await this.suspendProcessing(15),await this.removeEvents(t);return}if(e.status===400||e.status===404){n.error(`Error while trying to submit data: ${e.message}`),await this.suspendProcessing(60*4),await this.removeEvents(t);return}if(e.status===413){let o="Event submission discarded for being too large.";r.submissionBatchSize>1?(n.error(`${o} Retrying with smaller batch size.`),r.submissionBatchSize=Math.max(1,Math.round(r.submissionBatchSize/1.5))):(n.error(`${o} ${i}`),await this.removeEvents(t));return}n.error(`Error submitting events: ${e.message||"Please check the network tab for more info."}`),await this.suspendProcessing()}async loadEvents(){if(this.config.usePersistedQueueStorage){let{log:e,storage:t}=this.config.services;try{let i=await t.keys();for(let r of i)if(r?.startsWith(this.QUEUE_PREFIX)){let n=await t.getItem(r);n&&this._queue.push({file:r,event:JSON.parse(n)})}}catch(i){e.error(`Error loading queue items from storage: ${i instanceof Error?i.message:i+""}`)}}}async enqueueEvent(e){this._lastFileTimestamp=Math.max(Date.now(),this._lastFileTimestamp+1);let t=`${this.QUEUE_PREFIX}${this._lastFileTimestamp}.json`,{log:i,storage:r}=this.config.services,n=this.config.usePersistedQueueStorage;if(this._queue.push({file:t,event:e})>this.maxItems){i.trace("Removing oldest queue entry: maxItems exceeded");let o=this._queue.shift();if(n&&o)try{await r.removeItem(o.file)}catch(a){i.error(`Error removing oldest queue entry from storage: ${a instanceof Error?a.message:a+""}`)}}if(n)try{await r.setItem(t,JSON.stringify(e))}catch(o){i.error(`Error saving queue entry to storage: ${o instanceof Error?o.message:o+""}`)}return t}async removeEvents(e){let t=e.map(i=>i.file);if(this.config.usePersistedQueueStorage){let{log:i,storage:r}=this.config.services;for(let n of t)try{await r.removeItem(n)}catch(o){i.error(`Error removing queue item from storage: ${o instanceof Error?o.message:o+""}`)}}this._queue=this._queue.filter(i=>!t.includes(i.file))}};var H=class{constructor(e,t){this.settings=e;this.version=t}},I=class I{static async applySavedServerSettings(e){if(!e?.isValid)return;let t=await this.getSavedServerSettings(e);t&&e.applyServerSettings(t)}static async updateSettings(e){if(!e?.enabled||this._isUpdatingSettings)return;this._isUpdatingSettings=!0;let{log:t,storage:i,submissionClient:r}=e.services;try{let n="Unable to update settings";if(!e.isValid){t.error(`${n}: ApiKey is not set`);return}let o=e.settingsVersion;t.trace(`Checking for updated settings from: v${o}`);let a=await r.getSettings(o);if(a.status===304){t.trace("Settings are up-to-date");return}if(!a?.success||!a.data){t.warn(`${n}: ${a.message}`);return}e.applyServerSettings(a.data),await i.setItem(I.SettingsKey,JSON.stringify(a.data)),t.trace(`Updated settings: v${a.data.version}`)}catch(n){t.error(`Error updating settings: ${n instanceof Error?n.message:n+""}`)}finally{this._isUpdatingSettings=!1}}static async getSavedServerSettings(e){let{log:t,storage:i}=e.services;try{let r=await i.getItem(I.SettingsKey);return r&&JSON.parse(r)||new H({},0)}catch(r){return t.error(`Error getting saved settings: ${r instanceof Error?r.message:r+""}`),new H({},0)}}};I.SettingsKey="settings",I._isUpdatingSettings=!1;var v=I;var D=class{constructor(e,t,i,r,n){this.status=e;this.message=t;this.rateLimitRemaining=i;this.settingsVersion=r;this.data=n}get success(){return this.status>=200&&this.status<=299}};var A=class{constructor(e,t=globalThis.fetch?.bind(globalThis)){this.config=e;this.fetch=t;this.RateLimitRemainingHeader="x-ratelimit-remaining";this.ConfigurationVersionHeader="x-exceptionless-configversion"}getSettings(e){let t=`${this.config.serverUrl}/api/v2/projects/config?v=${e}`;return this.apiFetch(t,{method:"GET"})}async submitEvents(e){let t=`${this.config.serverUrl}/api/v2/events`,i=await this.apiFetch(t,{method:"POST",body:JSON.stringify(e)});return await this.updateSettingsVersion(i.settingsVersion),i}async submitUserDescription(e,t){let i=`${this.config.serverUrl}/api/v2/events/by-ref/${encodeURIComponent(e)}/user-description`,r=await this.apiFetch(i,{method:"POST",body:JSON.stringify(t)});return await this.updateSettingsVersion(r.settingsVersion),r}async submitHeartbeat(e,t){let i=`${this.config.heartbeatServerUrl}/api/v2/events/session/heartbeat?id=${e}&close=${t+""}`;return await this.apiFetch(i,{method:"GET"})}async updateSettingsVersion(e){isNaN(e)?this.config.services.log.error("No config version header was returned."):e>this.config.settingsVersion&&await v.updateSettings(this.config)}async apiFetch(e,t){let i={method:t.method,headers:{Accept:"application/json",Authorization:`Bearer ${this.config.apiKey}`,"User-Agent":this.config.userAgent},body:t.body??null};t.method==="POST"&&this.isHeaders(i.headers)&&(i.headers["Content-Type"]="application/json");let r=await this.fetch(e,i),n=parseInt(r.headers.get(this.RateLimitRemainingHeader)||"",10),o=parseInt(r.headers.get(this.ConfigurationVersionHeader)||"",10),a=await r.text(),l=a&&a.length>0?JSON.parse(a):null;return new D(r.status,r.statusText,n,o,l)}isHeaders(e){return e!==void 0}};var j=class{constructor(){this.items=new Map}length(){return Promise.resolve(this.items.size)}clear(){return this.items.clear(),Promise.resolve()}getItem(e){let t=this.items.get(e);return Promise.resolve(t||null)}async key(e){if(e<0)return Promise.resolve(null);let t=await this.keys();if(e>t.length)return Promise.resolve(null);let i=t[e];return Promise.resolve(i||null)}keys(){return Promise.resolve(Array.from(this.items.keys()))}removeItem(e){return this.items.delete(e),Promise.resolve()}setItem(e,t){return this.items.set(e,t),Promise.resolve()}};var q=class{constructor(e="exceptionless-",t=globalThis.localStorage){this.prefix=e;this.storage=t}length(){return Promise.resolve(this.getKeys().length)}clear(){for(let e of this.getKeys())this.storage.removeItem(this.getKey(e));return Promise.resolve()}getItem(e){return Promise.resolve(this.storage.getItem(this.getKey(e)))}key(e){let t=this.getKeys();return Promise.resolve(e<t.length?t[e]:null)}keys(){return Promise.resolve(this.getKeys())}removeItem(e){return this.storage.removeItem(this.getKey(e)),Promise.resolve()}setItem(e,t){return this.storage.setItem(this.getKey(e),t),Promise.resolve()}getKeys(){return Object.keys(this.storage).filter(e=>e.startsWith(this.prefix)).map(e=>e?.substr(this.prefix.length))}getKey(e){return this.prefix+e}};var B=class{constructor(){this.defaultTags=[];this.defaultData={};this.enabled=!0;this.submissionBatchSize=50;this.settings={};this.settingsVersion=0;this.apiKey="";this._serverUrl="https://collector.exceptionless.io";this.configServerUrl="https://config.exceptionless.io";this.heartbeatServerUrl="https://heartbeat.exceptionless.io";this._updateSettingsWhenIdleInterval=12e4;this._dataExclusions=[];this._includePrivateInformation=!0;this._includeUserName=!0;this._includeMachineName=!0;this._includeIpAddress=!0;this._includeHeaders=!0;this._includeCookies=!0;this._includePostData=!0;this._includeQueryString=!0;this._userAgentBotPatterns=[];this._plugins=[];this._subscribers=[];this.usePersistedQueueStorage=!1;this.sessionsEnabled=!1;this.currentSessionIdentifier=null;this.services={lastReferenceIdManager:new S,log:new _,storage:new j,queue:new M(this),submissionClient:new A(this)},m.addDefaultPlugins(this)}get isValid(){return this.apiKey?.length>=10}get serverUrl(){return this._serverUrl}set serverUrl(e){e&&(this._serverUrl=e,this.configServerUrl=e,this.heartbeatServerUrl=e)}get updateSettingsWhenIdleInterval(){return this._updateSettingsWhenIdleInterval}set updateSettingsWhenIdleInterval(e){typeof e=="number"&&(e<=0?e=-1:e>0&&e<12e4&&(e=12e4),this._updateSettingsWhenIdleInterval=e)}get dataExclusions(){let e=this.settings["@@DataExclusions"];return this._dataExclusions.concat(e&&e.split(",")||[])}addDataExclusions(...e){this._dataExclusions=[...this._dataExclusions,...e]}get includePrivateInformation(){return this._includePrivateInformation}set includePrivateInformation(e){let t=e===!0;this._includePrivateInformation=t,this._includeUserName=t,this._includeMachineName=t,this._includeIpAddress=t,this._includeHeaders=t,this._includeCookies=t,this._includePostData=t,this._includeQueryString=t}get includeUserName(){return this._includeUserName}set includeUserName(e){this._includeUserName=e===!0}get includeMachineName(){return this._includeMachineName}set includeMachineName(e){this._includeMachineName=e===!0}get includeIpAddress(){return this._includeIpAddress}set includeIpAddress(e){this._includeIpAddress=e===!0}get includeHeaders(){return this._includeHeaders}set includeHeaders(e){this._includeHeaders=e===!0}get includeCookies(){return this._includeCookies}set includeCookies(e){this._includeCookies=e===!0}get includePostData(){return this._includePostData}set includePostData(e){this._includePostData=e===!0}get includeQueryString(){return this._includeQueryString}set includeQueryString(e){this._includeQueryString=e===!0}get userAgentBotPatterns(){let e=this.settings["@@UserAgentBotPatterns"];return this._userAgentBotPatterns.concat(e&&e.split(",")||[])}addUserAgentBotPatterns(...e){this._userAgentBotPatterns=[...this._userAgentBotPatterns,...e]}get plugins(){return this._plugins.sort((e,t)=>e==null&&t==null?0:e?.priority==null?-1:t?.priority==null?1:e.priority==t.priority?0:e.priority>t.priority?1:-1)}addPlugin(e,t,i){let r=i?{name:e,priority:t,run:i}:e;if(!r||!(r.startup||r.run)){this.services.log.error("Add plugin failed: startup or run method not defined");return}r.name||(r.name=b()),r.priority||(r.priority=0),this._plugins.find(n=>n.name===r.name)||this._plugins.push(r)}removePlugin(e){let t=typeof e=="string"?e:e.name||"";if(!t){this.services.log.error("Remove plugin failed: Plugin name not defined");return}let i=this._plugins;for(let r=0;r<i.length;r++)if(i[r].name===t){i.splice(r,1);break}}get version(){return this.defaultData["@version"]}set version(e){e?this.defaultData["@version"]=e:delete this.defaultData["@version"]}setUserIdentity(e,t){let i=typeof e!="string"?e:{identity:e,name:t},r=!i||!i.identity&&!i.name;r?delete this.defaultData["@user"]:this.defaultData["@user"]=i,this.services.log.info(`user identity: ${r?"null":i.identity}`)}get userAgent(){return"exceptionless-js/3.0.5"}useLocalStorage(){globalThis?.localStorage&&(this.services.storage=new q)}useSessions(e=!0,t=6e4,i=!1){this.sessionsEnabled=!0,i&&this.addPlugin(new C);let r=new w(t);e?this.addPlugin(r):this.removePlugin(r)}applyServerSettings(e){this.originalSettings||(this.originalSettings=JSON.parse(JSON.stringify(this.settings))),this.services.log.trace(`Applying saved settings: v${e.version}`),this.settings=Object.assign(this.originalSettings,e.settings),this.settingsVersion=e.version,this.notifySubscribers()}useDebugLogger(){this.services.log=new x}subscribeServerSettingsChange(e){e&&this._subscribers.push(e)}notifySubscribers(){for(let e of this._subscribers)try{e(this)}catch(t){this.services.log.error(`Error calling subscribe handler: ${t instanceof Error?t.message:t+""}`)}}};var p=class{getException(){return this["@@_Exception"]||null}setException(e){e&&(this["@@_Exception"]=e)}get hasException(){return!!this["@@_Exception"]}markAsUnhandledError(){this["@@_IsUnhandledError"]=!0}get isUnhandledError(){return!!this["@@_IsUnhandledError"]}getSubmissionMethod(){return this["@@_SubmissionMethod"]||null}setSubmissionMethod(e){e&&(this["@@_SubmissionMethod"]=e)}};var P=class{constructor(e){this.client=e}get log(){return this.client.config.services.log}};var Q=class{constructor(e,t,i){this.client=e;this.event=t;this.eventContext=i;this.cancelled=!1;this.eventContext||(this.eventContext=new p)}get log(){return this.client.config.services.log}};var N=class{constructor(e,t,i){this._validIdentifierErrorMessage="must contain between 8 and 100 alphanumeric or '-' characters.";this.target=e,this.client=t,this.context=i||new p}setType(e){return e&&(this.target.type=e),this}setSource(e){return e&&(this.target.source=e),this}setReferenceId(e){if(!this.isValidIdentifier(e))throw new Error(`ReferenceId ${this._validIdentifierErrorMessage}`);return this.target.reference_id=e,this}setEventReference(e,t){if(!e)throw new Error("Invalid name");if(!t||!this.isValidIdentifier(t))throw new Error(`Id ${this._validIdentifierErrorMessage}`);return this.setProperty("@ref:"+e,t),this}setMessage(e){return e&&(this.target.message=e),this}setGeo(e,t){if(e<-90||e>90)throw new Error("Must be a valid latitude value between -90.0 and 90.0.");if(t<-180||t>180)throw new Error("Must be a valid longitude value between -180.0 and 180.0.");return this.target.geo=`${e},${t}`,this}setUserIdentity(e,t){let i=typeof e!="string"?e:{identity:e,name:t};return!i||!i.identity&&!i.name?this:(this.setProperty("@user",i),this)}setUserDescription(e,t){return e&&t&&this.setProperty("@user_description",{email_address:e,description:t}),this}setManualStackingInfo(e,t){if(e){let i={signature_data:e};t&&(i.title=t),this.setProperty("@stack",i)}return this}setManualStackingKey(e,t){if(e){let i={ManualStackingKey:e};this.setManualStackingInfo(i,t)}return this}setValue(e){return e&&(this.target.value=e),this}addTags(...e){return this.target.tags=[...this.target.tags||[],...e],this}setProperty(e,t,i,r){if(!e||t===void 0||t==null)return this;this.target.data||(this.target.data={});let n=this.client.config.dataExclusions.concat(r||[]),o=h(t,n,i);return d(o)||(this.target.data[e]=JSON.parse(o)),this}setContextProperty(e,t){return this.context[e]=t,this}markAsCritical(e){return e&&this.addTags("Critical"),this}submit(){return this.client.submitEvent(this.target,this.context)}isValidIdentifier(e){if(!e)return!0;if(e.length<8||e.length>100)return!1;for(let t=0;t<e.length;t++){let i=e.charCodeAt(t),r=i>=48&&i<=57,n=i>=65&&i<=90||i>=97&&i<=122;if(!(r||n)&&!(i===45))return!1}return!0}};var J=class{constructor(e=new B){this.config=e;this._initialized=!1}async startup(e){if(e&&!this._initialized&&(this._initialized=!0,typeof e=="string"?this.config.apiKey=e:e(this.config),this.config.services.queue.onEventsPosted(()=>Promise.resolve(this.updateSettingsTimer())),await v.applySavedServerSettings(this.config)),!this.config.isValid){this.config.services.log.warn("Exceptionless is not configured and will not process events.");return}this.updateSettingsTimer(!!e),await m.startup(new P(this));let{queue:t}=this.config.services;await t.startup(),this.config.usePersistedQueueStorage&&await t.process(),this.config.sessionsEnabled&&await this.submitSessionStart()}async suspend(){await m.suspend(new P(this));let{queue:e}=this.config.services;await e.suspend(),await e.process(),this.suspendSettingsTimer()}suspendSettingsTimer(){clearTimeout(this._timeoutId),this._timeoutId=void 0,clearInterval(this._intervalId),this._intervalId=void 0}async processQueue(){await this.config.services.queue.process()}updateSettingsTimer(e=!1){if(this.suspendSettingsTimer(),!this.config.isValid)return;let t=this.config.updateSettingsWhenIdleInterval;if(t>0){let i=t;e&&(i=this.config.settingsVersion>0?15e3:5e3),this.config.services.log.info(`Update settings every ${t}ms (${i||0}ms delay)`);let r=()=>void v.updateSettings(this.config);i<t&&(this._timeoutId=setTimeout(r,i),f(this._timeoutId)),this._intervalId=setInterval(r,t),f(this._intervalId)}}createException(e){let t=new p;return t.setException(e),this.createEvent(t).setType("error")}submitException(e){return this.createException(e).submit()}createUnhandledException(e,t){let i=this.createException(e);return i.context.markAsUnhandledError(),i.context.setSubmissionMethod(t||""),i}submitUnhandledException(e,t){return this.createUnhandledException(e,t).submit()}createFeatureUsage(e){return this.createEvent().setType("usage").setSource(e)}submitFeatureUsage(e){return this.createFeatureUsage(e).submit()}createLog(e,t,i){let r=this.createEvent().setType("log");if(i)r=r.setSource(e).setMessage(t).setProperty("@level",i);else if(t)r=r.setSource(e).setMessage(t);else{r=r.setMessage(e);try{let n=this.createLog.caller;r=r.setSource(n&&n.caller&&n.caller.name)}catch(n){this.config.services.log.trace(`Unable to resolve log source: ${n instanceof Error?n.message:n+""}`)}}return r}submitLog(e,t,i){return this.createLog(e,t,i).submit()}createNotFound(e){return this.createEvent().setType("404").setSource(e)}submitNotFound(e){return this.createNotFound(e).submit()}createSessionStart(){return this.createEvent().setType("session")}submitSessionStart(){return this.createSessionStart().submit()}async submitSessionEnd(e){let{currentSessionIdentifier:t,enabled:i,isValid:r,services:n}=this.config,o=e||t;o&&i&&r&&(n.log.info(`Submitting session end: ${o}`),await n.submissionClient.submitHeartbeat(o,!0))}async submitSessionHeartbeat(e){let{currentSessionIdentifier:t,enabled:i,isValid:r,services:n}=this.config,o=e||t;o&&i&&r&&(n.log.info(`Submitting session heartbeat: ${o}`),await n.submissionClient.submitHeartbeat(o,!1))}createEvent(e){return new N({date:new Date},this,e)}async submitEvent(e,t){let i=new Q(this,e,t??new p);if(!e)return i.cancelled=!0,i;if(!this.config.enabled||!this.config.isValid)return this.config.services.log.info("Event submission is currently disabled."),i.cancelled=!0,i;if(e.data||(e.data={}),(!e.tags||!e.tags.length)&&(e.tags=[]),await m.run(i),i.cancelled)return i;let r=i.event;return(!r.type||r.type.length===0)&&(r.type="log"),r.date||(r.date=new Date),await this.config.services.queue.enqueue(r),r.reference_id&&r.reference_id.length>0&&(i.log.info(`Setting last reference id "${r.reference_id}"`),this.config.services.lastReferenceIdManager.setLast(r.reference_id)),i}async updateUserEmailAndDescription(e,t,i){if(!e||!t||!i||!this.config.enabled||!this.config.isValid)return;let r={email_address:t,description:i},n=await this.config.services.submissionClient.submitUserDescription(e,r);n.success||this.config.services.log.error(`Failed to submit user email and description for event "${e}": ${n.status} ${n.message}`)}getLastReferenceId(){return this.config.services.lastReferenceIdManager.getLast()}};export{B as Configuration,U as ConfigurationDefaultsPlugin,x as ConsoleLog,M as DefaultEventQueue,S as DefaultLastReferenceIdManager,A as DefaultSubmissionClient,k as DuplicateCheckerPlugin,N as EventBuilder,p as EventContext,L as EventExclusionPlugin,Q as EventPluginContext,m as EventPluginManager,J as ExceptionlessClient,w as HeartbeatPlugin,Y as IgnoredErrorProperties,j as InMemoryStorage,G as KnownEventDataKeys,q as LocalStorage,_ as NullLog,P as PluginContext,R as ReferenceIdPlugin,D as Response,C as SessionIdManagementPlugin,v as SettingsManager,T as SimpleErrorPlugin,$ as SubmissionMethodPlugin,Z as endsWith,te as getCookies,F as getHashCode,b as guid,d as isEmpty,y as isMatch,re as parseQueryString,ie as parseVersion,X as prune,ne as randomNumber,V as startsWith,h as stringify,W as toBoolean,se as toError}; | ||
//# sourceMappingURL=index.bundle.min.js.map |
{ | ||
"name": "@exceptionless/core", | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"description": "JavaScript client for Exceptionless", | ||
@@ -58,6 +58,6 @@ "author": { | ||
"devDependencies": { | ||
"@jest/globals": "^29.5.0", | ||
"esbuild": "^0.19.2", | ||
"jest": "^29.6.4", | ||
"jest-environment-jsdom": "^29.6.4", | ||
"@jest/globals": "^29.7.0", | ||
"esbuild": "^0.19.5", | ||
"jest": "^29.7.0", | ||
"jest-environment-jsdom": "^29.7.0", | ||
"jest-ts-webcompat-resolver": "^1.0.0", | ||
@@ -64,0 +64,0 @@ "ts-jest": "^29.1.1" |
@@ -474,3 +474,3 @@ import { DefaultLastReferenceIdManager } from "../lastReferenceIdManager/DefaultLastReferenceIdManager.js"; | ||
public get userAgent(): string { | ||
return "exceptionless-js/3.0.4"; | ||
return "exceptionless-js/3.0.5"; | ||
} | ||
@@ -477,0 +477,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet