# Distribution and updates

## Test builds (leaving feedback while playing)

Builds for testers and clients can include a way to leave feedback on the scene while playing. Product exports don't include it (when it's left out, its code isn't in the engine bundle at all).

```bash
lim build [project] browser --feedback     # a test build (the same for the Mac version and others)
```

```json
"build": {
  "feedback": { "url": "https://example.com/feedback" },
  "variants": { "test": { "feedback": true } }
}
```

- A test build is made with `lim build --feedback`, "Test build" in the authoring app's export screen, or an edition with `feedback: true` (`--variant test`)
- A test build isn't exported to the same place as the product. The browser version goes to `<out>/browser/<id>-test` (`<id>-<name>-test` for an edition), and the desktop and smartphone versions get `_test` in their names
  (`<out>/windows/<name>_test_<datetime>/`; the Windows installer installs it as a separate app from the product). `feedback: true` is written to `project/build.json` and `build-history.jsonl`
- A test build exports images and sounds that the scenario or characters use but that don't exist yet as stand-ins (a card with "MISSING" and the asset's name for images, silence for sounds).
  This lets people read a scenario before the art and sound are ready. The cards are the same size as the dev server's (screen size for backgrounds, a person's shape for sprites, 16:9 for images). Other kinds of missing assets, such as videos,
  and names that differ only in case still stop a test build. Product exports stop on missing assets as before
- `lim publish itch`, `lim publish steam`, `lim update-manifest` and `lim patch` stop if what they upload (or start from) is a test build. Add `--allow-test` to upload a test build
- In a test build, "Feedback" at the top left and F8 take a screenshot of the page and open the feedback panel. Each piece of feedback carries the script file and line,
  the page key (which points to the same page even after lines are added), the screenshot, the name (remembered), the time, and the version and edition
- With `build.feedback.url`, feedback is sent as a POST of JSON (`kind: "liminalia-feedback"`; as with `build.crashReport`, you provide the receiving side).
  Without it, the player saves `<project ID>-<date-time>.liminalia-feedback.json` and passes it on (on phones, through the share sheet)
- Feedback you receive becomes comments on its script lines with "Import feedback…" in Studio's Comments screen (docs/studio.md, "Comments"). JSON received at the URL can be imported the same way once saved as a file

## Crash records and source maps

Exported games keep a record of one uncaught exception (["Crash reports" in player.md](../player.md#クラッシュレポート)). If you write `build.crashReport.url`,
the game asks the player at the next launch and then sends that JSON as a POST (you provide the receiving side). The record contains the following.

| Field | Contents |
|---|---|
| `message`, `stack`, `kind` | The exception's message and stack. `kind` is `error` (an uncaught exception) or `rejection` (an unhandled Promise rejection) |
| `source` | Where in the program the exception happened (`engine/….js:line:column` in the exported bundle; only for `error`) |
| `at`, `step` | The last page shown (`file:line`), and the position of the command being run (when it stopped on a command partway through a page) |
| `trail`, `diagnostics` | The pages shown before it stopped (the last 10 pages) and the runtime diagnostics (the last 10; `file:line [code] message`) |
| `version`, `build`, `engine`, `platform`, `language`, `screen`, `userAgent`, `date` | The game version, the export date and time, the engine version (`engine` in `project/build.json`), the environment it was played in (`browser`, `desktop`, `ios`, `android`), the language, the screen size, the browser, and the date and time |

The positions in `stack` and `source` are positions in the minified bundle, so map them back to the original program with source maps. `build.sourcemap` chooses whether to make them (by default they aren't made).

```json
"build": { "sourcemap": "separate" }
```

- `"separate"`: they aren't put in the files you distribute, and are kept in `sourcemaps/<project ID>-<export date-time>/` in the export folder. The date and time are the same as `build` in the record,
  so you can pick the ones that match a record you receive. To map positions back, use `lim crash` (below).
  They pile up with every export, so only the newest `build.keepSourcemaps` (or `build.keep` if that isn't set) for each name are kept and the rest are deleted ("Cleaning up exports" below).
  To keep them for reading records from distributed versions, raise `build.keepSourcemaps`, set it to `0` (delete nothing) or copy them outside `dist`
- `"include"`: they're put in the export (players can see the original program in their developer tools. The code of the project's plugins can be seen too, so think it over before choosing this for a release)

The environment variable `LIMINALIA_BUILD_SOURCEMAP=1` also includes them, the same as `"include"` (for looking into what makes up the bundle).

Pass a record you receive to `lim crash`, and it picks the source map copy by the `build` time in the record, maps the positions in `source` and `stack` back to the original files and lines,
and shows them next to the script positions (`at`, `step`, `trail`, `diagnostics`). If you copied the source maps somewhere else, give that folder with `--maps`.

```bash
lim crash crash.json             # add --json for JSON output
lim crash crash.json --maps ~/maps/game-2026-11-08T01-02-03-004Z
```

If there's no matching copy or no position could be mapped back, the exit code is 1 (the script positions are still shown). From an AI assistant, the MCP tool `read_crash_report` reads the same thing.

## Play statistics (optional)

To find out how often each choice is picked and where players stop playing, write a destination in `build.analytics.url`. If you don't, nothing is sent (the default).

```json
"build": { "analytics": { "url": "https://example.com/analytics" } }
```

- The first time the exported game starts, it asks the player whether it may send them. It sends them only if the player answers "Yes"; until the player answers, and if they answer "No," nothing is sent.
  The player can change this at any time with "Send play statistics" in Settings (the answer is remembered on that device). The development server, the preview in Studio and automated checks (`lim playtest` and so on) don't ask and don't send
- Only the choices picked (the choice's line, which of the options shown it was, out of how many, and the jump target) and the last page shown when the game was closed or sent to the background are sent.
  The text (which can include names players entered), variables, saves, and IDs that identify a device or person aren't sent. Events are grouped by a marker made for each launch (`session`)
- They're sent together as a POST every 20 choices and when the game is closed or sent to the background. The body is JSON (`Content-Type` is `text/plain`, to avoid the browser's preflight request)

```json
{
  "project": "my_game", "version": "1.0.0", "session": "3f1c…", "platform": "browser", "language": "",
  "events": [
    { "type": "choice", "at": "chapter1:120", "option": 1, "options": 3, "target": "chapter1#north", "time": 640 },
    { "type": "leave", "at": "chapter2:48", "time": 1830 }
  ]
}
```

For the share of each option, count the `choice` events with the same `at` by `option`. For where players stopped, count the last `leave` of each `session` (a player who keeps playing gets a different `session` at the next launch).
You provide the receiving side (your own server), and include it in your store declarations and the game's privacy policy ("Store declarations" below).
