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 */
2 2
3/*3/*
4 * Includes TraceKit4 * Includes TraceKit
@@ -91,6 +91,13 @@ var _window = typeof window !== 'undefined' ? window · 86 unmodified lines
91var _document = _window.document;91var _document = _window.document;
92var _navigator = _window.navigator;92var _navigator = _window.navigator;
93 93
94
95function keepOriginalCallback(original, callback) {
96 return isFunction(callback) ?
97 function (data) { return callback(data, original) } :
98 callback;
99}
100
94// First, check for JSON support101// First, check for JSON support
95// If there is no JSON, we no-op the core features of Raven102// If there is no JSON, we no-op the core features of Raven
96// since JSON is required to encode the payload103// since JSON is required to encode the payload
@@ -120,6 +127,7 @@ function Raven() { · 23 unmodified lines
120 maxUrlLength: 250,127 maxUrlLength: 250,
121 stackTraceLimit: 50,128 stackTraceLimit: 50,
122 autoBreadcrumbs: true,129 autoBreadcrumbs: true,
130 instrument: true,
123 sampleRate: 1131 sampleRate: 1
124 };132 };
125 this._ignoreOnError = 0;133 this._ignoreOnError = 0;
@@ -155,7 +163,7 @@ Raven.prototype = { · 29 unmodified lines
155 // webpack (using a build step causes webpack #1617). Grunt verifies that163 // webpack (using a build step causes webpack #1617). Grunt verifies that
156 // this value matches package.json during build.164 // this value matches package.json during build.
157 // See: https://github.com/getsentry/raven-js/issues/465165 // See: https://github.com/getsentry/raven-js/issues/465
158 VERSION: '3.14.2',166 VERSION: '3.17.0',
159 167
160 debug: false,168 debug: false,
161 169
@@ -220,6 +228,18 @@ Raven.prototype = { · 58 unmodified lines
220 }228 }
221 globalOptions.autoBreadcrumbs = autoBreadcrumbs;229 globalOptions.autoBreadcrumbs = autoBreadcrumbs;
222 230
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
223 TraceKit.collectWindowErrors = !!globalOptions.collectWindowErrors;243 TraceKit.collectWindowErrors = !!globalOptions.collectWindowErrors;
224 244
225 // return for chaining245 // return for chaining
@@ -240,7 +260,10 @@ Raven.prototype = { · 14 unmodified lines
240 TraceKit.report.subscribe(function () {260 TraceKit.report.subscribe(function () {
241 self._handleOnErrorStackInfo.apply(self, arguments);261 self._handleOnErrorStackInfo.apply(self, arguments);
242 });262 });
243 self._instrumentTryCatch();263 if (self._globalOptions.instrument && self._globalOptions.instrument.tryCatch) {
264 self._instrumentTryCatch();
265 }
266
244 if (self._globalOptions.autoBreadcrumbs)267 if (self._globalOptions.autoBreadcrumbs)
245 self._instrumentBreadcrumbs();268 self._instrumentBreadcrumbs();
246 269
@@ -622,10 +645,8 @@ Raven.prototype = { · 375 unmodified lines
622 */645 */
623 setDataCallback: function(callback) {646 setDataCallback: function(callback) {
624 var original = this._globalOptions.dataCallback;647 var original = this._globalOptions.dataCallback;
625 this._globalOptions.dataCallback = isFunction(callback)648 this._globalOptions.dataCallback =
626 ? function (data) { return callback(data, original); }649 keepOriginalCallback(original, callback);
627 : callback;
628
629 return this;650 return this;
630 },651 },
631 652
@@ -638,10 +659,8 @@ Raven.prototype = { · 6 unmodified lines
638 */659 */
639 setBreadcrumbCallback: function(callback) {660 setBreadcrumbCallback: function(callback) {
640 var original = this._globalOptions.breadcrumbCallback;661 var original = this._globalOptions.breadcrumbCallback;
641 this._globalOptions.breadcrumbCallback = isFunction(callback)662 this._globalOptions.breadcrumbCallback =
642 ? function (data) { return callback(data, original); }663 keepOriginalCallback(original, callback);
643 : callback;
644
645 return this;664 return this;
646 },665 },
647 666
@@ -654,10 +673,8 @@ Raven.prototype = { · 6 unmodified lines
654 */673 */
655 setShouldSendCallback: function(callback) {674 setShouldSendCallback: function(callback) {
656 var original = this._globalOptions.shouldSendCallback;675 var original = this._globalOptions.shouldSendCallback;
657 this._globalOptions.shouldSendCallback = isFunction(callback)676 this._globalOptions.shouldSendCallback =
658 ? function (data) { return callback(data, original); }677 keepOriginalCallback(original, callback);
659 : callback;
660
661 return this;678 return this;
662 },679 },
663 680
@@ -918,7 +935,8 @@ Raven.prototype = { · 254 unmodified lines
918 },935 },
919 936
920 /**937 /**
921 * Install any queued plugins938 * Wrap timer functions and event targets to catch errors and provide
939 * better metadata.
922 */940 */
923 _instrumentTryCatch: function() {941 _instrumentTryCatch: function() {
924 var self = this;942 var self = this;
@@ -1116,11 +1134,22 @@ Raven.prototype = { · 191 unmodified lines
1116 // Make a copy of the arguments to prevent deoptimization1134 // Make a copy of the arguments to prevent deoptimization
1117 // https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#32-leaking-arguments1135 // https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#32-leaking-arguments
1118 var args = new Array(arguments.length);1136 var args = new Array(arguments.length);
1119 for(var i = 0; i < args.length; ++i) {1137 for (var i = 0; i < args.length; ++i) {
1120 args[i] = arguments[i];1138 args[i] = arguments[i];
1121 }1139 }
1122 1140
1141 var fetchInput = args[0];
1123 var method = 'GET';1142 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 }
1124 1153
1125 if (args[1] && args[1].method) {1154 if (args[1] && args[1].method) {
1126 method = args[1].method;1155 method = args[1].method;
@@ -1128,7 +1157,7 @@ Raven.prototype = { · 1 unmodified line
1128 1157
1129 var fetchData = {1158 var fetchData = {
1130 method: method,1159 method: method,
1131 url: args[0],1160 url: url,
1132 status_code: null1161 status_code: null
1133 };1162 };
1134 1163
@@ -1421,16 +1450,17 @@ Raven.prototype = { · 286 unmodified lines
1421 1450
1422 for (var i = 0; i < breadcrumbs.values.length; ++i) {1451 for (var i = 0; i < breadcrumbs.values.length; ++i) {
1423 crumb = breadcrumbs.values[i];1452 crumb = breadcrumbs.values[i];
1424 if (!crumb.hasOwnProperty('data') || !isObject(crumb.data))1453 if (!crumb.hasOwnProperty('data') || !isObject(crumb.data) || objectFrozen(crumb.data))
1425 continue;1454 continue;
1426 1455
1427 data = crumb.data;1456 data = objectMerge({}, crumb.data);
1428 for (var j = 0; j < urlProps.length; ++j) {1457 for (var j = 0; j < urlProps.length; ++j) {
1429 urlProp = urlProps[j];1458 urlProp = urlProps[j];
1430 if (data.hasOwnProperty(urlProp)) {1459 if (data.hasOwnProperty(urlProp)) {
1431 data[urlProp] = truncate(data[urlProp], this._globalOptions.maxUrlLength);1460 data[urlProp] = truncate(data[urlProp], this._globalOptions.maxUrlLength);
1432 }1461 }
1433 }1462 }
1463 breadcrumbs.values[i].data = data;
1434 }1464 }
1435 },1465 },
1436 1466
@@ -1815,6 +1845,21 @@ function objectMerge(obj1, obj2) { · 378 unmodified lines
1815 return obj1;1845 return obj1;
1816}1846}
1817 1847
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 */
1856function objectFrozen(obj) {
1857 if (!Object.isFrozen) {
1858 return false;
1859 }
1860 return Object.isFrozen(obj);
1861}
1862
1818function truncate(str, max) {1863function truncate(str, max) {
1819 return !max || str.length <= max ? str : str.substr(0, max) + '\u2026';1864 return !max || str.length <= max ? str : str.substr(0, max) + '\u2026';
1820}1865}
@@ -2113,8 +2158,8 @@ var Raven = new RavenConstructor(); · 292 unmodified lines
2113 * @return {Raven}2158 * @return {Raven}
2114 */2159 */
2115Raven.noConflict = function () {2160Raven.noConflict = function () {
2116 _window.Raven = _Raven;2161 _window.Raven = _Raven;
2117 return Raven;2162 return Raven;
2118};2163};
2119 2164
2120Raven.afterLoad();2165Raven.afterLoad();
@@ -2140,9 +2185,22 @@ function isError(value) { · 19 unmodified lines
2140 }2185 }
2141}2186}
2142 2187
2188function 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
2143module.exports = {2200module.exports = {
2144 isObject: isObject,2201 isObject: isObject,
2145 isError: isError2202 isError: isError,
2203 wrappedCallback: wrappedCallback
2146};2204};
2147 2205
2148},{}],6:[function(_dereq_,module,exports){2206},{}],6:[function(_dereq_,module,exports){
@@ -2519,7 +2577,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() { · 370 unmodified lines
2519 if (typeof ex.stack === 'undefined' || !ex.stack) return;2577 if (typeof ex.stack === 'undefined' || !ex.stack) return;
2520 2578
2521 var chrome = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,2579 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,
2523 winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,2581 winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,
2524 2582
2525 // Used to additionally parse URL/line/column from eval frames2583 // Used to additionally parse URL/line/column from eval frames
@@ -2813,4 +2871,4 @@ function serializer(replacer, cycleReplacer) { · 287 unmodified lines
2813}2871}
2814 2872
2815},{}]},{},[4])(4)2873},{}]},{},[4])(4)
2816});2874});