1- /*! Raven.js 3.24.2 (540f32b ) | github.com/getsentry/raven-js */
1+ /*! Raven.js 3.25.0 (80dffad ) | github.com/getsentry/raven-js */
22
33/*
44 * Includes TraceKit
@@ -286,10 +286,12 @@ var md5 = _dereq_(13);
286286var RavenConfigError = _dereq_ ( 6 ) ;
287287
288288var utils = _dereq_ ( 10 ) ;
289+ var isErrorEvent = utils . isErrorEvent ;
290+ var isDOMError = utils . isDOMError ;
291+ var isDOMException = utils . isDOMException ;
289292var isError = utils . isError ;
290293var isObject = utils . isObject ;
291294var isPlainObject = utils . isPlainObject ;
292- var isErrorEvent = utils . isErrorEvent ;
293295var isUndefined = utils . isUndefined ;
294296var isFunction = utils . isFunction ;
295297var isString = utils . isString ;
@@ -417,7 +419,7 @@ Raven.prototype = {
417419 // webpack (using a build step causes webpack #1617). Grunt verifies that
418420 // this value matches package.json during build.
419421 // See: https://github.com/getsentry/raven-js/issues/465
420- VERSION : '3.24.2 ' ,
422+ VERSION : '3.25.0 ' ,
421423
422424 debug : false ,
423425
@@ -749,6 +751,23 @@ Raven.prototype = {
749751 if ( isErrorEvent ( ex ) && ex . error ) {
750752 // If it is an ErrorEvent with `error` property, extract it to get actual Error
751753 ex = ex . error ;
754+ } else if ( isDOMError ( ex ) || isDOMException ( ex ) ) {
755+ // If it is a DOMError or DOMException (which are legacy APIs, but still supported in some browsers)
756+ // then we just extract the name and message, as they don't provide anything else
757+ // https://developer.mozilla.org/en-US/docs/Web/API/DOMError
758+ // https://developer.mozilla.org/en-US/docs/Web/API/DOMException
759+ var name = ex . name || ( isDOMError ( ex ) ? 'DOMError' : 'DOMException' ) ;
760+ var message = ex . message ? name + ': ' + ex . message : name ;
761+
762+ return this . captureMessage (
763+ message ,
764+ objectMerge ( options , {
765+ // neither DOMError or DOMException provide stack trace and we most likely wont get it this way as well
766+ // but it's barely any overhead so we may at least try
767+ stacktrace : true ,
768+ trimHeadFrames : options . trimHeadFrames + 1
769+ } )
770+ ) ;
752771 } else if ( isError ( ex ) ) {
753772 // we have a real Error object
754773 ex = ex ;
@@ -760,6 +779,7 @@ Raven.prototype = {
760779 ex = new Error ( options . message ) ;
761780 } else {
762781 // If none of previous checks were valid, then it means that
782+ // it's not a DOMError/DOMException
763783 // it's not a plain Object
764784 // it's not a valid ErrorEvent (one with an error property)
765785 // it's not an Error
@@ -2532,7 +2552,7 @@ function isObject(what) {
25322552// Yanked from https://git.io/vS8DV re-used under CC0
25332553// with some tiny modifications
25342554function isError ( value ) {
2535- switch ( { } . toString . call ( value ) ) {
2555+ switch ( Object . prototype . toString . call ( value ) ) {
25362556 case '[object Error]' :
25372557 return true ;
25382558 case '[object Exception]' :
@@ -2545,7 +2565,15 @@ function isError(value) {
25452565}
25462566
25472567function isErrorEvent ( value ) {
2548- return supportsErrorEvent ( ) && { } . toString . call ( value ) === '[object ErrorEvent]' ;
2568+ return Object . prototype . toString . call ( value ) === '[object ErrorEvent]' ;
2569+ }
2570+
2571+ function isDOMError ( value ) {
2572+ return Object . prototype . toString . call ( value ) === '[object DOMError]' ;
2573+ }
2574+
2575+ function isDOMException ( value ) {
2576+ return Object . prototype . toString . call ( value ) === '[object DOMException]' ;
25492577}
25502578
25512579function isUndefined ( what ) {
@@ -2588,6 +2616,24 @@ function supportsErrorEvent() {
25882616 }
25892617}
25902618
2619+ function supportsDOMError ( ) {
2620+ try {
2621+ new DOMError ( '' ) ; // eslint-disable-line no-new
2622+ return true ;
2623+ } catch ( e ) {
2624+ return false ;
2625+ }
2626+ }
2627+
2628+ function supportsDOMException ( ) {
2629+ try {
2630+ new DOMException ( '' ) ; // eslint-disable-line no-new
2631+ return true ;
2632+ } catch ( e ) {
2633+ return false ;
2634+ }
2635+ }
2636+
25912637function supportsFetch ( ) {
25922638 if ( ! ( 'fetch' in _window ) ) return false ;
25932639
@@ -3103,13 +3149,17 @@ module.exports = {
31033149 isObject : isObject ,
31043150 isError : isError ,
31053151 isErrorEvent : isErrorEvent ,
3152+ isDOMError : isDOMError ,
3153+ isDOMException : isDOMException ,
31063154 isUndefined : isUndefined ,
31073155 isFunction : isFunction ,
31083156 isPlainObject : isPlainObject ,
31093157 isString : isString ,
31103158 isArray : isArray ,
31113159 isEmptyObject : isEmptyObject ,
31123160 supportsErrorEvent : supportsErrorEvent ,
3161+ supportsDOMError : supportsDOMError ,
3162+ supportsDOMException : supportsDOMException ,
31133163 supportsFetch : supportsFetch ,
31143164 supportsReferrerPolicy : supportsReferrerPolicy ,
31153165 supportsPromiseRejectionEvent : supportsPromiseRejectionEvent ,
@@ -3169,10 +3219,14 @@ var ERROR_TYPES_RE = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Ran
31693219
31703220function getLocationHref ( ) {
31713221 if ( typeof document === 'undefined' || document . location == null ) return '' ;
3172-
31733222 return document . location . href ;
31743223}
31753224
3225+ function getLocationOrigin ( ) {
3226+ if ( typeof document === 'undefined' || document . location == null ) return '' ;
3227+ return document . location . origin ;
3228+ }
3229+
31763230/**
31773231 * TraceKit.report: cross-browser processing of unhandled exceptions
31783232 *
@@ -3580,6 +3634,44 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
35803634 element . func = UNKNOWN_FUNCTION ;
35813635 }
35823636
3637+ if ( element . url && element . url . substr ( 0 , 5 ) === 'blob:' ) {
3638+ // Special case for handling JavaScript loaded into a blob.
3639+ // We use a synchronous AJAX request here as a blob is already in
3640+ // memory - it's not making a network request. This will generate a warning
3641+ // in the browser console, but there has already been an error so that's not
3642+ // that much of an issue.
3643+ var xhr = new XMLHttpRequest ( ) ;
3644+ xhr . open ( 'GET' , element . url , false ) ;
3645+ xhr . send ( null ) ;
3646+
3647+ // If we failed to download the source, skip this patch
3648+ if ( xhr . status === 200 ) {
3649+ var source = xhr . responseText || '' ;
3650+
3651+ // We trim the source down to the last 300 characters as sourceMappingURL is always at the end of the file.
3652+ // Why 300? To be in line with: https://github.com/getsentry/sentry/blob/4af29e8f2350e20c28a6933354e4f42437b4ba42/src/sentry/lang/javascript/processor.py#L164-L175
3653+ source = source . slice ( - 300 ) ;
3654+
3655+ // Now we dig out the source map URL
3656+ var sourceMaps = source . match ( / \/ \/ # s o u r c e M a p p i n g U R L = ( .* ) $ / ) ;
3657+
3658+ // If we don't find a source map comment or we find more than one, continue on to the next element.
3659+ if ( sourceMaps ) {
3660+ var sourceMapAddress = sourceMaps [ 1 ] ;
3661+
3662+ // Now we check to see if it's a relative URL.
3663+ // If it is, convert it to an absolute one.
3664+ if ( sourceMapAddress . charAt ( 0 ) === '~' ) {
3665+ sourceMapAddress = getLocationOrigin ( ) + sourceMapAddress . slice ( 1 ) ;
3666+ }
3667+
3668+ // Now we strip the '.map' off of the end of the URL and update the
3669+ // element so that Sentry can match the map to the blob.
3670+ element . url = sourceMapAddress . slice ( 0 , - 4 ) ;
3671+ }
3672+ }
3673+ }
3674+
35833675 stack . push ( element ) ;
35843676 }
35853677
0 commit comments