Unified · Split
| @@ -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 */ | |
| 2 | 2 | |
| 3 | 3 | /* |
| 4 | 4 | * Includes TraceKit |
| @@ -115,6 +115,9 @@ function Raven() { · 110 unmodified lines | ||
| 115 | 115 | crossOrigin: 'anonymous', |
| 116 | 116 | collectWindowErrors: true, |
| 117 | 117 | maxMessageLength: 0, |
| 118 | + | |
| 119 | + // By default, truncates URL values to 250 chars | |
| 120 | + maxUrlLength: 250, | |
| 118 | 121 | stackTraceLimit: 50, |
| 119 | 122 | autoBreadcrumbs: true, |
| 120 | 123 | sampleRate: 1 |
| @@ -152,7 +155,7 @@ Raven.prototype = { · 31 unmodified lines | ||
| 152 | 155 | // webpack (using a build step causes webpack #1617). Grunt verifies that |
| 153 | 156 | // this value matches package.json during build. |
| 154 | 157 | // See: https://github.com/getsentry/raven-js/issues/465 |
| 155 | − VERSION: '3.13.1', | |
| 158 | + VERSION: '3.14.2', | |
| 156 | 159 | |
| 157 | 160 | debug: false, |
| 158 | 161 | |
| @@ -457,9 +460,10 @@ Raven.prototype = { · 298 unmodified lines | ||
| 457 | 460 | |
| 458 | 461 | if (this._globalOptions.stacktrace || (options && options.stacktrace)) { |
| 459 | 462 | 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. | |
| 463 | 467 | try { |
| 464 | 468 | throw new Error(msg); |
| 465 | 469 | } catch (ex1) { |
| @@ -473,6 +477,9 @@ Raven.prototype = { · 7 unmodified lines | ||
| 473 | 477 | // fingerprint on msg, not stack trace (legacy behavior, could be |
| 474 | 478 | // revisited) |
| 475 | 479 | 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 | |
| 476 | 483 | trimHeadFrames: (options.trimHeadFrames || 0) + 1 |
| 477 | 484 | }, options); |
| 478 | 485 | |
| @@ -1385,9 +1392,48 @@ Raven.prototype = { · 906 unmodified lines | ||
| 1385 | 1392 | exception.value = truncate(exception.value, max); |
| 1386 | 1393 | } |
| 1387 | 1394 | |
| 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 | + | |
| 1388 | 1408 | return data; |
| 1389 | 1409 | }, |
| 1390 | 1410 | |
| 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 | + | |
| 1391 | 1437 | _getHttpData: function() { |
| 1392 | 1438 | if (!this._hasNavigator && !this._hasDocument) return; |
| 1393 | 1439 | var httpData = {}; |
| @@ -2083,20 +2129,22 @@ function isObject(what) { · 689 unmodified lines | ||
| 2083 | 2129 | return typeof what === 'object' && what !== null; |
| 2084 | 2130 | } |
| 2085 | 2131 | |
| 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 | |
| 2087 | 2133 | // 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 | + } | |
| 2094 | 2141 | } |
| 2095 | 2142 | |
| 2096 | 2143 | module.exports = { |
| 2097 | 2144 | isObject: isObject, |
| 2098 | 2145 | isError: isError |
| 2099 | 2146 | }; |
| 2147 | + | |
| 2100 | 2148 | },{}],6:[function(_dereq_,module,exports){ |
| 2101 | 2149 | (function (global){ |
| 2102 | 2150 | 'use strict'; |
| @@ -2424,27 +2472,6 @@ TraceKit.report = (function reportModuleWrapper() { · 321 unmodified lines | ||
| 2424 | 2472 | * |
| 2425 | 2473 | */ |
| 2426 | 2474 | 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('<', '(?:<|<)').replace('>', '(?:>|>)').replace('&', '(?:&|&)').replace('"', '(?:"|")').replace(/\s+/g, '\\s+'); | |
| 2446 | − } | |
| 2447 | − | |
| 2448 | 2475 | // Contents of Exception in various browsers. |
| 2449 | 2476 | // |
| 2450 | 2477 | // SAFARI: |
| @@ -2491,18 +2518,31 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() { · 40 unmodified lines | ||
| 2491 | 2518 | function computeStackTraceFromStackProp(ex) { |
| 2492 | 2519 | if (typeof ex.stack === 'undefined' || !ex.stack) return; |
| 2493 | 2520 | |
| 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 | + | |
| 2497 | 2529 | lines = ex.stack.split('\n'), |
| 2498 | 2530 | stack = [], |
| 2531 | + submatch, | |
| 2499 | 2532 | parts, |
| 2500 | 2533 | element, |
| 2501 | 2534 | reference = /^(.*) is undefined$/.exec(ex.message); |
| 2502 | 2535 | |
| 2503 | 2536 | for (var i = 0, j = lines.length; i < j; ++i) { |
| 2504 | 2537 | 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 | + } | |
| 2506 | 2546 | element = { |
| 2507 | 2547 | 'url': !isNative ? parts[2] : null, |
| 2508 | 2548 | 'func': parts[1] || UNKNOWN_FUNCTION, |
| @@ -2519,6 +2559,19 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() { · 10 unmodified lines | ||
| 2519 | 2559 | 'column': parts[4] ? +parts[4] : null |
| 2520 | 2560 | }; |
| 2521 | 2561 | } 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 | + } | |
| 2522 | 2575 | element = { |
| 2523 | 2576 | 'url': parts[3], |
| 2524 | 2577 | 'func': parts[1] || UNKNOWN_FUNCTION, |
| @@ -2541,13 +2594,6 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() { · 16 unmodified lines | ||
| 2541 | 2594 | return null; |
| 2542 | 2595 | } |
| 2543 | 2596 | |
| 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 | − | |
| 2551 | 2597 | return { |
| 2552 | 2598 | 'name': ex.name, |
| 2553 | 2599 | 'message': ex.message, |