@metricraven/cli 0.3.0 → 0.4.1
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 +5 -4
- package/dist/args.js +5 -0
- package/dist/commands.js +109 -21
- package/dist/completion.js +25 -2
- package/dist/index.js +10 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,8 +44,8 @@ The token is saved to `~/.config/metricraven/config.json` (or `$XDG_CONFIG_HOME/
|
|
|
44
44
|
| `analytics insights` | What converts and how long buyers take |
|
|
45
45
|
| `analytics search` | Google Search Console queries |
|
|
46
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 |
|
|
48
|
-
| `analytics meta-ads [campaign\|adset\|ad]` | Meta Ads spend, attributed revenue, ROAS and cost per customer |
|
|
47
|
+
| `analytics ads [campaign\|adgroup\|ad] [--provider all\|meta\|google\|tiktok] [--account <id>]` | Ad spend from every connected network, attributed and assisted revenue, ROAS and cost per customer, with each network's own reported value (Meta-reported, Google-reported) for comparison. `--account` reports one chosen ad account alone (the IDs are listed when several are combined; Google IDs with or without dashes, Meta without `act_`) |
|
|
48
|
+
| `analytics meta-ads [campaign\|adset\|ad] [--account <id>]` | Meta Ads spend, attributed revenue, ROAS and cost per customer |
|
|
49
49
|
| `realtime` | Visitors online now |
|
|
50
50
|
| `visitors list`, `visitors get <id>` | Visitors and journeys (token needs visitor details access) |
|
|
51
51
|
| `visitors list --page /pricing --goal signup --visits-gt 2` | Search visitors by visited page (`--page`, `--page-contains`), completed goal, `--referrer`, `--channel`, `--source`, `--utm-source/medium/campaign`, `--country`, `--device`, `--browser`, `--os` and visits in the period (`--visits-gt`, `--visits-lt`) |
|
|
@@ -58,15 +58,16 @@ The token is saved to `~/.config/metricraven/config.json` (or `$XDG_CONFIG_HOME/
|
|
|
58
58
|
| `ai-visibility` | What AI assistants answer to your tracked prompts (Growth plan); `--period` for the trend (default 90d) |
|
|
59
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
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 |
|
|
61
|
+
| `bots settings\|usage`, `bots settings --verified-only on\|off`, `bots exclude\|include <name…> [--company]`, `bots require-token on\|off` | Bot traffic settings (`--verified-only on` records only IP-verified crawlers) and the bot request allowance |
|
|
62
62
|
| `proxy status\|enable <subdomain>\|check\|remove` | The managed proxy subdomain that serves the script |
|
|
63
63
|
| `completion bash\|zsh\|fish` | Shell completion script |
|
|
64
64
|
|
|
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`).
|
|
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. `--compare off` shows no comparison: no change column, and the comparison fields are left out of `--json`. 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`).
|
|
66
66
|
|
|
67
67
|
```bash
|
|
68
68
|
metricraven analytics traffic --period 7d
|
|
69
69
|
metricraven analytics breakdown referrer --sort revenue --limit 20
|
|
70
|
+
metricraven analytics breakdown page --sort visitors --order asc # least-visited pages first
|
|
70
71
|
metricraven analytics traffic -f country:is:US -f device:is:mobile --json | jq .overview
|
|
71
72
|
```
|
|
72
73
|
|
package/dist/args.js
CHANGED
|
@@ -17,6 +17,8 @@ const OPTIONS = {
|
|
|
17
17
|
filter: { type: "string", short: "f", multiple: true },
|
|
18
18
|
compare: { type: "string" },
|
|
19
19
|
sort: { type: "string" },
|
|
20
|
+
// analytics breakdown: asc or desc (by --sort)
|
|
21
|
+
order: { type: "string" },
|
|
20
22
|
limit: { type: "string", short: "n" },
|
|
21
23
|
offset: { type: "string" },
|
|
22
24
|
q: { type: "string" },
|
|
@@ -44,6 +46,7 @@ const OPTIONS = {
|
|
|
44
46
|
company: { type: "boolean" },
|
|
45
47
|
// analytics ads
|
|
46
48
|
provider: { type: "string" },
|
|
49
|
+
account: { type: "string" },
|
|
47
50
|
// tokens create
|
|
48
51
|
scopes: { type: "string" },
|
|
49
52
|
sites: { type: "string" },
|
|
@@ -68,6 +71,8 @@ const OPTIONS = {
|
|
|
68
71
|
"visits-gt": { type: "string" },
|
|
69
72
|
"visits-lt": { type: "string" },
|
|
70
73
|
grace: { type: "string" },
|
|
74
|
+
// bots settings
|
|
75
|
+
"verified-only": { type: "string" },
|
|
71
76
|
};
|
|
72
77
|
export class UsageError extends Error {
|
|
73
78
|
}
|
package/dist/commands.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ApiError, createClient } from "./api.js";
|
|
2
2
|
import { UsageError, buildFilters, positiveInt, rangeParams } from "./args.js";
|
|
3
3
|
import { customRange, validTimeZone } from "./range.js";
|
|
4
|
-
import { completionScript } from "./completion.js";
|
|
4
|
+
import { AD_PROVIDER_VALUES, completionScript } from "./completion.js";
|
|
5
5
|
import { configPath, deleteConfigToken, readConfig, resolveSettings, updateConfig } from "./config.js";
|
|
6
6
|
import { bold, change, date, dim, duration, money, num, pct, section, table, terminalSafe, truncate } from "./format.js";
|
|
7
7
|
import { interactive, prompt, promptHidden, readStdin } from "./prompt.js";
|
|
@@ -233,6 +233,11 @@ async function analytics(ctx, sub, rest) {
|
|
|
233
233
|
params.set("dimension", dimension);
|
|
234
234
|
if (flags.sort)
|
|
235
235
|
params.set("sort", flags.sort);
|
|
236
|
+
if (flags.order) {
|
|
237
|
+
if (flags.order !== "asc" && flags.order !== "desc")
|
|
238
|
+
throw new UsageError("Use --order asc or desc (by the --sort column, visitors by default).");
|
|
239
|
+
params.set("order", flags.order);
|
|
240
|
+
}
|
|
236
241
|
if (flags.q)
|
|
237
242
|
params.set("q", flags.q);
|
|
238
243
|
const limit = positiveInt(flags.limit, "limit", 100);
|
|
@@ -247,10 +252,13 @@ async function analytics(ctx, sub, rest) {
|
|
|
247
252
|
throw new UsageError("Use: metricraven analytics goal <name>");
|
|
248
253
|
params.set("name", rest[0]);
|
|
249
254
|
}
|
|
250
|
-
else if (sub === "meta-ads" && rest[0]) {
|
|
251
|
-
if (!["campaign", "adset", "ad"].includes(rest[0]))
|
|
252
|
-
throw new UsageError("Use: metricraven analytics meta-ads [campaign|adset|ad]");
|
|
253
|
-
|
|
255
|
+
else if (sub === "meta-ads" && (rest[0] || flags.account)) {
|
|
256
|
+
if (rest[0] && !["campaign", "adset", "ad"].includes(rest[0]))
|
|
257
|
+
throw new UsageError("Use: metricraven analytics meta-ads [campaign|adset|ad] [--account <id>]");
|
|
258
|
+
if (rest[0])
|
|
259
|
+
params.set("level", rest[0]);
|
|
260
|
+
if (flags.account)
|
|
261
|
+
params.set("account", adAccountId(flags.account));
|
|
254
262
|
}
|
|
255
263
|
else if (sub === "mrr") {
|
|
256
264
|
if (rest[0] && !["day", "week", "month"].includes(rest[0]))
|
|
@@ -260,14 +268,16 @@ async function analytics(ctx, sub, rest) {
|
|
|
260
268
|
}
|
|
261
269
|
else if (sub === "ads") {
|
|
262
270
|
if (rest[0] && !["campaign", "adgroup", "adset", "ad"].includes(rest[0]))
|
|
263
|
-
throw new UsageError(
|
|
271
|
+
throw new UsageError(`Use: metricraven analytics ads [campaign|adgroup|ad] [--provider ${AD_PROVIDER_VALUES.join("|")}] [--account <id>]`);
|
|
264
272
|
if (rest[0])
|
|
265
273
|
params.set("level", rest[0]);
|
|
266
274
|
if (flags.provider) {
|
|
267
|
-
if (!
|
|
268
|
-
throw new UsageError("Use --provider all, meta or
|
|
275
|
+
if (!AD_PROVIDER_VALUES.includes(flags.provider))
|
|
276
|
+
throw new UsageError("Use --provider all, meta, google or tiktok (TikTok Ads can't be connected yet).");
|
|
269
277
|
params.set("provider", flags.provider);
|
|
270
278
|
}
|
|
279
|
+
if (flags.account)
|
|
280
|
+
params.set("account", adAccountId(flags.account));
|
|
271
281
|
}
|
|
272
282
|
else if (!REPORTS.includes(sub)) {
|
|
273
283
|
throw new UsageError(`Unknown report "${sub}". Use ${[...REPORTS, "breakdown", "goal"].join(", ")}.`);
|
|
@@ -275,14 +285,35 @@ async function analytics(ctx, sub, rest) {
|
|
|
275
285
|
params.set("site", await ctx.site());
|
|
276
286
|
const selected = selectFields(flags, params);
|
|
277
287
|
const path = sub === "breakdown" ? "/stats/breakdown" : sub === "goal" ? "/stats/goal" : sub === "mrr" ? "/stats/mrr-history" : `/stats/${sub}`;
|
|
278
|
-
const
|
|
288
|
+
const fetched = await client.get(path, params);
|
|
289
|
+
const data = flags.compare === "off" ? withoutComparison(fetched) : fetched;
|
|
279
290
|
if (flags.json || selected)
|
|
280
291
|
return printJson(data), 0;
|
|
292
|
+
if ((sub === "ads" || sub === "meta-ads") && flags.account && data.configured === false) {
|
|
293
|
+
out(`Ad account ${params.get("account")} is not one of this website's chosen ad accounts${params.get("provider") && params.get("provider") !== "all" ? ` on ${NETWORKS[params.get("provider")] ?? params.get("provider")}` : ""}. Run the report without --account to list them.`);
|
|
294
|
+
return 0;
|
|
295
|
+
}
|
|
281
296
|
const render = RENDER[sub];
|
|
282
297
|
out(render ? render(data) : JSON.stringify(data, null, 2));
|
|
283
298
|
return 0;
|
|
284
299
|
}
|
|
300
|
+
/**
|
|
301
|
+
* --account: one chosen ad account alone (GET /stats/ads ?account=). The ID as the dashboard
|
|
302
|
+
* shows it: Meta without "act_", Google with or without dashes (123-456-7890).
|
|
303
|
+
*/
|
|
304
|
+
export function adAccountId(v) {
|
|
305
|
+
const id = v.trim().replace(/^act_/, "");
|
|
306
|
+
const google = /^\d{3}-\d{3}-\d{4}$/.test(id) ? id.replace(/-/g, "") : id;
|
|
307
|
+
if (!/^[A-Za-z0-9_-]{1,40}$/.test(google))
|
|
308
|
+
throw new UsageError("Use --account <ad account ID> (letters, digits, - and _; see adAccounts[] in --json).");
|
|
309
|
+
return google;
|
|
310
|
+
}
|
|
285
311
|
const NETWORKS = { meta: "Meta Ads", google: "Google Ads", tiktok: "TikTok Ads" };
|
|
312
|
+
/** What each network's own reported value is called (never part of revenue or ROAS). */
|
|
313
|
+
const REPORTED = {
|
|
314
|
+
meta: { label: "Meta-reported purchase value", count: "purchases" },
|
|
315
|
+
google: { label: "Google-reported conversion value", count: "conversions" },
|
|
316
|
+
};
|
|
286
317
|
/** analytics ads and analytics meta-ads (the same response shape). */
|
|
287
318
|
function renderAds(d) {
|
|
288
319
|
if (!d.configured)
|
|
@@ -297,6 +328,16 @@ function renderAds(d) {
|
|
|
297
328
|
return [
|
|
298
329
|
...(d.accounts ?? []).map((a) => dim(`${NETWORKS[a.provider] ?? a.provider}: ${a.name}${d.sample ? " · sample data" : ""} · days ${a.days.from} → ${a.days.to} (${a.timeZone})`)),
|
|
299
330
|
`${combined ? "All networks: s" : "S"}pend ${money(t.spend, cur)} · revenue ${money(t.revenue, cur)} · ROAS ${roas(t.roas)} · ${num(t.customers)} customers · cost per customer ${t.costPerCustomer === null ? "–" : money(t.costPerCustomer, cur)} · assisted ${money(t.assistedRevenue ?? 0, cur)}`,
|
|
331
|
+
...(d.accounts ?? []).map((a) => {
|
|
332
|
+
const r = REPORTED[a.provider];
|
|
333
|
+
if (!r || a.totals?.reportedValue === undefined)
|
|
334
|
+
return "";
|
|
335
|
+
return dim(`${r.label}: ${money(a.totals.reportedValue, cur)} (${num(a.totals.reportedPurchases ?? 0, 2)} ${r.count}, ${roas(a.totals.reportedRoas)} by its own count). Not in revenue or ROAS.`);
|
|
336
|
+
}),
|
|
337
|
+
// Several chosen accounts: name them with their IDs for --account.
|
|
338
|
+
(d.adAccounts?.length ?? 0) > 1
|
|
339
|
+
? dim(`Ad accounts: ${d.adAccounts.map((a) => `${a.name} (${a.id}${combined || new Set(d.adAccounts.map((x) => x.provider)).size > 1 ? `, ${(NETWORKS[a.provider] ?? a.provider).replace(" Ads", "")}` : ""})${d.accountFilter === a.id ? " ← shown" : ""}`).join(", ")}${d.accountFilter ? "" : ". One alone: --account <id>"}`)
|
|
340
|
+
: "",
|
|
300
341
|
...(d.accounts ?? []).flatMap((a) => [
|
|
301
342
|
a.sync.error ? dim(`${NETWORKS[a.provider] ?? a.provider} sync: ${a.sync.error}`) : "",
|
|
302
343
|
a.unconvertedSpend ? dim(`${money(a.unconvertedSpend, a.currency)} of ${NETWORKS[a.provider] ?? a.provider} spend has no exchange rate yet and is left out.`) : "",
|
|
@@ -331,15 +372,42 @@ function periodLine(p) {
|
|
|
331
372
|
const rowsTable = (rows, label, currency, limit = 5) => rows?.length
|
|
332
373
|
? table([label, "Visitors", "Revenue"], rows.slice(0, limit).map((r) => [truncate(r.name), num(r.visitors), r.revenue === undefined ? "–" : money(r.revenue, currency)]), ["left", "right", "right"])
|
|
333
374
|
: dim("No data.");
|
|
375
|
+
const isObject = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
376
|
+
/**
|
|
377
|
+
* --compare off: reports always come with a comparison (the API compares with the previous period
|
|
378
|
+
* unless told otherwise), so the CLI leaves those parts out: the overview's previous figures and
|
|
379
|
+
* change percentages, previous-period series, insights' source changes and the subscription
|
|
380
|
+
* events' changes.
|
|
381
|
+
*/
|
|
382
|
+
export function withoutComparison(data) {
|
|
383
|
+
const { previous: _p, previousSeries: _s, previousPeriod: _pp, sourceChanges: _c, ...rest } = data;
|
|
384
|
+
const out = { ...rest };
|
|
385
|
+
if (isObject(rest.overview)) {
|
|
386
|
+
const { previous: _op, change: _oc, ...overview } = rest.overview;
|
|
387
|
+
out.overview = overview;
|
|
388
|
+
}
|
|
389
|
+
if (isObject(rest.lifecycle) && Array.isArray(rest.lifecycle.goals))
|
|
390
|
+
out.lifecycle = {
|
|
391
|
+
...rest.lifecycle,
|
|
392
|
+
goals: rest.lifecycle.goals.map((g) => {
|
|
393
|
+
if (!isObject(g))
|
|
394
|
+
return g;
|
|
395
|
+
const { previous: _gp, change: _gc, ...goal } = g;
|
|
396
|
+
return goal;
|
|
397
|
+
}),
|
|
398
|
+
};
|
|
399
|
+
return out;
|
|
400
|
+
}
|
|
334
401
|
const RENDER = {
|
|
335
402
|
traffic(d) {
|
|
336
403
|
const c = d.overview.current;
|
|
337
404
|
const ch = d.overview.change;
|
|
338
405
|
const cur = d.period.currency ?? "USD";
|
|
339
|
-
|
|
406
|
+
// No change column with --compare off (the report then has no overview.change).
|
|
407
|
+
const metric = (label, value, key, lowerIsBetter = false) => ch ? [label, value, change(ch[key], { lowerIsBetter })] : [label, value];
|
|
340
408
|
return [
|
|
341
409
|
periodLine(d.period),
|
|
342
|
-
table(["Metric", "Value", "vs previous"], [
|
|
410
|
+
table(ch ? ["Metric", "Value", "vs previous"] : ["Metric", "Value"], [
|
|
343
411
|
metric("Visitors", num(c.visitors), "visitors"),
|
|
344
412
|
metric("Pageviews", num(c.pageviews), "pageviews"),
|
|
345
413
|
metric("Visits", num(c.sessions), "sessions"),
|
|
@@ -348,7 +416,7 @@ const RENDER = {
|
|
|
348
416
|
metric("Revenue", money(c.revenue, cur), "revenue"),
|
|
349
417
|
metric("Conversion rate", pct(c.conversionRate, 2), "conversionRate"),
|
|
350
418
|
metric("Revenue / visitor", money(c.revenuePerVisitor, cur), "revenuePerVisitor"),
|
|
351
|
-
], ["left", "right", "right"]),
|
|
419
|
+
], ch ? ["left", "right", "right"] : ["left", "right"]),
|
|
352
420
|
section("Top channels", rowsTable(d.channels, "Channel", cur)),
|
|
353
421
|
section("Top pages", rowsTable(d.pages, "Page", cur)),
|
|
354
422
|
section("Top countries", rowsTable(d.countries, "Country", cur)),
|
|
@@ -366,17 +434,21 @@ const RENDER = {
|
|
|
366
434
|
const c = d.overview.current;
|
|
367
435
|
const ch = d.overview.change;
|
|
368
436
|
const cur = d.period.currency ?? "USD";
|
|
437
|
+
const rows = [
|
|
438
|
+
["Revenue", money(c.revenue, cur), change(ch?.revenue)],
|
|
439
|
+
["New revenue", money(c.newRevenue, cur), change(ch?.newRevenue)],
|
|
440
|
+
["Renewal revenue", money(c.renewalRevenue, cur), change(ch?.renewalRevenue)],
|
|
441
|
+
["New payments", num(c.newPayments), change(ch?.newPayments)],
|
|
442
|
+
["Renewals", num(c.renewals), change(ch?.renewals)],
|
|
443
|
+
["Paying customers", num(c.payingCustomers), change(ch?.payingCustomers)],
|
|
444
|
+
["Refunds", `${num(c.refunds)} (${money(c.refundedAmount, cur)})`, ""],
|
|
445
|
+
];
|
|
369
446
|
return [
|
|
370
447
|
periodLine(d.period),
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
["
|
|
374
|
-
["
|
|
375
|
-
["New payments", num(c.newPayments), change(ch.newPayments)],
|
|
376
|
-
["Renewals", num(c.renewals), change(ch.renewals)],
|
|
377
|
-
["Paying customers", num(c.payingCustomers), change(ch.payingCustomers)],
|
|
378
|
-
["Refunds", `${num(c.refunds)} (${money(c.refundedAmount, cur)})`, ""],
|
|
379
|
-
], ["left", "right", "right"]),
|
|
448
|
+
// No change column with --compare off (the report then has no overview.change).
|
|
449
|
+
ch
|
|
450
|
+
? table(["Metric", "Value", "vs previous"], rows, ["left", "right", "right"])
|
|
451
|
+
: table(["Metric", "Value"], rows.map(([label, value]) => [label, value]), ["left", "right"]),
|
|
380
452
|
section("Revenue by channel (first touch)", d.byChannel?.length
|
|
381
453
|
? table(["Channel", "Revenue", "New", "Renewals"], d.byChannel.slice(0, 8).map((r) => [r.name, money(r.revenue, cur), num(r.newPayments), num(r.renewals)]), ["left", "right", "right", "right"])
|
|
382
454
|
: dim("No payments.")),
|
|
@@ -966,6 +1038,7 @@ function printBotSettings(d) {
|
|
|
966
1038
|
out(`Excluded agents: ${list(d.settings.excludedAgents)}`);
|
|
967
1039
|
out(`Bot token: ${d.token.hasToken ? `${d.token.hint ?? "set"}${d.token.lastUsedAt ? `, last used ${date(d.token.lastUsedAt)}` : ", not used yet"}` : "none (create one in Settings → Tracking & install)"}`);
|
|
968
1040
|
out(`Require bot token: ${d.settings.rejectWithoutToken ? "yes" : "no"}`);
|
|
1041
|
+
out(`Verified only: ${d.settings.verifiedOnly ? "yes (crawler events from outside the published IP ranges are dropped)" : "no"}`);
|
|
969
1042
|
}
|
|
970
1043
|
/** `metricraven bots …`: bot traffic settings (exclusions, token enforcement) and the bot request allowance. */
|
|
971
1044
|
async function bots(ctx, sub, rest) {
|
|
@@ -974,6 +1047,18 @@ async function bots(ctx, sub, rest) {
|
|
|
974
1047
|
const params = () => new URLSearchParams({ site });
|
|
975
1048
|
switch (sub ?? "settings") {
|
|
976
1049
|
case "settings": {
|
|
1050
|
+
const verifiedOnly = flags["verified-only"];
|
|
1051
|
+
if (verifiedOnly !== undefined) {
|
|
1052
|
+
if (verifiedOnly !== "on" && verifiedOnly !== "off")
|
|
1053
|
+
throw new UsageError("Use: metricraven bots settings --verified-only on|off");
|
|
1054
|
+
const d = await needs("write", client.patch("/bot-traffic/settings", { verifiedOnly: verifiedOnly === "on" }, params()));
|
|
1055
|
+
if (flags.json)
|
|
1056
|
+
return printJson(d), 0;
|
|
1057
|
+
out(verifiedOnly === "on"
|
|
1058
|
+
? "Only IP-verified crawler events are recorded now; events from outside a crawler's published IP ranges are dropped."
|
|
1059
|
+
: "Crawler events are recorded whether or not their IP is verified.");
|
|
1060
|
+
return 0;
|
|
1061
|
+
}
|
|
977
1062
|
const d = await client.get("/bot-traffic/settings", params());
|
|
978
1063
|
if (flags.json)
|
|
979
1064
|
return printJson(d), 0;
|
|
@@ -1030,6 +1115,7 @@ const PROXY_STATUS = {
|
|
|
1030
1115
|
issuing_certificate: "Issuing certificate",
|
|
1031
1116
|
active: "Active",
|
|
1032
1117
|
error: "Needs attention",
|
|
1118
|
+
paused: "Paused (plan ended)",
|
|
1033
1119
|
};
|
|
1034
1120
|
function printProxy(d) {
|
|
1035
1121
|
const p = d.proxy;
|
|
@@ -1042,6 +1128,8 @@ function printProxy(d) {
|
|
|
1042
1128
|
out(`${bold(p.hostname)} ${PROXY_STATUS[p.status] ?? p.status}${p.checkedAt ? dim(` (checked ${date(p.checkedAt)})`) : ""}`);
|
|
1043
1129
|
if (p.error)
|
|
1044
1130
|
out(p.error);
|
|
1131
|
+
if (p.status === "paused")
|
|
1132
|
+
return out("Paused because your plan ended. Choose a plan, then run `metricraven proxy check` to set it up again.");
|
|
1045
1133
|
if (p.status !== "active")
|
|
1046
1134
|
out(section("Add this DNS record", table(["Type", "Name / Host", "Value", ""], p.records.map((r) => [r.type, r.name, r.value, r.required ? "" : "only if the CNAME doesn't verify"]))));
|
|
1047
1135
|
else
|
package/dist/completion.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { UsageError } from "./args.js";
|
|
2
|
+
/** --provider values of `analytics ads`: what GET /stats/ads accepts (TikTok Ads can't be connected yet). */
|
|
3
|
+
export const AD_PROVIDER_VALUES = ["all", "meta", "google", "tiktok"];
|
|
2
4
|
/** Shell completion scripts for `metricraven completion bash|zsh|fish`. */
|
|
3
5
|
const COMMANDS = ["login", "logout", "whoami", "account", "tokens", "payments", "use", "websites", "analytics", "realtime", "visitors", "funnels", "goals", "notes", "mentions", "ai-visibility", "alerts", "members", "bots", "proxy", "completion"];
|
|
4
6
|
const SUB = {
|
|
@@ -18,15 +20,28 @@ const SUB = {
|
|
|
18
20
|
proxy: ["status", "enable", "check", "remove"],
|
|
19
21
|
completion: ["bash", "zsh", "fish"],
|
|
20
22
|
};
|
|
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"];
|
|
23
|
+
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", "--account", "--order", "--verified-only"];
|
|
24
|
+
/** Flags with a fixed set of values; completion offers them after the flag. */
|
|
25
|
+
export const FLAG_VALUES = {
|
|
26
|
+
"--provider": AD_PROVIDER_VALUES,
|
|
27
|
+
"--compare": ["previous", "year", "off"],
|
|
28
|
+
"--order": ["asc", "desc"],
|
|
29
|
+
"--verified-only": ["on", "off"],
|
|
30
|
+
};
|
|
22
31
|
export function completionScript(shell) {
|
|
23
32
|
if (shell === "bash") {
|
|
33
|
+
const values = Object.entries(FLAG_VALUES)
|
|
34
|
+
.map(([flag, list]) => ` ${flag}) COMPREPLY=($(compgen -W "${list.join(" ")}" -- "$cur")); return ;;`)
|
|
35
|
+
.join("\n");
|
|
24
36
|
const cases = Object.entries(SUB)
|
|
25
37
|
.map(([cmd, subs]) => ` ${cmd}) COMPREPLY=($(compgen -W "${subs.join(" ")} ${FLAGS.join(" ")}" -- "$cur")) ;;`)
|
|
26
38
|
.join("\n");
|
|
27
39
|
return `# metricraven bash completion. Add to ~/.bashrc: eval "$(metricraven completion bash)"
|
|
28
40
|
_metricraven() {
|
|
29
41
|
local cur="\${COMP_WORDS[COMP_CWORD]}"
|
|
42
|
+
case "\${COMP_WORDS[COMP_CWORD-1]}" in
|
|
43
|
+
${values}
|
|
44
|
+
esac
|
|
30
45
|
if [ "$COMP_CWORD" -eq 1 ]; then
|
|
31
46
|
COMPREPLY=($(compgen -W "${COMMANDS.join(" ")} ${FLAGS.join(" ")}" -- "$cur")); return
|
|
32
47
|
fi
|
|
@@ -38,12 +53,18 @@ ${cases}
|
|
|
38
53
|
complete -F _metricraven metricraven`;
|
|
39
54
|
}
|
|
40
55
|
if (shell === "zsh") {
|
|
56
|
+
const values = Object.entries(FLAG_VALUES)
|
|
57
|
+
.map(([flag, list]) => ` ${flag}) compadd -- ${list.join(" ")}; return ;;`)
|
|
58
|
+
.join("\n");
|
|
41
59
|
const cases = Object.entries(SUB)
|
|
42
60
|
.map(([cmd, subs]) => ` ${cmd}) compadd -- ${subs.join(" ")} ${FLAGS.join(" ")} ;;`)
|
|
43
61
|
.join("\n");
|
|
44
62
|
return `#compdef metricraven
|
|
45
63
|
# metricraven zsh completion. Add to ~/.zshrc: eval "$(metricraven completion zsh)"
|
|
46
64
|
_metricraven() {
|
|
65
|
+
case "\${words[CURRENT-1]}" in
|
|
66
|
+
${values}
|
|
67
|
+
esac
|
|
47
68
|
if (( CURRENT == 2 )); then
|
|
48
69
|
compadd -- ${COMMANDS.join(" ")} ${FLAGS.join(" ")}
|
|
49
70
|
else
|
|
@@ -61,7 +82,9 @@ compdef _metricraven metricraven`;
|
|
|
61
82
|
"complete -c metricraven -f",
|
|
62
83
|
`complete -c metricraven -n "__fish_use_subcommand" -a "${COMMANDS.join(" ")}"`,
|
|
63
84
|
...Object.entries(SUB).map(([cmd, subs]) => `complete -c metricraven -n "__fish_seen_subcommand_from ${cmd}" -a "${subs.join(" ")}"`),
|
|
64
|
-
...FLAGS.map((f) =>
|
|
85
|
+
...FLAGS.map((f) => FLAG_VALUES[f]
|
|
86
|
+
? `complete -c metricraven -l ${f.slice(2)} -x -a "${FLAG_VALUES[f].join(" ")}"`
|
|
87
|
+
: `complete -c metricraven -l ${f.slice(2)}`),
|
|
65
88
|
];
|
|
66
89
|
return lines.join("\n");
|
|
67
90
|
}
|
package/dist/index.js
CHANGED
|
@@ -39,6 +39,7 @@ Reports (default: last 30 days)
|
|
|
39
39
|
analytics breakdown <dim> Full table for a dimension: channel, referrer, page,
|
|
40
40
|
entryPage, utmSource, utmCampaign, country, city,
|
|
41
41
|
browser, os, device, hostname, outbound, …
|
|
42
|
+
--sort visitors|pageviews|revenue|name, --order desc|asc
|
|
42
43
|
analytics revenue Payments, renewals, refunds, LTV, revenue by channel
|
|
43
44
|
analytics mrr [unit] MRR over time: new, expansion, contraction, churn
|
|
44
45
|
(unit: day, week or month)
|
|
@@ -48,8 +49,10 @@ Reports (default: last 30 days)
|
|
|
48
49
|
analytics search Google Search Console queries
|
|
49
50
|
analytics crawlers AI crawlers and bots
|
|
50
51
|
analytics ads [level] Ad spend, revenue and ROAS for every connected network
|
|
51
|
-
(campaign, adgroup or ad; --provider all|meta|google
|
|
52
|
+
(campaign, adgroup or ad; --provider all|meta|google|tiktok;
|
|
53
|
+
--account <id>: one chosen ad account alone)
|
|
52
54
|
analytics meta-ads [level] Meta Ads spend, revenue and ROAS by campaign, adset or ad
|
|
55
|
+
(--account <id>: one ad account alone)
|
|
53
56
|
realtime Visitors online now
|
|
54
57
|
visitors list Visitors in the period (needs visitor details access);
|
|
55
58
|
search: --page, --page-contains, --goal, --referrer,
|
|
@@ -98,7 +101,8 @@ Team
|
|
|
98
101
|
members revoke <invite_id> Revoke a pending invitation
|
|
99
102
|
|
|
100
103
|
Bot traffic
|
|
101
|
-
bots settings Excluded crawler companies and agents, bot token status
|
|
104
|
+
bots settings Excluded crawler companies and agents, bot token status;
|
|
105
|
+
--verified-only on|off records only IP-verified crawlers
|
|
102
106
|
bots usage AI and bot requests used this cycle and the allowance
|
|
103
107
|
bots exclude <name…> Stop recording these agents (--company for companies)
|
|
104
108
|
bots include <name…> Record excluded agents again (--company for companies)
|
|
@@ -117,7 +121,8 @@ Period and filters
|
|
|
117
121
|
--from, --to <date> Custom days, YYYY-MM-DD (inclusive)
|
|
118
122
|
-z, --timezone <zone> IANA zone for day boundaries, e.g. Europe/Madrid (default UTC)
|
|
119
123
|
--compare <c> Change figures against: previous (default), year
|
|
120
|
-
(same period last year)
|
|
124
|
+
(same period last year), a YYYY-MM-DD start, or
|
|
125
|
+
off (no comparison: no change column, none in --json)
|
|
121
126
|
-f, --filter <dim:op:value> Repeatable. Ops: is, is_not, contains, not_contains;
|
|
122
127
|
gt, lt for visits. e.g. -f country:is:US
|
|
123
128
|
-f page:contains:/blog -f visits:gt:2
|
|
@@ -129,7 +134,8 @@ Period and filters
|
|
|
129
134
|
with is or is_not: -f model:is:claude
|
|
130
135
|
|
|
131
136
|
List options
|
|
132
|
-
--sort, -n/--limit, --offset, --q (search),
|
|
137
|
+
--sort, --order asc|desc (breakdown), -n/--limit, --offset, --q (search),
|
|
138
|
+
--payment all|paid|unpaid
|
|
133
139
|
|
|
134
140
|
Global
|
|
135
141
|
--site <id> Website for this command (or METRICRAVEN_SITE, or \`use\`)
|
package/package.json
CHANGED