vendor/assets/javascripts/raven.js in ravenjs-gem-1.1.14 vs vendor/assets/javascripts/raven.js in ravenjs-gem-1.1.16
- old
+ new
@@ -1,6 +1,6 @@
-/*! Raven.js 1.1.14 (f9803bd) | github.com/getsentry/raven-js */
+/*! Raven.js 1.1.16 (463f68f) | github.com/getsentry/raven-js */
/*
* Includes TraceKit
* https://github.com/getsentry/TraceKit
*
@@ -557,11 +557,11 @@
if (!(parts = codeRE.exec(code))) {
re = new RegExp(escapeRegExp(code).replace(/\s+/g, '\\s+'));
}
- // not sure if this is really necessary, but I don’t have a test
+ // not sure if this is really necessary, but I don’t have a test
// corpus large enough to confirm that and it was in the original.
else {
var name = parts[1] ? '\\s+' + parts[1] : '',
args = parts[2].split(',').join('\\s*,\\s*');
@@ -643,12 +643,12 @@
function computeStackTraceFromStackProp(ex) {
if (!ex.stack) {
return null;
}
- var chrome = /^\s*at (?:((?:\[object object\])?\S+(?: \[as \S+\])?) )?\(?((?:file|https?):.*?):(\d+)(?::(\d+))?\)?\s*$/i,
- gecko = /^\s*(\S*)(?:\((.*?)\))?@((?:file|https?).*?):(\d+)(?::(\d+))?\s*$/i,
+ var chrome = /^\s*at (?:((?:\[object object\])?\S+(?: \[as \S+\])?) )?\(?((?:file|https?|chrome-extension):.*?):(\d+)(?::(\d+))?\)?\s*$/i,
+ gecko = /^\s*(\S*)(?:\((.*?)\))?@((?:file|https?|chrome).*?):(\d+)(?::(\d+))?\s*$/i,
lines = ex.stack.split('\n'),
stack = [],
parts,
element,
reference = /^(.*) is undefined$/.exec(ex.message);
@@ -1106,20 +1106,23 @@
includePaths: [],
collectWindowErrors: true,
tags: {},
extra: {}
},
- authQueryString;
+ authQueryString,
+ isRavenInstalled = false;
/*
* The core Raven singleton
*
* @this {Raven}
*/
var Raven = {
- VERSION: '1.1.14',
+ VERSION: '1.1.16',
+ debug: true,
+
/*
* Allow multiple versions of Raven to be installed.
* Strip Raven from the global context and returns the instance.
*
* @return {Raven}
@@ -1135,10 +1138,14 @@
* @param {string} dsn The public Sentry DSN
* @param {object} options Optional set of of global options [optional]
* @return {Raven}
*/
config: function(dsn, options) {
+ if (globalServer) {
+ logDebug('error', 'Error: Raven has already been configured');
+ return Raven;
+ }
if (!dsn) return Raven;
var uri = parseDSN(dsn),
lastSlash = uri.path.lastIndexOf('/'),
path = uri.path.substr(1, lastSlash);
@@ -1153,10 +1160,14 @@
// "Script error." is hard coded into browsers for errors that it can't read.
// this is the result of a script being pulled in from an external domain and CORS.
globalOptions.ignoreErrors.push('Script error.');
globalOptions.ignoreErrors.push('Script error');
+ // Other variants of external script errors:
+ globalOptions.ignoreErrors.push('Javascript error: Script error on line 0');
+ globalOptions.ignoreErrors.push('Javascript error: Script error. on line 0');
+
// join regexp rules into one big rule
globalOptions.ignoreErrors = joinRegExp(globalOptions.ignoreErrors);
globalOptions.ignoreUrls = globalOptions.ignoreUrls.length ? joinRegExp(globalOptions.ignoreUrls) : false;
globalOptions.whitelistUrls = globalOptions.whitelistUrls.length ? joinRegExp(globalOptions.whitelistUrls) : false;
globalOptions.includePaths = joinRegExp(globalOptions.includePaths);
@@ -1196,12 +1207,13 @@
* to the way TraceKit is set up.
*
* @return {Raven}
*/
install: function() {
- if (isSetup()) {
+ if (isSetup() && !isRavenInstalled) {
TraceKit.report.subscribe(handleStackInfo);
+ isRavenInstalled = true;
}
return Raven;
},
@@ -1271,11 +1283,11 @@
}
}
// copy over properties of the old function
for (var property in func) {
- if (func.hasOwnProperty(property)) {
+ if (hasKey(func, property)) {
wrapped[property] = func[property];
}
}
// Signal that this function has been wrapped already
@@ -1291,10 +1303,11 @@
*
* @return {Raven}
*/
uninstall: function() {
TraceKit.report.uninstall();
+ isRavenInstalled = false;
return Raven;
},
/*
@@ -1303,12 +1316,12 @@
* @param {error} ex An exception to be logged
* @param {object} options A specific set of options for this error [optional]
* @return {Raven}
*/
captureException: function(ex, options) {
- // If a string is passed through, recall as a message
- if (isString(ex)) return Raven.captureMessage(ex, options);
+ // If not an Error is passed through, recall as a message instead
+ if (!(ex instanceof Error)) return Raven.captureMessage(ex, options);
// Store the raw exception object for potential debugging and introspection
lastCapturedException = ex;
// TraceKit.report will re-raise any exception passed to it,
@@ -1336,11 +1349,11 @@
*/
captureMessage: function(msg, options) {
// Fire away!
send(
objectMerge({
- message: msg
+ message: msg + '' // Make sure it's actually a string
}, options)
);
return Raven;
},
@@ -1349,17 +1362,41 @@
* Set/clear a user to be sent along with the payload.
*
* @param {object} user An object representing user data [optional]
* @return {Raven}
*/
- setUser: function(user) {
+ setUserContext: function(user) {
globalUser = user;
return Raven;
},
/*
+ * Set extra attributes to be sent along with the payload.
+ *
+ * @param {object} extra An object representing extra data [optional]
+ * @return {Raven}
+ */
+ setExtraContext: function(extra) {
+ globalOptions.extra = extra || {};
+
+ return Raven;
+ },
+
+ /*
+ * Set tags to be sent along with the payload.
+ *
+ * @param {object} tags An object representing tags [optional]
+ * @return {Raven}
+ */
+ setTagsContext: function(tags) {
+ globalOptions.tags = tags || {};
+
+ return Raven;
+ },
+
+ /*
* Get the latest raw exception that was captured by Raven.
*
* @return {error}
*/
lastException: function() {
@@ -1374,10 +1411,12 @@
lastEventId: function() {
return lastEventId;
}
};
+Raven.setUser = Raven.setUserContext; // To be deprecated
+
function triggerEvent(eventType, options) {
var event, key;
options = options || {};
@@ -1389,11 +1428,11 @@
} else {
event = document.createEventObject();
event.eventType = eventType;
}
- for (key in options) if (options.hasOwnProperty(key)) {
+ for (key in options) if (hasKey(options, key)) {
event[key] = options[key];
}
if (document.createEvent) {
// IE9 if standards
@@ -1466,11 +1505,11 @@
function each(obj, callback) {
var i, j;
if (isUndefined(obj.length)) {
for (i in obj) {
- if (obj.hasOwnProperty(i)) {
+ if (hasKey(obj, i)) {
callback.call(null, i, obj[i]);
}
}
} else {
j = obj.length;
@@ -1539,11 +1578,11 @@
// first we check the global includePaths list.
!globalOptions.includePaths.test(normalized.filename) ||
// Now we check for fun, if the function name is Raven or TraceKit
/(Raven|TraceKit)\./.test(normalized['function']) ||
// finally, we do a last ditch effort and check for raven.min.js
- /raven\.(min\.)js$/.test(normalized.filename)
+ /raven\.(min\.)?js$/.test(normalized.filename)
);
return normalized;
}
@@ -1587,10 +1626,14 @@
}
function processException(type, message, fileurl, lineno, frames, options) {
var stacktrace, label, i;
+ // In some instances message is not actually a string, no idea why,
+ // so we want to always coerce it to one.
+ message += '';
+
// Sometimes an exception is getting logged in Sentry as
// <no message value>
// This can only mean that the message was falsey since this value
// is hardcoded into Sentry itself.
// At this point, if the message is falsey, we bail since it's useless
@@ -1730,13 +1773,11 @@
}
function isSetup() {
if (!hasJSON) return false; // needs JSON support
if (!globalServer) {
- if (window.console && console.error) {
- console.error("Error: Raven has not been configured.");
- }
+ logDebug('error', 'Error: Raven has not been configured.');
return false;
}
return true;
}
@@ -1769,10 +1810,16 @@
v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
}
+function logDebug(level, message) {
+ if (window.console && console[level] && Raven.debug) {
+ console[level](message);
+ }
+}
+
function afterLoad() {
// Attempt to initialize Raven on load
var RavenConfig = window.RavenConfig;
if (RavenConfig) {
Raven.config(RavenConfig.dsn, RavenConfig.config).install();
@@ -1787,39 +1834,5 @@
if (typeof define === 'function' && define.amd) {
define('raven', [], function() { return Raven; });
}
})(this);
-
-/**
- * native plugin
- *
- * Extends support for global error handling for asynchronous browser
- * functions. Adopted from Closure Library's errorhandler.js
- */
-;(function extendToAsynchronousCallbacks(window, Raven) {
-"use strict";
-
-var _helper = function _helper(fnName) {
- var originalFn = window[fnName];
- window[fnName] = function ravenAsyncExtension() {
- // Make a copy of the arguments
- var args = [].slice.call(arguments);
- var originalCallback = args[0];
- if (typeof (originalCallback) === 'function') {
- args[0] = Raven.wrap(originalCallback);
- }
- // IE < 9 doesn't support .call/.apply on setInterval/etTimeout, but it
- // also only supports 2 argument and doesn't care what this" is, so we
- // can just call the original function directly.
- if (originalFn.apply) {
- return originalFn.apply(this, args);
- } else {
- return originalFn(args[0], args[1]);
- }
- };
-};
-
-_helper('setTimeout');
-_helper('setInterval');
-
-}(this, Raven));