Skip to content

Commit

Permalink
3.25.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilogorek committed May 10, 2018
1 parent 80dffad commit c306608
Show file tree
Hide file tree
Showing 103 changed files with 3,468 additions and 518 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 3.25.0

* FEAT: Handle JavaScript loaded in the browser inside a blob (#1322)
* FEAT: Handle DOMError and DOMException gracefully (#1310)
* BUILD: include plugins-combination in dist and clear some old grunt config (#1313)

## 3.24.2

* FEAT: Capture breadcrumbs on failed fetch request (#1293)
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "raven-js",
"version": "3.24.2",
"version": "3.25.0",
"dependencies": {},
"main": "dist/raven.js",
"ignore": [
Expand Down
104 changes: 98 additions & 6 deletions dist/angular,console,ember,require,vue/raven.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Raven.js 3.24.2 (540f32b) | github.com/getsentry/raven-js */
/*! Raven.js 3.25.0 (80dffad) | github.com/getsentry/raven-js */

/*
* Includes TraceKit
Expand Down Expand Up @@ -286,10 +286,12 @@ var md5 = _dereq_(13);
var RavenConfigError = _dereq_(6);

var utils = _dereq_(10);
var isErrorEvent = utils.isErrorEvent;
var isDOMError = utils.isDOMError;
var isDOMException = utils.isDOMException;
var isError = utils.isError;
var isObject = utils.isObject;
var isPlainObject = utils.isPlainObject;
var isErrorEvent = utils.isErrorEvent;
var isUndefined = utils.isUndefined;
var isFunction = utils.isFunction;
var isString = utils.isString;
Expand Down Expand Up @@ -417,7 +419,7 @@ Raven.prototype = {
// webpack (using a build step causes webpack #1617). Grunt verifies that
// this value matches package.json during build.
// See: https://github.com/getsentry/raven-js/issues/465
VERSION: '3.24.2',
VERSION: '3.25.0',

debug: false,

Expand Down Expand Up @@ -749,6 +751,23 @@ Raven.prototype = {
if (isErrorEvent(ex) && ex.error) {
// If it is an ErrorEvent with `error` property, extract it to get actual Error
ex = ex.error;
} else if (isDOMError(ex) || isDOMException(ex)) {
// If it is a DOMError or DOMException (which are legacy APIs, but still supported in some browsers)
// then we just extract the name and message, as they don't provide anything else
// https://developer.mozilla.org/en-US/docs/Web/API/DOMError
// https://developer.mozilla.org/en-US/docs/Web/API/DOMException
var name = ex.name || (isDOMError(ex) ? 'DOMError' : 'DOMException');
var message = ex.message ? name + ': ' + ex.message : name;

return this.captureMessage(
message,
objectMerge(options, {
// neither DOMError or DOMException provide stack trace and we most likely wont get it this way as well
// but it's barely any overhead so we may at least try
stacktrace: true,
trimHeadFrames: options.trimHeadFrames + 1
})
);
} else if (isError(ex)) {
// we have a real Error object
ex = ex;
Expand All @@ -760,6 +779,7 @@ Raven.prototype = {
ex = new Error(options.message);
} else {
// If none of previous checks were valid, then it means that
// it's not a DOMError/DOMException
// it's not a plain Object
// it's not a valid ErrorEvent (one with an error property)
// it's not an Error
Expand Down Expand Up @@ -2532,7 +2552,7 @@ function isObject(what) {
// Yanked from https://git.io/vS8DV re-used under CC0
// with some tiny modifications
function isError(value) {
switch ({}.toString.call(value)) {
switch (Object.prototype.toString.call(value)) {
case '[object Error]':
return true;
case '[object Exception]':
Expand All @@ -2545,7 +2565,15 @@ function isError(value) {
}

function isErrorEvent(value) {
return supportsErrorEvent() && {}.toString.call(value) === '[object ErrorEvent]';
return Object.prototype.toString.call(value) === '[object ErrorEvent]';
}

function isDOMError(value) {
return Object.prototype.toString.call(value) === '[object DOMError]';
}

function isDOMException(value) {
return Object.prototype.toString.call(value) === '[object DOMException]';
}

function isUndefined(what) {
Expand Down Expand Up @@ -2588,6 +2616,24 @@ function supportsErrorEvent() {
}
}

function supportsDOMError() {
try {
new DOMError(''); // eslint-disable-line no-new
return true;
} catch (e) {
return false;
}
}

function supportsDOMException() {
try {
new DOMException(''); // eslint-disable-line no-new
return true;
} catch (e) {
return false;
}
}

function supportsFetch() {
if (!('fetch' in _window)) return false;

Expand Down Expand Up @@ -3103,13 +3149,17 @@ module.exports = {
isObject: isObject,
isError: isError,
isErrorEvent: isErrorEvent,
isDOMError: isDOMError,
isDOMException: isDOMException,
isUndefined: isUndefined,
isFunction: isFunction,
isPlainObject: isPlainObject,
isString: isString,
isArray: isArray,
isEmptyObject: isEmptyObject,
supportsErrorEvent: supportsErrorEvent,
supportsDOMError: supportsDOMError,
supportsDOMException: supportsDOMException,
supportsFetch: supportsFetch,
supportsReferrerPolicy: supportsReferrerPolicy,
supportsPromiseRejectionEvent: supportsPromiseRejectionEvent,
Expand Down Expand Up @@ -3169,10 +3219,14 @@ var ERROR_TYPES_RE = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Ran

function getLocationHref() {
if (typeof document === 'undefined' || document.location == null) return '';

return document.location.href;
}

function getLocationOrigin() {
if (typeof document === 'undefined' || document.location == null) return '';
return document.location.origin;
}

/**
* TraceKit.report: cross-browser processing of unhandled exceptions
*
Expand Down Expand Up @@ -3580,6 +3634,44 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
element.func = UNKNOWN_FUNCTION;
}

if (element.url && element.url.substr(0, 5) === 'blob:') {
// Special case for handling JavaScript loaded into a blob.
// We use a synchronous AJAX request here as a blob is already in
// memory - it's not making a network request. This will generate a warning
// in the browser console, but there has already been an error so that's not
// that much of an issue.
var xhr = new XMLHttpRequest();
xhr.open('GET', element.url, false);
xhr.send(null);

// If we failed to download the source, skip this patch
if (xhr.status === 200) {
var source = xhr.responseText || '';

// We trim the source down to the last 300 characters as sourceMappingURL is always at the end of the file.
// Why 300? To be in line with: https://github.com/getsentry/sentry/blob/4af29e8f2350e20c28a6933354e4f42437b4ba42/src/sentry/lang/javascript/processor.py#L164-L175
source = source.slice(-300);

// Now we dig out the source map URL
var sourceMaps = source.match(/\/\/# sourceMappingURL=(.*)$/);

// If we don't find a source map comment or we find more than one, continue on to the next element.
if (sourceMaps) {
var sourceMapAddress = sourceMaps[1];

// Now we check to see if it's a relative URL.
// If it is, convert it to an absolute one.
if (sourceMapAddress.charAt(0) === '~') {
sourceMapAddress = getLocationOrigin() + sourceMapAddress.slice(1);
}

// Now we strip the '.map' off of the end of the URL and update the
// element so that Sentry can match the map to the blob.
element.url = sourceMapAddress.slice(0, -4);
}
}
}

stack.push(element);
}

Expand Down
6 changes: 3 additions & 3 deletions dist/angular,console,ember,require,vue/raven.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/angular,console,ember,require,vue/raven.min.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit c306608

Please sign in to comment.