@@ -187,7 +187,10 @@ export class ReactNativeTracing implements Integration {
187187 /**
188188 * Registers routing and request instrumentation.
189189 */
190- public setupOnce ( addGlobalEventProcessor : ( callback : EventProcessor ) => void , getCurrentHub : ( ) => Hub ) : void {
190+ public async setupOnce (
191+ addGlobalEventProcessor : ( callback : EventProcessor ) => void ,
192+ getCurrentHub : ( ) => Hub ,
193+ ) : Promise < void > {
191194 const hub = getCurrentHub ( ) ;
192195 const client = hub . getClient ( ) ;
193196 const clientOptions = client && client . getOptions ( ) ;
@@ -203,7 +206,6 @@ export class ReactNativeTracing implements Integration {
203206 tracePropagationTargets : thisOptionsTracePropagationTargets ,
204207 routingInstrumentation,
205208 enableAppStartTracking,
206- enableNativeFramesTracking,
207209 enableStallTracking,
208210 } = this . options ;
209211
@@ -240,20 +242,7 @@ export class ReactNativeTracing implements Integration {
240242 } ) ;
241243 }
242244
243- if ( enableNativeFramesTracking ) {
244- NATIVE . enableNativeFramesTracking ( ) ;
245- this . nativeFramesInstrumentation = new NativeFramesInstrumentation ( addGlobalEventProcessor , ( ) => {
246- const self = getCurrentHub ( ) . getIntegration ( ReactNativeTracing ) ;
247-
248- if ( self ) {
249- return ! ! self . nativeFramesInstrumentation ;
250- }
251-
252- return false ;
253- } ) ;
254- } else {
255- NATIVE . disableNativeFramesTracking ( ) ;
256- }
245+ this . _enableNativeFramesTracking ( addGlobalEventProcessor ) ;
257246
258247 if ( enableStallTracking ) {
259248 this . stallTrackingInstrumentation = new StallTrackingInstrumentation ( ) ;
@@ -366,6 +355,40 @@ export class ReactNativeTracing implements Integration {
366355 return this . _inflightInteractionTransaction ;
367356 }
368357
358+ /**
359+ * Enables or disables native frames tracking based on the `enableNativeFramesTracking` option.
360+ */
361+ private _enableNativeFramesTracking ( addGlobalEventProcessor : ( callback : EventProcessor ) => void ) : void {
362+ if ( this . options . enableNativeFramesTracking && ! NATIVE . enableNative ) {
363+ // Do not enable native frames tracking if native is not available.
364+ logger . warn (
365+ '[ReactNativeTracing] NativeFramesTracking is not available on the Web, Expo Go and other platforms without native modules.' ,
366+ ) ;
367+ return ;
368+ }
369+
370+ if ( ! this . options . enableNativeFramesTracking && NATIVE . enableNative ) {
371+ // Disable native frames tracking when native available and option is false.
372+ NATIVE . disableNativeFramesTracking ( ) ;
373+ return ;
374+ }
375+
376+ if ( ! this . options . enableNativeFramesTracking ) {
377+ return ;
378+ }
379+
380+ NATIVE . enableNativeFramesTracking ( ) ;
381+ this . nativeFramesInstrumentation = new NativeFramesInstrumentation ( addGlobalEventProcessor , ( ) => {
382+ const self = getCurrentHub ( ) . getIntegration ( ReactNativeTracing ) ;
383+
384+ if ( self ) {
385+ return ! ! self . nativeFramesInstrumentation ;
386+ }
387+
388+ return false ;
389+ } ) ;
390+ }
391+
369392 /**
370393 * Sets the current view name into the app context.
371394 * @param event Le event.
0 commit comments