@@ -341,7 +341,18 @@ Raven.prototype = {
341
341
* @return {Raven }
342
342
*/
343
343
captureMessage : function ( msg , options ) {
344
- if ( options . stacktrace ) {
344
+ // config() automagically converts ignoreErrors from a list to a RegExp so we need to test for an
345
+ // early call; we'll error on the side of logging anything called before configuration since it's
346
+ // probably something you should see:
347
+ if ( ! ! this . _globalOptions . ignoreErrors . test && this . _globalOptions . ignoreErrors . test ( msg ) ) {
348
+ return ;
349
+ }
350
+
351
+ var data = objectMerge ( {
352
+ message : msg + '' // Make sure it's actually a string
353
+ } , options ) ;
354
+
355
+ if ( options && options . stacktrace ) {
345
356
var ex ;
346
357
// create a stack trace from this point; just trim
347
358
// off extra frames so they don't include this function call (or
@@ -363,26 +374,16 @@ Raven.prototype = {
363
374
trimTailFrames : ( options . trimHeadFrames || 0 ) + 1
364
375
} , options ) ;
365
376
366
- // infinite loop if ex *somehow* returns false for isError
367
- // is that possible when it is result of try/catch?
368
- this . captureException ( ex , options ) ;
369
-
370
- return this ;
371
- }
372
-
373
- // config() automagically converts ignoreErrors from a list to a RegExp so we need to test for an
374
- // early call; we'll error on the side of logging anything called before configuration since it's
375
- // probably something you should see:
376
- if ( ! ! this . _globalOptions . ignoreErrors . test && this . _globalOptions . ignoreErrors . test ( msg ) ) {
377
- return ;
377
+ var stack = TraceKit . computeStackTrace ( ex ) ;
378
+ var frames = this . _buildNormalizedFrames ( stack , options ) ;
379
+ data . stacktrace = {
380
+ // Sentry expects frames oldest to newest
381
+ frames : frames . reverse ( )
382
+ }
378
383
}
379
384
380
385
// Fire away!
381
- this . _send (
382
- objectMerge ( {
383
- message : msg + '' // Make sure it's actually a string
384
- } , options )
385
- ) ;
386
+ this . _send ( data ) ;
386
387
387
388
return this ;
388
389
} ,
@@ -1047,9 +1048,26 @@ Raven.prototype = {
1047
1048
} ,
1048
1049
1049
1050
_handleStackInfo : function ( stackInfo , options ) {
1051
+ var frames = this . _prepareFrames ( stackInfo , options ) ;
1052
+
1053
+ this . _triggerEvent ( 'handle' , {
1054
+ stackInfo : stackInfo ,
1055
+ options : options
1056
+ } ) ;
1057
+
1058
+ this . _processException (
1059
+ stackInfo . name ,
1060
+ stackInfo . message ,
1061
+ stackInfo . url ,
1062
+ stackInfo . lineno ,
1063
+ frames ,
1064
+ options
1065
+ ) ;
1066
+ } ,
1067
+
1068
+ _prepareFrames : function ( stackInfo , options ) {
1050
1069
var self = this ;
1051
1070
var frames = [ ] ;
1052
-
1053
1071
if ( stackInfo . stack && stackInfo . stack . length ) {
1054
1072
each ( stackInfo . stack , function ( i , stack ) {
1055
1073
var frame = self . _normalizeFrame ( stack ) ;
@@ -1059,30 +1077,25 @@ Raven.prototype = {
1059
1077
} ) ;
1060
1078
1061
1079
// e.g. frames captured via captureMessage throw
1062
- if ( options . trimHeadFrames ) {
1063
- frames = frames . slice ( options . trimHeadFrames ) ;
1080
+ var j ;
1081
+ if ( options && options . trimHeadFrames ) {
1082
+ for ( j = 0 ; j < options . trimHeadFrames && j < frames . length ; j ++ ) {
1083
+ frames [ j ] . in_app = true ;
1084
+ }
1064
1085
}
1086
+
1065
1087
// e.g. try/catch (wrapper) frames
1066
- if ( options . trimTailFrames ) {
1067
- frames = frames . slice ( 0 , options . trimTailFrames ) ;
1088
+ if ( options && options . trimTailFrames ) {
1089
+ for ( j = options . trimTailFrames ; j < frames . length ; j ++ ) {
1090
+ frames [ j ] . in_app = true ;
1091
+ }
1068
1092
}
1069
1093
}
1070
-
1071
- this . _triggerEvent ( 'handle' , {
1072
- stackInfo : stackInfo ,
1073
- options : options
1074
- } ) ;
1075
-
1076
- this . _processException (
1077
- stackInfo . name ,
1078
- stackInfo . message ,
1079
- stackInfo . url ,
1080
- stackInfo . lineno ,
1081
- frames . slice ( 0 , this . _globalOptions . stackTraceLimit ) ,
1082
- options
1083
- ) ;
1094
+ frames = frames . slice ( 0 , this . _globalOptions . stackTraceLimit ) ;
1095
+ return frames ;
1084
1096
} ,
1085
1097
1098
+
1086
1099
_normalizeFrame : function ( frame ) {
1087
1100
if ( ! frame . url ) return ;
1088
1101
@@ -1108,7 +1121,6 @@ Raven.prototype = {
1108
1121
1109
1122
_processException : function ( type , message , fileurl , lineno , frames , options ) {
1110
1123
var stacktrace ;
1111
-
1112
1124
if ( ! ! this . _globalOptions . ignoreErrors . test && this . _globalOptions . ignoreErrors . test ( message ) ) return ;
1113
1125
1114
1126
message += '' ;
0 commit comments