-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathexceptionless.min.js
3 lines (3 loc) · 34.5 KB
/
exceptionless.min.js
1
2
3
!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(d)i.computeStackTrace.augmentStackTraceWithInitialElement(d,t,n,e),u=d,d=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,stack:[a]}}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(d){if(g===t)return;var r=d;d=null,g=null,o.apply(null,[r,null].concat(n))}var u=i.computeStackTrace(t);throw d=u,g=t,e.setTimeout(function(){g===t&&(d=null,g=null,o.apply(null,[u,null].concat(n)))},u.incomplete?2e3:0),t}var l,f,p=[],g=null,d=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(E,e)){var r="",i="";try{i=document.domain}catch(o){}-1!==e.indexOf(i)&&(r=t(e)),E[e]=r?r.split("\n"):[]}return E[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*$/,d=0;d<u.length;++d){var h=u[d];h.src&&s.push(h.src)}if(i=p.exec(a)){var v=i[1]?"\\s+"+i[1]:"",m=i[2].split(",").join("\\s*,\\s*");n=c(i[3]).replace(/;$/,";?"),r=new RegExp("function"+v+"\\s*\\(\\s*"+m+"\\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 d(e){if(!e.stack)return null;for(var t,n,i=/^\s*at (.*?) ?\(((?:file|https?|chrome-extension|native|eval).*?)(?::(\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),d=0,h=l.length;h>d;++d){if(t=i.exec(l[d])){var v=t[2]&&-1!==t[2].indexOf("native");n={url:v?null:t[2],func:t[1]||u,args:v?[t[2]]:[],line:t[3]?+t[3]:null,column:t[4]?+t[4]:null}}else if(t=c.exec(l[d]))n={url:t[2],func:t[1]||u,args:[],line:+t[3],column:t[4]?+t[4]:null};else{if(!(t=o.exec(l[d])))continue;n={url:t[3],func:t[1]||u,args:t[2]?t[2].split(","):[],line:t[4]?+t[4]:null,column:t[5]?+t[5]: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,stack:f}):null}function h(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"),u=[],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=a(l.url,l.line)}catch(f){}l.context||(l.context=[o[c+1]]),u.push(l)}}return u.length?{mode:"stacktrace",name:e.name,message:e.message,stack:u}:null}}function v(t){var r=t.message.split("\n");if(r.length<4)return null;var i,u=/^\s*Line (\d+) of linked script ((?:file|https?)\S+)(?:: in function (\S+))?\s*$/i,c=/^\s*Line (\d+) of inline#(\d+) script in ((?:file|https?)\S+)(?:: in function (\S+))?\s*$/i,p=/^\s*Line (\d+) of function script\s*$/i,g=[],d=document.getElementsByTagName("script"),h=[];for(var v in d)n(d,v)&&!d[v].src&&h.push(d[v]);for(var m=2;m<r.length;m+=2){var y=null;if(i=u.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],x=h[i[2]-1];if(x){var S=o(y.url);if(S){S=S.join("\n");var E=S.indexOf(x.innerText);E>=0&&(y.line=b+S.substring(0,E).split("\n").length)}}}else if(i=p.exec(r[m])){var w=e.location.href.replace(/#.*$/,""),_=new RegExp(l(r[m+1])),T=f(_,[w]);y={url:w,func:"",args:[],line:T?T.line:i[1],column:null}}if(y){y.func||(y.func=s(y.url,y.line));var P=a(y.url,y.line),I=P?P[Math.floor(P.length/2)]:null;y.context=P&&I.replace(/^\s*/,"")===r[m+1].replace(/^\s*/,"")?P:[r[m+1]],g.push(y)}}return g.length?{mode:"multiline",name:t.name,message:r[0],stack:g}: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=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,d=y.caller;d&&!f;d=d.caller)if(d!==b&&d!==i.report){if(r={url:null,func:u,args:[],line:null,column:null},d.name?r.func=d.name:(n=a.exec(d.toString()))&&(r.func=n[1]),"undefined"==typeof r.func)try{r.func=n.input.substring(0,n.input.indexOf("{"))}catch(h){}if(o=g(d)){r.url=o.url,r.line=o.line,r.func===u&&(r.func=s(r.url,r.line));var v=/ '([^']+)' /.exec(e.message||e.description);v&&(r.column=p(v[1],o.url,o.line))}l[""+d]?f=!0:l[""+d]=!0,c.push(r)}t&&c.splice(0,t);var x={mode:"callers",name:e.name,message:e.message,stack:c};return m(x,e.sourceURL||e.fileName,e.line||e.lineNumber,e.message||e.description),x}function b(e,t){var n=null;t=null==t?0:+t;try{if(n=h(e))return n}catch(r){if(S)throw r}try{if(n=d(e))return n}catch(r){if(S)throw r}try{if(n=v(e))return n}catch(r){if(S)throw r}try{if(n=y(e,t+1))return n}catch(r){if(S)throw r}return{mode:"failed"}}function x(e){e=(null==e?0:+e)+1;try{throw new Error}catch(t){return b(t,e+1)}}var S=!1,E={};return b.augmentStackTraceWithInitialElement=m,b.guessFunctionName=s,b.gatherContext=a,b.ofCaller=x,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),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){function r(){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 v.parseQueryString(e[t].src.split("?").pop());return null}function i(e,t){var n=S["default"].createUnhandledException(new Error(e.message||(t||{}).status||"Script error"),"onerror");n.pluginContextData["@@_TraceKit.StackTrace"]=e,n.submit()}function o(e,t,n,r){var i=S["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)).submit()}if(!t)var t={};var s=function(){function e(){}return e.changed=function(e){for(var t=this._handlers,n=0;n<t.length;n++)t[n](e)},e.onChanged=function(e){!!e&&this._handlers.push(e)},e.applySavedServerSettings=function(e){e.log.info("Applying saved settings."),e.settings=v.merge(e.settings,this.getSavedServerSettings(e)),this.changed(e)},e.getSavedServerSettings=function(e){return e.storage.get(this._configPath)||{}},e.checkVersion=function(e,t){if(e){var n=parseInt(t.storage.get(this._configPath+"-version"));(isNaN(n)||e>n)&&(t.log.info("Updating settings from v"+(isNaN(n)?0:n)+" to v"+e),this.updateSettings(t))}},e.updateSettings=function(t){var n=this;return t.isValid?void t.submissionClient.getSettings(t,function(r){if(r&&r.success&&r.settings){t.settings=v.merge(t.settings,r.settings);var i=e.getSavedServerSettings(t);for(var o in i)r.settings[o]||delete t.settings[o];var s=e._configPath;t.storage.save(s+"-version",r.settingsVersion),t.storage.save(s,r.settings),t.log.info("Updated settings"),n.changed(t)}}):void t.log.error("Unable to update settings: ApiKey is not set.")},e._configPath="ex-server-settings.json",e._handlers=[],e}();t.SettingsManager=s;var u=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=u;var a=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=a;var c=function(){function e(){}return e.prototype.info=function(e){},e.prototype.warn=function(e){},e.prototype.error=function(e){},e}();t.NullLog=c;var l=function(){function e(e,t,n){this.client=e,this.event=t,this.contextData=n?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(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 E),e.addPlugin(new w),e.addPlugin(new _),e.addPlugin(new T),e.addPlugin(new P),e.addPlugin(new I)},e}();t.EventPluginManager=f;var p=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=v.guid().replace("-","").substring(0,10)),t&&t()},e}();t.ReferenceIdPlugin=p;var g=function(){function e(e){this._processingQueue=!1,this._config=e}return e.prototype.enqueue=function(e){var t=this._config;if(this.ensureQueueTimer(),this.areQueuedItemsDiscarded())return void t.log.info("Queue items are currently being discarded. The event will not be queued.");var n="ex-q-"+(new Date).toJSON()+"-"+v.randomNumber();t.log.info("Enqueuing event: "+n+" type="+e.type+" "+(e.reference_id?"refid="+e.reference_id:"")),t.storage.save(n,e)},e.prototype.process=function(e){function t(e){for(var t=[],n=0;n<e.length;n++)t.push(e[n].value);return t}var n=this,r="The queue will not be processed.",i=this._config,o=i.log;if(this.ensureQueueTimer(),!this._processingQueue){if(o.info("Processing queue..."),!i.enabled)return void o.info("Configuration is disabled. "+r);if(!i.isValid)return void o.info("Invalid Api Key. "+r);this._processingQueue=!0;try{var s=i.storage.getList("ex-q",i.submissionBatchSize);if(!s||0==s.length)return void(this._processingQueue=!1);o.info("Sending "+s.length+" events to "+i.serverUrl+"."),i.submissionClient.postEvents(t(s),i,function(e){n.processSubmissionResponse(e,s),o.info("Finished processing queue."),n._processingQueue=!1},e)}catch(u){o.error("Error processing queue: "+u),this.suspendProcessing(),this._processingQueue=!1}}},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.";return void(r.submissionBatchSize>1?(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)))}e.success||(i.error("Error submitting events: "+(e.message||"Please check the network tab for more info.")),this.suspendProcessing())},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){var r=this._config;(!e||0>=e)&&(e=5),r.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&&this.removeEvents(r.storage.getList("ex-q"))},e.prototype.removeEvents=function(e){for(var t=0;t<(e||[]).length;t++)this._config.storage.remove(e[t].path)},e.prototype.isQueueProcessingSuspended=function(){return this._suspendProcessingUntil&&this._suspendProcessingUntil>new Date},e.prototype.areQueuedItemsDiscarded=function(){return this._discardQueuedItemsUntil&&this._discardQueuedItemsUntil>new Date},e}();t.DefaultEventQueue=g;var d=function(){function e(e){this._items=[],this._maxItems=e>0?e:250}return e.prototype.save=function(e,t){return e&&t?(this.remove(e),this._items.push({created:(new Date).getTime(),path:e,value:t})>this._maxItems&&this._items.shift(),!0):!1},e.prototype.get=function(e){var t=e?this.getList("^"+e+"$",1)[0]:null;return t?t.value:null},e.prototype.getList=function(e,t){var n=this._items;if(!e)return n.slice(0,t);for(var r=new RegExp(e),i=[],o=0;o<n.length&&!(r.test(n[o].path)&&(i.push(n[o]),i.length>=t));o++);return i},e.prototype.remove=function(e){if(e){var t=this.getList("^"+e+"$",1)[0];t&&this._items.splice(this._items.indexOf(t),1)}},e}();t.InMemoryStorage=d;var h=function(){function e(){this.configurationVersionHeader="x-exceptionless-configversion"}return e.prototype.postEvents=function(e,t,n,r){var i=v.stringify(e,t.dataExclusions),o=this.createRequest(t,"POST","/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="/api/v2/events/by-ref/"+encodeURIComponent(e)+"/user-description",o=v.stringify(t,n.dataExclusions),s=this.createRequest(n,"POST",i,o),u=this.createSubmissionCallback(n,r);return n.submissionAdapter.sendRequest(s,u)},e.prototype.getSettings=function(e,t){var n=this.createRequest(e,"GET","/api/v2/projects/config"),r=function(n,r,i,o){if(200!==n)return t(new C(!1,null,-1,null,r));var s;try{s=JSON.parse(i)}catch(u){e.log.error("Unable to parse settings: '"+i+"'")}return!s||isNaN(s.version)?t(new C(!1,null,-1,null,"Invalid configuration settings.")):void t(new C(!0,s.settings||{},s.version))};return e.submissionAdapter.sendRequest(n,r)},e.prototype.createRequest=function(e,t,n,r){return void 0===r&&(r=null),{method:t,path:n,data:r,serverUrl:e.serverUrl,apiKey:e.apiKey,userAgent:e.userAgent}},e.prototype.createSubmissionCallback=function(e,t){var n=this;return function(r,i,o,u){var a=u&&parseInt(u[n.configurationVersionHeader]);s.checkVersion(a,e),t(new x(r,i))}},e}();t.DefaultSubmissionClient=h;var v=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;r<t.length;r++)t[r]&&e.indexOf(t[r])<0&&e.push(t[r]);return e},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,t){function n(e,t){if(!e||!t||"string"!=typeof t)return!1;var n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;if(e=e.toLowerCase().replace(n,""),t=t.toLowerCase().replace(n,""),e.length<=0)return!1;var r="*"===e[0];r&&(e=e.slice(1));var i="*"===e[e.length-1];return i&&(e=e.substring(0,e.length-1)),r&&i?-1!==t.indexOf(e):r?t.lastIndexOf(e)===t.length-e.length:i?0===t.indexOf(e):t===e}function r(e,t){var r=[];return JSON.stringify(e,function(e,i){for(var o=0;o<(t||[]).length;o++)if(n(t[o],e))return;if("object"==typeof i&&i){if(-1!==r.indexOf(i))return;r.push(i)}return i})}if("[object Array]"==={}.toString.call(e)){for(var i=[],o=0;o<e.length;o++)i[o]=JSON.parse(r(e[o],t||[]));return JSON.stringify(i)}return r(e,t||[])},e}();t.Utils=v;var m=function(){function e(t){function n(e){return"function"==typeof e?e(this):e}this.defaultTags=[],this.defaultData={},this.enabled=!0,this.lastReferenceIdManager=new u,this.settings={},this._serverUrl="https://collector.exceptionless.io",this._dataExclusions=[],this._plugins=[],t=v.merge(e.defaults,t),this.log=n(t.log)||new c,this.apiKey=t.apiKey,this.serverUrl=t.serverUrl,this.environmentInfoCollector=n(t.environmentInfoCollector),this.errorParser=n(t.errorParser),this.lastReferenceIdManager=n(t.lastReferenceIdManager)||new u,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 h,this.storage=n(t.storage)||new d,this.queue=n(t.queue)||new g(this),s.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)},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.log.info("serverUrl: "+this._serverUrl))},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-0]=arguments[t];this._dataExclusions=v.addRange.apply(v,[this._dataExclusions].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)return void this.log.error("Add plugin failed: Run method not defined");r.name||(r.name=v.guid()),r.priority||(r.priority=0);for(var i=!1,o=this._plugins,s=0;s<o.length;s++)if(o[s].name===r.name){i=!0;break}i||o.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: Plugin name not defined");for(var n=this._plugins,r=0;r<n.length;r++)if(n[r].name===t){n.splice(r,1);break}},e.prototype.setVersion=function(e){e&&(this.defaultData["@version"]=e)},e.prototype.setUserIdentity=function(e,t){var n="@user",r="string"!=typeof e?e:{identity:e,name:t},i=!r||!r.identity&&!r.name;i?delete this.defaultData[n]:this.defaultData[n]=r,this.log.info("user identity: "+(i?"null":r.identity))},Object.defineProperty(e.prototype,"userAgent",{get:function(){return"exceptionless-js/1.0.1"},enumerable:!0,configurable:!0}),e.prototype.useReferenceIds=function(){this.addPlugin(new p)},e.prototype.useDebugLogger=function(){this.log=new a},Object.defineProperty(e,"defaults",{get:function(){return null===e._defaultSettings&&(e._defaultSettings={}),e._defaultSettings},enumerable:!0,configurable:!0}),e._defaultSettings=null,e}();t.Configuration=m;var y=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.setSessionId=function(e){if(!this.isValidIdentifier(e))throw new Error("SessionId "+this._validIdentifierErrorMessage);return this.target.session_id=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.setMessage=function(e){return e&&(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];return this.target.tags=v.addRange.apply(v,[this.target.tags].concat(e)),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)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=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 x=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=x;var S=function(){function e(e,t){this.config=new m("object"!=typeof e?e:{apiKey:e,serverUrl:t})}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(t&&n)r=r.setSource(e).setMessage(t).setProperty("@level",n);else if(t)r=r.setSource(e).setMessage(t);else{var i=arguments.callee.caller;r=r.setSource(i&&i.name).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 y({date:new Date},this,e)},e.prototype.submitEvent=function(e,t,n){function r(){return i&&(i.cancelled=!0),!!n&&n(i)}if(!e)return r();if(!this.config.enabled)return this.config.log.info("Event submission is currently disabled."),r();e.data||(e.data={}),e.tags&&e.tags.length||(e.tags=[]);var i=new l(this,e,t);f.run(i,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.updateUserEmailAndDescription=function(e,t,n,r){var i=this;if(!(e&&t&&n&&this.config.enabled))return!!r&&r(new x(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()},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=S;var E=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=E;var w=function(){function e(){this.priority=30,this.name="ErrorPlugin"}return e.prototype.run=function(e,t){var n="@error",r=e.contextData.getException();if(r&&(e.event.type="error",!e.event.data[n])){var i=e.client.config.errorParser;if(!i)throw new Error("No error parser was defined.");var o=i.parse(e,r);o&&(e.event.data[n]=o)}t&&t()},e}();t.ErrorPlugin=w;var _=function(){function e(){this.priority=40,this.name="ModuleInfoPlugin"}return e.prototype.run=function(e,t){var n="@error",r=e.client.config.moduleCollector;if(e.event.data[n]&&!e.event.data["@error"].modules&&r){var i=r.getModules(e);i&&i.length>0&&(e.event.data[n].modules=i)}t&&t()},e}();t.ModuleInfoPlugin=_;var T=function(){function e(){this.priority=60,this.name="RequestInfoPlugin"}return e.prototype.run=function(e,t){var n="@request",r=e.client.config.requestInfoCollector;if(!e.event.data[n]&&r){var i=r.getRequestInfo(e);i&&(e.event.data[n]=i)}t&&t()},e}();t.RequestInfoPlugin=T;var P=function(){function e(){this.priority=70,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}();t.EnvironmentInfoPlugin=P;var I=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=I;var C=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=C;var R=function(){function e(){}return e.prototype.parse=function(e,t){function n(e){for(var t=("string"==typeof e?[e]:e)||[],n=[],r=0;r<t.length;r++)n.push({name:t[r]});return n}function r(e,t){
for(var r="<anonymous>",i=[],o=0;o<t.length;o++){var s=t[o];i.push({name:(s.func||r).replace("?",r),parameters:n(s.args),file_name:s.url,line_number:s.line||0,column:s.column||0})}return i}var i="@@_TraceKit.StackTrace",o=e.contextData[i]?e.contextData[i]:TraceKit.computeStackTrace(t,25);if(!o)throw new Error("Unable to parse the exceptions stack trace.");return{type:o.name,message:o.message||t.message,stack_trace:r(e,o.stack||[])}},e}();t.DefaultErrorParser=R;var U=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:v.parseVersion(n[r].src)}):n[r].innerHTML&&t.push({module_id:r,name:"Script Tag",version:v.getHashCode(n[r].innerHTML)});return t},e}();t.DefaultModuleCollector=U;var q=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:v.getCookies(document.cookie),query_string:v.parseQueryString(location.search.substring(1))};return document.referrer&&""!==document.referrer&&(t.referrer=document.referrer),t},e}();t.DefaultRequestInfoCollector=q;var k=function(){function e(){}return e.prototype.sendRequest=function(e,t,n){function r(n,r){function i(e){for(var t={},n=(e||"").split("\r\n"),r=0;r<n.length;r++){var i=n[r],o=i.indexOf(": ");o>0&&(t[i.substring(0,o)]=i.substring(o+2).toLowerCase())}return t}if(!a){a=!0;var u=r.statusText,c=r.responseText,l=r.status;if(n===o||0===l)u="Unable to connect to server.",l=0;else if(n!==s||l){if(200>l||l>299){var f=r.responseBody;if(f&&f.message)u=f.message;else if(c&&-1!==c.indexOf("message"))try{u=JSON.parse(c).message}catch(p){u=c}}}else l="POST"===e.method?202:200;t(l||500,u||"",c,i(r.getAllResponseHeaders&&r.getAllResponseHeaders()))}}function i(e,t,n){var r=new XMLHttpRequest;return u in r?(r.open(t,n,!0),r.setRequestHeader("X-Exceptionless-Client",e),"POST"===t&&r.setRequestHeader("Content-Type","application/json")):"undefined"!=typeof XDomainRequest?(c=!0,r=new XDomainRequest,r.open(t,"http:"===location.protocol?n.replace("https:","http:"):n)):r=null,r&&(r.timeout=1e4),r}var o="timeout",s="loaded",u="withCredentials",a=!1,c=!1,l=""+e.serverUrl+e.path+"?access_token="+encodeURIComponent(e.apiKey),f=i(e.userAgent,e.method||"POST",l);return f?(u in f&&(f.onreadystatechange=function(){4===f.readyState&&r(s,f)}),f.onprogress=function(){},f.ontimeout=function(){return r(o,f)},f.onerror=function(){return r("error",f)},f.onload=function(){return r(s,f)},void(c?setTimeout(function(){return f.send(e.data)},500):f.send(e.data))):t(503,"CORS not supported.")},e}();t.DefaultSubmissionAdapter=k;var D=m.defaults,M=r();return M&&(M.apiKey||M.serverUrl)&&(D.apiKey=M.apiKey,D.serverUrl=M.serverUrl),D.errorParser=new R,D.moduleCollector=new U,D.requestInfoCollector=new q,D.submissionAdapter=new k,TraceKit.report.subscribe(i),TraceKit.extendToAsynchronousCallbacks(),"undefined"!=typeof $&&$(document)&&$(document).ajaxError(o),Error.stackTraceLimit=1/0,t});
//# sourceMappingURL=exceptionless.min.js.map