##// END OF EJS Templates
pull-requests: reorder navigation on repo pull requests, fixes #2995
pull-requests: reorder navigation on repo pull requests, fixes #2995

File last commit:

r1:854a839a default
r283:d0db6bab default
Show More
appenlight-client-0.4.1.min.js
1 line | 11.8 KiB | application/javascript | JavascriptLexer
/ rhodecode / public / js / src / appenlight-client-0.4.1.min.js
/*! appenlight-client 29-01-2016 */
!function(a){"use strict";var b={version:"0.4.1",options:{apiKey:""},errorReportBuffer:[],slowReportBuffer:[],logBuffer:[],requestInfo:null,init:function(b){var c=this;"undefined"==typeof b.server&&(b.server="https://api.appenlight.com"),"undefined"==typeof b.apiKey&&(b.apiKey="undefined"),"undefined"==typeof b.protocol_version&&(b.protocol_version="0.5"),("undefined"==typeof b.windowOnError||0==b.windowOnError)&&(TraceKit.collectWindowErrors=!1),"undefined"==typeof b.sendInterval&&(b.sendInterval=1e3),"undefined"==typeof b.tracekitRemoteFetching&&(b.tracekitRemoteFetching=!0),"undefined"==typeof b.tracekitContextLines&&(b.tracekitContextLines=11),b.sendInterval>=1e3&&this.createSendInterval(b.sendInterval),this.options=b,this.requestInfo={url:a.location.href},this.reportsEndpoint=b.server+"/api/reports?public_api_key="+this.options.apiKey+"&protocol_version="+this.options.protocol_version,this.logsEndpoint=b.server+"/api/logs?public_api_key="+this.options.apiKey+"&protocol_version="+this.options.protocol_version,TraceKit.remoteFetching=b.tracekitRemoteFetching,TraceKit.linesOfContext=b.tracekitContextLines,TraceKit.report.subscribe(function(a){c.handleError(a)})},createSendInterval:function(a){var b=this;this.send_iv=setInterval(function(){b.sendReports(),b.sendLogs()},a)},setRequestInfo:function(a){for(var b in a)this.requestInfo[b]=a[b]},grabError:function(a){try{TraceKit.report(a)}catch(b){if(a!==b)throw b}},handleError:function(b){if("stack"==b.mode)var c=b.name+": "+b.message;else var c=b.message;var d={client:"javascript",language:"javascript",error:c,occurences:1,priority:5,server:"",http_status:500,request:{},traceback:[]};if(d.user_agent=a.navigator.userAgent,d.start_time=(new Date).toJSON(),null!=this.requestInfo)for(var e in this.requestInfo)d[e]=this.requestInfo[e];"undefined"!=typeof d.request_id&&d.request_id||(d.request_id=this.genUUID4());for(var f=b.stack.reverse().slice(-100),e=0;e<f.length;e++){var g="";try{if(f[e].context)for(var h=0;h<f[e].context.length;h++){var i=f[e].context[h];g+=i.length>300?"<minified-context>":i,g+="\n"}}catch(j){}var k={cline:g,file:f[e].url,fn:f[e].func,line:f[e].line,vars:[]};d.traceback.push(k)}d.traceback.length>0&&(d.traceback[d.traceback.length-1].cline=g+"\n"+c),this.errorReportBuffer.push(d)},log:function(b,c,d,e){if("undefined"==typeof d)var d=a.location.pathname;if("undefined"==typeof e)var e=null;this.logBuffer.push({log_level:b.toUpperCase(),message:c,date:(new Date).toJSON(),namespace:d}),null!=this.requestInfo&&"undefined"!=typeof this.requestInfo.server&&(this.logBuffer[this.logBuffer.length-1].server=this.requestInfo.server)},genUUID4:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"==a?b:3&b|8;return c.toString(16)})},sendReports:function(){if(this.errorReportBuffer.length<1)return!0;var a=this.errorReportBuffer;return this.submitData(this.reportsEndpoint,a),this.errorReportBuffer=[],!0},sendLogs:function(){if(this.logBuffer.length<1)return!0;var a=this.logBuffer;return this.submitData(this.logsEndpoint,a),this.logBuffer=[],!0},submitData:function(b,c){var d=new a.XMLHttpRequest;!d&&a.ActiveXObject&&(d=new a.ActiveXObject("Microsoft.XMLHTTP")),d.open("POST",b,!0),d.setRequestHeader("Content-Type","application/json"),d.send(JSON.stringify(c))}};a.AppEnlight=b,"function"==typeof define&&define.amd&&define("appenlight",[],function(){return b})}(window),function(a,b){function c(a,b){return Object.prototype.hasOwnProperty.call(a,b)}function d(a){return"undefined"==typeof a}if(a){var e={},f=a.TraceKit,g=[].slice,h="?";e.noConflict=function(){return a.TraceKit=f,e},e.wrap=function(a){function b(){try{return a.apply(this,arguments)}catch(b){throw e.report(b),b}}return b},e.report=function(){function b(a){i(),n.push(a)}function d(a){for(var b=n.length-1;b>=0;--b)n[b]===a&&n.splice(b,1)}function f(a,b){var d=null;if(!b||e.collectWindowErrors){for(var f in n)if(c(n,f))try{n[f].apply(null,[a].concat(g.call(arguments,2)))}catch(h){d=h}if(d)throw d}}function h(a,b,c,d,g){var h=null;if(q)e.computeStackTrace.augmentStackTraceWithInitialElement(q,b,c,a),j();else if(g)h=e.computeStackTrace(g),f(h,!0);else{var i={url:b,line:c,column:d};i.func=e.computeStackTrace.guessFunctionName(i.url,i.line),i.context=e.computeStackTrace.gatherContext(i.url,i.line),h={mode:"onerror",message:a,stack:[i]},f(h,!0)}return l?l.apply(this,arguments):!1}function i(){m!==!0&&(l=a.onerror,a.onerror=h,m=!0)}function j(){var a=q,b=o;o=null,q=null,p=null,f.apply(null,[a,!1].concat(b))}function k(b){if(q){if(p===b)return;j()}var c=e.computeStackTrace(b);throw q=c,p=b,o=g.call(arguments,1),a.setTimeout(function(){p===b&&j()},c.incomplete?2e3:0),b}var l,m,n=[],o=null,p=null,q=null;return k.subscribe=b,k.unsubscribe=d,k}(),e.computeStackTrace=function(){function b(b){if(!e.remoteFetching)return"";try{var c=function(){try{return new a.XMLHttpRequest}catch(b){return new a.ActiveXObject("Microsoft.XMLHTTP")}},d=c();return d.open("GET",b,!1),d.send(""),d.responseText}catch(f){return""}}function f(a){if("string"!=typeof a)return[];if(!c(w,a)){var d="",e="";try{e=document.domain}catch(f){}-1!==a.indexOf(e)&&(d=b(a)),w[a]=d?d.split("\n"):[]}return w[a]}function g(a,b){var c,e=/function ([^(]*)\(([^)]*)\)/,g=/['"]?([0-9A-Za-z$_]+)['"]?\s*[:=]\s*(function|eval|new Function)/,i="",j=10,k=f(a);if(!k.length)return h;for(var l=0;j>l;++l)if(i=k[b-l]+i,!d(i)){if(c=g.exec(i))return c[1];if(c=e.exec(i))return c[1]}return h}function i(a,b){var c=f(a);if(!c.length)return null;var g=[],h=Math.floor(e.linesOfContext/2),i=h+e.linesOfContext%2,j=Math.max(0,b-h-1),k=Math.min(c.length,b+i-1);b-=1;for(var l=j;k>l;++l)d(c[l])||g.push(c[l]);return g.length>0?g:null}function j(a){return a.replace(/[\-\[\]{}()*+?.,\\\^$|#]/g,"\\$&")}function k(a){return j(a).replace("<","(?:<|&lt;)").replace(">","(?:>|&gt;)").replace("&","(?:&|&amp;)").replace('"','(?:"|&quot;)').replace(/\s+/g,"\\s+")}function l(a,b){for(var c,d,e=0,g=b.length;g>e;++e)if((c=f(b[e])).length&&(c=c.join("\n"),d=a.exec(c)))return{url:b[e],line:c.substring(0,d.index).split("\n").length,column:d.index-c.lastIndexOf("\n",d.index)-1};return null}function m(a,b,c){var d,e=f(b),g=new RegExp("\\b"+j(a)+"\\b");return c-=1,e&&e.length>c&&(d=g.exec(e[c]))?d.index:null}function n(b){if(!d(document)){for(var c,e,f,g,h=[a.location.href],i=document.getElementsByTagName("script"),m=""+b,n=/^function(?:\s+([\w$]+))?\s*\(([\w\s,]*)\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,o=/^function on([\w$]+)\s*\(event\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,p=0;p<i.length;++p){var q=i[p];q.src&&h.push(q.src)}if(f=n.exec(m)){var r=f[1]?"\\s+"+f[1]:"",s=f[2].split(",").join("\\s*,\\s*");c=j(f[3]).replace(/;$/,";?"),e=new RegExp("function"+r+"\\s*\\(\\s*"+s+"\\s*\\)\\s*{\\s*"+c+"\\s*}")}else e=new RegExp(j(m).replace(/\s+/g,"\\s+"));if(g=l(e,h))return g;if(f=o.exec(m)){var t=f[1];if(c=k(f[2]),e=new RegExp("on"+t+"=[\\'\"]\\s*"+c+"\\s*[\\'\"]","i"),g=l(e,h[0]))return g;if(e=new RegExp(c),g=l(e,h))return g}return null}}function o(a){if(!a.stack)return null;for(var b,c,e=/^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,f=/^\s*(.*?)(?:\((.*?)\))?@?((?:file|https?|blob|chrome|\[).*?)(?::(\d+))?(?::(\d+))?\s*$/i,j=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:ms-appx|https?|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,k=a.stack.split("\n"),l=[],n=/^(.*) is undefined$/.exec(a.message),o=0,p=k.length;p>o;++o){if(b=e.exec(k[o])){var q=b[2]&&-1!==b[2].indexOf("native");c={url:q?null:b[2],func:b[1]||h,args:q?[b[2]]:[],line:b[3]?+b[3]:null,column:b[4]?+b[4]:null}}else if(b=j.exec(k[o]))c={url:b[2],func:b[1]||h,args:[],line:+b[3],column:b[4]?+b[4]:null};else{if(!(b=f.exec(k[o])))continue;c={url:b[3],func:b[1]||h,args:b[2]?b[2].split(","):[],line:b[4]?+b[4]:null,column:b[5]?+b[5]:null}}!c.func&&c.line&&(c.func=g(c.url,c.line)),c.line&&(c.context=i(c.url,c.line)),l.push(c)}return l.length?(l[0]&&l[0].line&&!l[0].column&&n?l[0].column=m(n[1],l[0].url,l[0].line):l[0].column||d(a.columnNumber)||(l[0].column=a.columnNumber+1),{mode:"stack",name:a.name,message:a.message,stack:l}):null}function p(a){var b=a.stacktrace;if(b){for(var c,d=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i,e=/ line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^\)]+))\((.*)\))? in (.*):\s*$/i,f=b.split("\n"),h=[],j=0;j<f.length;j+=2){var k=null;if((c=d.exec(f[j]))?k={url:c[2],line:+c[1],column:null,func:c[3],args:[]}:(c=e.exec(f[j]))&&(k={url:c[6],line:+c[1],column:+c[2],func:c[3]||c[4],args:c[5]?c[5].split(","):[]}),k){if(!k.func&&k.line&&(k.func=g(k.url,k.line)),k.line)try{k.context=i(k.url,k.line)}catch(l){}k.context||(k.context=[f[j+1]]),h.push(k)}}return h.length?{mode:"stacktrace",name:a.name,message:a.message,stack:h}:null}}function q(b){var d=b.message.split("\n");if(d.length<4)return null;var e,h=/^\s*Line (\d+) of linked script ((?:file|https?|blob)\S+)(?:: in function (\S+))?\s*$/i,j=/^\s*Line (\d+) of inline#(\d+) script in ((?:file|https?|blob)\S+)(?:: in function (\S+))?\s*$/i,m=/^\s*Line (\d+) of function script\s*$/i,n=[],o=document.getElementsByTagName("script"),p=[];for(var q in o)c(o,q)&&!o[q].src&&p.push(o[q]);for(var r=2;r<d.length;r+=2){var s=null;if(e=h.exec(d[r]))s={url:e[2],func:e[3],args:[],line:+e[1],column:null};else if(e=j.exec(d[r])){s={url:e[3],func:e[4],args:[],line:+e[1],column:null};var t=+e[1],u=p[e[2]-1];if(u){var v=f(s.url);if(v){v=v.join("\n");var w=v.indexOf(u.innerText);w>=0&&(s.line=t+v.substring(0,w).split("\n").length)}}}else if(e=m.exec(d[r])){var x=a.location.href.replace(/#.*$/,""),y=new RegExp(k(d[r+1])),z=l(y,[x]);s={url:x,func:"",args:[],line:z?z.line:e[1],column:null}}if(s){s.func||(s.func=g(s.url,s.line));var A=i(s.url,s.line),B=A?A[Math.floor(A.length/2)]:null;A&&B.replace(/^\s*/,"")===d[r+1].replace(/^\s*/,"")?s.context=A:s.context=[d[r+1]],n.push(s)}}return n.length?{mode:"multiline",name:b.name,message:d[0],stack:n}:null}function r(a,b,c,d){var e={url:b,line:c};if(e.url&&e.line){a.incomplete=!1,e.func||(e.func=g(e.url,e.line)),e.context||(e.context=i(e.url,e.line));var f=/ '([^']+)' /.exec(d);if(f&&(e.column=m(f[1],e.url,e.line)),a.stack.length>0&&a.stack[0].url===e.url){if(a.stack[0].line===e.line)return!1;if(!a.stack[0].line&&a.stack[0].func===e.func)return a.stack[0].line=e.line,a.stack[0].context=e.context,!1}return a.stack.unshift(e),a.partial=!0,!0}return a.incomplete=!0,!1}function s(a,b){for(var c,d,f,i=/function\s+([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)?\s*\(/i,j=[],k={},l=!1,o=s.caller;o&&!l;o=o.caller)if(o!==t&&o!==e.report){if(d={url:null,func:h,args:[],line:null,column:null},o.name?d.func=o.name:(c=i.exec(o.toString()))&&(d.func=c[1]),"undefined"==typeof d.func)try{d.func=c.input.substring(0,c.input.indexOf("{"))}catch(p){}if(f=n(o)){d.url=f.url,d.line=f.line,d.func===h&&(d.func=g(d.url,d.line));var q=/ '([^']+)' /.exec(a.message||a.description);q&&(d.column=m(q[1],f.url,f.line))}k[""+o]?l=!0:k[""+o]=!0,j.push(d)}b&&j.splice(0,b);var u={mode:"callers",name:a.name,message:a.message,stack:j};return r(u,a.sourceURL||a.fileName,a.line||a.lineNumber,a.message||a.description),u}function t(a,b){var c=null;b=null==b?0:+b;try{if(c=p(a))return c}catch(d){if(v)throw d}try{if(c=o(a))return c}catch(d){if(v)throw d}try{if(c=q(a))return c}catch(d){if(v)throw d}try{if(c=s(a,b+1))return c}catch(d){if(v)throw d}return{mode:"failed"}}function u(a){a=(null==a?0:+a)+1;try{throw new Error}catch(b){return t(b,a+1)}}var v=!1,w={};return t.augmentStackTraceWithInitialElement=r,t.guessFunctionName=g,t.gatherContext=i,t.ofCaller=u,t.getSource=f,t}(),e.extendToAsynchronousCallbacks=function(){var b=function(b){var c=a[b];a[b]=function(){var a=g.call(arguments),b=a[0];return"function"==typeof b&&(a[0]=e.wrap(b)),c.apply?c.apply(this,a):c(a[0],a[1])}};b("setTimeout"),b("setInterval")},e.remoteFetching||(e.remoteFetching=!0),e.collectWindowErrors||(e.collectWindowErrors=!0),(!e.linesOfContext||e.linesOfContext<1)&&(e.linesOfContext=11),a.TraceKit=e}}("undefined"!=typeof window?window:global);