@koda-sl/baker-cli 0.845.0 → 0.847.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.
Files changed (42) hide show
  1. package/README.md +1 -0
  2. package/dist/{ads-ZPBENENM.js → ads-2SBIPZJI.js} +3 -3
  3. package/dist/{analytics-5QZJQI6Z.js → analytics-MZ5A66JO.js} +56 -22
  4. package/dist/analytics-MZ5A66JO.js.map +1 -0
  5. package/dist/{chunk-NRA7TZV7.js → chunk-37NXS55Q.js} +2 -2
  6. package/dist/{chunk-2DVR6MUZ.js → chunk-HORX3JLB.js} +2 -2
  7. package/dist/{chunk-NT5X44IL.js → chunk-OQQN2UJS.js} +3 -3
  8. package/dist/{chunk-NT5X44IL.js.map → chunk-OQQN2UJS.js.map} +1 -1
  9. package/dist/{chunk-2GXFGP4M.js → chunk-SCK7U53A.js} +3 -3
  10. package/dist/{chunk-LKTBIO3F.js → chunk-STWMK24H.js} +2 -2
  11. package/dist/{chunk-PC37FCEC.js → chunk-T7GAC2WG.js} +78 -6
  12. package/dist/chunk-T7GAC2WG.js.map +1 -0
  13. package/dist/cli.js +3 -3
  14. package/dist/{funnel-QCRI5TPO.js → funnel-YR3ROIPN.js} +3 -3
  15. package/dist/{google-IOBFFSRM.js → google-BFBRJRZP.js} +2 -2
  16. package/dist/{lookup-4W7ERA4E.js → lookup-IAY43D6F.js} +4 -4
  17. package/dist/{performance-YM2U4GMU.js → performance-GIUF4NDE.js} +2 -2
  18. package/dist/{plan-VHLLCF4R.js → plan-LVTD6FZI.js} +3 -3
  19. package/dist/{questionnaire-47DIYMVE.js → questionnaire-7Y4QYVC6.js} +3 -3
  20. package/dist/{sends-JPPZJUBN.js → sends-TCVUTCLV.js} +66 -16
  21. package/dist/sends-TCVUTCLV.js.map +1 -0
  22. package/dist/{sources-Y75YRCNZ.js → sources-RA2KD7VO.js} +4 -4
  23. package/dist/{unstage-K7RYZLA2.js → unstage-6QVKZITE.js} +3 -3
  24. package/dist/{url-options-6ATRBK73.js → url-options-E6FNFBE3.js} +2 -2
  25. package/package.json +1 -1
  26. package/dist/analytics-5QZJQI6Z.js.map +0 -1
  27. package/dist/chunk-PC37FCEC.js.map +0 -1
  28. package/dist/sends-JPPZJUBN.js.map +0 -1
  29. /package/dist/{ads-ZPBENENM.js.map → ads-2SBIPZJI.js.map} +0 -0
  30. /package/dist/{chunk-NRA7TZV7.js.map → chunk-37NXS55Q.js.map} +0 -0
  31. /package/dist/{chunk-2DVR6MUZ.js.map → chunk-HORX3JLB.js.map} +0 -0
  32. /package/dist/{chunk-2GXFGP4M.js.map → chunk-SCK7U53A.js.map} +0 -0
  33. /package/dist/{chunk-LKTBIO3F.js.map → chunk-STWMK24H.js.map} +0 -0
  34. /package/dist/{funnel-QCRI5TPO.js.map → funnel-YR3ROIPN.js.map} +0 -0
  35. /package/dist/{google-IOBFFSRM.js.map → google-BFBRJRZP.js.map} +0 -0
  36. /package/dist/{lookup-4W7ERA4E.js.map → lookup-IAY43D6F.js.map} +0 -0
  37. /package/dist/{performance-YM2U4GMU.js.map → performance-GIUF4NDE.js.map} +0 -0
  38. /package/dist/{plan-VHLLCF4R.js.map → plan-LVTD6FZI.js.map} +0 -0
  39. /package/dist/{questionnaire-47DIYMVE.js.map → questionnaire-7Y4QYVC6.js.map} +0 -0
  40. /package/dist/{sources-Y75YRCNZ.js.map → sources-RA2KD7VO.js.map} +0 -0
  41. /package/dist/{unstage-K7RYZLA2.js.map → unstage-6QVKZITE.js.map} +0 -0
  42. /package/dist/{url-options-6ATRBK73.js.map → url-options-E6FNFBE3.js.map} +0 -0
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-GRQ2AXDX.js";
5
5
  import {
6
6
  EVENT_ITEMS_MAX
7
- } from "./chunk-PC37FCEC.js";
7
+ } from "./chunk-T7GAC2WG.js";
8
8
  import {
9
9
  EVENT_INGEST_BATCH_MAX,
10
10
  EVENT_INGEST_BODY_MAX_BYTES,
@@ -476,4 +476,4 @@ export {
476
476
  eventIngestUrl,
477
477
  ingestBrief
478
478
  };
479
- //# sourceMappingURL=chunk-NRA7TZV7.js.map
479
+ //# sourceMappingURL=chunk-37NXS55Q.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  CONVERSION_COUNT_MODES,
3
3
  findNameCollision
4
- } from "./chunk-PC37FCEC.js";
4
+ } from "./chunk-T7GAC2WG.js";
5
5
  import {
6
6
  CHECKOUT_RECORD_REFUSAL,
7
7
  isCheckoutRecordKey,
@@ -182,4 +182,4 @@ export {
182
182
  parseConversionsArgs,
183
183
  conversionsWrite
184
184
  };
185
- //# sourceMappingURL=chunk-2DVR6MUZ.js.map
185
+ //# sourceMappingURL=chunk-HORX3JLB.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  EVENT_PROPERTY_WITHHELD,
3
3
  analyticsTimelineRowSchema
4
- } from "./chunk-PC37FCEC.js";
4
+ } from "./chunk-T7GAC2WG.js";
5
5
  import {
6
6
  formEventKey
7
7
  } from "./chunk-KLO3TPTS.js";
@@ -261,7 +261,7 @@ function withheldBreakdownHint(data, asked) {
261
261
  const events = isPlainRow(row) && typeof row.events === "number" ? row.events : 0;
262
262
  if (events === 0) return [];
263
263
  return [
264
- `${events} ${asked.eventName} events are "${EVENT_PROPERTY_WITHHELD}": recorded from visitors who declined analytics consent (or while the site measures in aggregate), so they carry no visit and none of the page's own properties. They are real and count in every total; only their ${asked.property} is unknown. Report them as ${events} without consent, ${asked.property} unknown \u2014 not as a tracking fault, and not by reading the feed, which holds nothing more about them.`
264
+ `${events} ${asked.eventName} events are "${EVENT_PROPERTY_WITHHELD}": recorded from visitors who declined analytics consent (or while the site measures in aggregate), so they carry no visit of their own and none of the page's own properties: their visits are estimated (\`estimatedSessions\`). They are real and count in every total; only their ${asked.property} is unknown. Report them as ${events} without consent, ${asked.property} unknown \u2014 not as a tracking fault, and not by reading the feed, which holds nothing more about them.`
265
265
  ];
266
266
  }
267
267
  function narrowToBreakdown(data, asked, full) {
@@ -371,4 +371,4 @@ export {
371
371
  serverFeedFields,
372
372
  keepFeedFields
373
373
  };
374
- //# sourceMappingURL=chunk-NT5X44IL.js.map
374
+ //# sourceMappingURL=chunk-OQQN2UJS.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../api/src/analytics/flowEventKeys.ts","../src/commands/analytics/render.ts","../src/commands/analytics/fields.ts"],"sourcesContent":["/**\n * Every event a Form's own steps raise, built from the Form's tree.\n *\n * A Form published by Baker emits its events natively: every step raises the\n * triggers its node type has, and the Form raises `submit:<slug>` when it runs\n * out of steps. Nothing has to be registered for that to happen — no Source, no\n * conversion, no setting. But the lists a person or an agent PICKS an event\n * from are built from the event store, which knows an event only after somebody\n * has fired it. So a Form published five minutes ago offered nothing to pick,\n * and the only affordances left on the picker were \"type the name by hand\" and\n * \"add a Source\" — a door for a company's own systems, offered for an event a\n * Baker page already sends. Both of those are how a funnel step ends up wired\n * to a key that counts zero forever.\n *\n * This is the other half: the keys derived from the tree, offered at zero,\n * exactly as a Source is offered before its first send. Same builder\n * (`formEventKey`), same trigger table (`flowNodeTriggers`), so a key from here\n * and a key from the SQL are the same string.\n */\n\nimport { flowNodeTriggers } from \"../flowCatalog\";\nimport { formEventKey } from \"./eventKey\";\n\ntype AnyRecord = Record<string, unknown>;\n\nexport interface FlowEventKey {\n eventKey: string;\n /** `null` for the Form-level `submit:` key, which belongs to no step. */\n nodeId: string | null;\n nodeName: string;\n nodeType: string | null;\n triggerId: string | null;\n /** Whether this is the moment that step exists to produce. */\n isCompletion: boolean;\n}\n\n/** Every node of a Form tree, parents before children. */\nexport function flowNodes(node: unknown, acc: AnyRecord[] = []): AnyRecord[] {\n if (!node || typeof node !== \"object\") return acc;\n const record = node as AnyRecord;\n acc.push(record);\n if (Array.isArray(record.children)) for (const child of record.children) flowNodes(child, acc);\n return acc;\n}\n\n/**\n * Every event key this Form can produce, each step's completion first.\n *\n * Completion triggers lead because they are what a person means by \"reached\n * this step\"; the lifecycle triggers a widget also raises (\"the embedded form\n * finished loading\") follow rather than being hidden, since an embedded\n * checkout genuinely reports through one of them. The order says nothing about\n * which ending is the Form's outcome — that is the agent's call.\n */\nexport function flowEventKeys(tree: unknown, slug: string): FlowEventKey[] {\n const primary: FlowEventKey[] = [];\n const secondary: FlowEventKey[] = [];\n\n // A tree with no identified step raises nothing, and `submit:<slug>` for it\n // would be the very thing this file exists to prevent: a real-looking key\n // that counts zero for ever. It happens — a `_data.json` holding `null` or\n // `{}`, a folder a flow-builder loop created and has not finished writing.\n const nodes = flowNodes(tree).filter((node) => typeof node.id === \"string\" && node.id !== \"\");\n if (nodes.length === 0) return [];\n\n for (const node of nodes) {\n const id = node.id as string;\n const triggers = flowNodeTriggers(node.nodeData);\n for (const triggerId of triggers.available) {\n const candidate: FlowEventKey = {\n eventKey: formEventKey(slug, id, triggerId),\n nodeId: id,\n nodeName: typeof node.name === \"string\" ? node.name : id,\n nodeType: triggers.type,\n triggerId,\n isCompletion: triggers.completion === triggerId,\n };\n (candidate.isCompletion ? primary : secondary).push(candidate);\n }\n }\n\n return [\n ...primary,\n ...secondary,\n {\n eventKey: `submit:${slug}`,\n nodeId: null,\n nodeName: \"the Form ran out of steps\",\n nodeType: null,\n triggerId: null,\n // A Form reaching its last node is as primary as an outcome gets for a\n // Form with no widget in it — but it never fires on one that ends in a\n // booking widget or a redirect, so it does not lead the list.\n isCompletion: false,\n },\n ];\n}\n","/**\n * What the agent reads, as opposed to what the wire carries.\n *\n * The dashboard and the sandbox agent read the same `/api/analytics/query`\n * response and want different things out of it. A browser wants every field of\n * every row plus a sparkline it can draw; an agent pays for all of that in\n * context and cannot draw anything.\n *\n * Measured against the wire schema on a 40-landing site: `landings` came back\n * as ~11.5k tokens of pretty-printed JSON, a third of it indentation and half\n * of it sparkline. `landings --days 90 --granularity hour` came back as ~353k\n * tokens — the sparkline is bucketed by `--granularity`, so ninety days of\n * hours is 2,160 numbers per page — which is larger than the window it has to\n * fit inside. Nothing capped it and nothing warned about it.\n *\n * So the shaping happens here rather than in the endpoint: the wire keeps its\n * contract, the dashboard keeps its fields, and the agent gets the same answer\n * at roughly a tenth of the cost.\n */\n\nimport { type AnalyticsProjectedQueryData, EVENT_PROPERTY_WITHHELD } from \"@baker/api/analytics\";\n\n/**\n * How many points of a sparkline survive `--full`.\n *\n * A sparkline exists to carry a shape, and a shape survives resampling — thirty\n * points still say \"it collapsed in the third week\". The per-bucket counts are\n * not lost: `traffic --landing <id> --granularity hour` is the report that\n * answers at that resolution, and it answers for one page rather than for all\n * of them at once.\n */\nconst SPARKLINE_POINTS = 30;\n\n/** Fields no agent can act on, dropped before anything else is measured. */\nconst DASHBOARD_ONLY_FIELDS = new Set([\n // The Convex row id. It exists so a dashboard can link to the row; an agent\n // addresses a landing by `landingId`, which is the id in its `_definition.md`.\n \"landingRef\",\n]);\n\n/**\n * Blocks that are lists of things rather than breakdowns.\n *\n * Only these are paged, and only these are worth saying \"there are more\" about.\n */\nexport const ANALYTICS_LIST_BLOCKS = [\"deliveries\", \"submissions\", \"visitors\", \"timeline\", \"stream\"] as const;\n\n/**\n * A value carrying nothing a missing key would not carry.\n *\n * `null` is deliberately not in here. Every rate in this response is `null`\n * rather than `0` when it has no denominator, and the docs tell the agent to\n * read the two apart — so `null` is an answer and `\"\"` is an absence.\n * `0` and `false` are answers too.\n */\nfunction isAbsent(value: unknown): boolean {\n if (value === \"\") return true;\n if (Array.isArray(value)) return value.length === 0;\n if (typeof value === \"object\" && value !== null) return Object.keys(value).length === 0;\n return false;\n}\n\n/**\n * A series resampled to at most `points`, by summing into equal buckets.\n *\n * Summing rather than sampling every nth point: these are counts, and dropping\n * four hours in five understates a day by four fifths while still drawing a\n * plausible line. A resampled series totals what the original totalled.\n */\nexport function resample(series: readonly number[], points: number): number[] {\n if (series.length <= points || points < 1) return [...series];\n const out: number[] = [];\n for (let i = 0; i < points; i += 1) {\n const from = Math.floor((i * series.length) / points);\n const to = Math.floor(((i + 1) * series.length) / points);\n let sum = 0;\n for (let j = from; j < to; j += 1) sum += series[j] ?? 0;\n out.push(sum);\n }\n return out;\n}\n\nfunction pruneValue(value: unknown, full: boolean): unknown {\n if (Array.isArray(value)) return value.map((entry) => pruneValue(entry, full));\n if (typeof value === \"object\" && value !== null) {\n return pruneRow(value as Record<string, unknown>, full);\n }\n return value;\n}\n\n/** One row with its absent fields and its dashboard-only fields removed. */\nfunction pruneRow(row: Record<string, unknown>, full: boolean): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(row)) {\n if (DASHBOARD_ONLY_FIELDS.has(key)) continue;\n if (key === \"sparkline\" && Array.isArray(value)) {\n // Dropped outright unless asked for: it is the one field here that is a\n // picture rather than a fact, and it is also the largest.\n if (!full) continue;\n out[key] = resample(value as number[], SPARKLINE_POINTS);\n continue;\n }\n if (isAbsent(value)) continue;\n out[key] = pruneValue(value, full);\n }\n return out;\n}\n\n/**\n * The response an agent should be handed.\n *\n * Per-row rather than per-column pruning, because the saving is in the rows\n * that differ: a replay row carries thirty-five fields of which a page view\n * fills eight, and dropping a column only when it is empty in *every* row would\n * keep all thirty-five on every one of them.\n */\nexport function pruneForAgent(data: AnalyticsProjectedQueryData, full: boolean): Record<string, unknown> {\n const pruned = pruneRow(data as unknown as Record<string, unknown>, full);\n // The one empty list kept: the list the report pages. Pruned, a failures-only\n // `delivery` with no failures read exactly like a report that left the block\n // out, and agents pulled every submission with --full to tell them apart.\n const paged = data.pageInfo?.block;\n if (paged !== undefined && Array.isArray(data[paged]) && !(paged in pruned)) pruned[paged] = [];\n return pruned;\n}\n\n// ---------------------------------------------------------------------------\n// Rendering\n// ---------------------------------------------------------------------------\n\n/** A row that can be a table line: every value is a scalar or a flat list. */\nfunction isTabular(rows: readonly unknown[]): rows is ReadonlyArray<Record<string, unknown>> {\n return rows.every(\n (row) =>\n typeof row === \"object\" &&\n row !== null &&\n !Array.isArray(row) &&\n Object.values(row).every(\n (value) =>\n value === null ||\n typeof value !== \"object\" ||\n (Array.isArray(value) && value.every((e) => typeof e !== \"object\")),\n ),\n );\n}\n\nfunction cell(value: unknown, key?: string): string {\n if (value === null || value === undefined) return \"\";\n if (Array.isArray(value)) return value.join(\" \");\n if (typeof value === \"number\" && !Number.isInteger(value)) {\n // A duration in milliseconds to four decimal places is four digits of\n // noise: nothing downstream is sensitive to a microsecond of dwell time,\n // and every one of them is a character the reader pays for.\n if (key?.endsWith(\"Ms\")) return String(Math.round(value));\n return value.toFixed(4).replace(/0+$/, \"\").replace(/\\.$/, \"\");\n }\n return String(value);\n}\n\n/**\n * Columns that say *which row this is*, before the ones that say how it did.\n *\n * Needed because the keys do not arrive in the order the wire declares them —\n * they come back alphabetised, which buries `landingId` and `name` in the\n * middle of a table and leads with `avgEngagementMs`. A table whose first\n * column is not the subject has to be read twice.\n */\nconst IDENTITY_COLUMNS = [\n \"landingId\",\n \"name\",\n \"slug\",\n \"path\",\n \"flowSlug\",\n \"stepId\",\n \"value\",\n \"key\",\n \"bucket\",\n \"tag\",\n \"eventName\",\n \"release\",\n \"place\",\n \"bot\",\n \"source\",\n \"medium\",\n \"campaign\",\n \"platform\",\n \"sessionId\",\n \"eventId\",\n];\n\nfunction byIdentityFirst(a: string, b: string): number {\n const ia = IDENTITY_COLUMNS.indexOf(a);\n const ib = IDENTITY_COLUMNS.indexOf(b);\n if (ia !== -1 || ib !== -1)\n return (ia === -1 ? Number.MAX_SAFE_INTEGER : ia) - (ib === -1 ? Number.MAX_SAFE_INTEGER : ib);\n return 0;\n}\n\n/**\n * Blocks in the order a report is read: the window it covers, the totals, the\n * rows, and the echo of which preset produced it last of all. An `events`\n * breakdown or funnel leads, because it is what `--event --property` or\n * `--steps` asked for, and a reader cut off by `| head` must still see it.\n */\nconst BLOCK_ORDER = [\"eventBreakdown\", \"customFunnel\", \"window\", \"totals\", \"previous\", \"pageInfo\"];\n\nfunction byBlockOrder(a: string, b: string): number {\n const rank = (key: string) => {\n const at = BLOCK_ORDER.indexOf(key);\n if (at !== -1) return at;\n return key === \"preset\" ? BLOCK_ORDER.length + 1 : BLOCK_ORDER.length;\n };\n return rank(a) - rank(b);\n}\n\n/**\n * Columns, in the order the wire declares them, minus the ones no row filled.\n *\n * Per-column here where the JSON path prunes per-row: a table with a ragged\n * row is not a table, and a column of empty cells costs the header once rather\n * than once per row.\n */\nfunction columnsOf(rows: ReadonlyArray<Record<string, unknown>>): string[] {\n const seen: string[] = [];\n for (const row of rows) {\n for (const key of Object.keys(row)) {\n if (!seen.includes(key)) seen.push(key);\n }\n }\n return seen\n .filter((key) => rows.some((row) => !isAbsent(row[key]) && row[key] !== null && row[key] !== undefined))\n .sort(byIdentityFirst);\n}\n\nfunction table(rows: ReadonlyArray<Record<string, unknown>>): string {\n const cols = columnsOf(rows);\n if (cols.length === 0) return \"\";\n const head = `| ${cols.join(\" | \")} |`;\n const rule = `| ${cols.map(() => \"---\").join(\" | \")} |`;\n const body = rows.map((row) => `| ${cols.map((col) => cell(row[col], col)).join(\" | \")} |`);\n return [head, rule, ...body].join(\"\\n\");\n}\n\n/** A value that is a list of rows, i.e. a sub-table rather than a cell. */\nfunction isRowList(value: unknown): value is Array<Record<string, unknown>> {\n return (\n Array.isArray(value) &&\n value.length > 0 &&\n value.every((entry) => typeof entry === \"object\" && entry !== null && !Array.isArray(entry))\n );\n}\n\n/** Whatever names this row in a heading — its id, its slug, or its position. */\nfunction labelOf(row: Record<string, unknown>, index: number): string {\n for (const key of IDENTITY_COLUMNS) {\n const value = row[key];\n if (typeof value === \"string\" && value !== \"\") return value;\n }\n return `#${index + 1}`;\n}\n\n/**\n * A block whose rows carry nested rows of their own — a funnel and its steps.\n *\n * Rendered as the parent table followed by one sub-table per parent rather than\n * dumped as JSON. The JSON fallback was correct and nearly useless: `funnel`,\n * `flow` and `overview` all nest, they are the three commands most likely to be\n * the *first* call of a turn, and for them `--output md` was saving about 2%.\n */\nfunction nestedBlock(name: string, rows: ReadonlyArray<Record<string, unknown>>): string {\n const parents = rows.map((row) =>\n Object.fromEntries(Object.entries(row).filter(([, value]) => !isRowList(value) && !isPlainRow(value))),\n );\n const parts = [`### ${name}`, table(parents)];\n rows.forEach((row, index) => {\n for (const [key, value] of Object.entries(row)) {\n if (isRowList(value)) parts.push(`#### ${name}[${labelOf(row, index)}].${key}`, table(value));\n else if (isPlainRow(value)) parts.push(`#### ${name}[${labelOf(row, index)}].${key}`, table([value]));\n }\n });\n return parts.filter((part) => part !== \"\").join(\"\\n\");\n}\n\n/** An object that is one row rather than a list — `worstStep`. */\nfunction isPlainRow(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction block(name: string, value: unknown): string {\n if (Array.isArray(value)) {\n if (value.length === 0) return \"\";\n if (isTabular(value)) return `### ${name}\\n${table(value)}`;\n if (isRowList(value)) return nestedBlock(name, value);\n return `### ${name}\\n${JSON.stringify(value)}`;\n }\n if (typeof value === \"object\" && value !== null) {\n const entries = Object.entries(value as Record<string, unknown>);\n if (entries.length === 0) return \"\";\n if (entries.every(([, v]) => v === null || typeof v !== \"object\")) {\n return `### ${name}\\n${entries.map(([k, v]) => `- ${k}: ${v === null ? \"null\" : cell(v, k)}`).join(\"\\n\")}`;\n }\n return `### ${name}\\n${JSON.stringify(value)}`;\n }\n return `### ${name}\\n${cell(value)}`;\n}\n\n/**\n * The whole response as Markdown.\n *\n * A fifth to a half smaller than the compact JSON, because a\n * table names each column once instead of once per row. `warnings` and `hints`\n * lead rather than trail: they are instructions to the reader, and a reader\n * that has already summarised the table below them has acted without them.\n */\nexport function renderMarkdown(envelope: {\n data: Record<string, unknown>;\n warnings?: ReadonlyArray<{ code: string; message: string }>;\n hints?: readonly string[];\n}): string {\n const parts: string[] = [];\n for (const warning of envelope.warnings ?? []) parts.push(`> **${warning.code}** — ${warning.message}`);\n for (const hint of envelope.hints ?? []) parts.push(`> ${hint}`);\n for (const [name, value] of Object.entries(envelope.data).sort(([a], [b]) => byBlockOrder(a, b))) {\n const rendered = block(name, value);\n if (rendered !== \"\") parts.push(rendered);\n }\n return `${parts.join(\"\\n\\n\")}\\n`;\n}\n\n/**\n * An `--event` read that came back empty, said as what was empty.\n *\n * The event list is narrowed to the `--event` asked for, so an absent row\n * means the event had no rows in this window, and a present one with an empty\n * `eventBreakdown` means the `--property` (or `--where`) split it into nothing.\n * Calling the second \"that event does not exist\" — beside a list naming it —\n * is the contradiction BAKER-3379 recorded.\n */\nexport function missingBreakdownHint(\n data: Record<string, unknown>,\n asked: { eventName?: string; property?: string },\n): string[] {\n if (asked.eventName === undefined) return [];\n const listed = Array.isArray(data.customEvents)\n ? data.customEvents.find((row) => isPlainRow(row) && row.eventName === asked.eventName)\n : undefined;\n if (listed === undefined) {\n return [\n `No ${asked.eventName} events in this window. Run \\`baker analytics events\\` without --event for the names these pages send, or widen --days.`,\n ];\n }\n if (asked.property === undefined) return [];\n const breakdown = data.eventBreakdown;\n if (Array.isArray(breakdown) && breakdown.length > 0) return [];\n const keys = Array.isArray(listed.propertyKeys) ? listed.propertyKeys.join(\", \") : \"\";\n return [\n `${asked.eventName} has events in this window, but --property ${asked.property} split them into no rows (with --where, the filter matched none)${keys === \"\" ? \"\" : `. Its property keys: ${keys}`}.`,\n ];\n}\n\n/**\n * What the `(no consent)` row of a breakdown is, said before anyone goes\n * looking for a tracking fault in it.\n *\n * Its events are real and its session count is zero by construction: the\n * collector kept the event and dropped who it was, the page's own properties\n * with it. Unexplained, an agent paged the raw feed seven times and wrote three\n * scripts to find that out (BAKER-3791).\n */\nexport function withheldBreakdownHint(\n data: Record<string, unknown>,\n asked: { eventName?: string; property?: string },\n): string[] {\n if (asked.eventName === undefined || asked.property === undefined || !Array.isArray(data.eventBreakdown)) return [];\n const row = data.eventBreakdown.find((entry) => isPlainRow(entry) && entry.value === EVENT_PROPERTY_WITHHELD);\n const events = isPlainRow(row) && typeof row.events === \"number\" ? row.events : 0;\n if (events === 0) return [];\n return [\n `${events} ${asked.eventName} events are \"${EVENT_PROPERTY_WITHHELD}\": recorded from visitors who declined analytics consent (or while the site measures in aggregate), so they carry no visit and none of the page's own properties. They are real and count in every total; only their ${asked.property} is unknown. Report them as ${events} without consent, ${asked.property} unknown — not as a tracking fault, and not by reading the feed, which holds nothing more about them.`,\n ];\n}\n\n/**\n * `--event X --property Y` without `--full`: the breakdown asked for and the\n * window it covers, nothing site-wide.\n *\n * The totals and the event list answer a different question, and printed\n * beside the breakdown they pushed it past a `| head` and tripled what one\n * read cost (BAKER-2546). `--full` keeps them. Applied after the hints are\n * read, which still need the event list to say whether the event was there.\n */\nexport function narrowToBreakdown(\n data: Record<string, unknown>,\n asked: { eventName?: string; property?: string },\n full: boolean,\n): void {\n if (full || asked.eventName === undefined || asked.property === undefined) return;\n delete data.customEvents;\n delete data.totals;\n delete data.previous;\n}\n\n/**\n * `submissions --by-field` prints the answers and their window. The server\n * never reads the list of attempts for it; the site's traffic totals beside it\n * count something else, so they stay behind `--full`.\n */\nexport function narrowToAnswers(data: Record<string, unknown>, answerField: string | undefined, full: boolean): void {\n if (full || answerField === undefined) return;\n delete data.totals;\n delete data.previous;\n}\n\n/** The blocks that are a per-bucket series, which `--granularity` shapes. */\nconst SERIES_BLOCKS = [\"trend\", \"eventTrend\", \"customFunnelTrend\", \"flowTrend\", \"landings\"];\n\n/**\n * `--granularity` on a report that returned no series.\n *\n * The flag is shared by every report, and only a few have buckets to shape;\n * the rest accept it and change nothing, which read as \"no trend exists\" and\n * sent agents into one call per day (BAKER-2549, BAKER-924).\n */\nexport function noSeriesHint(\n data: Record<string, unknown>,\n granularity: string | undefined,\n warnings: readonly { code: string }[] = [],\n): string[] {\n if (granularity === undefined) return [];\n if (SERIES_BLOCKS.some((key) => key in data)) return [];\n // A series left out for size carries its own warning, which says why.\n if (warnings.some((warning) => warning.code === \"SERIES_CAPPED\")) return [];\n return [\n `--granularity ${granularity} shaped nothing: this report returned no per-bucket series. One comes with --full from overview, traffic or page (trend), events (eventTrend per event, --event <name> for one; customFunnelTrend with --steps) and flow (flowTrend per Form, --flow <slug> for one), narrowed with --landing, --platform or --role/--value like any report.`,\n ];\n}\n\n/** The formats this family renders. */\nexport const ANALYTICS_OUTPUT_FORMATS = [\"json\", \"md\"] as const;\n\n/**\n * Whether a `--output` value is one we render.\n *\n * Checked rather than defaulted, because the near-misses are the plausible\n * guesses — `markdown`, `table`, `csv` — and every one of them used to fall\n * through to JSON silently. An agent that asked for the cheap format, was\n * handed the expensive one, and was told nothing has no way to notice.\n */\nexport function isAnalyticsOutputFormat(value: string): boolean {\n return (ANALYTICS_OUTPUT_FORMATS as readonly string[]).includes(value);\n}\n\n/**\n * Write the report.\n *\n * JSON stays the default and stays the envelope every other family returns, but\n * it is emitted compact. It used to go through the shared pretty-printer, which\n * indents two spaces per level — measured at a third to a half of the bytes of\n * every analytics response, spent on whitespace the reader gains nothing from.\n */\nexport function writeAnalyticsReport(\n envelope: {\n ok: true;\n data: Record<string, unknown>;\n warnings?: ReadonlyArray<{ code: string; message: string }>;\n hints?: readonly string[];\n },\n format: string,\n): void {\n if (format === \"md\") {\n process.stdout.write(renderMarkdown(envelope));\n return;\n }\n process.stdout.write(`${JSON.stringify(envelope)}\\n`);\n}\n\n/**\n * Above this many rows in one response, the format is worth a sentence.\n *\n * A flag nobody knows about is a flag nobody passes. The saving is real —\n * measured at 70% on a hundred-row keyword breakdown — but it only ever\n * happens on the second call, so the first one has to say so.\n */\nconst ROWS_BEFORE_FORMAT_HINT = 25;\n\n/** How many rows the response carries, across every block that is a list. */\nexport function rowCount(data: Record<string, unknown>): number {\n let total = 0;\n for (const value of Object.values(data)) {\n if (Array.isArray(value)) total += value.length;\n }\n return total;\n}\n\n/** Told once, when it would have mattered, and never on a report already in Markdown. */\nexport function formatHint(data: Record<string, unknown>, format: string): string[] {\n if (format === \"md\") return [];\n const rows = rowCount(data);\n if (rows < ROWS_BEFORE_FORMAT_HINT) return [];\n return [\n \"This report is long. If you are going to read the numbers rather than pick one field out of them, --output md returns the same answer as tables, typically a third to a half smaller.\",\n ];\n}\n","/**\n * `--fields`: the columns of a report the agent is going to read, and no others.\n *\n * A feed row is ~1.1 KB as stored and a per-visitor pass reads six short\n * strings of it; a landings row is eighteen columns and an agent cutting one\n * out of the printed table with `cut -d'|'` took the column beside it. Naming\n * the columns is cheaper than either and cannot pick the wrong one.\n *\n * A report is narrowed as the CLI's own `--fields` mask narrows any envelope\n * (`field-mask.ts`). On the feed the server projects too, so a page is a few\n * hundred bytes and may hold 1000 rows.\n */\n\nimport { analyticsTimelineRowSchema } from \"@baker/api/analytics\";\nimport { pickRow } from \"../../field-mask.ts\";\n\n/** Keys the feed adds on its way out rather than reading from the store. */\nconst DERIVED_FEED_FIELDS: Readonly<Record<string, readonly string[]>> = {\n destination: [\"sideEffectType\"],\n matchedBy: [\"userData\"],\n eventKind: [\"sideEffectName\"],\n};\n\n/**\n * What the feed's own reading needs from every row, asked for whatever was\n * requested: the held-back rows are recognised by `eventType` and `triggerId`,\n * and the hints read the upload's `eventId` and a searched person's terms.\n */\nconst FEED_SHAPING_FIELDS = [\"eventType\", \"triggerId\", \"sideEffectType\", \"eventId\", \"personTerms\"];\n\n/** Every column a feed row can carry. */\nexport const FEED_COLUMNS: readonly string[] = [\n ...Object.keys(analyticsTimelineRowSchema.shape),\n ...Object.keys(DERIVED_FEED_FIELDS),\n];\n\n/** The `--fields` list, or undefined when it was not given. */\nexport function parseFields(raw: unknown): string[] | undefined {\n if (raw === undefined || raw === true || raw === false) return undefined;\n const fields = [\n ...new Set(\n String(raw)\n .split(\",\")\n .map((field) => field.trim())\n .filter((field) => field !== \"\"),\n ),\n ];\n return fields.length > 0 ? fields : undefined;\n}\n\n/**\n * The keys the server keeps on each feed row: the asked-for ones (a dotted\n * `properties.utm_source` reads inside `properties`), and what the feed itself reads.\n */\nexport function serverFeedFields(fields: readonly string[]): string[] {\n const stored = fields.flatMap((field) => {\n const head = field.split(\".\")[0] ?? field;\n return DERIVED_FEED_FIELDS[head] ?? [head];\n });\n return [...new Set([...stored, ...FEED_SHAPING_FIELDS])];\n}\n\n/**\n * The feed's rows with only the asked-for keys, every row, whichever were\n * empty: the keys the server kept for the feed's own reading are not the\n * agent's. Hints name a column the feed does not have, and one that is empty\n * on every row of this page, so neither reads as the other.\n */\nexport function keepFeedFields(\n rows: readonly Record<string, unknown>[],\n fields: string[],\n): { rows: Record<string, unknown>[]; hints: string[] } {\n const kept = rows.map((row) => pickRow(row, fields));\n const unknown = fields.filter((field) => !FEED_COLUMNS.includes(field.split(\".\")[0] ?? field));\n const empty = fields.filter((field) => !unknown.includes(field) && !kept.some((row) => field in row));\n const hints = [\n ...(unknown.length > 0\n ? [\n `--fields ${unknown.join(\", \")}: not a feed column. A misspelling? The columns: ${[...FEED_COLUMNS].sort().join(\", \")}.`,\n ]\n : []),\n ...(empty.length > 0 && kept.length > 0 ? [`--fields ${empty.join(\", \")}: empty on every row of this page.`] : []),\n ];\n return { rows: kept, hints };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqCO,SAAS,UAAU,MAAe,MAAmB,CAAC,GAAgB;AAC3E,MAAI,CAAC,QAAQ,OAAO,SAAS,SAAU,QAAO;AAC9C,QAAM,SAAS;AACf,MAAI,KAAK,MAAM;AACf,MAAI,MAAM,QAAQ,OAAO,QAAQ,EAAG,YAAW,SAAS,OAAO,SAAU,WAAU,OAAO,GAAG;AAC7F,SAAO;AACT;AAWO,SAAS,cAAc,MAAe,MAA8B;AACzE,QAAM,UAA0B,CAAC;AACjC,QAAM,YAA4B,CAAC;AAMnC,QAAM,QAAQ,UAAU,IAAI,EAAE,OAAO,CAAC,SAAS,OAAO,KAAK,OAAO,YAAY,KAAK,OAAO,EAAE;AAC5F,MAAI,MAAM,WAAW,EAAG,QAAO,CAAC;AAEhC,aAAW,QAAQ,OAAO;AACxB,UAAM,KAAK,KAAK;AAChB,UAAM,WAAW,iBAAiB,KAAK,QAAQ;AAC/C,eAAW,aAAa,SAAS,WAAW;AAC1C,YAAM,YAA0B;AAAA,QAC9B,UAAU,aAAa,MAAM,IAAI,SAAS;AAAA,QAC1C,QAA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AAQ,CAAC,UAAU;AACvC,UAAM,OAAO,MAAM,MAAM,GAAG,EAAE,CAAC,KAAK;AACpC,WAAO,oBAAoB,IAAI,KAAK,CAAC,IAAI;AAAA,EAC3C,CAAC;AACD,SAAO,CAAC,GAAG,oBAAI,IAAI,CAAC,GAAG,QAAQ,GAAG,mBAAmB,CAAC,CAAC;AACzD;AAQO,SAAS,eACd,MACA,QACsD;AACtD,QAAM,OAAO,KAAK,IAAI,CAAC,QAAQ,QAAQ,KAAK,MAAM,CAAC;AACnD,QAAM,UAAU,OAAO,OAAO,CAAC,UAAU,CAAC,aAAa,SAAS,MAAM,MAAM,GAAG,EAAE,CAAC,KAAK,KAAK,CAAC;AAC7F,QAAM,QAAQ,OAAO,OAAO,CAAC,UAAU,CAAC,QAAQ,SAAS,KAAK,KAAK,CAAC,KAAK,KAAK,CAAC,QAAQ,SAAS,GAAG,CAAC;AACpG,QAAM,QAAQ;AAAA,IACZ,GAAI,QAAQ,SAAS,IACjB;AAAA,MACE,YAAY,QAAQ,KAAK,IAAI,CAAC,oDAAoD,CAAC,GAAG,YAAY,EAAE,KAAK,EAAE,KAAK,IAAI,CAAC;AAAA,IACvH,IACA,CAAC;AAAA,IACL,GAAI,MAAM,SAAS,KAAK,KAAK,SAAS,IAAI,CAAC,YAAY,MAAM,KAAK,IAAI,CAAC,oCAAoC,IAAI,CAAC;AAAA,EAClH;AACA,SAAO,EAAE,MAAM,MAAM,MAAM;AAC7B;","names":[]}
1
+ {"version":3,"sources":["../../api/src/analytics/flowEventKeys.ts","../src/commands/analytics/render.ts","../src/commands/analytics/fields.ts"],"sourcesContent":["/**\n * Every event a Form's own steps raise, built from the Form's tree.\n *\n * A Form published by Baker emits its events natively: every step raises the\n * triggers its node type has, and the Form raises `submit:<slug>` when it runs\n * out of steps. Nothing has to be registered for that to happen — no Source, no\n * conversion, no setting. But the lists a person or an agent PICKS an event\n * from are built from the event store, which knows an event only after somebody\n * has fired it. So a Form published five minutes ago offered nothing to pick,\n * and the only affordances left on the picker were \"type the name by hand\" and\n * \"add a Source\" — a door for a company's own systems, offered for an event a\n * Baker page already sends. Both of those are how a funnel step ends up wired\n * to a key that counts zero forever.\n *\n * This is the other half: the keys derived from the tree, offered at zero,\n * exactly as a Source is offered before its first send. Same builder\n * (`formEventKey`), same trigger table (`flowNodeTriggers`), so a key from here\n * and a key from the SQL are the same string.\n */\n\nimport { flowNodeTriggers } from \"../flowCatalog\";\nimport { formEventKey } from \"./eventKey\";\n\ntype AnyRecord = Record<string, unknown>;\n\nexport interface FlowEventKey {\n eventKey: string;\n /** `null` for the Form-level `submit:` key, which belongs to no step. */\n nodeId: string | null;\n nodeName: string;\n nodeType: string | null;\n triggerId: string | null;\n /** Whether this is the moment that step exists to produce. */\n isCompletion: boolean;\n}\n\n/** Every node of a Form tree, parents before children. */\nexport function flowNodes(node: unknown, acc: AnyRecord[] = []): AnyRecord[] {\n if (!node || typeof node !== \"object\") return acc;\n const record = node as AnyRecord;\n acc.push(record);\n if (Array.isArray(record.children)) for (const child of record.children) flowNodes(child, acc);\n return acc;\n}\n\n/**\n * Every event key this Form can produce, each step's completion first.\n *\n * Completion triggers lead because they are what a person means by \"reached\n * this step\"; the lifecycle triggers a widget also raises (\"the embedded form\n * finished loading\") follow rather than being hidden, since an embedded\n * checkout genuinely reports through one of them. The order says nothing about\n * which ending is the Form's outcome — that is the agent's call.\n */\nexport function flowEventKeys(tree: unknown, slug: string): FlowEventKey[] {\n const primary: FlowEventKey[] = [];\n const secondary: FlowEventKey[] = [];\n\n // A tree with no identified step raises nothing, and `submit:<slug>` for it\n // would be the very thing this file exists to prevent: a real-looking key\n // that counts zero for ever. It happens — a `_data.json` holding `null` or\n // `{}`, a folder a flow-builder loop created and has not finished writing.\n const nodes = flowNodes(tree).filter((node) => typeof node.id === \"string\" && node.id !== \"\");\n if (nodes.length === 0) return [];\n\n for (const node of nodes) {\n const id = node.id as string;\n const triggers = flowNodeTriggers(node.nodeData);\n for (const triggerId of triggers.available) {\n const candidate: FlowEventKey = {\n eventKey: formEventKey(slug, id, triggerId),\n nodeId: id,\n nodeName: typeof node.name === \"string\" ? node.name : id,\n nodeType: triggers.type,\n triggerId,\n isCompletion: triggers.completion === triggerId,\n };\n (candidate.isCompletion ? primary : secondary).push(candidate);\n }\n }\n\n return [\n ...primary,\n ...secondary,\n {\n eventKey: `submit:${slug}`,\n nodeId: null,\n nodeName: \"the Form ran out of steps\",\n nodeType: null,\n triggerId: null,\n // A Form reaching its last node is as primary as an outcome gets for a\n // Form with no widget in it — but it never fires on one that ends in a\n // booking widget or a redirect, so it does not lead the list.\n isCompletion: false,\n },\n ];\n}\n","/**\n * What the agent reads, as opposed to what the wire carries.\n *\n * The dashboard and the sandbox agent read the same `/api/analytics/query`\n * response and want different things out of it. A browser wants every field of\n * every row plus a sparkline it can draw; an agent pays for all of that in\n * context and cannot draw anything.\n *\n * Measured against the wire schema on a 40-landing site: `landings` came back\n * as ~11.5k tokens of pretty-printed JSON, a third of it indentation and half\n * of it sparkline. `landings --days 90 --granularity hour` came back as ~353k\n * tokens — the sparkline is bucketed by `--granularity`, so ninety days of\n * hours is 2,160 numbers per page — which is larger than the window it has to\n * fit inside. Nothing capped it and nothing warned about it.\n *\n * So the shaping happens here rather than in the endpoint: the wire keeps its\n * contract, the dashboard keeps its fields, and the agent gets the same answer\n * at roughly a tenth of the cost.\n */\n\nimport { type AnalyticsProjectedQueryData, EVENT_PROPERTY_WITHHELD } from \"@baker/api/analytics\";\n\n/**\n * How many points of a sparkline survive `--full`.\n *\n * A sparkline exists to carry a shape, and a shape survives resampling — thirty\n * points still say \"it collapsed in the third week\". The per-bucket counts are\n * not lost: `traffic --landing <id> --granularity hour` is the report that\n * answers at that resolution, and it answers for one page rather than for all\n * of them at once.\n */\nconst SPARKLINE_POINTS = 30;\n\n/** Fields no agent can act on, dropped before anything else is measured. */\nconst DASHBOARD_ONLY_FIELDS = new Set([\n // The Convex row id. It exists so a dashboard can link to the row; an agent\n // addresses a landing by `landingId`, which is the id in its `_definition.md`.\n \"landingRef\",\n]);\n\n/**\n * Blocks that are lists of things rather than breakdowns.\n *\n * Only these are paged, and only these are worth saying \"there are more\" about.\n */\nexport const ANALYTICS_LIST_BLOCKS = [\"deliveries\", \"submissions\", \"visitors\", \"timeline\", \"stream\"] as const;\n\n/**\n * A value carrying nothing a missing key would not carry.\n *\n * `null` is deliberately not in here. Every rate in this response is `null`\n * rather than `0` when it has no denominator, and the docs tell the agent to\n * read the two apart — so `null` is an answer and `\"\"` is an absence.\n * `0` and `false` are answers too.\n */\nfunction isAbsent(value: unknown): boolean {\n if (value === \"\") return true;\n if (Array.isArray(value)) return value.length === 0;\n if (typeof value === \"object\" && value !== null) return Object.keys(value).length === 0;\n return false;\n}\n\n/**\n * A series resampled to at most `points`, by summing into equal buckets.\n *\n * Summing rather than sampling every nth point: these are counts, and dropping\n * four hours in five understates a day by four fifths while still drawing a\n * plausible line. A resampled series totals what the original totalled.\n */\nexport function resample(series: readonly number[], points: number): number[] {\n if (series.length <= points || points < 1) return [...series];\n const out: number[] = [];\n for (let i = 0; i < points; i += 1) {\n const from = Math.floor((i * series.length) / points);\n const to = Math.floor(((i + 1) * series.length) / points);\n let sum = 0;\n for (let j = from; j < to; j += 1) sum += series[j] ?? 0;\n out.push(sum);\n }\n return out;\n}\n\nfunction pruneValue(value: unknown, full: boolean): unknown {\n if (Array.isArray(value)) return value.map((entry) => pruneValue(entry, full));\n if (typeof value === \"object\" && value !== null) {\n return pruneRow(value as Record<string, unknown>, full);\n }\n return value;\n}\n\n/** One row with its absent fields and its dashboard-only fields removed. */\nfunction pruneRow(row: Record<string, unknown>, full: boolean): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(row)) {\n if (DASHBOARD_ONLY_FIELDS.has(key)) continue;\n if (key === \"sparkline\" && Array.isArray(value)) {\n // Dropped outright unless asked for: it is the one field here that is a\n // picture rather than a fact, and it is also the largest.\n if (!full) continue;\n out[key] = resample(value as number[], SPARKLINE_POINTS);\n continue;\n }\n if (isAbsent(value)) continue;\n out[key] = pruneValue(value, full);\n }\n return out;\n}\n\n/**\n * The response an agent should be handed.\n *\n * Per-row rather than per-column pruning, because the saving is in the rows\n * that differ: a replay row carries thirty-five fields of which a page view\n * fills eight, and dropping a column only when it is empty in *every* row would\n * keep all thirty-five on every one of them.\n */\nexport function pruneForAgent(data: AnalyticsProjectedQueryData, full: boolean): Record<string, unknown> {\n const pruned = pruneRow(data as unknown as Record<string, unknown>, full);\n // The one empty list kept: the list the report pages. Pruned, a failures-only\n // `delivery` with no failures read exactly like a report that left the block\n // out, and agents pulled every submission with --full to tell them apart.\n const paged = data.pageInfo?.block;\n if (paged !== undefined && Array.isArray(data[paged]) && !(paged in pruned)) pruned[paged] = [];\n return pruned;\n}\n\n// ---------------------------------------------------------------------------\n// Rendering\n// ---------------------------------------------------------------------------\n\n/** A row that can be a table line: every value is a scalar or a flat list. */\nfunction isTabular(rows: readonly unknown[]): rows is ReadonlyArray<Record<string, unknown>> {\n return rows.every(\n (row) =>\n typeof row === \"object\" &&\n row !== null &&\n !Array.isArray(row) &&\n Object.values(row).every(\n (value) =>\n value === null ||\n typeof value !== \"object\" ||\n (Array.isArray(value) && value.every((e) => typeof e !== \"object\")),\n ),\n );\n}\n\nfunction cell(value: unknown, key?: string): string {\n if (value === null || value === undefined) return \"\";\n if (Array.isArray(value)) return value.join(\" \");\n if (typeof value === \"number\" && !Number.isInteger(value)) {\n // A duration in milliseconds to four decimal places is four digits of\n // noise: nothing downstream is sensitive to a microsecond of dwell time,\n // and every one of them is a character the reader pays for.\n if (key?.endsWith(\"Ms\")) return String(Math.round(value));\n return value.toFixed(4).replace(/0+$/, \"\").replace(/\\.$/, \"\");\n }\n return String(value);\n}\n\n/**\n * Columns that say *which row this is*, before the ones that say how it did.\n *\n * Needed because the keys do not arrive in the order the wire declares them —\n * they come back alphabetised, which buries `landingId` and `name` in the\n * middle of a table and leads with `avgEngagementMs`. A table whose first\n * column is not the subject has to be read twice.\n */\nconst IDENTITY_COLUMNS = [\n \"landingId\",\n \"name\",\n \"slug\",\n \"path\",\n \"flowSlug\",\n \"stepId\",\n \"value\",\n \"key\",\n \"bucket\",\n \"tag\",\n \"eventName\",\n \"release\",\n \"place\",\n \"bot\",\n \"source\",\n \"medium\",\n \"campaign\",\n \"platform\",\n \"sessionId\",\n \"eventId\",\n];\n\nfunction byIdentityFirst(a: string, b: string): number {\n const ia = IDENTITY_COLUMNS.indexOf(a);\n const ib = IDENTITY_COLUMNS.indexOf(b);\n if (ia !== -1 || ib !== -1)\n return (ia === -1 ? Number.MAX_SAFE_INTEGER : ia) - (ib === -1 ? Number.MAX_SAFE_INTEGER : ib);\n return 0;\n}\n\n/**\n * Blocks in the order a report is read: the window it covers, the totals, the\n * rows, and the echo of which preset produced it last of all. An `events`\n * breakdown or funnel leads, because it is what `--event --property` or\n * `--steps` asked for, and a reader cut off by `| head` must still see it.\n */\nconst BLOCK_ORDER = [\"eventBreakdown\", \"customFunnel\", \"window\", \"totals\", \"previous\", \"pageInfo\"];\n\nfunction byBlockOrder(a: string, b: string): number {\n const rank = (key: string) => {\n const at = BLOCK_ORDER.indexOf(key);\n if (at !== -1) return at;\n return key === \"preset\" ? BLOCK_ORDER.length + 1 : BLOCK_ORDER.length;\n };\n return rank(a) - rank(b);\n}\n\n/**\n * Columns, in the order the wire declares them, minus the ones no row filled.\n *\n * Per-column here where the JSON path prunes per-row: a table with a ragged\n * row is not a table, and a column of empty cells costs the header once rather\n * than once per row.\n */\nfunction columnsOf(rows: ReadonlyArray<Record<string, unknown>>): string[] {\n const seen: string[] = [];\n for (const row of rows) {\n for (const key of Object.keys(row)) {\n if (!seen.includes(key)) seen.push(key);\n }\n }\n return seen\n .filter((key) => rows.some((row) => !isAbsent(row[key]) && row[key] !== null && row[key] !== undefined))\n .sort(byIdentityFirst);\n}\n\nfunction table(rows: ReadonlyArray<Record<string, unknown>>): string {\n const cols = columnsOf(rows);\n if (cols.length === 0) return \"\";\n const head = `| ${cols.join(\" | \")} |`;\n const rule = `| ${cols.map(() => \"---\").join(\" | \")} |`;\n const body = rows.map((row) => `| ${cols.map((col) => cell(row[col], col)).join(\" | \")} |`);\n return [head, rule, ...body].join(\"\\n\");\n}\n\n/** A value that is a list of rows, i.e. a sub-table rather than a cell. */\nfunction isRowList(value: unknown): value is Array<Record<string, unknown>> {\n return (\n Array.isArray(value) &&\n value.length > 0 &&\n value.every((entry) => typeof entry === \"object\" && entry !== null && !Array.isArray(entry))\n );\n}\n\n/** Whatever names this row in a heading — its id, its slug, or its position. */\nfunction labelOf(row: Record<string, unknown>, index: number): string {\n for (const key of IDENTITY_COLUMNS) {\n const value = row[key];\n if (typeof value === \"string\" && value !== \"\") return value;\n }\n return `#${index + 1}`;\n}\n\n/**\n * A block whose rows carry nested rows of their own — a funnel and its steps.\n *\n * Rendered as the parent table followed by one sub-table per parent rather than\n * dumped as JSON. The JSON fallback was correct and nearly useless: `funnel`,\n * `flow` and `overview` all nest, they are the three commands most likely to be\n * the *first* call of a turn, and for them `--output md` was saving about 2%.\n */\nfunction nestedBlock(name: string, rows: ReadonlyArray<Record<string, unknown>>): string {\n const parents = rows.map((row) =>\n Object.fromEntries(Object.entries(row).filter(([, value]) => !isRowList(value) && !isPlainRow(value))),\n );\n const parts = [`### ${name}`, table(parents)];\n rows.forEach((row, index) => {\n for (const [key, value] of Object.entries(row)) {\n if (isRowList(value)) parts.push(`#### ${name}[${labelOf(row, index)}].${key}`, table(value));\n else if (isPlainRow(value)) parts.push(`#### ${name}[${labelOf(row, index)}].${key}`, table([value]));\n }\n });\n return parts.filter((part) => part !== \"\").join(\"\\n\");\n}\n\n/** An object that is one row rather than a list — `worstStep`. */\nfunction isPlainRow(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction block(name: string, value: unknown): string {\n if (Array.isArray(value)) {\n if (value.length === 0) return \"\";\n if (isTabular(value)) return `### ${name}\\n${table(value)}`;\n if (isRowList(value)) return nestedBlock(name, value);\n return `### ${name}\\n${JSON.stringify(value)}`;\n }\n if (typeof value === \"object\" && value !== null) {\n const entries = Object.entries(value as Record<string, unknown>);\n if (entries.length === 0) return \"\";\n if (entries.every(([, v]) => v === null || typeof v !== \"object\")) {\n return `### ${name}\\n${entries.map(([k, v]) => `- ${k}: ${v === null ? \"null\" : cell(v, k)}`).join(\"\\n\")}`;\n }\n return `### ${name}\\n${JSON.stringify(value)}`;\n }\n return `### ${name}\\n${cell(value)}`;\n}\n\n/**\n * The whole response as Markdown.\n *\n * A fifth to a half smaller than the compact JSON, because a\n * table names each column once instead of once per row. `warnings` and `hints`\n * lead rather than trail: they are instructions to the reader, and a reader\n * that has already summarised the table below them has acted without them.\n */\nexport function renderMarkdown(envelope: {\n data: Record<string, unknown>;\n warnings?: ReadonlyArray<{ code: string; message: string }>;\n hints?: readonly string[];\n}): string {\n const parts: string[] = [];\n for (const warning of envelope.warnings ?? []) parts.push(`> **${warning.code}** — ${warning.message}`);\n for (const hint of envelope.hints ?? []) parts.push(`> ${hint}`);\n for (const [name, value] of Object.entries(envelope.data).sort(([a], [b]) => byBlockOrder(a, b))) {\n const rendered = block(name, value);\n if (rendered !== \"\") parts.push(rendered);\n }\n return `${parts.join(\"\\n\\n\")}\\n`;\n}\n\n/**\n * An `--event` read that came back empty, said as what was empty.\n *\n * The event list is narrowed to the `--event` asked for, so an absent row\n * means the event had no rows in this window, and a present one with an empty\n * `eventBreakdown` means the `--property` (or `--where`) split it into nothing.\n * Calling the second \"that event does not exist\" — beside a list naming it —\n * is the contradiction BAKER-3379 recorded.\n */\nexport function missingBreakdownHint(\n data: Record<string, unknown>,\n asked: { eventName?: string; property?: string },\n): string[] {\n if (asked.eventName === undefined) return [];\n const listed = Array.isArray(data.customEvents)\n ? data.customEvents.find((row) => isPlainRow(row) && row.eventName === asked.eventName)\n : undefined;\n if (listed === undefined) {\n return [\n `No ${asked.eventName} events in this window. Run \\`baker analytics events\\` without --event for the names these pages send, or widen --days.`,\n ];\n }\n if (asked.property === undefined) return [];\n const breakdown = data.eventBreakdown;\n if (Array.isArray(breakdown) && breakdown.length > 0) return [];\n const keys = Array.isArray(listed.propertyKeys) ? listed.propertyKeys.join(\", \") : \"\";\n return [\n `${asked.eventName} has events in this window, but --property ${asked.property} split them into no rows (with --where, the filter matched none)${keys === \"\" ? \"\" : `. Its property keys: ${keys}`}.`,\n ];\n}\n\n/**\n * What the `(no consent)` row of a breakdown is, said before anyone goes\n * looking for a tracking fault in it.\n *\n * Its events are real and its visits are only an estimate: the collector\n * kept the event and dropped who it was, the page's own properties with it. Unexplained, an agent paged the raw feed seven times and wrote three\n * scripts to find that out (BAKER-3791).\n */\nexport function withheldBreakdownHint(\n data: Record<string, unknown>,\n asked: { eventName?: string; property?: string },\n): string[] {\n if (asked.eventName === undefined || asked.property === undefined || !Array.isArray(data.eventBreakdown)) return [];\n const row = data.eventBreakdown.find((entry) => isPlainRow(entry) && entry.value === EVENT_PROPERTY_WITHHELD);\n const events = isPlainRow(row) && typeof row.events === \"number\" ? row.events : 0;\n if (events === 0) return [];\n return [\n `${events} ${asked.eventName} events are \"${EVENT_PROPERTY_WITHHELD}\": recorded from visitors who declined analytics consent (or while the site measures in aggregate), so they carry no visit of their own and none of the page's own properties: their visits are estimated (\\`estimatedSessions\\`). They are real and count in every total; only their ${asked.property} is unknown. Report them as ${events} without consent, ${asked.property} unknown — not as a tracking fault, and not by reading the feed, which holds nothing more about them.`,\n ];\n}\n\n/**\n * `--event X --property Y` without `--full`: the breakdown asked for and the\n * window it covers, nothing site-wide.\n *\n * The totals and the event list answer a different question, and printed\n * beside the breakdown they pushed it past a `| head` and tripled what one\n * read cost (BAKER-2546). `--full` keeps them. Applied after the hints are\n * read, which still need the event list to say whether the event was there.\n */\nexport function narrowToBreakdown(\n data: Record<string, unknown>,\n asked: { eventName?: string; property?: string },\n full: boolean,\n): void {\n if (full || asked.eventName === undefined || asked.property === undefined) return;\n delete data.customEvents;\n delete data.totals;\n delete data.previous;\n}\n\n/**\n * `submissions --by-field` prints the answers and their window. The server\n * never reads the list of attempts for it; the site's traffic totals beside it\n * count something else, so they stay behind `--full`.\n */\nexport function narrowToAnswers(data: Record<string, unknown>, answerField: string | undefined, full: boolean): void {\n if (full || answerField === undefined) return;\n delete data.totals;\n delete data.previous;\n}\n\n/** The blocks that are a per-bucket series, which `--granularity` shapes. */\nconst SERIES_BLOCKS = [\"trend\", \"eventTrend\", \"customFunnelTrend\", \"flowTrend\", \"landings\"];\n\n/**\n * `--granularity` on a report that returned no series.\n *\n * The flag is shared by every report, and only a few have buckets to shape;\n * the rest accept it and change nothing, which read as \"no trend exists\" and\n * sent agents into one call per day (BAKER-2549, BAKER-924).\n */\nexport function noSeriesHint(\n data: Record<string, unknown>,\n granularity: string | undefined,\n warnings: readonly { code: string }[] = [],\n): string[] {\n if (granularity === undefined) return [];\n if (SERIES_BLOCKS.some((key) => key in data)) return [];\n // A series left out for size carries its own warning, which says why.\n if (warnings.some((warning) => warning.code === \"SERIES_CAPPED\")) return [];\n return [\n `--granularity ${granularity} shaped nothing: this report returned no per-bucket series. One comes with --full from overview, traffic or page (trend), events (eventTrend per event, --event <name> for one; customFunnelTrend with --steps) and flow (flowTrend per Form, --flow <slug> for one), narrowed with --landing, --platform or --role/--value like any report.`,\n ];\n}\n\n/** The formats this family renders. */\nexport const ANALYTICS_OUTPUT_FORMATS = [\"json\", \"md\"] as const;\n\n/**\n * Whether a `--output` value is one we render.\n *\n * Checked rather than defaulted, because the near-misses are the plausible\n * guesses — `markdown`, `table`, `csv` — and every one of them used to fall\n * through to JSON silently. An agent that asked for the cheap format, was\n * handed the expensive one, and was told nothing has no way to notice.\n */\nexport function isAnalyticsOutputFormat(value: string): boolean {\n return (ANALYTICS_OUTPUT_FORMATS as readonly string[]).includes(value);\n}\n\n/**\n * Write the report.\n *\n * JSON stays the default and stays the envelope every other family returns, but\n * it is emitted compact. It used to go through the shared pretty-printer, which\n * indents two spaces per level — measured at a third to a half of the bytes of\n * every analytics response, spent on whitespace the reader gains nothing from.\n */\nexport function writeAnalyticsReport(\n envelope: {\n ok: true;\n data: Record<string, unknown>;\n warnings?: ReadonlyArray<{ code: string; message: string }>;\n hints?: readonly string[];\n },\n format: string,\n): void {\n if (format === \"md\") {\n process.stdout.write(renderMarkdown(envelope));\n return;\n }\n process.stdout.write(`${JSON.stringify(envelope)}\\n`);\n}\n\n/**\n * Above this many rows in one response, the format is worth a sentence.\n *\n * A flag nobody knows about is a flag nobody passes. The saving is real —\n * measured at 70% on a hundred-row keyword breakdown — but it only ever\n * happens on the second call, so the first one has to say so.\n */\nconst ROWS_BEFORE_FORMAT_HINT = 25;\n\n/** How many rows the response carries, across every block that is a list. */\nexport function rowCount(data: Record<string, unknown>): number {\n let total = 0;\n for (const value of Object.values(data)) {\n if (Array.isArray(value)) total += value.length;\n }\n return total;\n}\n\n/** Told once, when it would have mattered, and never on a report already in Markdown. */\nexport function formatHint(data: Record<string, unknown>, format: string): string[] {\n if (format === \"md\") return [];\n const rows = rowCount(data);\n if (rows < ROWS_BEFORE_FORMAT_HINT) return [];\n return [\n \"This report is long. If you are going to read the numbers rather than pick one field out of them, --output md returns the same answer as tables, typically a third to a half smaller.\",\n ];\n}\n","/**\n * `--fields`: the columns of a report the agent is going to read, and no others.\n *\n * A feed row is ~1.1 KB as stored and a per-visitor pass reads six short\n * strings of it; a landings row is eighteen columns and an agent cutting one\n * out of the printed table with `cut -d'|'` took the column beside it. Naming\n * the columns is cheaper than either and cannot pick the wrong one.\n *\n * A report is narrowed as the CLI's own `--fields` mask narrows any envelope\n * (`field-mask.ts`). On the feed the server projects too, so a page is a few\n * hundred bytes and may hold 1000 rows.\n */\n\nimport { analyticsTimelineRowSchema } from \"@baker/api/analytics\";\nimport { pickRow } from \"../../field-mask.ts\";\n\n/** Keys the feed adds on its way out rather than reading from the store. */\nconst DERIVED_FEED_FIELDS: Readonly<Record<string, readonly string[]>> = {\n destination: [\"sideEffectType\"],\n matchedBy: [\"userData\"],\n eventKind: [\"sideEffectName\"],\n};\n\n/**\n * What the feed's own reading needs from every row, asked for whatever was\n * requested: the held-back rows are recognised by `eventType` and `triggerId`,\n * and the hints read the upload's `eventId` and a searched person's terms.\n */\nconst FEED_SHAPING_FIELDS = [\"eventType\", \"triggerId\", \"sideEffectType\", \"eventId\", \"personTerms\"];\n\n/** Every column a feed row can carry. */\nexport const FEED_COLUMNS: readonly string[] = [\n ...Object.keys(analyticsTimelineRowSchema.shape),\n ...Object.keys(DERIVED_FEED_FIELDS),\n];\n\n/** The `--fields` list, or undefined when it was not given. */\nexport function parseFields(raw: unknown): string[] | undefined {\n if (raw === undefined || raw === true || raw === false) return undefined;\n const fields = [\n ...new Set(\n String(raw)\n .split(\",\")\n .map((field) => field.trim())\n .filter((field) => field !== \"\"),\n ),\n ];\n return fields.length > 0 ? fields : undefined;\n}\n\n/**\n * The keys the server keeps on each feed row: the asked-for ones (a dotted\n * `properties.utm_source` reads inside `properties`), and what the feed itself reads.\n */\nexport function serverFeedFields(fields: readonly string[]): string[] {\n const stored = fields.flatMap((field) => {\n const head = field.split(\".\")[0] ?? field;\n return DERIVED_FEED_FIELDS[head] ?? [head];\n });\n return [...new Set([...stored, ...FEED_SHAPING_FIELDS])];\n}\n\n/**\n * The feed's rows with only the asked-for keys, every row, whichever were\n * empty: the keys the server kept for the feed's own reading are not the\n * agent's. Hints name a column the feed does not have, and one that is empty\n * on every row of this page, so neither reads as the other.\n */\nexport function keepFeedFields(\n rows: readonly Record<string, unknown>[],\n fields: string[],\n): { rows: Record<string, unknown>[]; hints: string[] } {\n const kept = rows.map((row) => pickRow(row, fields));\n const unknown = fields.filter((field) => !FEED_COLUMNS.includes(field.split(\".\")[0] ?? field));\n const empty = fields.filter((field) => !unknown.includes(field) && !kept.some((row) => field in row));\n const hints = [\n ...(unknown.length > 0\n ? [\n `--fields ${unknown.join(\", \")}: not a feed column. A misspelling? The columns: ${[...FEED_COLUMNS].sort().join(\", \")}.`,\n ]\n : []),\n ...(empty.length > 0 && kept.length > 0 ? [`--fields ${empty.join(\", \")}: empty on every row of this page.`] : []),\n ];\n return { rows: kept, hints };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqCO,SAAS,UAAU,MAAe,MAAmB,CAAC,GAAgB;AAC3E,MAAI,CAAC,QAAQ,OAAO,SAAS,SAAU,QAAO;AAC9C,QAAM,SAAS;AACf,MAAI,KAAK,MAAM;AACf,MAAI,MAAM,QAAQ,OAAO,QAAQ,EAAG,YAAW,SAAS,OAAO,SAAU,WAAU,OAAO,GAAG;AAC7F,SAAO;AACT;AAWO,SAAS,cAAc,MAAe,MAA8B;AACzE,QAAM,UAA0B,CAAC;AACjC,QAAM,YAA4B,CAAC;AAMnC,QAAM,QAAQ,UAAU,IAAI,EAAE,OAAO,CAAC,SAAS,OAAO,KAAK,OAAO,YAAY,KAAK,OAAO,EAAE;AAC5F,MAAI,MAAM,WAAW,EAAG,QAAO,CAAC;AAEhC,aAAW,QAAQ,OAAO;AACxB,UAAM,KAAK,KAAK;AAChB,UAAM,WAAW,iBAAiB,KAAK,QAAQ;AAC/C,eAAW,aAAa,SAAS,WAAW;AAC1C,YAAM,YAA0B;AAAA,QAC9B,UAAU,aAAa,MAAM,IAAI,SAAS;AAAA,QAC1C,QAAQ;AAAA,QACR,UAAU,OAAO,KAAK,SAAS,WAAW,KAAK,OAAO;AAAA,QACtD,UAAU,SAAS;AAAA,QACnB;AAAA,QACA,cAAc,SAAS,eAAe;AAAA,MACxC;AACA,OAAC,UAAU,eAAe,UAAU,WAAW,KAAK,SAAS;AAAA,IAC/D;AAAA,EACF;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,GAAG;AAAA,IACH;AAAA,MACE,UAAU,UAAU,IAAI;AAAA,MACxB,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,UAAU;AAAA,MACV,WAAW;AAAA;AAAA;AAAA;AAAA,MAIX,cAAc;AAAA,IAChB;AAAA,EACF;AACF;;;ACjEA,IAAM,mBAAmB;AAG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AAO,OAAO,CAAC,UAAU,CAAC,QAAQ,SAAS,KAAK,KAAK,CAAC,KAAK,KAAK,CAAC,QAAQ,SAAS,GAAG,CAAC;AACpG,QAAM,QAAQ;AAAA,IACZ,GAAI,QAAQ,SAAS,IACjB;AAAA,MACE,YAAY,QAAQ,KAAK,IAAI,CAAC,oDAAoD,CAAC,GAAG,YAAY,EAAE,KAAK,EAAE,KAAK,IAAI,CAAC;AAAA,IACvH,IACA,CAAC;AAAA,IACL,GAAI,MAAM,SAAS,KAAK,KAAK,SAAS,IAAI,CAAC,YAAY,MAAM,KAAK,IAAI,CAAC,oCAAoC,IAAI,CAAC;AAAA,EAClH;AACA,SAAO,EAAE,MAAM,MAAM,MAAM;AAC7B;","names":[]}
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  analyticsErrorEnvelope
3
- } from "./chunk-LKTBIO3F.js";
3
+ } from "./chunk-STWMK24H.js";
4
4
  import {
5
5
  PEOPLE_SEARCH_MAX_TERMS,
6
6
  parsePeopleQuery,
7
7
  peopleLookupRequestSchema
8
- } from "./chunk-PC37FCEC.js";
8
+ } from "./chunk-T7GAC2WG.js";
9
9
  import {
10
10
  writeJsonEnvelope
11
11
  } from "./chunk-65QWF5C5.js";
@@ -187,4 +187,4 @@ export {
187
187
  lookupReport,
188
188
  lookupCommand
189
189
  };
190
- //# sourceMappingURL=chunk-2GXFGP4M.js.map
190
+ //# sourceMappingURL=chunk-SCK7U53A.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ANALYTICS_BUSY_FIX,
3
3
  isAnalyticsBusy
4
- } from "./chunk-PC37FCEC.js";
4
+ } from "./chunk-T7GAC2WG.js";
5
5
  import {
6
6
  ApiError
7
7
  } from "./chunk-SZCEKDLE.js";
@@ -42,4 +42,4 @@ export {
42
42
  questionnaireErrorEnvelope,
43
43
  trackingPlanErrorEnvelope
44
44
  };
45
- //# sourceMappingURL=chunk-LKTBIO3F.js.map
45
+ //# sourceMappingURL=chunk-STWMK24H.js.map
@@ -547,7 +547,13 @@ var sendsRequestSchema = z2.object({
547
547
  /** With `uploads`: only the events skipped, with what each was missing. */
548
548
  skippedOnly: z2.boolean().optional(),
549
549
  /** Also say when each live send was set up, and when an integration named after its event was removed. */
550
- history: z2.boolean().optional()
550
+ history: z2.boolean().optional(),
551
+ /**
552
+ * On a read: only what goes to this platform. The CLI narrows the rows; the
553
+ * server narrows the hints to match and refuses `uploads` of another
554
+ * platform's send, and refuses it beside a change (`set`, `remove`).
555
+ */
556
+ platform: z2.enum(SEND_PLATFORMS).optional()
551
557
  });
552
558
  var sendOutcomeSchema = z2.object({
553
559
  sendId: z2.string(),
@@ -1229,11 +1235,21 @@ var analyticsWindowSchema = z4.object({
1229
1235
  });
1230
1236
  var visitorsSchema = z4.number().int().nonnegative().nullable();
1231
1237
  var newVisitorsSchema = z4.number().int().nonnegative();
1238
+ var estimatedVisitsSchema = z4.number().int().nonnegative().default(0);
1232
1239
  var analyticsTotalsSchema = z4.object({
1233
1240
  visitors: visitorsSchema,
1234
1241
  newVisitors: newVisitorsSchema,
1235
- /** Counted from `session_start`. */
1242
+ /** Visits: every `session_start`, plus {@link estimatedSessions}. */
1236
1243
  sessions: z4.number().int().nonnegative(),
1244
+ estimatedSessions: estimatedVisitsSchema,
1245
+ /**
1246
+ * Visits that allowed analytics at any point: every `session_start`, the
1247
+ * ones opened by accepting after arriving included, though their visit is
1248
+ * counted in {@link estimatedSessions}. Not a part of {@link sessions} to
1249
+ * add or subtract: it is the visits of the browsers `visitors` counts, so
1250
+ * visits per visitor is `consentingSessions ÷ visitors`.
1251
+ */
1252
+ consentingSessions: z4.number().int().nonnegative().default(0),
1237
1253
  pageViews: z4.number().int().nonnegative(),
1238
1254
  /**
1239
1255
  * Every conversion, counting a visit twice when it converted twice.
@@ -1281,6 +1297,13 @@ var analyticsTrendPointSchema = z4.object({
1281
1297
  visitors: visitorsSchema,
1282
1298
  newVisitors: newVisitorsSchema,
1283
1299
  sessions: z4.number().int().nonnegative(),
1300
+ estimatedSessions: estimatedVisitsSchema,
1301
+ /**
1302
+ * Whether the pages marked their arrivals in this bucket, so the visits of
1303
+ * visitors who declined are estimated here — even when that estimate rounds
1304
+ * to 0. False under an ad scope, which estimates nothing.
1305
+ */
1306
+ estimateCovered: z4.boolean().default(false),
1284
1307
  pageViews: z4.number().int().nonnegative(),
1285
1308
  conversions: z4.number().int().nonnegative()
1286
1309
  });
@@ -1305,6 +1328,8 @@ var analyticsLandingRowSchema = z4.object({
1305
1328
  sessions: z4.number().int().nonnegative(),
1306
1329
  /** Sessions that BEGAN here — the page's Visits on screen, summing to the headline, and its rate's denominator. */
1307
1330
  entrances: z4.number().int().nonnegative(),
1331
+ /** How many of {@link entrances} are estimated. */
1332
+ estimatedEntrances: estimatedVisitsSchema,
1308
1333
  visitors: visitorsSchema,
1309
1334
  newVisitors: newVisitorsSchema,
1310
1335
  /**
@@ -1383,7 +1408,10 @@ var ANALYTICS_EVENT_ORIGINS = ["site", "systems", "both"];
1383
1408
  var analyticsCustomEventRowSchema = z4.object({
1384
1409
  eventName: z4.string(),
1385
1410
  events: z4.number().int().nonnegative(),
1411
+ /** Visits that sent it: the real ones, plus {@link estimatedSessions}. */
1386
1412
  sessions: z4.number().int().nonnegative(),
1413
+ /** How many of {@link sessions} are estimated, as {@link analyticsTotalsSchema.estimatedSessions}. */
1414
+ estimatedSessions: estimatedVisitsSchema,
1387
1415
  visitors: z4.number().int().nonnegative(),
1388
1416
  /**
1389
1417
  * The property keys this event carries.
@@ -1414,7 +1442,9 @@ var EVENT_PROPERTY_WITHHELD = "(no consent)";
1414
1442
  var analyticsEventBreakdownRowSchema = z4.object({
1415
1443
  value: z4.string(),
1416
1444
  events: z4.number().int().nonnegative(),
1445
+ /** Visits behind these events, {@link estimatedSessions} included — on `(no consent)`, nearly all of them. */
1417
1446
  sessions: z4.number().int().nonnegative(),
1447
+ estimatedSessions: estimatedVisitsSchema,
1418
1448
  /** Per currency, exactly as {@link analyticsCustomEventRowSchema.money}. */
1419
1449
  money: z4.record(z4.string(), z4.number()).default({})
1420
1450
  });
@@ -1431,7 +1461,9 @@ var analyticsEventTrendPointSchema = z4.object({
1431
1461
  /** The `--property` value this series counts; absent when no property was asked. */
1432
1462
  value: z4.string().optional(),
1433
1463
  events: z4.number().int().nonnegative(),
1434
- sessions: z4.number().int().nonnegative()
1464
+ /** Visits behind the bucket's events, {@link estimatedSessions} included. */
1465
+ sessions: z4.number().int().nonnegative(),
1466
+ estimatedSessions: estimatedVisitsSchema
1435
1467
  });
1436
1468
  var analyticsCustomFunnelTrendPointSchema = z4.object({
1437
1469
  bucket: z4.string(),
@@ -1451,7 +1483,15 @@ var analyticsCustomFunnelStepSchema = z4.object({
1451
1483
  var analyticsDeviceRowSchema = z4.object({
1452
1484
  /** The bucket label — `Chrome 120.0`, `iOS 17.4`, `380–767`. */
1453
1485
  bucket: z4.string(),
1486
+ /** Visits: the real sessions, plus {@link estimatedSessions}. */
1454
1487
  sessions: z4.number().int().nonnegative(),
1488
+ /**
1489
+ * How many of {@link sessions} are visits of visitors who did not allow
1490
+ * analytics, estimated from the pages they arrived on. Their rows carry no
1491
+ * version, model or viewport, so they fall under the family's own bucket
1492
+ * (`Chrome`, `iOS`, the device type, `(not reported)`).
1493
+ */
1494
+ estimatedSessions: estimatedVisitsSchema,
1455
1495
  pageViews: z4.number().int().nonnegative(),
1456
1496
  convertingSessions: z4.number().int().nonnegative(),
1457
1497
  conversions: z4.number().int().nonnegative(),
@@ -1479,6 +1519,8 @@ var analyticsPageRowSchema = z4.object({
1479
1519
  pageViews: z4.number().int().nonnegative(),
1480
1520
  /** Sessions that began on this page — its value as a landing page. */
1481
1521
  entrances: z4.number().int().nonnegative(),
1522
+ /** How many of {@link entrances} are estimated. */
1523
+ estimatedEntrances: estimatedVisitsSchema,
1482
1524
  /**
1483
1525
  * Conversions that fired ON this page — "which page converts".
1484
1526
  *
@@ -1506,6 +1548,7 @@ var analyticsSourceRowSchema = z4.object({
1506
1548
  source: z4.string(),
1507
1549
  medium: z4.string(),
1508
1550
  sessions: z4.number().int().nonnegative(),
1551
+ estimatedSessions: estimatedVisitsSchema,
1509
1552
  conversions: z4.number().int().nonnegative(),
1510
1553
  conversionRate: z4.number().min(0).max(1).nullable()
1511
1554
  });
@@ -1528,6 +1571,7 @@ var analyticsCampaignRowSchema = z4.object({
1528
1571
  */
1529
1572
  clickPlatform: z4.string(),
1530
1573
  sessions: z4.number().int().nonnegative(),
1574
+ estimatedSessions: estimatedVisitsSchema,
1531
1575
  conversions: z4.number().int().nonnegative(),
1532
1576
  conversionRate: z4.number().min(0).max(1).nullable()
1533
1577
  });
@@ -1554,6 +1598,7 @@ var analyticsRealtimeSchema = z4.object({
1554
1598
  var analyticsDimensionRowSchema = z4.object({
1555
1599
  key: z4.string(),
1556
1600
  sessions: z4.number().int().nonnegative(),
1601
+ estimatedSessions: estimatedVisitsSchema,
1557
1602
  conversions: z4.number().int().nonnegative(),
1558
1603
  conversionRate: z4.number().min(0).max(1).nullable()
1559
1604
  });
@@ -1617,7 +1662,14 @@ var analyticsFunnelSchema = z4.object({
1617
1662
  * mid-flow Calendly node reports zero submits and every one of its real
1618
1663
  * bookings here.
1619
1664
  */
1620
- convertedSessions: z4.number().int().nonnegative()
1665
+ convertedSessions: z4.number().int().nonnegative(),
1666
+ /**
1667
+ * Visits by people who did not allow analytics that opened the Form,
1668
+ * estimated from their views of its first screen. In none of the counts
1669
+ * above: a visit nobody may identify cannot be followed from step to step,
1670
+ * so the funnel is real visits only and this says how many it leaves out.
1671
+ */
1672
+ unconsentedVisits: z4.number().int().nonnegative().default(0)
1621
1673
  });
1622
1674
  var analyticsPaidRowSchema = z4.object({
1623
1675
  source: z4.string(),
@@ -1726,9 +1778,12 @@ var analyticsGeoRowSchema = z4.object({
1726
1778
  /** Always carried: a postcode without its country is ambiguous, a city twice over. */
1727
1779
  country: z4.string(),
1728
1780
  region: z4.string(),
1781
+ /** Visits: the real sessions, plus {@link estimatedSessions}. */
1729
1782
  sessions: z4.number().int().nonnegative(),
1783
+ /** How many of {@link sessions} are visits of visitors who did not allow analytics, estimated. No postcode: theirs is not kept. */
1784
+ estimatedSessions: estimatedVisitsSchema,
1730
1785
  conversions: z4.number().int().nonnegative(),
1731
- /** Conversions per session, 0–1. Null below a usable sample. */
1786
+ /** Converting visits per visit, estimated ones on both sides, 0–1. Null below a usable sample. */
1732
1787
  conversionRate: z4.number().min(0).max(1).nullable(),
1733
1788
  /** People rather than browsers, where the visit identified itself. */
1734
1789
  identifiedPeople: z4.number().int().nonnegative()
@@ -1816,9 +1871,23 @@ var analyticsWarningSchema = z4.object({
1816
1871
  });
1817
1872
  var analyticsFlowSummarySchema = z4.object({
1818
1873
  flowSlug: z4.string(),
1874
+ /** Visits that opened the Form: the real ones, plus {@link estimatedSessions}. */
1819
1875
  sessions: z4.number().int().nonnegative(),
1876
+ /**
1877
+ * How many of {@link sessions} are visits of visitors who did not allow
1878
+ * analytics, estimated from their views of the Form's first screen. They are
1879
+ * in {@link convertedSessions} too, estimated alike, and in nothing else here:
1880
+ * `starts` and the steps are real visits only.
1881
+ */
1882
+ estimatedSessions: estimatedVisitsSchema,
1820
1883
  starts: z4.number().int().nonnegative(),
1821
1884
  convertedSessions: z4.number().int().nonnegative(),
1885
+ /**
1886
+ * How many of {@link convertedSessions} are estimated. A screen that shows
1887
+ * the Form's steps, which are real visits only, shows the real half and
1888
+ * states the estimate beside it, so the two never read as one number.
1889
+ */
1890
+ estimatedConvertedSessions: estimatedVisitsSchema,
1822
1891
  submits: z4.number().int().nonnegative(),
1823
1892
  stepViews: z4.number().int().nonnegative(),
1824
1893
  /** Distinct steps anyone reached, across all visits. */
@@ -1838,7 +1907,10 @@ var analyticsFlowSummarySchema = z4.object({
1838
1907
  var analyticsFlowTrendPointSchema = z4.object({
1839
1908
  bucket: z4.string(),
1840
1909
  flowSlug: z4.string(),
1910
+ /** Visits that opened the Form in the bucket, {@link estimatedSessions} included. */
1841
1911
  sessions: z4.number().int().nonnegative(),
1912
+ /** How many of {@link sessions} are estimated, as `analyticsFlowSummarySchema` counts them. */
1913
+ estimatedSessions: estimatedVisitsSchema,
1842
1914
  starts: z4.number().int().nonnegative(),
1843
1915
  convertedSessions: z4.number().int().nonnegative(),
1844
1916
  submits: z4.number().int().nonnegative()
@@ -2937,4 +3009,4 @@ export {
2937
3009
  EVENT_PROPERTY_WITHHELD,
2938
3010
  analyticsTimelineRowSchema
2939
3011
  };
2940
- //# sourceMappingURL=chunk-PC37FCEC.js.map
3012
+ //# sourceMappingURL=chunk-T7GAC2WG.js.map