Replies: 2 comments 3 replies
-
I'm sorry I don't understand, you state you have read the documentation, but you want a simple example. The documentation contains a simple example Perhaps you should describe the tests you have performed (with the code you used), the results you obtained, why they are confusing, and where specifically you need help in order to obtain the results you want related to the tests you provided. https://stackoverflow.com/help/how-to-ask |
Beta Was this translation helpful? Give feedback.
-
I have a custom implementation. I use onStateChange of NavigationContainer and start on a route mount and stop on route change. I'm not sure if this works correctly or not. I inherited this piece of code. Does the tracer continues with the instance till stop is called, or we need to let the await on startScreenTrace handle itself? @mikehardy // screenTrace.js
import perf from '@react-native-firebase/perf';
import crashlytics from '@react-native-firebase/crashlytics';
async function screenTrace(screenName) {
try {
const trace = await perf().startScreenTrace(screenName);
return {
async stop() {
try {
await trace.stop();
} catch (err) {
crashlytics().recordError(err)
}
},
};
} catch (err) {
crashlytics().recordError(err)
return null;
}
}
export default screenTrace;
// onStateChange
if (previousRouteKey !== currentRouteKey) {
if (!prevRoutePerfRef.current) {
screenTrace(currentRouteName).then((trace) => {
prevRoutePerfRef.current = trace;
});
} else {
// Close the previous trace
prevRoutePerfRef.current?.stop?.().then(() =>
screenTrace(currentRouteName).then((trace) => {
prevRoutePerfRef.current = trace;
})
);
}
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I need guidance on using the
startScreenTrace
function.I've checked the documentation, but I'm still unsure about how to apply it to screen components in my app.
Can anyone provide a simple example of how to implement this for tracking screen performance? Any help would be much appreciated!
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions