thumbgate 1.40.3 → 1.40.6

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.
Files changed (54) hide show
  1. package/.agents/skills/comet-session-logger/SKILL.md +8 -5
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.well-known/mcp/server-card.json +1 -1
  4. package/README.md +7 -2
  5. package/adapters/claude/.mcp.json +3 -3
  6. package/adapters/forge/forge.yaml +3 -3
  7. package/adapters/future-agi/.mcp.json +1 -1
  8. package/adapters/future-agi/config.toml +1 -1
  9. package/adapters/future-agi/opencode.json +1 -1
  10. package/adapters/herdr/herdr-plugin.toml +2 -2
  11. package/adapters/mcp/server-stdio.js +1 -1
  12. package/adapters/opencode/opencode.json +1 -1
  13. package/config/github-about.json +1 -1
  14. package/config/post-deploy-marketing-pages.json +1 -1
  15. package/package.json +35 -7
  16. package/public/about.html +2 -2
  17. package/public/admin.html +546 -50
  18. package/public/case-studies.html +1 -0
  19. package/public/dashboard.html +7 -6
  20. package/public/diagnostic.html +15 -12
  21. package/public/index.html +210 -88
  22. package/public/install.html +9 -8
  23. package/public/js/connect-panel.js +437 -0
  24. package/public/learn.html +8 -0
  25. package/public/numbers.html +2 -2
  26. package/public/preview.html +42 -0
  27. package/public/pricing.html +55 -10
  28. package/public/support.html +1 -1
  29. package/public/terms.html +1 -1
  30. package/scripts/auto-promote-gates.js +29 -4
  31. package/scripts/billing.js +189 -4
  32. package/scripts/cap-hit-counter.js +47 -0
  33. package/scripts/checkout-human-gate.js +248 -0
  34. package/scripts/checkout-session-count.js +119 -0
  35. package/scripts/claude-feedback-sync.js +4 -2
  36. package/scripts/feedback-loop.js +41 -5
  37. package/scripts/first-block-upsell.js +187 -0
  38. package/scripts/gates-engine.js +37 -108
  39. package/scripts/human-feedback.js +20 -1
  40. package/scripts/ops-log.js +91 -0
  41. package/scripts/ops-report.js +174 -0
  42. package/scripts/owner-admin.js +508 -27
  43. package/scripts/owner-telemetry.js +151 -0
  44. package/scripts/rate-limiter.js +8 -2
  45. package/scripts/statusline-human-counts.js +71 -8
  46. package/scripts/statusline.sh +15 -2
  47. package/scripts/telemetry-analytics.js +4 -0
  48. package/scripts/tool-contract-validator.js +13 -3
  49. package/scripts/tool-registry.js +1 -1
  50. package/scripts/utm-source-summary.js +88 -0
  51. package/server.json +2 -2
  52. package/skills/comet-session-logger/SKILL.md +8 -5
  53. package/src/api/server.js +649 -107
  54. package/src/mcp/email-triage-server/index.js +92 -14
package/public/admin.html CHANGED
@@ -101,6 +101,30 @@
101
101
  background: var(--accent);
102
102
  color: var(--bg);
103
103
  }
104
+ .banner {
105
+ font-size: 18px;
106
+ padding: 14px 18px;
107
+ margin: 0 0 20px;
108
+ border: 1px solid var(--line);
109
+ border-left-width: 8px;
110
+ border-radius: 10px;
111
+ }
112
+ .banner.green {
113
+ border-left-color: #4ade80;
114
+ }
115
+ .banner.amber {
116
+ border-left-color: #fbbf24;
117
+ }
118
+ .banner.red {
119
+ border-left-color: #f87171;
120
+ }
121
+ .block {
122
+ margin: 0 0 22px;
123
+ }
124
+ .block h3 {
125
+ margin: 0 0 6px;
126
+ font-size: 16px;
127
+ }
104
128
  .panel {
105
129
  background: var(--panel);
106
130
  border: 1px solid var(--line);
@@ -247,6 +271,7 @@
247
271
  'use strict';
248
272
  const content = document.getElementById('content');
249
273
  const sections = [
274
+ 'money',
250
275
  'overview',
251
276
  'stripe',
252
277
  'data',
@@ -254,13 +279,14 @@
254
279
  'observability',
255
280
  ];
256
281
  const titles = {
282
+ money: 'Money',
257
283
  overview: 'Overview',
258
284
  stripe: 'Stripe records',
259
285
  data: 'Hosted data',
260
286
  analytics: 'Analytics',
261
287
  observability: 'Observability',
262
288
  };
263
- let current = 'overview';
289
+ let current = 'money';
264
290
  let resource = 'customers';
265
291
  let subscriptionId = null;
266
292
  let nextCursor = null;
@@ -274,8 +300,35 @@
274
300
  function label(value) {
275
301
  return String(value)
276
302
  .replace(/([a-z])([A-Z])/g, '$1 $2')
303
+ .replace(/([a-zA-Z])(\d)/g, '$1 $2')
277
304
  .replaceAll('_', ' ');
278
305
  }
306
+ // Money tab wording: plain words, never field names.
307
+ const CHECKOUT_WORDS = {
308
+ started: 'Started',
309
+ human: 'Started, browser-classified',
310
+ completedHuman: 'Completed, browser-classified',
311
+ paidHuman: 'Paid, browser-classified',
312
+ bot: 'Started, bot-classified',
313
+ notClassified: 'Insufficient classification evidence (no bot check on record)',
314
+ internal: 'Owner and test checkouts',
315
+ };
316
+ const SITE_START_WORDS = {
317
+ pro_checkout_direct_stripe: 'Direct Stripe link opened',
318
+ checkout_start: 'Checkout started',
319
+ checkout_bootstrap: 'Checkout page loaded',
320
+ diagnostic_checkout_confirmed: 'Diagnostic checkout confirmed',
321
+ };
322
+ const BASIS_WORDS = {
323
+ stripe_paid_and_active: 'people with a paid, unrefunded ThumbGate checkout in the past year, plus active subscribers, counted once each; owner and test purchases excluded',
324
+ stripe_paid_and_active_partial: 'people with a paid, unrefunded ThumbGate checkout in the past year, plus active subscribers (only the first records Stripe returned were counted), counted once each; owner and test purchases excluded',
325
+ stripe_active_subscriptions_excluding_owner: 'active Stripe subscriptions, owner excluded',
326
+ stripe_active_subscriptions_first_100_only: 'active Stripe subscriptions (first 100 only), owner excluded',
327
+ unavailable: 'not available right now',
328
+ };
329
+ function basis(value) {
330
+ return BASIS_WORDS[value] || 'not available right now';
331
+ }
279
332
  function date(value) {
280
333
  if (!value) return 'Unknown';
281
334
  const d = new Date(typeof value === 'number' ? value * 1000 : value);
@@ -336,7 +389,7 @@
336
389
  });
337
390
  return button;
338
391
  }
339
- function cards(parent, values) {
392
+ function cards(parent, values, named = false) {
340
393
  const grid = element('div', undefined, 'cards');
341
394
  for (const [key, value] of Object.entries(values)) {
342
395
  const card = element('div', undefined, 'card');
@@ -346,7 +399,7 @@
346
399
  value === null || value === undefined ? 'Unknown' : value,
347
400
  'value',
348
401
  ),
349
- element('div', label(key), 'label'),
402
+ element('div', named ? key : label(key), 'label'),
350
403
  );
351
404
  grid.append(card);
352
405
  }
@@ -380,11 +433,11 @@
380
433
  wrap.append(t);
381
434
  parent.append(wrap);
382
435
  }
383
- function detail(parent, title, value) {
436
+ function detail(parent, title, value, words = {}) {
384
437
  const block = element('details');
385
438
  block.append(element('summary', title));
386
439
  const rows = Object.entries(value || {}).map(([key, val]) => ({
387
- key: label(key),
440
+ key: words[key] || label(key),
388
441
  value: typeof val === 'object' ? JSON.stringify(val) : val,
389
442
  }));
390
443
  table(
@@ -397,22 +450,427 @@
397
450
  );
398
451
  parent.append(block);
399
452
  }
453
+ // How long a measurement has really run, in words ("about 1 day"), never a fixed window the data does not cover.
454
+ function periodWords(days) {
455
+ if (!Number.isFinite(days)) return 'length not measured';
456
+ if (days < 1) return 'less than 1 day';
457
+ const n = Math.round(days * 10) / 10;
458
+ return 'about ' + n + (n === 1 ? ' day' : ' days');
459
+ }
460
+ // A conversion rate with no denominator is not zero; it is not applicable.
461
+ function conversionRows(funnel) {
462
+ const stages = funnel?.stageCounts || {};
463
+ const rates = funnel?.conversionRates || {};
464
+ const row = (name, rate, denominator, none) => ({
465
+ name,
466
+ value:
467
+ !Number.isFinite(denominator) || denominator === 0
468
+ ? 'N/A, ' + none
469
+ : Number.isFinite(rate)
470
+ ? Math.round(rate * 1000) / 10 + '%'
471
+ : 'N/A, not reported',
472
+ });
473
+ return [
474
+ row('Acquisition to activation', rates.acquisitionToActivation, stages.acquisition, 'no measured acquisition events'),
475
+ row('Activation to paid', rates.activationToPaid, stages.activation, 'no measured activations'),
476
+ row('Acquisition to paid', rates.acquisitionToPaid, stages.acquisition, 'no measured acquisition events'),
477
+ ];
478
+ }
479
+ function funnelTable(parent, funnel) {
480
+ if (!funnel) return;
481
+ parent.append(element('h3', 'Funnel conversion'));
482
+ table(parent, [['Step', (r) => r.name], ['Rate', (r) => r.value]], conversionRows(funnel));
483
+ parent.append(
484
+ element(
485
+ 'p',
486
+ 'A lead is one distinct acquisition event identity (an acquisition, trace, visitor, session or install id) from a real checkout step; synthetic checkout sessions are excluded. ' +
487
+ 'An activation is the first call made with an API key. Free local use without a key is not measured, so a 0 here means none observed, not none happened.',
488
+ 'muted',
489
+ ),
490
+ );
491
+ }
492
+ const STATE_WORDS = {
493
+ ok: 'Verified',
494
+ verified_zero: 'Verified zero',
495
+ partial: 'Partial',
496
+ stale: 'Last verified value',
497
+ unavailable: 'Unavailable, the source failed',
498
+ unresolved: 'Unresolved, not collected yet',
499
+ };
500
+ function freshnessTable(parent, fresh) {
501
+ if (!fresh) return;
502
+ const names = {
503
+ paid: 'Paid checkouts (Stripe)',
504
+ subscriptions: 'Active subscriptions (Stripe)',
505
+ checkouts: 'Checkout sessions (Stripe)',
506
+ traffic: 'Site visits (telemetry)',
507
+ leads: 'Signups and leads (ledgers)',
508
+ };
509
+ const rows = Object.entries(names)
510
+ .filter(([key]) => fresh[key])
511
+ .map(([key, name]) => ({
512
+ name,
513
+ observed: when(fresh[key].collectedAt) || 'not collected',
514
+ state: fresh[key].stale ? 'Last verified value, the source did not answer' : 'Current',
515
+ }));
516
+ parent.append(element('h3', 'Source freshness'));
517
+ table(parent, [['Source', (r) => r.name], ['Source observed', (r) => r.observed], ['State', (r) => r.state]], rows);
518
+ parent.append(
519
+ element(
520
+ 'p',
521
+ 'Display refreshed ' + (when(fresh.displayRefreshedAt) || 'just now') +
522
+ (Number.isFinite(fresh.telemetryCacheSeconds) && Number.isFinite(fresh.billingSummaryCacheSeconds)
523
+ ? '. Site visits are cached for ' + fresh.telemetryCacheSeconds + ' seconds and the billing summary for ' + fresh.billingSummaryCacheSeconds / 60 + ' minutes.'
524
+ : '.'),
525
+ 'muted',
526
+ ),
527
+ );
528
+ }
529
+ // One sentence naming the first stage that is stuck, with the numbers that show it and what they cannot show.
530
+ function describeObstacle(fields, funnel) {
531
+ const paying = fields?.['money.paying_customers']?.value;
532
+ const panel = fields?.['money.checkout_bot_check']?.value;
533
+ const since = panel?.sinceBotCheck;
534
+ const stages = funnel?.stageCounts || {};
535
+ const leads = funnel?.uniqueAcquisitionLeads;
536
+ if (!Number.isFinite(paying)) return 'Paying customers could not be read right now, so no obstacle is named without evidence.';
537
+ if (paying > 0) return 'Money is arriving: ' + paying + ' paying customers.';
538
+ const parts = [];
539
+ if (Number.isFinite(leads) && leads > 0 && stages.activation === 0)
540
+ parts.push(leads + ' acquisition leads and 0 measured activations: no lead has made a first API-key call (free local use is not measured).');
541
+ if (since && since.human === 0)
542
+ parts.push('Since the bot check on ' + (panel.botCheckBeganLabel || 'its start date') + ', ' + since.started + ' checkout sessions started and 0 are classified as a browser (' + since.bot + ' bot-classified, ' + since.internal + ' owner or test).');
543
+ else if (since && since.human > 0)
544
+ parts.push(since.human + ' browser-classified checkout sessions since the bot check, and 0 paying customers.');
545
+ return parts.length ? parts.join(' ') : 'There is not enough classified evidence yet to name an obstacle.';
546
+ }
547
+ function metricValue(m) {
548
+ if (!m) return 'Not reported';
549
+ if (m.value === null || m.value === undefined) return m.reason || 'Unavailable';
550
+ if (typeof m.value === 'object') {
551
+ const entries = Object.entries(m.value);
552
+ return entries.length ? entries.map(([c, a]) => money(a, c)).join(', ') : 'None in this window';
553
+ }
554
+ return String(m.value);
555
+ }
556
+ function metricRows(fields, keys) {
557
+ return keys.filter((key) => fields?.[key]).map((key) => {
558
+ const m = fields[key];
559
+ return {
560
+ name: m.label,
561
+ value: metricValue(m),
562
+ state: STATE_WORDS[m.status] || label(m.status),
563
+ observed: when(m.status === 'stale' ? m.lastVerifiedAt : m.collectedAt) || 'not collected',
564
+ };
565
+ });
566
+ }
567
+ // First screen: verified money, measured activation and the biggest evidenced obstacle, read from the same JSON an agent reads.
568
+ function renderOverview(parent, data) {
569
+ const mine = activeLoad;
570
+ const box = element('div');
571
+ parent.append(box);
572
+ box.append(element('p', 'Loading verified money and measured activation…', 'muted'));
573
+ const read = (url) =>
574
+ fetch(url, { credentials: 'same-origin', cache: 'no-store' }).then((r) => (r.ok ? r.json() : null)).catch(() => null);
575
+ Promise.all([read('/v1/admin/summary'), read('/v1/admin/analytics')]).then(([summary, analytics]) => {
576
+ if (mine !== activeLoad) return;
577
+ box.replaceChildren();
578
+ const fields = summary?.data?.fields;
579
+ const funnel = analytics?.data?.funnel;
580
+ box.append(element('h3', 'Verified external money'));
581
+ if (fields)
582
+ table(
583
+ box,
584
+ [['Metric', (r) => r.name], ['Value', (r) => r.value], ['State', (r) => r.state], ['Source observed', (r) => r.observed]],
585
+ metricRows(fields, ['money.paying_customers', 'money.active_pro', 'money.revenue_30d', 'money.subscription_invoices_30d']),
586
+ );
587
+ else box.append(element('p', 'The money summary is unavailable right now. No zero is inferred.', 'notice'));
588
+ box.append(element('h3', 'Measured activation'));
589
+ if (funnel) {
590
+ cards(
591
+ box,
592
+ {
593
+ 'Unique acquisition leads': funnel.uniqueAcquisitionLeads,
594
+ 'Acquisition events': funnel.stageCounts?.acquisition,
595
+ 'Measured activations': funnel.stageCounts?.activation,
596
+ 'Paid customers': funnel.uniquePaidCustomers,
597
+ 'Excluded synthetic checkout sessions': funnel.excludedSyntheticCheckoutSessions,
598
+ },
599
+ true,
600
+ );
601
+ funnelTable(box, funnel);
602
+ } else box.append(element('p', 'The funnel is unavailable right now. No zero is inferred.', 'notice'));
603
+ box.append(element('h3', 'Biggest evidenced obstacle'));
604
+ box.append(element('p', describeObstacle(fields, funnel)));
605
+ if (summary?.data?.freshness)
606
+ box.append(element('p', 'Display refreshed ' + (when(summary.data.freshness.displayRefreshedAt) || 'just now') + '.', 'muted'));
607
+ });
608
+ }
400
609
  function count(v) {
401
610
  return v?.total === null || v?.total === undefined
402
611
  ? 'Unknown'
403
612
  : String(v.total) + (v.complete ? '' : ' (partial)');
404
613
  }
614
+ // Observability tab: plain sentences, times in the owner's own clock, every number labelled or explained.
615
+ function when(value) {
616
+ const d = new Date(value);
617
+ if (!value || Number.isNaN(d.getTime())) return null;
618
+ const clock = { hour: 'numeric', minute: '2-digit', hour12: true };
619
+ const sameDay = d.toDateString() === new Date().toDateString();
620
+ return sameDay
621
+ ? d.toLocaleTimeString([], clock)
622
+ : d.toLocaleString([], { month: 'short', day: 'numeric', ...clock });
623
+ }
624
+ function spanWords(seconds) {
625
+ const unit = (n, word) => n + ' ' + word + (n === 1 ? '' : 's');
626
+ if (seconds < 60) return 'under a minute';
627
+ if (seconds < 3600) return unit(Math.floor(seconds / 60), 'minute');
628
+ if (seconds < 86400) {
629
+ const h = Math.floor(seconds / 3600);
630
+ const m = Math.floor((seconds % 3600) / 60);
631
+ return unit(h, 'hour') + (m ? ' ' + unit(m, 'minute') : '');
632
+ }
633
+ const d = Math.floor(seconds / 86400);
634
+ const h = Math.floor((seconds % 86400) / 3600);
635
+ return unit(d, 'day') + (h ? ' ' + unit(h, 'hour') : '');
636
+ }
637
+ function renderObservability(parent, data) {
638
+ const r = data && data.report;
639
+ if (!r) {
640
+ parent.append(
641
+ element('p', 'This server did not send an observability report.', 'empty'),
642
+ );
643
+ return;
644
+ }
645
+ const block = (title) => {
646
+ const box = element('div', undefined, 'block');
647
+ box.append(element('h3', title));
648
+ parent.append(box);
649
+ return box;
650
+ };
651
+ const note = (box, words) => box.append(element('p', words, 'muted'));
652
+ const facts = (box, values) => cards(box, values, true);
653
+ const since = (stamp) => (when(stamp) ? ' since ' + when(stamp) : '');
654
+ parent.append(element('p', r.headline.sentence, 'banner ' + r.headline.level));
655
+
656
+ const running = block('Running');
657
+ if (r.runningFor.seconds === null) note(running, r.runningFor.reason);
658
+ else
659
+ running.append(
660
+ element(
661
+ 'p',
662
+ 'Running for ' + spanWords(r.runningFor.seconds) + since(r.runningFor.since) + '.',
663
+ ),
664
+ );
665
+
666
+ const up = block('Uptime');
667
+ if (r.uptime.percent === null) {
668
+ note(up, r.uptime.reason + (r.uptime.since ? ' Heartbeat started' + since(r.uptime.since) + '.' : ''));
669
+ } else {
670
+ facts(up, { ['Up during the observed period, ' + periodWords(r.uptime.observedDays)]: r.uptime.percent + '%' });
671
+ note(up, 'Measured over ' + r.uptime.observedDays + ' days' + since(r.uptime.since) + ', from the ' + r.uptime.source + '.');
672
+ if (r.uptime.lastOutage)
673
+ facts(up, {
674
+ 'Last outage': when(r.uptime.lastOutage.startedAt) + ', for ' + spanWords(r.uptime.lastOutage.minutes * 60),
675
+ });
676
+ else note(up, 'No outage recorded since measuring began.');
677
+ }
678
+
679
+ const errs = block('Errors');
680
+ if (r.errors.reason) note(errs, r.errors.reason);
681
+ else {
682
+ facts(errs, {
683
+ 'Errors in the last hour': r.errors.lastHour,
684
+ 'Errors in the last 24 hours': r.errors.last24Hours,
685
+ });
686
+ note(errs, 'Counted' + since(r.errors.since) + ', from the ' + r.errors.source + '.');
687
+ table(
688
+ errs,
689
+ [
690
+ ['What went wrong', (e) => e.what + (e.status ? ' (HTTP ' + e.status + ')' : '')],
691
+ ['Times in 24 hours', (e) => e.count],
692
+ ['Last seen', (e) => when(e.lastSeenAt) || 'time not recorded'],
693
+ ],
694
+ r.errors.top,
695
+ );
696
+ }
697
+
698
+ const speed = block('Speed');
699
+ if (r.speed.reason) note(speed, r.speed.reason);
700
+ else {
701
+ table(
702
+ speed,
703
+ [
704
+ ['Area', (g) => g.name],
705
+ ['Typical response', (g) => g.typicalMs + ' ms'],
706
+ ['Slowest 5% of responses', (g) => g.slowestFivePercentMs + ' ms'],
707
+ ['Requests measured', (g) => g.samples],
708
+ ],
709
+ r.speed.groups,
710
+ );
711
+ note(speed, 'Measured' + since(r.speed.since) + ' by this server; the numbers restart at each deploy.');
712
+ }
713
+
714
+ const deploy = block('Last deploy');
715
+ const deployLine = element('p');
716
+ const deployWhen = when(r.lastDeploy.startedAt);
717
+ deployLine.append(
718
+ document.createTextNode(
719
+ (deployWhen ? 'Deployed ' + deployWhen : 'Deploy time not reported') +
720
+ (r.lastDeploy.commitTitle ? ': ' + r.lastDeploy.commitTitle + ' ' : '. '),
721
+ ),
722
+ );
723
+ if (r.lastDeploy.shortSha) {
724
+ const link = element('a', r.lastDeploy.shortSha);
725
+ if (r.lastDeploy.commitUrl) {
726
+ link.href = r.lastDeploy.commitUrl;
727
+ link.rel = 'noopener noreferrer';
728
+ link.target = '_blank';
729
+ }
730
+ deployLine.append(link);
731
+ }
732
+ deploy.append(deployLine);
733
+ if (r.lastDeploy.reason) note(deploy, r.lastDeploy.reason);
734
+
735
+ const pay = block('Payments plumbing');
736
+ if (r.webhooks.failures24h !== null)
737
+ facts(pay, { 'Failed Stripe notifications in 24 hours': r.webhooks.failures24h });
738
+ if (r.webhooks.lastArrivedAt)
739
+ facts(pay, { 'Last Stripe notification arrived': when(r.webhooks.lastArrivedAt) });
740
+ if (r.webhooks.reason) note(pay, r.webhooks.reason);
741
+
742
+ const sign = block('Sign-in');
743
+ if (r.signIn.reason) note(sign, r.signIn.reason);
744
+ else {
745
+ facts(sign, { 'Failed sign-ins in 24 hours': r.signIn.failed24h });
746
+ if (r.signIn.reasons.length)
747
+ note(
748
+ sign,
749
+ 'Most common: ' + r.signIn.reasons.map((x) => x.words + ' (' + x.count + ')').join('; ') + '.',
750
+ );
751
+ }
752
+
753
+ const disk = block('Disk');
754
+ if (r.disk.reason) note(disk, r.disk.reason);
755
+ else
756
+ facts(disk, {
757
+ 'Data disk': r.disk.usedGb + ' GB of ' + r.disk.capacityGb + ' GB used (' + r.disk.percent + '%)',
758
+ });
759
+ }
405
760
  function render(parent, section, data) {
761
+ if (section === 'money') {
762
+ const checkouts = data.checkouts7d;
763
+ const traffic = data.traffic30d;
764
+ const why = data.reasons || {};
765
+ // A card never shows a bare "Unknown": a missing number shows the reason the source gave.
766
+ const shown = (value, reason, suffix = '') =>
767
+ value === null || value === undefined
768
+ ? reason || 'Source not available right now'
769
+ : String(value) + suffix;
770
+ cards(
771
+ parent,
772
+ {
773
+ 'Paying customers': shown(data.payingCustomers, why.payingCustomers, ' · from Stripe'),
774
+ 'Active Pro subscriptions': shown(data.activePro, why.activePro, ' · from Stripe'),
775
+ 'Checkouts started (7 days)': shown(checkouts ? checkouts.started : null, why.checkouts),
776
+ 'Observed visitor identifiers, excluding bot, internal and test (30 days)': shown(traffic ? traffic.realVisitors : null, why.visitors),
777
+ 'All observed visitor identifiers (30 days)': shown(traffic ? traffic.visitors : null, why.visitors),
778
+ 'Landing page views (30 days)': shown(traffic ? traffic.pageViews : null, why.visitors),
779
+ 'Checkout starts seen on the site (30 days)': shown(traffic ? traffic.checkoutStarts : null, why.visitors),
780
+ },
781
+ true,
782
+ );
783
+ parent.append(element('h3', 'Checkout sessions · past 30 days'));
784
+ const panel = data.checkoutBotCheck;
785
+ if (!panel) parent.append(element('p', why.checkouts || 'Source not available right now', 'notice'));
786
+ else {
787
+ const since = panel.sinceBotCheck;
788
+ cards(
789
+ parent,
790
+ {
791
+ 'Sessions with insufficient classification evidence (30 days)': String(panel.notClassified),
792
+ 'Browser-classified checkout sessions since the bot check': String(since.human),
793
+ 'Bot-classified checkout sessions since the bot check': String(since.bot),
794
+ 'Owner and test since the bot check': String(since.internal),
795
+ },
796
+ true,
797
+ );
798
+ const first = panel.firstClassifiedAt ? when(panel.firstClassifiedAt) : null;
799
+ parent.append(
800
+ element(
801
+ 'p',
802
+ 'The bot check began ' +
803
+ panel.botCheckBeganLabel +
804
+ '. Sessions created before it carry no classification, so they cannot be called browser or bot. A browser-classified session means the click came from a browser user agent; it is not proof of a person. ' +
805
+ (first ? 'The first session with a bot check result was created ' + first + '. ' : 'No session has a bot check result yet. ') +
806
+ since.started +
807
+ ' sessions were created since the bot check began.',
808
+ 'muted',
809
+ ),
810
+ );
811
+ const gap = panel.siteVersusStripe;
812
+ if (gap) {
813
+ parent.append(
814
+ element(
815
+ 'p',
816
+ 'Checkout starts seen on the site (' + gap.siteStarts + ') against checkout sessions in Stripe (' + gap.stripeSessions + '): difference ' + gap.difference + '. ' + gap.reason,
817
+ 'muted',
818
+ ),
819
+ );
820
+ detail(parent, 'Site checkout starts by kind', gap.siteStartsByType, SITE_START_WORDS);
821
+ }
822
+ }
823
+ parent.append(element('h3', 'One-time checkout revenue · past 30 days'));
824
+ if (data.revenueLast30Days === null || data.revenueLast30Days === undefined)
825
+ parent.append(element('p', why.revenue || 'Source not available right now', 'notice'));
826
+ else
827
+ table(
828
+ parent,
829
+ [
830
+ ['Currency', (r) => r.currency],
831
+ ['Checkout revenue after refunds', (r) => money(r.amount, r.currency)],
832
+ ],
833
+ Object.entries(data.revenueLast30Days).map(
834
+ ([currency, amount]) => ({ currency, amount }),
835
+ ),
836
+ );
837
+ parent.append(
838
+ element(
839
+ 'p',
840
+ 'Paying customers: ' +
841
+ basis(data.payingCustomersBasis) +
842
+ '. Active Pro: ' +
843
+ basis(data.activeProBasis) +
844
+ '. Revenue is the total of completed Checkout Sessions created in the last 30 days, after refunds. ' +
845
+ 'Subscription renewal invoices are not read, so recurring revenue is not included: subscription invoices are not collected yet.',
846
+ 'muted',
847
+ ),
848
+ );
849
+ freshnessTable(parent, data.freshness);
850
+ if (data.checkouts7d) detail(parent, 'Checkout sessions, last 7 days', data.checkouts7d, CHECKOUT_WORDS);
851
+ if (data.checkouts30d) detail(parent, 'Checkout sessions, last 30 days', data.checkouts30d, CHECKOUT_WORDS);
852
+ const leads = data.leadsBySource;
853
+ if (leads) {
854
+ detail(parent, 'Signups by source', leads.signups);
855
+ detail(parent, 'Setup Sprint leads by source', leads.workflowSprint?.bySource);
856
+ detail(parent, 'Newsletter by source', leads.newsletter?.bySource);
857
+ } else {
858
+ parent.append(element('p', 'Signups and leads: ' + (why.leads || 'source not available right now'), 'notice'));
859
+ }
860
+ for (const note of data.notes || [])
861
+ parent.append(element('p', note, 'muted'));
862
+ }
406
863
  if (section === 'overview') {
407
- cards(parent, {
864
+ renderOverview(parent, data);
865
+ detail(parent, 'Build and runtime', {
408
866
  version: data.health?.version,
409
867
  build: data.health?.buildSha,
410
- uptimeSeconds: Math.floor(data.health?.uptime || 0),
868
+ runningFor: spanWords(Math.floor(data.health?.uptime || 0)),
411
869
  });
412
870
  parent.append(
413
871
  element(
414
872
  'p',
415
- 'Select a section to load its current source. Stripe resources are fetched one page at a time.',
873
+ 'This console is read-only. The same numbers are available as JSON at /v1/admin/summary. Select a section to load its current source; Stripe resources are fetched one page at a time.',
416
874
  'muted',
417
875
  ),
418
876
  );
@@ -552,12 +1010,74 @@
552
1010
  }
553
1011
  if (section === 'analytics') {
554
1012
  const external = data.revenue?.external || {};
555
- cards(parent, {
556
- visitors: data.trafficMetrics?.visitors,
557
- checkoutStarts: data.trafficMetrics?.checkoutStarts,
558
- emailSignups: data.signups?.emailSignups,
559
- externalPaidOrders: external.paidOrders,
560
- });
1013
+ const traffic = data.trafficMetrics;
1014
+ const waiting = 'Billing totals still calculating, refresh in a minute';
1015
+ const shown = (value, fallback) =>
1016
+ value === null || value === undefined ? fallback : String(value);
1017
+ cards(
1018
+ parent,
1019
+ {
1020
+ 'Observed visitor identifiers, excluding bot, internal and test (30 days)': shown(traffic?.realVisitors, 'Telemetry store empty'),
1021
+ 'All observed visitor identifiers (30 days)': shown(traffic?.visitors, 'Telemetry store empty'),
1022
+ 'Landing page views (30 days)': shown(traffic?.pageViews, 'Telemetry store empty'),
1023
+ 'Call to action clicks (30 days)': shown(traffic?.ctaClicks, 'Telemetry store empty'),
1024
+ 'Checkout starts (30 days)': shown(traffic?.checkoutStarts, 'Telemetry store empty'),
1025
+ 'Paid confirmations (30 days)': shown(traffic?.checkoutPaidConfirmations, 'Telemetry store empty'),
1026
+ 'Email signups': shown(data.signups?.emailSignups, waiting),
1027
+ 'External paid orders': shown(external.paidOrders, waiting),
1028
+ },
1029
+ true,
1030
+ );
1031
+ parent.append(
1032
+ element(
1033
+ 'p',
1034
+ 'A visitor identifier is counted once from any site event (a click, a checkout step, a page view), while landing page views count page-view events only, so identifiers can exceed page views. ' +
1035
+ (traffic && Number.isFinite(traffic.pageViewers)
1036
+ ? traffic.pageViewers + ' of the identifiers viewed a landing page.'
1037
+ : ''),
1038
+ 'muted',
1039
+ ),
1040
+ );
1041
+ if (Array.isArray(data.daily) && data.daily.length) {
1042
+ parent.append(element('h3', 'Visitors per day · past 30 days'));
1043
+ const peak = Math.max(1, ...data.daily.map((d) => d.visitors));
1044
+ const width = 600;
1045
+ const height = 120;
1046
+ const step = width / data.daily.length;
1047
+ const ns = 'http://www.w3.org/2000/svg';
1048
+ const chart = document.createElementNS(ns, 'svg');
1049
+ chart.setAttribute('viewBox', '0 0 ' + width + ' ' + height);
1050
+ chart.setAttribute('role', 'img');
1051
+ chart.setAttribute('aria-label', 'Visitors per day for the past 30 days');
1052
+ chart.style.width = '100%';
1053
+ chart.style.maxHeight = '160px';
1054
+ data.daily.forEach((d, i) => {
1055
+ const bar = document.createElementNS(ns, 'rect');
1056
+ const h = Math.max(1, Math.round((d.visitors / peak) * (height - 4)));
1057
+ bar.setAttribute('x', String(i * step + 1));
1058
+ bar.setAttribute('y', String(height - h));
1059
+ bar.setAttribute('width', String(Math.max(1, step - 2)));
1060
+ bar.setAttribute('height', String(h));
1061
+ bar.setAttribute('fill', 'currentColor');
1062
+ const tip = document.createElementNS(ns, 'title');
1063
+ tip.textContent = d.date + ': ' + d.visitors + ' visitors, ' + d.pageViews + ' page views';
1064
+ bar.append(tip);
1065
+ chart.append(bar);
1066
+ });
1067
+ parent.append(chart);
1068
+ table(
1069
+ parent,
1070
+ [
1071
+ ['Day', (r) => r.date],
1072
+ ['Visitors', (r) => r.visitors],
1073
+ ['Page views', (r) => r.pageViews],
1074
+ ['Call to action clicks', (r) => r.ctaClicks],
1075
+ ['Checkout starts', (r) => r.checkoutStarts],
1076
+ ['Paid confirmations', (r) => r.checkoutPaidConfirmations],
1077
+ ],
1078
+ [...data.daily].reverse(),
1079
+ );
1080
+ }
561
1081
  parent.append(
562
1082
  element('h3', 'External booked revenue · past 30 days'),
563
1083
  );
@@ -578,6 +1098,7 @@
578
1098
  'muted',
579
1099
  ),
580
1100
  );
1101
+ funnelTable(parent, data.funnel);
581
1102
  for (const key of [
582
1103
  'funnel',
583
1104
  'signups',
@@ -589,7 +1110,7 @@
589
1110
  detail(parent, label(key), data[key]);
590
1111
  detail(
591
1112
  parent,
592
- 'Internal, test and unknown exclusions',
1113
+ 'Internal, test and unidentified exclusions',
593
1114
  external.excluded,
594
1115
  );
595
1116
  detail(
@@ -599,34 +1120,7 @@
599
1120
  );
600
1121
  }
601
1122
  if (section === 'observability') {
602
- cards(parent, {
603
- version: data.version,
604
- build: data.buildSha,
605
- uptimeSeconds: Math.floor(data.uptime || 0),
606
- persistedTelemetryLastMinute: data.telemetry?.events,
607
- });
608
- parent.append(
609
- element(
610
- 'p',
611
- 'Telemetry observed for ' +
612
- (data.telemetry?.windowSeconds ?? 0) +
613
- ' seconds; one-second precision. Process start ' +
614
- date(data.processStartedAt) +
615
- '. Deployment time unavailable. Error retention resets on restart.',
616
- 'muted',
617
- ),
618
- );
619
- detail(parent, 'Deployment identity', data.deployment);
620
- detail(parent, 'Volume filesystem bytes', data.disk);
621
- table(
622
- parent,
623
- [
624
- ['Time', (r) => date(r.timestamp)],
625
- ['Status', (r) => r.status],
626
- ['Route category', (r) => r.route],
627
- ],
628
- data.recentErrors || [],
629
- );
1123
+ renderObservability(parent, data);
630
1124
  }
631
1125
  }
632
1126
  function controls() {
@@ -706,7 +1200,9 @@
706
1200
  if (request !== activeLoad) return;
707
1201
  if (!response.ok)
708
1202
  throw new Error(
709
- response.status === 404
1203
+ response.status === 403
1204
+ ? 'This account is not on the owner list.'
1205
+ : response.status === 404
710
1206
  ? 'This page is unavailable. Sign in through the usual ThumbGate login and try again.'
711
1207
  : response.status === 429
712
1208
  ? 'Another collection is running. Try again shortly.'
@@ -757,12 +1253,12 @@
757
1253
  loading.className = 'notice';
758
1254
  }
759
1255
  }
760
- document.getElementById('logout').addEventListener('click', async () => {
761
- const response = await fetch('/v1/auth/session', {
762
- method: 'DELETE',
763
- credentials: 'same-origin',
764
- });
765
- if (response.ok) location.assign('/');
1256
+ document.getElementById('logout').addEventListener('click', () => {
1257
+ const form = document.createElement('form');
1258
+ form.method = 'POST';
1259
+ form.action = '/logout';
1260
+ document.body.append(form);
1261
+ form.submit();
766
1262
  });
767
1263
  controls();
768
1264
  load();