# Record a TestFlight build

Record performance on a tester's phone with no Mac connected, let them send you one file, and load it into your project.

A TestFlight build can record while someone uses it away from your desk: frame rate and jank, slow screens, memory, the screens they visited and the errors they hit. The tester taps a button in your app and shares one file with you. You load it with `squiggle perf import`, and it becomes a session in your project like any run on your Mac.

Your App Store build holds none of this: it gets Squiggle’s stand-in, which records nothing.

> **Before you start**
>
> iOS only. The app uses `@squiggle.sh/react-native` with Squiggle’s Babel plugin, and your project lists the app’s bundle id under `apps` in `.squiggle/config.jsonc`.

## Keep Squiggle in the TestFlight build only

Name the build variant that keeps Squiggle, and the environment variable your builds set to choose a variant:

```
{
  "apps": { "ios": "com.acme.shop" },
  "release": { "variants": ["testflight"], "variantEnv": "APP_VARIANT" }
}
```

Then turn on recording in that variant’s build profile with `EXPO_PUBLIC_SQUIGGLE_RECORD=local`. With EAS, `eas.json`:

```
{
  "build": {
    "testflight": {
      "env": { "APP_VARIANT": "testflight", "EXPO_PUBLIC_SQUIGGLE_RECORD": "local" }
    },
    "production": {
      "env": { "APP_VARIANT": "production" }
    }
  }
}
```

Both variables have to be set when the native project is generated and when the JavaScript is bundled; EAS does both from the profile. For a local build, set them for `pod install` as well. More on variants in [Set up your app](https://squiggle.sh/docs/setup).

## Let testers send the recording

Add a row your testers open on purpose, such as **Send diagnostics** in your settings screen:

```ts
import { exportSquiggleRecording } from '@squiggle.sh/react-native';
import { Button, Share } from 'react-native';

// Only the build that records shows the row.
const records = process.env.EXPO_PUBLIC_SQUIGGLE_RECORD === 'local';

export function SendDiagnostics() {
  if (!records) return null;
  return (
    <Button
      title="Send diagnostics"
      onPress={async () => {
        const exported = await exportSquiggleRecording();
        if (exported.ok) await Share.share({ url: exported.uri });
        else console.log(exported.reason);
      }}
    />
  );
}
```

`exportSquiggleRecording()` writes one `.sqrec` file holding the current launch and the two before it, and resolves a `file://` URL the share sheet takes. Because earlier launches are included, a tester who reopens the app after a crash still sends the launch that crashed. Pass `{ launches: 1 }` to send only the current one.

It never throws. When there is nothing to send it resolves `{ ok: false, reason }`: in your App Store build the reason says Squiggle is not in the build, and in a build made without `EXPO_PUBLIC_SQUIGGLE_RECORD=local` it names that variable.

Squiggle shows testers nothing by itself. Tell them the build records performance, in TestFlight’s “What to Test” notes, and use `isSquiggleRecording()` if you want a badge. It is true only while this launch is still recording, so it turns false once the launch reaches its size cap (see below). Don’t hide the send row on it: that is when the tester most needs to send the file.

## Load it into your project

Save the file the tester sent (AirDrop, mail, a chat attachment), then run in your project:

```shell
squiggle perf import ~/Downloads/com.acme.shop-20261202-141503.sqrec
```

Output:

```text
  ✔ import: com.acme.shop-20261202-141503.sqrec → session mx2k7q1a-1 (18422 events)
    read it with squiggle perf report --session mx2k7q1a-1
  ✔ import: com.acme.shop-20261202-141503.sqrec → session mx2l0c9d-1 (40917 events)
    read it with squiggle perf report --session mx2l0c9d-1
```

Each launch in the file becomes its own session. Read them with `squiggle perf report --session <id>`, in Studio, or with the performance and product commands, the same as a session recorded on your Mac. If an earlier file held part of a launch (the tester sent it while the app was still open), importing a later file replaces that session with the fuller one and says so; a file that holds no more of a launch than you already imported leaves it as it was.

## What is recorded

- Frame rate and dropped frames, memory and the JavaScript heap, how long screens take to render, and React render counts.
- The screens visited and where the tester touched them.
- JavaScript errors and crashes.
- Network requests: their origin, path, status and timing. Never the query string, headers or bodies.
- Storage reads and writes, timed, without their values.
- The phone’s thermal state, battery and Low Power Mode.

Not recorded: text typed into fields, your app’s log lines, and your app’s state (unless you turned on state analytics and the tester consented).

## Where it is kept

- On the phone only, in the app’s Caches folder. Nothing is uploaded: the file leaves the phone when the tester shares it.
- One recording per launch, the newest three kept, each up to 16 MiB. A launch that reaches 16 MiB stops recording, and the export reports `capped: true`.
- iOS can clear the Caches folder when the phone is short of space, and deleting the app deletes the recordings.
- If the app is killed, the last second of the recording can be lost. A JavaScript crash is written before the app closes.

## When it goes wrong

- **“Squiggle is not in this build, so nothing was recorded.”** The build got the stand-in: `APP_VARIANT` did not match a name in `variants` when it was bundled. Metro prints which config file it read.
- **“This build asked to record, but its Squiggle native library can’t”** The native project was generated before the variant was set, or from an older SDK. Run `pod install` again with `APP_VARIANT` set, then rebuild.
- **The import says the app is not owned by the project.** Add the app’s bundle id to `apps` in `.squiggle/config.jsonc`, or import the file in that app’s own project.
