-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathexceptionless.min.js
3 lines (3 loc) · 36.8 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(),g.push(e)}function r(e){for(var t=g.length-1;t>=0;--t)g[t]===e&&g.splice(t,1)}function o(e,t){var r=null;if(!t||i.collectWindowErrors){for(var o in g)if(n(g,o))try{g[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(v)i.computeStackTrace.augmentStackTraceWithInitialElement(v,t,n,e),c();else if(s)u=i.computeStackTrace(s),o(u,!0);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]},o(u,!0)}return f?f.apply(this,arguments):!1}function a(){p!==!0&&(f=e.onerror,e.onerror=u,p=!0)}function c(){var e=v,t=h;h=null,v=null,d=null,o.apply(null,[e,!1].concat(t))}function l(t){if(v){if(d===t)return;c()}var n=i.computeStackTrace(t);throw v=n,d=t,h=s.call(arguments,1),e.setTimeout(function(){d===t&&c()},n.incomplete?2e3:0),t}var f,p,g=[],h=null,d=null,v=null;return l.subscribe=t,l.unsubscribe=r,l}(),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){if(!r(document)){for(var n,i,o,s,u=[e.location.href],a=document.getElementsByTagName("script"),p=""+t,g=/^function(?:\s+([\w$]+))?\s*\(([\w\s,]*)\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,h=/^function on([\w$]+)\s*\(event\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,d=0;d<a.length;++d){var v=a[d];v.src&&u.push(v.src)}if(o=g.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,u))return s;if(o=h.exec(p)){var b=o[1];if(n=l(o[2]),i=new RegExp("on"+b+"=[\\'\"]\\s*"+n+"\\s*[\\'\"]","i"),s=f(i,u[0]))return s;if(i=new RegExp(n),s=f(i,u))return s}return null}}function h(e){if(!e.stack)return null;for(var t,n,i=/^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,o=/^\s*(.*?)(?:\((.*?)\))?@?((?:file|https?|blob|chrome|\[).*?)(?::(\d+))?(?::(\d+))?\s*$/i,c=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:ms-appx|https?|blob):.*?):(\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=i.exec(l[h])){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[h]))n={url:t[2],func:t[1]||u,args:[],line:+t[3],column:t[4]?+t[4]:null};else{if(!(t=o.exec(l[h])))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 d(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?|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,g=[],h=document.getElementsByTagName("script"),d=[];for(var v in h)n(h,v)&&!h[v].src&&d.push(h[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=d[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])),P=f(_,[w]);y={url:w,func:"",args:[],line:P?P.line:i[1],column:null}}if(y){y.func||(y.func=s(y.url,y.line));var I=a(y.url,y.line),T=I?I[Math.floor(I.length/2)]:null;I&&T.replace(/^\s*/,"")===r[m+1].replace(/^\s*/,"")?y.context=I:y.context=[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,h=y.caller;h&&!f;h=h.caller)if(h!==b&&h!==i.report){if(r={url:null,func:u,args:[],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 v=/ '([^']+)' /.exec(e.message||e.description);v&&(r.column=p(v[1],o.url,o.line))}l[""+h]?f=!0:l[""+h]=!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=d(e))return n}catch(r){if(S)throw r}try{if(n=h(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()}if(!t)var t={};var o=function(){function e(){}return 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.checkVersion=function(e,t){if(e){var n=parseInt(t.storage.get(this._configPath+"-version"),10);(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.changed=function(e){for(var t=this._handlers,n=0;n<t.length;n++)t[n](e)},e.getSavedServerSettings=function(e){return e.storage.get(this._configPath)||{}},e._configPath="ex-server-settings.json",e._handlers=[],e}();t.SettingsManager=o;var s=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=s;var u=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=u;var a=function(){function e(){}return e.prototype.info=function(e){},e.prototype.warn=function(e){},e.prototype.error=function(e){},e}();t.NullLog=a;var c=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=c;var l=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 U),e.addPlugin(new _),e.addPlugin(new P),e.addPlugin(new I),e.addPlugin(new T)},e}();t.EventPluginManager=l;var f=function(){function e(){this.priority=100,this.name="HeartbeatPlugin"}return e.prototype.run=function(e,t){var n=this,r=function(){n._heartbeatIntervalId&&(clearInterval(n._heartbeatIntervalId),n._heartbeatIntervalId=0)},i=e.event.type;if("heartbeat"!==i)if("sessionend"===i)r();else{var o=e.event.data["@user"];if(o&&o.identity){var s=function(){return e.client.createSessionHeartbeat().setUserIdentity(o).submit()};this._heartbeatIntervalId?r():this._lastUser=o,this._heartbeatIntervalId=setInterval(s,3e4)}}t&&t()},e}();t.HeartbeatPlugin=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.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.areQueuedItemsDiscarded=function(){return this._discardQueuedItemsUntil&&this._discardQueuedItemsUntil>new Date},e.prototype.ensureQueueTimer=function(){var e=this;this._queueTimer||(this._queueTimer=setInterval(function(){return e.onProcessQueue()},1e4))},e.prototype.isQueueProcessingSuspended=function(){return this._suspendProcessingUntil&&this._suspendProcessingUntil>new Date},e.prototype.onProcessQueue=function(){this.isQueueProcessingSuspended()||this._processingQueue||this.process()},e.prototype.processSubmissionResponse=function(e,t){var n="The event will not be submitted.",r=this._config,i=r.log;if(e.success)return i.info("Sent "+t.length+" events."),void this.removeEvents(t);if(e.serviceUnavailable)return i.error("Server returned service unavailable."),void this.suspendProcessing();if(e.paymentRequired)return i.info("Too many events have been submitted, please upgrade your plan."),void this.suspendProcessing(null,!0,!0);if(e.unableToAuthenticate)return i.info("Unable to authenticate, please check your configuration. "+n),this.suspendProcessing(15),void this.removeEvents(t);if(e.notFound||e.badRequest)return i.error("Error while trying to submit data: "+e.message),this.suspendProcessing(240),void this.removeEvents(t);if(e.requestEntityTooLarge){var o="Event submission discarded for being too large.";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.removeEvents=function(e){for(var t=0;t<(e||[]).length;t++)this._config.storage.remove(e[t].path)},e}();t.DefaultEventQueue=g;var h=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=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","/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=JSON.stringify(t),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 q(!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 q(!1,null,-1,null,"Invalid configuration settings.")):void t(new q(!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,s,u){var a=u&&parseInt(u[n.configurationVersionHeader],10);o.checkVersion(a,e),t(new x(r,i))}},e}();t.DefaultSubmissionClient=d;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 0;for(var t=0,n=0;n<e.length;n++){var r=e.charCodeAt(n);t=(t<<5)-t+r,t|=0}return t},e.getCookies=function(t,n){for(var r={},i=(t||"").split("; "),o=0;o<i.length;o++){var s=i[o].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||{})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(t,n){if(!t||0===t.length)return null;var r=t.split("&");if(0===r.length)return null;for(var i={},o=0;o<r.length;o++){var s=r[o].split("=");e.isMatch(s[0],n)||(i[decodeURIComponent(s[0])]=decodeURIComponent(s[1]))}return e.isEmpty(i)?null:i},e.randomNumber=function(){return Math.floor(9007199254740992*Math.random())},e.isMatch=function(e,t){if(!e||"string"!=typeof e)return!1;var n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;return(t||[]).some(function(t){if(!t)return!1;if(t=t.toLowerCase().replace(n,""),e=e.toLowerCase().replace(n,""),t.length<=0)return!1;var r="*"===t[0];r&&(t=t.slice(1));var i="*"===t[t.length-1];if(i&&(t=t.substring(0,t.length-1)),r&&i)return-1!==e.indexOf(t);if(r){var o=e.lastIndexOf(t);return-1!==o&&o===e.length-t.length}return i?0===e.indexOf(t):e===t})},e.isEmpty=function(e){return null===e||"object"==typeof e&&0===Object.keys(e).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){var u=t[s];u!==t&&(o[s]=t[s])}return i(o,n)}if("[object Array]"==={}.toString.call(t)){for(var a=[],c=0;c<t.length;c++)a[c]=JSON.parse(i(t[c],n));return JSON.stringify(a)}return i(t,n)},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 s,this.settings={},this._plugins=[],this._serverUrl="https://collector.exceptionless.io",this._dataExclusions=[],t=v.merge(e.defaults,t),this.log=n(t.log)||new a,this.apiKey=t.apiKey,this.serverUrl=t.serverUrl,this.environmentInfoCollector=n(t.environmentInfoCollector),this.errorParser=n(t.errorParser),this.lastReferenceIdManager=n(t.lastReferenceIdManager)||new s,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 g(this),o.applySavedServerSettings(this),l.addDefaultPlugins(this),t.enableSessions&&this.useSessions()}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.3.0"},enumerable:!0,configurable:!0}),e.prototype.useSessions=function(e){void 0===e&&(e=!0),e&&this.addPlugin(new f)},e.prototype.useReferenceIds=function(){this.addPlugin(new p)},e.prototype.useDebugLogger=function(){this.log=new u},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.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(-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,n,r){if(!e||void 0===t||null==t)return this;this.target.data||(this.target.data={});var i=JSON.parse(v.stringify(t,this.client.config.dataExclusions.concat(r||[]),n));return v.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&&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){"object"!=typeof e?this.config=new m(e):this.config=new m({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(){return this.createEvent().setType("session")},e.prototype.submitSessionStart=function(e){this.createSessionStart().submit(e)},e.prototype.createSessionEnd=function(){return this.createEvent().setType("sessionend")},e.prototype.submitSessionEnd=function(e){this.createSessionEnd().submit(e)},e.prototype.createSessionHeartbeat=function(){return this.createEvent().setType("heartbeat")},e.prototype.submitSessionHeartbeat=function(e){this.createSessionHeartbeat().submit(e)},e.prototype.createEvent=function(e){return new y({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 c(this,e,t);return e?this.config.enabled?(e.data||(e.data={}),e.tags&&e.tags.length||(e.tags=[]),void l.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)})):(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 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,r=n.defaultTags||[],i=0;i<r.length;i++){var o=r[i];o&&e.event.tags.indexOf(o)<0&&e.event.tags.push(o)}var s=n.defaultData||{};for(var u in s)if(s[u]){var a=JSON.parse(v.stringify(s[u],n.dataExclusions));v.isEmpty(a)||(e.event.data[u]=a)}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=["arguments","column","columnNumber","description","fileName","message","name","number","line","lineNumber","opera#sourceloc","sourceId","sourceURL","stack","stackArray","stacktrace"],i=e.contextData.getException();if(i&&(e.event.type="error",!e.event.data[n])){var o=e.client.config,s=o.errorParser;if(!s)throw new Error("No error parser was defined.");var u=s.parse(e,i);if(u){var a=JSON.parse(v.stringify(i,o.dataExclusions.concat(r)));v.isEmpty(a)||(u.data||(u.data={}),u.data["@ext"]=a),e.event.data[n]=u}}t&&t()},e}();t.ErrorPlugin=w;var _=function(){function e(){this.priority=50,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 P=function(){function e(){this.priority=70,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=P;var I=function(){function e(){this.priority=80,this.name="EnvironmentInfoPlugin"}return e.prototype.run=function(e,t){var n="@environment",r=e.client.config.environmentInfoCollector;if(!e.event.data[n]&&r){var i=r.getEnvironmentInfo(e);i&&(e.event.data[n]=i)}t&&t()},e}();t.EnvironmentInfoPlugin=I;var T=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=T;var C="@error",R=2e3,k=10,U=function(){function e(){this.priority=40,this.name="DuplicateCheckerPlugin",this.recentlyProcessedErrors=[]}return e.prototype.run=function(e,t){if("error"===e.event.type){var n=e.event.data[C],r=this.checkDuplicate(n,e.log);if(r)return void(e.cancelled=!0)}t&&t()},e.prototype.getNow=function(){return Date.now()},e.prototype.checkDuplicate=function(e,t){function n(e){return e.stack_trace?v.getHashCode(JSON.stringify(e.stack_trace)):null}for(var r,i=this.getNow(),o=i-R;e;){if(r=n(e),r&&this.recentlyProcessedErrors.some(function(e){return e.hash===r&&e.timestamp>=o}))return t.info("Ignoring duplicate error event: hash="+r),!0;for(this.recentlyProcessedErrors.push({hash:r,timestamp:i});this.recentlyProcessedErrors.length>k;)this.recentlyProcessedErrors.shift();e=e.inner}return!1},e}();t.DuplicateCheckerPlugin=U;var q=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=q;var D=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){for(var t="<anonymous>",r=[],i=0;i<e.length;i++){var o=e[i];r.push({name:(o.func||t).replace("?",t),parameters:n(o.args),file_name:o.url,line_number:o.line||0,column:o.column||0})}return r}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(o.stack||[])}},e}();t.DefaultErrorParser=D;var O=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).toString()});return t},e}();t.DefaultModuleCollector=O;var M=function(){function e(){}return e.prototype.getRequestInfo=function(e){if(!document||!navigator||!location)return null;var t=e.client.config.dataExclusions,n={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,cookies:v.getCookies(document.cookie,t),query_string:v.parseQueryString(location.search.substring(1),t)};return document.referrer&&""!==document.referrer&&(n.referrer=document.referrer),n},e}();t.DefaultRequestInfoCollector=M;var A=function(){function e(){}return e.prototype.sendRequest=function(e,t,n){function r(n,r){function i(e){function t(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")}for(var n={},r=(e||"").split("\r\n"),i=0;i<r.length;i++){var o=r[i],s=o.indexOf(": ");s>0&&(n[t(o.substring(0,s).toLowerCase())]=o.substring(s+2))}return n}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=A;var N=m.defaults,F=r();return F&&(F.apiKey||F.serverUrl)&&(N.apiKey=F.apiKey,N.serverUrl=F.serverUrl),N.enableSessions=!0,N.errorParser=new D,N.moduleCollector=new O,N.requestInfoCollector=new M,N.submissionAdapter=new A,TraceKit.report.subscribe(i),TraceKit.extendToAsynchronousCallbacks(),Error.stackTraceLimit=1/0,t});
//# sourceMappingURL=exceptionless.min.js.map