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

# Metrics

> Query your company's analytics from the terminal: the full catalog by category, a single metric, or a whole dashboard — with filters, time windows, and templates.

`jelou metrics` reads the same analytics catalog the Studio dashboards read —
eight categories: `inbox`, `ecommerce`, `payments`, `voice`, `biometrics`,
`brain`, `ai`, `general`. The catalog is per-company and served live, so
**discover before you fetch** — never hardcode a key from memory.

```bash theme={null}
jelou metrics list --agent                                 # whole catalog
jelou metrics list --category ecommerce --agent            # one category
jelou metrics get ecommerce_sales_kpis --last 30d --agent  # one metric
jelou metrics dashboard --template ecommerce --agent       # a whole board
jelou metrics dashboard --agent                             # the headline board
```

## Listing the catalog

```bash theme={null}
jelou metrics list                          # everything, human-readable
jelou metrics list --category payments      # just one category
jelou metrics list --json                   # includes each metric's filters and shape
```

| Flag                | Description                                                                       |
| ------------------- | --------------------------------------------------------------------------------- |
| `--category <cat>`  | `inbox`, `ecommerce`, `payments`, `voice`, `biometrics`, `brain`, `ai`, `general` |
| `--origin <origin>` | `default`, `custom`, or `datum` (all three are merged by default)                 |

`list` merges three catalog origins. If one fails, the command still exits 0
with the metrics it could read, and names the rest in `errors[]` — check
`failed` before concluding a key doesn't exist.

The seven pre-v2 legacy slugs (`dau_total`, `dau_ai_total`,
`unique_users_total`, `unique_users_per_day`, `brain_sessions`,
`bic_billing_sessions`, `hsm_by_sent_status`) still resolve and return their
usual envelope — they show up flagged `legacy: true` in `--json`.

## Fetching one metric

```bash theme={null}
jelou metrics get ecommerce_sales_kpis --last 30d
jelou metrics get payments_success_rate --last 7d --agent
jelou metrics get brain_top_words --bot-id <bot-id> --last 30d
jelou metrics get dau_ai_total --period currentYear   # legacy slug, legacy window
```

Keys are case-insensitive, and the invocation-name tail works when it's
unambiguous. In an interactive terminal it renders as a card or chart; in
`--json`/`--agent` mode (or with stdout redirected) it emits the JSON
envelope.

### Time windows

| Flag                                                       | Description                              |
| ---------------------------------------------------------- | ---------------------------------------- |
| `--last <7d\|30d\|90d\|12m>`                               | Rolling window. Prefer it.               |
| `--period <today\|currentWeek\|currentMonth\|currentYear>` | Calendar window (default `currentMonth`) |
| `--start <iso> --end <iso>`                                | Custom range; both or neither            |

Precedence: `--start`+`--end` beats `--last`, which beats `--period`.

### Filters

Each metric declares which filters it accepts — passing one it doesn't
declare exits with code `2` and tells you which ones it does accept. Check
`filters` in `jelou metrics list --json` before calling a metric you haven't
used yet.

| Declared filter     | Flag                      | Notes                                              |
| ------------------- | ------------------------- | -------------------------------------------------- |
| `botId`             | `--bot-id`                | repeatable; ids from `jelou channels list`         |
| `teamId`            | `--team-id`               | repeatable                                         |
| `provider`          | `--provider`              | repeatable (payments)                              |
| `currency`          | `--currency`              | repeatable (payments)                              |
| `environment`       | `--environment PROD\|DEV` | payments                                           |
| `typeBiometric`     | `--type-biometric`        | biometrics                                         |
| `skillName`         | `--skill-name`            | repeatable; AI cost per workflow                   |
| `nodeId`            | `--node-id`               | repeatable; agent evals                            |
| `skillId`           | `--skill-id`              | repeatable; agent evals                            |
| `criterionName`     | `--criterion-name`        | repeatable; agent-eval frequency                   |
| —                   | `--app-id`                | ecommerce only, repeatable; omit it for every shop |
| `startAt` / `endAt` | the window flags above    | always accepted, declared or not                   |

## A whole dashboard

```bash theme={null}
jelou metrics dashboard                                    # headline board
jelou metrics dashboard --template ecommerce               # official board
jelou metrics dashboard "Operations"                       # saved board, by name
jelou metrics dashboard --template payments --last 7d --agent
```

| Flag                                        | Description                                                       |
| ------------------------------------------- | ----------------------------------------------------------------- |
| `--template <name>`                         | `ecommerce`, `payments`, `brain`, `ai`, `biometrics`, `operators` |
| `--last` / `--period` / `--start` / `--end` | same windows as `get`                                             |

A dashboard's metrics are fetched concurrently — one that fails doesn't take
down the whole board: the `--json` response carries `failed` and `errors[]`,
and the rest still renders. With no name or `--template`, `dashboard` shows
the company's headline board; that command's envelope lists the saved-board
names it found under `workspaces`.

## Exit codes

| Code | Meaning                                                                                        |
| ---- | ---------------------------------------------------------------------------------------------- |
| 0    | Success                                                                                        |
| 1    | Generic / unknown                                                                              |
| 2    | Input — ambiguous key, bad date, a lone `--start`/`--end`, or a flag the metric doesn't accept |
| 3    | Not found — unknown key, dashboard, or template                                                |
| 4    | Auth / forbidden — missing, expired, or rejected token                                         |
| 6    | Transient / API — 5xx or network timeout, safe to retry                                        |

<Warning>
  The numbers this command returns come with real caveats — don't treat them as
  accounting truth:

  * Ecommerce aggregates come from rollup tables refreshed every \~10 min (only
    today/yesterday plus recently-touched days); `detail` data is live and can
    disagree with the summaries.
  * `total_sales` excludes product modifiers — it's a GMV estimate, not
    accounting revenue. `AOV` inherits this.
  * `cart_conversion` is a creation-date cohort with no abandonment TTL — recent
    windows understate it; `breakdown.abandoned` is often `0`.
  * `sales_by_category` double-counts (M:N relationship) — it won't sum to
    `total_sales`.
  * The catalog metric family ignores `from`/`to` entirely (it's a global
    snapshot).
  * `ai_usage_cost` in search metrics is Jelou's internal cost.
  * Top-search-term totals exclude browse/sentinel queries, but `total_searches`
    includes them — the lists won't add up.
  * You need the `analytics:read` scope (plus `ecommerce:access` for shop). Don't
    pre-check it — let the API's own 401/403 come back as-is.
</Warning>

<Tip>
  If your agent is already going to fetch the rest of the workspace context,
  `jelou context --agent` doesn't include metrics — this command is still the
  only entry point to company analytics.
</Tip>
