Skip to content

Latest commit

 

History

History

react-native-startup-trace

react-native-startup-trace

⚠️ You need Firebase performance installed on your project See the Firebase docs

Getting started

$ npm install react-native-startup-trace --save

Usage

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 (
		...
	)
};

Test it works

Android

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

Usage with jest

Import the mock in the setupFiles of your jest.config.js:

setupFiles: ["./node_modules/react-native-startup-trace/jest.setup.js"];