Skip to content

Expo / React Native

The React Native adapter is @quameleon/qa-react-native. It ships the Kotlin and Swift cores, an Expo config plugin and a JavaScript API. It works with the New Architecture and with Hermes.

Terminal window
npx expo install @quameleon/qa-react-native
app.json
{
"expo": {
"plugins": [["@quameleon/qa-react-native", { "production": true }]]
}
}

The plugin adds ACCESS_NETWORK_STATE, bakes a build id, and exports the release sourcemap for symbolication.

  • Without production: true the plugin treats the SDK as QA-only and refuses to configure a store build unless QUAMELEON_ALLOW_STORE=1 is set.
  • With production: true store profiles are allowed, and QA activation is baked off in every build that is not an explicit QA build (dev.qualgent.quameleon.QA_ACTIVATION=false on Android, QuameleonQAActivation = NO in Info.plist), whatever the profile is called, so a store build can never be driven by a test host. QA builds are the EAS profiles in qaProfiles (default development, preview, qa, e2e) or APP_VARIANTs in qaVariants (default development, dev, preview, qa, e2e); override with those options or isQaBuild(env) in app.config.js. Debug builds can always be driven.
  • Android QA activation also needs the test host’s adb provisioning (settings put global quameleon_qa_token …, done by quameleon-qa), so another app on the device cannot activate QA mode by launching yours with a token.

Bare React Native apps get the same native modules through autolinking; run pod install after installing or upgrading.

Call startProduction as early as possible, before the first render:

app/_layout.tsx
import Quameleon, { QuameleonErrorBoundary } from "@quameleon/qa-react-native";
import { Stack, useNavigationContainerRef } from "expo-router";
import { useEffect } from "react";
if (!Quameleon.isActive()) {
// A QA run (launched with a token) is already active and stays in QA mode.
Quameleon.startProduction({
apiKey: process.env.EXPO_PUBLIC_QUAMELEON_KEY!,
endpoint: "https://quameleon.qualgent.ai",
publicKey: process.env.EXPO_PUBLIC_QUAMELEON_PUBLIC_KEY, // encrypts the spool and uploads
replay: { sampleRate: 0.1 }, // local default; remote config overrides it
});
}
export default function RootLayout() {
const nav = useNavigationContainerRef();
useEffect(() => Quameleon.trackNavigation(nav), [nav]); // one `screen` signal per route change
return (
<QuameleonErrorBoundary name="root">
<Stack />
</QuameleonErrorBoundary>
);
}

replay and deviceId are SDK 0.5 options; every other field works from 0.4. See the full list in Configuration options.

// After sign-in: links this device and its sessions to your user id. Persisted across launches.
Quameleon.identify(user.id, { plan: "pro", company: "Acme" });
// Product events, for Events, Trends, Funnels and Retention.
Quameleon.capture("order.placed", { items: 2, total: 49.9 });
// On sign-out.
Quameleon.reset();

capture is an alias of track. Props are flat: strings, numbers, booleans or null. Keys that look like secrets (password, token, authorization, …) are replaced with <redacted> on the device. See Users and identify.

Text inputs are always masked in replay. Mask anything else that shows private data:

const ref = useRef<View>(null);
useEffect(() => Quameleon.markSensitive(ref), []);
return <View ref={ref}>{/* account balance */}</View>;

Give tappable views a testID: it becomes the tap target in analytics, the node id in the hierarchy and the handle for QA assertions.

The same build can be driven by a test host. Build a QA variant (expo run:android --variant release, or a QA EAS profile without production: true), install it, and record a session:

Terminal window
npm i -D @quameleon/qa-host
npx quameleon-qa doctor
npx quameleon-qa record --android-serial emulator-5554 --package com.acme.app --out runs/1 --replay
npx quameleon-qa replay runs/1 --open

Continue with Assertions and the CLI.

One scripted test runs on both platforms (app.android and app.ios in the file):

Terminal window
npx quameleon-qa test qa-tests --android-serial emulator-5554
npx quameleon-qa test qa-tests --ios-udid booted

On Android the SDK injects real touches, which React Native’s touch system handles like a finger, into the top-most window under the target, so a Modal (a separate Dialog window) gets them and back closes it through onRequestClose. iOS has no public touch injection, and Pressables / Touchables only answer real touches, so on iOS the native SDK hands React Native views to the JS SDK: it finds the component for the views under the point through the React fiber tree (their React tags, else the step’s testID) and calls what a finger lift would: onPressIn, onPressOut, onPress (onLongPress for long_press). A disabled component does nothing. Alert.alert buttons work on iOS 26 too: Cancel through the alert’s Escape key command, any other button through the JS SDK, which keeps the last alert’s buttons and calls the onPress after the native alert is dismissed. react-native-pager-view / material top tabs switch pages on a horizontal swipe and RefreshControl refreshes on a swipe down at the top of the list. Text goes through the native TextInput like the keyboard (onChangeText and onSubmitEditing fire); when no native input is focused, the focused TextInput’s onChangeText / onSubmitEditing are called from JS. ScrollView and FlatList scroll natively. This path exists only in QA mode, never in production.

Components that handle touches without an onPress / onLongPress prop (raw onResponder* handlers, Gesture Handler gestures) can’t be driven on iOS; on Android they get real touches. disabled sets enabled: false in the hierarchy and steps wait up to 2 s for it to clear, so a button enabled by a response is tapped once it re-renders.

  • Expo 55+ replaces global fetch with Expo’s own module. Quameleon hooks both the JS fetch wrapper and the native client, so requests are captured either way.
  • EXPO_PUBLIC_* values are inlined at bundle time. Rebuild after changing the key or endpoint.
  • The Android emulator reaches a backend on your computer at http://10.0.2.2:<port>; plain http is accepted only for 127.0.0.1, localhost and 10.0.2.2.