The measuring build
This page is for whoever owns your app’s build. It says what the SDK changes in a measuring build, which variables turn it on, and how to check that a store build carries none of it.
keepsnappy init makes these changes for you (Getting started). For an app with its own ios/ and android/ folders that never runs expo prebuild, see Bare React Native.
What the SDK does
The SDK is @keepsnappy/react-native. It measures from inside your app: taps, screens and React render times. You add no app code.
A build carries the SDK only when KEEPSNAPPY=1 is set while it is built. This page calls it the build switch. Your store builds leave it unset, so they carry none of the SDK (Store builds).
When init leaves a step to you, Install by hand has the versions, the install commands and the config changes.
Plugin options
| Option | Default | Effect |
|---|---|---|
measureFromLaunch | true | Measures from launch. |
renderTimes | true | Records render times per component, with React’s profiling renderer. |
waitForActivation | false | Measures nothing until keepsnappy run activates the app, from its next launch. Wins over measureFromLaunch. |
tapText | true | false: never reads text on screen to name a tap. |
Leave renderTimes on. Render times are the main measure a result is judged on (How a result is decided).
waitForActivation lets one build also serve your other test jobs. keepsnappy run activates such a build on Android. On an iOS simulator it does so when keepsnappy.yml sets app.wait_for_activation to true, and it switches the activation off after the last run. It can’t activate the build on an iPhone on a cable, so use a build without this option there.
A tapped element with no test id and no accessibility label is named by its text on screen. Use test accounts and test data, or set tapText to false.
An option the SDK doesn’t know fails the build. Keys go in build variables, never in the options.
The build switch
The SDK reads these variables when the app is built. Set each one the same way for expo prebuild and for the build.
| Variable | Value | Effect |
|---|---|---|
KEEPSNAPPY | 1 | Puts the SDK into the build. Any other value, or none, leaves it out, whatever the options say. |
EXPO_PUBLIC_KEEPSNAPPY_KEY, EXPO_PUBLIC_KEEPSNAPPY_INGEST_URL | from Setup | Only for a build whose app sends its own measurements. See below. |
KEEPSNAPPY_METRO_GRAPH | 0 | Stops saving the Metro dependency graph (Your data). |
The SDK key can only send measurements; it is built into the app, so treat it as public. A build whose app sends the measurements itself needs EXPO_PUBLIC_KEEPSNAPPY_KEY and EXPO_PUBLIC_KEEPSNAPPY_INGEST_URL: Android, BrowserStack and every run through the Appium driver or the farm command. Only keepsnappy run --upload on an iOS simulator or a cabled iPhone needs neither in the build: the CLI reads the data off the device.
Route by route:
- iOS, on a simulator or an iPhone on a cable:
keepsnappy run --platform ios-sim --uploadreads the app’s data from the simulator withxcrun simctland uploads it with the CI key.keepsnappy run --platform ios-device --uploaddoes the same on a cabled iPhone withdevicectl. The build carries neither variable. - Android, on an emulator or a phone on a cable:
keepsnappy run --platform android-emulator(orandroid-device) has the app send its own measurements. The build must carryEXPO_PUBLIC_KEEPSNAPPY_KEYandEXPO_PUBLIC_KEEPSNAPPY_INGEST_URL(Android). - Real phones on BrowserStack, iOS or Android:
farm openstarts the session, your test tool runs, andfarm closeends it. The app sends its own measurements here too, so the build needs the same two variables (BrowserStack).
Without them nothing arrives. keepsnappy run then prints Session failed: no run sent any data. Check that the build carries the SDK and that the app reaches the API. A BrowserStack session prints No iteration sent any data.
Metro reads the values when it bundles the app, and it caches what it bundled. After you change a variable or an option, clear the cache: npx expo start --clear.
Older setups
Builds set up with older variables still build as before. EXPO_PUBLIC_KEEPSNAPPY=1 works like KEEPSNAPPY=1. EXPO_PUBLIC_KEEPSNAPPY_AUTO=1 stands for measureFromLaunch, and EXPO_PUBLIC_KEEPSNAPPY_PROFILE=1 or KEEPSNAPPY_REACT_PROFILING=1 for renderTimes. A variable you set wins over its option, and only over the part it covers.
Make a Release build
A measuring build is a Release build with KEEPSNAPPY=1. If your app’s eas.json profiles are all development-client builds, none of them makes one. Build Release by hand, on your machine or in CI, with the commands below. They don’t use eas.json.
Run the same setup scripts your normal Release build needs, such as code generation or compiling translations. A KeepSnappy build still needs their output. If the build stops, look for the first error from those scripts or the compiler in the build log.
If you use an iPhone on a cable, follow the iPhone build and install steps. Before uploading an iOS build to a device farm, check its signing instructions. Your build job needs access to its signing keychain and the provisioning profiles for the Release bundle ID and each extension it includes. Check app groups and push entitlements against those profiles. For a fork, use bundle IDs your signing team controls.
If the build waits for activation, check that your run route can activate it. The SDK options explain how this works on Android and iOS, and BrowserStack shows where the run token is used on the farm.
iOS, on a simulator. Set KEEPSNAPPY=1 in the shell that runs both commands:
export KEEPSNAPPY=1npx expo prebuild --platform iosnpx expo run:ios --configuration Release --device "iPhone 16"Android, on an emulator or a phone. The app sends its own measurements, so set the key and the address too, from Setup. Replace both quoted placeholders first:
export KEEPSNAPPY=1export EXPO_PUBLIC_KEEPSNAPPY_KEY='<your SDK key>'export EXPO_PUBLIC_KEEPSNAPPY_INGEST_URL='https://REPLACE_WITH_YOUR_API_HOST'npx expo prebuild --platform android --no-installcd android && ./gradlew assembleReleaseThe APK is android/app/build/outputs/apk/release/app-release.apk. For an emulator on a Linux CI machine, add -PreactNativeArchitectures=x86_64 to the gradlew command.
An app that never runs expo prebuild builds another way: see Bare React Native.
Store builds
Without KEEPSNAPPY=1, and without the older EXPO_PUBLIC_KEEPSNAPPY=1, Metro leaves your bundle unchanged. The config plugin also leaves the SDK’s native module out of the iOS and Android projects. Run expo prebuild without either variable before a store build. Check your .env and EAS profiles for the older one.
To check a store build, count the SDK’s marker in its JS bundle: main.jsbundle inside the .app, or assets/index.android.bundle in the unzipped APK. The count must be 0. A Hermes bundle is binary, and grep prints nothing for a binary file without -a, so keep the -a:
grep -a -c __KEEPSNAPPY_HOOK__ main.jsbundleKeys
Keys says what each KeepSnappy key does, where you get it, where it goes, and how to replace or stop it.