$ npm install react-native-startup-trace --save
In ios/AppDelegate.m
:
#import <StartupTrace.h>
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
// After Firebase initialization
[StartupPerformanceTrace start];
...
return YES;
}
In MainApplication.java
import tech.bam.rnperformance.startuptrace.StartupTraceModule;
...
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
StartupTraceModule.start();
}
In App.js
import { useStopStartupTrace } from 'react-native-startup-trace';
const App = () => {
useStopStartupTrace();
return (
...
)
};
Follow the Firebase Android doc step 4 to view the logs. Then run:
adb logcat | grep STARTUP_JS
And start the app.
You should see something similar to:
FirebasePerformance: Logging trace metric - STARTUP_JS 2423.1650ms
Import the mock in the setupFiles of your jest.config.js
:
setupFiles: ["./node_modules/react-native-startup-trace/jest.setup.js"];