Skip to content

Commit 2cef32d

Browse files
committed
Update Raven.js
1 parent 993c0d8 commit 2cef32d

1 file changed

Lines changed: 90 additions & 44 deletions

File tree

‎assets/javascripts/vendor/raven.js‎

Lines changed: 90 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! Raven.js 3.13.1 (f55d281) | github.com/getsentry/raven-js */
1+
/*! Raven.js 3.14.2 (5cf57e1) | github.com/getsentry/raven-js */
22

33
/*
44
* Includes TraceKit
@@ -115,6 +115,9 @@ function Raven() {
115115
crossOrigin: 'anonymous',
116116
collectWindowErrors: true,
117117
maxMessageLength: 0,
118+
119+
// By default, truncates URL values to 250 chars
120+
maxUrlLength: 250,
118121
stackTraceLimit: 50,
119122
autoBreadcrumbs: true,
120123
sampleRate: 1
@@ -152,7 +155,7 @@ Raven.prototype = {
152155
// webpack (using a build step causes webpack #1617). Grunt verifies that
153156
// this value matches package.json during build.
154157
// See: https://github.com/getsentry/raven-js/issues/465
155-
VERSION: '3.13.1',
158+
VERSION: '3.14.2',
156159

157160
debug: false,
158161

@@ -457,9 +460,10 @@ Raven.prototype = {
457460

458461
if (this._globalOptions.stacktrace || (options && options.stacktrace)) {
459462
var ex;
460-
// create a stack trace from this point; just trim
461-
// off extra frames so they don't include this function call (or
462-
// earlier Raven.js library fn calls)
463+
// Generate a "synthetic" stack trace from this point.
464+
// NOTE: If you are a Sentry user, and you are seeing this stack frame, it is NOT indicative
465+
// of a bug with Raven.js. Sentry generates synthetic traces either by configuration,
466+
// or if it catches a thrown object without a "stack" property.
463467
try {
464468
throw new Error(msg);
465469
} catch (ex1) {
@@ -473,6 +477,9 @@ Raven.prototype = {
473477
// fingerprint on msg, not stack trace (legacy behavior, could be
474478
// revisited)
475479
fingerprint: msg,
480+
// since we know this is a synthetic trace, the top N-most frames
481+
// MUST be from Raven.js, so mark them as in_app later by setting
482+
// trimHeadFrames
476483
trimHeadFrames: (options.trimHeadFrames || 0) + 1
477484
}, options);
478485

@@ -1385,9 +1392,48 @@ Raven.prototype = {
13851392
exception.value = truncate(exception.value, max);
13861393
}
13871394

1395+
var request = data.request;
1396+
if (request) {
1397+
if (request.url) {
1398+
request.url = truncate(request.url, this._globalOptions.maxUrlLength);
1399+
}
1400+
if (request.Referer) {
1401+
request.Referer = truncate(request.Referer, this._globalOptions.maxUrlLength);
1402+
}
1403+
}
1404+
1405+
if (data.breadcrumbs && data.breadcrumbs.values)
1406+
this._trimBreadcrumbs(data.breadcrumbs);
1407+
13881408
return data;
13891409
},
13901410

1411+
/**
1412+
* Truncate breadcrumb values (right now just URLs)
1413+
*/
1414+
_trimBreadcrumbs: function (breadcrumbs) {
1415+
// known breadcrumb properties with urls
1416+
// TODO: also consider arbitrary prop values that start with (https?)?://
1417+
var urlProps = ['to', 'from', 'url'],
1418+
urlProp,
1419+
crumb,
1420+
data;
1421+
1422+
for (var i = 0; i < breadcrumbs.values.length; ++i) {
1423+
crumb = breadcrumbs.values[i];
1424+
if (!crumb.hasOwnProperty('data') || !isObject(crumb.data))
1425+
continue;
1426+
1427+
data = crumb.data;
1428+
for (var j = 0; j < urlProps.length; ++j) {
1429+
urlProp = urlProps[j];
1430+
if (data.hasOwnProperty(urlProp)) {
1431+
data[urlProp] = truncate(data[urlProp], this._globalOptions.maxUrlLength);
1432+
}
1433+
}
1434+
}
1435+
},
1436+
13911437
_getHttpData: function() {
13921438
if (!this._hasNavigator && !this._hasDocument) return;
13931439
var httpData = {};
@@ -2083,20 +2129,22 @@ function isObject(what) {
20832129
return typeof what === 'object' && what !== null;
20842130
}
20852131

2086-
// Sorta yanked from https://github.com/joyent/node/blob/aa3b4b4/lib/util.js#L560
2132+
// Yanked from https://git.io/vS8DV re-used under CC0
20872133
// with some tiny modifications
2088-
function isError(what) {
2089-
var toString = {}.toString.call(what);
2090-
return isObject(what) &&
2091-
toString === '[object Error]' ||
2092-
toString === '[object Exception]' || // Firefox NS_ERROR_FAILURE Exceptions
2093-
what instanceof Error;
2134+
function isError(value) {
2135+
switch ({}.toString.call(value)) {
2136+
case '[object Error]': return true;
2137+
case '[object Exception]': return true;
2138+
case '[object DOMException]': return true;
2139+
default: return value instanceof Error;
2140+
}
20942141
}
20952142

20962143
module.exports = {
20972144
isObject: isObject,
20982145
isError: isError
20992146
};
2147+
21002148
},{}],6:[function(_dereq_,module,exports){
21012149
(function (global){
21022150
'use strict';
@@ -2424,27 +2472,6 @@ TraceKit.report = (function reportModuleWrapper() {
24242472
*
24252473
*/
24262474
TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
2427-
/**
2428-
* Escapes special characters, except for whitespace, in a string to be
2429-
* used inside a regular expression as a string literal.
2430-
* @param {string} text The string.
2431-
* @return {string} The escaped string literal.
2432-
*/
2433-
function escapeRegExp(text) {
2434-
return text.replace(/[\-\[\]{}()*+?.,\\\^$|#]/g, '\\$&');
2435-
}
2436-
2437-
/**
2438-
* Escapes special characters in a string to be used inside a regular
2439-
* expression as a string literal. Also ensures that HTML entities will
2440-
* be matched the same as their literal friends.
2441-
* @param {string} body The string.
2442-
* @return {string} The escaped string.
2443-
*/
2444-
function escapeCodeAsRegExpForMatchingInsideHTML(body) {
2445-
return escapeRegExp(body).replace('<', '(?:<|&lt;)').replace('>', '(?:>|&gt;)').replace('&', '(?:&|&amp;)').replace('"', '(?:"|&quot;)').replace(/\s+/g, '\\s+');
2446-
}
2447-
24482475
// Contents of Exception in various browsers.
24492476
//
24502477
// SAFARI:
@@ -2491,18 +2518,31 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
24912518
function computeStackTraceFromStackProp(ex) {
24922519
if (typeof ex.stack === 'undefined' || !ex.stack) return;
24932520

2494-
var chrome = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|<anonymous>).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,
2495-
gecko = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|resource|\[native).*?)(?::(\d+))?(?::(\d+))?\s*$/i,
2496-
winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,
2521+
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,
2523+
winjs = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,
2524+
2525+
// Used to additionally parse URL/line/column from eval frames
2526+
geckoEval = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i,
2527+
chromeEval = /\((\S*)(?::(\d+))(?::(\d+))\)/,
2528+
24972529
lines = ex.stack.split('\n'),
24982530
stack = [],
2531+
submatch,
24992532
parts,
25002533
element,
25012534
reference = /^(.*) is undefined$/.exec(ex.message);
25022535

25032536
for (var i = 0, j = lines.length; i < j; ++i) {
25042537
if ((parts = chrome.exec(lines[i]))) {
2505-
var isNative = parts[2] && parts[2].indexOf('native') !== -1;
2538+
var isNative = parts[2] && parts[2].indexOf('native') === 0; // start of line
2539+
var isEval = parts[2] && parts[2].indexOf('eval') === 0; // start of line
2540+
if (isEval && (submatch = chromeEval.exec(parts[2]))) {
2541+
// throw out eval line/column and use top-most line/column number
2542+
parts[2] = submatch[1]; // url
2543+
parts[3] = submatch[2]; // line
2544+
parts[4] = submatch[3]; // column
2545+
}
25062546
element = {
25072547
'url': !isNative ? parts[2] : null,
25082548
'func': parts[1] || UNKNOWN_FUNCTION,
@@ -2519,6 +2559,19 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
25192559
'column': parts[4] ? +parts[4] : null
25202560
};
25212561
} else if ((parts = gecko.exec(lines[i]))) {
2562+
var isEval = parts[3] && parts[3].indexOf(' > eval') > -1;
2563+
if (isEval && (submatch = geckoEval.exec(parts[3]))) {
2564+
// throw out eval line/column and use top-most line number
2565+
parts[3] = submatch[1];
2566+
parts[4] = submatch[2];
2567+
parts[5] = null; // no column when eval
2568+
} else if (i === 0 && !parts[5] && typeof ex.columnNumber !== 'undefined') {
2569+
// FireFox uses this awesome columnNumber property for its top frame
2570+
// Also note, Firefox's column number is 0-based and everything else expects 1-based,
2571+
// so adding 1
2572+
// NOTE: this hack doesn't work if top-most frame is eval
2573+
stack[0].column = ex.columnNumber + 1;
2574+
}
25222575
element = {
25232576
'url': parts[3],
25242577
'func': parts[1] || UNKNOWN_FUNCTION,
@@ -2541,13 +2594,6 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
25412594
return null;
25422595
}
25432596

2544-
if (!stack[0].column && typeof ex.columnNumber !== 'undefined') {
2545-
// FireFox uses this awesome columnNumber property for its top frame
2546-
// Also note, Firefox's column number is 0-based and everything else expects 1-based,
2547-
// so adding 1
2548-
stack[0].column = ex.columnNumber + 1;
2549-
}
2550-
25512597
return {
25522598
'name': ex.name,
25532599
'message': ex.message,

0 commit comments

Comments
 (0)