1- import { NativeModules } from 'react-native' ;
1+ import {
2+ NativeModules
3+ } from 'react-native' ;
24import Raven from 'raven-js' ;
35require ( 'raven-js/plugins/react-native' ) ( Raven ) ;
46
57const {
68 RNSentry
79} = NativeModules ;
810
11+ const DEFAULT_MODULE_IGNORES = [
12+ "AccessibilityManager" ,
13+ "ActionSheetManager" ,
14+ "AlertManager" ,
15+ "AppState" ,
16+ "AsyncLocalStorage" ,
17+ "Clipboard" ,
18+ "DevLoadingView" ,
19+ "DevMenu" ,
20+ "ExceptionsManager" ,
21+ "I18nManager" ,
22+ "ImageEditingManager" ,
23+ "ImageStoreManager" ,
24+ "ImageViewManager" ,
25+ "IOSConstants" ,
26+ "JSCExecutor" ,
27+ "JSCSamplingProfiler" ,
28+ "KeyboardObserver" ,
29+ "LinkingManager" ,
30+ "LocationObserver" ,
31+ "NativeAnimatedModule" ,
32+ "NavigatorManager" ,
33+ "NetInfo" ,
34+ "Networking" ,
35+ "RedBox" ,
36+ "ScrollViewManager" ,
37+ "SettingsManager" ,
38+ "SourceCode" ,
39+ "StatusBarManager" ,
40+ "Timing" ,
41+ "UIManager" ,
42+ "Vibration" ,
43+ "WebSocketModule" ,
44+ "WebViewManager"
45+ ] ;
46+
947export const SentrySeverity = {
1048 Fatal : 0 ,
1149 Error : 1 ,
@@ -80,6 +118,14 @@ class NativeClient {
80118 if ( options && options . logLevel ) {
81119 RNSentry . setLogLevel ( options . logLevel ) ;
82120 }
121+ this . _ignoreModulesExclude = [ ] ;
122+ if ( options && options . ignoreModulesExclude ) {
123+ this . _ignoreModulesExclude = options . ignoreModulesExclude ;
124+ }
125+ this . _ignoreModulesInclude = [ ] ;
126+ if ( options && options . ignoreModulesInclude ) {
127+ this . _ignoreModulesInclude = options . ignoreModulesInclude ;
128+ }
83129 if ( this . _deactivateStacktraceMerging === false ) {
84130 this . _activateStacktraceMerging ( ) ;
85131 }
@@ -115,40 +161,30 @@ class NativeClient {
115161 if ( this . _activatedMerging ) {
116162 return ;
117163 }
164+ this . _ignoredModules = { } ;
165+ __fbBatchedBridgeConfig . remoteModuleConfig . forEach ( ( module , moduleID ) => {
166+ if ( module !== null &&
167+ this . _ignoreModulesExclude . indexOf ( module [ 0 ] ) == - 1 &&
168+ ( DEFAULT_MODULE_IGNORES . indexOf ( module [ 0 ] ) >= 0 ||
169+ this . _ignoreModulesInclude . indexOf ( module [ 0 ] ) >= 0 ) ) {
170+ this . _ignoredModules [ moduleID ] = true ;
171+ }
172+ } ) ;
118173 this . _activatedMerging = true ;
119174 this . _overwriteEnqueueNativeCall ( ) ;
120175 } ) ;
121176 }
122177
123178 _overwriteEnqueueNativeCall = ( ) => {
124- let BatchedBridge = require ( 'react-native/Libraries/BatchedBridge/BatchedBridge' ) ;
125- let parseErrorStack = require ( 'react-native/Libraries/Core/Devtools/parseErrorStack' ) ;
126- let original = BatchedBridge . enqueueNativeCall ;
127- BatchedBridge . enqueueNativeCall = function ( moduleID : number , methodID : number , params : Array < any > , onFail : ?Function , onSucc : ?Function ) {
128- const stack = parseErrorStack ( new Error ( ) ) ;
129- let sendStacktrace = true ;
130- stack . forEach ( function ( frame ) {
131- if ( frame . methodName ) {
132- const mN = frame . methodName
133- if ( mN . match ( "createAnimatedNode" ) ||
134- mN . match ( "setupDevtools" ) ||
135- mN . match ( "stopAnimation" ) ||
136- mN . match ( "TimingAnimation" ) ||
137- mN . match ( "startAnimatingNode" ) ||
138- mN . match ( "AnimatedStyle" ) ||
139- mN . match ( "_cancelLongPressDelayTimeout" ) ||
140- mN . match ( "__startNativeAnimation" ) ||
141- mN . match ( "extractEvents" ) ||
142- mN . match ( "WebSocket." ) ) {
143- sendStacktrace = false ;
144- }
179+ const BatchedBridge = require ( 'react-native/Libraries/BatchedBridge/BatchedBridge' ) ;
180+ const original = BatchedBridge . enqueueNativeCall ;
181+ const that = this ;
182+ BatchedBridge . enqueueNativeCall = function ( moduleID : number , methodID : number , params : Array < any > , onFail : ? Function , onSucc : ? Function ) {
183+ if ( that . _ignoredModules [ moduleID ] ) {
184+ return original . apply ( this , arguments ) ;
145185 }
146- } ) ;
147-
148- if ( sendStacktrace ) {
149- params . push ( { '__sentry_stack' : stack } ) ;
150- }
151- return original . apply ( this , arguments ) ;
186+ params . push ( { '__sentry_stack' : new Error ( ) . stack } ) ;
187+ return original . apply ( this , arguments ) ;
152188 }
153189 }
154190}
@@ -163,7 +199,9 @@ class RavenClient {
163199 if ( options === null || options === undefined ) {
164200 options = { } ;
165201 }
166- Object . assign ( options , { allowSecretKey : true } ) ;
202+ Object . assign ( options , {
203+ allowSecretKey : true
204+ } ) ;
167205 Raven . config ( dsn , options ) . install ( ) ;
168206 }
169207
@@ -186,7 +224,7 @@ class RavenClient {
186224
187225 captureMessage = async ( message , options ) => {
188226 if ( options && options . level ) {
189- switch ( options . level ) {
227+ switch ( options . level ) {
190228 case SentrySeverity . Warning :
191229 options . level = 'warning' ;
192230 break ;
0 commit comments