History

Update Raven.js

Thibaut Courouble committed 9 years ago

Commit 68c03081 parent 26132681 file · +83 −25Browse files

Unified · Split

assets/javascripts/vendor/raven.js+83−25
@@ -1,4 +1,4 @@
1−/*! Raven.js 3.14.2 (5cf57e1) | github.com/getsentry/raven-js */
1+/*! Raven.js 3.17.0 (6384830) | github.com/getsentry/raven-js */
22
33 /*
44 * Includes TraceKit
@@ -91,6 +91,13 @@ var _window = typeof window !== 'undefined' ? window · 86 unmodified lines
9191 var _document = _window.document;
9292 var _navigator = _window.navigator;
9393
94+
95+function keepOriginalCallback(original, callback) {
96+ return isFunction(callback) ?
97+ function (data) { return callback(data, original) } :
98+ callback;
99+}
100+
94101 // First, check for JSON support
95102 // If there is no JSON, we no-op the core features of Raven
96103 // since JSON is required to encode the payload
@@ -120,6 +127,7 @@ function Raven() { · 23 unmodified lines
120127 maxUrlLength: 250,
121128 stackTraceLimit: 50,
122129 autoBreadcrumbs: true,
130+ instrument: true,
123131 sampleRate: 1
124132 };
125133 this._ignoreOnError = 0;
@@ -155,7 +163,7 @@ Raven.prototype = { · 29 unmodified lines
155163 // webpack (using a build step causes webpack #1617). Grunt verifies that
156164 // this value matches package.json during build.
157165 // See: https://github.com/getsentry/raven-js/issues/465
158− VERSION: '3.14.2',
166+ VERSION: '3.17.0',
159167
160168 debug: false,
161169
@@ -220,6 +228,18 @@ Raven.prototype = { · 58 unmodified lines
220228 }
221229 globalOptions.autoBreadcrumbs = autoBreadcrumbs;
222230
231+ var instrumentDefaults = {
232+ tryCatch: true
233+ };
234+
235+ var instrument = globalOptions.instrument;
236+ if ({}.toString.call(instrument) === '[object Object]') {
237+ instrument = objectMerge(instrumentDefaults, instrument);
238+ } else if (instrument !== false) {
239+ instrument = instrumentDefaults;
240+ }
241+ globalOptions.instrument = instrument;
242+
223243 TraceKit.collectWindowErrors = !!globalOptions.collectWindowErrors;
224244
225245 // return for chaining
@@ -240,7 +260,10 @@ Raven.prototype = { · 14 unmodified lines
240260 TraceKit.report.subscribe(function () {
241261 self._handleOnErrorStackInfo.apply(self, arguments);
242262 });
243− self._instrumentTryCatch();
263+ if (self._globalOptions.instrument && self._globalOptions.instrument.tryCatch) {
264+ self._instrumentTryCatch();
265+ }
266+
244267 if (self._globalOptions.autoBreadcrumbs)
245268 self._instrumentBreadcrumbs();
246269
@@ -622,10 +645,8 @@ Raven.prototype = { · 375 unmodified lines
622645 */
623646 setDataCallback: function(callback) {
624647 var original = this._globalOptions.dataCallback;
625− this._globalOptions.dataCallback = isFunction(callback)
626− ? function (data) { return callback(data, original); }
627− : callback;
628−
648+ this._globalOptions.dataCallback =
649+ keepOriginalCallback(original, callback);
629650 return this;
630651 },
631652
@@ -638,10 +659,8 @@ Raven.prototype = { · 6 unmodified lines
638659 */
639660 setBreadcrumbCallback: function(callback) {
640661 var original = this._globalOptions.breadcrumbCallback;
641− this._globalOptions.breadcrumbCallback = isFunction(callback)
642− ? function (data) { return callback(data, original); }
643− : callback;
644−
662+ this._globalOptions.breadcrumbCallback =
663+ keepOriginalCallback(original, callback);
645664 return this;
646665 },
647666
@@ -654,10 +673,8 @@ Raven.prototype = { · 6 unmodified lines
654673 */
655674 setShouldSendCallback: function(callback) {
656675 var original = this._globalOptions.shouldSendCallback;
657− this._globalOptions.shouldSendCallback = isFunction(callback)
658− ? function (data) { return callback(data, original); }
659− : callback;
660−
676+ this._globalOptions.shouldSendCallback =
677+ keepOriginalCallback(original, callback);
661678 return this;
662679 },
663680
@@ -918,7 +935,8 @@ Raven.prototype = { · 254 unmodified lines
918935 },
919936
920937 /**
921− * Install any queued plugins
938+ * Wrap timer functions and event targets to catch errors and provide
939+ * better metadata.
922940 */
923941 _instrumentTryCatch: function() {
924942 var self = this;
@@ -1116,11 +1134,22 @@ Raven.prototype = { · 191 unmodified lines
11161134 // Make a copy of the arguments to prevent deoptimization
11171135 // https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#32-leaking-arguments
11181136 var args = new Array(arguments.length);
1119− for(var i = 0; i < args.length; ++i) {
1137+ for (var i = 0; i < args.length; ++i) {
11201138 args[i] = arguments[i];
11211139 }
11221140
1141+ var fetchInput = args[0];
11231142 var method = 'GET';
1143+ var url;
1144+
1145+ if (typeof fetchInput === 'string') {
1146+ url = fetchInput;
1147+ } else {
1148+ url = fetchInput.url;
1149+ if (fetchInput.method) {
1150+ method = fetchInput.method;
1151+ }
1152+ }
11241153
11251154 if (args[1] && args[1].method) {
11261155 method = args[1].method;
@@ -1128,7 +1157,7 @@ Raven.prototype = { · 1 unmodified line
11281157
11291158 var fetchData = {
11301159 method: method,
1131− url: args[0],
1160+ url: url,
11321161 status_code: null
11331162 };
11341163
@@ -1421,16 +1450,17 @@ Raven.prototype = { · 286 unmodified lines
14211450
14221451 for (var i = 0; i < breadcrumbs.values.length; ++i) {
14231452 crumb = breadcrumbs.values[i];
1424− if (!crumb.hasOwnProperty('data') || !isObject(crumb.data))
1453+ if (!crumb.hasOwnProperty('data') || !isObject(crumb.data) || objectFrozen(crumb.data))
14251454 continue;
14261455
1427− data = crumb.data;
1456+ data = objectMerge({}, crumb.data);
14281457 for (var j = 0; j < urlProps.length; ++j) {
14291458 urlProp = urlProps[j];
14301459 if (data.hasOwnProperty(urlProp)) {
14311460 data[urlProp] = truncate(data[urlProp], this._globalOptions.maxUrlLength);
14321461 }
14331462 }
1463+ breadcrumbs.values[i].data = data;
14341464 }
14351465 },
14361466
@@ -1815,6 +1845,21 @@ function objectMerge(obj1, obj2) { · 378 unmodified lines
18151845 return obj1;
18161846 }
18171847
1848+/**
1849+ * This function is only used for react-native.
1850+ * react-native freezes object that have already been sent over the
1851+ * js bridge. We need this function in order to check if the object is frozen.
1852+ * So it's ok that objectFrozen returns false if Object.isFrozen is not
1853+ * supported because it's not relevant for other "platforms". See related issue:
1854+ * https://github.com/getsentry/react-native-sentry/issues/57
1855+ */
1856+function objectFrozen(obj) {
1857+ if (!Object.isFrozen) {
1858+ return false;
1859+ }
1860+ return Object.isFrozen(obj);
1861+}
1862+
18181863 function truncate(str, max) {
18191864 return !max || str.length <= max ? str : str.substr(0, max) + '\u2026';
18201865 }
@@ -2113,8 +2158,8 @@ var Raven = new RavenConstructor(); · 292 unmodified lines
21132158 * @return {Raven}
21142159 */
21152160 Raven.noConflict = function () {
2116− _window.Raven = _Raven;
2117− return Raven;
2161+ _window.Raven = _Raven;
2162+ return Raven;
21182163 };
21192164
21202165 Raven.afterLoad();
@@ -2140,9 +2185,22 @@ function isError(value) { · 19 unmodified lines
21402185 }
21412186 }
21422187
2188+function wrappedCallback(callback) {
2189+ function dataCallback(data, original) {
2190+ var normalizedData = callback(data) || data;
2191+ if (original) {
2192+ return original(normalizedData) || normalizedData;
2193+ }
2194+ return normalizedData;
2195+ }
2196+
2197+ return dataCallback;
2198+}
2199+
21432200 module.exports = {
21442201 isObject: isObject,
2145− isError: isError
2202+ isError: isError,
2203+ wrappedCallback: wrappedCallback
21462204 };
21472205
21482206 },{}],6:[function(_dereq_,module,exports){
@@ -2519,7 +2577,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() { · 370 unmodified lines
25192577 if (typeof ex.stack === 'undefined' || !ex.stack) return;
25202578
25212579 var chrome = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,
2522− gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?)(?::(\d+))?(?::(\d+))?\s*$/i,
2580+ gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,
25232581 winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,
25242582
25252583 // Used to additionally parse URL/line/column from eval frames
@@ -2813,4 +2871,4 @@ function serializer(replacer, cycleReplacer) { · 287 unmodified lines
28132871 }
28142872
28152873 },{}]},{},[4])(4)
2816−});
2874+});