Update Raven.js

pull/656/merge
Thibaut Courouble 8 years ago
parent 26132688ae
commit 68c030877d

@ -1,4 +1,4 @@
/*! Raven.js 3.14.2 (5cf57e1) | github.com/getsentry/raven-js */ /*! Raven.js 3.17.0 (6384830) | github.com/getsentry/raven-js */
/* /*
* Includes TraceKit * Includes TraceKit
@ -91,6 +91,13 @@ var _window = typeof window !== 'undefined' ? window
var _document = _window.document; var _document = _window.document;
var _navigator = _window.navigator; var _navigator = _window.navigator;
function keepOriginalCallback(original, callback) {
return isFunction(callback) ?
function (data) { return callback(data, original) } :
callback;
}
// First, check for JSON support // First, check for JSON support
// If there is no JSON, we no-op the core features of Raven // If there is no JSON, we no-op the core features of Raven
// since JSON is required to encode the payload // since JSON is required to encode the payload
@ -120,6 +127,7 @@ function Raven() {
maxUrlLength: 250, maxUrlLength: 250,
stackTraceLimit: 50, stackTraceLimit: 50,
autoBreadcrumbs: true, autoBreadcrumbs: true,
instrument: true,
sampleRate: 1 sampleRate: 1
}; };
this._ignoreOnError = 0; this._ignoreOnError = 0;
@ -155,7 +163,7 @@ Raven.prototype = {
// webpack (using a build step causes webpack #1617). Grunt verifies that // webpack (using a build step causes webpack #1617). Grunt verifies that
// this value matches package.json during build. // this value matches package.json during build.
// See: https://github.com/getsentry/raven-js/issues/465 // See: https://github.com/getsentry/raven-js/issues/465
VERSION: '3.14.2', VERSION: '3.17.0',
debug: false, debug: false,
@ -220,6 +228,18 @@ Raven.prototype = {
} }
globalOptions.autoBreadcrumbs = autoBreadcrumbs; globalOptions.autoBreadcrumbs = autoBreadcrumbs;
var instrumentDefaults = {
tryCatch: true
};
var instrument = globalOptions.instrument;
if ({}.toString.call(instrument) === '[object Object]') {
instrument = objectMerge(instrumentDefaults, instrument);
} else if (instrument !== false) {
instrument = instrumentDefaults;
}
globalOptions.instrument = instrument;
TraceKit.collectWindowErrors = !!globalOptions.collectWindowErrors; TraceKit.collectWindowErrors = !!globalOptions.collectWindowErrors;
// return for chaining // return for chaining
@ -240,7 +260,10 @@ Raven.prototype = {
TraceKit.report.subscribe(function () { TraceKit.report.subscribe(function () {
self._handleOnErrorStackInfo.apply(self, arguments); self._handleOnErrorStackInfo.apply(self, arguments);
}); });
self._instrumentTryCatch(); if (self._globalOptions.instrument && self._globalOptions.instrument.tryCatch) {
self._instrumentTryCatch();
}
if (self._globalOptions.autoBreadcrumbs) if (self._globalOptions.autoBreadcrumbs)
self._instrumentBreadcrumbs(); self._instrumentBreadcrumbs();
@ -622,10 +645,8 @@ Raven.prototype = {
*/ */
setDataCallback: function(callback) { setDataCallback: function(callback) {
var original = this._globalOptions.dataCallback; var original = this._globalOptions.dataCallback;
this._globalOptions.dataCallback = isFunction(callback) this._globalOptions.dataCallback =
? function (data) { return callback(data, original); } keepOriginalCallback(original, callback);
: callback;
return this; return this;
}, },
@ -638,10 +659,8 @@ Raven.prototype = {
*/ */
setBreadcrumbCallback: function(callback) { setBreadcrumbCallback: function(callback) {
var original = this._globalOptions.breadcrumbCallback; var original = this._globalOptions.breadcrumbCallback;
this._globalOptions.breadcrumbCallback = isFunction(callback) this._globalOptions.breadcrumbCallback =
? function (data) { return callback(data, original); } keepOriginalCallback(original, callback);
: callback;
return this; return this;
}, },
@ -654,10 +673,8 @@ Raven.prototype = {
*/ */
setShouldSendCallback: function(callback) { setShouldSendCallback: function(callback) {
var original = this._globalOptions.shouldSendCallback; var original = this._globalOptions.shouldSendCallback;
this._globalOptions.shouldSendCallback = isFunction(callback) this._globalOptions.shouldSendCallback =
? function (data) { return callback(data, original); } keepOriginalCallback(original, callback);
: callback;
return this; return this;
}, },
@ -918,7 +935,8 @@ Raven.prototype = {
}, },
/** /**
* Install any queued plugins * Wrap timer functions and event targets to catch errors and provide
* better metadata.
*/ */
_instrumentTryCatch: function() { _instrumentTryCatch: function() {
var self = this; var self = this;
@ -1116,11 +1134,22 @@ Raven.prototype = {
// Make a copy of the arguments to prevent deoptimization // Make a copy of the arguments to prevent deoptimization
// https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#32-leaking-arguments // https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#32-leaking-arguments
var args = new Array(arguments.length); var args = new Array(arguments.length);
for(var i = 0; i < args.length; ++i) { for (var i = 0; i < args.length; ++i) {
args[i] = arguments[i]; args[i] = arguments[i];
} }
var fetchInput = args[0];
var method = 'GET'; var method = 'GET';
var url;
if (typeof fetchInput === 'string') {
url = fetchInput;
} else {
url = fetchInput.url;
if (fetchInput.method) {
method = fetchInput.method;
}
}
if (args[1] && args[1].method) { if (args[1] && args[1].method) {
method = args[1].method; method = args[1].method;
@ -1128,7 +1157,7 @@ Raven.prototype = {
var fetchData = { var fetchData = {
method: method, method: method,
url: args[0], url: url,
status_code: null status_code: null
}; };
@ -1421,16 +1450,17 @@ Raven.prototype = {
for (var i = 0; i < breadcrumbs.values.length; ++i) { for (var i = 0; i < breadcrumbs.values.length; ++i) {
crumb = breadcrumbs.values[i]; crumb = breadcrumbs.values[i];
if (!crumb.hasOwnProperty('data') || !isObject(crumb.data)) if (!crumb.hasOwnProperty('data') || !isObject(crumb.data) || objectFrozen(crumb.data))
continue; continue;
data = crumb.data; data = objectMerge({}, crumb.data);
for (var j = 0; j < urlProps.length; ++j) { for (var j = 0; j < urlProps.length; ++j) {
urlProp = urlProps[j]; urlProp = urlProps[j];
if (data.hasOwnProperty(urlProp)) { if (data.hasOwnProperty(urlProp)) {
data[urlProp] = truncate(data[urlProp], this._globalOptions.maxUrlLength); data[urlProp] = truncate(data[urlProp], this._globalOptions.maxUrlLength);
} }
} }
breadcrumbs.values[i].data = data;
} }
}, },
@ -1815,6 +1845,21 @@ function objectMerge(obj1, obj2) {
return obj1; return obj1;
} }
/**
* This function is only used for react-native.
* react-native freezes object that have already been sent over the
* js bridge. We need this function in order to check if the object is frozen.
* So it's ok that objectFrozen returns false if Object.isFrozen is not
* supported because it's not relevant for other "platforms". See related issue:
* https://github.com/getsentry/react-native-sentry/issues/57
*/
function objectFrozen(obj) {
if (!Object.isFrozen) {
return false;
}
return Object.isFrozen(obj);
}
function truncate(str, max) { function truncate(str, max) {
return !max || str.length <= max ? str : str.substr(0, max) + '\u2026'; return !max || str.length <= max ? str : str.substr(0, max) + '\u2026';
} }
@ -2113,8 +2158,8 @@ var Raven = new RavenConstructor();
* @return {Raven} * @return {Raven}
*/ */
Raven.noConflict = function () { Raven.noConflict = function () {
_window.Raven = _Raven; _window.Raven = _Raven;
return Raven; return Raven;
}; };
Raven.afterLoad(); Raven.afterLoad();
@ -2140,9 +2185,22 @@ function isError(value) {
} }
} }
function wrappedCallback(callback) {
function dataCallback(data, original) {
var normalizedData = callback(data) || data;
if (original) {
return original(normalizedData) || normalizedData;
}
return normalizedData;
}
return dataCallback;
}
module.exports = { module.exports = {
isObject: isObject, isObject: isObject,
isError: isError isError: isError,
wrappedCallback: wrappedCallback
}; };
},{}],6:[function(_dereq_,module,exports){ },{}],6:[function(_dereq_,module,exports){
@ -2519,7 +2577,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
if (typeof ex.stack === 'undefined' || !ex.stack) return; if (typeof ex.stack === 'undefined' || !ex.stack) return;
var chrome = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i, var chrome = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,
gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?)(?::(\d+))?(?::(\d+))?\s*$/i, gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,
winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i, winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,
// Used to additionally parse URL/line/column from eval frames // Used to additionally parse URL/line/column from eval frames
@ -2813,4 +2871,4 @@ function serializer(replacer, cycleReplacer) {
} }
},{}]},{},[4])(4) },{}]},{},[4])(4)
}); });
Loading…
Cancel
Save