@aglyn/plugins-marketing 1.0.0-beta.143

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 (183) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +7 -0
  3. package/package.json +56 -0
  4. package/src/index.d.ts +19 -0
  5. package/src/index.js +20 -0
  6. package/src/index.js.map +1 -0
  7. package/src/lib/components/announcement-bar-card.component.d.ts +20 -0
  8. package/src/lib/components/announcement-bar-card.component.js +292 -0
  9. package/src/lib/components/announcement-bar-card.component.js.map +1 -0
  10. package/src/lib/components/campaign-composer.d.ts +84 -0
  11. package/src/lib/components/campaign-composer.js +1643 -0
  12. package/src/lib/components/campaign-composer.js.map +1 -0
  13. package/src/lib/components/campaign-conversions-card.d.ts +22 -0
  14. package/src/lib/components/campaign-conversions-card.js +642 -0
  15. package/src/lib/components/campaign-conversions-card.js.map +1 -0
  16. package/src/lib/components/campaign-detail-card.d.ts +55 -0
  17. package/src/lib/components/campaign-detail-card.js +771 -0
  18. package/src/lib/components/campaign-detail-card.js.map +1 -0
  19. package/src/lib/components/campaign-edit-drawer.d.ts +60 -0
  20. package/src/lib/components/campaign-edit-drawer.js +252 -0
  21. package/src/lib/components/campaign-edit-drawer.js.map +1 -0
  22. package/src/lib/components/campaign-email-zones.d.ts +111 -0
  23. package/src/lib/components/campaign-email-zones.js +54 -0
  24. package/src/lib/components/campaign-email-zones.js.map +1 -0
  25. package/src/lib/components/campaign-glance-card.component.d.ts +18 -0
  26. package/src/lib/components/campaign-glance-card.component.js +151 -0
  27. package/src/lib/components/campaign-glance-card.component.js.map +1 -0
  28. package/src/lib/components/campaign-members-section.d.ts +87 -0
  29. package/src/lib/components/campaign-members-section.js +499 -0
  30. package/src/lib/components/campaign-members-section.js.map +1 -0
  31. package/src/lib/components/campaign-reach-sections.d.ts +137 -0
  32. package/src/lib/components/campaign-reach-sections.js +694 -0
  33. package/src/lib/components/campaign-reach-sections.js.map +1 -0
  34. package/src/lib/components/campaign-report-card.d.ts +91 -0
  35. package/src/lib/components/campaign-report-card.js +667 -0
  36. package/src/lib/components/campaign-report-card.js.map +1 -0
  37. package/src/lib/components/campaign-test-send-drawer.d.ts +45 -0
  38. package/src/lib/components/campaign-test-send-drawer.js +238 -0
  39. package/src/lib/components/campaign-test-send-drawer.js.map +1 -0
  40. package/src/lib/components/campaigns-card.d.ts +31 -0
  41. package/src/lib/components/campaigns-card.js +667 -0
  42. package/src/lib/components/campaigns-card.js.map +1 -0
  43. package/src/lib/components/conversion-attribution.component.d.ts +62 -0
  44. package/src/lib/components/conversion-attribution.component.js +127 -0
  45. package/src/lib/components/conversion-attribution.component.js.map +1 -0
  46. package/src/lib/components/email-compose-card.d.ts +12 -0
  47. package/src/lib/components/email-compose-card.js +157 -0
  48. package/src/lib/components/email-compose-card.js.map +1 -0
  49. package/src/lib/components/email-detail.d.ts +40 -0
  50. package/src/lib/components/email-detail.js +1180 -0
  51. package/src/lib/components/email-detail.js.map +1 -0
  52. package/src/lib/components/email-edit-drawer.d.ts +54 -0
  53. package/src/lib/components/email-edit-drawer.js +172 -0
  54. package/src/lib/components/email-edit-drawer.js.map +1 -0
  55. package/src/lib/components/email-messages-widget.d.ts +22 -0
  56. package/src/lib/components/email-messages-widget.js +49 -0
  57. package/src/lib/components/email-messages-widget.js.map +1 -0
  58. package/src/lib/components/email-recipients-card.d.ts +50 -0
  59. package/src/lib/components/email-recipients-card.js +338 -0
  60. package/src/lib/components/email-recipients-card.js.map +1 -0
  61. package/src/lib/components/emails-list-card.d.ts +36 -0
  62. package/src/lib/components/emails-list-card.js +544 -0
  63. package/src/lib/components/emails-list-card.js.map +1 -0
  64. package/src/lib/components/experiment-zones.d.ts +78 -0
  65. package/src/lib/components/experiment-zones.js +65 -0
  66. package/src/lib/components/experiment-zones.js.map +1 -0
  67. package/src/lib/components/host-experiments-card.component.d.ts +17 -0
  68. package/src/lib/components/host-experiments-card.component.js +887 -0
  69. package/src/lib/components/host-experiments-card.component.js.map +1 -0
  70. package/src/lib/components/host-marketing-summary-card.component.d.ts +15 -0
  71. package/src/lib/components/host-marketing-summary-card.component.js +161 -0
  72. package/src/lib/components/host-marketing-summary-card.component.js.map +1 -0
  73. package/src/lib/components/host-overlays-card.component.d.ts +19 -0
  74. package/src/lib/components/host-overlays-card.component.js +783 -0
  75. package/src/lib/components/host-overlays-card.component.js.map +1 -0
  76. package/src/lib/components/marketing-console-page.d.ts +28 -0
  77. package/src/lib/components/marketing-console-page.js +166 -0
  78. package/src/lib/components/marketing-console-page.js.map +1 -0
  79. package/src/lib/components/marketing-console-sections.d.ts +34 -0
  80. package/src/lib/components/marketing-console-sections.js +77 -0
  81. package/src/lib/components/marketing-console-sections.js.map +1 -0
  82. package/src/lib/components/overlay-stats-row.component.d.ts +15 -0
  83. package/src/lib/components/overlay-stats-row.component.js +78 -0
  84. package/src/lib/components/overlay-stats-row.component.js.map +1 -0
  85. package/src/lib/components/popup-card.component.d.ts +18 -0
  86. package/src/lib/components/popup-card.component.js +462 -0
  87. package/src/lib/components/popup-card.component.js.map +1 -0
  88. package/src/lib/components/record-attribution-widget.d.ts +35 -0
  89. package/src/lib/components/record-attribution-widget.js +33 -0
  90. package/src/lib/components/record-attribution-widget.js.map +1 -0
  91. package/src/lib/components/site-runtime.d.ts +9 -0
  92. package/src/lib/components/site-runtime.js +1081 -0
  93. package/src/lib/components/site-runtime.js.map +1 -0
  94. package/src/lib/components/use-campaign-send-api.d.ts +35 -0
  95. package/src/lib/components/use-campaign-send-api.js +99 -0
  96. package/src/lib/components/use-campaign-send-api.js.map +1 -0
  97. package/src/lib/components/use-campaign-topic-options.d.ts +20 -0
  98. package/src/lib/components/use-campaign-topic-options.js +44 -0
  99. package/src/lib/components/use-campaign-topic-options.js.map +1 -0
  100. package/src/lib/components/use-emails-hub-path.d.ts +39 -0
  101. package/src/lib/components/use-emails-hub-path.js +70 -0
  102. package/src/lib/components/use-emails-hub-path.js.map +1 -0
  103. package/src/lib/components/use-marketing-hub-path.d.ts +21 -0
  104. package/src/lib/components/use-marketing-hub-path.js +50 -0
  105. package/src/lib/components/use-marketing-hub-path.js.map +1 -0
  106. package/src/lib/components/use-overlay-copy-editor.d.ts +79 -0
  107. package/src/lib/components/use-overlay-copy-editor.js +110 -0
  108. package/src/lib/components/use-overlay-copy-editor.js.map +1 -0
  109. package/src/lib/constants/bundle-common.d.ts +8 -0
  110. package/src/lib/constants/bundle-common.js +9 -0
  111. package/src/lib/constants/bundle-common.js.map +1 -0
  112. package/src/lib/model/campaign-membership-figures.d.ts +109 -0
  113. package/src/lib/model/campaign-membership-figures.js +113 -0
  114. package/src/lib/model/campaign-membership-figures.js.map +1 -0
  115. package/src/lib/model/compile-client-automations.d.ts +65 -0
  116. package/src/lib/model/compile-client-automations.js +95 -0
  117. package/src/lib/model/compile-client-automations.js.map +1 -0
  118. package/src/lib/model/experiments.d.ts +130 -0
  119. package/src/lib/model/experiments.js +186 -0
  120. package/src/lib/model/experiments.js.map +1 -0
  121. package/src/lib/model/index.d.ts +26 -0
  122. package/src/lib/model/index.js +26 -0
  123. package/src/lib/model/index.js.map +1 -0
  124. package/src/lib/model/marketing-record-routes.d.ts +6 -0
  125. package/src/lib/model/marketing-record-routes.js +46 -0
  126. package/src/lib/model/marketing-record-routes.js.map +1 -0
  127. package/src/lib/model/overlay-copy.d.ts +62 -0
  128. package/src/lib/model/overlay-copy.js +78 -0
  129. package/src/lib/model/overlay-copy.js.map +1 -0
  130. package/src/lib/model/overlays.d.ts +113 -0
  131. package/src/lib/model/overlays.js +93 -0
  132. package/src/lib/model/overlays.js.map +1 -0
  133. package/src/lib/model/site-contract.d.ts +100 -0
  134. package/src/lib/model/site-contract.js +23 -0
  135. package/src/lib/model/site-contract.js.map +1 -0
  136. package/src/lib/plugin.d.ts +27 -0
  137. package/src/lib/plugin.js +168 -0
  138. package/src/lib/plugin.js.map +1 -0
  139. package/src/lib/preview-props.d.ts +31 -0
  140. package/src/lib/preview-props.js +54 -0
  141. package/src/lib/preview-props.js.map +1 -0
  142. package/src/lib/server/campaign-manage.d.ts +62 -0
  143. package/src/lib/server/campaign-manage.js +829 -0
  144. package/src/lib/server/campaign-manage.js.map +1 -0
  145. package/src/lib/server/campaign-process-scheduled.d.ts +26 -0
  146. package/src/lib/server/campaign-process-scheduled.js +198 -0
  147. package/src/lib/server/campaign-process-scheduled.js.map +1 -0
  148. package/src/lib/server/campaign-recipients.d.ts +55 -0
  149. package/src/lib/server/campaign-recipients.js +219 -0
  150. package/src/lib/server/campaign-recipients.js.map +1 -0
  151. package/src/lib/server/campaign-send.d.ts +487 -0
  152. package/src/lib/server/campaign-send.js +3157 -0
  153. package/src/lib/server/campaign-send.js.map +1 -0
  154. package/src/lib/server/email-campaign-reach.d.ts +174 -0
  155. package/src/lib/server/email-campaign-reach.js +254 -0
  156. package/src/lib/server/email-campaign-reach.js.map +1 -0
  157. package/src/lib/server/email-events.d.ts +27 -0
  158. package/src/lib/server/email-events.js +714 -0
  159. package/src/lib/server/email-events.js.map +1 -0
  160. package/src/lib/server/get-client-automations.d.ts +60 -0
  161. package/src/lib/server/get-client-automations.js +87 -0
  162. package/src/lib/server/get-client-automations.js.map +1 -0
  163. package/src/lib/server/get-overlays.d.ts +28 -0
  164. package/src/lib/server/get-overlays.js +65 -0
  165. package/src/lib/server/get-overlays.js.map +1 -0
  166. package/src/lib/server/get-screen-experiments.d.ts +42 -0
  167. package/src/lib/server/get-screen-experiments.js +82 -0
  168. package/src/lib/server/get-screen-experiments.js.map +1 -0
  169. package/src/lib/server/lists-materialize.d.ts +18 -0
  170. package/src/lib/server/lists-materialize.js +130 -0
  171. package/src/lib/server/lists-materialize.js.map +1 -0
  172. package/src/lib/server/marketing-figures.d.ts +37 -0
  173. package/src/lib/server/marketing-figures.js +248 -0
  174. package/src/lib/server/marketing-figures.js.map +1 -0
  175. package/src/lib/server/site-page-enricher.d.ts +26 -0
  176. package/src/lib/server/site-page-enricher.js +210 -0
  177. package/src/lib/server/site-page-enricher.js.map +1 -0
  178. package/src/lib/server.d.ts +20 -0
  179. package/src/lib/server.js +152 -0
  180. package/src/lib/server.js.map +1 -0
  181. package/src/lib/site.d.ts +22 -0
  182. package/src/lib/site.js +48 -0
  183. package/src/lib/site.js.map +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/marketing/src/lib/components/campaign-reach-sections.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { AppLink } from '@aglyn/shared-ui-jsx'\nimport {\n Figure,\n MoneyFigure,\n Section,\n} from '@aglyn/shared-ui-email-campaigns/components/report-figures'\nimport { ListPagination } from '@aglyn/shared-ui-jsx/components/list-pagination.component'\nimport { TABLE_PAGE_SIZE_DEFAULT } from '@aglyn/shared-ui-jsx/const/table-pagination'\nimport { ScrollTable } from '@aglyn/shared-ui-jsx/components/scroll-table.component'\nimport {\n Alert,\n Button,\n Stack,\n TableBody,\n TableCell,\n TableHead,\n TableRow,\n Typography,\n} from '@mui/material'\nimport {\n collection,\n doc,\n getCountFromServer,\n getDoc,\n query,\n where,\n} from 'firebase/firestore'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport { useFirestore } from '@aglyn/tenant-feature-instance'\nimport {\n campaignRevenueAcrossSends,\n CAMPAIGN_CONVERSION_KINDS,\n CAMPAIGN_CONVERSION_KIND_COPY,\n EMAIL_ATTRIBUTION_WINDOW_DAYS,\n type CampaignConversionKind,\n type CampaignLinkRollup,\n type CampaignRevenueAcrossSends,\n type CampaignRevenueRollup,\n} from '@aglyn/shared-ui-email-campaigns/model'\n\n/**\n * A CAMPAIGN BEYOND ITS MAIL — what it caused, what it earned, and where it\n * sent people.\n *\n * ## Attribution is the mechanism, and there is no other one\n *\n * A campaign owns no screen, no form and no overlay. Nothing in the stored\n * model connects `emailCampaigns/{id}` to a page a visitor lands on:\n * `HostExperiment` names a screen and never a campaign, `HostOverlay` names\n * neither, and a form document carries no campaign field. So a section\n * claiming a campaign CONTAINS a landing page would be inventing an edge, and\n * the containment would be a claim nothing in the data supports.\n *\n * What the data does support is EVIDENCE, of two kinds, and both are already\n * being written:\n *\n * - **Where it sent people.** `campaigns/{sendId}/reports/links` counts\n * clicks per destination URL, so the union across a campaign's emails is\n * the set of pages that campaign drove traffic to — observed rather than\n * declared, which is also why it stays true when a marketer re-points a\n * link.\n * - **What it caused there.** `campaignAttributions` records one row per\n * identify moment — a form submission, a lead, a contact, a booking —\n * carrying the SEND whose link the visitor followed.\n * - **What it earned there.** `campaigns/{sendId}/reports/revenue` buckets\n * the orders credited to that send by currency, so the merge across a\n * campaign's emails is what the campaign was credited with — per currency,\n * because the buckets have units and a total across them would not.\n *\n * All three sections below therefore hang off the campaign's own send ids,\n * which is the only handle any of those collections offers.\n *\n * ## What neither section can say, and says so instead\n *\n * A conversion credited to a WEB touch carries `utm_` labels and no send id.\n * A campaign container has no `utm_` label of its own — a marketer types\n * those into a URL — so there is no join to make, and no amount of matching\n * on the campaign's NAME would be one: two campaigns may share a name, and a\n * label is a string anybody who can vary a query string can mint. The\n * site-wide Conversions section is where the web channel is read, and the\n * copy below points at it rather than quietly leaving it out.\n *\n * A conversion with no touch at all is credited to nobody and is in neither\n * collection. The same holds for an order: one placed by somebody who never\n * clicked is credited to no campaign. That makes a page showing only credited\n * outcomes a partial account by construction, which is why the figures are\n * labelled \"credited to this campaign\" everywhere they appear.\n */\n\n/** Firestore's cap on the values in one `in` filter. */\nconst ID_CHUNK = 30\n\nexport interface CampaignReachProps {\n hostId: string\n /**\n * The campaign's emails, by send id — the handle both collections join on.\n *\n * A stable array is not required: both sections key their reads on the\n * joined string, so a caller rebuilding the array every render pays for one\n * set of reads rather than one per render.\n */\n sendIds: readonly string[]\n /** The campaign holds more emails than `sendIds` names. */\n truncated: boolean\n}\n\n/** The ids as one primitive, so an effect depends on the VALUE not the array. */\nconst idsKey = (sendIds: readonly string[]): string => sendIds.join(',')\n\n/** `['a','b','c']` in runs of at most {@link ID_CHUNK}. */\nfunction chunked(ids: readonly string[]): string[][] {\n const out: string[][] = []\n for (let index = 0; index < ids.length; index += ID_CHUNK) {\n out.push(ids.slice(index, index + ID_CHUNK))\n }\n return out\n}\n\n/**\n * WHAT THE CAMPAIGN CAUSED, counted rather than listed.\n *\n * Four aggregation counts over `campaignAttributions`, one per kind, each\n * narrowed to this campaign's own sends. An aggregation is billed per\n * thousand index entries rather than per document, so the honest figure costs\n * about as much as a single row — which is what lets this run on mount\n * instead of behind a button. Listing the records would not: that is the\n * per-record read every figure on this page is arranged to avoid, and the\n * site-wide Conversions section already lists them.\n *\n * The composite index the query needs — `kind` then `campaignId` — is already\n * declared for the conversions list's own campaign-scoped view, and an `in`\n * runs as a disjunction of equalities against that same index.\n *\n * ## The kinds are never added together\n *\n * One form submission by a new person writes a submission, a contact AND a\n * lead: three true statements about one visit. A total would count that visit\n * three times and would look exactly like a bigger number, so there is no\n * total here and the note under the figures says why.\n */\nexport function CampaignConversionsSection(\n props: CampaignReachProps & {\n /** The marketing hub URL, for the site-wide conversions list. */\n basePath: string\n },\n) {\n const { hostId, sendIds, truncated, basePath } = props\n const firestore = useFirestore()\n const key = idsKey(sendIds)\n const [counts, setCounts] = useState<Record<string, number> | null>(null)\n const [failed, setFailed] = useState(false)\n\n useEffect(() => {\n const ids = key ? key.split(',') : []\n setCounts(null)\n setFailed(false)\n if (!ids.length) return\n let active = true\n const attributions = collection(\n firestore,\n 'hosts',\n hostId,\n 'campaignAttributions',\n )\n /*\n * Summed ACROSS chunks, which is safe because a record carries exactly\n * one `campaignId`: the chunks partition the send ids, so no record can\n * be counted by two of them.\n */\n void Promise.all(\n CAMPAIGN_CONVERSION_KINDS.map(async (kind) => {\n const perChunk = await Promise.all(\n chunked(ids).map((chunk) =>\n getCountFromServer(\n query(\n attributions,\n where('kind', '==', kind),\n where('campaignId', 'in', chunk),\n ),\n ).then((snapshot) => Number(snapshot.data().count ?? 0)),\n ),\n )\n return [kind, perChunk.reduce((sum, value) => sum + value, 0)] as const\n }),\n )\n .then((entries) => {\n if (active) setCounts(Object.fromEntries(entries))\n })\n .catch(() => {\n /*\n * WITHHELD, never zeroed. A count that failed and a campaign that\n * caused nothing are opposite facts, and rendering the first as the\n * second is the most flattering wrong answer available here.\n */\n if (active) setFailed(true)\n })\n return () => {\n active = false\n }\n }, [firestore, hostId, key])\n\n return (\n <Section title=\"What it caused\">\n {!key ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No emails have gone out under this campaign, so nothing can be ' +\n 'credited to it yet.'}\n </Typography>\n ) : failed ? (\n <Alert severity=\"warning\">\n {'The conversions credited to this campaign could not be counted.'}\n </Alert>\n ) : !counts ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Counting what this campaign is credited with…'}\n </Typography>\n ) : (\n <Stack spacing={1}>\n <Stack direction=\"row\" spacing={3} sx={{ flexWrap: 'wrap' }}>\n {CAMPAIGN_CONVERSION_KINDS.map((kind: CampaignConversionKind) => (\n <Figure\n key={kind}\n label={CAMPAIGN_CONVERSION_KIND_COPY[kind].label}\n value={counts[kind] ?? 0}\n note={CAMPAIGN_CONVERSION_KIND_COPY[kind].note}\n />\n ))}\n </Stack>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'These count different things about the same visits and are ' +\n 'deliberately not added together — one person filling in one ' +\n 'form appears as a submission, a contact and a lead.'}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Credited to this campaign’s own emails. Somebody who arrived ' +\n 'from a link tagged with utm_ parameters is credited to that ' +\n 'label instead, and somebody who arrived directly is credited ' +\n 'to nobody — both are counted on the site’s conversions list.'}\n </Typography>\n {truncated ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Over the emails listed below. This campaign has sent more ' +\n 'than the page holds, and their conversions are not in these ' +\n 'figures.'}\n </Typography>\n ) : null}\n </Stack>\n )}\n <Stack direction=\"row\">\n <Button\n component={AppLink as any}\n {...({ componentVariant: 'naked', nativeButton: false } as any)}\n href={`${basePath}/conversions`}\n size=\"small\"\n color=\"primary\"\n >\n {'All conversions'}\n </Button>\n </Stack>\n </Section>\n )\n}\nCampaignConversionsSection.displayName = 'CampaignConversionsSection'\n\n/**\n * The rule the amounts were credited under, in the sentence a reader can\n * check them against.\n *\n * Plural where the campaign is plural. A container can hold emails credited\n * under different models or windows, and printing one of them as though it\n * governed all of them would be the same lie as printing one currency symbol\n * over two currencies.\n */\nfunction creditedUnder(report: CampaignRevenueAcrossSends): string {\n const model = report.models.length === 1 ? report.models[0] : ''\n const rule =\n model === 'last-click'\n ? 'to the last campaign whose link the buyer clicked'\n : model\n ? `under the ${model} model`\n : 'under more than one attribution model'\n const window =\n report.windowDays.length === 1\n ? `within ${report.windowDays[0]} days of that click`\n : `within ${report.windowDays.join(' or ')} days of that click, ` +\n 'depending on the email'\n return `Credited ${rule}, ${window}.`\n}\n\n/**\n * WHAT THE CAMPAIGN EARNED — per currency, and never across them.\n *\n * The same question a campaign of one email answers, answered the same way by\n * a campaign of several: how many messages a container happens to hold is not\n * a fact about whether its revenue is knowable. So this is the same section\n * the single-send report carries — `Revenue`, in the same place in the page's\n * order, drawn by the same money components — over a merge rather than over\n * one document.\n *\n * ## Why it takes a merge, and what the merge may not do\n *\n * `reports/revenue` is written per SEND. There is no container-level rollup\n * and there should not be one: it would have to be kept true against every\n * order and every refund of every email in the campaign, duplicating figures\n * that are already correct one level down. So the campaign's figure is one\n * document per email and an addition — and the addition is the danger.\n *\n * **Currency is to money what kind is to a conversion.** The section above\n * refuses to total form submissions with leads because one visit writes both;\n * this refuses to total USD with EUR because the sum has no unit. Both\n * refusals are structural rather than remembered:\n * {@link campaignRevenueAcrossSends} keys its accumulator on the currency, so\n * amounts in different currencies never reach the same addition, and the\n * result carries no combined field for a screen to print.\n *\n * ## One currency reads as one figure; several read as several\n *\n * The common case is one currency, and it is drawn exactly as a single\n * email's report draws it — net, gross, refunded, orders — with no currency\n * heading, because a label saying `USD` over a page that only ever shows\n * dollars is noise. The moment a second currency appears every block gets its\n * code as a heading and its own email count, and a caveat says in words what\n * the headings say in layout: these do not add up, and nothing here converts\n * between them. The rare case pays for itself; the common one does not pay\n * for the rare one.\n *\n * ## Behind a button, and the button says the price\n *\n * One document per email — the per-record read the conversions section above\n * is shaped to avoid. That section can run on mount because an aggregation is\n * billed per thousand index entries, so its four honest figures cost about as\n * much as a single row however large the campaign is. This cannot: fifty\n * emails is fifty document reads, every time the page opens, for a section\n * most readers of a campaign are not opening the page for. So it is asked\n * for, at the same control and in the same words as the destinations section\n * below, which buys its rows the same way.\n *\n * ## Nothing, and nothing readable, are different sentences\n *\n * The rollup is created by the writer on the first order it credits, so an\n * email with no record has never earned. A campaign where NO email has one\n * has not been shown to have earned nothing — it is also every campaign sent\n * before the join existed and every campaign on a site with no store, which\n * is the distinction the single-send report draws in the same two sentences.\n * A read that is REFUSED shows neither: the figures are withheld behind a\n * warning, and any figures already on screen are dropped rather than left\n * standing beside it, because a stale total under a fresh error is the one\n * arrangement that looks authoritative and is not.\n */\nexport function CampaignRevenueSection(props: CampaignReachProps) {\n const { hostId, sendIds, truncated } = props\n const firestore = useFirestore()\n const key = idsKey(sendIds)\n const [busy, setBusy] = useState(false)\n const [error, setError] = useState<string | null>(null)\n const [report, setReport] = useState<CampaignRevenueAcrossSends | null>(null)\n\n // A merge over one set of emails describes that set. Leaving it on screen\n // after the campaign's emails change labels it as something it is not.\n useEffect(() => {\n setReport(null)\n setError(null)\n }, [key])\n\n const load = useCallback(async () => {\n if (busy) return\n const ids = key ? key.split(',') : []\n if (!ids.length) return\n setBusy(true)\n setError(null)\n try {\n const snapshots = await Promise.all(\n ids.map((id) =>\n getDoc(\n doc(\n firestore,\n 'hosts',\n hostId,\n 'campaigns',\n id,\n 'reports',\n 'revenue',\n ),\n ),\n ),\n )\n /*\n * `data()` is `undefined` on a document that does not exist, and it is\n * handed on as `undefined` rather than as an empty rollup: the merge\n * counts the records that EXIST to tell a campaign that earned nothing\n * from one whose revenue was never recorded at all.\n */\n setReport(\n campaignRevenueAcrossSends(\n snapshots.map(\n (snapshot) => snapshot.data() as CampaignRevenueRollup | undefined,\n ),\n ),\n )\n } catch (caught) {\n console.error(caught)\n /*\n * WITHHELD, never zeroed and never left stale. A refused read and a\n * campaign that earned nothing are opposite facts, and the second is\n * the more flattering of the two.\n */\n setReport(null)\n setError('The revenue credited to this campaign could not be read')\n } finally {\n setBusy(false)\n }\n }, [busy, firestore, hostId, key])\n\n const count = key ? key.split(',').length : 0\n\n return (\n <Section title=\"Revenue\">\n {!count ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No emails have gone out under this campaign, so nothing can be ' +\n 'credited to it yet.'}\n </Typography>\n ) : (\n <Stack spacing={1}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'What this campaign’s emails were credited with, read from each ' +\n 'email’s own revenue record and merged by currency.'}\n </Typography>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Button size=\"small\" onClick={() => void load()} disabled={busy}>\n {busy ? 'Reading…' : report ? 'Read again' : 'Show revenue'}\n </Button>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Reads one record per email — ${count.toLocaleString()} of them.`}\n </Typography>\n </Stack>\n {error ? <Alert severity=\"warning\">{error}</Alert> : null}\n {report ? (\n report.currencies.length ? (\n <Stack spacing={3}>\n {report.caveats.map((caveat) => (\n <Alert key={caveat.id} severity=\"info\">\n {caveat.message}\n </Alert>\n ))}\n {report.currencies.map((entry) => (\n <Stack key={entry.currency} spacing={1}>\n {/*\n * The currency is a HEADING when there is more than one\n * and absent when there is one — the single-send report's\n * rule, so the two shapes of campaign page read alike.\n */}\n {report.multiCurrency ? (\n <Typography variant=\"subtitle2\">\n {entry.currency.toUpperCase()}\n </Typography>\n ) : null}\n <Stack\n direction=\"row\"\n spacing={4}\n useFlexGap\n sx={{ flexWrap: 'wrap' }}\n >\n <MoneyFigure\n label=\"Net revenue\"\n cents={entry.netCents}\n currency={entry.currency}\n note=\"after refunds\"\n />\n <MoneyFigure\n label=\"Gross revenue\"\n cents={entry.grossCents}\n currency={entry.currency}\n note=\"as charged\"\n />\n <MoneyFigure\n label=\"Refunded\"\n cents={entry.refundedCents}\n currency={entry.currency}\n note=\"handed back\"\n />\n <Figure\n label=\"Orders\"\n value={entry.orders}\n note=\"credited to this campaign\"\n />\n <Figure\n label=\"Fully refunded\"\n value={entry.refundedOrders}\n note=\"of those orders\"\n />\n {/*\n * Only where it says something. With one currency this\n * repeats the coverage line under the figures; with\n * two it is what shows the blocks are disjoint parts of\n * the campaign rather than two views of all of it.\n */}\n {report.multiCurrency ? (\n <Figure\n label=\"Emails\"\n value={entry.emails}\n note={`earned in ${entry.currency.toUpperCase()}`}\n />\n ) : null}\n </Stack>\n </Stack>\n ))}\n {/*\n * NO PER-MESSAGE AVERAGE, and this is where a reader of the\n * single-send report would look for one. That page divides by\n * the send's own delivered count, read from the same document\n * at the same instant. A campaign has no such pair — its\n * revenue covers the emails with a revenue record and its\n * delivery total covers the emails that recorded a delivery\n * count, which are different subsets — so the quotient would\n * be an average over a population nobody named.\n */}\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`${report.attributedOrders.toLocaleString()} ` +\n `${report.attributedOrders === 1 ? 'order' : 'orders'} ` +\n `credited, across ${report.recorded.toLocaleString()} of ` +\n `this campaign’s ${report.read.toLocaleString()} ` +\n `${report.read === 1 ? 'email' : 'emails'}. The rest have ` +\n 'never been credited with a sale.'}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`${creditedUnder(report)} Clicks only — an open is not ` +\n 'treated as evidence that anybody read the email. An ' +\n 'order placed by somebody who never clicked, or who ' +\n 'checked out without giving an address, is credited to no ' +\n 'campaign, so this is a floor rather than every sale this ' +\n 'campaign influenced.'}\n </Typography>\n </Stack>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {report.recorded\n ? 'No orders have been credited to this campaign.'\n : 'No revenue has been attributed to any of this ' +\n 'campaign’s emails. Orders are credited to the last ' +\n 'campaign whose link the buyer clicked, within ' +\n `${EMAIL_ATTRIBUTION_WINDOW_DAYS} days — emails sent ` +\n 'before that was recorded, or a site with no store, will ' +\n 'never show a figure here.'}\n </Typography>\n )\n ) : null}\n {/*\n OUTSIDE both branches, because it qualifies both. A campaign that\n reports nothing over the emails this page holds has not reported\n nothing about itself, and the emptier answer is the one that most\n needs its population named.\n */}\n {report && truncated ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Across the ${report.read.toLocaleString()} emails this page ` +\n 'holds. The campaign has sent more.'}\n </Typography>\n ) : null}\n </Stack>\n )}\n </Section>\n )\n}\nCampaignRevenueSection.displayName = 'CampaignRevenueSection'\n\n/** One destination, summed across the campaign's emails. */\ninterface DestinationRow {\n url: string\n clicks: number\n /** How many of the campaign's emails carried a link to it. */\n emails: number\n}\n\n/** What one pass over the campaign's link rollups produced. */\ninterface DestinationsResult {\n rows: DestinationRow[]\n /** Emails whose rollup was read, which is the population the rows describe. */\n read: number\n /** Clicks on destinations past each email's own rollup cap. */\n overflowClicks: number\n /** Clicks that arrived naming no destination at all. */\n unattributedClicks: number\n}\n\n/**\n * WHERE THE CAMPAIGN SENT PEOPLE — the pages its mail pointed at.\n *\n * The union of `campaigns/{sendId}/reports/links` across the campaign's\n * emails, which is the closest the stored data comes to \"the surfaces this\n * campaign runs across\". It is observed rather than declared: a page is on\n * this list because a link in this campaign's mail was followed to it.\n *\n * ## Behind a button, and the button says the price\n *\n * One document per email, up to the ceiling the page holds — which is the\n * per-record read the figures above are shaped to avoid, so it is asked for\n * rather than paid on mount. The same bargain the conversions list makes for\n * its landing-page grouping.\n *\n * ## What a row is, and what it is not\n *\n * A destination is the link's address with its query string dropped, because\n * a campaign body is merged per recipient and a personalised query would mint\n * one row per person — and could carry that person's address into an\n * aggregate the whole team reads. The cost is that two links to one page\n * distinguished only by their tracking parameters are one row, which the note\n * under the table states rather than leaving the reader to discover.\n *\n * Clicks are EVENTS. One reader clicking twice counts twice, so a destination\n * total is not a count of people.\n */\nexport function CampaignDestinationsSection(props: CampaignReachProps) {\n const { hostId, sendIds, truncated } = props\n const firestore = useFirestore()\n const key = idsKey(sendIds)\n const [busy, setBusy] = useState(false)\n const [error, setError] = useState<string | null>(null)\n const [result, setResult] = useState<DestinationsResult | null>(null)\n /*\n * The page is a SLICE of a window this section already holds. One campaign\n * can reach fifty destinations per email over fifty emails, so the row\n * count is bounded by the rollups rather than small — and a table that\n * grows with the campaign gets a footer like every other one.\n */\n const [page, setPage] = useState(0)\n const [pageSize, setPageSize] = useState(TABLE_PAGE_SIZE_DEFAULT)\n const visibleRows = useMemo(\n () => (result?.rows ?? []).slice(page * pageSize, page * pageSize + pageSize),\n [result, page, pageSize],\n )\n\n // A grouping read for one set of emails describes that set. Leaving it on\n // screen after the campaign's emails change labels it as something it is not.\n useEffect(() => {\n setResult(null)\n setError(null)\n setPage(0)\n }, [key])\n\n const load = useCallback(async () => {\n if (busy) return\n const ids = key ? key.split(',') : []\n if (!ids.length) return\n setBusy(true)\n setError(null)\n try {\n const snapshots = await Promise.all(\n ids.map((id) =>\n getDoc(\n doc(\n firestore,\n 'hosts',\n hostId,\n 'campaigns',\n id,\n 'reports',\n 'links',\n ),\n ),\n ),\n )\n const byUrl = new Map<string, DestinationRow>()\n let overflowClicks = 0\n let unattributedClicks = 0\n snapshots.forEach((snapshot) => {\n const rollup = snapshot.data() as CampaignLinkRollup | undefined\n if (!rollup) return\n overflowClicks += Number(rollup.overflowClicks ?? 0)\n unattributedClicks += Number(rollup.unattributedClicks ?? 0)\n Object.values(rollup.links ?? {}).forEach((entry) => {\n const url = String(entry?.url ?? '').trim()\n if (!url) return\n const row = byUrl.get(url) ?? { url, clicks: 0, emails: 0 }\n row.clicks += Number(entry?.clicks ?? 0)\n // One rollup holds at most one entry per destination, so this\n // counts EMAILS that linked there rather than link occurrences.\n row.emails += 1\n byUrl.set(url, row)\n })\n })\n setPage(0)\n setResult({\n rows: [...byUrl.values()].sort(\n (a, b) => b.clicks - a.clicks || a.url.localeCompare(b.url),\n ),\n read: ids.length,\n overflowClicks,\n unattributedClicks,\n })\n } catch (caught) {\n console.error(caught)\n setError('The destinations could not be read')\n } finally {\n setBusy(false)\n }\n }, [busy, firestore, hostId, key])\n\n const count = key ? key.split(',').length : 0\n\n return (\n <Section title=\"Where it sent people\">\n {!count ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No emails have gone out under this campaign, so it has sent ' +\n 'nobody anywhere yet.'}\n </Typography>\n ) : (\n <Stack spacing={1}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'The pages this campaign’s links were followed to. A campaign ' +\n 'does not own a page — this is where its mail actually sent ' +\n 'people, read from each email’s own click report.'}\n </Typography>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Button size=\"small\" onClick={() => void load()} disabled={busy}>\n {busy ? 'Reading…' : result ? 'Read again' : 'Show destinations'}\n </Button>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Reads one record per email — ${count.toLocaleString()} of them.`}\n </Typography>\n </Stack>\n {error ? <Alert severity=\"warning\">{error}</Alert> : null}\n {result ? (\n result.rows.length ? (\n <Stack spacing={0.5}>\n <ScrollTable size=\"small\">\n <TableHead>\n <TableRow>\n <TableCell>{'Destination'}</TableCell>\n <TableCell align=\"right\">{'Emails'}</TableCell>\n <TableCell align=\"right\">{'Clicks'}</TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {visibleRows.map((row) => (\n <TableRow key={row.url}>\n <TableCell sx={{ wordBreak: 'break-all' }}>\n {row.url}\n </TableCell>\n <TableCell align=\"right\">\n {row.emails.toLocaleString()}\n </TableCell>\n <TableCell align=\"right\">\n {row.clicks.toLocaleString()}\n </TableCell>\n </TableRow>\n ))}\n </TableBody>\n </ScrollTable>\n <ListPagination\n page={page}\n pageSize={pageSize}\n rowCount={visibleRows.length}\n count={result.rows.length}\n onPageChange={setPage}\n onPageSizeChange={setPageSize}\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'A destination is the address without its query string, ' +\n 'so two links to one page that differ only in their ' +\n 'tracking parameters are one row. Clicks are events — ' +\n 'one reader clicking twice counts twice.'}\n </Typography>\n {result.overflowClicks ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`${result.overflowClicks.toLocaleString()} further ` +\n 'clicks landed on destinations past the per-email cap ' +\n 'and are not in the table.'}\n </Typography>\n ) : null}\n {result.unattributedClicks ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`${result.unattributedClicks.toLocaleString()} clicks ` +\n 'arrived naming no destination, so they belong to no ' +\n 'row.'}\n </Typography>\n ) : null}\n {truncated ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Across the ${result.read.toLocaleString()} emails this ` +\n 'page holds. The campaign has sent more.'}\n </Typography>\n ) : null}\n </Stack>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'None of this campaign’s emails has recorded a followed ' +\n 'link yet.'}\n </Typography>\n )\n ) : null}\n </Stack>\n )}\n </Section>\n )\n}\nCampaignDestinationsSection.displayName = 'CampaignDestinationsSection'\n"],"names":["AppLink","Figure","MoneyFigure","Section","ListPagination","TABLE_PAGE_SIZE_DEFAULT","ScrollTable","Alert","Button","Stack","TableBody","TableCell","TableHead","TableRow","Typography","collection","doc","getCountFromServer","getDoc","query","where","useCallback","useEffect","useMemo","useState","useFirestore","campaignRevenueAcrossSends","CAMPAIGN_CONVERSION_KINDS","CAMPAIGN_CONVERSION_KIND_COPY","EMAIL_ATTRIBUTION_WINDOW_DAYS","ID_CHUNK","idsKey","sendIds","join","chunked","ids","out","index","length","push","slice","CampaignConversionsSection","props","hostId","truncated","basePath","firestore","key","counts","setCounts","failed","setFailed","split","active","attributions","Promise","all","map","kind","perChunk","chunk","then","snapshot","Number","data","count","reduce","sum","value","entries","Object","fromEntries","catch","title","variant","color","severity","spacing","direction","sx","flexWrap","label","note","component","componentVariant","nativeButton","href","size","displayName","creditedUnder","report","model","models","rule","window","windowDays","CampaignRevenueSection","busy","setBusy","error","setError","setReport","load","snapshots","id","caught","console","alignItems","onClick","disabled","toLocaleString","currencies","caveats","caveat","message","entry","multiCurrency","currency","toUpperCase","useFlexGap","cents","netCents","grossCents","refundedCents","orders","refundedOrders","emails","attributedOrders","recorded","read","CampaignDestinationsSection","result","setResult","page","setPage","pageSize","setPageSize","visibleRows","rows","byUrl","Map","overflowClicks","unattributedClicks","forEach","rollup","values","links","url","String","trim","row","get","clicks","set","sort","a","b","localeCompare","align","wordBreak","rowCount","onPageChange","onPageSizeChange"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,OAAO,QAAQ,uBAAsB;AAC9C,SACEC,MAAM,EACNC,WAAW,EACXC,OAAO,QACF,6DAA4D;AACnE,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,uBAAuB,QAAQ,8CAA6C;AACrF,SAASC,WAAW,QAAQ,yDAAwD;AACpF,SACEC,KAAK,EACLC,MAAM,EACNC,KAAK,EACLC,SAAS,EACTC,SAAS,EACTC,SAAS,EACTC,QAAQ,EACRC,UAAU,QACL,gBAAe;AACtB,SACEC,UAAU,EACVC,GAAG,EACHC,kBAAkB,EAClBC,MAAM,EACNC,KAAK,EACLC,KAAK,QACA,qBAAoB;AAC3B,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACjE,SAASC,YAAY,QAAQ,iCAAgC;AAC7D,SACEC,0BAA0B,EAC1BC,yBAAyB,EACzBC,6BAA6B,EAC7BC,6BAA6B,QAKxB,yCAAwC;AAE/C;;;;;;;;;;;;;;;;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J;gDAAUmJ,OAAM;0DAAS;;;;;8CAG9B,KAACpJ;8CACE+H,YAAYhF,GAAG,CAAC,CAAC6F,oBAChB,MAACzI;;8DACC,KAACF;oDAAUoE,IAAI;wDAAEgF,WAAW;oDAAY;8DACrCT,IAAIH,GAAG;;8DAEV,KAACxI;oDAAUmJ,OAAM;8DACdR,IAAIxB,MAAM,CAAChB,cAAc;;8DAE5B,KAACnG;oDAAUmJ,OAAM;8DACdR,IAAIE,MAAM,CAAC1C,cAAc;;;2CARfwC,IAAIH,GAAG;;;;sCAc5B,KAAC/I;4BACCiI,MAAMA;4BACNE,UAAUA;4BACVyB,UAAUvB,YAAYnG,MAAM;4BAC5B2B,OAAOkE,OAAOO,IAAI,CAACpG,MAAM;4BACzB2H,cAAc3B;4BACd4B,kBAAkB1B;;sCAEpB,KAAC1H;4BAAW4D,SAAQ;4BAAUC,OAAM;sCACjC,4DACC,wDACA,0DACA;;wBAEHwD,OAAOU,cAAc,iBACpB,KAAC/H;4BAAW4D,SAAQ;4BAAUC,OAAM;sCACjC,GAAGwD,OAAOU,cAAc,CAAC/B,cAAc,GAAG,SAAS,CAAC,GACnD,0DACA;6BAEF;wBACHqB,OAAOW,kBAAkB,iBACxB,KAAChI;4BAAW4D,SAAQ;4BAAUC,OAAM;sCACjC,GAAGwD,OAAOW,kBAAkB,CAAChC,cAAc,GAAG,QAAQ,CAAC,GACtD,yDACA;6BAEF;wBACHlE,0BACC,KAAC9B;4BAAW4D,SAAQ;4BAAUC,OAAM;sCACjC,CAAC,WAAW,EAAEwD,OAAOF,IAAI,CAACnB,cAAc,GAAG,aAAa,CAAC,GACxD;6BAEF;;mCAGN,KAAChG;oBAAW4D,SAAQ;oBAAQC,OAAM;8BAC/B,4DACC;qBAGJ;;;;AAKd;AACAuD,4BAA4B1C,WAAW,GAAG"}
@@ -0,0 +1,91 @@
1
+ export interface CampaignReportCardProps {
2
+ hostId: string;
3
+ campaignId: string;
4
+ /** The marketing hub URL, for the way back to the campaigns list. */
5
+ basePath: string;
6
+ }
7
+ /**
8
+ * ONE CAMPAIGN, MEASURED — and every denominator on screen.
9
+ *
10
+ * ## What was missing
11
+ *
12
+ * Opens and clicks have been recorded on the campaign document since AGL-268
13
+ * and displayed as two words in a history row: `12 opens · 3 clicks`. Nothing
14
+ * anywhere showed a rate, a delivery count, a bounce, a complaint or an
15
+ * unsubscribe, and the populations the send itself measured — how large the
16
+ * audience was, how many the consent rule refused, how many were already
17
+ * suppressed — were computed on every send and written nowhere.
18
+ *
19
+ * ## The rule this screen is built around
20
+ *
21
+ * **Every rate names its denominator, in the same breath as the number.**
22
+ *
23
+ * That is not decoration. An open rate over `sent` and an open rate over
24
+ * `delivered` are different numbers that share a label, and the difference
25
+ * between them is exactly the mail that bounced — so a report that showed one
26
+ * while the reader assumed the other would be wrong by however bad the
27
+ * address list is, which is the case where being wrong matters most. Worse,
28
+ * "click rate" is used in the wild for two unrelated quantities — clicks over
29
+ * delivered, and clicks over openers — and they differ by a factor of three
30
+ * or four on ordinary mail.
31
+ *
32
+ * So the arithmetic is not done here at all. `campaign-report.ts` returns
33
+ * each rate as a triple carrying `denominatorLabel`, this file renders that
34
+ * label, and a rate whose denominator is zero or unrecorded comes back `null`
35
+ * and is drawn as "—" with a caveat naming the reason. There is no path
36
+ * through this component that prints a percentage without saying what it is a
37
+ * percentage of.
38
+ *
39
+ * ## What the page is about comes before how the mail did
40
+ *
41
+ * A campaign of one email is the ordinary shape, and this card is the page it
42
+ * gets: the URL names a send, so there is no container above it and no list of
43
+ * emails to draw. That collapse is honest, but it decided what the page was
44
+ * ABOUT — delivery, engagement and rates are mechanics of a message, and a
45
+ * page that led with them at length read as a mail report wearing the word
46
+ * campaign.
47
+ *
48
+ * So the outcomes lead: what it caused, what it earned, where it sent people.
49
+ * Two of those headings are the ones `campaign-reach-sections.tsx` puts at the
50
+ * top of a campaign holding SEVERAL emails, and they are the same words here
51
+ * deliberately — a merchant who opens a campaign of one and a campaign of six
52
+ * is asking the same question and should not have to learn two vocabularies to
53
+ * find the answer. The email's own figures follow, under a row that names the
54
+ * message they belong to.
55
+ *
56
+ * Nothing about the reads changed with the order. The conversions, revenue and
57
+ * destination figures were already on this page and already came from the four
58
+ * documents below; they were simply underneath the mail.
59
+ *
60
+ * ## Three documents, whatever the campaign's size
61
+ *
62
+ * The whole screen is one campaign document plus one link-rollup document
63
+ * plus one revenue-rollup document. All three are single-document listens, so
64
+ * the cost does not move with the audience — a report over a 50,000-recipient
65
+ * send reads the same three documents as one over ten. Aggregating the
66
+ * per-recipient delivery log on mount would have been the obvious
67
+ * implementation and would have read one document per recipient, every time
68
+ * anybody opened the page; joining orders to campaigns at read time would
69
+ * have been the same mistake one collection along, which is why the join is
70
+ * done once at the sale and stored.
71
+ *
72
+ * ## No per-recipient view here, deliberately
73
+ *
74
+ * Every number on this screen is an aggregate that carries no address, and
75
+ * that is what makes it three single-document reads. A per-recipient list is a
76
+ * different read and a different question, so it lives where it is asked:
77
+ * the design report's recipients table, which resolves the campaigns from the
78
+ * design on a server that has already checked the reader's site role, and
79
+ * returns only rows tagged with that site.
80
+ *
81
+ * The other per-recipient view — the staff delivery log on the user detail
82
+ * page — spans every site on the install and is behind a staff claim that
83
+ * records who looked. Neither reaches this card: adding a recipient list here
84
+ * would put an unbounded read behind a widget whose whole cost model is that
85
+ * it has none.
86
+ */
87
+ export declare function CampaignReportCard(props: CampaignReportCardProps): import("react").JSX.Element;
88
+ export declare namespace CampaignReportCard {
89
+ var displayName: string;
90
+ }
91
+ export default CampaignReportCard;