@metricraven/cli 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -2
- package/dist/args.js +1 -0
- package/dist/commands.js +56 -5
- package/dist/completion.js +2 -2
- package/dist/index.js +6 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ Node.js 20 or later.
|
|
|
13
13
|
|
|
14
14
|
## Log in
|
|
15
15
|
|
|
16
|
-
Create an access token
|
|
16
|
+
Create an access token on the **API & MCP** page (https://metricraven.com/app/api), then:
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
19
|
metricraven login # paste the token (hidden)
|
|
@@ -38,11 +38,13 @@ The token is saved to `~/.config/metricraven/config.json` (or `$XDG_CONFIG_HOME/
|
|
|
38
38
|
| `analytics traffic` | Visitors, pageviews, revenue, conversion rate and top sources |
|
|
39
39
|
| `analytics breakdown <dimension>` | Full table for `channel`, `referrer`, `page`, `utmSource`, `country`, `device`, … |
|
|
40
40
|
| `analytics revenue` | Payments, renewals, refunds, LTV, revenue by channel |
|
|
41
|
+
| `analytics mrr [day\|week\|month]` | MRR over time: new, expansion, contraction, churn |
|
|
41
42
|
| `analytics conversions` | Goals and funnel steps |
|
|
42
43
|
| `analytics goal <name>` | One goal with its sources and properties |
|
|
43
44
|
| `analytics insights` | What converts and how long buyers take |
|
|
44
45
|
| `analytics search` | Google Search Console queries |
|
|
45
46
|
| `analytics crawlers` | AI crawlers and bots |
|
|
47
|
+
| `analytics ads [campaign\|adgroup\|ad] [--provider all\|meta\|google]` | Ad spend from every connected network, attributed and assisted revenue, ROAS and cost per customer |
|
|
46
48
|
| `analytics meta-ads [campaign\|adset\|ad]` | Meta Ads spend, attributed revenue, ROAS and cost per customer |
|
|
47
49
|
| `realtime` | Visitors online now |
|
|
48
50
|
| `visitors list`, `visitors get <id>` | Visitors and journeys (token needs visitor details access) |
|
|
@@ -53,6 +55,11 @@ The token is saved to `~/.config/metricraven/config.json` (or `$XDG_CONFIG_HOME/
|
|
|
53
55
|
| `goals set <goal> [--name] [--color] [--description] [--hidden\|--visible]`, `goals reset <goal>` | Change how a goal is shown (needs write access, admin) |
|
|
54
56
|
| `notes list`, `notes add --text [--date]` | Chart notes (adding needs write access) |
|
|
55
57
|
| `mentions [--platform x\|reddit] [--q text]` | X and Reddit posts mentioning the website (Growth plan) |
|
|
58
|
+
| `ai-visibility` | What AI assistants answer to your tracked prompts (Growth plan); `--period` for the trend (default 90d) |
|
|
59
|
+
| `alerts list\|get <id>\|history`, `alerts create --goal <name>` (or `--trigger payment\|new_customer`), `alerts update <id>`, `alerts delete <id>` | Conversion alerts; `--recipients a@x.com,b@x.com\|all` picks who gets them (changes need write access) |
|
|
60
|
+
| `members list`, `members invite <email> --role admin\|viewer`, `members role <user_id> --role …`, `members remove <user_id>`, `members revoke <invite_id>` | The website's team (changes need write access, admin) |
|
|
61
|
+
| `bots settings\|usage`, `bots exclude\|include <name…> [--company]`, `bots require-token on\|off` | Bot traffic settings and the bot request allowance |
|
|
62
|
+
| `proxy status\|enable <subdomain>\|check\|remove` | The managed proxy subdomain that serves the script |
|
|
56
63
|
| `completion bash\|zsh\|fish` | Shell completion script |
|
|
57
64
|
|
|
58
65
|
Reports cover the last 30 days by default. Use `--period today|yesterday|24h|7d|30d|90d|6m|1y|wtd|mtd|all`, or `--from 2026-10-01 --to 2026-10-31`, with `--timezone Europe/Madrid` for day boundaries. `--compare year` (or a `YYYY-MM-DD` start) changes what the change figures compare against; the default is the previous period of equal length. Filter with `--filter dimension:operator:value` (repeatable; operators `is`, `is_not`, `contains`, `not_contains`, and `gt`/`lt` for `visits`, e.g. `-f visits:gt:2`).
|
|
@@ -78,6 +85,6 @@ metricraven analytics traffic -p 7d --fields overview.current,series.date,series
|
|
|
78
85
|
metricraven analytics breakdown country --fields rows.name,rows.revenue
|
|
79
86
|
```
|
|
80
87
|
|
|
81
|
-
Global flags: `--site <id>`, `--json`, `--verbose` (request URLs and status codes on stderr), `--help`, `--version`.
|
|
88
|
+
Global flags: `--site <id>`, `--json`, `--fields`, `--verbose` (request URLs and status codes on stderr), `--help`, `--version`.
|
|
82
89
|
|
|
83
90
|
Full documentation: https://metricraven.com/docs/cli
|
package/dist/args.js
CHANGED
package/dist/commands.js
CHANGED
|
@@ -124,7 +124,7 @@ async function login(flags) {
|
|
|
124
124
|
let token = flags.token?.trim();
|
|
125
125
|
if (!token) {
|
|
126
126
|
if (process.stdin.isTTY) {
|
|
127
|
-
out(`Create an access token at ${bold(TOKENS_URL)} (
|
|
127
|
+
out(`Create an access token at ${bold(TOKENS_URL)} (API & MCP), then paste it here.`);
|
|
128
128
|
token = await promptHidden("Token: ");
|
|
129
129
|
}
|
|
130
130
|
else
|
|
@@ -220,7 +220,7 @@ async function useSite({ flags, client }, id) {
|
|
|
220
220
|
out(`Default website: ${bold(site.name)} (${id}).`);
|
|
221
221
|
return 0;
|
|
222
222
|
}
|
|
223
|
-
const REPORTS = ["traffic", "revenue", "conversions", "insights", "search", "crawlers", "ads", "meta-ads"];
|
|
223
|
+
const REPORTS = ["traffic", "revenue", "mrr", "conversions", "insights", "search", "crawlers", "ads", "meta-ads"];
|
|
224
224
|
async function analytics(ctx, sub, rest) {
|
|
225
225
|
const { flags, client } = ctx;
|
|
226
226
|
if (!sub)
|
|
@@ -252,6 +252,12 @@ async function analytics(ctx, sub, rest) {
|
|
|
252
252
|
throw new UsageError("Use: metricraven analytics meta-ads [campaign|adset|ad]");
|
|
253
253
|
params.set("level", rest[0]);
|
|
254
254
|
}
|
|
255
|
+
else if (sub === "mrr") {
|
|
256
|
+
if (rest[0] && !["day", "week", "month"].includes(rest[0]))
|
|
257
|
+
throw new UsageError("Use: metricraven analytics mrr [day|week|month]");
|
|
258
|
+
if (rest[0])
|
|
259
|
+
params.set("granularity", rest[0]);
|
|
260
|
+
}
|
|
255
261
|
else if (sub === "ads") {
|
|
256
262
|
if (rest[0] && !["campaign", "adgroup", "adset", "ad"].includes(rest[0]))
|
|
257
263
|
throw new UsageError("Use: metricraven analytics ads [campaign|adgroup|ad] [--provider all|meta|google]");
|
|
@@ -268,7 +274,7 @@ async function analytics(ctx, sub, rest) {
|
|
|
268
274
|
}
|
|
269
275
|
params.set("site", await ctx.site());
|
|
270
276
|
const selected = selectFields(flags, params);
|
|
271
|
-
const path = sub === "breakdown" ? "/stats/breakdown" : sub === "goal" ? "/stats/goal" : `/stats/${sub}`;
|
|
277
|
+
const path = sub === "breakdown" ? "/stats/breakdown" : sub === "goal" ? "/stats/goal" : sub === "mrr" ? "/stats/mrr-history" : `/stats/${sub}`;
|
|
272
278
|
const data = await client.get(path, params);
|
|
273
279
|
if (flags.json || selected)
|
|
274
280
|
return printJson(data), 0;
|
|
@@ -377,6 +383,32 @@ const RENDER = {
|
|
|
377
383
|
d.ltv ? section("Lifetime value", `${num(d.ltv.customers)} customers · average ${money(d.ltv.average, cur)}`) : "",
|
|
378
384
|
].join("\n");
|
|
379
385
|
},
|
|
386
|
+
mrr(d) {
|
|
387
|
+
if (!d.available || !d.series || !d.summary)
|
|
388
|
+
return dim(d.reason ?? "No MRR history yet.");
|
|
389
|
+
const cur = d.currency;
|
|
390
|
+
const s = d.summary;
|
|
391
|
+
const m = (n) => (n === null ? "–" : money(n, cur));
|
|
392
|
+
const points = d.series.filter((p) => p.mrr !== null);
|
|
393
|
+
return [
|
|
394
|
+
periodLine(d.period),
|
|
395
|
+
table(["Metric", "Value"], [
|
|
396
|
+
["MRR at end", `${m(s.endMrr)}${s.change !== null ? ` (${s.change > 0 ? "+" : ""}${s.change}% in period)` : ""}`],
|
|
397
|
+
["MRR at start", m(s.startMrr)],
|
|
398
|
+
["New", `${m(s.newMrr)} · ${num(s.newSubscriptions)} started paying`],
|
|
399
|
+
["Expansion", m(s.expansionMrr)],
|
|
400
|
+
["Contraction", m(s.contractionMrr)],
|
|
401
|
+
["Churned", `${m(s.churnedMrr)} · ${num(s.churned)} stopped paying`],
|
|
402
|
+
["Net new", m(s.netNewMrr)],
|
|
403
|
+
], ["left", "right"]),
|
|
404
|
+
section(`MRR by ${d.period.granularity ?? "day"} (last 12)`, points.length
|
|
405
|
+
? table(["Date", "MRR", "Active", "Net new", ""], points.slice(-12).map((p) => [p.date, m(p.mrr), num(p.active), m(p.netNewMrr), p.reconstructed ? dim("reconstructed") : ""]), ["left", "right", "right", "right", "left"])
|
|
406
|
+
: dim("No MRR recorded in this period.")),
|
|
407
|
+
d.demo ? dim("Sample history (demo).") : "",
|
|
408
|
+
]
|
|
409
|
+
.filter(Boolean)
|
|
410
|
+
.join("\n");
|
|
411
|
+
},
|
|
380
412
|
conversions(d) {
|
|
381
413
|
// Hidden goals (Settings → Goals) stay out of the table, like the dashboard; --json has them all.
|
|
382
414
|
const shown = d.goals.filter((g) => !g.hidden);
|
|
@@ -714,6 +746,22 @@ async function goals(ctx, sub, rest) {
|
|
|
714
746
|
}
|
|
715
747
|
throw new UsageError(`Unknown command "goals ${sub}". Use list, set, reset or colors.`);
|
|
716
748
|
}
|
|
749
|
+
/**
|
|
750
|
+
* `--recipients a@x.com,b@x.com` (emails or user IDs), or `all` for every current member. The API
|
|
751
|
+
* checks each one is a member of the website.
|
|
752
|
+
*/
|
|
753
|
+
function recipientsFlag(flags) {
|
|
754
|
+
if (flags.recipients !== undefined && flags.notify !== undefined)
|
|
755
|
+
throw new UsageError("Use --recipients or --notify, not both.");
|
|
756
|
+
if (flags.notify !== undefined)
|
|
757
|
+
return { notify: flags.notify };
|
|
758
|
+
if (flags.recipients === undefined)
|
|
759
|
+
return {};
|
|
760
|
+
const list = flags.recipients.split(",").map((r) => r.trim()).filter(Boolean);
|
|
761
|
+
if (!list.length)
|
|
762
|
+
throw new UsageError("--recipients needs member emails or user IDs, comma-separated, or all.");
|
|
763
|
+
return list.length === 1 && list[0].toLowerCase() === "all" ? { notify: "members" } : { recipients: list };
|
|
764
|
+
}
|
|
717
765
|
const triggerText = (t) => (t.type === "goal" ? `goal ${t.goalName}` : t.type === "payment" ? "any payment" : "new customer");
|
|
718
766
|
/** `metricraven alerts …`: conversion alerts on the website (list/get/create/update/delete/history). */
|
|
719
767
|
async function alerts(ctx, sub, rest) {
|
|
@@ -747,6 +795,8 @@ async function alerts(ctx, sub, rest) {
|
|
|
747
795
|
out(bold(a.name));
|
|
748
796
|
out(`Trigger: ${triggerText(a.trigger)} · ${a.isEnabled ? "enabled" : "disabled"}`);
|
|
749
797
|
out(`Recipients: ${a.recipients.map((r) => r.email).join(", ") || "none"}`);
|
|
798
|
+
if (a.optedOut?.length)
|
|
799
|
+
out(`Unsubscribed: ${a.optedOut.map((r) => r.email).join(", ")}`);
|
|
750
800
|
if (a.template.subject)
|
|
751
801
|
out(`Subject: ${a.template.subject}`);
|
|
752
802
|
if (a.template.message)
|
|
@@ -772,7 +822,7 @@ async function alerts(ctx, sub, rest) {
|
|
|
772
822
|
name: flags.name,
|
|
773
823
|
trigger: type === "goal" ? { type, goalName: goal } : { type },
|
|
774
824
|
template: flags.subject || flags.message ? { subject: flags.subject, message: flags.message } : undefined,
|
|
775
|
-
|
|
825
|
+
...recipientsFlag(flags),
|
|
776
826
|
isEnabled: flags.disabled ? false : undefined,
|
|
777
827
|
};
|
|
778
828
|
const d = await needs("write", client.post("/alerts", body, params()));
|
|
@@ -789,9 +839,10 @@ async function alerts(ctx, sub, rest) {
|
|
|
789
839
|
name: flags.name,
|
|
790
840
|
trigger: flags.goal ? { type: "goal", goalName: flags.goal } : undefined,
|
|
791
841
|
isEnabled: flags.enabled ? true : flags.disabled ? false : undefined,
|
|
842
|
+
...recipientsFlag(flags),
|
|
792
843
|
};
|
|
793
844
|
if (Object.values(body).every((v) => v === undefined))
|
|
794
|
-
throw new UsageError("Nothing to change. Use --name, --goal, --enabled or --
|
|
845
|
+
throw new UsageError("Nothing to change. Use --name, --goal, --enabled, --disabled or --recipients.");
|
|
795
846
|
const d = await needs("write", client.patch(alertPath(rest[0]), body, params()));
|
|
796
847
|
if (flags.json)
|
|
797
848
|
return printJson(d), 0;
|
package/dist/completion.js
CHANGED
|
@@ -6,7 +6,7 @@ const SUB = {
|
|
|
6
6
|
account: ["get", "update"],
|
|
7
7
|
tokens: ["list", "create", "delete"],
|
|
8
8
|
payments: ["delete"],
|
|
9
|
-
analytics: ["traffic", "breakdown", "revenue", "conversions", "goal", "insights", "search", "crawlers", "ads", "meta-ads"],
|
|
9
|
+
analytics: ["traffic", "breakdown", "revenue", "mrr", "conversions", "goal", "insights", "search", "crawlers", "ads", "meta-ads"],
|
|
10
10
|
visitors: ["list", "get"],
|
|
11
11
|
funnels: ["list"],
|
|
12
12
|
goals: ["list", "set", "reset", "colors", "delete-events"],
|
|
@@ -18,7 +18,7 @@ const SUB = {
|
|
|
18
18
|
proxy: ["status", "enable", "check", "remove"],
|
|
19
19
|
completion: ["bash", "zsh", "fish"],
|
|
20
20
|
};
|
|
21
|
-
const FLAGS = ["--json", "--fields", "--site", "--token", "--verbose", "--help", "--version", "--period", "--from", "--to", "--timezone", "--filter", "--compare", "--sort", "--limit", "--offset", "--q", "--payment", "--name", "--domain", "--date", "--text", "--goal", "--trigger", "--subject", "--message", "--notify", "--enabled", "--disabled", "--yes", "--alert", "--platform", "--role", "--color", "--description", "--hidden", "--visible", "--company", "--scopes", "--sites", "--transaction", "--visitor", "--user", "--dry-run", "--page", "--page-contains", "--referrer", "--channel", "--source", "--utm-source", "--utm-medium", "--utm-campaign", "--country", "--device", "--browser", "--os", "--visits-gt", "--visits-lt", "--grace", "--provider"];
|
|
21
|
+
const FLAGS = ["--json", "--fields", "--site", "--token", "--verbose", "--help", "--version", "--period", "--from", "--to", "--timezone", "--filter", "--compare", "--sort", "--limit", "--offset", "--q", "--payment", "--name", "--domain", "--date", "--text", "--goal", "--trigger", "--subject", "--message", "--notify", "--recipients", "--enabled", "--disabled", "--yes", "--alert", "--platform", "--role", "--color", "--description", "--hidden", "--visible", "--company", "--scopes", "--sites", "--transaction", "--visitor", "--user", "--dry-run", "--page", "--page-contains", "--referrer", "--channel", "--source", "--utm-source", "--utm-medium", "--utm-campaign", "--country", "--device", "--browser", "--os", "--visits-gt", "--visits-lt", "--grace", "--provider"];
|
|
22
22
|
export function completionScript(shell) {
|
|
23
23
|
if (shell === "bash") {
|
|
24
24
|
const cases = Object.entries(SUB)
|
package/dist/index.js
CHANGED
|
@@ -40,6 +40,8 @@ Reports (default: last 30 days)
|
|
|
40
40
|
entryPage, utmSource, utmCampaign, country, city,
|
|
41
41
|
browser, os, device, hostname, outbound, …
|
|
42
42
|
analytics revenue Payments, renewals, refunds, LTV, revenue by channel
|
|
43
|
+
analytics mrr [unit] MRR over time: new, expansion, contraction, churn
|
|
44
|
+
(unit: day, week or month)
|
|
43
45
|
analytics conversions Goals and funnel steps
|
|
44
46
|
analytics goal <name> One goal in detail
|
|
45
47
|
analytics insights What converts: sources, countries, time to purchase
|
|
@@ -79,9 +81,11 @@ Alerts (email when a goal, payment or new customer happens)
|
|
|
79
81
|
alerts list Alerts on the website
|
|
80
82
|
alerts get <alert_id> One alert with its counts
|
|
81
83
|
alerts create --goal <name> New goal alert; or --trigger payment|new_customer
|
|
82
|
-
[--name] [--subject] [--message]
|
|
83
|
-
[--
|
|
84
|
+
[--name] [--subject] [--message]
|
|
85
|
+
[--recipients <email,email|all>] (default: you)
|
|
86
|
+
[--disabled] (needs write access, admin)
|
|
84
87
|
alerts update <alert_id> [--name] [--goal] [--enabled | --disabled]
|
|
88
|
+
[--recipients <email,email|all>]
|
|
85
89
|
alerts delete <alert_id> Delete an alert (asks first; --yes to skip)
|
|
86
90
|
alerts history [--alert <id>] Emails the alerts sent, newest first
|
|
87
91
|
|
package/package.json
CHANGED