Installing the Freshpaint React Native SDK
Getting Started
The first step installing the Freshpaint React Native SDK is to install the @freshpaint/freshpaint-react-native
node module. If you are not using Expo and are using the React Native CLI instead, you'll also need to install and link the @react-native-community/async-storage
dependency:
Next, you'll need to setup the Freshpaint React Native babel plugin. This allows Freshpaint to instrument your app without any additional work on your part. To setup the plugin, add the following bit of code to either your .babelrc
or babel.config.json
:
Then to initialize the Freshpaint SDK, you call freshpaint.init
at the top level with your environment ID. This is normally done in the App.js
file. You can get your Freshpaint environment ID from the Freshpaint sources page.
At this point you'll need to clear any build caches for your app:
Then restart the expo app on your phone.
After that Freshpaint will automatically collect the following actions:
Touches
Text Input Edits
Switch Toggles
Text Input Edits are only captured on iOS and Android. They are not captured on React Native Web.
How it Works
Capturing Screen Views
If you are using React Native Navigation, Freshpaint can also autocapture screen views. To set this up, wrap the NavigationContainer
provided by React Navigation with Freshpaint.withReactNavigationAutotrack
:
Then use FreshpaintNavigationContainer
in place of NavigationContainer
:
Verifying your Instrumentation
You can click one of the events to dig into the specific properties captured. For example, you can see the full React component hierarchy of the captured event:
Last updated
Was this helpful?