ravenjs-gem 1.0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ /*! Raven.js 1.0.7 | github.com/getsentry/raven-js */
2
+ (function(n,e){function r(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function t(n){return n===e}var i={},u=n.TraceKit,o=[].slice,c="?";i.noConflict=function(){return n.TraceKit=u,i},i.wrap=function(n){function e(){try{return n.apply(this,arguments)}catch(e){throw i.report(e),e}}return e},i.report=function(){function e(n){l.push(n)}function t(n){for(var e=l.length-1;e>=0;--e)l[e]===n&&l.splice(e,1)}function u(n,e){var t=null;if(!e||i.collectWindowErrors){for(var u in l)if(r(l,u))try{l[u].apply(null,[n].concat(o.call(arguments,2)))}catch(c){t=c}if(t)throw t}}function c(e){var r=o.call(arguments,1);if(s){if(a===e)return;var t=s;s=null,a=null,u.apply(null,[t,null].concat(r))}var c=i.computeStackTrace(e);throw s=c,a=e,n.setTimeout(function(){a===e&&(s=null,a=null,u.apply(null,[c,null].concat(r)))},c.incomplete?2e3:0),e}var l=[],a=null,s=null,f=n.onerror;return n.onerror=function(n,e,r){var t=null;if(s)i.computeStackTrace.augmentStackTraceWithInitialElement(s,e,r,n),t=s,s=null,a=null;else{var o={url:e,line:r};o.func=i.computeStackTrace.guessFunctionName(o.url,o.line),o.context=i.computeStackTrace.gatherContext(o.url,o.line),t={mode:"onerror",message:n,url:document.location.href,stack:[o],useragent:navigator.userAgent}}return u(t,"from window.onerror"),f?f.apply(this,arguments):!1},c.subscribe=e,c.unsubscribe=t,c}(),i.computeStackTrace=function(){function e(e){function r(){try{return new n.XMLHttpRequest}catch(e){return new n.ActiveXObject("Microsoft.XMLHTTP")}}if(!i.remoteFetching)return"";try{var t=r();return t.open("GET",e,!1),t.send(""),t.responseText}catch(u){return""}}function u(n){if(!r(E,n)){var t="";-1!==n.indexOf(document.domain)&&(t=e(n)),E[n]=t?t.split("\n"):[]}return E[n]}function o(n,e){var r,i=/function ([^(]*)\(([^)]*)\)/,o=/['"]?([0-9A-Za-z$_]+)['"]?\s*[:=]\s*(function|eval|new Function)/,l="",a=10,s=u(n);if(!s.length)return c;for(var f=0;a>f;++f)if(l=s[e-f]+l,!t(l)){if(r=o.exec(l))return r[1];if(r=i.exec(l))return r[1]}return c}function l(n,e){var r=u(n);if(!r.length)return null;var o=[],c=Math.floor(i.linesOfContext/2),l=c+i.linesOfContext%2,a=Math.max(0,e-c-1),s=Math.min(r.length,e+l-1);e-=1;for(var f=a;s>f;++f)t(r[f])||o.push(r[f]);return o.length>0?o:null}function a(n){return n.replace(/[\-\[\]{}()*+?.,\\\^$|#]/g,"\\$&")}function s(n){return a(n).replace("<","(?:<|&lt;)").replace(">","(?:>|&gt;)").replace("&","(?:&|&amp;)").replace('"','(?:"|&quot;)').replace(/\s+/g,"\\s+")}function f(n,e){for(var r,t,i=0,o=e.length;o>i;++i)if((r=u(e[i])).length&&(r=r.join("\n"),t=n.exec(r)))return{url:e[i],line:r.substring(0,t.index).split("\n").length,column:t.index-r.lastIndexOf("\n",t.index)-1};return null}function p(n,e,r){var t,i=u(e),o=RegExp("\\b"+a(n)+"\\b");return r-=1,i&&i.length>r&&(t=o.exec(i[r]))?t.index:null}function g(e){for(var r,t,i,u,o=[n.location.href],c=document.getElementsByTagName("script"),l=""+e,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;c.length>h;++h){var m=c[h];m.src&&o.push(m.src)}if(i=p.exec(l)){var v=i[1]?"\\s+"+i[1]:"",d=i[2].split(",").join("\\s*,\\s*");r=a(i[3]).replace(/;$/,";?"),t=RegExp("function"+v+"\\s*\\(\\s*"+d+"\\s*\\)\\s*{\\s*"+r+"\\s*}")}else t=RegExp(a(l).replace(/\s+/g,"\\s+"));if(u=f(t,o))return u;if(i=g.exec(l)){var x=i[1];if(r=s(i[2]),t=RegExp("on"+x+"=[\\'\"]\\s*"+r+"\\s*[\\'\"]","i"),u=f(t,o[0]))return u;if(t=RegExp(r),u=f(t,o))return u}return null}function h(n){if(!n.stack)return null;for(var e,r,t=/^\s*at (?:((?:\[object object\])?\S+) )?\(?((?:file|http|https):.*?):(\d+)(?::(\d+))?\)?\s*$/i,i=/^\s*(\S*)(?:\((.*?)\))?@((?:file|http|https).*?):(\d+)(?::(\d+))?\s*$/i,u=n.stack.split("\n"),a=[],s=/^(.*) is undefined$/.exec(n.message),f=0,g=u.length;g>f;++f){if(e=i.exec(u[f]))r={url:e[3],func:e[1]||c,args:e[2]?e[2].split(","):"",line:+e[4],column:e[5]?+e[5]:null};else{if(!(e=t.exec(u[f])))continue;r={url:e[2],func:e[1]||c,line:+e[3],column:e[4]?+e[4]:null}}!r.func&&r.line&&(r.func=o(r.url,r.line)),r.line&&(r.context=l(r.url,r.line)),a.push(r)}return a[0]&&a[0].line&&!a[0].column&&s&&(a[0].column=p(s[1],a[0].url,a[0].line)),a.length?{mode:"stack",name:n.name,message:n.message,url:document.location.href,stack:a,useragent:navigator.userAgent}:null}function m(n){for(var e,r=n.stacktrace,t=/ line (\d+), column (\d+) in (?:<anonymous function: ([^>]+)>|([^\)]+))\((.*)\) in (.*):\s*$/i,i=r.split("\n"),u=[],c=0,a=i.length;a>c;c+=2)if(e=t.exec(i[c])){var s={line:+e[1],column:+e[2],func:e[3]||e[4],args:e[5]?e[5].split(","):[],url:e[6]};if(!s.func&&s.line&&(s.func=o(s.url,s.line)),s.line)try{s.context=l(s.url,s.line)}catch(f){}s.context||(s.context=[i[c+1]]),u.push(s)}return u.length?{mode:"stacktrace",name:n.name,message:n.message,url:document.location.href,stack:u,useragent:navigator.userAgent}:null}function v(e){var t=e.message.split("\n");if(4>t.length)return null;var i,c,a,p,g=/^\s*Line (\d+) of linked script ((?:file|http|https)\S+)(?:: in function (\S+))?\s*$/i,h=/^\s*Line (\d+) of inline#(\d+) script in ((?:file|http|https)\S+)(?:: in function (\S+))?\s*$/i,m=/^\s*Line (\d+) of function script\s*$/i,v=[],d=document.getElementsByTagName("script"),x=[];for(c in d)r(d,c)&&!d[c].src&&x.push(d[c]);for(c=2,a=t.length;a>c;c+=2){var y=null;if(i=g.exec(t[c]))y={url:i[2],func:i[3],line:+i[1]};else if(i=h.exec(t[c])){y={url:i[3],func:i[4]};var w=+i[1],k=x[i[2]-1];if(k&&(p=u(y.url))){p=p.join("\n");var E=p.indexOf(k.innerText);E>=0&&(y.line=w+p.substring(0,E).split("\n").length)}}else if(i=m.exec(t[c])){var b=n.location.href.replace(/#.*$/,""),S=i[1],T=RegExp(s(t[c+1]));p=f(T,[b]),y={url:b,line:p?p.line:S,func:""}}if(y){y.func||(y.func=o(y.url,y.line));var $=l(y.url,y.line),F=$?$[Math.floor($.length/2)]:null;y.context=$&&F.replace(/^\s*/,"")===t[c+1].replace(/^\s*/,"")?$:[t[c+1]],v.push(y)}}return v.length?{mode:"multiline",name:e.name,message:t[0],url:document.location.href,stack:v,useragent:navigator.userAgent}:null}function d(n,e,r,t){var i={url:e,line:r};if(i.url&&i.line){n.incomplete=!1,i.func||(i.func=o(i.url,i.line)),i.context||(i.context=l(i.url,i.line));var u=/ '([^']+)' /.exec(t);if(u&&(i.column=p(u[1],i.url,i.line)),n.stack.length>0&&n.stack[0].url===i.url){if(n.stack[0].line===i.line)return!1;if(!n.stack[0].line&&n.stack[0].func===i.func)return n.stack[0].line=i.line,n.stack[0].context=i.context,!1}return n.stack.unshift(i),n.partial=!0,!0}return n.incomplete=!0,!1}function x(n,e){for(var r,t,u,l=/function\s+([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)?\s*\(/i,a=[],s={},f=!1,h=x.caller;h&&!f;h=h.caller)if(h!==y&&h!==i.report){if(t={url:null,func:c,line:null,column:null},h.name?t.func=h.name:(r=l.exec(""+h))&&(t.func=r[1]),u=g(h)){t.url=u.url,t.line=u.line,t.func===c&&(t.func=o(t.url,t.line));var m=/ '([^']+)' /.exec(n.message||n.description);m&&(t.column=p(m[1],u.url,u.line))}s[""+h]?f=!0:s[""+h]=!0,a.push(t)}e&&a.splice(0,e);var v={mode:"callers",name:n.name,message:n.message,url:document.location.href,stack:a,useragent:navigator.userAgent};return d(v,n.sourceURL||n.fileName,n.line||n.lineNumber,n.message||n.description),v}function y(n,e){var r=null;e=null==e?0:+e;try{if(r=m(n))return r}catch(t){if(k)throw t}try{if(r=h(n))return r}catch(t){if(k)throw t}try{if(r=v(n))return r}catch(t){if(k)throw t}try{if(r=x(n,e+1))return r}catch(t){if(k)throw t}return{mode:"failed"}}function w(n){n=(null==n?0:+n)+1;try{throw Error()}catch(e){return y(e,n+1)}return null}var k=!1,E={};return y.augmentStackTraceWithInitialElement=d,y.guessFunctionName=o,y.gatherContext=l,y.ofCaller=w,y}(),function(){var e=function e(e){var r=n[e];n[e]=function(){var n=o.call(arguments),e=n[0];return"function"==typeof e&&(n[0]=i.wrap(e)),r.apply?r.apply(this,n):r(n[0],n[1])}};e("setTimeout"),e("setInterval")}(),function(n){if(n){var r=n.event.add;n.event.add=function(e,t,u,o,c){var l;return u.handler?(l=u.handler,u.handler=i.wrap(u.handler)):(l=u,u=i.wrap(u)),u.guid=l.guid?l.guid:l.guid=n.guid++,r.call(this,e,t,u,o,c)};var t=n.fn.ready;n.fn.ready=function(n){return t.call(this,i.wrap(n))};var u=n.ajax;n.ajax=function(r,t){var o,c=["complete","error","success"];for("object"==typeof r&&(t=r,r=e),t=t||{};o=c.pop();)n.isFunction(t[o])&&(t[o]=i.wrap(t[o]));try{return u.call(this,r,t)}catch(l){throw i.report(l),l}}}}(n.jQuery),i.remoteFetching||(i.remoteFetching=!0),i.collectWindowErrors||(i.collectWindowErrors=!0),(!i.linesOfContext||1>i.linesOfContext)&&(i.linesOfContext=11),n.TraceKit=i})(window),function(n,e){"use strict";function r(n){for(var e=F.exec(n),r={},t=14;t--;)r[$[t]]=e[t]||"";return r}function t(n){return n===e}function i(n){return"function"==typeof n}function u(n,e){var r,i;if(t(n.length))for(r in n)n.hasOwnProperty(r)&&e.call(null,r,n[r]);else for(r=0,i=n.length;i>r;r++)e.call(null,r,n[r])}function o(){if(S)return S;var n=["sentry_version=2.0","sentry_client=raven-js/"+T.VERSION];return x&&n.push("sentry_key="+x),S="?"+n.join("&")}function c(n,e){var r,t,i=[],u=0;if(n.stack&&(r=n.stack.length))for(;r>u;u++)t=l(n.stack[u]),t&&i.push(t);s(n.name,n.message,n.url,n.lineno,i,e)}function l(n){if(n.url){var e={filename:n.url,lineno:n.line,colno:n.column,"function":n.func||"?"},r=a(n);if(r)for(var t=3,i=["pre_context","context_line","post_context"];t--;)e[i[t]]=r[t];return e.in_app=!/(Raven|TraceKit)\./.test(e["function"]),e}}function a(n){if(n.context&&E.fetchContext){for(var e=n.context,r=~~(e.length/2),i=e.length,u=!1;i--;)if(e[i].length>300){u=!0;break}if(u){if(t(n.column))return;return[[],e[r].substr(n.column,50),[]]}return[e.slice(0,r),e[r],e.slice(r+1)]}}function s(n,e,r,t,i,u){var o,c,l;for(l=E.ignoreErrors.length;l--;)if(e===E.ignoreErrors[l])return;for(i&&i.length?(o={frames:i},r=r||i[0].filename):r&&(o={frames:[{filename:r,lineno:t}]}),l=E.ignoreUrls.length;l--;)if(E.ignoreUrls[l].test(r))return;c=t?e+" at "+t:e,g(f({"sentry.interfaces.Exception":{type:n,value:e},"sentry.interfaces.Stacktrace":o,culprit:r,message:c},u))}function f(n,e){return e?(u(e,function(e,r){n[e]=r}),n):n}function p(){var e={url:n.location.href,headers:{"User-Agent":navigator.userAgent}};return n.document.referrer&&(e.headers.Referer=n.document.referrer),e}function g(n){m()&&(n=f({project:y,logger:E.logger,site:E.site,platform:"javascript","sentry.interfaces.Http":p()},n),d&&(n["sentry.interfaces.User"]=d),i(E.dataCallback)&&(n=E.dataCallback(n)),h(n))}function h(n){(new Image).src=v+o()+"&sentry_data="+encodeURIComponent(JSON.stringify(n))}function m(){return k?v?!0:(n.console&&console.error&&console.error("Error: Raven has not been configured."),!1):!1}var v,d,x,y,w=n.Raven,k=!t(n.JSON),E={logger:"javascript",ignoreErrors:[],ignoreUrls:[]},b=TraceKit.noConflict();b.remoteFetching=!1;var S,T={VERSION:"1.0.7",noConflict:function(){return n.Raven=w,T},config:function(e,t){var i=r(e),o=i.path.lastIndexOf("/"),c=i.path.substr(1,o);return t&&t.ignoreErrors&&n.console&&console.warn&&console.warn("DeprecationWarning: `ignoreErrors` is going to be removed soon."),t&&u(t,function(n,e){E[n]=e}),E.ignoreErrors.push("Script error."),x=i.user,y=~~i.path.substr(o+1),v="//"+i.host+(i.port?":"+i.port:"")+"/"+c+"api/"+y+"/store/",i.protocol&&(v=i.protocol+":"+v),E.fetchContext&&(b.remoteFetching=!0),T},install:function(){return m()?(b.report.subscribe(c),T):e},context:function(n,r,t){i(n)&&(t=r||[],r=n,n=e),T.wrap(n,r).apply(this,t)},wrap:function(n,r){return i(n)&&(r=n,n=e),function(){try{r.apply(this,arguments)}catch(e){throw T.captureException(e,n),e}}},uninstall:function(){return b.report.unsubscribe(c),T},captureException:function(n,e){if("string"==typeof n)return T.captureMessage(n,e);try{b.report(n,e)}catch(r){if(n!==r)throw r}return T},captureMessage:function(n,e){return g(f({message:n},e)),T},setUser:function(n){return d=n,T}},$="source protocol authority userInfo user password host port relative path directory file query anchor".split(" "),F=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;n.Raven=T,"function"==typeof define&&define.amd&&define(function(){return T})}(window);
3
+ /*
4
+ //@ sourceMappingURL=raven.min.map
5
+ */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"raven.min.js","sources":["raven.js"],"names":["window","undefined","_has","object","key","Object","prototype","hasOwnProperty","call","_isUndefined","what","TraceKit","_oldTraceKit","_slice","slice","UNKNOWN_FUNCTION","noConflict","wrap","func","wrapped","apply","this","arguments","e","report","subscribe","handler","handlers","push","unsubscribe","i","length","splice","notifyHandlers","stack","windowError","exception","collectWindowErrors","concat","inner","ex","args","lastExceptionStack","lastException","s","computeStackTrace","setTimeout","incomplete","_oldOnerrorHandler","onerror","message","url","lineNo","augmentStackTraceWithInitialElement","location","line","guessFunctionName","context","gatherContext","mode","document","href","useragent","navigator","userAgent","loadSource","getXHR","XMLHttpRequest","ActiveXObject","remoteFetching","request","open","send","responseText","getSource","sourceCache","source","indexOf","domain","split","m","reFunctionArgNames","reGuessFunction","maxLines","exec","linesBefore","Math","floor","linesOfContext","linesAfter","start","max","end","min","escapeRegExp","text","replace","escapeCodeAsRegExpForMatchingInsideHTML","body","findSourceInUrls","re","urls","j","join","substring","index","column","lastIndexOf","findSourceInLine","fragment","RegExp","findSourceByFunctionBody","parts","result","scripts","getElementsByTagName","code","codeRE","eventRE","script","src","name","event","computeStackTraceFromStackProp","element","chrome","gecko","lines","reference","computeStackTraceFromStacktraceProp","stacktrace","testRE","exc","computeStackTraceFromOperaMultiLineMessage","len","lineRE1","lineRE2","lineRE3","inlineScriptBlocks","item","relativeLine","pos","innerText","midline","stackInfo","initial","unshift","partial","computeStackTraceByWalkingCallerChain","depth","functionName","funcs","recursion","curr","caller","description","sourceURL","fileName","lineNumber","debug","computeStackTraceOfCaller","Error","ofCaller","_helper","fnName","originalFn","originalCallback","$","_oldEventAdd","add","elem","types","data","selector","_handler","guid","_oldReady","fn","ready","_oldAjax","ajax","options","keys","pop","isFunction","jQuery","parseUri","str","uriPattern","uri","uriKeys","isUndefined","each","obj","callback","getAuthQueryString","cachedAuth","qs","Raven","VERSION","globalKey","handleStackInfo","frame","frames","normalizeFrame","processException","lineno","normalized","filename","colno","function","extractContextFromFrame","in_app","test","globalOptions","fetchContext","pivot","isMinified","substr","type","fileurl","label","ignoreErrors","ignoreUrls","arrayMerge","sentry.interfaces.Exception","value","sentry.interfaces.Stacktrace","culprit","arr1","arr2","getHttpData","http","headers","User-Agent","referrer","Referer","isSetup","project","globalProject","logger","site","platform","sentry.interfaces.Http","globalUser","dataCallback","makeRequest","Image","globalServer","encodeURIComponent","JSON","stringify","hasJSON","console","error","_Raven","TK","config","dsn","lastSlash","path","warn","user","host","port","protocol","install","captureException","uninstall","captureMessage","ex1","msg","setUser","define","amd"],"mappings":";CAgBE,SAASA,EAAQC,GAkBnB,QAASC,GAAKC,EAAQC,GAClB,MAAOC,QAAOC,UAAUC,eAAeC,KAAKL,EAAQC,GAGxD,QAASK,GAAaC,GAClB,MAAcA,KAAAA,EApBlB,GAAIC,MACAC,EAAeZ,EAAOW,SAGtBE,KAAYC,MACZC,EAAmB,GAsBvBJ,GAASK,WAAa,WAElB,MADAhB,GAAOW,SAAWC,EACXD,GAUXA,EAASM,KAAO,SAAyBC,GACrC,QAASC,KACL,IACI,MAAOD,GAAKE,MAAMC,KAAMC,WAC1B,MAAOC,GAEL,KADAZ,GAASa,OAAOD,GACVA,GAGd,MAAOJ,IA0CXR,EAASa,OAAU,WASf,QAASC,GAAUC,GACfC,EAASC,KAAKF,GAOlB,QAASG,GAAYH,GACjB,IAAK,GAAII,GAAIH,EAASI,OAAS,EAAGD,GAAK,IAAKA,EACpCH,EAASG,KAAOJ,GAChBC,EAASK,OAAOF,EAAG,GAS/B,QAASG,GAAeC,EAAOC,GAC3B,GAAIC,GAAY,IAChB,KAAID,GAAgBxB,EAAS0B,oBAA7B,CAGA,IAAK,GAAIP,KAAKH,GACV,GAAIzB,EAAKyB,EAAUG,GACf,IACIH,EAASG,GAAGV,MAAM,MAAOc,GAAOI,OAAOzB,EAAOL,KAAKc,UAAW,KAChE,MAAOiB,GACLH,EAAYG,EAKxB,GAAIH,EACA,KAAMA,IAmDd,QAASZ,GAAOgB,GACZ,GAAIC,GAAO5B,E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R,EAAU,uGAAuG/G,MAAM,KACvH6G,EAAa,kMAsPjB5L,GAAOsM,MAAQA,EAGO,kBAAX2E,SAAyBA,OAAOC,KACvCD,OAAO,WAAa,MAAO3E,MAG5BtM"}
@@ -0,0 +1,1659 @@
1
+ /*! Raven.js 1.0.7 | github.com/getsentry/raven-js */
2
+
3
+ /*
4
+ * Includes TraceKit
5
+ * https://github.com/getsentry/TraceKit
6
+ *
7
+ * Copyright 2013 Matt Robenolt and other contributors
8
+ * Released under the BSD license
9
+ * https://github.com/getsentry/raven-js/blob/master/LICENSE
10
+ *
11
+ */
12
+ /*
13
+ TraceKit - Cross brower stack traces - github.com/occ/TraceKit
14
+ MIT license
15
+ */
16
+
17
+ ;(function(window, undefined) {
18
+
19
+
20
+ var TraceKit = {};
21
+ var _oldTraceKit = window.TraceKit;
22
+
23
+ // global reference to slice
24
+ var _slice = [].slice;
25
+ var UNKNOWN_FUNCTION = '?';
26
+
27
+
28
+ /**
29
+ * _has, a better form of hasOwnProperty
30
+ * Example: _has(MainHostObject, property) === true/false
31
+ *
32
+ * @param {Object} host object to check property
33
+ * @param {string} key to check
34
+ */
35
+ function _has(object, key) {
36
+ return Object.prototype.hasOwnProperty.call(object, key);
37
+ }
38
+
39
+ function _isUndefined(what) {
40
+ return typeof what === 'undefined';
41
+ }
42
+
43
+ /**
44
+ * TraceKit.noConflict: Export TraceKit out to another variable
45
+ * Example: var TK = TraceKit.noConflict()
46
+ */
47
+ TraceKit.noConflict = function noConflict() {
48
+ window.TraceKit = _oldTraceKit;
49
+ return TraceKit;
50
+ };
51
+
52
+ /**
53
+ * TraceKit.wrap: Wrap any function in a TraceKit reporter
54
+ * Example: func = TraceKit.wrap(func);
55
+ *
56
+ * @param {Function} func Function to be wrapped
57
+ * @return {Function} The wrapped func
58
+ */
59
+ TraceKit.wrap = function traceKitWrapper(func) {
60
+ function wrapped() {
61
+ try {
62
+ return func.apply(this, arguments);
63
+ } catch (e) {
64
+ TraceKit.report(e);
65
+ throw e;
66
+ }
67
+ }
68
+ return wrapped;
69
+ };
70
+
71
+ /**
72
+ * TraceKit.report: cross-browser processing of unhandled exceptions
73
+ *
74
+ * Syntax:
75
+ * TraceKit.report.subscribe(function(stackInfo) { ... })
76
+ * TraceKit.report.unsubscribe(function(stackInfo) { ... })
77
+ * TraceKit.report(exception)
78
+ * try { ...code... } catch(ex) { TraceKit.report(ex); }
79
+ *
80
+ * Supports:
81
+ * - Firefox: full stack trace with line numbers, plus column number
82
+ * on top frame; column number is not guaranteed
83
+ * - Opera: full stack trace with line and column numbers
84
+ * - Chrome: full stack trace with line and column numbers
85
+ * - Safari: line and column number for the top frame only; some frames
86
+ * may be missing, and column number is not guaranteed
87
+ * - IE: line and column number for the top frame only; some frames
88
+ * may be missing, and column number is not guaranteed
89
+ *
90
+ * In theory, TraceKit should work on all of the following versions:
91
+ * - IE5.5+ (only 8.0 tested)
92
+ * - Firefox 0.9+ (only 3.5+ tested)
93
+ * - Opera 7+ (only 10.50 tested; versions 9 and earlier may require
94
+ * Exceptions Have Stacktrace to be enabled in opera:config)
95
+ * - Safari 3+ (only 4+ tested)
96
+ * - Chrome 1+ (only 5+ tested)
97
+ * - Konqueror 3.5+ (untested)
98
+ *
99
+ * Requires TraceKit.computeStackTrace.
100
+ *
101
+ * Tries to catch all unhandled exceptions and report them to the
102
+ * subscribed handlers. Please note that TraceKit.report will rethrow the
103
+ * exception. This is REQUIRED in order to get a useful stack trace in IE.
104
+ * If the exception does not reach the top of the browser, you will only
105
+ * get a stack trace from the point where TraceKit.report was called.
106
+ *
107
+ * Handlers receive a stackInfo object as described in the
108
+ * TraceKit.computeStackTrace docs.
109
+ */
110
+ TraceKit.report = (function reportModuleWrapper() {
111
+ var handlers = [],
112
+ lastException = null,
113
+ lastExceptionStack = null;
114
+
115
+ /**
116
+ * Add a crash handler.
117
+ * @param {Function} handler
118
+ */
119
+ function subscribe(handler) {
120
+ handlers.push(handler);
121
+ }
122
+
123
+ /**
124
+ * Remove a crash handler.
125
+ * @param {Function} handler
126
+ */
127
+ function unsubscribe(handler) {
128
+ for (var i = handlers.length - 1; i >= 0; --i) {
129
+ if (handlers[i] === handler) {
130
+ handlers.splice(i, 1);
131
+ }
132
+ }
133
+ }
134
+
135
+ /**
136
+ * Dispatch stack information to all handlers.
137
+ * @param {Object.<string, *>} stack
138
+ */
139
+ function notifyHandlers(stack, windowError) {
140
+ var exception = null;
141
+ if (windowError && !TraceKit.collectWindowErrors) {
142
+ return;
143
+ }
144
+ for (var i in handlers) {
145
+ if (_has(handlers, i)) {
146
+ try {
147
+ handlers[i].apply(null, [stack].concat(_slice.call(arguments, 2)));
148
+ } catch (inner) {
149
+ exception = inner;
150
+ }
151
+ }
152
+ }
153
+
154
+ if (exception) {
155
+ throw exception;
156
+ }
157
+ }
158
+
159
+ var _oldOnerrorHandler = window.onerror;
160
+
161
+ /**
162
+ * Ensures all global unhandled exceptions are recorded.
163
+ * Supported by Gecko and IE.
164
+ * @param {string} message Error message.
165
+ * @param {string} url URL of script that generated the exception.
166
+ * @param {(number|string)} lineNo The line number at which the error
167
+ * occurred.
168
+ */
169
+ window.onerror = function traceKitWindowOnError(message, url, lineNo) {
170
+ var stack = null;
171
+
172
+ if (lastExceptionStack) {
173
+ TraceKit.computeStackTrace.augmentStackTraceWithInitialElement(lastExceptionStack, url, lineNo, message);
174
+ stack = lastExceptionStack;
175
+ lastExceptionStack = null;
176
+ lastException = null;
177
+ } else {
178
+ var location = {
179
+ 'url': url,
180
+ 'line': lineNo
181
+ };
182
+ location.func = TraceKit.computeStackTrace.guessFunctionName(location.url, location.line);
183
+ location.context = TraceKit.computeStackTrace.gatherContext(location.url, location.line);
184
+ stack = {
185
+ 'mode': 'onerror',
186
+ 'message': message,
187
+ 'url': document.location.href,
188
+ 'stack': [location],
189
+ 'useragent': navigator.userAgent
190
+ };
191
+ }
192
+
193
+ notifyHandlers(stack, 'from window.onerror');
194
+
195
+ if (_oldOnerrorHandler) {
196
+ return _oldOnerrorHandler.apply(this, arguments);
197
+ }
198
+
199
+ return false;
200
+ };
201
+
202
+ /**
203
+ * Reports an unhandled Error to TraceKit.
204
+ * @param {Error} ex
205
+ */
206
+ function report(ex) {
207
+ var args = _slice.call(arguments, 1);
208
+ if (lastExceptionStack) {
209
+ if (lastException === ex) {
210
+ return; // already caught by an inner catch block, ignore
211
+ } else {
212
+ var s = lastExceptionStack;
213
+ lastExceptionStack = null;
214
+ lastException = null;
215
+ notifyHandlers.apply(null, [s, null].concat(args));
216
+ }
217
+ }
218
+
219
+ var stack = TraceKit.computeStackTrace(ex);
220
+ lastExceptionStack = stack;
221
+ lastException = ex;
222
+
223
+ // If the stack trace is incomplete, wait for 2 seconds for
224
+ // slow slow IE to see if onerror occurs or not before reporting
225
+ // this exception; otherwise, we will end up with an incomplete
226
+ // stack trace
227
+ window.setTimeout(function () {
228
+ if (lastException === ex) {
229
+ lastExceptionStack = null;
230
+ lastException = null;
231
+ notifyHandlers.apply(null, [stack, null].concat(args));
232
+ }
233
+ }, (stack.incomplete ? 2000 : 0));
234
+
235
+ throw ex; // re-throw to propagate to the top level (and cause window.onerror)
236
+ }
237
+
238
+ report.subscribe = subscribe;
239
+ report.unsubscribe = unsubscribe;
240
+ return report;
241
+ }());
242
+
243
+ /**
244
+ * TraceKit.computeStackTrace: cross-browser stack traces in JavaScript
245
+ *
246
+ * Syntax:
247
+ * s = TraceKit.computeStackTrace.ofCaller([depth])
248
+ * s = TraceKit.computeStackTrace(exception) // consider using TraceKit.report instead (see below)
249
+ * Returns:
250
+ * s.name - exception name
251
+ * s.message - exception message
252
+ * s.stack[i].url - JavaScript or HTML file URL
253
+ * s.stack[i].func - function name, or empty for anonymous functions (if guessing did not work)
254
+ * s.stack[i].args - arguments passed to the function, if known
255
+ * s.stack[i].line - line number, if known
256
+ * s.stack[i].column - column number, if known
257
+ * s.stack[i].context - an array of source code lines; the middle element corresponds to the correct line#
258
+ * s.mode - 'stack', 'stacktrace', 'multiline', 'callers', 'onerror', or 'failed' -- method used to collect the stack trace
259
+ *
260
+ * Supports:
261
+ * - Firefox: full stack trace with line numbers and unreliable column
262
+ * number on top frame
263
+ * - Opera 10: full stack trace with line and column numbers
264
+ * - Opera 9-: full stack trace with line numbers
265
+ * - Chrome: full stack trace with line and column numbers
266
+ * - Safari: line and column number for the topmost stacktrace element
267
+ * only
268
+ * - IE: no line numbers whatsoever
269
+ *
270
+ * Tries to guess names of anonymous functions by looking for assignments
271
+ * in the source code. In IE and Safari, we have to guess source file names
272
+ * by searching for function bodies inside all page scripts. This will not
273
+ * work for scripts that are loaded cross-domain.
274
+ * Here be dragons: some function names may be guessed incorrectly, and
275
+ * duplicate functions may be mismatched.
276
+ *
277
+ * TraceKit.computeStackTrace should only be used for tracing purposes.
278
+ * Logging of unhandled exceptions should be done with TraceKit.report,
279
+ * which builds on top of TraceKit.computeStackTrace and provides better
280
+ * IE support by utilizing the window.onerror event to retrieve information
281
+ * about the top of the stack.
282
+ *
283
+ * Note: In IE and Safari, no stack trace is recorded on the Error object,
284
+ * so computeStackTrace instead walks its *own* chain of callers.
285
+ * This means that:
286
+ * * in Safari, some methods may be missing from the stack trace;
287
+ * * in IE, the topmost function in the stack trace will always be the
288
+ * caller of computeStackTrace.
289
+ *
290
+ * This is okay for tracing (because you are likely to be calling
291
+ * computeStackTrace from the function you want to be the topmost element
292
+ * of the stack trace anyway), but not okay for logging unhandled
293
+ * exceptions (because your catch block will likely be far away from the
294
+ * inner function that actually caused the exception).
295
+ *
296
+ * Tracing example:
297
+ * function trace(message) {
298
+ * var stackInfo = TraceKit.computeStackTrace.ofCaller();
299
+ * var data = message + "\n";
300
+ * for(var i in stackInfo.stack) {
301
+ * var item = stackInfo.stack[i];
302
+ * data += (item.func || '[anonymous]') + "() in " + item.url + ":" + (item.line || '0') + "\n";
303
+ * }
304
+ * if (window.console)
305
+ * console.info(data);
306
+ * else
307
+ * alert(data);
308
+ * }
309
+ */
310
+ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
311
+ var debug = false,
312
+ sourceCache = {};
313
+
314
+ /**
315
+ * Attempts to retrieve source code via XMLHttpRequest, which is used
316
+ * to look up anonymous function names.
317
+ * @param {string} url URL of source code.
318
+ * @return {string} Source contents.
319
+ */
320
+ function loadSource(url) {
321
+ if (!TraceKit.remoteFetching) { //Only attempt request if remoteFetching is on.
322
+ return '';
323
+ }
324
+ try {
325
+ function getXHR() {
326
+ try {
327
+ return new window.XMLHttpRequest();
328
+ } catch (e) {
329
+ // explicitly bubble up the exception if not found
330
+ return new window.ActiveXObject('Microsoft.XMLHTTP');
331
+ }
332
+ }
333
+
334
+ var request = getXHR();
335
+ request.open('GET', url, false);
336
+ request.send('');
337
+ return request.responseText;
338
+ } catch (e) {
339
+ return '';
340
+ }
341
+ }
342
+
343
+ /**
344
+ * Retrieves source code from the source code cache.
345
+ * @param {string} url URL of source code.
346
+ * @return {Array.<string>} Source contents.
347
+ */
348
+ function getSource(url) {
349
+ if (!_has(sourceCache, url)) {
350
+ // URL needs to be able to fetched within the acceptable domain. Otherwise,
351
+ // cross-domain errors will be triggered.
352
+ var source = '';
353
+ if (url.indexOf(document.domain) !== -1) {
354
+ source = loadSource(url);
355
+ }
356
+ sourceCache[url] = source ? source.split('\n') : [];
357
+ }
358
+
359
+ return sourceCache[url];
360
+ }
361
+
362
+ /**
363
+ * Tries to use an externally loaded copy of source code to determine
364
+ * the name of a function by looking at the name of the variable it was
365
+ * assigned to, if any.
366
+ * @param {string} url URL of source code.
367
+ * @param {(string|number)} lineNo Line number in source code.
368
+ * @return {string} The function name, if discoverable.
369
+ */
370
+ function guessFunctionName(url, lineNo) {
371
+ var reFunctionArgNames = /function ([^(]*)\(([^)]*)\)/,
372
+ reGuessFunction = /['"]?([0-9A-Za-z$_]+)['"]?\s*[:=]\s*(function|eval|new Function)/,
373
+ line = '',
374
+ maxLines = 10,
375
+ source = getSource(url),
376
+ m;
377
+
378
+ if (!source.length) {
379
+ return UNKNOWN_FUNCTION;
380
+ }
381
+
382
+ // Walk backwards from the first line in the function until we find the line which
383
+ // matches the pattern above, which is the function definition
384
+ for (var i = 0; i < maxLines; ++i) {
385
+ line = source[lineNo - i] + line;
386
+
387
+ if (!_isUndefined(line)) {
388
+ if ((m = reGuessFunction.exec(line))) {
389
+ return m[1];
390
+ } else if ((m = reFunctionArgNames.exec(line))) {
391
+ return m[1];
392
+ }
393
+ }
394
+ }
395
+
396
+ return UNKNOWN_FUNCTION;
397
+ }
398
+
399
+ /**
400
+ * Retrieves the surrounding lines from where an exception occurred.
401
+ * @param {string} url URL of source code.
402
+ * @param {(string|number)} line Line number in source code to centre
403
+ * around for context.
404
+ * @return {?Array.<string>} Lines of source code.
405
+ */
406
+ function gatherContext(url, line) {
407
+ var source = getSource(url);
408
+
409
+ if (!source.length) {
410
+ return null;
411
+ }
412
+
413
+ var context = [],
414
+ // linesBefore & linesAfter are inclusive with the offending line.
415
+ // if linesOfContext is even, there will be one extra line
416
+ // *before* the offending line.
417
+ linesBefore = Math.floor(TraceKit.linesOfContext / 2),
418
+ // Add one extra line if linesOfContext is odd
419
+ linesAfter = linesBefore + (TraceKit.linesOfContext % 2),
420
+ start = Math.max(0, line - linesBefore - 1),
421
+ end = Math.min(source.length, line + linesAfter - 1);
422
+
423
+ line -= 1; // convert to 0-based index
424
+
425
+ for (var i = start; i < end; ++i) {
426
+ if (!_isUndefined(source[i])) {
427
+ context.push(source[i]);
428
+ }
429
+ }
430
+
431
+ return context.length > 0 ? context : null;
432
+ }
433
+
434
+ /**
435
+ * Escapes special characters, except for whitespace, in a string to be
436
+ * used inside a regular expression as a string literal.
437
+ * @param {string} text The string.
438
+ * @return {string} The escaped string literal.
439
+ */
440
+ function escapeRegExp(text) {
441
+ return text.replace(/[\-\[\]{}()*+?.,\\\^$|#]/g, '\\$&');
442
+ }
443
+
444
+ /**
445
+ * Escapes special characters in a string to be used inside a regular
446
+ * expression as a string literal. Also ensures that HTML entities will
447
+ * be matched the same as their literal friends.
448
+ * @param {string} body The string.
449
+ * @return {string} The escaped string.
450
+ */
451
+ function escapeCodeAsRegExpForMatchingInsideHTML(body) {
452
+ return escapeRegExp(body).replace('<', '(?:<|&lt;)').replace('>', '(?:>|&gt;)').replace('&', '(?:&|&amp;)').replace('"', '(?:"|&quot;)').replace(/\s+/g, '\\s+');
453
+ }
454
+
455
+ /**
456
+ * Determines where a code fragment occurs in the source code.
457
+ * @param {RegExp} re The function definition.
458
+ * @param {Array.<string>} urls A list of URLs to search.
459
+ * @return {?Object.<string, (string|number)>} An object containing
460
+ * the url, line, and column number of the defined function.
461
+ */
462
+ function findSourceInUrls(re, urls) {
463
+ var source, m;
464
+ for (var i = 0, j = urls.length; i < j; ++i) {
465
+ // console.log('searching', urls[i]);
466
+ if ((source = getSource(urls[i])).length) {
467
+ source = source.join('\n');
468
+ if ((m = re.exec(source))) {
469
+ // console.log('Found function in ' + urls[i]);
470
+
471
+ return {
472
+ 'url': urls[i],
473
+ 'line': source.substring(0, m.index).split('\n').length,
474
+ 'column': m.index - source.lastIndexOf('\n', m.index) - 1
475
+ };
476
+ }
477
+ }
478
+ }
479
+
480
+ // console.log('no match');
481
+
482
+ return null;
483
+ }
484
+
485
+ /**
486
+ * Determines at which column a code fragment occurs on a line of the
487
+ * source code.
488
+ * @param {string} fragment The code fragment.
489
+ * @param {string} url The URL to search.
490
+ * @param {(string|number)} line The line number to examine.
491
+ * @return {?number} The column number.
492
+ */
493
+ function findSourceInLine(fragment, url, line) {
494
+ var source = getSource(url),
495
+ re = new RegExp('\\b' + escapeRegExp(fragment) + '\\b'),
496
+ m;
497
+
498
+ line -= 1;
499
+
500
+ if (source && source.length > line && (m = re.exec(source[line]))) {
501
+ return m.index;
502
+ }
503
+
504
+ return null;
505
+ }
506
+
507
+ /**
508
+ * Determines where a function was defined within the source code.
509
+ * @param {(Function|string)} func A function reference or serialized
510
+ * function definition.
511
+ * @return {?Object.<string, (string|number)>} An object containing
512
+ * the url, line, and column number of the defined function.
513
+ */
514
+ function findSourceByFunctionBody(func) {
515
+ var urls = [window.location.href],
516
+ scripts = document.getElementsByTagName('script'),
517
+ body,
518
+ code = '' + func,
519
+ codeRE = /^function(?:\s+([\w$]+))?\s*\(([\w\s,]*)\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,
520
+ eventRE = /^function on([\w$]+)\s*\(event\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,
521
+ re,
522
+ parts,
523
+ result;
524
+
525
+ for (var i = 0; i < scripts.length; ++i) {
526
+ var script = scripts[i];
527
+ if (script.src) {
528
+ urls.push(script.src);
529
+ }
530
+ }
531
+
532
+ if (!(parts = codeRE.exec(code))) {
533
+ re = new RegExp(escapeRegExp(code).replace(/\s+/g, '\\s+'));
534
+ }
535
+
536
+ // not sure if this is really necessary, but I don’t have a test
537
+ // corpus large enough to confirm that and it was in the original.
538
+ else {
539
+ var name = parts[1] ? '\\s+' + parts[1] : '',
540
+ args = parts[2].split(',').join('\\s*,\\s*');
541
+
542
+ body = escapeRegExp(parts[3]).replace(/;$/, ';?'); // semicolon is inserted if the function ends with a comment.replace(/\s+/g, '\\s+');
543
+ re = new RegExp('function' + name + '\\s*\\(\\s*' + args + '\\s*\\)\\s*{\\s*' + body + '\\s*}');
544
+ }
545
+
546
+ // look for a normal function definition
547
+ if ((result = findSourceInUrls(re, urls))) {
548
+ return result;
549
+ }
550
+
551
+ // look for an old-school event handler function
552
+ if ((parts = eventRE.exec(code))) {
553
+ var event = parts[1];
554
+ body = escapeCodeAsRegExpForMatchingInsideHTML(parts[2]);
555
+
556
+ // look for a function defined in HTML as an onXXX handler
557
+ re = new RegExp('on' + event + '=[\\\'"]\\s*' + body + '\\s*[\\\'"]', 'i');
558
+
559
+ if ((result = findSourceInUrls(re, urls[0]))) {
560
+ return result;
561
+ }
562
+
563
+ // look for ???
564
+ re = new RegExp(body);
565
+
566
+ if ((result = findSourceInUrls(re, urls))) {
567
+ return result;
568
+ }
569
+ }
570
+
571
+ return null;
572
+ }
573
+
574
+ // Contents of Exception in various browsers.
575
+ //
576
+ // SAFARI:
577
+ // ex.message = Can't find variable: qq
578
+ // ex.line = 59
579
+ // ex.sourceId = 580238192
580
+ // ex.sourceURL = http://...
581
+ // ex.expressionBeginOffset = 96
582
+ // ex.expressionCaretOffset = 98
583
+ // ex.expressionEndOffset = 98
584
+ // ex.name = ReferenceError
585
+ //
586
+ // FIREFOX:
587
+ // ex.message = qq is not defined
588
+ // ex.fileName = http://...
589
+ // ex.lineNumber = 59
590
+ // ex.stack = ...stack trace... (see the example below)
591
+ // ex.name = ReferenceError
592
+ //
593
+ // CHROME:
594
+ // ex.message = qq is not defined
595
+ // ex.name = ReferenceError
596
+ // ex.type = not_defined
597
+ // ex.arguments = ['aa']
598
+ // ex.stack = ...stack trace...
599
+ //
600
+ // INTERNET EXPLORER:
601
+ // ex.message = ...
602
+ // ex.name = ReferenceError
603
+ //
604
+ // OPERA:
605
+ // ex.message = ...message... (see the example below)
606
+ // ex.name = ReferenceError
607
+ // ex.opera#sourceloc = 11 (pretty much useless, duplicates the info in ex.message)
608
+ // ex.stacktrace = n/a; see 'opera:config#UserPrefs|Exceptions Have Stacktrace'
609
+
610
+ /**
611
+ * Computes stack trace information from the stack property.
612
+ * Chrome and Gecko use this property.
613
+ * @param {Error} ex
614
+ * @return {?Object.<string, *>} Stack trace information.
615
+ */
616
+ function computeStackTraceFromStackProp(ex) {
617
+ if (!ex.stack) {
618
+ return null;
619
+ }
620
+
621
+ var chrome = /^\s*at (?:((?:\[object object\])?\S+) )?\(?((?:file|http|https):.*?):(\d+)(?::(\d+))?\)?\s*$/i,
622
+ gecko = /^\s*(\S*)(?:\((.*?)\))?@((?:file|http|https).*?):(\d+)(?::(\d+))?\s*$/i,
623
+ lines = ex.stack.split('\n'),
624
+ stack = [],
625
+ parts,
626
+ element,
627
+ reference = /^(.*) is undefined$/.exec(ex.message);
628
+
629
+ for (var i = 0, j = lines.length; i < j; ++i) {
630
+ if ((parts = gecko.exec(lines[i]))) {
631
+ element = {
632
+ 'url': parts[3],
633
+ 'func': parts[1] || UNKNOWN_FUNCTION,
634
+ 'args': parts[2] ? parts[2].split(',') : '',
635
+ 'line': +parts[4],
636
+ 'column': parts[5] ? +parts[5] : null
637
+ };
638
+ } else if ((parts = chrome.exec(lines[i]))) {
639
+ element = {
640
+ 'url': parts[2],
641
+ 'func': parts[1] || UNKNOWN_FUNCTION,
642
+ 'line': +parts[3],
643
+ 'column': parts[4] ? +parts[4] : null
644
+ };
645
+ } else {
646
+ continue;
647
+ }
648
+
649
+ if (!element.func && element.line) {
650
+ element.func = guessFunctionName(element.url, element.line);
651
+ }
652
+
653
+ if (element.line) {
654
+ element.context = gatherContext(element.url, element.line);
655
+ }
656
+
657
+ stack.push(element);
658
+ }
659
+
660
+ if (stack[0] && stack[0].line && !stack[0].column && reference) {
661
+ stack[0].column = findSourceInLine(reference[1], stack[0].url, stack[0].line);
662
+ }
663
+
664
+ if (!stack.length) {
665
+ return null;
666
+ }
667
+
668
+ return {
669
+ 'mode': 'stack',
670
+ 'name': ex.name,
671
+ 'message': ex.message,
672
+ 'url': document.location.href,
673
+ 'stack': stack,
674
+ 'useragent': navigator.userAgent
675
+ };
676
+ }
677
+
678
+ /**
679
+ * Computes stack trace information from the stacktrace property.
680
+ * Opera 10 uses this property.
681
+ * @param {Error} ex
682
+ * @return {?Object.<string, *>} Stack trace information.
683
+ */
684
+ function computeStackTraceFromStacktraceProp(ex) {
685
+ // Access and store the stacktrace property before doing ANYTHING
686
+ // else to it because Opera is not very good at providing it
687
+ // reliably in other circumstances.
688
+ var stacktrace = ex.stacktrace;
689
+
690
+ var testRE = / line (\d+), column (\d+) in (?:<anonymous function: ([^>]+)>|([^\)]+))\((.*)\) in (.*):\s*$/i,
691
+ lines = stacktrace.split('\n'),
692
+ stack = [],
693
+ parts;
694
+
695
+ for (var i = 0, j = lines.length; i < j; i += 2) {
696
+ if ((parts = testRE.exec(lines[i]))) {
697
+ var element = {
698
+ 'line': +parts[1],
699
+ 'column': +parts[2],
700
+ 'func': parts[3] || parts[4],
701
+ 'args': parts[5] ? parts[5].split(',') : [],
702
+ 'url': parts[6]
703
+ };
704
+
705
+ if (!element.func && element.line) {
706
+ element.func = guessFunctionName(element.url, element.line);
707
+ }
708
+ if (element.line) {
709
+ try {
710
+ element.context = gatherContext(element.url, element.line);
711
+ } catch (exc) {}
712
+ }
713
+
714
+ if (!element.context) {
715
+ element.context = [lines[i + 1]];
716
+ }
717
+
718
+ stack.push(element);
719
+ }
720
+ }
721
+
722
+ if (!stack.length) {
723
+ return null;
724
+ }
725
+
726
+ return {
727
+ 'mode': 'stacktrace',
728
+ 'name': ex.name,
729
+ 'message': ex.message,
730
+ 'url': document.location.href,
731
+ 'stack': stack,
732
+ 'useragent': navigator.userAgent
733
+ };
734
+ }
735
+
736
+ /**
737
+ * NOT TESTED.
738
+ * Computes stack trace information from an error message that includes
739
+ * the stack trace.
740
+ * Opera 9 and earlier use this method if the option to show stack
741
+ * traces is turned on in opera:config.
742
+ * @param {Error} ex
743
+ * @return {?Object.<string, *>} Stack information.
744
+ */
745
+ function computeStackTraceFromOperaMultiLineMessage(ex) {
746
+ // Opera includes a stack trace into the exception message. An example is:
747
+ //
748
+ // Statement on line 3: Undefined variable: undefinedFunc
749
+ // Backtrace:
750
+ // Line 3 of linked script file://localhost/Users/andreyvit/Projects/TraceKit/javascript-client/sample.js: In function zzz
751
+ // undefinedFunc(a);
752
+ // Line 7 of inline#1 script in file://localhost/Users/andreyvit/Projects/TraceKit/javascript-client/sample.html: In function yyy
753
+ // zzz(x, y, z);
754
+ // Line 3 of inline#1 script in file://localhost/Users/andreyvit/Projects/TraceKit/javascript-client/sample.html: In function xxx
755
+ // yyy(a, a, a);
756
+ // Line 1 of function script
757
+ // try { xxx('hi'); return false; } catch(ex) { TraceKit.report(ex); }
758
+ // ...
759
+
760
+ var lines = ex.message.split('\n');
761
+ if (lines.length < 4) {
762
+ return null;
763
+ }
764
+
765
+ var lineRE1 = /^\s*Line (\d+) of linked script ((?:file|http|https)\S+)(?:: in function (\S+))?\s*$/i,
766
+ lineRE2 = /^\s*Line (\d+) of inline#(\d+) script in ((?:file|http|https)\S+)(?:: in function (\S+))?\s*$/i,
767
+ lineRE3 = /^\s*Line (\d+) of function script\s*$/i,
768
+ stack = [],
769
+ scripts = document.getElementsByTagName('script'),
770
+ inlineScriptBlocks = [],
771
+ parts,
772
+ i,
773
+ len,
774
+ source;
775
+
776
+ for (i in scripts) {
777
+ if (_has(scripts, i) && !scripts[i].src) {
778
+ inlineScriptBlocks.push(scripts[i]);
779
+ }
780
+ }
781
+
782
+ for (i = 2, len = lines.length; i < len; i += 2) {
783
+ var item = null;
784
+ if ((parts = lineRE1.exec(lines[i]))) {
785
+ item = {
786
+ 'url': parts[2],
787
+ 'func': parts[3],
788
+ 'line': +parts[1]
789
+ };
790
+ } else if ((parts = lineRE2.exec(lines[i]))) {
791
+ item = {
792
+ 'url': parts[3],
793
+ 'func': parts[4]
794
+ };
795
+ var relativeLine = (+parts[1]); // relative to the start of the <SCRIPT> block
796
+ var script = inlineScriptBlocks[parts[2] - 1];
797
+ if (script) {
798
+ source = getSource(item.url);
799
+ if (source) {
800
+ source = source.join('\n');
801
+ var pos = source.indexOf(script.innerText);
802
+ if (pos >= 0) {
803
+ item.line = relativeLine + source.substring(0, pos).split('\n').length;
804
+ }
805
+ }
806
+ }
807
+ } else if ((parts = lineRE3.exec(lines[i]))) {
808
+ var url = window.location.href.replace(/#.*$/, ''),
809
+ line = parts[1];
810
+ var re = new RegExp(escapeCodeAsRegExpForMatchingInsideHTML(lines[i + 1]));
811
+ source = findSourceInUrls(re, [url]);
812
+ item = {
813
+ 'url': url,
814
+ 'line': source ? source.line : line,
815
+ 'func': ''
816
+ };
817
+ }
818
+
819
+ if (item) {
820
+ if (!item.func) {
821
+ item.func = guessFunctionName(item.url, item.line);
822
+ }
823
+ var context = gatherContext(item.url, item.line);
824
+ var midline = (context ? context[Math.floor(context.length / 2)] : null);
825
+ if (context && midline.replace(/^\s*/, '') === lines[i + 1].replace(/^\s*/, '')) {
826
+ item.context = context;
827
+ } else {
828
+ // if (context) alert("Context mismatch. Correct midline:\n" + lines[i+1] + "\n\nMidline:\n" + midline + "\n\nContext:\n" + context.join("\n") + "\n\nURL:\n" + item.url);
829
+ item.context = [lines[i + 1]];
830
+ }
831
+ stack.push(item);
832
+ }
833
+ }
834
+ if (!stack.length) {
835
+ return null; // could not parse multiline exception message as Opera stack trace
836
+ }
837
+
838
+ return {
839
+ 'mode': 'multiline',
840
+ 'name': ex.name,
841
+ 'message': lines[0],
842
+ 'url': document.location.href,
843
+ 'stack': stack,
844
+ 'useragent': navigator.userAgent
845
+ };
846
+ }
847
+
848
+ /**
849
+ * Adds information about the first frame to incomplete stack traces.
850
+ * Safari and IE require this to get complete data on the first frame.
851
+ * @param {Object.<string, *>} stackInfo Stack trace information from
852
+ * one of the compute* methods.
853
+ * @param {string} url The URL of the script that caused an error.
854
+ * @param {(number|string)} lineNo The line number of the script that
855
+ * caused an error.
856
+ * @param {string=} message The error generated by the browser, which
857
+ * hopefully contains the name of the object that caused the error.
858
+ * @return {boolean} Whether or not the stack information was
859
+ * augmented.
860
+ */
861
+ function augmentStackTraceWithInitialElement(stackInfo, url, lineNo, message) {
862
+ var initial = {
863
+ 'url': url,
864
+ 'line': lineNo
865
+ };
866
+
867
+ if (initial.url && initial.line) {
868
+ stackInfo.incomplete = false;
869
+
870
+ if (!initial.func) {
871
+ initial.func = guessFunctionName(initial.url, initial.line);
872
+ }
873
+
874
+ if (!initial.context) {
875
+ initial.context = gatherContext(initial.url, initial.line);
876
+ }
877
+
878
+ var reference = / '([^']+)' /.exec(message);
879
+ if (reference) {
880
+ initial.column = findSourceInLine(reference[1], initial.url, initial.line);
881
+ }
882
+
883
+ if (stackInfo.stack.length > 0) {
884
+ if (stackInfo.stack[0].url === initial.url) {
885
+ if (stackInfo.stack[0].line === initial.line) {
886
+ return false; // already in stack trace
887
+ } else if (!stackInfo.stack[0].line && stackInfo.stack[0].func === initial.func) {
888
+ stackInfo.stack[0].line = initial.line;
889
+ stackInfo.stack[0].context = initial.context;
890
+ return false;
891
+ }
892
+ }
893
+ }
894
+
895
+ stackInfo.stack.unshift(initial);
896
+ stackInfo.partial = true;
897
+ return true;
898
+ } else {
899
+ stackInfo.incomplete = true;
900
+ }
901
+
902
+ return false;
903
+ }
904
+
905
+ /**
906
+ * Computes stack trace information by walking the arguments.caller
907
+ * chain at the time the exception occurred. This will cause earlier
908
+ * frames to be missed but is the only way to get any stack trace in
909
+ * Safari and IE. The top frame is restored by
910
+ * {@link augmentStackTraceWithInitialElement}.
911
+ * @param {Error} ex
912
+ * @return {?Object.<string, *>} Stack trace information.
913
+ */
914
+ function computeStackTraceByWalkingCallerChain(ex, depth) {
915
+ var functionName = /function\s+([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)?\s*\(/i,
916
+ stack = [],
917
+ funcs = {},
918
+ recursion = false,
919
+ parts,
920
+ item,
921
+ source;
922
+
923
+ for (var curr = computeStackTraceByWalkingCallerChain.caller; curr && !recursion; curr = curr.caller) {
924
+ if (curr === computeStackTrace || curr === TraceKit.report) {
925
+ // console.log('skipping internal function');
926
+ continue;
927
+ }
928
+
929
+ item = {
930
+ 'url': null,
931
+ 'func': UNKNOWN_FUNCTION,
932
+ 'line': null,
933
+ 'column': null
934
+ };
935
+
936
+ if (curr.name) {
937
+ item.func = curr.name;
938
+ } else if ((parts = functionName.exec(curr.toString()))) {
939
+ item.func = parts[1];
940
+ }
941
+
942
+ if ((source = findSourceByFunctionBody(curr))) {
943
+ item.url = source.url;
944
+ item.line = source.line;
945
+
946
+ if (item.func === UNKNOWN_FUNCTION) {
947
+ item.func = guessFunctionName(item.url, item.line);
948
+ }
949
+
950
+ var reference = / '([^']+)' /.exec(ex.message || ex.description);
951
+ if (reference) {
952
+ item.column = findSourceInLine(reference[1], source.url, source.line);
953
+ }
954
+ }
955
+
956
+ if (funcs['' + curr]) {
957
+ recursion = true;
958
+ }else{
959
+ funcs['' + curr] = true;
960
+ }
961
+
962
+ stack.push(item);
963
+ }
964
+
965
+ if (depth) {
966
+ // console.log('depth is ' + depth);
967
+ // console.log('stack is ' + stack.length);
968
+ stack.splice(0, depth);
969
+ }
970
+
971
+ var result = {
972
+ 'mode': 'callers',
973
+ 'name': ex.name,
974
+ 'message': ex.message,
975
+ 'url': document.location.href,
976
+ 'stack': stack,
977
+ 'useragent': navigator.userAgent
978
+ };
979
+ augmentStackTraceWithInitialElement(result, ex.sourceURL || ex.fileName, ex.line || ex.lineNumber, ex.message || ex.description);
980
+ return result;
981
+ }
982
+
983
+ /**
984
+ * Computes a stack trace for an exception.
985
+ * @param {Error} ex
986
+ * @param {(string|number)=} depth
987
+ */
988
+ function computeStackTrace(ex, depth) {
989
+ var stack = null;
990
+ depth = (depth == null ? 0 : +depth);
991
+
992
+ try {
993
+ // This must be tried first because Opera 10 *destroys*
994
+ // its stacktrace property if you try to access the stack
995
+ // property first!!
996
+ stack = computeStackTraceFromStacktraceProp(ex);
997
+ if (stack) {
998
+ return stack;
999
+ }
1000
+ } catch (e) {
1001
+ if (debug) {
1002
+ throw e;
1003
+ }
1004
+ }
1005
+
1006
+ try {
1007
+ stack = computeStackTraceFromStackProp(ex);
1008
+ if (stack) {
1009
+ return stack;
1010
+ }
1011
+ } catch (e) {
1012
+ if (debug) {
1013
+ throw e;
1014
+ }
1015
+ }
1016
+
1017
+ try {
1018
+ stack = computeStackTraceFromOperaMultiLineMessage(ex);
1019
+ if (stack) {
1020
+ return stack;
1021
+ }
1022
+ } catch (e) {
1023
+ if (debug) {
1024
+ throw e;
1025
+ }
1026
+ }
1027
+
1028
+ try {
1029
+ stack = computeStackTraceByWalkingCallerChain(ex, depth + 1);
1030
+ if (stack) {
1031
+ return stack;
1032
+ }
1033
+ } catch (e) {
1034
+ if (debug) {
1035
+ throw e;
1036
+ }
1037
+ }
1038
+
1039
+ return {
1040
+ 'mode': 'failed'
1041
+ };
1042
+ }
1043
+
1044
+ /**
1045
+ * Logs a stacktrace starting from the previous call and working down.
1046
+ * @param {(number|string)=} depth How many frames deep to trace.
1047
+ * @return {Object.<string, *>} Stack trace information.
1048
+ */
1049
+ function computeStackTraceOfCaller(depth) {
1050
+ depth = (depth == null ? 0 : +depth) + 1; // "+ 1" because "ofCaller" should drop one frame
1051
+ try {
1052
+ throw new Error();
1053
+ } catch (ex) {
1054
+ return computeStackTrace(ex, depth + 1);
1055
+ }
1056
+
1057
+ return null;
1058
+ }
1059
+
1060
+ computeStackTrace.augmentStackTraceWithInitialElement = augmentStackTraceWithInitialElement;
1061
+ computeStackTrace.guessFunctionName = guessFunctionName;
1062
+ computeStackTrace.gatherContext = gatherContext;
1063
+ computeStackTrace.ofCaller = computeStackTraceOfCaller;
1064
+
1065
+ return computeStackTrace;
1066
+ }());
1067
+
1068
+ /**
1069
+ * Extends support for global error handling for asynchronous browser
1070
+ * functions. Adopted from Closure Library's errorhandler.js
1071
+ */
1072
+ (function extendToAsynchronousCallbacks() {
1073
+ var _helper = function _helper(fnName) {
1074
+ var originalFn = window[fnName];
1075
+ window[fnName] = function traceKitAsyncExtension() {
1076
+ // Make a copy of the arguments
1077
+ var args = _slice.call(arguments);
1078
+ var originalCallback = args[0];
1079
+ if (typeof (originalCallback) === 'function') {
1080
+ args[0] = TraceKit.wrap(originalCallback);
1081
+ }
1082
+ // IE < 9 doesn't support .call/.apply on setInterval/setTimeout, but it
1083
+ // also only supports 2 argument and doesn't care what "this" is, so we
1084
+ // can just call the original function directly.
1085
+ if (originalFn.apply) {
1086
+ return originalFn.apply(this, args);
1087
+ } else {
1088
+ return originalFn(args[0], args[1]);
1089
+ }
1090
+ };
1091
+ };
1092
+
1093
+ _helper('setTimeout');
1094
+ _helper('setInterval');
1095
+ }());
1096
+
1097
+ /**
1098
+ * Extended support for backtraces and global error handling for most
1099
+ * asynchronous jQuery functions.
1100
+ */
1101
+ (function traceKitAsyncForjQuery($) {
1102
+
1103
+ // quit if jQuery isn't on the page
1104
+ if (!$) {
1105
+ return;
1106
+ }
1107
+
1108
+ var _oldEventAdd = $.event.add;
1109
+ $.event.add = function traceKitEventAdd(elem, types, handler, data, selector) {
1110
+ var _handler;
1111
+
1112
+ if (handler.handler) {
1113
+ _handler = handler.handler;
1114
+ handler.handler = TraceKit.wrap(handler.handler);
1115
+ } else {
1116
+ _handler = handler;
1117
+ handler = TraceKit.wrap(handler);
1118
+ }
1119
+
1120
+ // If the handler we are attaching doesn’t have the same guid as
1121
+ // the original, it will never be removed when someone tries to
1122
+ // unbind the original function later. Technically as a result of
1123
+ // this our guids are no longer globally unique, but whatever, that
1124
+ // never hurt anybody RIGHT?!
1125
+ if (_handler.guid) {
1126
+ handler.guid = _handler.guid;
1127
+ } else {
1128
+ handler.guid = _handler.guid = $.guid++;
1129
+ }
1130
+
1131
+ return _oldEventAdd.call(this, elem, types, handler, data, selector);
1132
+ };
1133
+
1134
+ var _oldReady = $.fn.ready;
1135
+ $.fn.ready = function traceKitjQueryReadyWrapper(fn) {
1136
+ return _oldReady.call(this, TraceKit.wrap(fn));
1137
+ };
1138
+
1139
+ var _oldAjax = $.ajax;
1140
+ $.ajax = function traceKitAjaxWrapper(url, options) {
1141
+ var keys = ['complete', 'error', 'success'], key;
1142
+
1143
+ // Taken from https://github.com/jquery/jquery/blob/eee2eaf1d7a189d99106423a4206c224ebd5b848/src/ajax.js#L311-L318
1144
+ // If url is an object, simulate pre-1.5 signature
1145
+ if (typeof url === 'object') {
1146
+ options = url;
1147
+ url = undefined;
1148
+ }
1149
+
1150
+ // Force options to be an object
1151
+ options = options || {};
1152
+
1153
+ while(key = keys.pop()) {
1154
+ if ($.isFunction(options[key])) {
1155
+ options[key] = TraceKit.wrap(options[key]);
1156
+ }
1157
+ }
1158
+
1159
+ try {
1160
+ return _oldAjax.call(this, url, options);
1161
+ } catch (e) {
1162
+ TraceKit.report(e);
1163
+ throw e;
1164
+ }
1165
+ };
1166
+
1167
+ }(window.jQuery));
1168
+
1169
+ //Default options:
1170
+ if (!TraceKit.remoteFetching) {
1171
+ TraceKit.remoteFetching = true;
1172
+ }
1173
+ if (!TraceKit.collectWindowErrors) {
1174
+ TraceKit.collectWindowErrors = true;
1175
+ }
1176
+ if (!TraceKit.linesOfContext || TraceKit.linesOfContext < 1) {
1177
+ // 5 lines before, the offending line, 5 lines after
1178
+ TraceKit.linesOfContext = 11;
1179
+ }
1180
+
1181
+
1182
+
1183
+ // Export to global object
1184
+ window.TraceKit = TraceKit;
1185
+
1186
+ }(window));
1187
+ ;(function(window, undefined){
1188
+ 'use strict';
1189
+
1190
+ // First, check for JSON support
1191
+ // If there is no JSON, we no-op the core features of Raven
1192
+ // since JSON is required to encode the payload
1193
+ var _Raven = window.Raven,
1194
+ hasJSON = !isUndefined(window.JSON),
1195
+ globalServer,
1196
+ globalUser,
1197
+ globalKey,
1198
+ globalProject,
1199
+ globalOptions = {
1200
+ logger: 'javascript',
1201
+ ignoreErrors: [],
1202
+ ignoreUrls: []
1203
+ };
1204
+
1205
+ var TK = TraceKit.noConflict();
1206
+
1207
+ // Disable Tracekit's remote fetching by default
1208
+ TK.remoteFetching = false;
1209
+
1210
+ /*
1211
+ * The core Raven singleton
1212
+ *
1213
+ * @this {Raven}
1214
+ */
1215
+ var Raven = {
1216
+ VERSION: '1.0.7',
1217
+
1218
+ /*
1219
+ * Allow multiple versions of Raven to be installed.
1220
+ * Strip Raven from the global context and returns the instance.
1221
+ *
1222
+ * @return {Raven}
1223
+ */
1224
+ noConflict: function() {
1225
+ window.Raven = _Raven;
1226
+ return Raven;
1227
+ },
1228
+
1229
+ /*
1230
+ * Configure Raven with a DSN and extra options
1231
+ *
1232
+ * @param {string} dsn The public Sentry DSN
1233
+ * @param {object} options Optional set of of global options [optional]
1234
+ * @return {Raven}
1235
+ */
1236
+ config: function(dsn, options) {
1237
+ var uri = parseUri(dsn),
1238
+ lastSlash = uri.path.lastIndexOf('/'),
1239
+ path = uri.path.substr(1, lastSlash);
1240
+
1241
+ if (options && options.ignoreErrors && window.console && console.warn) {
1242
+ console.warn('DeprecationWarning: `ignoreErrors` is going to be removed soon.');
1243
+ }
1244
+
1245
+ // merge in options
1246
+ if (options) {
1247
+ each(options, function(key, value){
1248
+ globalOptions[key] = value;
1249
+ });
1250
+ }
1251
+
1252
+ // "Script error." is hard coded into browsers for errors that it can't read.
1253
+ // this is the result of a script being pulled in from an external domain and CORS.
1254
+ globalOptions.ignoreErrors.push('Script error.');
1255
+
1256
+ globalKey = uri.user;
1257
+ globalProject = ~~uri.path.substr(lastSlash + 1);
1258
+
1259
+ // assemble the endpoint from the uri pieces
1260
+ globalServer = '//' + uri.host +
1261
+ (uri.port ? ':' + uri.port : '') +
1262
+ '/' + path + 'api/' + globalProject + '/store/';
1263
+
1264
+ if (uri.protocol) {
1265
+ globalServer = uri.protocol + ':' + globalServer;
1266
+ }
1267
+
1268
+ if (globalOptions.fetchContext) {
1269
+ TK.remoteFetching = true;
1270
+ }
1271
+
1272
+ // return for chaining
1273
+ return Raven;
1274
+ },
1275
+
1276
+ /*
1277
+ * Installs a global window.onerror error handler
1278
+ * to capture and report uncaught exceptions.
1279
+ * At this point, install() is required to be called due
1280
+ * to the way TraceKit is set up.
1281
+ *
1282
+ * @return {Raven}
1283
+ */
1284
+ install: function() {
1285
+ if (!isSetup()) return;
1286
+
1287
+ TK.report.subscribe(handleStackInfo);
1288
+
1289
+ return Raven;
1290
+ },
1291
+
1292
+ /*
1293
+ * Wrap code within a context so Raven can capture errors
1294
+ * reliably across domains that is executed immediately.
1295
+ *
1296
+ * @param {object} options A specific set of options for this context [optional]
1297
+ * @param {function} func The callback to be immediately executed within the context
1298
+ * @param {array} args An array of arguments to be called with the callback [optional]
1299
+ */
1300
+ context: function(options, func, args) {
1301
+ if (isFunction(options)) {
1302
+ args = func || [];
1303
+ func = options;
1304
+ options = undefined;
1305
+ }
1306
+
1307
+ Raven.wrap(options, func).apply(this, args);
1308
+ },
1309
+
1310
+ /*
1311
+ * Wrap code within a context and returns back a new function to be executed
1312
+ *
1313
+ * @param {object} options A specific set of options for this context [optional]
1314
+ * @param {function} func The function to be wrapped in a new context
1315
+ * @return {function} The newly wrapped functions with a context
1316
+ */
1317
+ wrap: function(options, func) {
1318
+ // options is optional
1319
+ if (isFunction(options)) {
1320
+ func = options;
1321
+ options = undefined;
1322
+ }
1323
+
1324
+ return function() {
1325
+ try {
1326
+ func.apply(this, arguments);
1327
+ } catch(e) {
1328
+ Raven.captureException(e, options);
1329
+ throw e;
1330
+ }
1331
+ };
1332
+ },
1333
+
1334
+ /*
1335
+ * Uninstalls the global error handler.
1336
+ *
1337
+ * @return {Raven}
1338
+ */
1339
+ uninstall: function() {
1340
+ TK.report.unsubscribe(handleStackInfo);
1341
+
1342
+ return Raven;
1343
+ },
1344
+
1345
+ /*
1346
+ * Manually capture an exception and send it over to Sentry
1347
+ *
1348
+ * @param {error} ex An exception to be logged
1349
+ * @param {object} options A specific set of options for this error [optional]
1350
+ * @return {Raven}
1351
+ */
1352
+ captureException: function(ex, options) {
1353
+ // If a string is passed through, recall as a message
1354
+ if (typeof ex === 'string') {
1355
+ return Raven.captureMessage(ex, options);
1356
+ }
1357
+
1358
+ // TraceKit.report will re-raise any exception passed to it,
1359
+ // which means you have to wrap it in try/catch. Instead, we
1360
+ // can wrap it here and only re-raise if TraceKit.report
1361
+ // raises an exception different from the one we asked to
1362
+ // report on.
1363
+ try {
1364
+ TK.report(ex, options);
1365
+ } catch(ex1) {
1366
+ if(ex !== ex1) {
1367
+ throw ex1;
1368
+ }
1369
+ }
1370
+
1371
+ return Raven;
1372
+ },
1373
+
1374
+ /*
1375
+ * Manually send a message to Sentry
1376
+ *
1377
+ * @param {string} msg A plain message to be captured in Sentry
1378
+ * @param {object} options A specific set of options for this message [optional]
1379
+ * @return {Raven}
1380
+ */
1381
+ captureMessage: function(msg, options) {
1382
+ // Fire away!
1383
+ send(
1384
+ arrayMerge({
1385
+ message: msg
1386
+ }, options)
1387
+ );
1388
+
1389
+ return Raven;
1390
+ },
1391
+
1392
+ /*
1393
+ * Set/clear a user to be sent along with the payload.
1394
+ *
1395
+ * @param {object} user An object representing user data [optional]
1396
+ * @return {Raven}
1397
+ */
1398
+ setUser: function(user) {
1399
+ globalUser = user;
1400
+
1401
+ return Raven;
1402
+ }
1403
+ };
1404
+
1405
+ var uriKeys = 'source protocol authority userInfo user password host port relative path directory file query anchor'.split(' '),
1406
+ uriPattern = /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
1407
+
1408
+ /**** Private functions ****/
1409
+ function parseUri(str) {
1410
+ var m = uriPattern.exec(str),
1411
+ uri = {},
1412
+ i = 14;
1413
+
1414
+ while (i--) uri[uriKeys[i]] = m[i] || '';
1415
+
1416
+ return uri;
1417
+ }
1418
+
1419
+ function isUndefined(what) {
1420
+ return typeof what === 'undefined';
1421
+ }
1422
+
1423
+ function isFunction(what) {
1424
+ return typeof what === 'function';
1425
+ }
1426
+
1427
+ function each(obj, callback) {
1428
+ var i, j;
1429
+
1430
+ if (isUndefined(obj.length)) {
1431
+ for (i in obj) {
1432
+ if (obj.hasOwnProperty(i)) {
1433
+ callback.call(null, i, obj[i]);
1434
+ }
1435
+ }
1436
+ } else {
1437
+ for (i = 0, j = obj.length; i < j; i++) {
1438
+ callback.call(null, i, obj[i]);
1439
+ }
1440
+ }
1441
+ }
1442
+
1443
+ var cachedAuth;
1444
+
1445
+ function getAuthQueryString() {
1446
+ if (cachedAuth) return cachedAuth;
1447
+
1448
+ var qs = [
1449
+ 'sentry_version=2.0',
1450
+ 'sentry_client=raven-js/' + Raven.VERSION
1451
+ ];
1452
+ if (globalKey) {
1453
+ qs.push('sentry_key=' + globalKey);
1454
+ }
1455
+
1456
+ cachedAuth = '?' + qs.join('&');
1457
+ return cachedAuth;
1458
+ }
1459
+
1460
+ function handleStackInfo(stackInfo, options) {
1461
+ var frames = [],
1462
+ i = 0,
1463
+ j, frame;
1464
+
1465
+ if (stackInfo.stack && (j = stackInfo.stack.length)) {
1466
+ for (; i < j; i++) {
1467
+ frame = normalizeFrame(stackInfo.stack[i]);
1468
+ if (frame) {
1469
+ frames.push(frame);
1470
+ }
1471
+ }
1472
+ }
1473
+
1474
+ processException(
1475
+ stackInfo.name,
1476
+ stackInfo.message,
1477
+ stackInfo.url,
1478
+ stackInfo.lineno,
1479
+ frames,
1480
+ options
1481
+ );
1482
+ }
1483
+
1484
+ function normalizeFrame(frame) {
1485
+ if (!frame.url) return;
1486
+
1487
+ // normalize the frames data
1488
+ var normalized = {
1489
+ filename: frame.url,
1490
+ lineno: frame.line,
1491
+ colno: frame.column,
1492
+ 'function': frame.func || '?'
1493
+ }, context = extractContextFromFrame(frame);
1494
+
1495
+ if (context) {
1496
+ var i = 3, keys = ['pre_context', 'context_line', 'post_context'];
1497
+ while (i--) normalized[keys[i]] = context[i];
1498
+ }
1499
+
1500
+ normalized.in_app = !/(Raven|TraceKit)\./.test(normalized['function']);
1501
+
1502
+ return normalized;
1503
+ }
1504
+
1505
+ function extractContextFromFrame(frame) {
1506
+ // immediately check if we should even attempt to parse a context
1507
+ if (!frame.context || !globalOptions.fetchContext) return;
1508
+
1509
+ var context = frame.context,
1510
+ pivot = ~~(context.length / 2),
1511
+ i = context.length, isMinified = false;
1512
+
1513
+ while (i--) {
1514
+ // We're making a guess to see if the source is minified or not.
1515
+ // To do that, we make the assumption if *any* of the lines passed
1516
+ // in are greater than 300 characters long, we bail.
1517
+ // Sentry will see that there isn't a context
1518
+ if (context[i].length > 300) {
1519
+ isMinified = true;
1520
+ break;
1521
+ }
1522
+ }
1523
+
1524
+ if (isMinified) {
1525
+ // The source is minified and we don't know which column. Fuck it.
1526
+ if (isUndefined(frame.column)) return;
1527
+
1528
+ // If the source is minified and has a frame column
1529
+ // we take a chunk of the offending line to hopefully shed some light
1530
+ return [
1531
+ [], // no pre_context
1532
+ context[pivot].substr(frame.column, 50), // grab 50 characters, starting at the offending column
1533
+ [] // no post_context
1534
+ ];
1535
+ }
1536
+
1537
+ return [
1538
+ context.slice(0, pivot), // pre_context
1539
+ context[pivot], // context_line
1540
+ context.slice(pivot + 1) // post_context
1541
+ ];
1542
+ }
1543
+
1544
+ function processException(type, message, fileurl, lineno, frames, options) {
1545
+ var stacktrace, label, i;
1546
+
1547
+ // IE8 really doesn't have Array.prototype.indexOf
1548
+ // Filter out a message that matches our ignore list
1549
+ i = globalOptions.ignoreErrors.length;
1550
+ while (i--) {
1551
+ if (message === globalOptions.ignoreErrors[i]) {
1552
+ return;
1553
+ }
1554
+ }
1555
+
1556
+ if (frames && frames.length) {
1557
+ stacktrace = {frames: frames};
1558
+ fileurl = fileurl || frames[0].filename;
1559
+ } else if (fileurl) {
1560
+ stacktrace = {
1561
+ frames: [{
1562
+ filename: fileurl,
1563
+ lineno: lineno
1564
+ }]
1565
+ };
1566
+ }
1567
+
1568
+ i = globalOptions.ignoreUrls.length;
1569
+ while (i--) {
1570
+ if (globalOptions.ignoreUrls[i].test(fileurl)) {
1571
+ return;
1572
+ }
1573
+ }
1574
+
1575
+ label = lineno ? message + ' at ' + lineno : message;
1576
+
1577
+ // Fire away!
1578
+ send(
1579
+ arrayMerge({
1580
+ 'sentry.interfaces.Exception': {
1581
+ type: type,
1582
+ value: message
1583
+ },
1584
+ 'sentry.interfaces.Stacktrace': stacktrace,
1585
+ culprit: fileurl,
1586
+ message: label
1587
+ }, options)
1588
+ );
1589
+ }
1590
+
1591
+ function arrayMerge(arr1, arr2) {
1592
+ if (!arr2) {
1593
+ return arr1;
1594
+ }
1595
+ each(arr2, function(key, value){
1596
+ arr1[key] = value;
1597
+ });
1598
+ return arr1;
1599
+ }
1600
+
1601
+ function getHttpData() {
1602
+ var http = {
1603
+ url: window.location.href,
1604
+ headers: {
1605
+ 'User-Agent': navigator.userAgent
1606
+ }
1607
+ };
1608
+
1609
+ if (window.document.referrer) {
1610
+ http.headers.Referer = window.document.referrer;
1611
+ }
1612
+
1613
+ return http;
1614
+ }
1615
+
1616
+ function send(data) {
1617
+ if (!isSetup()) return;
1618
+
1619
+ data = arrayMerge({
1620
+ project: globalProject,
1621
+ logger: globalOptions.logger,
1622
+ site: globalOptions.site,
1623
+ platform: 'javascript',
1624
+ 'sentry.interfaces.Http': getHttpData()
1625
+ }, data);
1626
+
1627
+ if (globalUser) data['sentry.interfaces.User'] = globalUser;
1628
+
1629
+ if (isFunction(globalOptions.dataCallback)) {
1630
+ data = globalOptions.dataCallback(data);
1631
+ }
1632
+
1633
+ makeRequest(data);
1634
+ }
1635
+
1636
+ function makeRequest(data) {
1637
+ new Image().src = globalServer + getAuthQueryString() + '&sentry_data=' + encodeURIComponent(JSON.stringify(data));
1638
+ }
1639
+
1640
+ function isSetup() {
1641
+ if (!hasJSON) return false; // needs JSON support
1642
+ if (!globalServer) {
1643
+ if (window.console && console.error) {
1644
+ console.error("Error: Raven has not been configured.");
1645
+ }
1646
+ return false;
1647
+ }
1648
+ return true;
1649
+ }
1650
+
1651
+ // Expose Raven to the world
1652
+ window.Raven = Raven;
1653
+
1654
+ // AMD
1655
+ if (typeof define === 'function' && define.amd) {
1656
+ define(function() { return Raven; });
1657
+ }
1658
+
1659
+ })(window);