1
- import { NativeModules } from 'react-native' ;
2
- const { RNSentry} = NativeModules ;
1
+ import { NativeModules , NativeEventEmitter } from 'react-native' ;
2
+ const { RNSentry, RNSentryEventEmitter } = NativeModules ;
3
3
4
4
const DEFAULT_MODULE_IGNORES = [
5
5
'AccessibilityManager' ,
@@ -58,6 +58,10 @@ export class NativeClient {
58
58
RNSentry . startWithDsnString ( this . _dsn ) ;
59
59
if ( this . options . deactivateStacktraceMerging === false ) {
60
60
this . _activateStacktraceMerging ( ) ;
61
+ const eventEmitter = new NativeEventEmitter ( RNSentryEventEmitter ) ;
62
+ eventEmitter . addListener ( RNSentryEventEmitter . MODULE_TABLE , moduleTable => {
63
+ this . _updateIgnoredModules ( JSON . parse ( moduleTable . payload ) ) ;
64
+ } ) ;
61
65
}
62
66
RNSentry . setLogLevel ( options . logLevel ) ;
63
67
}
@@ -94,6 +98,29 @@ export class NativeClient {
94
98
RNSentry . clearContext ( ) ;
95
99
}
96
100
101
+ _updateIgnoredModules ( modules ) {
102
+ const values = Object . values ( modules ) ;
103
+ const keys = Object . keys ( modules ) ;
104
+ for ( let i = 0 ; i < values . length ; i ++ ) {
105
+ const moduleName = values [ i ] . replace ( / R C T / , '' ) ;
106
+ const moduleID = keys [ i ] ;
107
+ if ( this . _ignoredModules [ moduleID ] ) {
108
+ continue ;
109
+ }
110
+ this . _addIgnoredModule ( moduleID , moduleName ) ;
111
+ }
112
+ }
113
+
114
+ _addIgnoredModule ( moduleID , moduleName ) {
115
+ if (
116
+ this . options . ignoreModulesExclude . indexOf ( moduleName ) === - 1 &&
117
+ ( DEFAULT_MODULE_IGNORES . indexOf ( moduleName ) >= 0 ||
118
+ this . options . ignoreModulesInclude . indexOf ( moduleName ) >= 0 )
119
+ ) {
120
+ this . _ignoredModules [ moduleID ] = true ;
121
+ }
122
+ }
123
+
97
124
_activateStacktraceMerging = async ( ) => {
98
125
return RNSentry . activateStacktraceMerging ( )
99
126
. then ( activated => {
@@ -105,26 +132,15 @@ export class NativeClient {
105
132
if ( typeof __fbBatchedBridgeConfig !== 'undefined' ) {
106
133
/* global __fbBatchedBridgeConfig */
107
134
__fbBatchedBridgeConfig . remoteModuleConfig . forEach ( ( module , moduleID ) => {
108
- if (
109
- module !== null &&
110
- this . options . ignoreModulesExclude . indexOf ( module [ 0 ] ) === - 1 &&
111
- ( DEFAULT_MODULE_IGNORES . indexOf ( module [ 0 ] ) >= 0 ||
112
- this . options . ignoreModulesInclude . indexOf ( module [ 0 ] ) >= 0 )
113
- ) {
114
- this . _ignoredModules [ moduleID ] = true ;
135
+ if ( module !== null ) {
136
+ this . _addIgnoredModule ( moduleID , module [ 0 ] ) ;
115
137
}
116
138
} ) ;
117
139
} else if ( BatchedBridge . _remoteModuleTable ) {
118
- for ( let module in BatchedBridge . _remoteModuleTable ) {
119
- if ( BatchedBridge . _remoteModuleTable . hasOwnProperty ( module ) ) {
120
- let moduleName = BatchedBridge . _remoteModuleTable [ module ] ;
121
- if (
122
- this . options . ignoreModulesExclude . indexOf ( moduleName ) === - 1 &&
123
- ( DEFAULT_MODULE_IGNORES . indexOf ( moduleName ) >= 0 ||
124
- this . options . ignoreModulesInclude . indexOf ( moduleName ) >= 0 )
125
- ) {
126
- this . _ignoredModules [ module ] = true ;
127
- }
140
+ for ( let moduleID in BatchedBridge . _remoteModuleTable ) {
141
+ if ( BatchedBridge . _remoteModuleTable . hasOwnProperty ( moduleID ) ) {
142
+ let moduleName = BatchedBridge . _remoteModuleTable [ moduleID ] ;
143
+ this . _addIgnoredModule ( moduleID , moduleName ) ;
128
144
}
129
145
}
130
146
}
@@ -152,7 +168,8 @@ export class NativeClient {
152
168
return original . apply ( this , arguments ) ;
153
169
}
154
170
params . push ( {
155
- __sentry_stack : new Error ( ) . stack
171
+ __sentry_stack : new Error ( ) . stack ,
172
+ __sentry_moduleID : moduleID
156
173
} ) ;
157
174
return original . apply ( this , arguments ) ;
158
175
} ;
0 commit comments