@@ -221,6 +221,9 @@ Raven.prototype = {
221
221
TraceKit . report . subscribe ( function ( ) {
222
222
self . _handleOnErrorStackInfo . apply ( self , arguments ) ;
223
223
} ) ;
224
+
225
+ self . _patchFunctionToString ( ) ;
226
+
224
227
if ( self . _globalOptions . instrument && self . _globalOptions . instrument . tryCatch ) {
225
228
self . _instrumentTryCatch ( ) ;
226
229
}
@@ -377,6 +380,7 @@ Raven.prototype = {
377
380
uninstall : function ( ) {
378
381
TraceKit . report . uninstall ( ) ;
379
382
383
+ this . _unpatchFunctionToString ( ) ;
380
384
this . _restoreBuiltIns ( ) ;
381
385
382
386
Error . stackTraceLimit = this . _originalErrorStackTraceLimit ;
@@ -939,6 +943,25 @@ Raven.prototype = {
939
943
} ) ;
940
944
} ,
941
945
946
+ _patchFunctionToString : function ( ) {
947
+ var self = this ;
948
+ self . _originalFunctionToString = Function . prototype . toString ;
949
+ // eslint-disable-next-line no-extend-native
950
+ Function . prototype . toString = function ( ) {
951
+ if ( typeof this === 'function' && this . __raven__ ) {
952
+ return self . _originalFunctionToString . apply ( this . __orig_method__ , arguments ) ;
953
+ }
954
+ return self . _originalFunctionToString . apply ( this , arguments ) ;
955
+ } ;
956
+ } ,
957
+
958
+ _unpatchFunctionToString : function ( ) {
959
+ if ( this . _originalFunctionToString ) {
960
+ // eslint-disable-next-line no-extend-native
961
+ Function . prototype . toString = this . _originalFunctionToString ;
962
+ }
963
+ } ,
964
+
942
965
/**
943
966
* Wrap timer functions and event targets to catch errors and provide
944
967
* better metadata.
0 commit comments