1
- /*! Raven.js 3.24.2 (540f32b ) | github.com/getsentry/raven-js */
1
+ /*! Raven.js 3.25.0 (80dffad ) | github.com/getsentry/raven-js */
2
2
3
3
/*
4
4
* Includes TraceKit
@@ -286,10 +286,12 @@ var md5 = _dereq_(13);
286
286
var RavenConfigError = _dereq_ ( 6 ) ;
287
287
288
288
var utils = _dereq_ ( 10 ) ;
289
+ var isErrorEvent = utils . isErrorEvent ;
290
+ var isDOMError = utils . isDOMError ;
291
+ var isDOMException = utils . isDOMException ;
289
292
var isError = utils . isError ;
290
293
var isObject = utils . isObject ;
291
294
var isPlainObject = utils . isPlainObject ;
292
- var isErrorEvent = utils . isErrorEvent ;
293
295
var isUndefined = utils . isUndefined ;
294
296
var isFunction = utils . isFunction ;
295
297
var isString = utils . isString ;
@@ -417,7 +419,7 @@ Raven.prototype = {
417
419
// webpack (using a build step causes webpack #1617). Grunt verifies that
418
420
// this value matches package.json during build.
419
421
// See: https://github.com/getsentry/raven-js/issues/465
420
- VERSION : '3.24.2 ' ,
422
+ VERSION : '3.25.0 ' ,
421
423
422
424
debug : false ,
423
425
@@ -749,6 +751,23 @@ Raven.prototype = {
749
751
if ( isErrorEvent ( ex ) && ex . error ) {
750
752
// If it is an ErrorEvent with `error` property, extract it to get actual Error
751
753
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
+ ) ;
752
771
} else if ( isError ( ex ) ) {
753
772
// we have a real Error object
754
773
ex = ex ;
@@ -760,6 +779,7 @@ Raven.prototype = {
760
779
ex = new Error ( options . message ) ;
761
780
} else {
762
781
// If none of previous checks were valid, then it means that
782
+ // it's not a DOMError/DOMException
763
783
// it's not a plain Object
764
784
// it's not a valid ErrorEvent (one with an error property)
765
785
// it's not an Error
@@ -2532,7 +2552,7 @@ function isObject(what) {
2532
2552
// Yanked from https://git.io/vS8DV re-used under CC0
2533
2553
// with some tiny modifications
2534
2554
function isError ( value ) {
2535
- switch ( { } . toString . call ( value ) ) {
2555
+ switch ( Object . prototype . toString . call ( value ) ) {
2536
2556
case '[object Error]' :
2537
2557
return true ;
2538
2558
case '[object Exception]' :
@@ -2545,7 +2565,15 @@ function isError(value) {
2545
2565
}
2546
2566
2547
2567
function 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]' ;
2549
2577
}
2550
2578
2551
2579
function isUndefined ( what ) {
@@ -2588,6 +2616,24 @@ function supportsErrorEvent() {
2588
2616
}
2589
2617
}
2590
2618
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
+
2591
2637
function supportsFetch ( ) {
2592
2638
if ( ! ( 'fetch' in _window ) ) return false ;
2593
2639
@@ -3103,13 +3149,17 @@ module.exports = {
3103
3149
isObject : isObject ,
3104
3150
isError : isError ,
3105
3151
isErrorEvent : isErrorEvent ,
3152
+ isDOMError : isDOMError ,
3153
+ isDOMException : isDOMException ,
3106
3154
isUndefined : isUndefined ,
3107
3155
isFunction : isFunction ,
3108
3156
isPlainObject : isPlainObject ,
3109
3157
isString : isString ,
3110
3158
isArray : isArray ,
3111
3159
isEmptyObject : isEmptyObject ,
3112
3160
supportsErrorEvent : supportsErrorEvent ,
3161
+ supportsDOMError : supportsDOMError ,
3162
+ supportsDOMException : supportsDOMException ,
3113
3163
supportsFetch : supportsFetch ,
3114
3164
supportsReferrerPolicy : supportsReferrerPolicy ,
3115
3165
supportsPromiseRejectionEvent : supportsPromiseRejectionEvent ,
@@ -3169,10 +3219,14 @@ var ERROR_TYPES_RE = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Ran
3169
3219
3170
3220
function getLocationHref ( ) {
3171
3221
if ( typeof document === 'undefined' || document . location == null ) return '' ;
3172
-
3173
3222
return document . location . href ;
3174
3223
}
3175
3224
3225
+ function getLocationOrigin ( ) {
3226
+ if ( typeof document === 'undefined' || document . location == null ) return '' ;
3227
+ return document . location . origin ;
3228
+ }
3229
+
3176
3230
/**
3177
3231
* TraceKit.report: cross-browser processing of unhandled exceptions
3178
3232
*
@@ -3580,6 +3634,44 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
3580
3634
element . func = UNKNOWN_FUNCTION ;
3581
3635
}
3582
3636
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
+
3583
3675
stack . push ( element ) ;
3584
3676
}
3585
3677
0 commit comments