> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> To set up Hatchmark for a user, follow https://hatchmark.dev/docs/get-started/agent-setup.md. Inside a Hatchmark project, prefer `hatchmark docs`: it prints the docs of the installed version.

# Telemetry

> The anonymous usage events the hatchmark CLI records and sends at most once an hour, field by field, and every way to turn them off.

The `hatchmark` command line tool records one small anonymous event for each command and sends
them at most once an hour, so we can see which commands people use, which errors they hit, and how
long commands take. It never sends your specs, data, SQL, file paths or project names. You can turn it off at any time.

## What is sent

At most one request an hour, posted to `https://api.hatchmark.dev/v1/telemetry` with the headers
`Content-Type: application/json` and `User-Agent: hatchmark/<version>`, carrying the machine's
random ID and every event queued since the last request:

```json theme={null}
{
  "id": "3f1c2b9e-8d4a-4f6b-9c2e-1a7d5e3b8f20",
  "events": [
    {
      "uuid": "9b2d7c41-6e0a-4c3f-8b15-2f4e7a9d0c63",
      "command": "build",
      "codes": ["HM2003"],
      "version": "0.4.1",
      "os": "darwin",
      "duration_ms": 1834,
      "agent": true
    },
    {
      "uuid": "e41a5f08-3b7c-4d92-a6e1-7c0b9f2d5a84",
      "command": "check",
      "codes": [],
      "version": "0.4.1",
      "os": "darwin",
      "duration_ms": 412,
      "agent": true
    }
  ]
}
```

`id` belongs to the request; each event has the fields below.

| Field | What it holds |
| - | - |
| `uuid` | A random ID for this event, so an event that arrives twice is counted once. |
| `command` | The command name, such as `build` or `check`; `help` for help; `null` for a command Hatchmark doesn't know. Arguments and option values are never sent. |
| `codes` | The diagnostic codes of the errors the command reported, such as `HM2003`, at most 20, without their messages. Empty when it succeeded. |
| `version` | The Hatchmark version. |
| `os` | The platform as Node.js names it: `darwin`, `linux`, `win32` and so on. |
| `duration_ms` | How long the command took, in whole milliseconds. |
| `agent` | `true` when an AI coding agent ran the command (detected with `@vercel/detect-agent`, the same check that picks JSON output). |

Nothing else is sent, and the collector refuses any event with another field. It does not keep or
pass on your IP address, and it stores events with our analytics provider, PostHog, as anonymous
events with no person profile and no location lookup. Events carry no time of their own; they are
dated when the request arrives, so their times are accurate to about an hour.

## When it is sent

* The first time a command runs with telemetry on, Hatchmark creates the random ID, prints a
  notice on stderr and records nothing for that command.
* After that, each command adds its event to a queue in the setting file (below). At most 100
  events are kept; when the queue is full, the oldest event is dropped. Commands that run at the
  same moment take turns on the file; a command that finds it busy skips recording its event
  rather than wait.
* Before sending, every queued event is checked against the format above, and anything that
  doesn't match, such as an edited file with extra fields, is dropped.
* When a command finishes and an hour or more has passed since the last request (or since the
  notice), Hatchmark empties the queue and sends all of it in one request. A separate background
  process sends it once, with a 3 second timeout, so a slow or missing network never slows a
  command down or changes its output or exit code. A request that fails is not retried; its events
  are dropped.
* `hatchmark telemetry` itself is never recorded.

## Turning it off

Any one of these turns telemetry off. They are checked in this order, and the first that applies wins.
While one is in effect, nothing is recorded and nothing is sent:

1. `DO_NOT_TRACK=1` in the environment (any value except empty, `0` or `false`).
2. `HATCHMARK_TELEMETRY_DISABLED=1` in the environment (same values).
3. `telemetry: false` in the project's `hatchmark.yaml`, which turns it off for everyone who runs
   Hatchmark in that project, CI included. `hatchmark init` writes `telemetry: true`, which leaves
   the choice to each person.
4. `hatchmark telemetry disable`, which turns it off for every project on this machine and deletes
   the random ID and the queued events. `hatchmark telemetry enable` turns it back on with a new ID.

Only `hatchmark telemetry disable` deletes events already queued. The other switches pause
telemetry, so events queued before you set `DO_NOT_TRACK`, for example, are still sent once the
switch is gone. Run `hatchmark telemetry disable` to discard them.

`hatchmark telemetry` (or `hatchmark telemetry status`) shows whether events are sent, which switch
turned them off, the random ID, how many events are queued, and where the setting is stored. The setting lives in
`telemetry.json` under `$XDG_CONFIG_HOME/hatchmark/`, `%APPDATA%\hatchmark\` on Windows, or
`~/.config/hatchmark/` otherwise. The file holds whether telemetry is on (`enabled`), the ID, the
time of the last request and the queue, nothing else. When Hatchmark can't write it, it records
and sends nothing. When the file exists but can't be read or doesn't have that shape, telemetry is
off and the file is left as it is until `hatchmark telemetry enable` or `disable` rewrites it.

In JSON mode `hatchmark telemetry` prints:

```json theme={null}
{
  "format_version": "1",
  "action": "status",
  "enabled": false,
  "off": "DO_NOT_TRACK",
  "id": null,
  "queued": 0,
  "file": "/home/me/.config/hatchmark/telemetry.json"
}
```

`off` is `null` when telemetry is on, otherwise one of `DO_NOT_TRACK`,
`HATCHMARK_TELEMETRY_DISABLED`, `hatchmark.yaml`, `hatchmark telemetry disable` or
`unreadable setting`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.