1- import { NativeModules } from 'react-native' ;
2- const { RNSentry} = NativeModules ;
1+ import { NativeModules , NativeEventEmitter } from 'react-native' ;
2+ const { RNSentry, RNSentryEventEmitter } = NativeModules ;
33
44const DEFAULT_MODULE_IGNORES = [
55 'AccessibilityManager' ,
@@ -58,6 +58,10 @@ export class NativeClient {
5858 RNSentry . startWithDsnString ( this . _dsn ) ;
5959 if ( this . options . deactivateStacktraceMerging === false ) {
6060 this . _activateStacktraceMerging ( ) ;
61+ const eventEmitter = new NativeEventEmitter ( RNSentryEventEmitter ) ;
62+ eventEmitter . addListener ( RNSentryEventEmitter . MODULE_TABLE , moduleTable => {
63+ this . _updateIgnoredModules ( JSON . parse ( moduleTable . payload ) ) ;
64+ } ) ;
6165 }
6266 RNSentry . setLogLevel ( options . logLevel ) ;
6367 }
@@ -94,6 +98,29 @@ export class NativeClient {
9498 RNSentry . clearContext ( ) ;
9599 }
96100
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+
97124 _activateStacktraceMerging = async ( ) => {
98125 return RNSentry . activateStacktraceMerging ( )
99126 . then ( activated => {
@@ -105,26 +132,15 @@ export class NativeClient {
105132 if ( typeof __fbBatchedBridgeConfig !== 'undefined' ) {
106133 /* global __fbBatchedBridgeConfig */
107134 __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 ] ) ;
115137 }
116138 } ) ;
117139 } 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 ) ;
128144 }
129145 }
130146 }
@@ -152,7 +168,8 @@ export class NativeClient {
152168 return original . apply ( this , arguments ) ;
153169 }
154170 params . push ( {
155- __sentry_stack : new Error ( ) . stack
171+ __sentry_stack : new Error ( ) . stack ,
172+ __sentry_moduleID : moduleID
156173 } ) ;
157174 return original . apply ( this , arguments ) ;
158175 } ;
0 commit comments