@@ -29,6 +29,7 @@ class RNPerfMetrics {
29
29
#telemetryInfo: Object = { } ;
30
30
// map of panel location to panel name
31
31
#currentPanels = new Map < PanelLocation , string > ( ) ;
32
+ #initialResourcesLoadedInfo: null | { count : number , time : number } = null ;
32
33
33
34
isEnabled ( ) : boolean {
34
35
return globalThis . enableReactNativePerfMetrics === true ;
@@ -186,13 +187,10 @@ class RNPerfMetrics {
186
187
} ) ;
187
188
}
188
189
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 at %sms since launch' , info . count , info . time ) ;
193
+ this . #initialResourcesLoadedInfo = info ;
196
194
}
197
195
198
196
fuseboxSetClientMetadataStarted ( ) : void {
@@ -215,10 +213,30 @@ class RNPerfMetrics {
215
213
}
216
214
}
217
215
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 at %sms since launch' , cdpLowRoundtripStartTime ) ;
227
+ // eslint-disable-next-line no-console
228
+ console . info ( 'Startup time is %sms' , startupTime ) ;
229
+
219
230
this . sendEvent ( {
220
- eventName : 'FirstSteadyPing' ,
231
+ eventName : 'StartUpFinished' ,
232
+ params : {
233
+ bundleCount : this . #initialResourcesLoadedInfo. count ,
234
+ duration : startupTime ,
235
+ initialResourcesLoadedTime : this . #initialResourcesLoadedInfo. time ,
236
+ cdpLowRoundtripStartTime,
237
+ }
221
238
} ) ;
239
+ return true ;
222
240
}
223
241
224
242
heapSnapshotStarted ( ) : void {
@@ -432,13 +450,6 @@ export type DeveloperResourceLoadingFinishedEvent = Readonly<{
432
450
} > ,
433
451
} > ;
434
452
435
- export type AllInitialDeveloperResourcesLoadingFinished = Readonly < {
436
- eventName : 'DeveloperResource.AllInitialLoadingFinished' ,
437
- params : Readonly < {
438
- count : number ,
439
- } > ,
440
- } > ;
441
-
442
453
export type FuseboxSetClientMetadataStartedEvent = Readonly < {
443
454
eventName : 'FuseboxSetClientMetadataStarted' ,
444
455
} > ;
@@ -511,16 +522,22 @@ export type StackTraceFrameUrlResolutionFailed = Readonly<{
511
522
} > ,
512
523
} > ;
513
524
514
- export type FirstSteadyPing = Readonly < {
515
- eventName : 'FirstSteadyPing' ,
525
+ export type StartUpFinished = Readonly < {
526
+ eventName : 'StartUpFinished' ,
527
+ params : Readonly < {
528
+ bundleCount : number ,
529
+ duration : number ,
530
+ initialResourcesLoadedTime : number ,
531
+ cdpLowRoundtripStartTime : number ,
532
+ } > ,
516
533
} > ;
517
534
518
535
export type ReactNativeChromeDevToolsEvent =
519
536
EntrypointLoadingStartedEvent | EntrypointLoadingFinishedEvent | DebuggerReadyEvent | BrowserVisibilityChangeEvent |
520
537
BrowserErrorEvent | RemoteDebuggingTerminatedEvent | DeveloperResourceLoadingStartedEvent |
521
- DeveloperResourceLoadingFinishedEvent | AllInitialDeveloperResourcesLoadingFinished | FuseboxSetClientMetadataStartedEvent |
538
+ DeveloperResourceLoadingFinishedEvent | FuseboxSetClientMetadataStartedEvent |
522
539
FuseboxSetClientMetadataFinishedEvent | MemoryPanelActionStartedEvent | MemoryPanelActionFinishedEvent |
523
540
PanelShownEvent | PanelClosedEvent | StackTraceSymbolicationSucceeded | StackTraceSymbolicationFailed |
524
- StackTraceFrameUrlResolutionSucceeded | StackTraceFrameUrlResolutionFailed | FirstSteadyPing ;
541
+ StackTraceFrameUrlResolutionSucceeded | StackTraceFrameUrlResolutionFailed | StartUpFinished ;
525
542
526
543
export type DecoratedReactNativeChromeDevToolsEvent = CommonEventFields & ReactNativeChromeDevToolsEvent ;
0 commit comments