Skip to content

Commit 3121bbd

Browse files
yosriadyclaude
andauthored
Update CLI docs: add analytics, fix profiles filter format, kebab-case flags (#77)
* Update CLI docs: add analytics, fix profiles filter format, kebab-case flags - Add cli/analytics.mdx documenting the new `formo analytics` command group (17 pre-built pipes, --date-from/--date-to/--filters/--params, per-pipe params, examples) and wire it into docs.json nav + the overview card grid. - Fix the profiles search --conditions docs: field paths must be typed (users.net_worth_usd, chains.1.balance, …); a bare name like net_worth_usd is silently ignored by the API. Added a Warning callout, the field-path prefix table, and the scope/appId token-filter fields. - Normalize every CLI flag reference to kebab-case (--date-from, --order-by, --tag-id, --trigger-filters, …) to match `incur --help` output and the Node/TS CLI ecosystem standard. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Sync CLI docs with implementation: query run, conditions validation - query.mdx + overview.mdx: the command is `formo query run <sql>` (subcommand), not `formo query <sql>`. - profiles.mdx: the CLI now rejects an untyped --conditions field client-side (it would otherwise be silently ignored by the API); reworded the warning accordingly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs(api): sync openapi.json with backend spec Reconcile api/openapi.json with the backend source-of-truth spec (apps/backend/src/openapi.json): - Rename funnel/flow date params dateFrom/dateTo -> date_from/date_to to match the snake_case rename shipped on the backend branch. - Normalize dash typography (em-dash/en-dash) across all descriptions to match backend; preserves legitimate hyphens. - Drop ENS-resolution wording from the 5 wallet-address parameter descriptions: ENS resolution was removed from the API (resolveWalletAddress.ts deleted), so the docs claim was inaccurate. - Adopt backend wording for the two /v0/funnel example summaries. All 2928 shared string fields are now byte-identical to the backend spec. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs(cli): fix invalid JSON placeholder in analytics --filters `[{"field","op","value"}]` is not valid JSON and reads as an array of strings. Use `[{"field": "...", "op": "...", "value": "..."}]` to reflect the actual {field, op, value} object structure the analytics pipes consume. Addresses gemini-code-assist review comment on PR #77. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs(api): restore ENS wording in wallet-address descriptions Reverts the wallet-address description changes from 0fe56c0, which removed the "Accepts an EVM (0x...) or Solana address, or an ENS name (e.g. vitalik.eth) which is resolved to an address." wording from 5 parameters. That removal was based on a stale local `main` ref that made the backend branch appear to delete ENS resolution. It does not: ENS support (formono PR #1713 / commit 7fc4887f) is present on main and on the backend branch, and the backend openapi.json keeps the full ENS wording. Stripping it here made the docs inaccurate for a shipped feature and contradicted PR #77's intent to leave ENS docs unchanged. api/openapi.json is now byte-identical to the backend spec across all 2928 shared string fields (date_from/date_to, dash typography, funnel example summaries, and ENS wording all consistent). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 6172c33 commit 3121bbd

10 files changed

Lines changed: 221 additions & 92 deletions

File tree

api/openapi.json

Lines changed: 38 additions & 38 deletions
Large diffs are not rendered by default.

cli/alerts.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,28 +54,28 @@ Requires `alerts:write` scope on your API key.
5454
| Option | Type | Required | Description |
5555
|--------|------|----------|-------------|
5656
| `--name` | `string` || Alert name |
57-
| `--triggerType` | `string` || Trigger type (e.g. `event`, `threshold`) |
58-
| `--triggerFilters` | `string` || JSON array of trigger filter objects |
57+
| `--trigger-type` | `string` || Trigger type (e.g. `event`, `threshold`) |
58+
| `--trigger-filters` | `string` || JSON array of trigger filter objects |
5959
| `--recipient` | `string` || JSON array of recipient objects |
6060
| `--secret` | `string` || Webhook secret for the alert |
6161

6262
### Examples
6363

6464
```bash
6565
# Create a basic event alert
66-
formo alerts create --name "High value tx" --triggerType event
66+
formo alerts create --name "High value tx" --trigger-type event
6767

6868
# Create an alert with trigger filters and recipients
6969
formo alerts create \
7070
--name "Whale activity" \
71-
--triggerType threshold \
72-
--triggerFilters '[{"field":"net_worth_usd","op":"gt","value":100000}]' \
71+
--trigger-type threshold \
72+
--trigger-filters '[{"field":"net_worth_usd","op":"gt","value":100000}]' \
7373
--recipient '[{"type":"email","value":"team@example.com"}]'
7474

7575
# Create an alert with a webhook secret
7676
formo alerts create \
7777
--name "Transaction webhook" \
78-
--triggerType event \
78+
--trigger-type event \
7979
--secret "whsec_abc123"
8080
```
8181

@@ -100,21 +100,21 @@ Requires `alerts:write` scope on your API key.
100100
| Option | Type | Required | Description |
101101
|--------|------|----------|-------------|
102102
| `--name` | `string` || Alert name |
103-
| `--triggerType` | `string` || Trigger type |
104-
| `--triggerFilters` | `string` || JSON array of trigger filter objects |
103+
| `--trigger-type` | `string` || Trigger type |
104+
| `--trigger-filters` | `string` || JSON array of trigger filter objects |
105105
| `--recipient` | `string` || JSON array of recipient objects |
106106
| `--secret` | `string` || Webhook secret for the alert |
107107

108108
### Examples
109109

110110
```bash
111111
# Update an alert name
112-
formo alerts update alert_abc123 --name "Renamed alert" --triggerType event
112+
formo alerts update alert_abc123 --name "Renamed alert" --trigger-type event
113113

114114
# Update alert with new recipients
115115
formo alerts update alert_abc123 \
116116
--name "Updated alert" \
117-
--triggerType threshold \
117+
--trigger-type threshold \
118118
--recipient '[{"type":"slack","value":"#alerts"}]'
119119
```
120120

cli/analytics.mdx

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
title: "Analytics"
3+
sidebarTitle: "Analytics"
4+
icon: chart-mixed
5+
description: "Run Formo's pre-built analytics pipes — KPIs, funnels, retention, revenue, and top-N breakdowns — directly from the terminal, without writing SQL."
6+
---
7+
8+
The `formo analytics` command exposes Formo's pre-built analytics pipes — the same data that powers the Formo dashboard — as terminal commands. Each pipe is a subcommand: `formo analytics <pipe>`.
9+
10+
<Note>
11+
Requires `query:read` scope on your API key.
12+
</Note>
13+
14+
## `formo analytics <pipe>`
15+
16+
### Pipes
17+
18+
| Pipe | Description |
19+
|------|-------------|
20+
| `kpis` | Traffic KPIs: visitors, pageviews, bounce rate, session duration |
21+
| `event_timeseries` | Event counts over time |
22+
| `funnel` | Conversion funnel across ordered steps |
23+
| `flow` | User path / flow analysis between steps |
24+
| `frequency` | Engagement frequency distribution |
25+
| `lifecycle` | User lifecycle stages (new, returning, power, resurrected, churned) |
26+
| `retention` | Retention cohort analysis |
27+
| `revenue_overview` | Revenue overview with optional breakdown |
28+
| `revenue_by_metric` | Revenue ranked by a metric column |
29+
| `revenue_timeseries` | Revenue over time (requires `address`) |
30+
| `volume_by_metric` | Trading volume ranked by a metric column |
31+
| `top_chains` | Top chains by activity |
32+
| `top_events` | Top events by count |
33+
| `top_locations` | Top locations |
34+
| `top_pages` | Top pages by traffic |
35+
| `top_sources` | Top acquisition sources |
36+
| `top_wallets` | Top wallets by activity |
37+
38+
### Options
39+
40+
| Option | Type | Required | Description |
41+
|--------|------|----------|-------------|
42+
| `--date-from` | `string` || Inclusive start date `YYYY-MM-DD` (default: 7 days before `--date-to`) |
43+
| `--date-to` | `string` || Inclusive end date `YYYY-MM-DD` (default: today) |
44+
| `--filters` | `string` || JSON array of filter conditions: `[{"field": "...", "op": "...", "value": "..."}]` |
45+
| `--params` | `string` || JSON object of pipe-specific params merged into the query |
46+
47+
<Note>
48+
`--params` may **not** set `date_from`/`date_to`/`filters` — use the dedicated
49+
`--date-from`/`--date-to`/`--filters` flags for those. Object/array values in
50+
`--params` are JSON-encoded automatically (e.g. `funnel`'s `steps`).
51+
</Note>
52+
53+
### `--filters`
54+
55+
A JSON array of `{ field, op, value }` conditions, e.g. `[{"field":"location","op":"equals","value":"US"}]`. For multi-value matching, use `in` / `notIn` with a pipe-delimited `value` (e.g. `"chrome|firefox"`).
56+
57+
### `--params` (pipe-specific)
58+
59+
Some pipes take additional, pipe-specific parameters. Pass them as a JSON object via `--params`:
60+
61+
| Pipe | Key params |
62+
|------|------------|
63+
| `kpis`, `revenue_overview` | `group_by`, `limit`, `include_previous_period` |
64+
| `funnel` | `steps` (required — JSON array of `{type,event,name,filters?}`), `window_seconds`, `funnel_type`, `breakdown` |
65+
| `flow` | `start_step` (required — JSON `{type,event,resolved_event,...}`), `end_step`, `global_filters`, `window_seconds`, `max_steps` |
66+
| `retention` | `id_type`, `event_type`, `event_name`, `min_users` |
67+
| `revenue_timeseries` | `address` (required) |
68+
| `revenue_by_metric`, `volume_by_metric`, `top_sources` | `metric_column`, `limit`, `offset` |
69+
| `top_chains`, `top_events`, `top_locations`, `top_pages`, `top_wallets` | `limit`, `offset` |
70+
71+
### Examples
72+
73+
```bash
74+
# Traffic KPIs for the last 7 days (default range)
75+
formo analytics kpis
76+
77+
# KPIs for April 2026, broken down by device
78+
formo analytics kpis --date-from 2026-04-01 --date-to 2026-04-30 --params '{"group_by":"device"}'
79+
80+
# Conversion funnel across ordered steps
81+
formo analytics funnel \
82+
--date-from 2026-04-01 --date-to 2026-04-30 \
83+
--params '{"steps":[{"type":"event","event":"page","name":"page::0","filters":[]},{"type":"track","event":"connect","name":"connect::1","filters":[]}],"window_seconds":86400}'
84+
85+
# Top 10 wallets by activity last month
86+
formo analytics top_wallets --date-from 2026-04-01 --date-to 2026-04-30 --params '{"limit":10}'
87+
88+
# Retention restricted to US visitors
89+
formo analytics retention --filters '[{"field":"location","op":"equals","value":"US"}]'
90+
91+
# Revenue timeseries for a specific wallet
92+
formo analytics revenue_timeseries \
93+
--date-from 2026-04-01 --date-to 2026-04-30 \
94+
--params '{"address":"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"}'
95+
96+
# Pipe results to jq for processing
97+
formo analytics kpis | jq '.data'
98+
```
99+
100+
The response shape matches the dashboard data: `{ meta, data, rows, statistics }`.

cli/charts.mdx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ Requires `boards:read` scope on your API key.
1919

2020
| Option | Type | Required | Description |
2121
|--------|------|----------|-------------|
22-
| `--boardId` | `string` || Board ID to list charts from |
22+
| `--board-id` | `string` || Board ID to list charts from |
2323

2424
```bash
25-
formo charts list --boardId board_abc123
25+
formo charts list --board-id board_abc123
2626
```
2727

2828
---
@@ -45,10 +45,10 @@ Requires `boards:read` scope on your API key.
4545

4646
| Option | Type | Required | Description |
4747
|--------|------|----------|-------------|
48-
| `--boardId` | `string` || Board ID the chart belongs to |
48+
| `--board-id` | `string` || Board ID the chart belongs to |
4949

5050
```bash
51-
formo charts get chart_abc123 --boardId board_abc123
51+
formo charts get chart_abc123 --board-id board_abc123
5252
```
5353

5454
---
@@ -65,20 +65,20 @@ Requires `boards:write` scope on your API key.
6565

6666
| Option | Type | Required | Description |
6767
|--------|------|----------|-------------|
68-
| `--boardId` | `string` || Board ID to add the chart to |
68+
| `--board-id` | `string` || Board ID to add the chart to |
6969
| `--body` | `string` || JSON string with the chart configuration |
7070

7171
### Examples
7272

7373
```bash
7474
# Create a line chart
7575
formo charts create \
76-
--boardId board_abc123 \
76+
--board-id board_abc123 \
7777
--body '{"name":"Daily active users","chartType":"line"}'
7878

7979
# Create a bar chart with a SQL query
8080
formo charts create \
81-
--boardId board_abc123 \
81+
--board-id board_abc123 \
8282
--body '{"name":"Top chains","chartType":"bar","query":"SELECT chain, count(*) as cnt FROM events GROUP BY chain ORDER BY cnt DESC LIMIT 10"}'
8383
```
8484

@@ -102,20 +102,20 @@ Requires `boards:write` scope on your API key.
102102

103103
| Option | Type | Required | Description |
104104
|--------|------|----------|-------------|
105-
| `--boardId` | `string` || Board ID the chart belongs to |
105+
| `--board-id` | `string` || Board ID the chart belongs to |
106106
| `--body` | `string` || JSON string with updated chart configuration |
107107

108108
### Examples
109109

110110
```bash
111111
# Update a chart name
112112
formo charts update chart_abc123 \
113-
--boardId board_abc123 \
113+
--board-id board_abc123 \
114114
--body '{"name":"Updated chart name"}'
115115

116116
# Update chart type and query
117117
formo charts update chart_abc123 \
118-
--boardId board_abc123 \
118+
--board-id board_abc123 \
119119
--body '{"name":"Revenue","chartType":"area","query":"SELECT DATE(timestamp) as day, SUM(revenue) as rev FROM events GROUP BY day"}'
120120
```
121121

@@ -139,10 +139,10 @@ Requires `boards:write` scope on your API key.
139139

140140
| Option | Type | Required | Description |
141141
|--------|------|----------|-------------|
142-
| `--boardId` | `string` || Board ID the chart belongs to |
142+
| `--board-id` | `string` || Board ID the chart belongs to |
143143

144144
```bash
145-
formo charts delete chart_abc123 --boardId board_abc123
145+
formo charts delete chart_abc123 --board-id board_abc123
146146
```
147147

148148
<Warning>

cli/import.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ Bulk import wallet addresses into the project.
2020
| Option | Type | Required | Description |
2121
|--------|------|----------|-------------|
2222
| `--addresses` | `string` || JSON array of wallet address strings to import |
23-
| `--writeKey` | `string` || Project write SDK key |
23+
| `--write-key` | `string` || Project write SDK key |
2424

2525
### Examples
2626

2727
```bash
2828
# Import two wallet addresses
2929
formo import wallets \
3030
--addresses '["0xabc123...","0xdef456..."]' \
31-
--writeKey write_key_xxx
31+
--write-key write_key_xxx
3232

3333
# Import a list of addresses from a file (using jq)
3434
formo import wallets \
3535
--addresses "$(cat wallets.json)" \
36-
--writeKey write_key_xxx
36+
--write-key write_key_xxx
3737
```
3838

3939
### Tips

cli/overview.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ The Formo CLI (`@formo/cli`) gives you full access to the Formo API from the com
1414
<Card title="Query" icon="database" href="/cli/query">
1515
Run SQL queries on my data
1616
</Card>
17+
<Card title="Analytics" icon="chart-mixed" href="/cli/analytics">
18+
Run pre-built analytics pipes (KPIs, funnels, retention, revenue)
19+
</Card>
1720
<Card title="Charts" icon="chart-line" href="/cli/charts">
1821
Create and manage charts within custom dashboards
1922
</Card>
@@ -55,7 +58,7 @@ formo login formo_abc123
5558
formo profiles get vitalik.eth
5659

5760
# 3. Run a SQL query
58-
formo query "SELECT count(*) FROM events"
61+
formo query run "SELECT count(*) FROM events"
5962

6063
# 4. List your dashboard boards
6164
formo boards list

0 commit comments

Comments
 (0)