@letterstory/cli 0.177.111 → 0.177.113

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/lib/cli.mjs CHANGED
@@ -91,7 +91,7 @@ import {
91
91
  import { fetchParkedSections, withoutParked } from "./parked.mjs";
92
92
 
93
93
  // Matches cli/package.json; publish-cli.yml rewrites both to the published version.
94
- export const VERSION = "0.177.111";
94
+ export const VERSION = "0.177.113";
95
95
 
96
96
  /** The exit code for a gate refusal (CARD_REQUIRED, PAYMENT_FAILED, OUT_OF_TOKENS): 1 is a plain error. */
97
97
  export const EXIT_PAYMENT_REQUIRED = 3;
@@ -11,6 +11,10 @@
11
11
  // letterstory usage posthog [status]|sync [--days 7]|disconnect the connection (never its key), sync now, remove it
12
12
  // letterstory usage database connect (--project <ref> --key <sbp_…> | --url postgres://… | --existing)
13
13
  // --host app.acme.com --schemas public --since … --until … Supabase or any Postgres
14
+ // letterstory usage shown statistics shown to agents, and what agents get
15
+ // letterstory usage shown show|hide <choice_id> show a tracked action to agents, or take it off
16
+ // letterstory usage shown pr [--repo <owner/name>] [--base <branch>] put them on the website: one build, one pull request
17
+ // letterstory usage shown check [--url <page>] check a page serves them as the data says
14
18
  // letterstory usage case-study [--days 7|30|90] the patterns and the latest case study
15
19
  // letterstory usage case-study generate [--days] [--patterns a,b] [--named [--companies x.com,y.com]]
16
20
  // letterstory usage case-study publish|unpublish <id>
@@ -71,6 +75,13 @@ export const ARGS = {
71
75
  },
72
76
  set_usage_payment_scope: paymentScopeArgs,
73
77
  preview_usage_payment_scope: paymentScopeArgs,
78
+ get_shown_statistics: {},
79
+ set_shown_statistic: {
80
+ choice_id: { positional: 0, required: true, label: "choice_id" },
81
+ shown: { value: (_flags, _positionals, extra) => extra.shown === true },
82
+ },
83
+ open_shown_statistics_pr: { repo: { flag: "repo" }, base_branch: { flag: "base" } },
84
+ check_shown_statistics_on_site: { url: { flag: "url" } },
74
85
  disconnect_usage_payments: {},
75
86
  get_usage_sources: { host: { flag: "host" }, site_id: { flag: "site" } },
76
87
  choose_product_repo: {
@@ -342,6 +353,30 @@ export async function cmdUsage(ctx) {
342
353
  printResult(io, flags, await client.callTool(tool, argsFromFlags(ARGS[tool], flags, [])));
343
354
  return 0;
344
355
  }
356
+ if (ctx.positionals[0] === "shown") {
357
+ const sub = ctx.positionals[1] ?? "status";
358
+ const rest = ctx.positionals.slice(2);
359
+ if (sub === "status") {
360
+ printResult(io, flags, await client.callTool("get_shown_statistics", {}));
361
+ return 0;
362
+ }
363
+ if (sub === "show" || sub === "hide") {
364
+ const args = argsFromFlags(ARGS.set_shown_statistic, flags, rest, { shown: sub === "show" });
365
+ printResult(io, flags, await client.callTool("set_shown_statistic", args));
366
+ return 0;
367
+ }
368
+ if (sub === "pr") {
369
+ const args = argsFromFlags(ARGS.open_shown_statistics_pr, flags, rest);
370
+ printResult(io, flags, await client.callTool("open_shown_statistics_pr", args));
371
+ return 0;
372
+ }
373
+ if (sub === "check") {
374
+ const args = argsFromFlags(ARGS.check_shown_statistics_on_site, flags, rest);
375
+ printResult(io, flags, await client.callTool("check_shown_statistics_on_site", args));
376
+ return 0;
377
+ }
378
+ throw new CliError("Use shown, shown show|hide <choice_id>, shown pr or shown check");
379
+ }
345
380
  if (ctx.positionals[0] === "payments") {
346
381
  const tool = {
347
382
  connect: "connect_usage_payments",
@@ -438,6 +473,13 @@ export async function cmdUsage(ctx) {
438
473
  const t = r.totals;
439
474
  const lines = [
440
475
  `${r.app.host ?? "Your app"}, last ${r.days} days: ${t.people} people, ${t.companies} companies, ${t.pages} pages`,
476
+ ...(r.browsers
477
+ ? [` of ${r.browsers.total} browsers since ${r.browsers.since}, ${r.browsers.signed_in} signed in`]
478
+ : []),
479
+ ...r.sources.map(
480
+ (s) =>
481
+ ` ${s.source === "letter" ? "Letter, tracked since" : "PostHog history from"} ${s.first_day}: ${s.people} people`
482
+ ),
441
483
  "",
442
484
  "Features",
443
485
  ...r.features
@@ -10,6 +10,8 @@
10
10
  // letterstory visits citations --since 30d
11
11
  // letterstory visits people --since 30d [--path /pricing] people who read the site, and how many were identified
12
12
  // letterstory visits who --icp [--category Investors] [--path /pricing] who was identified (--icp: who fits your ICP)
13
+ // letterstory visits converts [--event signup] [--days 30] which pages lead to a conversion, by lift
14
+ // letterstory visits retention [--days 90] which features new people used early and came back
13
15
  // letterstory visits export --since 30d --format csv
14
16
  // letterstory visits export --include people --icp > icp.csv the people who fit your ICP, as Humans shows them
15
17
  // letterstory visits sites
@@ -62,6 +64,13 @@ export const ARGS = {
62
64
  },
63
65
  visitors_get_citations: { site_id: "site", days },
64
66
  visitors_get_human_visits: { site_id: "site", days, path: "path" },
67
+ visitors_get_conversions: {
68
+ site_id: "site",
69
+ days,
70
+ event: { flag: "event" },
71
+ limit: { flag: "limit", type: "num" },
72
+ },
73
+ visitors_get_feature_retention: { site_id: "site", days },
65
74
  visitors_get_people: {
66
75
  site_id: "site",
67
76
  days,
@@ -192,6 +201,10 @@ export async function cmdVisits(ctx) {
192
201
  return visitsPeople(rest);
193
202
  case "who":
194
203
  return visitsWho(rest);
204
+ case "converts":
205
+ return visitsConverts(rest);
206
+ case "retention":
207
+ return visitsRetention(rest);
195
208
  case "compare":
196
209
  return visitsCompare(rest);
197
210
  case "export":
@@ -510,6 +523,43 @@ async function visitsWho(ctx) {
510
523
  return 0;
511
524
  }
512
525
 
526
+ async function visitsConverts(ctx) {
527
+ const { flags, io } = ctx;
528
+ const result = await call(ctx, "visitors_get_conversions");
529
+ printResult(io, flags, result, (r) => {
530
+ if (!r.event) return 'No events tracked yet. Add lettervisit("track", "signup") where it happens.';
531
+ const pct = (v) => `${(v * 100).toFixed(1)}%`;
532
+ const lines = [
533
+ `${r.event}: ${r.browsers ? `${r.browsers.converted} of ${r.browsers.total} browsers (${pct(r.browsers.rate)})` : "no browsers"} since ${r.since}`,
534
+ `Events: ${r.events.map((e) => `${e.name} ${e.browsers}`).join(", ")}`,
535
+ "",
536
+ ];
537
+ for (const p of r.pages)
538
+ lines.push(
539
+ ` ${p.path.slice(0, 40).padEnd(42)} ${String(p.viewers).padStart(6)} viewers ${pct(p.rate).padStart(6)} ${p.lift === null ? "" : `${p.lift}x`}`
540
+ );
541
+ return lines.join("\n");
542
+ });
543
+ return 0;
544
+ }
545
+
546
+ async function visitsRetention(ctx) {
547
+ const { flags, io } = ctx;
548
+ const result = await call(ctx, "visitors_get_feature_retention");
549
+ printResult(io, flags, result, (r) => {
550
+ if (!r.features.length) return "Not enough new people yet.";
551
+ const pct = (v) => `${(v * 100).toFixed(0)}%`;
552
+ return [
553
+ `New people since ${r.since}: used early (first ${r.early_days} days) vs not, back by week 3`,
554
+ ...r.features.map(
555
+ (f) =>
556
+ ` ${f.feature.slice(0, 36).padEnd(38)} ${String(f.users).padStart(5)} people ${pct(f.rate).padStart(4)} vs ${pct(f.rate_others).padStart(4)} ${f.lift === null ? "" : `${f.lift}x`}`
557
+ ),
558
+ ].join("\n");
559
+ });
560
+ return 0;
561
+ }
562
+
513
563
  async function visitsCompare(ctx) {
514
564
  const { flags, io } = ctx;
515
565
  const result = await call(ctx, "visitors_compare_agents");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letterstory/cli",
3
- "version": "0.177.111",
3
+ "version": "0.177.113",
4
4
  "description": "Spin up and manage Letter phantom blogs from your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",