@@ -5,6 +5,7 @@ import { logger, timestampInSeconds } from '@sentry/utils';
55
66import type { NewFrameEvent } from '../utils/sentryeventemitter' ;
77import { type SentryEventEmitter , createSentryEventEmitter , NewFrameEventName } from '../utils/sentryeventemitter' ;
8+ import { type SentryEventEmitterFallback , createSentryFallbackEventEmitter } from '../utils/sentryeventemitterfallback' ;
89import { RN_GLOBAL_OBJ } from '../utils/worldwide' ;
910import { NATIVE } from '../wrapper' ;
1011import type { OnConfirmRoute , TransactionCreator } from './routingInstrumentation' ;
@@ -69,7 +70,7 @@ export class ReactNavigationInstrumentation extends InternalRoutingInstrumentati
6970
7071 private _navigationContainer : NavigationContainer | null = null ;
7172 private _newScreenFrameEventEmitter : SentryEventEmitter | null = null ;
72-
73+ private _newFallbackEventEmitter : SentryEventEmitterFallback | null = null ;
7374 private readonly _maxRecentRouteLen : number = 200 ;
7475
7576 private _latestRoute ?: NavigationRoute ;
@@ -92,7 +93,9 @@ export class ReactNavigationInstrumentation extends InternalRoutingInstrumentati
9293
9394 if ( this . _options . enableTimeToInitialDisplay ) {
9495 this . _newScreenFrameEventEmitter = createSentryEventEmitter ( ) ;
96+ this . _newFallbackEventEmitter = createSentryFallbackEventEmitter ( ) ;
9597 this . _newScreenFrameEventEmitter . initAsync ( NewFrameEventName ) ;
98+ this . _newFallbackEventEmitter . initAsync ( ) ;
9699 NATIVE . initNativeReactNavigationNewFrameTracking ( ) . catch ( ( reason : unknown ) => {
97100 logger . error ( `[ReactNavigationInstrumentation] Failed to initialize native new frame tracking: ${ reason } ` ) ;
98101 } ) ;
@@ -238,8 +241,8 @@ export class ReactNavigationInstrumentation extends InternalRoutingInstrumentati
238241 isAutoInstrumented : true ,
239242 } ) ;
240243
241- ! routeHasBeenSeen &&
242- latestTtidSpan &&
244+ if ( ! routeHasBeenSeen && latestTtidSpan ) {
245+ this . _newFallbackEventEmitter ?. startListenerAsync ( ) ;
243246 this . _newScreenFrameEventEmitter ?. once (
244247 NewFrameEventName ,
245248 ( { newFrameTimestampInSeconds } : NewFrameEvent ) => {
@@ -256,6 +259,7 @@ export class ReactNavigationInstrumentation extends InternalRoutingInstrumentati
256259 setSpanDurationAsMeasurementOnTransaction ( latestTransaction , 'time_to_initial_display' , latestTtidSpan ) ;
257260 } ,
258261 ) ;
262+ }
259263
260264 this . _navigationProcessingSpan ?. updateName ( `Processing navigation to ${ route . name } ` ) ;
261265 this . _navigationProcessingSpan ?. setStatus ( 'ok' ) ;
0 commit comments