@metricraven/cli 0.4.1 → 0.4.3

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 CHANGED
@@ -58,7 +58,7 @@ 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 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 |
61
+ | `bots settings\|usage`, `bots settings --verified-only on\|off`, `bots settings --datacenter on\|off`, `bots exclude\|include <name…> [--company]`, `bots require-token on\|off` | Bot traffic settings (`--verified-only on` records only IP-verified crawlers; `--datacenter on`, the default, doesn't count tracker hits from cloud and hosting networks) 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
 
package/dist/args.js CHANGED
@@ -73,6 +73,7 @@ const OPTIONS = {
73
73
  grace: { type: "string" },
74
74
  // bots settings
75
75
  "verified-only": { type: "string" },
76
+ datacenter: { type: "string" },
76
77
  };
77
78
  export class UsageError extends Error {
78
79
  }
package/dist/commands.js CHANGED
@@ -273,7 +273,7 @@ async function analytics(ctx, sub, rest) {
273
273
  params.set("level", rest[0]);
274
274
  if (flags.provider) {
275
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).");
276
+ throw new UsageError("Use --provider all, meta, google or tiktok.");
277
277
  params.set("provider", flags.provider);
278
278
  }
279
279
  if (flags.account)
@@ -319,7 +319,7 @@ function renderAds(d) {
319
319
  if (!d.configured)
320
320
  return d.reason === "no_account"
321
321
  ? "An ad network is connected but no ad account is chosen yet. Pick one in Settings → Integrations."
322
- : "No ad network is connected for this website. Connect Meta Ads or Google Ads in the dashboard: https://metricraven.com/docs/meta-ads";
322
+ : "No ad network is connected for this website. Connect Meta Ads, Google Ads or TikTok Ads in the dashboard: https://metricraven.com/docs/meta-ads";
323
323
  const cur = d.period?.currency ?? "USD";
324
324
  const t = d.totals;
325
325
  const roas = (v) => (v === null || v === undefined ? "–" : `${num(v, 2)}x`);
@@ -1039,6 +1039,10 @@ function printBotSettings(d) {
1039
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)"}`);
1040
1040
  out(`Require bot token: ${d.settings.rejectWithoutToken ? "yes" : "no"}`);
1041
1041
  out(`Verified only: ${d.settings.verifiedOnly ? "yes (crawler events from outside the published IP ranges are dropped)" : "no"}`);
1042
+ if (d.settings.excludeDatacenter !== undefined) {
1043
+ const count = d.datacenter ? `, ${num(d.datacenter.excludedLast30Days)} hits excluded in the last 30 days` : "";
1044
+ out(`Data-center hits: ${d.settings.excludeDatacenter ? `excluded (cloud and hosting networks${count})` : "counted"}`);
1045
+ }
1042
1046
  }
1043
1047
  /** `metricraven bots …`: bot traffic settings (exclusions, token enforcement) and the bot request allowance. */
1044
1048
  async function bots(ctx, sub, rest) {
@@ -1047,6 +1051,18 @@ async function bots(ctx, sub, rest) {
1047
1051
  const params = () => new URLSearchParams({ site });
1048
1052
  switch (sub ?? "settings") {
1049
1053
  case "settings": {
1054
+ const datacenter = flags.datacenter;
1055
+ if (datacenter !== undefined) {
1056
+ if (datacenter !== "on" && datacenter !== "off")
1057
+ throw new UsageError("Use: metricraven bots settings --datacenter on|off");
1058
+ const d = await needs("write", client.patch("/bot-traffic/settings", { excludeDatacenter: datacenter === "on" }, params()));
1059
+ if (flags.json)
1060
+ return printJson(d), 0;
1061
+ out(datacenter === "on"
1062
+ ? "Tracker hits from data-center networks (cloud servers, scrapers) are no longer counted as visitors."
1063
+ : "Tracker hits from data-center networks are counted again.");
1064
+ return 0;
1065
+ }
1050
1066
  const verifiedOnly = flags["verified-only"];
1051
1067
  if (verifiedOnly !== undefined) {
1052
1068
  if (verifiedOnly !== "on" && verifiedOnly !== "off")
@@ -1,5 +1,5 @@
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). */
2
+ /** --provider values of `analytics ads`: what GET /stats/ads accepts. */
3
3
  export const AD_PROVIDER_VALUES = ["all", "meta", "google", "tiktok"];
4
4
  /** Shell completion scripts for `metricraven completion bash|zsh|fish`. */
5
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"];
@@ -20,13 +20,14 @@ const SUB = {
20
20
  proxy: ["status", "enable", "check", "remove"],
21
21
  completion: ["bash", "zsh", "fish"],
22
22
  };
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"];
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", "--datacenter"];
24
24
  /** Flags with a fixed set of values; completion offers them after the flag. */
25
25
  export const FLAG_VALUES = {
26
26
  "--provider": AD_PROVIDER_VALUES,
27
27
  "--compare": ["previous", "year", "off"],
28
28
  "--order": ["asc", "desc"],
29
29
  "--verified-only": ["on", "off"],
30
+ "--datacenter": ["on", "off"],
30
31
  };
31
32
  export function completionScript(shell) {
32
33
  if (shell === "bash") {
package/dist/index.js CHANGED
@@ -102,7 +102,8 @@ Team
102
102
 
103
103
  Bot traffic
104
104
  bots settings Excluded crawler companies and agents, bot token status;
105
- --verified-only on|off records only IP-verified crawlers
105
+ --verified-only on|off records only IP-verified crawlers;
106
+ --datacenter on|off excludes cloud/hosting network hits
106
107
  bots usage AI and bot requests used this cycle and the allowance
107
108
  bots exclude <name…> Stop recording these agents (--company for companies)
108
109
  bots include <name…> Record excluded agents again (--company for companies)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metricraven/cli",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "MetricRaven from your terminal: traffic, revenue, goals, visitors and websites. Built for people and AI agents.",
5
5
  "type": "module",
6
6
  "license": "MIT",