@@ -478,6 +478,82 @@ describe('ReactNativeTracing', () => {
478478 } ) ,
479479 ) ;
480480 } ) ;
481+
482+ it ( 'adds ui kit init full length as a child of the main app start span' , async ( ) => {
483+ const integration = new ReactNativeTracing ( ) ;
484+
485+ const timeOriginMilliseconds = Date . now ( ) ;
486+ mockAppStartResponse ( {
487+ cold : true ,
488+ enableNativeSpans : true ,
489+ customNativeSpans : [
490+ {
491+ description : 'UIKit init' ,
492+ start_timestamp_ms : timeOriginMilliseconds - 100 ,
493+ end_timestamp_ms : timeOriginMilliseconds - 60 ,
494+ } ,
495+ ] ,
496+ } ) ;
497+ mockReactNativeBundleExecutionStartTimestamp ( ) ;
498+
499+ setup ( integration ) ;
500+
501+ await jest . advanceTimersByTimeAsync ( 500 ) ;
502+ await jest . runOnlyPendingTimersAsync ( ) ;
503+
504+ const transaction = client . event ;
505+
506+ const nativeSpan = transaction ! . spans ! . find ( ( { description } ) => description ?. startsWith ( 'UIKit Init' ) ) ;
507+ const nativeSpanJSON = spanToJSON ( nativeSpan ! ) ;
508+
509+ expect ( nativeSpan ) . toBeDefined ( ) ;
510+ expect ( nativeSpanJSON ) . toEqual (
511+ expect . objectContaining ( < SpanJSON > {
512+ description : 'UIKit Init' ,
513+ start_timestamp : ( timeOriginMilliseconds - 100 ) / 1000 ,
514+ timestamp : ( timeOriginMilliseconds - 60 ) / 1000 ,
515+ } ) ,
516+ ) ;
517+ } ) ;
518+
519+ it ( 'adds ui kit init start mark as a child of the main app start span' , async ( ) => {
520+ const integration = new ReactNativeTracing ( ) ;
521+
522+ const timeOriginMilliseconds = Date . now ( ) ;
523+ mockAppStartResponse ( {
524+ cold : true ,
525+ enableNativeSpans : true ,
526+ customNativeSpans : [
527+ {
528+ description : 'UIKit init' ,
529+ start_timestamp_ms : timeOriginMilliseconds - 100 ,
530+ end_timestamp_ms : timeOriginMilliseconds - 20 , // After mocked bundle execution start
531+ } ,
532+ ] ,
533+ } ) ;
534+ mockReactNativeBundleExecutionStartTimestamp ( ) ;
535+
536+ setup ( integration ) ;
537+
538+ await jest . advanceTimersByTimeAsync ( 500 ) ;
539+ await jest . runOnlyPendingTimersAsync ( ) ;
540+
541+ const transaction = client . event ;
542+
543+ const nativeRuntimeInitSpan = transaction ! . spans ! . find ( ( { description } ) =>
544+ description ?. startsWith ( 'UIKit Init to JS Exec Start' ) ,
545+ ) ;
546+ const nativeRuntimeInitSpanJSON = spanToJSON ( nativeRuntimeInitSpan ! ) ;
547+
548+ expect ( nativeRuntimeInitSpanJSON ) . toBeDefined ( ) ;
549+ expect ( nativeRuntimeInitSpanJSON ) . toEqual (
550+ expect . objectContaining ( < SpanJSON > {
551+ description : 'UIKit Init to JS Exec Start' ,
552+ start_timestamp : ( timeOriginMilliseconds - 100 ) / 1000 ,
553+ timestamp : ( timeOriginMilliseconds - 50 ) / 1000 ,
554+ } ) ,
555+ ) ;
556+ } ) ;
481557 } ) ;
482558
483559 describe ( 'With routing instrumentation' , ( ) => {
@@ -1068,10 +1144,12 @@ function mockAppStartResponse({
10681144 cold,
10691145 has_fetched,
10701146 enableNativeSpans,
1147+ customNativeSpans,
10711148} : {
10721149 cold : boolean ;
10731150 has_fetched ?: boolean ;
10741151 enableNativeSpans ?: boolean ;
1152+ customNativeSpans ?: NativeAppStartResponse [ 'spans' ] ;
10751153} ) {
10761154 const timeOriginMilliseconds = Date . now ( ) ;
10771155 const appStartTimeMilliseconds = timeOriginMilliseconds - 100 ;
@@ -1086,6 +1164,7 @@ function mockAppStartResponse({
10861164 start_timestamp_ms : timeOriginMilliseconds - 100 ,
10871165 end_timestamp_ms : timeOriginMilliseconds - 50 ,
10881166 } ,
1167+ ...( customNativeSpans ?? [ ] ) ,
10891168 ]
10901169 : [ ] ,
10911170 } ;
0 commit comments