Skip to main content
This guide explains how to capture performance profiles from your React Native application using react-native-release-profiler and seamlessly upload them to Flamedeck using the @flamedeck/upload package. This is particularly useful for understanding the performance characteristics of your app as it runs on a real device or in a production-like environment.

Prerequisites

1

Install necessary packages

  • @flamedeck/upload: For uploading the trace to Flamedeck
  • react-native-release-profiler: For capturing the performance profile from your React Native app
  • expo-file-system (if using Expo, or a similar file system module for vanilla React Native): For reading the profile file from device storage
2

Get a Flamedeck API Key

You’ll need an API key from Flamedeck to upload traces. You can obtain one from your Flamedeck settings page.
Remember to replace 'YOUR_FLAMEDECK_API_KEY' in the code example with your actual key.

Integration Steps

The core logic involves starting the profiler, executing the code you want to measure, stopping the profiler, reading the generated trace file, and then uploading it.

Example Implementation

Here’s a function demonstrating these steps. You can adapt this and trigger it, for example, from a button press in your development builds or testing scenarios.

Key Implementation Notes

File System Access: The example uses expo-file-system for Expo projects. If you’re using vanilla React Native, you’ll need to use a different file system library like react-native-fs.
Development vs Production: Consider adding environment checks to only enable profiling in development or specific testing builds to avoid impacting production performance.
API Key Security: Never hardcode your API key in production builds. Use environment variables or secure storage mechanisms to handle API keys safely.

Usage Tips

  1. Trigger Profiling: You can trigger the captureAndUploadProfile function from a button press, gesture, or specific app event
  2. Profile Specific Flows: Replace the example loop with the actual user flows or operations you want to profile
  3. Customize Metadata: Add relevant metadata like user ID, app version, or device information to help with analysis
  4. Error Handling: The example includes comprehensive error handling for common issues like empty files or upload failures

Next Steps

Once you’ve uploaded your React Native traces to Flamedeck, you can:
  • Analyze performance bottlenecks in your app
  • Compare performance across different devices or app versions
  • Share traces with your team for collaborative debugging
  • Set up automated profiling in your CI/CD pipeline