forked from exceptionless/Exceptionless.JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexceptionless.min.js
More file actions
2 lines (2 loc) · 49 KB
/
exceptionless.min.js
File metadata and controls
2 lines (2 loc) · 49 KB
1
2
!function(e,t){function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function r(e){return void 0===e}if(e){var i={},o=e.TraceKit,s=[].slice,a="?",u=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/;i.noConflict=function(){return e.TraceKit=o,i},i.wrap=function(e){return function(){try{return e.apply(this,arguments)}catch(e){throw i.report(e),e}}},i.report=function(){function t(e,t,r){var o=null;if(!t||i.collectWindowErrors){for(var s in f)if(n(f,s))try{f[s](e,t,r)}catch(e){o=e}if(o)throw o}}function r(e,n,r,o,a){if(h)i.computeStackTrace.augmentStackTraceWithInitialElement(h,n,r,e),s();else if(a)t(i.computeStackTrace(a),!0,a);else{var l,f={url:n,line:r,column:o},p=e;if("[object String]"==={}.toString.call(e)){var d=e.match(u);d&&(l=d[1],p=d[2])}f.func=i.computeStackTrace.guessFunctionName(f.url,f.line),f.context=i.computeStackTrace.gatherContext(f.url,f.line),t({name:l,message:p,mode:"onerror",stack:[f]},!0,null)}return!!c&&c.apply(this,arguments)}function o(){!0!==l&&(c=e.onerror,e.onerror=r,l=!0)}function s(){var e=h,n=p;h=null,p=null,t(e,!1,n)}function a(e){if(h){if(p===e)return;s()}var t=i.computeStackTrace(e);throw h=t,p=e,setTimeout(function(){p===e&&s()},t.incomplete?2e3:0),e}var c,l,f=[],p=null,h=null;return a.subscribe=function(e){o(),f.push(e)},a.unsubscribe=function(t){for(var n=f.length-1;n>=0;--n)f[n]===t&&f.splice(n,1);0===f.length&&(e.onerror=c,l=!1)},a}(),i.computeStackTrace=function(){function t(t){if(!i.remoteFetching)return"";try{var n=function(){try{return new e.XMLHttpRequest}catch(t){return new e.ActiveXObject("Microsoft.XMLHTTP")}}();return n.open("GET",t,!1),n.send(""),n.responseText}catch(e){return""}}function o(r){if("string"!=typeof r)return[];if(!n(_,r)){var i="",o="";try{o=e.document.domain}catch(e){}var s=/(.*)\:\/\/([^:\/]+)([:\d]*)\/{0,1}([\s\S]*)/.exec(r);s&&s[2]===o&&(i=t(r)),_[r]=i?i.split("\n"):[]}return _[r]}function s(e,t){var n,i=/function ([^(]*)\(([^)]*)\)/,s=/['"]?([0-9A-Za-z$_]+)['"]?\s*[:=]\s*(function|eval|new Function)/,u="",c=o(e);if(!c.length)return a;for(var l=0;l<10;++l)if(u=c[t-l]+u,!r(u)){if(n=s.exec(u))return n[1];if(n=i.exec(u))return n[1]}return a}function u(e,t){var n=o(e);if(!n.length)return null;var s=[],a=Math.floor(i.linesOfContext/2),u=a+i.linesOfContext%2,c=Math.max(0,t-a-1),l=Math.min(n.length,t+u-1);t-=1;for(var f=c;f<l;++f)r(n[f])||s.push(n[f]);return s.length>0?s:null}function c(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#]/g,"\\$&")}function l(e){return c(e).replace("<","(?:<|<)").replace(">","(?:>|>)").replace("&","(?:&|&)").replace('"','(?:"|")').replace(/\s+/g,"\\s+")}function f(e,t){for(var n,r,i=0,s=t.length;i<s;++i)if((n=o(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 p(e,t,n){var r,i=o(t),s=new RegExp("\\b"+c(e)+"\\b");return n-=1,i&&i.length>n&&(r=s.exec(i[n]))?r.index:null}function h(t){if(!r(e&&e.document)){for(var n,i,o,s,a=[e.location.href],u=e.document.getElementsByTagName("script"),p=""+t,h=/^function(?:\s+([\w$]+))?\s*\(([\w\s,]*)\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,d=/^function on([\w$]+)\s*\(event\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,g=0;g<u.length;++g){var v=u[g];v.src&&a.push(v.src)}if(o=h.exec(p)){var m=o[1]?"\\s+"+o[1]:"",y=o[2].split(",").join("\\s*,\\s*");n=c(o[3]).replace(/;$/,";?"),i=new RegExp("function"+m+"\\s*\\(\\s*"+y+"\\s*\\)\\s*{\\s*"+n+"\\s*}")}else i=new RegExp(c(p).replace(/\s+/g,"\\s+"));if(s=f(i,a))return s;if(o=d.exec(p)){var b=o[1];if(n=l(o[2]),i=new RegExp("on"+b+"=[\\'\"]\\s*"+n+"\\s*[\\'\"]","i"),s=f(i,a[0]))return s;if(i=new RegExp(n),s=f(i,a))return s}return null}}function d(e){if(!e.stack)return null;for(var t,n,i,o=/^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,c=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,l=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,f=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,h=/\((\S*)(?::(\d+))(?::(\d+))\)/,d=e.stack.split("\n"),g=[],v=/^(.*) is undefined$/.exec(e.message),m=0,y=d.length;m<y;++m){if(n=o.exec(d[m])){var b=n[2]&&0===n[2].indexOf("native");n[2]&&0===n[2].indexOf("eval")&&(t=h.exec(n[2]))&&(n[2]=t[1],n[3]=t[2],n[4]=t[3]),i={url:b?null:n[2],func:n[1]||a,args:b?[n[2]]:[],line:n[3]?+n[3]:null,column:n[4]?+n[4]:null}}else if(n=l.exec(d[m]))i={url:n[2],func:n[1]||a,args:[],line:+n[3],column:n[4]?+n[4]:null};else{if(!(n=c.exec(d[m])))continue;n[3]&&n[3].indexOf(" > eval")>-1&&(t=f.exec(n[3]))?(n[3]=t[1],n[4]=t[2],n[5]=null):0!==m||n[5]||r(e.columnNumber)||(g[0].column=e.columnNumber+1),i={url:n[3],func:n[1]||a,args:n[2]?n[2].split(","):[],line:n[4]?+n[4]:null,column:n[5]?+n[5]:null}}!i.func&&i.line&&(i.func=s(i.url,i.line)),i.context=i.line?u(i.url,i.line):null,g.push(i)}return g.length?(g[0]&&g[0].line&&!g[0].column&&v&&(g[0].column=p(v[1],g[0].url,g[0].line)),{mode:"stack",name:e.name,message:e.message,stack:g}):null}function g(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"),a=[],c=0;c<o.length;c+=2){var l=null;if((n=r.exec(o[c]))?l={url:n[2],line:+n[1],column:null,func:n[3],args:[]}:(n=i.exec(o[c]))&&(l={url:n[6],line:+n[1],column:+n[2],func:n[3]||n[4],args:n[5]?n[5].split(","):[]}),l){if(!l.func&&l.line&&(l.func=s(l.url,l.line)),l.line)try{l.context=u(l.url,l.line)}catch(e){}l.context||(l.context=[o[c+1]]),a.push(l)}}return a.length?{mode:"stacktrace",name:e.name,message:e.message,stack:a}:null}}function v(t){var r=t.message.split("\n");if(r.length<4)return null;var i,a=/^\s*Line (\d+) of linked script ((?:file|https?|blob)\S+)(?:: in function (\S+))?\s*$/i,c=/^\s*Line (\d+) of inline#(\d+) script in ((?:file|https?|blob)\S+)(?:: in function (\S+))?\s*$/i,p=/^\s*Line (\d+) of function script\s*$/i,h=[],d=e&&e.document&&e.document.getElementsByTagName("script"),g=[];for(var v in d)n(d,v)&&!d[v].src&&g.push(d[v]);for(var m=2;m<r.length;m+=2){var y=null;if(i=a.exec(r[m]))y={url:i[2],func:i[3],args:[],line:+i[1],column:null};else if(i=c.exec(r[m])){y={url:i[3],func:i[4],args:[],line:+i[1],column:null};var b=+i[1],S=g[i[2]-1];if(S){var _=o(y.url);if(_){var x=(_=_.join("\n")).indexOf(S.innerText);x>=0&&(y.line=b+_.substring(0,x).split("\n").length)}}}else if(i=p.exec(r[m])){var w=e.location.href.replace(/#.*$/,""),E=f(new RegExp(l(r[m+1])),[w]);y={url:w,func:"",args:[],line:E?E.line:i[1],column:null}}if(y){y.func||(y.func=s(y.url,y.line));var I=u(y.url,y.line),P=I?I[Math.floor(I.length/2)]:null;I&&P.replace(/^\s*/,"")===r[m+1].replace(/^\s*/,"")?y.context=I:y.context=[r[m+1]],h.push(y)}}return h.length?{mode:"multiline",name:t.name,message:r[0],stack:h}:null}function m(e,t,n,r){var i={url:t,line:n};if(i.url&&i.line){e.incomplete=!1,i.func||(i.func=s(i.url,i.line)),i.context||(i.context=u(i.url,i.line));var o=/ '([^']+)' /.exec(r);if(o&&(i.column=p(o[1],i.url,i.line)),e.stack.length>0&&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,!0}return e.incomplete=!0,!1}function y(e,t){for(var n,r,o,u=/function\s+([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)?\s*\(/i,c=[],l={},f=!1,d=y.caller;d&&!f;d=d.caller)if(d!==b&&d!==i.report){if(r={url:null,func:a,args:[],line:null,column:null},d.name?r.func=d.name:(n=u.exec(d.toString()))&&(r.func=n[1]),void 0===r.func)try{r.func=n.input.substring(0,n.input.indexOf("{"))}catch(e){}if(o=h(d)){r.url=o.url,r.line=o.line,r.func===a&&(r.func=s(r.url,r.line));var g=/ '([^']+)' /.exec(e.message||e.description);g&&(r.column=p(g[1],o.url,o.line))}l[""+d]?f=!0:l[""+d]=!0,c.push(r)}t&&c.splice(0,t);var v={mode:"callers",name:e.name,message:e.message,stack:c};return m(v,e.sourceURL||e.fileName,e.line||e.lineNumber,e.message||e.description),v}function b(e,t){var n=null;t=null==t?0:+t;try{if(n=g(e))return n}catch(e){if(S)throw e}try{if(n=d(e))return n}catch(e){if(S)throw e}try{if(n=v(e))return n}catch(e){if(S)throw e}try{if(n=y(e,t+1))return n}catch(e){if(S)throw e}return{name:e.name,message:e.message,mode:"failed"}}var S=!1,_={};return b.augmentStackTraceWithInitialElement=m,b.computeStackTraceFromStackProp=d,b.guessFunctionName=s,b.gatherContext=u,b.ofCaller=function(e){e=1+(null==e?0:+e);try{throw new Error}catch(t){return b(t,e+1)}},b.getSource=o,b}(),i.extendToAsynchronousCallbacks=function(){var t=function(t){var n=e[t];e[t]=function(){var e=s.call(arguments),t=e[0];return"function"==typeof t&&(e[0]=i.wrap(t)),n.apply?n.apply(this,e):n(e[0],e[1])}};t("setTimeout"),t("setInterval")},i.remoteFetching||(i.remoteFetching=!0),i.collectWindowErrors||(i.collectWindowErrors=!0),(!i.linesOfContext||i.linesOfContext<1)&&(i.linesOfContext=11),"function"==typeof define&&define.amd?define("TraceKit",[],i):"undefined"!=typeof module&&module.exports&&e.module!==module?module.exports=i:e.TraceKit=i}}("undefined"!=typeof window?window:global);var exports,require;!function(e,t){"function"==typeof define&&define.amd?define("exceptionless",["require","exports","TraceKit"],t):"object"==typeof exports?module.exports=t(require,exports,require("TraceKit")):e.exceptionless=t(require,exports,e.TraceKit)}(this,function(e,t,n){function r(e,t){var n=/\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;return"string"==typeof t&&n.exec(t)?new Date(t):t}if(!t)var t={};var i=this&&this.__extends||function(){var e=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])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=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}();t.DefaultLastReferenceIdManager=o;var s=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}();t.ConsoleLog=s;var a=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}();t.NullLog=a;var u=function(){function e(e){void 0===e&&(e=3e4),this.priority=100,this.name="HeartbeatPlugin",this._interval=e>=3e4?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}();t.HeartbeatPlugin=u;var c=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=g.guid().replace("-","").substring(0,10)),t&&t()},e}();t.ReferenceIdPlugin=c;var l=function(){function e(e,t,n){this.client=e,this.event=t,this.contextData=n||new b}return Object.defineProperty(e.prototype,"log",{get:function(){return this.client.config.log},enumerable:!0,configurable:!0}),e}();t.EventPluginContext=l;var f=function(){function e(){}return e.run=function(e,t){var n=function(n,r){return function(){try{e.cancelled||n.run(e,r)}catch(t){e.cancelled=!0,e.log.error("Error running plugin '"+n.name+"': "+t.message+". Discarding Event.")}e.cancelled&&t&&t(e)}},r=e.client.config.plugins,i=[];t&&(i[r.length]=n({name:"cb",priority:9007199254740992,run:t},null));for(var o=r.length-1;o>-1;o--)i[o]=n(r[o],t||o<r.length-1?i[o+1]:null);i[0]()},e.addDefaultPlugins=function(e){e.addPlugin(new w),e.addPlugin(new T),e.addPlugin(new E),e.addPlugin(new C),e.addPlugin(new U),e.addPlugin(new k),e.addPlugin(new P),e.addPlugin(new q)},e}();t.EventPluginManager=f;var p=function(){function e(e){this._handlers=[],this._processingQueue=!1,this._config=e}return e.prototype.enqueue=function(e){var t=this._config,n=t.log;if(t.enabled)if(t.isValid)if(this.areQueuedItemsDiscarded())n.info("Queue items are currently being discarded. The event will not be queued.");else{this.ensureQueueTimer();var r=t.storage.queue.save(e),i="type="+e.type+" "+(e.reference_id?"refid="+e.reference_id:"");r?n.info("Enqueuing event: "+r+" "+i):n.error("Could not enqueue event "+i)}else n.info("Invalid Api Key. The event will not be queued.");else n.info("Configuration is disabled. The event will not be queued.")},e.prototype.process=function(e){var t=this,n=this._config,r=n.log;if(!this._processingQueue)if(r.info("Processing queue..."),n.enabled)if(n.isValid){this._processingQueue=!0,this.ensureQueueTimer();try{var i=n.storage.queue.get(n.submissionBatchSize);if(!i||0===i.length)return void(this._processingQueue=!1);r.info("Sending "+i.length+" events to "+n.serverUrl+"."),n.submissionClient.postEvents(i.map(function(e){return e.value}),n,function(e){t.processSubmissionResponse(e,i),t.eventsPosted(i.map(function(e){return e.value}),e),r.info("Finished processing queue."),t._processingQueue=!1},e)}catch(e){r.error("Error processing queue: "+e),this.suspendProcessing(),this._processingQueue=!1}}else r.info("Invalid Api Key. The queue will not be processed.");else r.info("Configuration is disabled. The queue will not be processed.")},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=this._config,r=n.log;if(e.success)return r.info("Sent "+t.length+" events."),void this.removeEvents(t);if(e.serviceUnavailable)return r.error("Server returned service unavailable."),void this.suspendProcessing();if(e.paymentRequired)return r.info("Too many events have been submitted, please upgrade your plan."),void this.suspendProcessing(null,!0,!0);if(e.unableToAuthenticate)return r.info("Unable to authenticate, please check your configuration. The event will not be submitted."),this.suspendProcessing(15),void this.removeEvents(t);if(e.notFound||e.badRequest)return r.error("Error while trying to submit data: "+e.message),this.suspendProcessing(240),void this.removeEvents(t);if(e.requestEntityTooLarge){var i="Event submission discarded for being too large.";n.submissionBatchSize>1?(r.error(i+" Retrying with smaller batch size."),n.submissionBatchSize=Math.max(1,Math.round(n.submissionBatchSize/1.5))):(r.error(i+" The event will not be submitted."),this.removeEvents(t))}else e.success||(r.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}();t.DefaultEventQueue=p;var h=function(){return function(e){void 0===e&&(e=250),this.queue=new O(e),this.settings=new O(1)}}();t.InMemoryStorageProvider=h;var d=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(e,t,n){var r=this.createRequest(e,"GET",e.configServerUrl+"/api/v2/projects/config?v="+t);return e.submissionAdapter.sendRequest(r,function(t,r,i,o){if(200!==t)return n(new _(!1,null,-1,null,r));var s;try{s=JSON.parse(i)}catch(t){e.log.error("Unable to parse settings: '"+i+"'")}if(!s||isNaN(s.version))return n(new _(!1,null,-1,null,"Invalid configuration settings."));n(new _(!0,s.settings||{},s.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(e,t){var n=this;return function(r,i,o,s){var a=s&&parseInt(s[n.configurationVersionHeader],10);isNaN(a)?e.log.error("No config version header was returned."):v.checkVersion(a,e),t(new m(r,i))}},e}();t.DefaultSubmissionClient=d;var g=function(){function e(){}return e.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},e.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},e.getCookies=function(t,n){for(var r={},i=0,o=(t||"").split("; ");i<o.length;i++){var s=o[i].split("=");e.isMatch(s[0],n)||(r[s[0]]=s[1])}return e.isEmpty(r)?null:r},e.guid=function(){function e(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()},e.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},e.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&&t.length>0?t[0]:null},e.parseQueryString=function(t,n){if(!t||0===t.length)return null;var r=t.split("&");if(0===r.length)return null;for(var i={},o=0,s=r;o<s.length;o++){var a=s[o].split("=");e.isMatch(a[0],n)||(i[decodeURIComponent(a[0])]=decodeURIComponent(a[1]))}return e.isEmpty(i)?null:i},e.randomNumber=function(){return Math.floor(9007199254740992*Math.random())},e.isMatch=function(t,n,r){if(void 0===r&&(r=!0),!t||"string"!=typeof t)return!1;var i=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;return t=(r?t.toLowerCase():t).replace(i,""),(n||[]).some(function(n){if("string"!=typeof n)return!1;if((n=(r?n.toLowerCase():n).replace(i,"")).length<=0)return!1;var o="*"===n[0];o&&(n=n.slice(1));var s="*"===n[n.length-1];return s&&(n=n.substring(0,n.length-1)),o&&s?n.length<=t.length&&-1!==t.indexOf(n,0):o?e.endsWith(t,n):s?e.startsWith(t,n):t===n})},e.isEmpty=function(e){return null===e||"object"==typeof e&&0===Object.keys(e).length},e.startsWith=function(e,t){return e.substring(0,t.length)===t},e.endsWith=function(e,t){return-1!==e.indexOf(t,e.length-t.length)},e.stringify=function(t,n,r){function i(t,n){var r=[];return JSON.stringify(t,function(t,i){if(!e.isMatch(t,n)){if("object"==typeof i&&i){if(-1!==r.indexOf(i))return;r.push(i)}return i}})}if("[object Object]"==={}.toString.call(t)){var o={};for(var s in t)t[s]!==t&&(o[s]=t[s]);return i(o,n)}if("[object Array]"==={}.toString.call(t)){for(var a=[],u=0;u<t.length;u++)a[u]=JSON.parse(i(t[u],n));return JSON.stringify(a)}return i(t,n)},e.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},e}();t.Utils=g;var v=function(){function e(){}return e.onChanged=function(e){!!e&&this._handlers.push(e)},e.applySavedServerSettings=function(e){if(e&&e.isValid){var t=this.getSavedServerSettings(e);e.log.info("Applying saved settings: v"+t.version),e.settings=g.merge(e.settings,t.settings),this.changed(e)}},e.getVersion=function(e){return e&&e.isValid?this.getSavedServerSettings(e).version||0:0},e.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))},e.updateSettings=function(t,n){var r=this;if(t&&t.enabled&&!this._isUpdatingSettings){t.isValid?((!n||n<0)&&(n=this.getVersion(t)),t.log.info("Checking for updated settings from: v"+n+"."),this._isUpdatingSettings=!0,t.submissionClient.getSettings(t,n,function(n){try{if(!(t&&n&&n.success&&n.settings))return void t.log.warn("Unable to update settings: "+n.message);t.settings=g.merge(t.settings,n.settings);var i=e.getSavedServerSettings(t);for(var o in i)n.settings[o]||delete t.settings[o];var s={version:n.settingsVersion,settings:n.settings};t.storage.settings.save(s),t.log.info("Updated settings: v"+s.version),r.changed(t)}finally{r._isUpdatingSettings=!1}})):t.log.error("Unable to update settings: ApiKey is not set.")}},e.changed=function(e){for(var t=0,n=this._handlers;t<n.length;t++){var r=n[t];try{r(e)}catch(t){e.log.error("Error calling onChanged handler: "+t)}}},e.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:{}}},e}();v._isUpdatingSettings=!1,v._handlers=[],t.SettingsManager=v;var m=function(){return 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=e>=200&&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}}();t.SubmissionResponse=m;var y=function(){function e(e,t){var n=this;this.config=new S("object"==typeof e?e:{apiKey:e,serverUrl:t}),this.updateSettingsTimer(5e3),this.config.onChanged(function(e){return n.updateSettingsTimer(n._timeoutId>0?5e3:0)}),this.config.queue.onEventsPosted(function(e,t){return n.updateSettingsTimer()})}return e.prototype.createException=function(e){var t=new b;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 x({date:new Date},this,e)},e.prototype.submitEvent=function(e,t,n){function r(e){return e&&(e.cancelled=!0),!!n&&n(e)}var i=new l(this,e,t);return e?this.config.enabled?(e.data||(e.data={}),e.tags&&e.tags.length||(e.tags=[]),void f.run(i,function(e){var t=e.client.config,r=e.event;e.cancelled||(r.type&&0!==r.type.length||(r.type="log"),r.date||(r.date=new Date),t.queue.enqueue(r),r.reference_id&&r.reference_id.length>0&&(e.log.info("Setting last reference id '"+r.reference_id+"'"),t.lastReferenceIdManager.setLast(r.reference_id))),!!n&&n(e)})):(this.config.log.info("Event submission is currently disabled."),r(i)):r(i)},e.prototype.updateUserEmailAndDescription=function(e,t,n,r){var i=this;if(!(e&&t&&n&&this.config.enabled))return!!r&&r(new m(500,"cancelled"));var o={email_address:t,description:n};this.config.submissionClient.postUserDescription(e,o,this.config,function(t){t.success||i.config.log.error("Failed to submit user email and description for event '"+e+"': "+t.statusCode+" "+t.message),!!r&&r(t)})},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(n>0){var r=function(){return v.updateSettings(t.config)};e>0&&(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}();y._instance=null,t.ExceptionlessClient=y;var b=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}();t.ContextData=b;var S=function(){function e(t){function n(e){return"function"==typeof e?e(this):e}this.defaultTags=[],this.defaultData={},this.enabled=!0,this.lastReferenceIdManager=new o,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=[],t=g.merge(e.defaults,t),this.log=n(t.log)||new a,this.apiKey=t.apiKey,this.serverUrl=t.serverUrl,this.configServerUrl=t.configServerUrl,this.heartbeatServerUrl=t.heartbeatServerUrl,this.updateSettingsWhenIdleInterval=t.updateSettingsWhenIdleInterval,this.includePrivateInformation=t.includePrivateInformation,this.environmentInfoCollector=n(t.environmentInfoCollector),this.errorParser=n(t.errorParser),this.lastReferenceIdManager=n(t.lastReferenceIdManager)||new o,this.moduleCollector=n(t.moduleCollector),this.requestInfoCollector=n(t.requestInfoCollector),this.submissionBatchSize=n(t.submissionBatchSize)||50,this.submissionAdapter=n(t.submissionAdapter),this.submissionClient=n(t.submissionClient)||new d,this.storage=n(t.storage)||new h,this.queue=n(t.queue)||new p(this),v.applySavedServerSettings(this),f.addDefaultPlugins(this)}return Object.defineProperty(e.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(e.prototype,"isValid",{get:function(){return!!this.apiKey&&this.apiKey.length>=10},enumerable:!0,configurable:!0}),Object.defineProperty(e.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(e.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(e.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(e.prototype,"updateSettingsWhenIdleInterval",{get:function(){return this._updateSettingsWhenIdleInterval},set:function(e){"number"==typeof e&&(e<=0?e=-1:e>0&&e<12e4&&(e=12e4),this._updateSettingsWhenIdleInterval=e,this.log.info("updateSettingsWhenIdleInterval: "+e),this.changed())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dataExclusions",{get:function(){var e=this.settings["@@DataExclusions"];return this._dataExclusions.concat(e&&e.split(",")||[])},enumerable:!0,configurable:!0}),e.prototype.addDataExclusions=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._dataExclusions=g.addRange.apply(g,[this._dataExclusions].concat(e))},Object.defineProperty(e.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(e.prototype,"includeUserName",{get:function(){return this._includeUserName},set:function(e){this._includeUserName=e||!1,this.changed()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"includeMachineName",{get:function(){return this._includeMachineName},set:function(e){this._includeMachineName=e||!1,this.changed()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"includeIpAddress",{get:function(){return this._includeIpAddress},set:function(e){this._includeIpAddress=e||!1,this.changed()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"includeCookies",{get:function(){return this._includeCookies},set:function(e){this._includeCookies=e||!1,this.changed()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"includePostData",{get:function(){return this._includePostData},set:function(e){this._includePostData=e||!1,this.changed()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"includeQueryString",{get:function(){return this._includeQueryString},set:function(e){this._includeQueryString=e||!1,this.changed()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"userAgentBotPatterns",{get:function(){var e=this.settings["@@UserAgentBotPatterns"];return this._userAgentBotPatterns.concat(e&&e.split(",")||[])},enumerable:!0,configurable:!0}),e.prototype.addUserAgentBotPatterns=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._userAgentBotPatterns=g.addRange.apply(g,[this._userAgentBotPatterns].concat(e))},Object.defineProperty(e.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}),e.prototype.addPlugin=function(e,t,n){var r=n?{name:e,priority:t,run:n}:e;if(r&&r.run){r.name||(r.name=g.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")},e.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")},e.prototype.setVersion=function(e){e&&(this.defaultData["@version"]=e)},e.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(e.prototype,"userAgent",{get:function(){return"exceptionless-js/1.6.0"},enumerable:!0,configurable:!0}),e.prototype.useSessions=function(e,t){void 0===e&&(e=!0),void 0===t&&(t=3e4),e&&this.addPlugin(new u(t))},e.prototype.useReferenceIds=function(){this.addPlugin(new c)},e.prototype.useLocalStorage=function(){},e.prototype.useDebugLogger=function(){this.log=new s},e.prototype.onChanged=function(e){!!e&&this._handlers.push(e)},e.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(e,"defaults",{get:function(){return null===e._defaultSettings&&(e._defaultSettings={includePrivateInformation:!0}),e._defaultSettings},enumerable:!0,configurable:!0}),e}();S._defaultSettings=null,t.Configuration=S;var _=function(){return 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}}();t.SettingsResponse=_;var x=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 b}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||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},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):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=g.addRange.apply(g,[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(g.stringify(t,this.client.config.dataExclusions.concat(r||[]),n));return g.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||e.length>100)return!1;for(var t=0;t<e.length;t++){var n=e.charCodeAt(t),r=n>=48&&n<=57,i=n>=65&&n<=90||n>=97&&n<=122,o=45===n;if(!r&&!i&&!o)return!1}return!0},e}();t.EventBuilder=x;var w=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(g.stringify(s[a],n.dataExclusions));g.isEmpty(u)||(e.event.data[a]=u)}t&&t()},e}();t.ConfigurationDefaultsPlugin=w;var E=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(;n._mergedEvents.length>0;)n._mergedEvents.shift().resubmit()},t)}return e.prototype.run=function(e,t){var n=this,r=function(e){for(var t=0;e;)e.message&&e.message.length&&(t+=397*t^g.getHashCode(e.message)),e.stack_trace&&e.stack_trace.length&&(t+=397*t^g.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 I(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});this._processedHashcodes.length>50;)this._processedHashcodes.shift()}t&&t()},e}();t.DuplicateCheckerPlugin=E;var I=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}(),P=function(){function e(){this.priority=80,this.name="EnvironmentInfoPlugin"}return e.prototype.run=function(e,t){var n=e.client.config.environmentInfoCollector;if(!e.event.data["@environment"]&&n){var r=n.getEnvironmentInfo(e);r&&(e.event.data["@environment"]=r)}t&&t()},e}();t.EnvironmentInfoPlugin=P;var T=function(){function e(){this.priority=30,this.name="ErrorPlugin"}return e.prototype.run=function(e,t){var n=["arguments","column","columnNumber","description","fileName","message","name","number","line","lineNumber","opera#sourceloc","sourceId","sourceURL","stack","stackArray","stacktrace"],r=e.contextData.getException();if(r&&(e.event.type="error",!e.event.data["@error"])){var i=e.client.config,o=i.errorParser;if(!o)throw new Error("No error parser was defined.");var s=o.parse(e,r);if(s){var a=JSON.parse(g.stringify(r,i.dataExclusions.concat(n)));g.isEmpty(a)||(s.data||(s.data={}),s.data["@ext"]=a),e.event.data["@error"]=s}}t&&t()},e}();t.ErrorPlugin=T;var C=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:g.toBoolean(s);for(var a in e)if(g.startsWith(a.toLowerCase(),o.toLowerCase())&&g.isMatch(n,[a.substring(o.length)]))return i?e[a]:g.toBoolean(e[a]);return r}var i=e.event,o=e.log,s=e.client.config.settings;if("log"===i.type){var a=function(e,t){return void 0===t&&(t="*"),n(r(e,"log",t,"Trace")+"")}(s,i.source),u=n(i.data["@level"]);u>=0&&(u>5||u<a)&&(o.info("Cancelling log event due to minimum log level."),e.cancelled=!0)}else if("error"===i.type)for(var c=i.data["@error"];!e.cancelled&&c;)!1===r(s,i.type,c.type,!0)&&(o.info("Cancelling error from excluded exception type: "+c.type),e.cancelled=!0),c=c.inner;else!1===r(s,i.type,i.source,!0)&&(o.info("Cancelling event from excluded type: "+i.type+" and source: "+i.source),e.cancelled=!0);t&&t()},e}();t.EventExclusionPlugin=C;var U=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&&r.length>0&&(e.event.data["@error"].modules=r)}t&&t()},e}();t.ModuleInfoPlugin=U;var k=function(){function e(){this.priority=70,this.name="RequestInfoPlugin"}return e.prototype.run=function(e,t){var n=e.client.config,r=n.requestInfoCollector;if(!e.event.data["@request"]&&r){var i=r.getRequestInfo(e);i&&(g.isMatch(i.user_agent,n.userAgentBotPatterns)?(e.log.info("Cancelling event as the request user agent matches a known bot pattern"),e.cancelled=!0):e.event.data["@request"]=i)}t&&t()},e}();t.RequestInfoPlugin=k;var q=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}();t.SubmissionMethodPlugin=q;var O=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}();t.InMemoryStorage=O;var R=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 t=this;return this.ensureIndex(),this.items.slice(0,e).map(function(e){var n=t.getKey(e);try{var i=t.read(n);return{timestamp:e,value:JSON.parse(i,r)}}catch(e){return t.safeDelete(n),null}}).filter(function(e){return null!=e})},e.prototype.remove=function(e){this.ensureIndex();var t=this.items,n=t.indexOf(e);if(n>=0){var r=this.getKey(e);this.safeDelete(r),t.splice(n,1)}},e.prototype.clear=function(){var e=this;this.items.forEach(function(t){return e.safeDelete(e.getKey(t))}),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 e=this;try{return this.readAllKeys().map(function(t){try{var n=e.getTimestamp(t);return n||(e.safeDelete(t),null)}catch(n){return e.safeDelete(t),null}}).filter(function(e){return null!=e}).sort(function(e,t){return e-t})}catch(e){return[]}},e}();t.KeyValueStorageBase=R;var M=function(e){function t(t,n,r){void 0===n&&(n="com.exceptionless."),void 0===r&&(r=20);var i=e.call(this,r)||this;return i.prefix=n+t+"-",i}return i(t,e),t.isAvailable=function(){try{var e=window.localStorage,t="__storage_test__";return e.setItem(t,t),e.removeItem(t),!0}catch(e){return!1}},t.prototype.write=function(e,t){window.localStorage.setItem(e,t)},t.prototype.read=function(e){return window.localStorage.getItem(e)},t.prototype.readAllKeys=function(){var e=this;return Object.keys(window.localStorage).filter(function(t){return 0===t.indexOf(e.prefix)})},t.prototype.delete=function(e){window.localStorage.removeItem(e)},t.prototype.getKey=function(e){return this.prefix+e},t.prototype.getTimestamp=function(e){return parseInt(e.substr(this.prefix.length),10)},t}(R);t.BrowserStorage=M;var A=function(){function e(){}return e.prototype.parse=function(e,t){function r(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 i=e.contextData["@@_TraceKit.StackTrace"]?e.contextData["@@_TraceKit.StackTrace"]:n.computeStackTrace(t,25);if(!i)throw new Error("Unable to parse the exceptions stack trace.");var o="string"==typeof t?t:void 0;return{type:i.name||"Error",message:i.message||t.message||o,stack_trace:function(e){for(var t=[],n=0,i=e;n<i.length;n++){var o=i[n];t.push({name:(o.func||"<anonymous>").replace("?","<anonymous>"),parameters:r(o.args),file_name:o.url,line_number:o.line||0,column:o.column||0})}return t}(i.stack||[])}},e}();t.DefaultErrorParser=A;var D=function(){function e(){}return e.prototype.getModules=function(e){if(!document||!document.getElementsByTagName)return null;var t=[],n=document.getElementsByTagName("script");if(n&&n.length>0)for(var r=0;r<n.length;r++)n[r].src?t.push({module_id:r,name:n[r].src.split("?")[0],version:g.parseVersion(n[r].src)}):n[r].innerHTML&&t.push({module_id:r,name:"Script Tag",version:g.getHashCode(n[r].innerHTML).toString()});return t},e}();t.DefaultModuleCollector=D;var N=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=g.getCookies(document.cookie,n)),t.includeQueryString&&(r.query_string=g.parseQueryString(location.search.substring(1),n)),document.referrer&&""!==document.referrer&&(r.referrer=document.referrer),r},e}();t.DefaultRequestInfoCollector=N;var j=function(){return function(e,t){void 0===t&&(t=250),this.queue=new M("q",e,t),this.settings=new M("settings",e,1)}}();t.BrowserStorageProvider=j;var K=function(){function e(){}return e.prototype.sendRequest=function(e,t,n){function r(n,r){if(!a){a=!0;var s=r.statusText,u=r.responseText,c=r.status;if(n===i||0===c)s="Unable to connect to server.",c=0;else if(n!==o||c){if(c<200||c>299){var l=r.responseBody;if(l&&l.message)s=l.message;else if(u&&-1!==u.indexOf("message"))try{s=JSON.parse(u).message}catch(e){s=u}}}else c="POST"===e.method?202:200;t&&t(c||500,s||"",u,function(e){for(var t={},n=0,r=(e||"").split("\r\n");n<r.length;n++){var i=r[n],o=i.indexOf(": ");o>0&&(t[i.substring(0,o).toLowerCase().replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")]=i.substring(o+2))}return t}(r.getAllResponseHeaders&&r.getAllResponseHeaders()))}}var i="timeout",o="loaded",s="withCredentials",a=!1,u=!1,c=e.url+(-1===e.url.indexOf("?")?"?":"&")+"access_token="+encodeURIComponent(e.apiKey),l=function(e,t,n){var r=new XMLHttpRequest;return s in r?(r.open(t,n,!0),r.setRequestHeader("X-Exceptionless-Client",e),"POST"===t&&r.setRequestHeader("Content-Type","application/json")):"undefined"!=typeof XDomainRequest?(u=!0,(r=new XDomainRequest).open(t,"http:"===location.protocol?n.replace("https:","http:"):n)):r=null,r&&(r.timeout=1e4),r}(e.userAgent,e.method||"POST",c);if(!l)return t&&t(503,"CORS not supported.");s in l&&(l.onreadystatechange=function(){4===l.readyState&&r(o,l)}),l.onprogress=function(){},l.ontimeout=function(){return r(i,l)},l.onerror=function(){return r("error",l)},l.onload=function(){return r(o,l)},u?setTimeout(function(){return l.send(e.data)},500):l.send(e.data)},e}();return t.DefaultSubmissionAdapter=K,function(){if("undefined"!=typeof document){S.prototype.useLocalStorage=function(){M.isAvailable()&&(this.storage=new j,v.applySavedServerSettings(this),this.changed())};var e=S.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&&e[t].src.indexOf("/exceptionless")>-1)return g.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 A,e.moduleCollector=new D,e.requestInfoCollector=new N,e.submissionAdapter=new K,n.report.subscribe(function(e,t){var n=y.default.createUnhandledException(new Error(e.message||(t||{}).status||"Script error"),"onerror");n.pluginContextData["@@_TraceKit.StackTrace"]=e,n.submit()}),n.extendToAsynchronousCallbacks(),Error.stackTraceLimit=1/0}}(),t});
//# sourceMappingURL=exceptionless.min.js.map