forked from exceptionless/Exceptionless.JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexceptionless.universal.min.js
More file actions
2 lines (2 loc) · 54.9 KB
/
exceptionless.universal.min.js
File metadata and controls
2 lines (2 loc) · 54.9 KB
1
2
!function(I,e){if(I){var y={},t=I.TraceKit,r=[].slice,b="?",d=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/;y.noConflict=function(){return I.TraceKit=t,y},y.wrap=function(e){return function(){try{return e.apply(this,arguments)}catch(e){throw y.report(e),e}}},y.report=function(){var c,n,o=[],r=null,l=null;function f(e,t,n){var r=null;if(!t||y.collectWindowErrors){for(var i in o)if(P(o,i))try{o[i](e,t,n)}catch(e){r=e}if(r)throw r}}function t(e,t,n,r,i){if(l)y.computeStackTrace.augmentStackTraceWithInitialElement(l,t,n,e),p();else if(i)f(y.computeStackTrace(i),!0,i);else{var o,s={url:t,line:n,column:r},a=e;if("[object String]"==={}.toString.call(e)){var u=e.match(d);u&&(o=u[1],a=u[2])}s.func=y.computeStackTrace.guessFunctionName(s.url,s.line),s.context=y.computeStackTrace.gatherContext(s.url,s.line),f({name:o,message:a,mode:"onerror",stack:[s]},!0,null)}return!!c&&c.apply(this,arguments)}function p(){var e=l,t=r;r=l=null,f(e,!1,t)}function e(e){if(l){if(r===e)return;p()}var t=y.computeStackTrace(e);throw l=t,r=e,setTimeout(function(){r===e&&p()},t.incomplete?2e3:0),e}return e.subscribe=function(e){!0!==n&&(c=I.onerror,I.onerror=t,n=!0),o.push(e)},e.unsubscribe=function(e){for(var t=o.length-1;0<=t;--t)o[t]===e&&o.splice(t,1);0===o.length&&(I.onerror=c,n=!1)},e}(),y.computeStackTrace=function(){var r=!1,i={};function S(e){if("string"!=typeof e)return[];if(!P(i,e)){var t="",n="";try{n=I.document.domain}catch(e){}var r=/(.*)\:\/\/([^:\/]+)([:\d]*)\/{0,1}([\s\S]*)/.exec(e);r&&r[2]===n&&(t=function(e){if(!y.remoteFetching)return"";try{var t=function(){try{return new I.XMLHttpRequest}catch(e){return new I.ActiveXObject("Microsoft.XMLHTTP")}}();return t.open("GET",e,!1),t.send(""),t.responseText}catch(e){return""}}(e)),i[e]=t?t.split("\n"):[]}return i[e]}function _(e,t){var n,r=/function ([^(]*)\(([^)]*)\)/,i=/['"]?([0-9A-Za-z$_]+)['"]?\s*[:=]\s*(function|eval|new Function)/,o="",s=S(e);if(!s.length)return b;for(var a=0;a<10;++a)if(!C(o=s[t-a]+o)){if(n=i.exec(o))return n[1];if(n=r.exec(o))return n[1]}return b}function x(e,t){var n=S(e);if(!n.length)return null;var r=[],i=Math.floor(y.linesOfContext/2),o=i+y.linesOfContext%2,s=Math.max(0,t-i-1),a=Math.min(n.length,t+o-1);t-=1;for(var u=s;u<a;++u)C(n[u])||r.push(n[u]);return 0<r.length?r:null}function d(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#]/g,"\\$&")}function w(e){return d(e).replace("<","(?:<|<)").replace(">","(?:>|>)").replace("&","(?:&|&)").replace('"','(?:"|")').replace(/\s+/g,"\\s+")}function E(e,t){for(var n,r,i=0,o=t.length;i<o;++i)if((n=S(t[i])).length&&(n=n.join("\n"),r=e.exec(n)))return{url:t[i],line:n.substring(0,r.index).split("\n").length,column:r.index-n.lastIndexOf("\n",r.index)-1};return null}function g(e,t,n){var r,i=S(t),o=new RegExp("\\b"+d(e)+"\\b");return n-=1,i&&i.length>n&&(r=o.exec(i[n]))?r.index:null}function p(e){if(!C(I&&I.document)){for(var t,n,r,i,o=[I.location.href],s=I.document.getElementsByTagName("script"),a=""+e,u=0;u<s.length;++u){var c=s[u];c.src&&o.push(c.src)}if(r=/^function(?:\s+([\w$]+))?\s*\(([\w\s,]*)\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/.exec(a)){var l=r[1]?"\\s+"+r[1]:"",f=r[2].split(",").join("\\s*,\\s*");t=d(r[3]).replace(/;$/,";?"),n=new RegExp("function"+l+"\\s*\\(\\s*"+f+"\\s*\\)\\s*{\\s*"+t+"\\s*}")}else n=new RegExp(d(a).replace(/\s+/g,"\\s+"));if(i=E(n,o))return i;if(r=/^function on([\w$]+)\s*\(event\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/.exec(a)){var p=r[1];if(t=w(r[2]),i=E(n=new RegExp("on"+p+"=[\\'\"]\\s*"+t+"\\s*[\\'\"]","i"),o[0]))return i;if(i=E(n=new RegExp(t),o))return i}return null}}function o(e){if(!e.stack)return null;for(var t,n,r,i=/^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,o=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,s=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,a=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,u=/\((\S*)(?::(\d+))(?::(\d+))\)/,c=e.stack.split("\n"),l=[],f=/^(.*) is undefined$/.exec(e.message),p=0,d=c.length;p<d;++p){if(n=i.exec(c[p])){var h=n[2]&&0===n[2].indexOf("native");n[2]&&0===n[2].indexOf("eval")&&(t=u.exec(n[2]))&&(n[2]=t[1],n[3]=t[2],n[4]=t[3]),r={url:h?null:n[2],func:n[1]||b,args:h?[n[2]]:[],line:n[3]?+n[3]:null,column:n[4]?+n[4]:null}}else if(n=s.exec(c[p]))r={url:n[2],func:n[1]||b,args:[],line:+n[3],column:n[4]?+n[4]:null};else{if(!(n=o.exec(c[p])))continue;n[3]&&-1<n[3].indexOf(" > eval")&&(t=a.exec(n[3]))?(n[3]=t[1],n[4]=t[2],n[5]=null):0!==p||n[5]||C(e.columnNumber)||(l[0].column=e.columnNumber+1),r={url:n[3],func:n[1]||b,args:n[2]?n[2].split(","):[],line:n[4]?+n[4]:null,column:n[5]?+n[5]:null}}!r.func&&r.line&&(r.func=_(r.url,r.line)),r.context=r.line?x(r.url,r.line):null,l.push(r)}return l.length?(l[0]&&l[0].line&&!l[0].column&&f&&(l[0].column=g(f[1],l[0].url,l[0].line)),{mode:"stack",name:e.name,message:e.message,stack:l}):null}function h(e,t,n,r){var i={url:t,line:n};if(i.url&&i.line){e.incomplete=!1,i.func||(i.func=_(i.url,i.line)),i.context||(i.context=x(i.url,i.line));var o=/ '([^']+)' /.exec(r);if(o&&(i.column=g(o[1],i.url,i.line)),0<e.stack.length&&e.stack[0].url===i.url){if(e.stack[0].line===i.line)return!1;if(!e.stack[0].line&&e.stack[0].func===i.func)return e.stack[0].line=i.line,e.stack[0].context=i.context,!1}return e.stack.unshift(i),e.partial=!0}return!(e.incomplete=!0)}function v(e,t){for(var n,r,i,o=/function\s+([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)?\s*\(/i,s=[],a={},u=!1,c=v.caller;c&&!u;c=c.caller)if(c!==m&&c!==y.report){if(r={url:null,func:b,args:[],line:null,column:null},c.name?r.func=c.name:(n=o.exec(c.toString()))&&(r.func=n[1]),void 0===r.func)try{r.func=n.input.substring(0,n.input.indexOf("{"))}catch(e){}if(i=p(c)){r.url=i.url,r.line=i.line,r.func===b&&(r.func=_(r.url,r.line));var l=/ '([^']+)' /.exec(e.message||e.description);l&&(r.column=g(l[1],i.url,i.line))}a[""+c]?u=!0:a[""+c]=!0,s.push(r)}t&&s.splice(0,t);var f={mode:"callers",name:e.name,message:e.message,stack:s};return h(f,e.sourceURL||e.fileName,e.line||e.lineNumber,e.message||e.description),f}function m(e,t){var n=null;t=null==t?0:+t;try{if(n=function(e){var t=e.stacktrace;if(t){for(var n,r=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i,i=/ line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^\)]+))\((.*)\))? in (.*):\s*$/i,o=t.split("\n"),s=[],a=0;a<o.length;a+=2){var u=null;if((n=r.exec(o[a]))?u={url:n[2],line:+n[1],column:null,func:n[3],args:[]}:(n=i.exec(o[a]))&&(u={url:n[6],line:+n[1],column:+n[2],func:n[3]||n[4],args:n[5]?n[5].split(","):[]}),u){if(!u.func&&u.line&&(u.func=_(u.url,u.line)),u.line)try{u.context=x(u.url,u.line)}catch(e){}u.context||(u.context=[o[a+1]]),s.push(u)}}return s.length?{mode:"stacktrace",name:e.name,message:e.message,stack:s}:null}}(e))return n}catch(e){if(r)throw e}try{if(n=o(e))return n}catch(e){if(r)throw e}try{if(n=function(e){var t=e.message.split("\n");if(t.length<4)return null;var n,r=/^\s*Line (\d+) of linked script ((?:file|https?|blob)\S+)(?:: in function (\S+))?\s*$/i,i=/^\s*Line (\d+) of inline#(\d+) script in ((?:file|https?|blob)\S+)(?:: in function (\S+))?\s*$/i,o=/^\s*Line (\d+) of function script\s*$/i,s=[],a=I&&I.document&&I.document.getElementsByTagName("script"),u=[];for(var c in a)P(a,c)&&!a[c].src&&u.push(a[c]);for(var l=2;l<t.length;l+=2){var f=null;if(n=r.exec(t[l]))f={url:n[2],func:n[3],args:[],line:+n[1],column:null};else if(n=i.exec(t[l])){f={url:n[3],func:n[4],args:[],line:+n[1],column:null};var p=+n[1],d=u[n[2]-1];if(d){var h=S(f.url);if(h){var g=(h=h.join("\n")).indexOf(d.innerText);0<=g&&(f.line=p+h.substring(0,g).split("\n").length)}}}else if(n=o.exec(t[l])){var v=I.location.href.replace(/#.*$/,""),m=E(new RegExp(w(t[l+1])),[v]);f={url:v,func:"",args:[],line:m?m.line:n[1],column:null}}if(f){f.func||(f.func=_(f.url,f.line));var y=x(f.url,f.line),b=y?y[Math.floor(y.length/2)]:null;y&&b.replace(/^\s*/,"")===t[l+1].replace(/^\s*/,"")?f.context=y:f.context=[t[l+1]],s.push(f)}}return s.length?{mode:"multiline",name:e.name,message:t[0],stack:s}:null}(e))return n}catch(e){if(r)throw e}try{if(n=v(e,t+1))return n}catch(e){if(r)throw e}return{name:e.name,message:e.message,mode:"failed"}}return m.augmentStackTraceWithInitialElement=h,m.computeStackTraceFromStackProp=o,m.guessFunctionName=_,m.gatherContext=x,m.ofCaller=function(t){t=1+(null==t?0:+t);try{throw new Error}catch(e){return m(e,t+1)}},m.getSource=S,m}(),y.extendToAsynchronousCallbacks=function(){var e=function(e){var n=I[e];I[e]=function(){var e=r.call(arguments),t=e[0];return"function"==typeof t&&(e[0]=y.wrap(t)),n.apply?n.apply(this,e):n(e[0],e[1])}};e("setTimeout"),e("setInterval")},y.remoteFetching||(y.remoteFetching=!0),y.collectWindowErrors||(y.collectWindowErrors=!0),(!y.linesOfContext||y.linesOfContext<1)&&(y.linesOfContext=11),"function"==typeof define&&define.amd?define("TraceKit",[],y):"undefined"!=typeof module&&module.exports&&I.module!==module?module.exports=y:I.TraceKit=y}function P(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function C(e){return void 0===e}}("undefined"!=typeof window?window:global),function(e,t){var n,r;"function"==typeof define&&define.amd?define("exceptionless",["require","exports","TraceKit"],t):e.exceptionless=t(r,n,e.TraceKit)}(this,function(u,e,o){if(!e)e={};var r,t=this&&this.__extends||(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});if(Object.defineProperty(e,"__esModule",{value:!0}),u&&"undefined"!=typeof process)var s=u("os"),i=u("stack-trace"),a=u("child_process"),c=u("path"),l=u("fs"),f=u("path"),p=u("http"),d=u("https"),h=u("url");var g=function(){function e(){this._lastReferenceId=null}return e.prototype.getLast=function(){return this._lastReferenceId},e.prototype.clearLast=function(){this._lastReferenceId=null},e.prototype.setLast=function(e){this._lastReferenceId=e},e}();e.DefaultLastReferenceIdManager=g;var v=function(){function e(){}return e.prototype.trace=function(e){this.log("debug",e)},e.prototype.info=function(e){this.log("info",e)},e.prototype.warn=function(e){this.log("warn",e)},e.prototype.error=function(e){this.log("error",e)},e.prototype.log=function(e,t){if(console){var n="["+e+"] Exceptionless: "+t;console[e]?console[e](n):console.log&&console.log(n)}},e}();e.ConsoleLog=v;var m=function(){function e(){}return e.prototype.trace=function(e){},e.prototype.info=function(e){},e.prototype.warn=function(e){},e.prototype.error=function(e){},e}();e.NullLog=m;var y=function(){function e(e){void 0===e&&(e=3e4),this.priority=100,this.name="HeartbeatPlugin",this._interval=3e4<=e?e:6e4}return e.prototype.run=function(e,t){clearInterval(this._intervalId);var n=e.event.data["@user"];n&&n.identity&&(this._intervalId=setInterval(function(){return e.client.submitSessionHeartbeat(n.identity)},this._interval)),t&&t()},e}();e.HeartbeatPlugin=y;var b=function(){function e(){this.priority=20,this.name="ReferenceIdPlugin"}return e.prototype.run=function(e,t){e.event.reference_id&&0!==e.event.reference_id.length||"error"!==e.event.type||(e.event.reference_id=I.guid().replace("-","").substring(0,10)),t&&t()},e}();e.ReferenceIdPlugin=b;var S=function(){function e(e,t,n){this.client=e,this.event=t,this.contextData=n||new k}return Object.defineProperty(e.prototype,"log",{get:function(){return this.client.config.log},enumerable:!0,configurable:!0}),e}();e.EventPluginContext=S;var _=function(){function e(){}return e.run=function(n,r){var e=function(t,e){return function(){try{n.cancelled||t.run(n,e)}catch(e){n.cancelled=!0,n.log.error("Error running plugin '"+t.name+"': "+e.message+". Discarding Event.")}n.cancelled&&r&&r(n)}},t=n.client.config.plugins,i=[];r&&(i[t.length]=e({name:"cb",priority:9007199254740992,run:r},null));for(var o=t.length-1;-1<o;o--)i[o]=e(t[o],r||o<t.length-1?i[o+1]:null);i[0]()},e.addDefaultPlugins=function(e){e.addPlugin(new R),e.addPlugin(new D),e.addPlugin(new q),e.addPlugin(new N),e.addPlugin(new j),e.addPlugin(new F),e.addPlugin(new A),e.addPlugin(new L)},e}();e.EventPluginManager=_;var x=function(){function e(e){this._handlers=[],this._processingQueue=!1,this._config=e}return e.prototype.enqueue=function(e){var t="The event will not be queued.",n=this._config,r=n.log;if(n.enabled)if(n.isValid)if(this.areQueuedItemsDiscarded())r.info("Queue items are currently being discarded. "+t);else{this.ensureQueueTimer();var i=n.storage.queue.save(e),o="type="+e.type+" "+(e.reference_id?"refid="+e.reference_id:"");i?r.info("Enqueuing event: "+i+" "+o):r.error("Could not enqueue event "+o)}else r.info("Invalid Api Key. "+t);else r.info("Configuration is disabled. "+t)},e.prototype.process=function(e){var t=this,n="The queue will not be processed.",r=this._config,i=r.log;if(!this._processingQueue)if(i.info("Processing queue..."),r.enabled)if(r.isValid){this._processingQueue=!0,this.ensureQueueTimer();try{var o=r.storage.queue.get(r.submissionBatchSize);if(!o||0===o.length)return void(this._processingQueue=!1);i.info("Sending "+o.length+" events to "+r.serverUrl+"."),r.submissionClient.postEvents(o.map(function(e){return e.value}),r,function(e){t.processSubmissionResponse(e,o),t.eventsPosted(o.map(function(e){return e.value}),e),i.info("Finished processing queue."),t._processingQueue=!1},e)}catch(e){i.error("Error processing queue: "+e),this.suspendProcessing(),this._processingQueue=!1}}else i.info("Invalid Api Key. "+n);else i.info("Configuration is disabled. "+n)},e.prototype.suspendProcessing=function(e,t,n){var r=this._config;(!e||e<=0)&&(e=5),r.log.info("Suspending processing for "+e+" minutes."),this._suspendProcessingUntil=new Date((new Date).getTime()+6e4*e),t&&(this._discardQueuedItemsUntil=this._suspendProcessingUntil),n&&r.storage.queue.clear()},e.prototype.onEventsPosted=function(e){e&&this._handlers.push(e)},e.prototype.eventsPosted=function(e,t){for(var n=0,r=this._handlers;n<r.length;n++){var i=r[n];try{i(e,t)}catch(e){this._config.log.error("Error calling onEventsPosted handler: "+e)}}},e.prototype.areQueuedItemsDiscarded=function(){return this._discardQueuedItemsUntil&&this._discardQueuedItemsUntil>new Date},e.prototype.ensureQueueTimer=function(){var e=this;this._queueTimer||(this._queueTimer=setInterval(function(){return e.onProcessQueue()},1e4))},e.prototype.isQueueProcessingSuspended=function(){return this._suspendProcessingUntil&&this._suspendProcessingUntil>new Date},e.prototype.onProcessQueue=function(){this.isQueueProcessingSuspended()||this._processingQueue||this.process()},e.prototype.processSubmissionResponse=function(e,t){var n="The event will not be submitted.",r=this._config,i=r.log;if(e.success)return i.info("Sent "+t.length+" events."),void this.removeEvents(t);if(e.serviceUnavailable)return i.error("Server returned service unavailable."),void this.suspendProcessing();if(e.paymentRequired)return i.info("Too many events have been submitted, please upgrade your plan."),void this.suspendProcessing(null,!0,!0);if(e.unableToAuthenticate)return i.info("Unable to authenticate, please check your configuration. "+n),this.suspendProcessing(15),void this.removeEvents(t);if(e.notFound||e.badRequest)return i.error("Error while trying to submit data: "+e.message),this.suspendProcessing(240),void this.removeEvents(t);if(e.requestEntityTooLarge){var o="Event submission discarded for being too large.";1<r.submissionBatchSize?(i.error(o+" Retrying with smaller batch size."),r.submissionBatchSize=Math.max(1,Math.round(r.submissionBatchSize/1.5))):(i.error(o+" "+n),this.removeEvents(t))}else e.success||(i.error("Error submitting events: "+(e.message||"Please check the network tab for more info.")),this.suspendProcessing())},e.prototype.removeEvents=function(e){for(var t=0;t<(e||[]).length;t++)this._config.storage.queue.remove(e[t].timestamp)},e}();e.DefaultEventQueue=x;var w=function(e){void 0===e&&(e=250),this.queue=new K(e),this.settings=new K(1)};e.InMemoryStorageProvider=w;var E=function(){function e(){this.configurationVersionHeader="x-exceptionless-configversion"}return e.prototype.postEvents=function(e,t,n,r){var i=JSON.stringify(e),o=this.createRequest(t,"POST",t.serverUrl+"/api/v2/events",i),s=this.createSubmissionCallback(t,n);return t.submissionAdapter.sendRequest(o,s,r)},e.prototype.postUserDescription=function(e,t,n,r){var i=n.serverUrl+"/api/v2/events/by-ref/"+encodeURIComponent(e)+"/user-description",o=JSON.stringify(t),s=this.createRequest(n,"POST",i,o),a=this.createSubmissionCallback(n,r);return n.submissionAdapter.sendRequest(s,a)},e.prototype.getSettings=function(o,e,s){var t=this.createRequest(o,"GET",o.configServerUrl+"/api/v2/projects/config?v="+e);return o.submissionAdapter.sendRequest(t,function(e,t,n,r){if(200!==e)return s(new O(!1,null,-1,null,t));var i;try{i=JSON.parse(n)}catch(e){o.log.error("Unable to parse settings: '"+n+"'")}if(!i||isNaN(i.version))return s(new O(!1,null,-1,null,"Invalid configuration settings."));s(new O(!0,i.settings||{},i.version))})},e.prototype.sendHeartbeat=function(e,t,n){var r=this.createRequest(n,"GET",n.heartbeatServerUrl+"/api/v2/events/session/heartbeat?id="+e+"&close="+t);n.submissionAdapter.sendRequest(r)},e.prototype.createRequest=function(e,t,n,r){return void 0===r&&(r=null),{method:t,url:n,data:r,apiKey:e.apiKey,userAgent:e.userAgent}},e.prototype.createSubmissionCallback=function(o,s){var a=this;return function(e,t,n,r){var i=r&&parseInt(r[a.configurationVersionHeader],10);isNaN(i)?o.log.error("No config version header was returned."):P.checkVersion(i,o),s(new C(e,t))}},e}();e.DefaultSubmissionClient=E;var I=function(){function u(){}return u.addRange=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(e||(e=[]),!t||0===t.length)return e;for(var r=0,i=t;r<i.length;r++){var o=i[r];o&&e.indexOf(o)<0&&e.push(o)}return e},u.getHashCode=function(e){if(!e||0===e.length)return 0;for(var t=0,n=0;n<e.length;n++){t=(t<<5)-t+e.charCodeAt(n),t|=0}return t},u.getCookies=function(e,t){for(var n={},r=0,i=(e||"").split("; ");r<i.length;r++){var o=i[r].split("=");u.isMatch(o[0],t)||(n[o[0]]=o[1])}return u.isEmpty(n)?null:n},u.guid=function(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()},u.merge=function(e,t){var n={};for(var r in e||{})void 0!==e[r]&&null!==e[r]&&(n[r]=e[r]);for(var r in t||{})void 0!==t[r]&&null!==t[r]&&(n[r]=t[r]);return n},u.parseVersion=function(e){if(!e)return null;var t=/(v?((\d+)\.(\d+)(\.(\d+))?)(?:-([\dA-Za-z\-]+(?:\.[\dA-Za-z\-]+)*))?(?:\+([\dA-Za-z\-]+(?:\.[\dA-Za-z\-]+)*))?)/.exec(e);return t&&0<t.length?t[0]:null},u.parseQueryString=function(e,t){if(!e||0===e.length)return null;var n=e.split("&");if(0===n.length)return null;for(var r={},i=0,o=n;i<o.length;i++){var s=o[i].split("=");u.isMatch(s[0],t)||(r[decodeURIComponent(s[0])]=decodeURIComponent(s[1]))}return u.isEmpty(r)?null:r},u.randomNumber=function(){return Math.floor(9007199254740992*Math.random())},u.isMatch=function(r,e,i){if(void 0===i&&(i=!0),!r||"string"!=typeof r)return!1;var o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;return r=(i?r.toLowerCase():r).replace(o,""),(e||[]).some(function(e){if("string"!=typeof e)return!1;if((e=(i?e.toLowerCase():e).replace(o,"")).length<=0)return!1;var t="*"===e[0];t&&(e=e.slice(1));var n="*"===e[e.length-1];return n&&(e=e.substring(0,e.length-1)),t&&n?e.length<=r.length&&-1!==r.indexOf(e,0):t?u.endsWith(r,e):n?u.startsWith(r,e):r===e})},u.isEmpty=function(e){return null===e||"object"==typeof e&&0===Object.keys(e).length},u.startsWith=function(e,t){return e.substring(0,t.length)===t},u.endsWith=function(e,t){return-1!==e.indexOf(t,e.length-t.length)},u.stringify=function(e,t,n){function r(e,n){var r=[];return JSON.stringify(e,function(e,t){if(!u.isMatch(e,n)){if("object"==typeof t&&t){if(-1!==r.indexOf(t))return;r.push(t)}return t}})}if("[object Object]"==={}.toString.call(e)){var i={};for(var o in e){e[o]!==e&&(i[o]=e[o])}return r(i,t)}if("[object Array]"!=={}.toString.call(e))return r(e,t);for(var s=[],a=0;a<e.length;a++)s[a]=JSON.parse(r(e[a],t));return JSON.stringify(s)},u.toBoolean=function(e,t){if(void 0===t&&(t=!1),"boolean"==typeof e)return e;if(null===e||"number"!=typeof e&&"string"!=typeof e)return t;switch((e+"").toLowerCase().trim()){case"true":case"yes":case"1":return!0;case"false":case"no":case"0":case null:return!1}return t},u}();e.Utils=I;var P=function(){function a(){}return a.onChanged=function(e){e&&this._handlers.push(e)},a.applySavedServerSettings=function(e){if(e&&e.isValid){var t=this.getSavedServerSettings(e);e.log.info("Applying saved settings: v"+t.version),e.settings=I.merge(e.settings,t.settings),this.changed(e)}},a.getVersion=function(e){return e&&e.isValid&&this.getSavedServerSettings(e).version||0},a.checkVersion=function(e,t){var n=this.getVersion(t);e<=n||(t.log.info("Updating settings from v"+n+" to v"+e),this.updateSettings(t,n))},a.updateSettings=function(i,e){var o=this;if(i&&i.enabled&&!this._isUpdatingSettings){var s="Unable to update settings";i.isValid?((!e||e<0)&&(e=this.getVersion(i)),i.log.info("Checking for updated settings from: v"+e+"."),this._isUpdatingSettings=!0,i.submissionClient.getSettings(i,e,function(e){try{if(!(i&&e&&e.success&&e.settings))return void i.log.warn(s+": "+e.message);i.settings=I.merge(i.settings,e.settings);var t=a.getSavedServerSettings(i);for(var n in t)e.settings[n]||delete i.settings[n];var r={version:e.settingsVersion,settings:e.settings};i.storage.settings.save(r),i.log.info("Updated settings: v"+r.version),o.changed(i)}finally{o._isUpdatingSettings=!1}})):i.log.error(s+": ApiKey is not set.")}},a.changed=function(t){for(var e=0,n=this._handlers;e<n.length;e++){var r=n[e];try{r(t)}catch(e){t.log.error("Error calling onChanged handler: "+e)}}},a.getSavedServerSettings=function(e){var t=e.storage.settings.get()[0];return t&&t.value&&t.value.version&&t.value.settings?t.value:{version:0,settings:{}}},a}();P._isUpdatingSettings=!1,P._handlers=[],e.SettingsManager=P;var C=function(e,t){this.success=!1,this.badRequest=!1,this.serviceUnavailable=!1,this.paymentRequired=!1,this.unableToAuthenticate=!1,this.notFound=!1,this.requestEntityTooLarge=!1,this.statusCode=e,this.message=t,this.success=200<=e&&e<=299,this.badRequest=400===e,this.serviceUnavailable=503===e,this.paymentRequired=402===e,this.unableToAuthenticate=401===e||403===e,this.notFound=404===e,this.requestEntityTooLarge=413===e};e.SubmissionResponse=C;var T=function(){function e(e,t){var n=this;this.config=new U("object"==typeof e?e:{apiKey:e,serverUrl:t}),this.updateSettingsTimer(5e3),this.config.onChanged(function(e){return n.updateSettingsTimer(0<n._timeoutId?5e3:0)}),this.config.queue.onEventsPosted(function(e,t){return n.updateSettingsTimer()})}return e.prototype.createException=function(e){var t=new k;return t.setException(e),this.createEvent(t).setType("error")},e.prototype.submitException=function(e,t){this.createException(e).submit(t)},e.prototype.createUnhandledException=function(e,t){var n=this.createException(e);return n.pluginContextData.markAsUnhandledError(),n.pluginContextData.setSubmissionMethod(t),n},e.prototype.submitUnhandledException=function(e,t,n){this.createUnhandledException(e,t).submit(n)},e.prototype.createFeatureUsage=function(e){return this.createEvent().setType("usage").setSource(e)},e.prototype.submitFeatureUsage=function(e,t){this.createFeatureUsage(e).submit(t)},e.prototype.createLog=function(e,t,n){var r=this.createEvent().setType("log");if(n)r=r.setSource(e).setMessage(t).setProperty("@level",n);else if(t)r=r.setSource(e).setMessage(t);else{r=r.setMessage(e);try{var i=this.createLog.caller;r=r.setSource(i&&i.caller&&i.caller.name)}catch(e){this.config.log.trace("Unable to resolve log source: "+e.message)}}return r},e.prototype.submitLog=function(e,t,n,r){this.createLog(e,t,n).submit(r)},e.prototype.createNotFound=function(e){return this.createEvent().setType("404").setSource(e)},e.prototype.submitNotFound=function(e,t){this.createNotFound(e).submit(t)},e.prototype.createSessionStart=function(){return this.createEvent().setType("session")},e.prototype.submitSessionStart=function(e){this.createSessionStart().submit(e)},e.prototype.submitSessionEnd=function(e){e&&(this.config.log.info("Submitting session end: "+e),this.config.submissionClient.sendHeartbeat(e,!0,this.config))},e.prototype.submitSessionHeartbeat=function(e){e&&(this.config.log.info("Submitting session heartbeat: "+e),this.config.submissionClient.sendHeartbeat(e,!1,this.config))},e.prototype.createEvent=function(e){return new n({date:new Date},this,e)},e.prototype.submitEvent=function(e,t,r){function n(e){return e&&(e.cancelled=!0),!!r&&r(e)}var i=new S(this,e,t);return e?this.config.enabled?(e.data||(e.data={}),e.tags&&e.tags.length||(e.tags=[]),void _.run(i,function(e){var t=e.client.config,n=e.event;e.cancelled||(n.type&&0!==n.type.length||(n.type="log"),n.date||(n.date=new Date),t.queue.enqueue(n),n.reference_id&&0<n.reference_id.length&&(e.log.info("Setting last reference id '"+n.reference_id+"'"),t.lastReferenceIdManager.setLast(n.reference_id))),r&&r(e)})):(this.config.log.info("Event submission is currently disabled."),n(i)):n(i)},e.prototype.updateUserEmailAndDescription=function(t,e,n,r){var i=this;if(!(t&&e&&n&&this.config.enabled))return!!r&&r(new C(500,"cancelled"));var o={email_address:e,description:n};this.config.submissionClient.postUserDescription(t,o,this.config,function(e){e.success||i.config.log.error("Failed to submit user email and description for event '"+t+"': "+e.statusCode+" "+e.message),r&&r(e)})},e.prototype.getLastReferenceId=function(){return this.config.lastReferenceIdManager.getLast()},e.prototype.updateSettingsTimer=function(e){var t=this;this.config.log.info("Updating settings timer with delay: "+e),this._timeoutId=clearTimeout(this._timeoutId),this._timeoutId=clearInterval(this._intervalId);var n=this.config.updateSettingsWhenIdleInterval;if(0<n){var r=function(){return P.updateSettings(t.config)};0<e&&(this._timeoutId=setTimeout(r,e)),this._intervalId=setInterval(r,n)}},Object.defineProperty(e,"default",{get:function(){return null===e._instance&&(e._instance=new e(null)),e._instance},enumerable:!0,configurable:!0}),e}();T._instance=null,e.ExceptionlessClient=T;var k=function(){function e(){}return e.prototype.setException=function(e){e&&(this["@@_Exception"]=e)},Object.defineProperty(e.prototype,"hasException",{get:function(){return!!this["@@_Exception"]},enumerable:!0,configurable:!0}),e.prototype.getException=function(){return this["@@_Exception"]||null},e.prototype.markAsUnhandledError=function(){this["@@_IsUnhandledError"]=!0},Object.defineProperty(e.prototype,"isUnhandledError",{get:function(){return!!this["@@_IsUnhandledError"]},enumerable:!0,configurable:!0}),e.prototype.setSubmissionMethod=function(e){e&&(this["@@_SubmissionMethod"]=e)},e.prototype.getSubmissionMethod=function(){return this["@@_SubmissionMethod"]||null},e}();e.ContextData=k;var U=function(){function n(e){function t(e){return"function"==typeof e?e(this):e}this.defaultTags=[],this.defaultData={},this.enabled=!0,this.lastReferenceIdManager=new g,this.settings={},this._serverUrl="https://collector.exceptionless.io",this._configServerUrl="https://config.exceptionless.io",this._heartbeatServerUrl="https://heartbeat.exceptionless.io",this._updateSettingsWhenIdleInterval=12e4,this._dataExclusions=[],this._userAgentBotPatterns=[],this._plugins=[],this._handlers=[],e=I.merge(n.defaults,e),this.log=t(e.log)||new m,this.apiKey=e.apiKey,this.serverUrl=e.serverUrl,this.configServerUrl=e.configServerUrl,this.heartbeatServerUrl=e.heartbeatServerUrl,this.updateSettingsWhenIdleInterval=e.updateSettingsWhenIdleInterval,this.includePrivateInformation=e.includePrivateInformation,this.environmentInfoCollector=t(e.environmentInfoCollector),this.errorParser=t(e.errorParser),this.lastReferenceIdManager=t(e.lastReferenceIdManager)||new g,this.moduleCollector=t(e.moduleCollector),this.requestInfoCollector=t(e.requestInfoCollector),this.submissionBatchSize=t(e.submissionBatchSize)||50,this.submissionAdapter=t(e.submissionAdapter),this.submissionClient=t(e.submissionClient)||new E,this.storage=t(e.storage)||new w,this.queue=t(e.queue)||new x(this),P.applySavedServerSettings(this),_.addDefaultPlugins(this)}return Object.defineProperty(n.prototype,"apiKey",{get:function(){return this._apiKey},set:function(e){this._apiKey=e||null,this.log.info("apiKey: "+this._apiKey),this.changed()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isValid",{get:function(){return!!this.apiKey&&10<=this.apiKey.length},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"serverUrl",{get:function(){return this._serverUrl},set:function(e){e&&(this._serverUrl=e,this._configServerUrl=e,this._heartbeatServerUrl=e,this.log.info("serverUrl: "+e),this.changed())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"configServerUrl",{get:function(){return this._configServerUrl},set:function(e){e&&(this._configServerUrl=e,this.log.info("configServerUrl: "+e),this.changed())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"heartbeatServerUrl",{get:function(){return this._heartbeatServerUrl},set:function(e){e&&(this._heartbeatServerUrl=e,this.log.info("heartbeatServerUrl: "+e),this.changed())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"updateSettingsWhenIdleInterval",{get:function(){return this._updateSettingsWhenIdleInterval},set:function(e){"number"==typeof e&&(e<=0?e=-1:0<e&&e<12e4&&(e=12e4),this._updateSettingsWhenIdleInterval=e,this.log.info("updateSettingsWhenIdleInterval: "+e),this.changed())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"dataExclusions",{get:function(){var e=this.settings["@@DataExclusions"];return this._dataExclusions.concat(e&&e.split(",")||[])},enumerable:!0,configurable:!0}),n.prototype.addDataExclusions=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._dataExclusions=I.addRange.apply(I,[this._dataExclusions].concat(e))},Object.defineProperty(n.prototype,"includePrivateInformation",{get:function(){return this._includePrivateInformation},set:function(e){var t=e||!1;this._includePrivateInformation=t,this._includeUserName=t,this._includeMachineName=t,this._includeIpAddress=t,this._includeCookies=t,this._includePostData=t,this._includeQueryString=t,this.log.info("includePrivateInformation: "+t),this.changed()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"includeUserName",{get:function(){return this._includeUserName},set:function(e){this._includeUserName=e||!1,this.changed()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"includeMachineName",{get:function(){return this._includeMachineName},set:function(e){this._includeMachineName=e||!1,this.changed()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"includeIpAddress",{get:function(){return this._includeIpAddress},set:function(e){this._includeIpAddress=e||!1,this.changed()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"includeCookies",{get:function(){return this._includeCookies},set:function(e){this._includeCookies=e||!1,this.changed()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"includePostData",{get:function(){return this._includePostData},set:function(e){this._includePostData=e||!1,this.changed()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"includeQueryString",{get:function(){return this._includeQueryString},set:function(e){this._includeQueryString=e||!1,this.changed()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"userAgentBotPatterns",{get:function(){var e=this.settings["@@UserAgentBotPatterns"];return this._userAgentBotPatterns.concat(e&&e.split(",")||[])},enumerable:!0,configurable:!0}),n.prototype.addUserAgentBotPatterns=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._userAgentBotPatterns=I.addRange.apply(I,[this._userAgentBotPatterns].concat(e))},Object.defineProperty(n.prototype,"plugins",{get:function(){return this._plugins.sort(function(e,t){return e.priority<t.priority?-1:e.priority>t.priority?1:0})},enumerable:!0,configurable:!0}),n.prototype.addPlugin=function(e,t,n){var r=n?{name:e,priority:t,run:n}:e;if(r&&r.run){r.name||(r.name=I.guid()),r.priority||(r.priority=0);for(var i=!1,o=this._plugins,s=0,a=o;s<a.length;s++){if(a[s].name===r.name){i=!0;break}}i||o.push(r)}else this.log.error("Add plugin failed: Run method not defined")},n.prototype.removePlugin=function(e){var t="string"==typeof e?e:e.name;if(t){for(var n=this._plugins,r=0;r<n.length;r++)if(n[r].name===t){n.splice(r,1);break}}else this.log.error("Remove plugin failed: Plugin name not defined")},n.prototype.setVersion=function(e){e&&(this.defaultData["@version"]=e)},n.prototype.setUserIdentity=function(e,t){var n="string"!=typeof e?e:{identity:e,name:t},r=!n||!n.identity&&!n.name;r?delete this.defaultData["@user"]:this.defaultData["@user"]=n,this.log.info("user identity: "+(r?"null":n.identity))},Object.defineProperty(n.prototype,"userAgent",{get:function(){return"exceptionless-universal-js/1.6.1"},enumerable:!0,configurable:!0}),n.prototype.useSessions=function(e,t){void 0===e&&(e=!0),void 0===t&&(t=3e4),e&&this.addPlugin(new y(t))},n.prototype.useReferenceIds=function(){this.addPlugin(new b)},n.prototype.useLocalStorage=function(){},n.prototype.useDebugLogger=function(){this.log=new v},n.prototype.onChanged=function(e){e&&this._handlers.push(e)},n.prototype.changed=function(){for(var e=0,t=this._handlers;e<t.length;e++){var n=t[e];try{n(this)}catch(e){this.log.error("Error calling onChanged handler: "+e)}}},Object.defineProperty(n,"defaults",{get:function(){return null===n._defaultSettings&&(n._defaultSettings={includePrivateInformation:!0}),n._defaultSettings},enumerable:!0,configurable:!0}),n}();U._defaultSettings=null,e.Configuration=U;var O=function(e,t,n,r,i){void 0===n&&(n=-1),void 0===r&&(r=null),void 0===i&&(i=null),this.success=!1,this.settingsVersion=-1,this.success=e,this.settings=t,this.settingsVersion=n,this.exception=r,this.message=i};e.SettingsResponse=O;var n=function(){function e(e,t,n){this._validIdentifierErrorMessage="must contain between 8 and 100 alphanumeric or '-' characters.",this.target=e,this.client=t,this.pluginContextData=n||new k}return e.prototype.setType=function(e){return e&&(this.target.type=e),this},e.prototype.setSource=function(e){return e&&(this.target.source=e),this},e.prototype.setReferenceId=function(e){if(!this.isValidIdentifier(e))throw new Error("ReferenceId "+this._validIdentifierErrorMessage);return this.target.reference_id=e,this},e.prototype.setEventReference=function(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},e.prototype.setMessage=function(e){return e&&(this.target.message=e),this},e.prototype.setGeo=function(e,t){if(e<-90||90<e)throw new Error("Must be a valid latitude value between -90.0 and 90.0.");if(t<-180||180<t)throw new Error("Must be a valid longitude value between -180.0 and 180.0.");return this.target.geo=e+","+t,this},e.prototype.setUserIdentity=function(e,t){var n="string"!=typeof e?e:{identity:e,name:t};return n&&(n.identity||n.name)&&this.setProperty("@user",n),this},e.prototype.setUserDescription=function(e,t){return e&&t&&this.setProperty("@user_description",{email_address:e,description:t}),this},e.prototype.setManualStackingInfo=function(e,t){if(e){var n={signature_data:e};t&&(n.title=t),this.setProperty("@stack",n)}return this},e.prototype.setManualStackingKey=function(e,t){if(e){var n={ManualStackingKey:e};this.setManualStackingInfo(n,t)}return this},e.prototype.setValue=function(e){return e&&(this.target.value=e),this},e.prototype.addTags=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this.target.tags=I.addRange.apply(I,[this.target.tags].concat(e)),this},e.prototype.setProperty=function(e,t,n,r){if(!e||void 0===t||null==t)return this;this.target.data||(this.target.data={});var i=JSON.parse(I.stringify(t,this.client.config.dataExclusions.concat(r||[]),n));return I.isEmpty(i)||(this.target.data[e]=i),this},e.prototype.markAsCritical=function(e){return e&&this.addTags("Critical"),this},e.prototype.addRequestInfo=function(e){return e&&(this.pluginContextData["@request"]=e),this},e.prototype.submit=function(e){this.client.submitEvent(this.target,this.pluginContextData,e)},e.prototype.isValidIdentifier=function(e){if(!e)return!0;if(e.length<8||100<e.length)return!1;for(var t=0;t<e.length;t++){var n=e.charCodeAt(t);if(!(48<=n&&n<=57)&&!(65<=n&&n<=90||97<=n&&n<=122)&&!(45===n))return!1}return!0},e}();e.EventBuilder=n;var R=function(){function e(){this.priority=10,this.name="ConfigurationDefaultsPlugin"}return e.prototype.run=function(e,t){for(var n=e.client.config,r=0,i=n.defaultTags||[];r<i.length;r++){var o=i[r];o&&e.event.tags.indexOf(o)<0&&e.event.tags.push(o)}var s=n.defaultData||{};for(var a in s)if(s[a]){var u=JSON.parse(I.stringify(s[a],n.dataExclusions));I.isEmpty(u)||(e.event.data[a]=u)}t&&t()},e}();e.ConfigurationDefaultsPlugin=R;var q=function(){function e(e,t){void 0===e&&(e=function(){return Date.now()}),void 0===t&&(t=3e4);var n=this;this.priority=1010,this.name="DuplicateCheckerPlugin",this._mergedEvents=[],this._processedHashcodes=[],this._getCurrentTime=e,this._interval=t,setInterval(function(){for(;0<n._mergedEvents.length;)n._mergedEvents.shift().resubmit()},t)}return e.prototype.run=function(e,t){var n=this;var r=function(e){for(var t=0;e;)e.message&&e.message.length&&(t+=397*t^I.getHashCode(e.message)),e.stack_trace&&e.stack_trace.length&&(t+=397*t^I.getHashCode(JSON.stringify(e.stack_trace))),e=e.inner;return t}(e.event.data["@error"]);if(r){var i=e.event.count||1,o=this._getCurrentTime(),s=this._mergedEvents.filter(function(e){return e.hashCode===r})[0];if(s&&(s.incrementCount(i),s.updateDate(e.event.date),e.log.info("Ignoring duplicate event with hash: "+r),e.cancelled=!0),!e.cancelled&&this._processedHashcodes.some(function(e){return e.hash===r&&e.timestamp>=o-n._interval})&&(e.log.trace("Adding event with hash: "+r),this._mergedEvents.push(new M(r,e,i)),e.cancelled=!0),!e.cancelled)for(e.log.trace("Enqueueing event with hash: "+r+"to cache."),this._processedHashcodes.push({hash:r,timestamp:o});50<this._processedHashcodes.length;)this._processedHashcodes.shift()}t&&t()},e}();e.DuplicateCheckerPlugin=q;var M=function(){function e(e,t,n){this.hashCode=e,this._context=t,this._count=n}return e.prototype.incrementCount=function(e){this._count+=e},e.prototype.resubmit=function(){this._context.event.count=this._count,this._context.client.config.queue.enqueue(this._context.event)},e.prototype.updateDate=function(e){e>this._context.event.date&&(this._context.event.date=e)},e}(),A=function(){function e(){this.priority=80,this.name="EnvironmentInfoPlugin"}return e.prototype.run=function(e,t){var n="@environment",r=e.client.config.environmentInfoCollector;if(!e.event.data[n]&&r){var i=r.getEnvironmentInfo(e);i&&(e.event.data[n]=i)}t&&t()},e}();e.EnvironmentInfoPlugin=A;var D=function(){function e(){this.priority=30,this.name="ErrorPlugin"}return e.prototype.run=function(e,t){var n=e.contextData.getException();if(n&&(e.event.type="error",!e.event.data["@error"])){var r=e.client.config,i=r.errorParser;if(!i)throw new Error("No error parser was defined.");var o=i.parse(e,n);if(o){var s=JSON.parse(I.stringify(n,r.dataExclusions.concat(["arguments","column","columnNumber","description","fileName","message","name","number","line","lineNumber","opera#sourceloc","sourceId","sourceURL","stack","stackArray","stacktrace"])));I.isEmpty(s)||(o.data||(o.data={}),o.data["@ext"]=s),e.event.data["@error"]=o}}t&&t()},e}();e.ErrorPlugin=D;var N=function(){function e(){this.priority=45,this.name="EventExclusionPlugin"}return e.prototype.run=function(e,t){function n(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}}function r(e,t,n,r){if(void 0===e&&(e={}),!t)return r;var i="log"===t,o="@@"+t+":",s=e[o+n];if(s)return i?s:I.toBoolean(s);for(var a in e)if(I.startsWith(a.toLowerCase(),o.toLowerCase())&&I.isMatch(n,[a.substring(o.length)]))return i?e[a]:I.toBoolean(e[a]);return r}var i,o,s=e.event,a=e.log,u=e.client.config.settings;if("log"===s.type){var c=(i=u,void 0===(o=s.source)&&(o="*"),n(r(i,"log",o,"Trace")+"")),l=n(s.data["@level"]);0<=l&&(5<l||l<c)&&(a.info("Cancelling log event due to minimum log level."),e.cancelled=!0)}else if("error"===s.type)for(var f=s.data["@error"];!e.cancelled&&f;)!1===r(u,s.type,f.type,!0)&&(a.info("Cancelling error from excluded exception type: "+f.type),e.cancelled=!0),f=f.inner;else!1===r(u,s.type,s.source,!0)&&(a.info("Cancelling event from excluded type: "+s.type+" and source: "+s.source),e.cancelled=!0);t&&t()},e}();e.EventExclusionPlugin=N;var j=function(){function e(){this.priority=50,this.name="ModuleInfoPlugin"}return e.prototype.run=function(e,t){var n=e.client.config.moduleCollector;if(e.event.data["@error"]&&!e.event.data["@error"].modules&&n){var r=n.getModules(e);r&&0<r.length&&(e.event.data["@error"].modules=r)}t&&t()},e}();e.ModuleInfoPlugin=j;var F=function(){function e(){this.priority=70,this.name="RequestInfoPlugin"}return e.prototype.run=function(e,t){var n="@request",r=e.client.config,i=r.requestInfoCollector;if(!e.event.data[n]&&i){var o=i.getRequestInfo(e);o&&(I.isMatch(o.user_agent,r.userAgentBotPatterns)?(e.log.info("Cancelling event as the request user agent matches a known bot pattern"),e.cancelled=!0):e.event.data[n]=o)}t&&t()},e}();e.RequestInfoPlugin=F;var L=function(){function e(){this.priority=100,this.name="SubmissionMethodPlugin"}return e.prototype.run=function(e,t){var n=e.contextData.getSubmissionMethod();n&&(e.event.data["@submission_method"]=n),t&&t()},e}();e.SubmissionMethodPlugin=L;var K=function(){function e(e){this.items=[],this.lastTimestamp=0,this.maxItems=e}return e.prototype.save=function(e){if(!e)return null;var t=this.items,n=Math.max(Date.now(),this.lastTimestamp+1),r={timestamp:n,value:e};return t.push(r)>this.maxItems&&t.shift(),this.lastTimestamp=n,r.timestamp},e.prototype.get=function(e){return this.items.slice(0,e)},e.prototype.remove=function(e){for(var t=this.items,n=0;n<t.length;n++)if(t[n].timestamp===e)return void t.splice(n,1)},e.prototype.clear=function(){this.items=[]},e}();e.InMemoryStorage=K;var Q=function(){function e(e){this.lastTimestamp=0,this.maxItems=e}return e.prototype.save=function(e,t){if(!e)return null;this.ensureIndex();var n=this.items,r=Math.max(Date.now(),this.lastTimestamp+1),i=this.getKey(r),o=JSON.stringify(e);try{this.write(i,o),this.lastTimestamp=r,n.push(r)>this.maxItems&&this.delete(this.getKey(n.shift()))}catch(e){return null}return r},e.prototype.get=function(e){var r=this;return this.ensureIndex(),this.items.slice(0,e).map(function(e){var t=r.getKey(e);try{var n=r.read(t);return{timestamp:e,value:JSON.parse(n,B)}}catch(e){return r.safeDelete(t),null}}).filter(function(e){return null!=e})},e.prototype.remove=function(e){this.ensureIndex();var t=this.items,n=t.indexOf(e);if(0<=n){var r=this.getKey(e);this.safeDelete(r),t.splice(n,1)}},e.prototype.clear=function(){var t=this;this.items.forEach(function(e){return t.safeDelete(t.getKey(e))}),this.items=[]},e.prototype.ensureIndex=function(){this.items||(this.items=this.createIndex(),this.lastTimestamp=Math.max.apply(Math,[0].concat(this.items))+1)},e.prototype.safeDelete=function(e){try{this.delete(e)}catch(e){}},e.prototype.createIndex=function(){var n=this;try{return this.readAllKeys().map(function(t){try{var e=n.getTimestamp(t);return e||(n.safeDelete(t),null)}catch(e){return n.safeDelete(t),null}}).filter(function(e){return null!=e}).sort(function(e,t){return e-t})}catch(e){return[]}},e}();function B(e,t){if("string"==typeof t&&/\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)/g.exec(t))return new Date(t);return t}var H=function(i){function e(e,t,n){void 0===t&&(t="com.exceptionless."),void 0===n&&(n=20);var r=i.call(this,n)||this;return r.prefix=t+e+"-",r}return t(e,i),e.isAvailable=function(){try{var e=window.localStorage,t="__storage_test__";return e.setItem(t,t),e.removeItem(t),!0}catch(e){return!1}},e.prototype.write=function(e,t){window.localStorage.setItem(e,t)},e.prototype.read=function(e){return window.localStorage.getItem(e)},e.prototype.readAllKeys=function(){var t=this;return Object.keys(window.localStorage).filter(function(e){return 0===e.indexOf(t.prefix)})},e.prototype.delete=function(e){window.localStorage.removeItem(e)},e.prototype.getKey=function(e){return this.prefix+e},e.prototype.getTimestamp=function(e){return parseInt(e.substr(this.prefix.length),10)},e}(e.KeyValueStorageBase=Q);e.BrowserStorage=H;var V=function(){function e(){}return e.prototype.parse=function(e,t){function s(e){for(var t=[],n=0,r=("string"==typeof e?[e]:e)||[];n<r.length;n++){var i=r[n];t.push({name:i})}return t}var n="@@_TraceKit.StackTrace",r=e.contextData[n]?e.contextData[n]:o.computeStackTrace(t,25);if(!r)throw new Error("Unable to parse the exceptions stack trace.");var i="string"==typeof t?t:void 0;return{type:r.name||"Error",message:r.message||t.message||i,stack_trace:function(e){for(var t="<anonymous>",n=[],r=0,i=e;r<i.length;r++){var o=i[r];n.push({name:(o.func||t).replace("?",t),parameters:s(o.args),file_name:o.url,line_number:o.line||0,column:o.column||0})}return n}(r.stack||[])}},e}();e.DefaultErrorParser=V;var $=function(){function e(){}return e.prototype.getModules=function(e){if(!document||!document.getElementsByTagName)return null;var t=[],n=document.getElementsByTagName("script");if(n&&0<n.length)for(var r=0;r<n.length;r++)n[r].src?t.push({module_id:r,name:n[r].src.split("?")[0],version:I.parseVersion(n[r].src)}):n[r].innerHTML&&t.push({module_id:r,name:"Script Tag",version:I.getHashCode(n[r].innerHTML).toString()});return t},e}();e.DefaultModuleCollector=$;var J=function(){function e(){}return e.prototype.getRequestInfo=function(e){if(!document||!navigator||!location)return null;var t=e.client.config,n=t.dataExclusions,r={user_agent:navigator.userAgent,is_secure:"https:"===location.protocol,host:location.hostname,port:location.port&&""!==location.port?parseInt(location.port,10):80,path:location.pathname};return t.includeCookies&&(r.cookies=I.getCookies(document.cookie,n)),t.includeQueryString&&(r.query_string=I.parseQueryString(location.search.substring(1),n)),document.referrer&&""!==document.referrer&&(r.referrer=document.referrer),r},e}();e.DefaultRequestInfoCollector=J;var z=function(e,t){void 0===t&&(t=250),this.queue=new H("q",e,t),this.settings=new H("settings",e,1)};e.BrowserStorageProvider=z;var W=function(){function e(){}return e.prototype.sendRequest=function(s,a,e){var u="timeout",c="loaded",t="withCredentials",l=!1,n=!1;function r(e,t){if(!l){l=!0;var n=t.statusText,r=t.responseText,i=t.status;if(e===u||0===i)n="Unable to connect to server.",i=0;else if(e!==c||i){if(i<200||299<i){var o=t.responseBody;if(o&&o.message)n=o.message;else if(r&&-1!==r.indexOf("message"))try{n=JSON.parse(r).message}catch(e){n=r}}}else i="POST"===s.method?202:200;a&&a(i||500,n||"",r,function(e){for(var t,n={},r=0,i=(e||"").split("\r\n");r<i.length;r++){var o=i[r],s=o.indexOf(": ");0<s&&(n[(t=o.substring(0,s).toLowerCase(),t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""))]=o.substring(s+2))}return n}(t.getAllResponseHeaders&&t.getAllResponseHeaders()))}}var i,o,f,p,d=s.url+(-1===s.url.indexOf("?")?"?":"&")+"access_token="+encodeURIComponent(s.apiKey),h=(i=s.userAgent,o=s.method||"POST",f=d,p=new XMLHttpRequest,t in p?(p.open(o,f,!0),p.setRequestHeader("X-Exceptionless-Client",i),"POST"===o&&p.setRequestHeader("Content-Type","application/json")):"undefined"!=typeof XDomainRequest?(n=!0,(p=new XDomainRequest).open(o,"http:"===location.protocol?f.replace("https:","http:"):f)):p=null,p&&(p.timeout=1e4),p);if(!h)return a&&a(503,"CORS not supported.");t in h&&(h.onreadystatechange=function(){4===h.readyState&&r(c,h)}),h.onprogress=function(){},h.ontimeout=function(){return r(u,h)},h.onerror=function(){return r("error",h)},h.onload=function(){return r(c,h)},n?setTimeout(function(){return h.send(s.data)},500):h.send(s.data)},e}();e.DefaultSubmissionAdapter=W;var Z=function(a){function e(e,t,n,r,i){void 0===n&&(n="ex-"),void 0===r&&(r=20);var o=a.call(this,r)||this;t||(t=f.join(f.dirname(u.main.filename),".exceptionless"));var s=f.join(t,e);return o.directory=f.resolve(s),o.prefix=n,o.fs=i||l,o.mkdir(o.directory),o}return t(e,a),e.prototype.write=function(e,t){this.fs.writeFileSync(e,t)},e.prototype.read=function(e){return this.fs.readFileSync(e,"utf8")},e.prototype.readAllKeys=function(){var t=this;return this.fs.readdirSync(this.directory).filter(function(e){return 0===e.indexOf(t.prefix)}).map(function(e){return f.join(t.directory,e)})},e.prototype.delete=function(e){this.fs.unlinkSync(e)},e.prototype.getKey=function(e){return f.join(this.directory,""+this.prefix+e+".json")},e.prototype.getTimestamp=function(e){return parseInt(f.basename(e,".json").substr(this.prefix.length),10)},e.prototype.mkdir=function(e){for(var t=e.split(f.sep),n="";0<t.length;){var r=t.shift();""===r&&(n=f.sep),this.fs.existsSync(n+r)||this.fs.mkdirSync(n+r),n+=r+f.sep}},e}(Q);e.NodeFileStorage=Z;var X=function(){function e(){}return e.prototype.getEnvironmentInfo=function(e){if(!s)return null;var t,n,r={processor_count:s.cpus().length,total_physical_memory:s.totalmem(),available_physical_memory:s.freemem(),command_line:process.argv.join(" "),process_name:(process.title||"").replace(/[\uE000-\uF8FF]/g,""),process_id:process.pid+"",process_memory_size:process.memoryUsage().heapTotal,architecture:s.arch(),o_s_name:s.type(),o_s_version:s.release(),runtime_version:process.version,data:{loadavg:s.loadavg(),platform:s.platform(),tmpdir:s.tmpdir(),uptime:s.uptime()}},i=e.client.config;return i.includeMachineName&&(r.machine_name=s.hostname()),i.includeIpAddress&&(r.ip_address=(t=[],n=s.networkInterfaces(),Object.keys(n).forEach(function(e){n[e].forEach(function(e){"IPv4"!==e.family||e.internal||t.push(e.address)})}),t.join(", "))),s.endianness&&(r.data.endianness=s.endianness()),r},e}();e.NodeEnvironmentInfoCollector=X;var G=function(){function e(){}return e.prototype.parse=function(e,t){if(!i)throw new Error("Unable to load the stack trace library.");var n=i.parse(t)||[];return{type:t.name||"Error",message:t.message,stack_trace:function(e){for(var t=[],n=0,r=e;n<r.length;n++){var i=r[n];t.push({name:i.getMethodName()||i.getFunctionName(),file_name:i.getFileName(),line_number:i.getLineNumber()||0,column:i.getColumnNumber()||0,declaring_type:i.getTypeName(),data:{is_native:i.isNative()||!!i.filename&&"/"!==i.filename[0]&&"."!==i.filename[0]}})}return t}(n)}},e}();e.NodeErrorParser=G;var Y=function(){function e(){this.initialized=!1,this.installedModules={}}return e.prototype.getModules=function(e){var t=this;if(this.initialize(),!u.main)return[];var n=(c.dirname(u.main.filename)+"/node_modules/").length,r=Object.keys(u.cache),i={};return r.forEach(function(e){var t=e.substr(n);t=t.substr(0,t.indexOf("/")),i[t]=!0}),Object.keys(i).map(function(e){return t.installedModules[e]}).filter(function(e){return void 0!==e})},e.prototype.initialize=function(){var r=this;if(!this.initialized){this.initialized=!0;var e=a.spawnSync("npm",["ls","--depth=0","--json"]).stdout;if(e){var t;try{t=JSON.parse(e.toString())}catch(e){return}var i=t.dependencies;if(i){var o=0;this.installedModules={},Object.keys(i).forEach(function(e){var t=i[e],n={module_id:o++,name:e,version:t.version};r.installedModules[e]=n})}}}},e}();e.NodeModuleCollector=Y;var ee=function(){function e(){}return e.prototype.getRequestInfo=function(e){var t="@request";if(!e.contextData[t])return null;var n=e.client.config,r=n.dataExclusions,i=e.contextData[t],o={user_agent:i.headers["user-agent"],is_secure:i.secure,http_method:i.method,host:i.hostname||i.host,path:i.path},s=i.headers.host,a=s&&parseInt(s.slice(s.indexOf(":")+1),10);return 0<a&&(o.port=a),n.includeIpAddress&&(o.client_ip_address=i.ip),n.includeCookies&&(o.cookies=I.getCookies(i.headers.cookie,r)),n.includeQueryString&&(o.query_string=JSON.parse(I.stringify(i.params||{},r))),n.includePostData&&(o.post_data=JSON.parse(I.stringify(i.body||{},r))),o},e}();e.NodeRequestInfoCollector=ee;var te=function(e,t,n){void 0===n&&(n=250),this.queue=new Z("q",e,t,n),this.settings=new Z("settings",e,t,1)};e.NodeFileStorageProvider=te;var ne=function(){function e(){}return e.prototype.sendRequest=function(e,n,t){var r=this;if(t)this.sendRequestSync(e,n);else{var i=h.parse(e.url),o={auth:"client:"+e.apiKey,headers:{},hostname:i.hostname,method:e.method,port:i.port&&parseInt(i.port,10),path:e.url};o.headers["User-Agent"]=e.userAgent,"POST"===e.method&&(o.headers={"Content-Type":"application/json","Content-Length":Buffer.byteLength(e.data)});var s=("https:"===i.protocol?d:p).request(o,function(e){var t="";e.setEncoding("utf8"),e.on("data",function(e){return t+=e}),e.on("end",function(){return r.complete(e,t,e.headers,n)})});s.on("error",function(e){return n&&n(500,e.message)}),s.end(e.data)}},e.prototype.complete=function(e,t,n,r){var i;0===e.statusCode?i="Unable to connect to server.":(e.statusCode<200||299<e.statusCode)&&(i=e.statusMessage||e.message),r&&r(e.statusCode||500,i,t,n)},e.prototype.sendRequestSync=function(e,t){var n=JSON.stringify(e),r=a.spawnSync(process.execPath,[u.resolve("./submitSync.js")],{input:n,stdio:["pipe","pipe",process.stderr]}).stdout.toString(),i=JSON.parse(r);t&&t(i.status,i.message,i.data,i.headers)},e}();return e.NodeSubmissionAdapter=ne,function(){if("undefined"!=typeof document){U.prototype.useLocalStorage=function(){H.isAvailable()&&(this.storage=new z,P.applySavedServerSettings(this),this.changed())};var e=U.defaults,t=function(){if(!document||!document.getElementsByTagName)return null;for(var e=document.getElementsByTagName("script"),t=0;t<e.length;t++)if(e[t].src&&-1<e[t].src.indexOf("/exceptionless"))return I.parseQueryString(e[t].src.split("?").pop());return null}();t&&(t.apiKey&&(e.apiKey=t.apiKey),t.serverUrl&&(e.serverUrl=t.serverUrl),"string"==typeof t.includePrivateInformation&&(e.includePrivateInformation="false"!==t.includePrivateInformation)),e.errorParser=new V,e.moduleCollector=new $,e.requestInfoCollector=new J,e.submissionAdapter=new W,o.report.subscribe(function(e,t){var n=T.default.createUnhandledException(new Error(e.message||(t||{}).status||"Script error"),"onerror");n.pluginContextData["@@_TraceKit.StackTrace"]=e,n.submit()}),o.extendToAsynchronousCallbacks(),Error.stackTraceLimit=1/0}}(),function(){if("undefined"!=typeof process){var e=U.defaults;e.environmentInfoCollector=new X,e.errorParser=new G,e.moduleCollector=new Y,e.requestInfoCollector=new ee,e.submissionAdapter=new ne,U.prototype.useLocalStorage=function(){this.storage=new te,P.applySavedServerSettings(this),this.changed()},process.addListener("uncaughtException",function(e){T.default.submitUnhandledException(e,"uncaughtException")}),process.on("exit",function(e){var t,n=T.default,r=1===(t=e)?"Uncaught Fatal Exception":3===t?"Internal JavaScript Parse Error":4===t?"Internal JavaScript Evaluation Failure":5===t?"Fatal Exception":6===t?"Non-function Internal Exception Handler ":7===t?"Internal Exception Handler Run-Time Failure":8===t?"Uncaught Exception":9===t?"Invalid Argument":10===t?"Internal JavaScript Run-Time Failure":12===t?"Invalid Debug Argument":null;null!==r&&n.submitLog("exit",r,"Error"),n.config.queue.process(!0)}),Error.stackTraceLimit=1/0}}(),e});
//# sourceMappingURL=exceptionless.universal.min.js.map