@@ -29,6 +29,7 @@ class RNPerfMetrics {
2929 #telemetryInfo: Object = { } ;
3030 // map of panel location to panel name
3131 #currentPanels = new Map < PanelLocation , string > ( ) ;
32+ #initialResourcesLoadedInfo: null | { count : number , time : number } = null ;
3233
3334 isEnabled ( ) : boolean {
3435 return globalThis . enableReactNativePerfMetrics === true ;
@@ -186,13 +187,10 @@ class RNPerfMetrics {
186187 } ) ;
187188 }
188189
189- allInitialDeveloperResourcesLoadingFinished ( count : number ) : void {
190- this . sendEvent ( {
191- eventName : 'DeveloperResource.AllInitialLoadingFinished' ,
192- params : {
193- count,
194- } ,
195- } ) ;
190+ initialResourcesLoaded ( info : { count : number , time : number } ) : void {
191+ // eslint-disable-next-line no-console
192+ console . info ( 'Initial %d resources are loaded after %sms' , info . count , info . time ) ;
193+ this . #initialResourcesLoadedInfo = info ;
196194 }
197195
198196 fuseboxSetClientMetadataStarted ( ) : void {
@@ -215,10 +213,28 @@ class RNPerfMetrics {
215213 }
216214 }
217215
218- firstSteadyPing ( ) : void {
216+ tryReportingCdpLowRoundtrip ( cdpLowRoundtripStartTime : number ) : boolean {
217+ if ( this . #initialResourcesLoadedInfo === null ) {
218+ return false ;
219+ }
220+
221+ // if the roundtrip is fine for a long time, just take the initial resources loading time
222+ // if it got better only after the initial resources were loaded, take the cdp low roundtrip time instead
223+ const startupTime = Math . max ( cdpLowRoundtripStartTime , this . #initialResourcesLoadedInfo. time ) ;
224+
225+ // eslint-disable-next-line no-console
226+ console . info ( 'The app had a low CDP roundtrip for %sms' , cdpLowRoundtripStartTime ) ;
227+ // eslint-disable-next-line no-console
228+ console . info ( 'Startup time is %sms' , startupTime ) ;
229+
219230 this . sendEvent ( {
220- eventName : 'FirstSteadyPing' ,
231+ eventName : 'StartUpFinished' ,
232+ params : {
233+ bundleCount : this . #initialResourcesLoadedInfo. count ,
234+ duration : performance . now ( ) ,
235+ }
221236 } ) ;
237+ return true ;
222238 }
223239
224240 heapSnapshotStarted ( ) : void {
@@ -432,13 +448,6 @@ export type DeveloperResourceLoadingFinishedEvent = Readonly<{
432448 } > ,
433449} > ;
434450
435- export type AllInitialDeveloperResourcesLoadingFinished = Readonly < {
436- eventName : 'DeveloperResource.AllInitialLoadingFinished' ,
437- params : Readonly < {
438- count : number ,
439- } > ,
440- } > ;
441-
442451export type FuseboxSetClientMetadataStartedEvent = Readonly < {
443452 eventName : 'FuseboxSetClientMetadataStarted' ,
444453} > ;
@@ -511,16 +520,20 @@ export type StackTraceFrameUrlResolutionFailed = Readonly<{
511520 } > ,
512521} > ;
513522
514- export type FirstSteadyPing = Readonly < {
515- eventName : 'FirstSteadyPing' ,
523+ export type StartUpFinished = Readonly < {
524+ eventName : 'StartUpFinished' ,
525+ params : Readonly < {
526+ bundleCount : number ,
527+ duration : number ,
528+ } > ,
516529} > ;
517530
518531export type ReactNativeChromeDevToolsEvent =
519532 EntrypointLoadingStartedEvent | EntrypointLoadingFinishedEvent | DebuggerReadyEvent | BrowserVisibilityChangeEvent |
520533 BrowserErrorEvent | RemoteDebuggingTerminatedEvent | DeveloperResourceLoadingStartedEvent |
521- DeveloperResourceLoadingFinishedEvent | AllInitialDeveloperResourcesLoadingFinished | FuseboxSetClientMetadataStartedEvent |
534+ DeveloperResourceLoadingFinishedEvent | FuseboxSetClientMetadataStartedEvent |
522535 FuseboxSetClientMetadataFinishedEvent | MemoryPanelActionStartedEvent | MemoryPanelActionFinishedEvent |
523536 PanelShownEvent | PanelClosedEvent | StackTraceSymbolicationSucceeded | StackTraceSymbolicationFailed |
524- StackTraceFrameUrlResolutionSucceeded | StackTraceFrameUrlResolutionFailed | FirstSteadyPing ;
537+ StackTraceFrameUrlResolutionSucceeded | StackTraceFrameUrlResolutionFailed | StartUpFinished ;
525538
526539export type DecoratedReactNativeChromeDevToolsEvent = CommonEventFields & ReactNativeChromeDevToolsEvent ;
0 commit comments