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
4 lines (3 loc) · 35.7 KB
/
exceptionless.min.js
File metadata and controls
4 lines (3 loc) · 35.7 KB
1
2
3
4
!function(e,t){function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function r(e){return"undefined"==typeof e}if(e){var i={},o=e.TraceKit,s=[].slice,u="?";i.noConflict=function(){return e.TraceKit=o,i},i.wrap=function(e){function t(){try{return e.apply(this,arguments)}catch(t){throw i.report(t),t}}return t},i.report=function(){function t(e){a(),p.push(e)}function r(e){for(var t=p.length-1;t>=0;--t)p[t]===e&&p.splice(t,1)}function o(e,t){var r=null;if(!t||i.collectWindowErrors){for(var o in p)if(n(p,o))try{p[o].apply(null,[e].concat(s.call(arguments,2)))}catch(u){r=u}if(r)throw r}}function u(e,t,n,r,s){var u=null;if(s)u=i.computeStackTrace(s);else if(h)i.computeStackTrace.augmentStackTraceWithInitialElement(h,t,n,e),u=h,h=null,g=null;else{var a={url:t,line:n,column:r};a.func=i.computeStackTrace.guessFunctionName(a.url,a.line),a.context=i.computeStackTrace.gatherContext(a.url,a.line),u={mode:"onerror",message:e,url:document.location.href,stack:[a],useragent:navigator.userAgent}}return o(u,"from window.onerror"),l?l.apply(this,arguments):!1}function a(){f!==!0&&(l=e.onerror,e.onerror=u,f=!0)}function c(t){var n=s.call(arguments,1);if(h){if(g===t)return;var r=h;h=null,g=null,o.apply(null,[r,null].concat(n))}var u=i.computeStackTrace(t);throw h=u,g=t,e.setTimeout(function(){g===t&&(h=null,g=null,o.apply(null,[u,null].concat(n)))},u.incomplete?2e3:0),t}var l,f,p=[],g=null,h=null;return c.subscribe=t,c.unsubscribe=r,c}(),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")}},r=n();return r.open("GET",t,!1),r.send(""),r.responseText}catch(o){return""}}function o(e){if("string"!=typeof e)return[];if(!n(w,e)){var r="";e=e||"",e.indexOf&&-1!==e.indexOf(document.domain)&&(r=t(e)),w[e]=r?r.split("\n"):[]}return w[e]}function s(e,t){var n,i=/function ([^(]*)\(([^)]*)\)/,s=/['"]?([0-9A-Za-z$_]+)['"]?\s*[:=]\s*(function|eval|new Function)/,a="",c=10,l=o(e);if(!l.length)return u;for(var f=0;c>f;++f)if(a=l[t-f]+a,!r(a)){if(n=s.exec(a))return n[1];if(n=i.exec(a))return n[1]}return u}function a(e,t){var n=o(e);if(!n.length)return null;var s=[],u=Math.floor(i.linesOfContext/2),a=u+i.linesOfContext%2,c=Math.max(0,t-u-1),l=Math.min(n.length,t+a-1);t-=1;for(var f=c;l>f;++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;s>i;++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 g(t){for(var n,r,i,o,s=[e.location.href],u=document.getElementsByTagName("script"),a=""+t,p=/^function(?:\s+([\w$]+))?\s*\(([\w\s,]*)\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,g=/^function on([\w$]+)\s*\(event\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,h=0;h<u.length;++h){var d=u[h];d.src&&s.push(d.src)}if(i=p.exec(a)){var m=i[1]?"\\s+"+i[1]:"",v=i[2].split(",").join("\\s*,\\s*");n=c(i[3]).replace(/;$/,";?"),r=new RegExp("function"+m+"\\s*\\(\\s*"+v+"\\s*\\)\\s*{\\s*"+n+"\\s*}")}else r=new RegExp(c(a).replace(/\s+/g,"\\s+"));if(o=f(r,s))return o;if(i=g.exec(a)){var y=i[1];if(n=l(i[2]),r=new RegExp("on"+y+"=[\\'\"]\\s*"+n+"\\s*[\\'\"]","i"),o=f(r,s[0]))return o;if(r=new RegExp(n),o=f(r,s))return o}return null}function h(e){if(!e.stack)return null;for(var t,n,i=/^\s*at (.*?) ?\(?((?:file|https?|chrome-extension):.*?):(\d+)(?::(\d+))?\)?\s*$/i,o=/^\s*(.*?)(?:\((.*?)\))?@?((?:file|https?|chrome):.*?):(\d+)(?::(\d+))?\s*$/i,c=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:ms-appx|http|https):.*?):(\d+)(?::(\d+))?\)?\s*$/i,l=e.stack.split("\n"),f=[],g=/^(.*) is undefined$/.exec(e.message),h=0,d=l.length;d>h;++h){if(t=o.exec(l[h]))n={url:t[3],func:t[1]||u,args:t[2]?t[2].split(","):"",line:+t[4],column:t[5]?+t[5]:null};else if(t=i.exec(l[h]))n={url:t[2],func:t[1]||u,line:+t[3],column:t[4]?+t[4]:null};else{if(!(t=c.exec(l[h])))continue;n={url:t[2],func:t[1]||u,line:+t[3],column:t[4]?+t[4]:null}}!n.func&&n.line&&(n.func=s(n.url,n.line)),n.line&&(n.context=a(n.url,n.line)),f.push(n)}return f.length?(f[0]&&f[0].line&&!f[0].column&&g?f[0].column=p(g[1],f[0].url,f[0].line):f[0].column||r(e.columnNumber)||(f[0].column=e.columnNumber+1),{mode:"stack",name:e.name,message:e.message,url:document.location.href,stack:f,useragent:navigator.userAgent}):null}function d(e){for(var t,n=e.stacktrace,r=/ line (\d+), column (\d+) in (?:<anonymous function: ([^>]+)>|([^\)]+))\((.*)\) in (.*):\s*$/i,i=n.split("\n"),o=[],u=0,c=i.length;c>u;u+=2)if(t=r.exec(i[u])){var l={line:+t[1],column:+t[2],func:t[3]||t[4],args:t[5]?t[5].split(","):[],url:t[6]};if(!l.func&&l.line&&(l.func=s(l.url,l.line)),l.line)try{l.context=a(l.url,l.line)}catch(f){}l.context||(l.context=[i[u+1]]),o.push(l)}return o.length?{mode:"stacktrace",name:e.name,message:e.message,url:document.location.href,stack:o,useragent:navigator.userAgent}:null}function m(t){var r=t.message.split("\n");if(r.length<4)return null;var i,u,c,p,g=/^\s*Line (\d+) of linked script ((?:file|https?)\S+)(?:: in function (\S+))?\s*$/i,h=/^\s*Line (\d+) of inline#(\d+) script in ((?:file|https?)\S+)(?:: in function (\S+))?\s*$/i,d=/^\s*Line (\d+) of function script\s*$/i,m=[],v=document.getElementsByTagName("script"),y=[];for(u in v)n(v,u)&&!v[u].src&&y.push(v[u]);for(u=2,c=r.length;c>u;u+=2){var b=null;if(i=g.exec(r[u]))b={url:i[2],func:i[3],line:+i[1]};else if(i=h.exec(r[u])){b={url:i[3],func:i[4]};var _=+i[1],x=y[i[2]-1];if(x&&(p=o(b.url))){p=p.join("\n");var w=p.indexOf(x.innerText);w>=0&&(b.line=_+p.substring(0,w).split("\n").length)}}else if(i=d.exec(r[u])){var E=e.location.href.replace(/#.*$/,""),S=i[1],T=new RegExp(l(r[u+1]));p=f(T,[E]),b={url:E,line:p?p.line:S,func:""}}if(b){b.func||(b.func=s(b.url,b.line));var I=a(b.url,b.line),P=I?I[Math.floor(I.length/2)]:null;b.context=I&&P.replace(/^\s*/,"")===r[u+1].replace(/^\s*/,"")?I:[r[u+1]],m.push(b)}}return m.length?{mode:"multiline",name:t.name,message:r[0],url:document.location.href,stack:m,useragent:navigator.userAgent}:null}function v(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=a(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,a=/function\s+([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)?\s*\(/i,c=[],l={},f=!1,h=y.caller;h&&!f;h=h.caller)if(h!==b&&h!==i.report){if(r={url:null,func:u,line:null,column:null},h.name?r.func=h.name:(n=a.exec(h.toString()))&&(r.func=n[1]),"undefined"==typeof r.func)try{r.func=n.input.substring(0,n.input.indexOf("{"))}catch(d){}if(o=g(h)){r.url=o.url,r.line=o.line,r.func===u&&(r.func=s(r.url,r.line));var m=/ '([^']+)' /.exec(e.message||e.description);m&&(r.column=p(m[1],o.url,o.line))}l[""+h]?f=!0:l[""+h]=!0,c.push(r)}t&&c.splice(0,t);var _={mode:"callers",name:e.name,message:e.message,url:document.location.href,stack:c,useragent:navigator.userAgent};return v(_,e.sourceURL||e.fileName,e.line||e.lineNumber,e.message||e.description),_}function b(e,t){var n=null;t=null==t?0:+t;try{if(n=d(e))return n}catch(r){if(x)throw r}try{if(n=h(e))return n}catch(r){if(x)throw r}try{if(n=m(e))return n}catch(r){if(x)throw r}try{if(n=y(e,t+1))return n}catch(r){if(x)throw r}return{mode:"failed"}}function _(e){e=(null==e?0:+e)+1;try{throw new Error}catch(t){return b(t,e+1)}}var x=!1,w={};return b.augmentStackTraceWithInitialElement=v,b.guessFunctionName=s,b.gatherContext=a,b.ofCaller=_,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),e.TraceKit=i}}("undefined"!=typeof window?window:global),function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t(require,exports,module):e.Exceptionless=t()}(this,function(e,t,n){if(!t)var t={};if(!e)var e=function(){};var r=this.__extends||function(e,t){function n(){this.constructor=e}for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);n.prototype=t.prototype,e.prototype=new n},i=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.hasException?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&&e.length>0&&(this["@@_SubmissionMethod"]=e)},e.prototype.getSubmissionMethod=function(){return this["@@_SubmissionMethod"]?this["@@_SubmissionMethod"]:null},e}();t.ContextData=i;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.InMemoryLastReferenceIdManager=o;var s=function(){function e(){}return 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){console&&console[e]&&console[e]("["+e+"] Exceptionless: "+t)},e}();t.ConsoleLog=s;var u=function(){function e(){}return e.prototype.info=function(e){},e.prototype.warn=function(e){},e.prototype.error=function(e){},e}();t.NullLog=u;var a=function(){function e(e,t,n){this.client=e,this.event=t,this.contextData=n?n:new i}return Object.defineProperty(e.prototype,"log",{get:function(){return this.client.config.log},enumerable:!0,configurable:!0}),e}();t.EventPluginContext=a;var c=function(){function e(){}return e.run=function(e,t){var n=function(n,r){return function(){try{e.cancelled||n.run(e,r)}catch(i){e.cancelled=!0,e.log.error("Error running plugin '"+n.name+"': "+i.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 v),e.addPlugin(new y),e.addPlugin(new b),e.addPlugin(new _),e.addPlugin(new x),e.addPlugin(new w),e.addPlugin(new E)},e}();t.EventPluginManager=c;var l=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=l;var f=function(){function e(e){this._processingQueue=!1,this._config=e}return e.prototype.enqueue=function(e){if(this.ensureQueueTimer(),this.areQueuedItemsDiscarded())return void this._config.log.info("Queue items are currently being discarded. The event will not be queued.");var t=this.queuePath()+"-"+(new Date).toJSON()+"-"+g.randomNumber();this._config.log.info("Enqueuing event: "+t+" type="+e.type+" "+(e.reference_id?"refid="+e.reference_id:"")),this._config.storage.save(t,e)},e.prototype.process=function(){var e=this;if(this.ensureQueueTimer(),!this._processingQueue){var t="The queue will not be processed.";if(this._config.log.info("Processing queue..."),!this._config.enabled)return void this._config.log.info("Configuration is disabled. "+t);if(!this._config.apiKey||this._config.apiKey.length<10)return void this._config.log.info("Invalid Api Key. "+t);this._processingQueue=!0;try{var n=this._config.storage.get(this.queuePath(),this._config.submissionBatchSize);if(!n||0==n.length)return void(this._processingQueue=!1);this._config.log.info("Sending "+n.length+" events to "+this._config.serverUrl+"."),this._config.submissionClient.submit(n,this._config,function(t){e.processSubmissionResponse(t,n),e._config.log.info("Finished processing queue."),e._processingQueue=!1})}catch(r){this._config.log.error("Error processing queue: "+r),this.suspendProcessing(),this._processingQueue=!1}}},e.prototype.processSubmissionResponse=function(e,t){var n="The event will not be submitted.";if(e.success)return void this._config.log.info("Sent "+t.length+" events.");if(e.serviceUnavailable)return this._config.log.error("Server returned service unavailable."),this.suspendProcessing(),void this.requeueEvents(t);if(e.paymentRequired)return this._config.log.info("Too many events have been submitted, please upgrade your plan."),void this.suspendProcessing(null,!0,!0);if(e.unableToAuthenticate)return this._config.log.info("Unable to authenticate, please check your configuration. "+n),void this.suspendProcessing(15);if(e.notFound||e.badRequest)return this._config.log.error("Error while trying to submit data: "+e.message),void this.suspendProcessing(240);if(e.requestEntityTooLarge){var r="Event submission discarded for being too large.";return void(this._config.submissionBatchSize>1?(this._config.log.error(r+" Retrying with smaller batch size."),this._config.submissionBatchSize=Math.max(1,Math.round(this._config.submissionBatchSize/1.5)),this.requeueEvents(t)):this._config.log.error(r+" "+n))}e.success||(this._config.log.error("Error submitting events: "+e.message),this.suspendProcessing(),this.requeueEvents(t))},e.prototype.ensureQueueTimer=function(){var e=this;this._queueTimer||(this._queueTimer=setInterval(function(){return e.onProcessQueue()},1e4))},e.prototype.onProcessQueue=function(){this.isQueueProcessingSuspended()||this._processingQueue||this.process()},e.prototype.suspendProcessing=function(e,t,n){if((!e||0>=e)&&(e=5),this._config.log.info("Suspending processing for "+e+" minutes."),this._suspendProcessingUntil=new Date((new Date).getTime()+6e4*e),t&&(this._discardQueuedItemsUntil=new Date((new Date).getTime()+6e4*e)),n)try{this._config.storage.clear(this.queuePath())}catch(r){}},e.prototype.requeueEvents=function(e){this._config.log.info("Requeuing "+e.length+" events.");for(var t=0;t<e.length;t++)this.enqueue(e[t])},e.prototype.isQueueProcessingSuspended=function(){return this._suspendProcessingUntil&&this._suspendProcessingUntil>new Date},e.prototype.areQueuedItemsDiscarded=function(){return this._discardQueuedItemsUntil&&this._discardQueuedItemsUntil>new Date},e.prototype.queuePath=function(){return"ex-q"},e}();t.DefaultEventQueue=f;var p=function(){function e(){this._items={}}return e.prototype.save=function(e,t){return this._items[e]=t,!0},e.prototype.get=function(e,t){var n=[],r=new RegExp(e||".*");for(var i in this._items){if(n.length>=t)break;r.test(i)&&(n.push(this._items[i]),delete this._items[i])}return n},e.prototype.clear=function(e){if(!e)return void(this._items={});var t=new RegExp(e);for(var n in this._items)t.test(n)&&delete this._items[n]},e.prototype.count=function(e){var t=new RegExp(e||".*"),n=[];for(var r in this._items)t.test(r)&&n.push(r);return n.length},e}();t.InMemoryStorage=p;var g=function(){function e(){}return e.getHashCode=function(e){if(!e||0===e.length)return null;for(var t=0,n=0;n<e.length;n++){var r=e.charCodeAt(n);t=(t<<5)-t+r,t|=0}return t.toString()},e.getCookies=function(e){for(var t={},n=(e||"").split("; "),r=0;r<n.length;r++){var i=n[r].split("=");t[i[0]]=i[1]}return t},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||{})e[r]&&(n[r]=e[r]);for(var r in t||{})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\-]+)*))?)/,n=t.exec(e);return n&&n.length>0?n[0]:null},e.parseQueryString=function(e){if(!e||0===e.length)return null;var t=e.split("&");if(0===t.length)return null;for(var n={},r=0;r<t.length;r++){var i=t[r].split("=");n[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return n},e.randomNumber=function(){return Math.floor(9007199254740992*Math.random())},e.stringify=function(e){function t(e){var t=[];return JSON.stringify(e,function(e,n){if("object"==typeof n&&n){if(-1!==t.indexOf(n))return;t.push(n)}return n})}if("[object Array]"===toString.call(e)){for(var n=[],r=0;r<e.length;r++)n[r]=JSON.parse(t(e[r]));return JSON.stringify(n)}return t(e)},e}();t.Utils=g;var h=function(){function e(t){function n(e){return"function"==typeof e?e(this):e}this._enabled=!0,this._serverUrl="https://collector.exceptionless.io",this._plugins=[],this.lastReferenceIdManager=new o,this.defaultTags=[],this.defaultData={},t=g.merge(e.defaults,t),this.log=n(t.log)||new u,this.apiKey=t.apiKey,this.serverUrl=t.serverUrl,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.submissionClient=n(t.submissionClient),this.storage=n(t.storage)||new p,this.queue=n(t.queue)||new f(this),c.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)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"serverUrl",{get:function(){return this._serverUrl},set:function(e){e&&e.length>0&&(this._serverUrl=e,this.log.info("serverUrl: "+this._serverUrl))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},enumerable:!0,configurable:!0}),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)return void this.log.error("Add plugin failed: No run method was defined.");r.name||(r.name=g.guid()),r.priority||(r.priority=0);for(var i=!1,o=0;o<this._plugins.length;o++)if(this._plugins[o].name===r.name){i=!0;break}i||this._plugins.push(r)},e.prototype.removePlugin=function(e){var t="string"==typeof e?e:e.name;if(!t)return void this.log.error("Remove plugin failed: No plugin name was defined.");for(var n=0;n<this._plugins.length;n++)if(this._plugins[n].name===t){this._plugins.splice(n,1);break}},e.prototype.setVersion=function(e){e&&e.length>0&&(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))},e.prototype.useReferenceIds=function(){this.addPlugin(new l)},e.prototype.useDebugLogger=function(){this.log=new s},Object.defineProperty(e,"defaults",{get:function(){return null===e._defaultSettings&&(e._defaultSettings={}),e._defaultSettings},enumerable:!0,configurable:!0}),e._defaultSettings=null,e}();t.Configuration=h;var d=function(){function e(e,t,n){this.target=e,this.client=t,this.pluginContextData=n||new i}return e.prototype.setType=function(e){return e&&e.length>0&&(this.target.type=e),this},e.prototype.setSource=function(e){return e&&e.length>0&&(this.target.source=e),this},e.prototype.setSessionId=function(e){if(!this.isValidIdentifier(e))throw new Error("SessionId must contain between 8 and 100 alphanumeric or '-' characters.");return this.target.session_id=e,this},e.prototype.setReferenceId=function(e){if(!this.isValidIdentifier(e))throw new Error("SessionId must contain between 8 and 100 alphanumeric or '-' characters.");return this.target.reference_id=e,this},e.prototype.setMessage=function(e){return e&&e.length>0&&(this.target.message=e),this},e.prototype.setGeo=function(e,t){if(-90>e||e>90)throw new Error("Must be a valid latitude value between -90.0 and 90.0.");if(-180>t||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.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-0]=arguments[t];if(!e||0===e.length)return this;this.target.tags||(this.target.tags=[]);for(var n=0;n<e.length;n++)e[n]&&this.target.tags.indexOf(e[n])<0&&this.target.tags.push(e[n]);return this},e.prototype.setProperty=function(e,t){return e&&void 0!==t&&null!=t?(this.target.data||(this.target.data={}),this.target.data[e]=t,this):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||!e.length)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&&57>=n,i=n>=65&&90>=n||n>=97&&122>=n,o=45===n;if(!r&&!i&&!o)return!1}return!0},e}();t.EventBuilder=d;var m=function(){function e(e,t){this.config=new h("object"!=typeof e?e:{apiKey:e,serverUrl:t})}return e.prototype.createException=function(e){var t=new i;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(e&&t&&n)r=r.setSource(e).setMessage(t).setProperty("@level",n);else if(e&&t)r=r.setSource(e).setMessage(t);else{var i=arguments.callee.caller.name;r=r.setSource(i).setMessage(e)}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(e){return this.createEvent().setType("start").setSessionId(e)},e.prototype.submitSessionStart=function(e,t){this.createSessionStart(e).submit(t)},e.prototype.createSessionEnd=function(e){return this.createEvent().setType("end").setSessionId(e)},e.prototype.submitSessionEnd=function(e,t){this.createSessionEnd(e).submit(t)},e.prototype.createEvent=function(e){return new d({date:new Date},this,e)},e.prototype.submitEvent=function(e,t,n){if(e){if(!this.config.enabled)return this.config.log.info("Event submission is currently disabled.");e.data||(e.data={}),e.tags&&e.tags.length||(e.tags=[]);var r=new a(this,e,t);c.run(r,function(e){var t=e.event;if(!e.cancelled){t.type&&0!==t.type.length||(t.type="log"),t.date||(t.date=new Date);var r=e.client.config;r.queue.enqueue(t),t.reference_id&&t.reference_id.length>0&&(e.log.info("Setting last reference id '"+t.reference_id+"'"),r.lastReferenceIdManager.setLast(t.reference_id))}n&&n(e)})}},e.prototype.getLastReferenceId=function(){return this.config.lastReferenceIdManager.getLast()},Object.defineProperty(e,"default",{get:function(){return null===e._instance&&(e._instance=new e(null)),e._instance},enumerable:!0,configurable:!0}),e._instance=null,e}();t.ExceptionlessClient=m;var v=function(){function e(){this.priority=10,this.name="ConfigurationDefaultsPlugin"}return e.prototype.run=function(e,t){for(var n=e.client.config.defaultTags||[],r=0;r<n.length;r++){var i=n[r];i&&e.event.tags.indexOf(i)<0&&e.event.tags.push(i)}var o=e.client.config.defaultData||{};for(var s in o)o[s]&&(e.event.data[s]=o[s]);t&&t()},e}();t.ConfigurationDefaultsPlugin=v;var y=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.errorParser;if(!r)throw new Error("No error parser was defined.");r.parse(e,n)}t&&t()},e}();t.ErrorPlugin=y;var b=function(){function e(){this.priority=50,this.name="DuplicateCheckerPlugin"}return e.prototype.run=function(e,t){t&&t()},e}();t.DuplicateCheckerPlugin=b;var _=function(){function e(){this.priority=40,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=_;var x=function(){function e(){this.priority=60,this.name="RequestInfoPlugin"}return e.prototype.run=function(e,t){var n=e.client.config.requestInfoCollector;if(!e.event.data["@request"]&&n){var r=n.getRequestInfo(e);r&&(e.event.data["@request"]=r)}t&&t()},e}();t.RequestInfoPlugin=x;var w=function(){function e(){this.priority=70,this.name="EnvironmentInfoPlugin"}return e.prototype.run=function(e,t){if(!e.event.data["@environment"]&&e.client.config.environmentInfoCollector){var n=e.client.config.environmentInfoCollector.getEnvironmentInfo(e);n&&(e.event.data["@environment"]=n)}t&&t()},e}();t.EnvironmentInfoPlugin=w;var E=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=E;var S=function(){function e(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}return e}();t.SettingsResponse=S;var T=function(){function e(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&&299>=e,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}return e}();t.SubmissionResponse=T;var I=e("os"),P=function(){function e(){}return e.prototype.getEnvironmentInfo=function(e){if(!I)return null;var t={processor_count:I.cpus().length,total_physical_memory:I.totalmem(),available_physical_memory:I.freemem(),command_line:process.argv.join(" "),process_name:process.title,process_id:process.pid+"",process_memory_size:process.memoryUsage().heapTotal,architecture:I.arch(),o_s_name:I.type(),o_s_version:I.release(),ip_address:this.getIpAddresses(),machine_name:I.hostname(),runtime_version:process.version,data:{loadavg:I.loadavg(),platform:I.platform(),tmpdir:I.tmpdir(),uptime:I.uptime()}};return I.endianness&&(t.data.endianness=I.endianness()),t},e.prototype.getIpAddresses=function(){var e=[],t=I.networkInterfaces();return Object.keys(t).forEach(function(n){t[n].forEach(function(t){"IPv4"!==t.family||t.internal||e.push(t.address)})}),e.join(", ")},e}();t.NodeEnvironmentInfoCollector=P;var C=e("stack-trace"),q=function(){function e(){}return e.prototype.parse=function(e,t){if(!C)throw new Error("Unable to load the stack trace library.");var n=C.parse(t)||[],r={type:t.name,message:t.message,stack_trace:this.getStackFrames(e,n)};e.event.data["@error"]=r},e.prototype.getStackFrames=function(e,t){for(var n=[],r=0;r<t.length;r++){var i=t[r];n.push({name:i.getMethodName()||i.getFunctionName(),file_name:i.getFileName(),line_number:i.getLineNumber(),column:i.getColumnNumber(),declaring_type:i.getTypeName(),data:{is_native:i.isNative()||!!i.filename&&"/"!==i.filename[0]&&"."!==i.filename[0]}})}return n},e}();t.NodeErrorParser=q;var R=function(){function e(){}return e.prototype.getRequestInfo=function(e){if(!e.contextData["@request"])return null;var t=e.contextData["@request"],n={client_ip_address:t.ip,user_agent:t.headers["user-agent"],is_secure:t.secure,http_method:t.method,host:t.hostname||t.host,path:t.path,post_data:t.body,cookies:g.getCookies((t||{}).headers.cookie),query_string:t.params},r=t.headers.host,i=r&&parseInt(r.slice(r.indexOf(":")+1));return i>0&&(n.port=i),n},e}();t.NodeRequestInfoCollector=R;var k=function(){function e(){}return e.prototype.submit=function(e,t,n){return this.sendRequest("POST",t.serverUrl,"/api/v2/events",t.apiKey,g.stringify(e),function(e,t,r){n(new T(e,t))})},e.prototype.submitDescription=function(e,t,n,r){var i="/api/v2/events/by-ref/"+encodeURIComponent(e)+"/user-description";return this.sendRequest("POST",n.serverUrl,i,n.apiKey,g.stringify(t),function(e,t,n){r(new T(e,t))})},e.prototype.getSettings=function(e,t){return this.sendRequest("GET",e.serverUrl,"/api/v2/projects/config",e.apiKey,null,function(n,r,i){if(200!==n)return t(new S(!1,null,-1,null,r));var o;try{o=JSON.parse(i)}catch(s){e.log.error("Unable to parse settings: '"+i+"'")}return o&&o.settings&&o.version?void t(new S(!0,o.settings,o.version)):t(new S(!1,null,-1,null,"Invalid configuration settings."))})},e.prototype.sendRequest=function(e,t,n,r,i,o){o(500,"Not Implemented")},e}();t.SubmissionClientBase=k;var U=e("https"),M=e("url"),D=function(e){function t(){e.apply(this,arguments)}return r(t,e),t.prototype.sendRequest=function(e,t,n,r,i,o){function s(e,t){var n;0===e.statusCode?n="Unable to connect to server.":(e.statusCode<200||e.statusCode>299)&&(n=e.statusMessage||e.message),o(e.statusCode||500,n,t)}var u=M.parse(t),a={auth:"client:"+r,hostname:u.hostname,method:e,port:u.port&&parseInt(u.port),path:n};"POST"===e&&(a.headers={"Content-Type":"application/json","Content-Length":i.length});var c=U.request(a,function(e){var t="";e.on("data",function(e){return t+=e}),e.on("end",function(){s(e,t)})});c.on("error",function(e){o(500,e.message)}),c.write(i),c.end()},t}(k);t.NodeSubmissionClient=D;var N=function(){function e(){}return e.prototype.register=function(){var e=this;if("undefined"==typeof window&&"undefined"!=typeof global&&"[object global]"==={}.toString.call(global)){var t=h.defaults;t.environmentInfoCollector=new P,t.errorParser=new q,t.requestInfoCollector=new R,t.submissionClient=new D,process.on("uncaughtException",function(e){m["default"].submitUnhandledException(e,"uncaughtException")}),process.on("beforeExit",function(t){var n=m["default"],r=e.getExitCodeReason(t);null!==r&&n.submitLog("beforeExit",r,"Error"),n.config.queue.process()})}},e.prototype.getExitCodeReason=function(e){return 1===e?"Uncaught Fatal Exception":3===e?"Internal JavaScript Parse Error":4===e?"Internal JavaScript Evaluation Failure":5===e?"Fatal Exception":6===e?"Non-function Internal Exception Handler ":7===e?"Internal Exception Handler Run-Time Failure":8===e?"Uncaught Exception":9===e?"Invalid Argument":10===e?"Internal JavaScript Run-Time Failure":12===e?"Invalid Debug Argument":e>128?"Signal Exits":null;
},e}();t.NodeBootstrapper=N;var O=function(){function e(){}return e.prototype.parse=function(e,t){var n=e.contextData["@@_TraceKit.StackTrace"]?e.contextData["@@_TraceKit.StackTrace"]:TraceKit.computeStackTrace(t,25);if(!n)throw new Error("Unable to parse the exceptions stack trace.");var r={type:n.name,message:n.message||t.message,stack_trace:this.getStackFrames(e,n.stack||[])};e.event.data["@error"]=r},e.prototype.getStackFrames=function(e,t){for(var n=[],r=0;r<t.length;r++){var i=t[r];n.push({name:i.func,parameters:this.getParameters(i.args),file_name:i.url,line_number:i.line,column:i.column})}return n},e.prototype.getParameters=function(e){for(var t=("string"==typeof e?[e]:e)||[],n=[],r=0;r<t.length;r++)n.push({name:t[r]});return n},e}();t.WebErrorParser=O;var F=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,version:g.parseVersion(n[r].src)}):n[r].innerHTML&&t.push({module_id:r,name:"Script Tag",version:g.getHashCode(n[r].innerHTML)});return t},e}();t.WebModuleCollector=F;var A=function(){function e(){}return e.prototype.getRequestInfo=function(e){if(!document||!navigator||!location)return null;var t={user_agent:navigator.userAgent,is_secure:"https:"===location.protocol,host:location.hostname,port:location.port&&""!==location.port?parseInt(location.port):80,path:location.pathname,cookies:g.getCookies(document.cookie),query_string:g.parseQueryString(location.search.substring(1))};return document.referrer&&""!==document.referrer&&(t.referrer=document.referrer),t},e}();t.WebRequestInfoCollector=A;var j=function(e){function t(){e.apply(this,arguments)}return r(t,e),t.prototype.createRequest=function(e,t){var n=new XMLHttpRequest;return"withCredentials"in n?n.open(e,t,!0):"undefined"!=typeof XDomainRequest?(n=new XDomainRequest,n.open(e,t)):n=null,n&&("POST"===e&&n.setRequestHeader&&n.setRequestHeader("Content-Type","application/json"),n.timeout=1e4),n},t.prototype.sendRequest=function(e,t,n,r,i,o){function s(e){if(!u){u=!0;var t;if(0===e.status)t="Unable to connect to server.";else if(e.status<200||e.status>299)if(e.responseBody&&e.responseBody.message)t=e.responseBody.message;else if(e.responseText&&-1!==e.responseText.indexOf("message"))try{t=JSON.parse(e.responseText).message}catch(n){t=e.responseText}else t=e.statusText;o(e.status||500,t,e.responseText)}}var u=!1,a=""+t+n+"?access_token="+encodeURIComponent(r),c=this.createRequest(e||"POST",a);return c?("withCredentials"in c&&(c.onreadystatechange=function(){4===c.readyState&&s(c)}),c.ontimeout=function(){return s(c)},c.onerror=function(){return s(c)},c.onload=function(){return s(c)},void c.send(i)):o(503,"CORS not supported.")},t}(k);t.DefaultSubmissionClient=j;var L=function(){function e(){}return e.prototype.register=function(){if("undefined"!=typeof window&&"undefined"!=typeof document){var e=h.defaults,t=this.getDefaultsSettingsFromScriptTag();t&&(t.apiKey||t.serverUrl)&&(e.apiKey=t.apiKey,e.serverUrl=t.serverUrl),e.errorParser=new O,e.moduleCollector=new F,e.requestInfoCollector=new A,e.submissionClient=new j,TraceKit.report.subscribe(this.processUnhandledException),TraceKit.extendToAsynchronousCallbacks(),"undefined"!=typeof $&&$(document)&&$(document).ajaxError(this.processJQueryAjaxError)}},e.prototype.getDefaultsSettingsFromScriptTag=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},e.prototype.processUnhandledException=function(e,t){var n=m["default"].createUnhandledException(new Error(e.message||(t||{}).status||"Script error"),"onerror");n.pluginContextData["@@_TraceKit.StackTrace"]=e,n.submit()},e.prototype.processJQueryAjaxError=function(e,t,n,r){var i=m["default"];404===t.status?i.submitNotFound(n.url):401!==t.status&&i.createUnhandledException(r,"JQuery.ajaxError").setSource(n.url).setProperty("status",t.status).setProperty("request",n.data).setProperty("response",t.responseText&&t.responseText.slice?t.responseText.slice(0,1024):void 0).submit()},e}();return t.WindowBootstrapper=L,(new N).register(),(new L).register(),Error.stackTraceLimit=1/0,t});
//# sourceMappingURL=exceptionless.min.js.map