mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-15 16:12:51 +11:00
2 lines
5.4 KiB
JavaScript
2 lines
5.4 KiB
JavaScript
|
/* Raven.js v0.4 | https://github.com/lincolnloop/raven-js/ */
|
||
|
function parseUri(e){var d=parseUri.options,a=d.parser[d.strictMode?"strict":"loose"].exec(e),c={},b=14;while(b--){c[d.key[b]]=a[b]||""}c[d.q.name]={};c[d.key[12]].replace(d.q.parser,function(g,f,h){if(f){c[d.q.name][f]=h}});return c}parseUri.options={strictMode:false,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};(function(){var a=this;var d;d=a.Raven={};var b=d;d.VERSION="0.4";var c=a.jQuery||a.Zepto||a.ender;d.loaded=false;d.options={secretKey:undefined,publicKey:undefined,servers:[],projectId:1,logger:"javascript",site:undefined,signatureUrl:undefined,fetchHeaders:false,testMode:false};d.funcNameRE=/function\s*([\w\-$]+)?\s*\(/i;d.config=function(e){if(typeof(e)==="string"){if(e.indexOf("http")===0){e=d.parseDSN(e)}else{throw"Base64 encoded config is no longer supported - use DSN"}}c.each(e,function(f,g){b.options[f]=g})};d.parseDSN=function(f){var h=parseUri(f);var g=h.path.lastIndexOf("/");var e;var i;if(g===-1){e=h.path.substr(1);i=""}else{i=h.path.substr(1,g);e=h.path.substr(g+1)}return{servers:[h.protocol+"://"+h.host+":"+h.port+"/"+i+"api/"+e+"/store/"],publicKey:h.user,secretKey:h.password,projectId:e}};d.getHeaders=function(){var e={};if(b.options.fetchHeaders){e=c.ajax({type:"HEAD",url:a.location,async:false}).getAllResponseHeaders()}e.Referer=document.referrer;e["User-Agent"]=navigator.userAgent;return e};d.parseHeaders=function(e){var f={};c.each(e.split("\n"),function(h,k){var g=k.slice(0,k.indexOf(":")),j=k.slice(k.indexOf(":")+2);f[g]=j});return f};d.getSignature=function(e,f,g){if(b.options.signatureUrl){c.post(b.options.signatureUrl,{message:e,timestamp:f},function(h){g(h.signature)})}else{g()}};d.getAuthHeader=function(e,f){var g="Sentry sentry_version=2.0, ";g+="sentry_timestamp="+f+", ";g+="sentry_client=raven-js/"+b.VERSION;if(b.options.publicKey){g+=", sentry_key="+b.options.publicKey}if(e){g+=", sentry_signature="+e}return g};d.captureException=function(i){var h,f,g;if(i.line){h=i.line}else{if(i.lineNumber){h=i.lineNumber}}if(i.sourceURL){g=i.sourceURL}else{if(i.fileName){g=i.fileName}}if(i.arguments&&i.stack){f=this.chromeTraceback(i)}else{if(i.stack){if(i.stack.indexOf("@")==-1){f=this.chromeTraceback(i)}else{f=this.firefoxTraceback(i)}}else{f=[{filename:g,lineno:h}];f=f.concat(this.otherTraceback(arguments.callee))}}b.process(i,g,h,f)};d.captureMessage=function(e){b.process(e)};d.trimString=function(e){return e.replace(/^\s+|\s+$/g,"")};d.chromeTraceback=function(k){var l,i,g,j,h=[],f=k.stack.split("\n");c.each(f.slice(1),function(m,e){l=d.trimString(e).slice(3);if(l=="unknown source"){return}else{l=l.split(" ")}if(l.length>2){i=l[0];g=l.slice(1).join(" ");j="(unknown)"}else{if(l.length==2){i=l[0];g=l[1]}else{i="(unknown)";g=l[0]}}if(g&&g!="(unknown source)"){if(g.slice(0,1)=="("){g=g.slice(1,-1).split(":")}else{g=g.split(":")}j=g.slice(-2)[0];g=g.slice(0,-2).join(":")}h.push({"function":i,filename:g,lineno:j})});return h};d.firefoxTraceback=function(l){var m,j,i,g,k,h=[],f=l.stack.split("\n");c.each(f,function(n,e){if(e){m=e.split("@");if(m[0]){j=m[0].split("(");if(j[1]!=")"){i=j[1].slice(0,-1).split(",")}else{i=undefined}if(j[0]){j=j[0]}else{j="(unknown)"}}else{j="(unknown)"}g=m[1].split(":");k=g.slice(-1)[0];g=g.slice(0,-1).join(":");h.push({"function":j,filename:g,lineno:k,vars:{"arguments":i}})}});return h};d.otherTraceback=function(j){var i,h,f="<anonymous>",g=[],e=9;while(j&&g.length<e){i=j.name||(this.funcNameRE.test(j.toString())?RegExp.$1||f:f);if(j.arguments){h=this.stringifyArguments(j.arguments)}else{h=undefined}g.push({filename:"(unknown source)",lineno:"(unknown)","function":i,post_conte
|