@aglyn/plugins-marketing 1.0.0-beta.173 → 1.0.0-beta.175

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 (79) hide show
  1. package/README.md +2 -1
  2. package/package.json +15 -15
  3. package/src/lib/components/campaign-detail-card.d.ts +12 -1
  4. package/src/lib/components/campaign-detail-card.js +146 -35
  5. package/src/lib/components/campaign-detail-card.js.map +1 -1
  6. package/src/lib/components/campaign-edit-drawer.d.ts +13 -0
  7. package/src/lib/components/campaign-edit-drawer.js +56 -4
  8. package/src/lib/components/campaign-edit-drawer.js.map +1 -1
  9. package/src/lib/components/campaign-glance-card.component.js +10 -2
  10. package/src/lib/components/campaign-glance-card.component.js.map +1 -1
  11. package/src/lib/components/campaign-members-section.d.ts +6 -0
  12. package/src/lib/components/campaign-members-section.js +2 -2
  13. package/src/lib/components/campaign-members-section.js.map +1 -1
  14. package/src/lib/components/campaign-queries.d.ts +58 -0
  15. package/src/lib/components/campaign-queries.js +72 -0
  16. package/src/lib/components/campaign-queries.js.map +1 -0
  17. package/src/lib/components/campaign-reach-sections.d.ts +21 -7
  18. package/src/lib/components/campaign-reach-sections.js +20 -17
  19. package/src/lib/components/campaign-reach-sections.js.map +1 -1
  20. package/src/lib/components/campaign-report-card.d.ts +8 -1
  21. package/src/lib/components/campaign-report-card.js +33 -16
  22. package/src/lib/components/campaign-report-card.js.map +1 -1
  23. package/src/lib/components/campaigns-card.d.ts +10 -1
  24. package/src/lib/components/campaigns-card.js +102 -19
  25. package/src/lib/components/campaigns-card.js.map +1 -1
  26. package/src/lib/components/email-compose-card.d.ts +3 -2
  27. package/src/lib/components/email-compose-card.js +18 -7
  28. package/src/lib/components/email-compose-card.js.map +1 -1
  29. package/src/lib/components/email-detail.d.ts +11 -2
  30. package/src/lib/components/email-detail.js +50 -23
  31. package/src/lib/components/email-detail.js.map +1 -1
  32. package/src/lib/components/emails-list-card.d.ts +10 -1
  33. package/src/lib/components/emails-list-card.js +129 -23
  34. package/src/lib/components/emails-list-card.js.map +1 -1
  35. package/src/lib/components/host-marketing-summary-card.component.js +9 -1
  36. package/src/lib/components/host-marketing-summary-card.component.js.map +1 -1
  37. package/src/lib/components/marketing-console-page.js +81 -4
  38. package/src/lib/components/marketing-console-page.js.map +1 -1
  39. package/src/lib/components/marketing-console-sections.d.ts +16 -1
  40. package/src/lib/components/marketing-console-sections.js +25 -2
  41. package/src/lib/components/marketing-console-sections.js.map +1 -1
  42. package/src/lib/components/marketing-org-mount.d.ts +71 -0
  43. package/src/lib/components/marketing-org-mount.js +84 -0
  44. package/src/lib/components/marketing-org-mount.js.map +1 -0
  45. package/src/lib/components/use-campaign-send-api.d.ts +2 -2
  46. package/src/lib/components/use-campaign-send-api.js +22 -6
  47. package/src/lib/components/use-campaign-send-api.js.map +1 -1
  48. package/src/lib/components/use-emails-hub-path.d.ts +13 -3
  49. package/src/lib/components/use-emails-hub-path.js +25 -4
  50. package/src/lib/components/use-emails-hub-path.js.map +1 -1
  51. package/src/lib/components/use-marketing-hub-path.d.ts +19 -16
  52. package/src/lib/components/use-marketing-hub-path.js +6 -32
  53. package/src/lib/components/use-marketing-hub-path.js.map +1 -1
  54. package/src/lib/model/marketing-record-routes.js +11 -4
  55. package/src/lib/model/marketing-record-routes.js.map +1 -1
  56. package/src/lib/plugin.js +31 -1
  57. package/src/lib/plugin.js.map +1 -1
  58. package/src/lib/server/campaign-manage.d.ts +31 -2
  59. package/src/lib/server/campaign-manage.js +365 -137
  60. package/src/lib/server/campaign-manage.js.map +1 -1
  61. package/src/lib/server/campaign-org-refs.d.ts +45 -0
  62. package/src/lib/server/campaign-org-refs.js +83 -0
  63. package/src/lib/server/campaign-org-refs.js.map +1 -0
  64. package/src/lib/server/campaign-process-scheduled.d.ts +32 -2
  65. package/src/lib/server/campaign-process-scheduled.js +79 -9
  66. package/src/lib/server/campaign-process-scheduled.js.map +1 -1
  67. package/src/lib/server/campaign-recipients.js +18 -4
  68. package/src/lib/server/campaign-recipients.js.map +1 -1
  69. package/src/lib/server/campaign-send.js +139 -55
  70. package/src/lib/server/campaign-send.js.map +1 -1
  71. package/src/lib/server/email-campaign-reach.d.ts +6 -5
  72. package/src/lib/server/email-campaign-reach.js +14 -14
  73. package/src/lib/server/email-campaign-reach.js.map +1 -1
  74. package/src/lib/server/email-events.js +48 -17
  75. package/src/lib/server/email-events.js.map +1 -1
  76. package/src/lib/server/marketing-figures.js +12 -1
  77. package/src/lib/server/marketing-figures.js.map +1 -1
  78. package/src/lib/server.js +7 -3
  79. package/src/lib/server.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/marketing/src/lib/components/campaign-report-card.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 { PageHeaderRecord, pluginDocsHelp } from '@aglyn/aglyn'\nimport { AppLink, CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { ScrollTable } from '@aglyn/shared-ui-jsx/components/scroll-table.component'\nimport {\n Alert,\n Box,\n Button,\n Chip,\n Divider,\n Stack,\n TableBody,\n TableCell,\n TableHead,\n TableRow,\n Typography,\n} from '@mui/material'\nimport { doc } from 'firebase/firestore'\nimport { useFirestore, useFirestoreDoc } from '@aglyn/tenant-feature-instance'\nimport {\n campaignLinkReport,\n campaignReport,\n type CampaignLinkRollup,\n type CampaignStats,\n} from '@aglyn/shared-ui-email-campaigns/model/campaign-report'\nimport {\n campaignRevenueReport,\n type CampaignRevenueRollup,\n} from '@aglyn/shared-ui-email-campaigns/model/campaign-revenue'\nimport {\n campaignConversionsReport,\n type CampaignConversionsRollup,\n} from '@aglyn/shared-ui-email-campaigns/model/campaign-conversions'\n/*\n * The three renderers every email report shares. Imported rather than kept\n * here, so \"a rate prints its denominator\" is one implementation and not a\n * convention each new card has to remember.\n */\nimport {\n Figure,\n MoneyFigure,\n MoneyPerUnitRow,\n percent,\n RateRow,\n Section,\n} from '@aglyn/shared-ui-jsx/components/measured-figures.component'\nimport {\n emailSendTimeMs,\n} from '@aglyn/shared-ui-email-campaigns/model/email-record'\nimport {\n campaignSendDisplay,\n campaignSendProgress,\n} from '@aglyn/shared-ui-email-campaigns/model/campaign-container'\nimport { useEmailsHubPath } from './use-emails-hub-path'\n\n/**\n * The help affordance, hoisted so BOTH headers carry it.\n *\n * The unreadable-campaign branch below renders its own `CardDisplay`, and a\n * header without help is a header a reader has no way out of — which is\n * exactly the state that branch describes.\n */\nconst reportDocsHelp = pluginDocsHelp('emailCampaigns', {\n anchor: '#the-campaign-report',\n excerpt:\n 'What one campaign did: delivery, opens, clicks, bounces, complaints, ' +\n 'unsubscribes and the revenue it was credited with, each with the ' +\n 'population it is measured against.',\n})\n\nexport interface CampaignReportCardProps {\n hostId: string\n campaignId: string\n /** The marketing hub URL, for the way back to the campaigns list. */\n basePath: string\n}\n\n/**\n * ONE CAMPAIGN, MEASURED — and every denominator on screen.\n *\n * ## What was missing\n *\n * Opens and clicks have been recorded on the campaign document since AGL-268\n * and displayed as two words in a history row: `12 opens · 3 clicks`. Nothing\n * anywhere showed a rate, a delivery count, a bounce, a complaint or an\n * unsubscribe, and the populations the send itself measured — how large the\n * audience was, how many the consent rule refused, how many were already\n * suppressed — were computed on every send and written nowhere.\n *\n * ## The rule this screen is built around\n *\n * **Every rate names its denominator, in the same breath as the number.**\n *\n * That is not decoration. An open rate over `sent` and an open rate over\n * `delivered` are different numbers that share a label, and the difference\n * between them is exactly the mail that bounced — so a report that showed one\n * while the reader assumed the other would be wrong by however bad the\n * address list is, which is the case where being wrong matters most. Worse,\n * \"click rate\" is used in the wild for two unrelated quantities — clicks over\n * delivered, and clicks over openers — and they differ by a factor of three\n * or four on ordinary mail.\n *\n * So the arithmetic is not done here at all. `campaign-report.ts` returns\n * each rate as a triple carrying `denominatorLabel`, this file renders that\n * label, and a rate whose denominator is zero or unrecorded comes back `null`\n * and is drawn as \"—\" with a caveat naming the reason. There is no path\n * through this component that prints a percentage without saying what it is a\n * percentage of.\n *\n * ## What the page is about comes before how the mail did\n *\n * A campaign of one email is the ordinary shape, and this card is the page it\n * gets: the URL names a send, so there is no container above it and no list of\n * emails to draw. That collapse is honest, but it decided what the page was\n * ABOUT — delivery, engagement and rates are mechanics of a message, and a\n * page that led with them at length read as a mail report wearing the word\n * campaign.\n *\n * So the outcomes lead: what it caused, what it earned, where it sent people.\n * Two of those headings are the ones `campaign-reach-sections.tsx` puts at the\n * top of a campaign holding SEVERAL emails, and they are the same words here\n * deliberately — a merchant who opens a campaign of one and a campaign of six\n * is asking the same question and should not have to learn two vocabularies to\n * find the answer. The email's own figures follow, under a row that names the\n * message they belong to.\n *\n * Nothing about the reads changed with the order. The conversions, revenue and\n * destination figures were already on this page and already came from the four\n * documents below; they were simply underneath the mail.\n *\n * ## Three documents, whatever the campaign's size\n *\n * The whole screen is one campaign document plus one link-rollup document\n * plus one revenue-rollup document. All three are single-document listens, so\n * the cost does not move with the audience — a report over a 50,000-recipient\n * send reads the same three documents as one over ten. Aggregating the\n * per-recipient delivery log on mount would have been the obvious\n * implementation and would have read one document per recipient, every time\n * anybody opened the page; joining orders to campaigns at read time would\n * have been the same mistake one collection along, which is why the join is\n * done once at the sale and stored.\n *\n * ## No per-recipient view here, deliberately\n *\n * Every number on this screen is an aggregate that carries no address, and\n * that is what makes it three single-document reads. A per-recipient list is a\n * different read and a different question, so it lives where it is asked:\n * the design report's recipients table, which resolves the campaigns from the\n * design on a server that has already checked the reader's site role, and\n * returns only rows tagged with that site.\n *\n * The other per-recipient view — the staff delivery log on the user detail\n * page — spans every site on the install and is behind a staff claim that\n * records who looked. Neither reaches this card: adding a recipient list here\n * would put an unbounded read behind a widget whose whole cost model is that\n * it has none.\n */\nexport function CampaignReportCard(props: CampaignReportCardProps) {\n const { hostId, campaignId, basePath } = props\n // The sibling hub: the message's own page belongs to the Emails console.\n const emailsHub = useEmailsHubPath()\n const firestore = useFirestore()\n\n const { data: campaign } = useFirestoreDoc<\n Record<string, unknown> & { stats?: CampaignStats }\n >(\n () => doc(firestore, 'hosts', hostId, 'campaigns', campaignId),\n [firestore, hostId, campaignId],\n )\n /*\n * The link rollup, its own document rather than a field on the campaign.\n *\n * A map of destinations grows with the campaign's content and a campaign\n * document is read by the history list, the glance widget and the send\n * path; putting an unbounded map on it would make every one of those reads\n * larger. Split, the rollup is read by exactly the screen that renders it.\n */\n const { data: links } = useFirestoreDoc<CampaignLinkRollup>(\n () => doc(firestore, 'hosts', hostId, 'campaigns', campaignId, 'reports', 'links'),\n [firestore, hostId, campaignId],\n )\n /*\n * The revenue rollup, a third single-document listen.\n *\n * Its own document beside the link rollup rather than a field on the\n * campaign, for the reason the link rollup is: the campaign document is\n * read by the history list, the glance widget and the send path, and a map\n * that grows with the campaign's sales would enlarge every one of those\n * reads. The cost model in this file's header is unchanged in the way that\n * matters — the page still reads a fixed number of documents whatever the\n * audience, and no per-order or per-recipient read exists anywhere on it.\n */\n const { data: revenue } = useFirestoreDoc<CampaignRevenueRollup>(\n () =>\n doc(\n firestore,\n 'hosts',\n hostId,\n 'campaigns',\n campaignId,\n 'reports',\n 'revenue',\n ),\n [firestore, hostId, campaignId],\n )\n\n /*\n * The conversions rollup, a fourth single-document listen.\n *\n * Beside `reports/revenue` and read the same way, because it is the same\n * join answering the other half of the question: revenue is what a campaign\n * EARNED from people who named themselves at checkout, and this is what it\n * CAUSED among people who were anonymous until the moment they submitted,\n * signed up or booked. The cost model in this file's header is unchanged in\n * the way that matters — a fixed number of documents whatever the audience,\n * and no per-conversion read anywhere on the page.\n */\n const { data: conversions } = useFirestoreDoc<CampaignConversionsRollup>(\n () =>\n doc(\n firestore,\n 'hosts',\n hostId,\n 'campaigns',\n campaignId,\n 'reports',\n 'conversions',\n ),\n [firestore, hostId, campaignId],\n )\n\n const report = campaignReport(campaign?.stats)\n const linkReport = campaignLinkReport(links)\n const revenueReport = campaignRevenueReport({\n rollup: revenue,\n /*\n * The DENOMINATOR, handed over from the same document read at the same\n * instant rather than re-read here. `report.delivered` is `null` when no\n * delivery event was ever recorded, and it is passed as `null` so the\n * revenue figures over it are withheld for exactly the reason every other\n * rate over it is.\n */\n delivered: report.delivered,\n midFlight: campaign\n ? campaignSendProgress(campaign as never).state === 'sending'\n : false,\n })\n /*\n * No denominator is handed in, unlike the revenue report. A conversion RATE\n * over delivered messages would repeat the defect the revenue section\n * refuses for orders — one visitor can submit two forms, so the quotient\n * passes 100% without anything being wrong — and counting distinct people\n * instead needs a document per person per campaign, which is the\n * per-recipient read this screen's cost model exists to refuse.\n */\n const conversionsReport = campaignConversionsReport({ rollup: conversions })\n const subject = String(campaign?.subject ?? 'Campaign')\n const sendTimeMs = campaign ? emailSendTimeMs(campaign) : 0\n\n const backButton = (\n <Button\n component={AppLink as any}\n {...({ componentVariant: 'naked', nativeButton: false } as any)}\n href={`${basePath}/campaigns`}\n size=\"small\"\n color=\"primary\"\n >\n {'All campaigns'}\n </Button>\n )\n\n if (!campaign) {\n return (\n <CardDisplay\n header={'Campaign report'}\n help={reportDocsHelp}\n contentGutterX\n contentGutterY\n HeaderProps={{ action: backButton }}\n >\n {/*\n * Not \"no data\". A campaign that cannot be read is a different\n * situation from one with no engagement, and rendering an empty\n * report for the first is how somebody comes to believe a campaign\n * they sent reached nobody.\n */}\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'This campaign could not be loaded. It may have been deleted.'}\n </Typography>\n </CardDisplay>\n )\n }\n\n /* The card, named so the page chrome above it is a plain list of\n what this surface publishes upward. */\n const card = (\n <CardDisplay\n header={'Campaign report'}\n help={reportDocsHelp}\n contentGutterX\n contentGutterY\n HeaderProps={{ action: backButton }}\n >\n <Stack spacing={3}>\n {report.caveats.map((caveat) => (\n <Alert key={caveat.id} severity=\"info\">\n {caveat.message}\n </Alert>\n ))}\n\n {/*==========================================\n * WHAT THIS CAMPAIGN CAUSED — the page's first section, and the\n * heading a campaign of several emails leads with too.\n *\n * The same join as the revenue below, credited under the same rule,\n * answering it for people who were anonymous until the moment being\n * counted: they arrived from a campaign link, browsed, and only\n * became somebody when they submitted a form, signed up or booked.\n *\n * THE FOUR FIGURES ARE NEVER ADDED. One person filling in one form\n * writes a submission, a contact and a lead, so a total would count\n * that visit three times — and it would look like a bigger version\n * of a real number, which is why the model carries no total for this\n * JSX to reach for and the caveat says so in words above them.\n *\n * They are laid out in a row of independent `Figure`s rather than in\n * a table with a footer, because a footer row is where a reader\n * expects the sum to be.\n *=========================================*/}\n <Section title=\"What it caused\">\n {conversionsReport.caveats.map((caveat) => (\n <Alert key={caveat.id} severity=\"info\">\n {caveat.message}\n </Alert>\n ))}\n {conversionsReport.any ? (\n <Stack spacing={1}>\n <Stack\n direction=\"row\"\n spacing={4}\n useFlexGap\n sx={{ flexWrap: 'wrap' }}\n >\n {conversionsReport.kinds.map((entry) => (\n <Figure\n key={entry.kind}\n label={entry.label}\n value={entry.value}\n note={entry.note}\n />\n ))}\n </Stack>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Credited ${conversionsReport.model === 'last-click' ? 'to the last campaign whose link the visitor clicked' : `under the ${conversionsReport.model} model`}, ` +\n `within ${conversionsReport.windowDays} days of that click. ` +\n 'Somebody who converted without ever following a campaign ' +\n 'link is credited to no campaign at all — nothing is ' +\n 'inferred from a referrer — so these are a floor rather ' +\n 'than everything this campaign influenced. The ones ' +\n 'credited to nobody are counted under Conversions in the ' +\n 'marketing console.'}\n </Typography>\n {/*\n THE RECORDS BEHIND THE FIGURES. The rollup says how many; the\n list says which, and it is the only place the uncredited half\n is counted. A link rather than a table here — the records are\n a paged read and this page's whole cost model is a fixed\n number of documents whatever the audience.\n */}\n <Box>\n <Button\n component={AppLink as any}\n {...({\n componentVariant: 'naked',\n nativeButton: false,\n } as any)}\n href={`${basePath}/conversions/${campaignId}`}\n size=\"small\"\n color=\"primary\"\n >\n {'See these conversions'}\n </Button>\n </Box>\n </Stack>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {conversionsReport.recorded\n ? 'Nothing has been credited to this campaign yet.'\n : 'No conversions have been attributed to this campaign. A ' +\n 'form submission, lead, contact or booking is credited to ' +\n 'the last campaign whose link the visitor clicked, within ' +\n `${conversionsReport.windowDays} days — a campaign sent ` +\n 'before that was recorded will never show a figure here.'}\n </Typography>\n )}\n </Section>\n\n <Divider />\n\n {/*==========================================\n * WHAT THIS CAMPAIGN EARNED.\n *\n * The merchant's second question, and the one every compared\n * product answers by reconstructing revenue probabilistically\n * because it does not own the order. Here it is a join: the click\n * and the order are rows in one database, so there is no tracking\n * script, no catalog sync and nothing estimated except the model.\n *\n * THE MODEL IS ON SCREEN, in a sentence, above the money. A revenue\n * figure whose rule the reader cannot state is worse than no\n * figure, because they will use it anyway — and the two things they\n * have to know to use it are which campaign gets the credit when\n * several touched the buyer, and how long a click stays creditable.\n *\n * NET LEADS. Gross and refunded are both shown beside it, because\n * \"this campaign made $4,000\" and \"this campaign made $4,000 of\n * which $3,100 came back\" are different facts about whether to send\n * another one.\n *=========================================*/}\n <Section title=\"Revenue\">\n {revenueReport.caveats.map((caveat) => (\n <Alert key={caveat.id} severity=\"info\">\n {caveat.message}\n </Alert>\n ))}\n {revenueReport.currencies.length ? (\n <Stack spacing={3}>\n {revenueReport.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. A per-currency label on a\n * report that only ever shows dollars is noise; the moment\n * there are two, the reader has to be able to see at a\n * glance that the blocks are not addable — which is also\n * what the caveat above says in words.\n */}\n {revenueReport.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 </Stack>\n <MoneyPerUnitRow\n label=\"Net revenue per delivered message\"\n figure={entry.netPerDelivered}\n />\n </Stack>\n ))}\n {/*\n * NO CONVERSION RATE, and this is where a reader would look\n * for one. Orders over delivered is not a rate: one buyer can\n * place two orders, so the quotient passes 100% without\n * anything being wrong — the same defect that keeps `opens`\n * out of the open-rate numerator two sections above. Counting\n * distinct buyers instead would need a document per person per\n * campaign, which is the per-recipient read this screen's cost\n * model exists to refuse. The order count is shown as a count.\n */}\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Credited ${revenueReport.model === 'last-click' ? 'to the last campaign whose link the buyer clicked' : `under the ${revenueReport.model} model`}, ` +\n `within ${revenueReport.windowDays} days of that click. ` +\n 'Clicks only — an open is not treated as evidence that ' +\n 'anybody read the email. An order placed by somebody who ' +\n 'never clicked, or who checked out without giving an ' +\n 'address, is credited to no campaign, so this is a floor ' +\n 'rather than every sale this campaign influenced.'}\n </Typography>\n </Stack>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {revenueReport.recorded\n ? 'No orders have been credited to this campaign.'\n : 'No revenue has been attributed to this campaign. Orders ' +\n 'are credited to the last campaign whose link the buyer ' +\n `clicked, within ${revenueReport.windowDays} days — a ` +\n 'campaign sent before that was recorded, or one on a site ' +\n 'with no store, will never show a figure here.'}\n </Typography>\n )}\n </Section>\n\n <Divider />\n\n <Section title=\"Where it sent people\">\n {/*\n The heading a campaign of several emails carries over the same\n question, so the two shapes of campaign page read alike. A\n campaign owns no page — this is where its mail was actually\n followed to, which is the only account of it the data holds.\n */}\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'The pages this campaign’s links were followed to.'}\n </Typography>\n {linkReport.rows.length ? (\n <>\n <ScrollTable size=\"small\">\n <TableHead>\n <TableRow>\n <TableCell>{'Destination'}</TableCell>\n <TableCell align=\"right\">{'Clicks'}</TableCell>\n <TableCell align=\"right\">{'Share'}</TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {linkReport.rows.map((row) => (\n <TableRow key={row.url}>\n <TableCell sx={{ wordBreak: 'break-all' }}>\n {row.url}\n </TableCell>\n <TableCell align=\"right\" sx={{ fontWeight: 'bold' }}>\n {row.clicks.toLocaleString()}\n </TableCell>\n <TableCell align=\"right\">\n {row.share\n ? `${percent(row.share.value)} of ${row.share.denominator.toLocaleString()} ${row.share.denominatorLabel}`\n : '—'}\n </TableCell>\n </TableRow>\n ))}\n </TableBody>\n </ScrollTable>\n {/*\n * The normalisation, stated rather than left for somebody to\n * discover from a total that does not add up. Two links to the\n * same page distinguished only by their UTM tags are one row\n * here, and a merchant comparing this table with the campaign\n * they built has to be told that before they conclude a link\n * is missing.\n */}\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Counted by address and path — query strings are dropped, so ' +\n 'two links to the same page with different tracking ' +\n 'parameters count as one row.'}\n </Typography>\n {linkReport.unattributedClicks ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`${linkReport.unattributedClicks.toLocaleString()} clicks ` +\n 'arrived without a destination and are not in this table.'}\n </Typography>\n ) : null}\n {linkReport.overflowClicks ? (\n <Alert severity=\"info\">\n {`This campaign has more distinct destinations than the ` +\n `rollup keeps. ${linkReport.overflowClicks.toLocaleString()} ` +\n 'clicks landed on links past that limit and are counted ' +\n 'in the click total above but not in this table.'}\n </Alert>\n ) : null}\n </>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {report.clicks\n ? 'Clicks were recorded for this campaign, but none of them ' +\n 'carried a destination, so there is nothing to break down ' +\n 'by link.'\n : 'No link clicks have been recorded for this campaign.'}\n </Typography>\n )}\n </Section>\n\n <Divider />\n\n {/*==========================================\n * THE EMAIL THE FIGURES BELOW CAME FROM — and the hinge between the\n * two halves of this page.\n *\n * This screen is reached at `/marketing/campaigns/{sendId}`, which\n * is a CAMPAIGN url resolving to a send — the fall-through that keeps\n * every unsubscribe footer and every pasted report link working. So\n * a reader arrives from the campaigns table, where the row carries a\n * \"Single send\" chip, and everything under this row is a fact about\n * a message rather than about the campaign.\n *\n * Figures with no visible source read as a campaign holding no\n * emails while reporting real numbers, which is a contradiction\n * rather than a shortage of detail. Naming the one email — and\n * saying it IS the campaign, which is what the chip already claims\n * and what `campaignListRows` already does at read time — is what\n * makes the page answer the question it raises.\n *\n * One row, from the document this card already read: no query, no\n * second listen, and the two-document cost the header describes is\n * unchanged.\n *=========================================*/}\n <Section title=\"The email in this campaign\">\n <Stack spacing={1}>\n <Stack\n direction=\"row\"\n spacing={1}\n useFlexGap\n sx={{ alignItems: 'center', flexWrap: 'wrap' }}\n >\n {/*\n The MESSAGE's own page, which the Emails console owns — hence\n the sibling hub rather than this surface's `basePath`. Plain\n text until that hub resolves: a link with no destination is\n worse than none, and the subject is what the reader came for\n either way.\n */}\n {emailsHub ? (\n <AppLink href={`${emailsHub}/messages/${campaignId}`}>\n {subject}\n </AppLink>\n ) : (\n <Typography variant=\"body2\">{subject}</Typography>\n )}\n {/*\n What the email is DOING, not the field it stores. One\n delivering an audience larger than one batch is written back\n as `scheduled` between runs, so a chip rendering the status\n said \"Scheduled\" at the head of a report of five hundred\n deliveries.\n */}\n <Chip\n size=\"small\"\n label={campaignSendDisplay(campaign as never).label}\n />\n <Chip\n size=\"small\"\n variant=\"outlined\"\n label=\"Single send\"\n title={\n 'One email, sent on its own rather than as part of a ' +\n 'campaign of several. Its report and its unsubscribe links ' +\n 'are unchanged.'\n }\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {sendTimeMs\n ? new Date(sendTimeMs).toLocaleString()\n : 'not recorded'}\n </Typography>\n </Stack>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'This campaign is one email, so the sections above are what ' +\n 'that one email caused. What follows is the mail itself — ' +\n 'how it was delivered and how it was read. Open the message ' +\n 'for its body and the people it reached.'}\n </Typography>\n </Stack>\n </Section>\n\n <Divider />\n\n {/*==========================================\n * WHAT HAPPENED TO THE MAIL.\n *\n * Counts first and rates second, in that order and not the other\n * way round, because a rate is only readable once you know what it\n * was taken over — and because the counts are the part that is\n * always true. Every rate below can be absent; none of these can.\n *=========================================*/}\n <Section title=\"Delivery\">\n <Stack direction=\"row\" spacing={4} useFlexGap sx={{ flexWrap: 'wrap' }}>\n <Figure\n label=\"Addressed\"\n value={report.recipients}\n note=\"after the per-send cap\"\n />\n <Figure\n label=\"Sent\"\n value={report.sent}\n note=\"accepted by the provider\"\n />\n <Figure\n label=\"Delivered\"\n value={report.delivered}\n note=\"accepted by the receiving server\"\n />\n <Figure label=\"Bounced\" value={report.bounced} note=\"of sent\" />\n <Figure\n label=\"Marked as spam\"\n value={report.complained}\n note=\"of delivered\"\n />\n </Stack>\n </Section>\n\n <Divider />\n\n <Section title=\"Engagement\">\n {/*\n * BOTH the event count and the distinct count, side by side.\n *\n * `Opens` is every open event — one reader opening four times is\n * four — and it is the number this product has always shown. It\n * cannot be a rate numerator: divided by anything it exceeds 100%\n * the moment somebody reads an email twice. `Readers who opened`\n * is the distinct count, and it is what the rate below divides.\n * Showing only one of them would either hide activity or invite a\n * rate nobody can defend, so both are here with different names.\n */}\n <Stack direction=\"row\" spacing={4} useFlexGap sx={{ flexWrap: 'wrap' }}>\n <Figure\n label=\"Opens\"\n value={report.opens}\n note=\"every open, repeats included\"\n />\n <Figure\n label=\"Readers who opened\"\n value={report.uniqueOpens}\n note=\"distinct recipients\"\n />\n <Figure\n label=\"Clicks\"\n value={report.clicks}\n note=\"every click, repeats included\"\n />\n <Figure\n label=\"Readers who clicked\"\n value={report.uniqueClicks}\n note=\"distinct recipients\"\n />\n <Figure\n label=\"Unsubscribed\"\n value={report.unsubscribes}\n note=\"through this campaign's link\"\n />\n </Stack>\n </Section>\n\n <Divider />\n\n <Section title=\"Rates\">\n <Stack spacing={1}>\n <RateRow label=\"Delivery rate\" rate={report.rates.delivery} />\n <RateRow label=\"Open rate\" rate={report.rates.open} />\n <RateRow label=\"Click rate\" rate={report.rates.click} />\n <RateRow\n label=\"Click-to-open rate\"\n rate={report.rates.clickToOpen}\n />\n <RateRow label=\"Bounce rate\" rate={report.rates.bounce} />\n <RateRow label=\"Complaint rate\" rate={report.rates.complaint} />\n <RateRow\n label=\"Unsubscribe rate\"\n rate={report.rates.unsubscribe}\n />\n </Stack>\n </Section>\n\n {report.populations.length ? (\n <>\n <Divider />\n <Section title=\"Who this went to\">\n {/*\n * The populations the SEND measured, recorded at send time.\n *\n * Not recomputed here, and the note under the heading says so:\n * consent records change and addresses get suppressed, so\n * asking the list today produces a number that is true of the\n * list and false of the campaign.\n */}\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Measured when this campaign was sent, and stored as it was ' +\n 'then. These figures describe the send, not the audience ' +\n 'as it stands today.'}\n </Typography>\n <ScrollTable size=\"small\">\n <TableBody>\n {report.populations.map((population) => (\n <TableRow key={population.id}>\n <TableCell>{population.label}</TableCell>\n <TableCell align=\"right\" sx={{ fontWeight: 'bold' }}>\n {population.count.toLocaleString()}\n </TableCell>\n <TableCell align=\"right\">\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`of ${population.of.toLocaleString()} ${population.ofLabel}`}\n </Typography>\n </TableCell>\n </TableRow>\n ))}\n </TableBody>\n </ScrollTable>\n </Section>\n </>\n ) : null}\n </Stack>\n </CardDisplay>\n )\n\n return (\n <>\n {/* The page heading and the trail name the send; this card is\n then free to say what it holds rather than repeating the title. */}\n <PageHeaderRecord\n title={\n campaign ? String(campaign.subject || '') || campaignId : undefined\n }\n />\n {card}\n </>\n )\n}\nCampaignReportCard.displayName = 'CampaignReportCard'\n\nexport default CampaignReportCard\n"],"names":["PageHeaderRecord","pluginDocsHelp","AppLink","CardDisplay","ScrollTable","Alert","Box","Button","Chip","Divider","Stack","TableBody","TableCell","TableHead","TableRow","Typography","doc","useFirestore","useFirestoreDoc","campaignLinkReport","campaignReport","campaignRevenueReport","campaignConversionsReport","Figure","MoneyFigure","MoneyPerUnitRow","percent","RateRow","Section","emailSendTimeMs","campaignSendDisplay","campaignSendProgress","useEmailsHubPath","reportDocsHelp","anchor","excerpt","CampaignReportCard","props","hostId","campaignId","basePath","emailsHub","firestore","data","campaign","links","revenue","conversions","report","stats","linkReport","revenueReport","rollup","delivered","midFlight","state","conversionsReport","subject","String","sendTimeMs","backButton","component","componentVariant","nativeButton","href","size","color","header","help","contentGutterX","contentGutterY","HeaderProps","action","variant","card","spacing","caveats","map","caveat","severity","message","id","title","any","direction","useFlexGap","sx","flexWrap","kinds","entry","label","value","note","kind","model","windowDays","recorded","currencies","length","multiCurrency","currency","toUpperCase","cents","netCents","grossCents","refundedCents","orders","refundedOrders","figure","netPerDelivered","rows","align","row","wordBreak","url","fontWeight","clicks","toLocaleString","share","denominator","denominatorLabel","unattributedClicks","overflowClicks","alignItems","Date","recipients","sent","bounced","complained","opens","uniqueOpens","uniqueClicks","unsubscribes","rate","rates","delivery","open","click","clickToOpen","bounce","complaint","unsubscribe","populations","population","count","of","ofLabel","undefined","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,gBAAgB,EAAEC,cAAc,QAAQ,eAAc;AAC/D,SAASC,OAAO,EAAEC,WAAW,QAAQ,uBAAsB;AAC3D,SAASC,WAAW,QAAQ,yDAAwD;AACpF,SACEC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,OAAO,EACPC,KAAK,EACLC,SAAS,EACTC,SAAS,EACT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0CACtD,KAAChH;gCAAQ+D,OAAM;gCAAiB2C,MAAMrF,OAAOsF,KAAK,CAACM,SAAS;;0CAC5D,KAACjH;gCACC+D,OAAM;gCACN2C,MAAMrF,OAAOsF,KAAK,CAACO,WAAW;;;;;gBAKnC7F,OAAO8F,WAAW,CAAC5C,MAAM,iBACxB;;sCACE,KAACzF;sCACD,MAACmB;4BAAQsD,OAAM;;8CASb,KAACnE;oCAAW0D,SAAQ;oCAAQP,OAAM;8CAC/B,gEACC,6DACA;;8CAEJ,KAAC9D;oCAAY6D,MAAK;8CAChB,cAAA,KAACtD;kDACEqC,OAAO8F,WAAW,CAACjE,GAAG,CAAC,CAACkE,2BACvB,MAACjI;;kEACC,KAACF;kEAAWmI,WAAWrD,KAAK;;kEAC5B,KAAC9E;wDAAUmG,OAAM;wDAAQzB,IAAI;4DAAE6B,YAAY;wDAAO;kEAC/C4B,WAAWC,KAAK,CAAC3B,cAAc;;kEAElC,KAACzG;wDAAUmG,OAAM;kEACf,cAAA,KAAChG;4DAAW0D,SAAQ;4DAAUP,OAAM;sEACjC,CAAC,GAAG,EAAE6E,WAAWE,EAAE,CAAC5B,cAAc,GAAG,CAAC,EAAE0B,WAAWG,OAAO,EAAE;;;;+CAPpDH,WAAW9D,EAAE;;;;;;qBAgBpC;;;;IAKV,qBACE;;0BAGE,KAACjF;gBACCkF,OACEtC,WAAWc,OAAOd,SAASa,OAAO,IAAI,OAAOlB,aAAa4G;;YAG7DzE;;;AAGP;AACAtC,mBAAmBgH,WAAW,GAAG;AAEjC,eAAehH,mBAAkB"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/marketing/src/lib/components/campaign-report-card.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 { PageHeaderRecord, pluginDocsHelp } from '@aglyn/aglyn'\nimport { AppLink, CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { ScrollTable } from '@aglyn/shared-ui-jsx/components/scroll-table.component'\nimport {\n Alert,\n Box,\n Button,\n Chip,\n Divider,\n Stack,\n TableBody,\n TableCell,\n TableHead,\n TableRow,\n Typography,\n} from '@mui/material'\nimport { useFirestore, useFirestoreDoc } from '@aglyn/tenant-feature-instance'\nimport {\n campaignLinkReport,\n campaignReport,\n type CampaignLinkRollup,\n type CampaignStats,\n} from '@aglyn/shared-ui-email-campaigns/model/campaign-report'\nimport {\n campaignRevenueReport,\n type CampaignRevenueRollup,\n} from '@aglyn/shared-ui-email-campaigns/model/campaign-revenue'\nimport {\n campaignConversionsReport,\n type CampaignConversionsRollup,\n} from '@aglyn/shared-ui-email-campaigns/model/campaign-conversions'\n/*\n * The three renderers every email report shares. Imported rather than kept\n * here, so \"a rate prints its denominator\" is one implementation and not a\n * convention each new card has to remember.\n */\nimport {\n Figure,\n MoneyFigure,\n MoneyPerUnitRow,\n percent,\n RateRow,\n Section,\n} from '@aglyn/shared-ui-jsx/components/measured-figures.component'\nimport {\n emailSendTimeMs,\n} from '@aglyn/shared-ui-email-campaigns/model/email-record'\nimport {\n campaignSendDisplay,\n campaignSendProgress,\n} from '@aglyn/shared-ui-email-campaigns/model/campaign-container'\nimport { campaignSendDoc, campaignSendReportDoc } from './campaign-queries'\nimport {\n orgSiteHubPath,\n useMarketingOrgId,\n useMarketingOrgMount,\n} from './marketing-org-mount'\nimport { useEmailsHubPath } from './use-emails-hub-path'\n\n/**\n * The help affordance, hoisted so BOTH headers carry it.\n *\n * The unreadable-campaign branch below renders its own `CardDisplay`, and a\n * header without help is a header a reader has no way out of — which is\n * exactly the state that branch describes.\n */\nconst reportDocsHelp = pluginDocsHelp('emailCampaigns', {\n anchor: '#the-campaign-report',\n excerpt:\n 'What one campaign did: delivery, opens, clicks, bounces, complaints, ' +\n 'unsubscribes and the revenue it was credited with, each with the ' +\n 'population it is measured against.',\n})\n\nexport interface CampaignReportCardProps {\n /** The site, or `null` on the org Marketing hub. */\n hostId: string | null\n campaignId: string\n /** The marketing hub URL, for the way back to the campaigns list. */\n basePath: string\n}\n\n/**\n * ONE CAMPAIGN, MEASURED — and every denominator on screen.\n *\n * ## What was missing\n *\n * Opens and clicks have been recorded on the campaign document since AGL-268\n * and displayed as two words in a history row: `12 opens · 3 clicks`. Nothing\n * anywhere showed a rate, a delivery count, a bounce, a complaint or an\n * unsubscribe, and the populations the send itself measured — how large the\n * audience was, how many the consent rule refused, how many were already\n * suppressed — were computed on every send and written nowhere.\n *\n * ## The rule this screen is built around\n *\n * **Every rate names its denominator, in the same breath as the number.**\n *\n * That is not decoration. An open rate over `sent` and an open rate over\n * `delivered` are different numbers that share a label, and the difference\n * between them is exactly the mail that bounced — so a report that showed one\n * while the reader assumed the other would be wrong by however bad the\n * address list is, which is the case where being wrong matters most. Worse,\n * \"click rate\" is used in the wild for two unrelated quantities — clicks over\n * delivered, and clicks over openers — and they differ by a factor of three\n * or four on ordinary mail.\n *\n * So the arithmetic is not done here at all. `campaign-report.ts` returns\n * each rate as a triple carrying `denominatorLabel`, this file renders that\n * label, and a rate whose denominator is zero or unrecorded comes back `null`\n * and is drawn as \"—\" with a caveat naming the reason. There is no path\n * through this component that prints a percentage without saying what it is a\n * percentage of.\n *\n * ## What the page is about comes before how the mail did\n *\n * A campaign of one email is the ordinary shape, and this card is the page it\n * gets: the URL names a send, so there is no container above it and no list of\n * emails to draw. That collapse is honest, but it decided what the page was\n * ABOUT — delivery, engagement and rates are mechanics of a message, and a\n * page that led with them at length read as a mail report wearing the word\n * campaign.\n *\n * So the outcomes lead: what it caused, what it earned, where it sent people.\n * Two of those headings are the ones `campaign-reach-sections.tsx` puts at the\n * top of a campaign holding SEVERAL emails, and they are the same words here\n * deliberately — a merchant who opens a campaign of one and a campaign of six\n * is asking the same question and should not have to learn two vocabularies to\n * find the answer. The email's own figures follow, under a row that names the\n * message they belong to.\n *\n * Nothing about the reads changed with the order. The conversions, revenue and\n * destination figures were already on this page and already came from the four\n * documents below; they were simply underneath the mail.\n *\n * ## Three documents, whatever the campaign's size\n *\n * The whole screen is one campaign document plus one link-rollup document\n * plus one revenue-rollup document. All three are single-document listens, so\n * the cost does not move with the audience — a report over a 50,000-recipient\n * send reads the same three documents as one over ten. Aggregating the\n * per-recipient delivery log on mount would have been the obvious\n * implementation and would have read one document per recipient, every time\n * anybody opened the page; joining orders to campaigns at read time would\n * have been the same mistake one collection along, which is why the join is\n * done once at the sale and stored.\n *\n * ## No per-recipient view here, deliberately\n *\n * Every number on this screen is an aggregate that carries no address, and\n * that is what makes it three single-document reads. A per-recipient list is a\n * different read and a different question, so it lives where it is asked:\n * the design report's recipients table, which resolves the campaigns from the\n * design on a server that has already checked the reader's site role, and\n * returns only rows tagged with that site.\n *\n * ## The same four documents at the org level\n *\n * A send and its rollups are the org's, so the org hub reads the same four\n * documents. The one link that leads to a SITE fact — the conversions list,\n * which is that site's visitors — goes to the site the send was sent as.\n *\n * The other per-recipient view — the staff delivery log on the user detail\n * page — spans every site on the install and is behind a staff claim that\n * records who looked. Neither reaches this card: adding a recipient list here\n * would put an unbounded read behind a widget whose whole cost model is that\n * it has none.\n */\nexport function CampaignReportCard(props: CampaignReportCardProps) {\n const { hostId, campaignId, basePath } = props\n // The sibling hub: the message's own page belongs to the Emails console.\n const emailsHub = useEmailsHubPath()\n const orgMount = useMarketingOrgMount()\n const { orgId } = useMarketingOrgId(hostId)\n const firestore = useFirestore()\n\n const { data: campaign, status } = useFirestoreDoc<\n Record<string, unknown> & { stats?: CampaignStats }\n >(\n () => (orgId ? campaignSendDoc(firestore, orgId, campaignId) : null),\n [firestore, orgId, campaignId],\n )\n /*\n * The link rollup, its own document rather than a field on the campaign.\n *\n * A map of destinations grows with the campaign's content and a campaign\n * document is read by the history list, the glance widget and the send\n * path; putting an unbounded map on it would make every one of those reads\n * larger. Split, the rollup is read by exactly the screen that renders it.\n */\n const { data: links } = useFirestoreDoc<CampaignLinkRollup>(\n () =>\n orgId ? campaignSendReportDoc(firestore, orgId, campaignId, 'links') : null,\n [firestore, orgId, campaignId],\n )\n /*\n * The revenue rollup, a third single-document listen.\n *\n * Its own document beside the link rollup rather than a field on the\n * campaign, for the reason the link rollup is: the campaign document is\n * read by the history list, the glance widget and the send path, and a map\n * that grows with the campaign's sales would enlarge every one of those\n * reads. The cost model in this file's header is unchanged in the way that\n * matters — the page still reads a fixed number of documents whatever the\n * audience, and no per-order or per-recipient read exists anywhere on it.\n */\n const { data: revenue } = useFirestoreDoc<CampaignRevenueRollup>(\n () =>\n orgId\n ? campaignSendReportDoc(firestore, orgId, campaignId, 'revenue')\n : null,\n [firestore, orgId, campaignId],\n )\n\n /*\n * The conversions rollup, a fourth single-document listen.\n *\n * Beside `reports/revenue` and read the same way, because it is the same\n * join answering the other half of the question: revenue is what a campaign\n * EARNED from people who named themselves at checkout, and this is what it\n * CAUSED among people who were anonymous until the moment they submitted,\n * signed up or booked. The cost model in this file's header is unchanged in\n * the way that matters — a fixed number of documents whatever the audience,\n * and no per-conversion read anywhere on the page.\n */\n const { data: conversions } = useFirestoreDoc<CampaignConversionsRollup>(\n () =>\n orgId\n ? campaignSendReportDoc(firestore, orgId, campaignId, 'conversions')\n : null,\n [firestore, orgId, campaignId],\n )\n /*\n * Where this send's links lead. The message's page is the Emails console's\n * under a site and the org hub's own Emails section over the org; the\n * conversions list is always the sending site's.\n */\n const messageHref = orgMount\n ? `${orgMount.basePath}/emails/${campaignId}`\n : emailsHub\n ? `${emailsHub}/messages/${campaignId}`\n : null\n const conversionsHub = orgMount\n ? orgSiteHubPath(orgMount, String(campaign?.hostId ?? ''), 'marketing')\n : basePath\n\n const report = campaignReport(campaign?.stats)\n const linkReport = campaignLinkReport(links)\n const revenueReport = campaignRevenueReport({\n rollup: revenue,\n /*\n * The DENOMINATOR, handed over from the same document read at the same\n * instant rather than re-read here. `report.delivered` is `null` when no\n * delivery event was ever recorded, and it is passed as `null` so the\n * revenue figures over it are withheld for exactly the reason every other\n * rate over it is.\n */\n delivered: report.delivered,\n midFlight: campaign\n ? campaignSendProgress(campaign as never).state === 'sending'\n : false,\n })\n /*\n * No denominator is handed in, unlike the revenue report. A conversion RATE\n * over delivered messages would repeat the defect the revenue section\n * refuses for orders — one visitor can submit two forms, so the quotient\n * passes 100% without anything being wrong — and counting distinct people\n * instead needs a document per person per campaign, which is the\n * per-recipient read this screen's cost model exists to refuse.\n */\n const conversionsReport = campaignConversionsReport({ rollup: conversions })\n const subject = String(campaign?.subject ?? 'Campaign')\n const sendTimeMs = campaign ? emailSendTimeMs(campaign) : 0\n\n const backButton = (\n <Button\n component={AppLink as any}\n {...({ componentVariant: 'naked', nativeButton: false } as any)}\n href={`${basePath}/campaigns`}\n size=\"small\"\n color=\"primary\"\n >\n {'All campaigns'}\n </Button>\n )\n\n // Nothing to say until the read has had its chance to answer.\n if (!campaign && (status === 'loading' || !orgId)) return null\n\n if (!campaign) {\n return (\n <CardDisplay\n header={'Campaign report'}\n help={reportDocsHelp}\n contentGutterX\n contentGutterY\n HeaderProps={{ action: backButton }}\n >\n {/*\n * Not \"no data\". A campaign that cannot be read is a different\n * situation from one with no engagement, and rendering an empty\n * report for the first is how somebody comes to believe a campaign\n * they sent reached nobody.\n */}\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'This campaign could not be loaded. It may have been deleted.'}\n </Typography>\n </CardDisplay>\n )\n }\n\n /* The card, named so the page chrome above it is a plain list of\n what this surface publishes upward. */\n const card = (\n <CardDisplay\n header={'Campaign report'}\n help={reportDocsHelp}\n contentGutterX\n contentGutterY\n HeaderProps={{ action: backButton }}\n >\n <Stack spacing={3}>\n {report.caveats.map((caveat) => (\n <Alert key={caveat.id} severity=\"info\">\n {caveat.message}\n </Alert>\n ))}\n\n {/*==========================================\n * WHAT THIS CAMPAIGN CAUSED — the page's first section, and the\n * heading a campaign of several emails leads with too.\n *\n * The same join as the revenue below, credited under the same rule,\n * answering it for people who were anonymous until the moment being\n * counted: they arrived from a campaign link, browsed, and only\n * became somebody when they submitted a form, signed up or booked.\n *\n * THE FOUR FIGURES ARE NEVER ADDED. One person filling in one form\n * writes a submission, a contact and a lead, so a total would count\n * that visit three times — and it would look like a bigger version\n * of a real number, which is why the model carries no total for this\n * JSX to reach for and the caveat says so in words above them.\n *\n * They are laid out in a row of independent `Figure`s rather than in\n * a table with a footer, because a footer row is where a reader\n * expects the sum to be.\n *=========================================*/}\n <Section title=\"What it caused\">\n {conversionsReport.caveats.map((caveat) => (\n <Alert key={caveat.id} severity=\"info\">\n {caveat.message}\n </Alert>\n ))}\n {conversionsReport.any ? (\n <Stack spacing={1}>\n <Stack\n direction=\"row\"\n spacing={4}\n useFlexGap\n sx={{ flexWrap: 'wrap' }}\n >\n {conversionsReport.kinds.map((entry) => (\n <Figure\n key={entry.kind}\n label={entry.label}\n value={entry.value}\n note={entry.note}\n />\n ))}\n </Stack>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Credited ${conversionsReport.model === 'last-click' ? 'to the last campaign whose link the visitor clicked' : `under the ${conversionsReport.model} model`}, ` +\n `within ${conversionsReport.windowDays} days of that click. ` +\n 'Somebody who converted without ever following a campaign ' +\n 'link is credited to no campaign at all — nothing is ' +\n 'inferred from a referrer — so these are a floor rather ' +\n 'than everything this campaign influenced. The ones ' +\n 'credited to nobody are counted under Conversions in the ' +\n 'marketing console.'}\n </Typography>\n {/*\n THE RECORDS BEHIND THE FIGURES. The rollup says how many; the\n list says which, and it is the only place the uncredited half\n is counted. A link rather than a table here — the records are\n a paged read and this page's whole cost model is a fixed\n number of documents whatever the audience.\n */}\n {conversionsHub ? (\n <Box>\n <Button\n component={AppLink as any}\n {...({\n componentVariant: 'naked',\n nativeButton: false,\n } as any)}\n href={`${conversionsHub}/conversions/${campaignId}`}\n size=\"small\"\n color=\"primary\"\n >\n {'See these conversions'}\n </Button>\n </Box>\n ) : null}\n </Stack>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {conversionsReport.recorded\n ? 'Nothing has been credited to this campaign yet.'\n : 'No conversions have been attributed to this campaign. A ' +\n 'form submission, lead, contact or booking is credited to ' +\n 'the last campaign whose link the visitor clicked, within ' +\n `${conversionsReport.windowDays} days — a campaign sent ` +\n 'before that was recorded will never show a figure here.'}\n </Typography>\n )}\n </Section>\n\n <Divider />\n\n {/*==========================================\n * WHAT THIS CAMPAIGN EARNED.\n *\n * The merchant's second question, and the one every compared\n * product answers by reconstructing revenue probabilistically\n * because it does not own the order. Here it is a join: the click\n * and the order are rows in one database, so there is no tracking\n * script, no catalog sync and nothing estimated except the model.\n *\n * THE MODEL IS ON SCREEN, in a sentence, above the money. A revenue\n * figure whose rule the reader cannot state is worse than no\n * figure, because they will use it anyway — and the two things they\n * have to know to use it are which campaign gets the credit when\n * several touched the buyer, and how long a click stays creditable.\n *\n * NET LEADS. Gross and refunded are both shown beside it, because\n * \"this campaign made $4,000\" and \"this campaign made $4,000 of\n * which $3,100 came back\" are different facts about whether to send\n * another one.\n *=========================================*/}\n <Section title=\"Revenue\">\n {revenueReport.caveats.map((caveat) => (\n <Alert key={caveat.id} severity=\"info\">\n {caveat.message}\n </Alert>\n ))}\n {revenueReport.currencies.length ? (\n <Stack spacing={3}>\n {revenueReport.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. A per-currency label on a\n * report that only ever shows dollars is noise; the moment\n * there are two, the reader has to be able to see at a\n * glance that the blocks are not addable — which is also\n * what the caveat above says in words.\n */}\n {revenueReport.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 </Stack>\n <MoneyPerUnitRow\n label=\"Net revenue per delivered message\"\n figure={entry.netPerDelivered}\n />\n </Stack>\n ))}\n {/*\n * NO CONVERSION RATE, and this is where a reader would look\n * for one. Orders over delivered is not a rate: one buyer can\n * place two orders, so the quotient passes 100% without\n * anything being wrong — the same defect that keeps `opens`\n * out of the open-rate numerator two sections above. Counting\n * distinct buyers instead would need a document per person per\n * campaign, which is the per-recipient read this screen's cost\n * model exists to refuse. The order count is shown as a count.\n */}\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Credited ${revenueReport.model === 'last-click' ? 'to the last campaign whose link the buyer clicked' : `under the ${revenueReport.model} model`}, ` +\n `within ${revenueReport.windowDays} days of that click. ` +\n 'Clicks only — an open is not treated as evidence that ' +\n 'anybody read the email. An order placed by somebody who ' +\n 'never clicked, or who checked out without giving an ' +\n 'address, is credited to no campaign, so this is a floor ' +\n 'rather than every sale this campaign influenced.'}\n </Typography>\n </Stack>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {revenueReport.recorded\n ? 'No orders have been credited to this campaign.'\n : 'No revenue has been attributed to this campaign. Orders ' +\n 'are credited to the last campaign whose link the buyer ' +\n `clicked, within ${revenueReport.windowDays} days — a ` +\n 'campaign sent before that was recorded, or one on a site ' +\n 'with no store, will never show a figure here.'}\n </Typography>\n )}\n </Section>\n\n <Divider />\n\n <Section title=\"Where it sent people\">\n {/*\n The heading a campaign of several emails carries over the same\n question, so the two shapes of campaign page read alike. A\n campaign owns no page — this is where its mail was actually\n followed to, which is the only account of it the data holds.\n */}\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'The pages this campaign’s links were followed to.'}\n </Typography>\n {linkReport.rows.length ? (\n <>\n <ScrollTable size=\"small\">\n <TableHead>\n <TableRow>\n <TableCell>{'Destination'}</TableCell>\n <TableCell align=\"right\">{'Clicks'}</TableCell>\n <TableCell align=\"right\">{'Share'}</TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {linkReport.rows.map((row) => (\n <TableRow key={row.url}>\n <TableCell sx={{ wordBreak: 'break-all' }}>\n {row.url}\n </TableCell>\n <TableCell align=\"right\" sx={{ fontWeight: 'bold' }}>\n {row.clicks.toLocaleString()}\n </TableCell>\n <TableCell align=\"right\">\n {row.share\n ? `${percent(row.share.value)} of ${row.share.denominator.toLocaleString()} ${row.share.denominatorLabel}`\n : '—'}\n </TableCell>\n </TableRow>\n ))}\n </TableBody>\n </ScrollTable>\n {/*\n * The normalisation, stated rather than left for somebody to\n * discover from a total that does not add up. Two links to the\n * same page distinguished only by their UTM tags are one row\n * here, and a merchant comparing this table with the campaign\n * they built has to be told that before they conclude a link\n * is missing.\n */}\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Counted by address and path — query strings are dropped, so ' +\n 'two links to the same page with different tracking ' +\n 'parameters count as one row.'}\n </Typography>\n {linkReport.unattributedClicks ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`${linkReport.unattributedClicks.toLocaleString()} clicks ` +\n 'arrived without a destination and are not in this table.'}\n </Typography>\n ) : null}\n {linkReport.overflowClicks ? (\n <Alert severity=\"info\">\n {`This campaign has more distinct destinations than the ` +\n `rollup keeps. ${linkReport.overflowClicks.toLocaleString()} ` +\n 'clicks landed on links past that limit and are counted ' +\n 'in the click total above but not in this table.'}\n </Alert>\n ) : null}\n </>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {report.clicks\n ? 'Clicks were recorded for this campaign, but none of them ' +\n 'carried a destination, so there is nothing to break down ' +\n 'by link.'\n : 'No link clicks have been recorded for this campaign.'}\n </Typography>\n )}\n </Section>\n\n <Divider />\n\n {/*==========================================\n * THE EMAIL THE FIGURES BELOW CAME FROM — and the hinge between the\n * two halves of this page.\n *\n * This screen is reached at `/marketing/campaigns/{sendId}`, which\n * is a CAMPAIGN url resolving to a send — the fall-through that keeps\n * every unsubscribe footer and every pasted report link working. So\n * a reader arrives from the campaigns table, where the row carries a\n * \"Single send\" chip, and everything under this row is a fact about\n * a message rather than about the campaign.\n *\n * Figures with no visible source read as a campaign holding no\n * emails while reporting real numbers, which is a contradiction\n * rather than a shortage of detail. Naming the one email — and\n * saying it IS the campaign, which is what the chip already claims\n * and what `campaignListRows` already does at read time — is what\n * makes the page answer the question it raises.\n *\n * One row, from the document this card already read: no query, no\n * second listen, and the two-document cost the header describes is\n * unchanged.\n *=========================================*/}\n <Section title=\"The email in this campaign\">\n <Stack spacing={1}>\n <Stack\n direction=\"row\"\n spacing={1}\n useFlexGap\n sx={{ alignItems: 'center', flexWrap: 'wrap' }}\n >\n {/*\n The MESSAGE's own page, which the Emails console owns — hence\n the sibling hub rather than this surface's `basePath`. Plain\n text until that hub resolves: a link with no destination is\n worse than none, and the subject is what the reader came for\n either way.\n */}\n {messageHref ? (\n <AppLink href={messageHref}>{subject}</AppLink>\n ) : (\n <Typography variant=\"body2\">{subject}</Typography>\n )}\n {/*\n What the email is DOING, not the field it stores. One\n delivering an audience larger than one batch is written back\n as `scheduled` between runs, so a chip rendering the status\n said \"Scheduled\" at the head of a report of five hundred\n deliveries.\n */}\n <Chip\n size=\"small\"\n label={campaignSendDisplay(campaign as never).label}\n />\n <Chip\n size=\"small\"\n variant=\"outlined\"\n label=\"Single send\"\n title={\n 'One email, sent on its own rather than as part of a ' +\n 'campaign of several. Its report and its unsubscribe links ' +\n 'are unchanged.'\n }\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {sendTimeMs\n ? new Date(sendTimeMs).toLocaleString()\n : 'not recorded'}\n </Typography>\n </Stack>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'This campaign is one email, so the sections above are what ' +\n 'that one email caused. What follows is the mail itself — ' +\n 'how it was delivered and how it was read. Open the message ' +\n 'for its body and the people it reached.'}\n </Typography>\n </Stack>\n </Section>\n\n <Divider />\n\n {/*==========================================\n * WHAT HAPPENED TO THE MAIL.\n *\n * Counts first and rates second, in that order and not the other\n * way round, because a rate is only readable once you know what it\n * was taken over — and because the counts are the part that is\n * always true. Every rate below can be absent; none of these can.\n *=========================================*/}\n <Section title=\"Delivery\">\n <Stack direction=\"row\" spacing={4} useFlexGap sx={{ flexWrap: 'wrap' }}>\n <Figure\n label=\"Addressed\"\n value={report.recipients}\n note=\"after the per-send cap\"\n />\n <Figure\n label=\"Sent\"\n value={report.sent}\n note=\"accepted by the provider\"\n />\n <Figure\n label=\"Delivered\"\n value={report.delivered}\n note=\"accepted by the receiving server\"\n />\n <Figure label=\"Bounced\" value={report.bounced} note=\"of sent\" />\n <Figure\n label=\"Marked as spam\"\n value={report.complained}\n note=\"of delivered\"\n />\n </Stack>\n </Section>\n\n <Divider />\n\n <Section title=\"Engagement\">\n {/*\n * BOTH the event count and the distinct count, side by side.\n *\n * `Opens` is every open event — one reader opening four times is\n * four — and it is the number this product has always shown. It\n * cannot be a rate numerator: divided by anything it exceeds 100%\n * the moment somebody reads an email twice. `Readers who opened`\n * is the distinct count, and it is what the rate below divides.\n * Showing only one of them would either hide activity or invite a\n * rate nobody can defend, so both are here with different names.\n */}\n <Stack direction=\"row\" spacing={4} useFlexGap sx={{ flexWrap: 'wrap' }}>\n <Figure\n label=\"Opens\"\n value={report.opens}\n note=\"every open, repeats included\"\n />\n <Figure\n label=\"Readers who opened\"\n value={report.uniqueOpens}\n note=\"distinct recipients\"\n />\n <Figure\n label=\"Clicks\"\n value={report.clicks}\n note=\"every click, repeats included\"\n />\n <Figure\n label=\"Readers who clicked\"\n value={report.uniqueClicks}\n note=\"distinct recipients\"\n />\n <Figure\n label=\"Unsubscribed\"\n value={report.unsubscribes}\n note=\"through this campaign's link\"\n />\n </Stack>\n </Section>\n\n <Divider />\n\n <Section title=\"Rates\">\n <Stack spacing={1}>\n <RateRow label=\"Delivery rate\" rate={report.rates.delivery} />\n <RateRow label=\"Open rate\" rate={report.rates.open} />\n <RateRow label=\"Click rate\" rate={report.rates.click} />\n <RateRow\n label=\"Click-to-open rate\"\n rate={report.rates.clickToOpen}\n />\n <RateRow label=\"Bounce rate\" rate={report.rates.bounce} />\n <RateRow label=\"Complaint rate\" rate={report.rates.complaint} />\n <RateRow\n label=\"Unsubscribe rate\"\n rate={report.rates.unsubscribe}\n />\n </Stack>\n </Section>\n\n {report.populations.length ? (\n <>\n <Divider />\n <Section title=\"Who this went to\">\n {/*\n * The populations the SEND measured, recorded at send time.\n *\n * Not recomputed here, and the note under the heading says so:\n * consent records change and addresses get suppressed, so\n * asking the list today produces a number that is true of the\n * list and false of the campaign.\n */}\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Measured when this campaign was sent, and stored as it was ' +\n 'then. These figures describe the send, not the audience ' +\n 'as it stands today.'}\n </Typography>\n <ScrollTable size=\"small\">\n <TableBody>\n {report.populations.map((population) => (\n <TableRow key={population.id}>\n <TableCell>{population.label}</TableCell>\n <TableCell align=\"right\" sx={{ fontWeight: 'bold' }}>\n {population.count.toLocaleString()}\n </TableCell>\n <TableCell align=\"right\">\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`of ${population.of.toLocaleString()} ${population.ofLabel}`}\n </Typography>\n </TableCell>\n </TableRow>\n ))}\n </TableBody>\n </ScrollTable>\n </Section>\n </>\n ) : null}\n </Stack>\n </CardDisplay>\n )\n\n return (\n <>\n {/* The page heading and the trail name the send; this card is\n then free to say what it holds rather than repeating the title. */}\n <PageHeaderRecord\n title={\n campaign ? String(campaign.subject || '') || campaignId : undefined\n }\n />\n {card}\n </>\n )\n}\nCampaignReportCard.displayName = 'CampaignReportCard'\n\nexport default CampaignReportCard\n"],"names":["PageHeaderRecord","pluginDocsHelp","AppLink","CardDisplay","ScrollTable","Alert","Box","Button","Chip","Divider","Stack","TableBody","TableCell","TableHead","TableRow","Typography","useFirestore","useFirestoreDoc","campaignLinkReport","campaignReport","campaignRevenueReport","campaignConversionsReport","Figure","MoneyFigure","MoneyPerUnitRow","percent","RateRow","Section","emailSendTimeMs","campaignSendDisplay","campaignSendProgress","campaignSendDoc","campaignSendReportDoc","orgSiteHubPath","useMarketingOrgId","useMarketingOrgMount","useEmailsHubPath","reportDocsHelp","anchor","excerpt","CampaignReportCard","props","hostId","campaignId","basePath","emailsHub","orgMount","orgId","firestore","data","campaign","status","links","revenue","conversions","messageHref","conversionsHub","String","report","stats","linkReport","revenueReport","rollup","delivered","midFlight","state","conversionsReport","subject","sendTimeMs","backButton","component","componentVariant","nativeButton","href","size","color","header","help","contentGutterX","contentGutterY","HeaderProps","action","variant","card","spacing","caveats","map","caveat","severity","message","id","title","any","direction","useFlexGap","sx","flexWrap","kinds","entry","label","value","note","kind","model","windowDays","recorded","currencies","length","multiCurrency","currency","toUpperCase","cents","netCents","grossCents","refundedCents","orders","refundedOrders","figure","netPerDelivered","rows","align","row","wordBreak","url","fontWeight","clicks","toLocaleString","share","denominator","denominatorLabel","unattributedClicks","overflowClicks","alignItems","Date","recipients","sent","bounced","complained","opens","uniqueOpens","uniqueClicks","unsubscribes","rate","rates","delivery","open","click","clickToOpen","bounce","complaint","unsubscribe","populations","population","count","of","ofLabel","undefined","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,gBAAgB,EAAEC,cAAc,QAAQ,eAAc;AAC/D,SAASC,OAAO,EAAEC,WAAW,QAAQ,uBAAsB;AAC3D,SAASC,WAAW,QAAQ,yDAAwD;AACpF,SACEC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,OAAO,EACPC,KAAK,EACLC,SAAS,EACTC,SAAS,EACTC,SAAS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AAC,EAAE0B,WAAWG,OAAO,EAAE;;;;+CAPpDH,WAAW9D,EAAE;;;;;;qBAgBpC;;;;IAKV,qBACE;;0BAGE,KAAC1F;gBACC2F,OACEzC,WAAWO,OAAOP,SAASiB,OAAO,IAAI,OAAOxB,aAAaiH;;YAG7DzE;;;AAGP;AACA3C,mBAAmBqH,WAAW,GAAG;AAEjC,eAAerH,mBAAkB"}
@@ -12,9 +12,18 @@
12
12
  * existed; those carry no container id, and `campaignListRows` presents each
13
13
  * as a campaign of one rather than dropping it. Nothing is rewritten, so no
14
14
  * unsubscribe link and no pasted report URL stops resolving.
15
+ *
16
+ * ## At two levels
17
+ *
18
+ * Both collections are the organization's. Under a site the card lists the
19
+ * campaigns PLACED on that site and the sends sent AS it (see
20
+ * `campaign-queries.ts` for why those filters are what make the read legal);
21
+ * on the org hub, with `hostId` null, it lists every campaign with the sites
22
+ * each one is placed on, and a new campaign is placed where its creator says.
15
23
  */
16
24
  export declare function HostCampaignsCard(props: {
17
- hostId: string;
25
+ /** The site, or `null` on the org Marketing hub. */
26
+ hostId: string | null;
18
27
  /**
19
28
  * The marketing hub URL, when the caller already has it.
20
29
  *
@@ -27,12 +27,14 @@ import { AppLink, CardDisplay, MdiIcon, useConfirmationContext } from "@aglyn/sh
27
27
  import { ListRowActions, ListTable, listActionsColumn } from "@aglyn/shared-ui-jsx/components/list-table.component";
28
28
  import { useSnackbar } from "@aglyn/shared-ui-snackstack";
29
29
  import { Alert, Button, Chip, Stack, Typography } from "@mui/material";
30
- import { collection, doc, limit, query, setDoc } from "firebase/firestore";
30
+ import { collection, limit, query, setDoc } from "firebase/firestore";
31
31
  import { useCallback, useMemo, useState } from "react";
32
32
  import { useRouter } from "next/navigation";
33
- import { useConsoleHostRoute, useFirestore, useFirestoreCollection, useOrgDataScope, useUser } from "@aglyn/tenant-feature-instance";
34
- import { campaignListRows } from "@aglyn/shared-ui-email-campaigns/model";
33
+ import { useConsoleHostRoute, useFirestore, useFirestoreCollection, useUser } from "@aglyn/tenant-feature-instance";
34
+ import { campaignListRows, campaignSiteIds, campaignVisibleTo } from "@aglyn/shared-ui-email-campaigns/model";
35
35
  import { CreateArtifactDrawer } from "@aglyn/shared-ui-jsx-forms";
36
+ import { campaignContainerDoc, campaignContainersQuery, campaignSendsQuery } from "./campaign-queries.js";
37
+ import { orgSiteName, orgSiteOptions, topicCatalogHostId, useMarketingOrgId, useMarketingOrgMount } from "./marketing-org-mount.js";
36
38
  import { useCampaignManageApi } from "./use-campaign-send-api.js";
37
39
  import { useCampaignTopicOptions } from "./use-campaign-topic-options.js";
38
40
  /**
@@ -65,6 +67,14 @@ const WINDOW_LABEL = {
65
67
  * existed; those carry no container id, and `campaignListRows` presents each
66
68
  * as a campaign of one rather than dropping it. Nothing is rewritten, so no
67
69
  * unsubscribe link and no pasted report URL stops resolving.
70
+ *
71
+ * ## At two levels
72
+ *
73
+ * Both collections are the organization's. Under a site the card lists the
74
+ * campaigns PLACED on that site and the sends sent AS it (see
75
+ * `campaign-queries.ts` for why those filters are what make the read legal);
76
+ * on the org hub, with `hostId` null, it lists every campaign with the sites
77
+ * each one is placed on, and a new campaign is placed where its creator says.
68
78
  */ export function HostCampaignsCard(props) {
69
79
  const { hostId, basePath } = props;
70
80
  const firestore = useFirestore();
@@ -78,10 +88,10 @@ const WINDOW_LABEL = {
78
88
  const { data: user } = useUser();
79
89
  const { enqueueSnackbar } = useSnackbar();
80
90
  const { confirm } = useConfirmationContext();
81
- const manageApi = useCampaignManageApi(hostId);
82
- const { scope: dataScope } = useOrgDataScope({
83
- hostId
84
- });
91
+ const orgMount = useMarketingOrgMount();
92
+ const { orgId } = useMarketingOrgId(hostId);
93
+ // A container is the org's, so deleting one from the org hub names the org.
94
+ const manageApi = useCampaignManageApi(hostId, orgId);
85
95
  /*
86
96
  * ORDERED AND CEILINGED, and not orderable on any DATE.
87
97
  *
@@ -96,15 +106,23 @@ const WINDOW_LABEL = {
96
106
  * document-id order is what the bare cap already gave — but it says so,
97
107
  * which is what stops the next edit reaching for `sentAt`, and it probes one
98
108
  * past the ceiling so the reader is told the history is longer.
99
- */ const { data: sendDocs } = useFirestoreCollection(()=>collectionCeiling(collection(firestore, 'hosts', hostId, 'campaigns'), CAMPAIGN_CEILING), [
109
+ */ const { data: sendDocs } = useFirestoreCollection(()=>{
110
+ const sends = campaignSendsQuery(firestore, orgId, hostId);
111
+ return sends ? collectionCeiling(sends, CAMPAIGN_CEILING) : null;
112
+ }, [
100
113
  firestore,
114
+ orgId,
101
115
  hostId
102
116
  ], {
103
117
  idField: '$id'
104
118
  });
105
119
  const { rows: readSends, truncated: sendsTruncated } = ceilingedWindow(sendDocs, CAMPAIGN_CEILING);
106
- const { data: campaignDocs } = useFirestoreCollection(()=>collectionCeiling(collection(firestore, 'hosts', hostId, 'emailCampaigns'), CONTAINER_CEILING), [
120
+ const { data: campaignDocs } = useFirestoreCollection(()=>{
121
+ const containers = campaignContainersQuery(firestore, orgId, hostId);
122
+ return containers ? collectionCeiling(containers, CONTAINER_CEILING) : null;
123
+ }, [
107
124
  firestore,
125
+ orgId,
108
126
  hostId
109
127
  ], {
110
128
  idField: '$id'
@@ -112,9 +130,9 @@ const WINDOW_LABEL = {
112
130
  const { rows: readCampaigns, truncated: campaignsTruncated } = ceilingedWindow(campaignDocs, CONTAINER_CEILING);
113
131
  // Org email lists, so a row can name what it is aimed at rather than
114
132
  // showing ids.
115
- const { data: listDocs } = useFirestoreCollection(()=>dataScope ? query(collection(firestore, dataScope[0], dataScope[1], 'lists'), limit(50)) : null, [
133
+ const { data: listDocs } = useFirestoreCollection(()=>orgId ? query(collection(firestore, 'orgs', orgId, 'lists'), limit(50)) : null, [
116
134
  firestore,
117
- dataScope
135
+ orgId
118
136
  ], {
119
137
  idField: '$id'
120
138
  });
@@ -128,7 +146,7 @@ const WINDOW_LABEL = {
128
146
  * own drawer, and the one the audiences section applies to a list's
129
147
  * members. It is the largest read on this section at 200 documents, and it
130
148
  * is the only one nothing on screen needs.
131
- */ const { topics, source: topicSource } = useCampaignTopicOptions(hostId, {
149
+ */ const { topics, source: topicSource } = useCampaignTopicOptions(topicCatalogHostId(hostId, orgMount), {
132
150
  enabled: createOpen
133
151
  });
134
152
  const topicOptions = useMemo(()=>topics.map((topic)=>({
@@ -158,12 +176,18 @@ const WINDOW_LABEL = {
158
176
  ]);
159
177
  const rows = useMemo(()=>{
160
178
  const campaigns = readCampaigns.filter((campaign)=>!campaign.deletedAt);
179
+ const byId = new Map(campaigns.map((campaign)=>[
180
+ campaign.$id,
181
+ campaign
182
+ ]));
161
183
  return campaignListRows(campaigns, readSends, Date.now()).map((row)=>_extends({}, row, {
162
- $id: row.id
184
+ $id: row.id,
185
+ sitesLabel: orgMount ? campaignSitesLabel(orgMount, row, byId.get(row.id)) : ''
163
186
  }));
164
187
  }, [
165
188
  readCampaigns,
166
- readSends
189
+ readSends,
190
+ orgMount
167
191
  ]);
168
192
  const [createError, setCreateError] = useState(null);
169
193
  const [creating, setCreating] = useState(false);
@@ -192,12 +216,18 @@ const WINDOW_LABEL = {
192
216
  if (startAtMs !== null && endAtMs !== null && endAtMs < startAtMs) {
193
217
  return setCreateError('The end date is before the start date');
194
218
  }
219
+ /*
220
+ * Held until the org is known. A container has one home, and a write
221
+ * that raced the site's org lookup would have nowhere to go.
222
+ */ if (!orgId) {
223
+ return setCreateError('This workspace is still loading — try again');
224
+ }
195
225
  setCreating(true);
196
226
  setCreateError(null);
197
227
  const id = createResourceUid();
198
228
  try {
199
229
  var _ref;
200
- await setDoc(doc(firestore, 'hosts', hostId, 'emailCampaigns', id), _extends({
230
+ await setDoc(campaignContainerDoc(firestore, orgId, id), _extends({
201
231
  name
202
232
  }, Number.isFinite(startAtMs) && startAtMs !== null ? {
203
233
  startAtMs
@@ -208,6 +238,14 @@ const WINDOW_LABEL = {
208
238
  }, values.topicId ? {
209
239
  topicId: String(values.topicId)
210
240
  } : {}, {
241
+ /*
242
+ * Where it is placed. From a site's hub, that site — the creator is
243
+ * standing on it, and a campaign that appeared on every sibling
244
+ * site would be a decision nobody made. From the org hub, the sites
245
+ * picked, and every site when none are.
246
+ */ visibleTo: campaignVisibleTo(hostId ? [
247
+ hostId
248
+ ] : Array.isArray(values.siteIds) ? values.siteIds.map(String) : null),
211
249
  createdAtMs: Date.now(),
212
250
  createdBy: String((_ref = user == null ? void 0 : user.uid) != null ? _ref : '')
213
251
  }));
@@ -227,6 +265,7 @@ const WINDOW_LABEL = {
227
265
  creating,
228
266
  firestore,
229
267
  hostId,
268
+ orgId,
230
269
  user,
231
270
  enqueueSnackbar,
232
271
  openCampaign
@@ -351,6 +390,23 @@ const WINDOW_LABEL = {
351
390
  ]
352
391
  })
353
392
  },
393
+ /*
394
+ WHERE IT IS PLACED, on the org hub only. Under a site every row is on
395
+ that site by construction, so the column would say one thing thirty
396
+ times.
397
+ */ ...orgMount ? [
398
+ {
399
+ field: 'sitesLabel',
400
+ headerName: 'Sites',
401
+ width: 170,
402
+ sortable: false,
403
+ renderCell: ({ row })=>/*#__PURE__*/ _jsx(Typography, {
404
+ variant: "body2",
405
+ noWrap: true,
406
+ children: row.sitesLabel
407
+ })
408
+ }
409
+ ] : [],
354
410
  {
355
411
  field: 'windowState',
356
412
  headerName: 'Window',
@@ -543,7 +599,8 @@ const WINDOW_LABEL = {
543
599
  listNames,
544
600
  campaignHref,
545
601
  deletingId,
546
- handleDelete
602
+ handleDelete,
603
+ orgMount
547
604
  ]);
548
605
  return /*#__PURE__*/ _jsxs(CardDisplay, {
549
606
  header: 'Campaigns',
@@ -588,7 +645,7 @@ const WINDOW_LABEL = {
588
645
  }),
589
646
  sendsTruncated || campaignsTruncated ? /*#__PURE__*/ _jsx(Alert, {
590
647
  severity: "info",
591
- children: `Showing the most recent ${CONTAINER_CEILING} campaigns and ` + `${CAMPAIGN_CEILING} sends. This site has more — the ones ` + 'listed are not necessarily the most recent, because a send ' + 'carries no date field that every writer stamps.'
648
+ children: `Showing the most recent ${CONTAINER_CEILING} campaigns and ` + `${CAMPAIGN_CEILING} sends. ${hostId ? 'This site' : 'This organization'} has more — the ones ` + 'listed are not necessarily the most recent, because a send ' + 'carries no date field that every writer stamps.'
592
649
  }) : null
593
650
  ]
594
651
  }),
@@ -600,7 +657,7 @@ const WINDOW_LABEL = {
600
657
  submitLabel: "Create campaign",
601
658
  includeDescription: false,
602
659
  onSubmit: handleCreate,
603
- extraFields: campaignFields(listOptions, topicOptions),
660
+ extraFields: campaignFields(listOptions, topicOptions, orgMount ? orgSiteOptions(orgMount) : null),
604
661
  errorSlot: createError ? /*#__PURE__*/ _jsx(Alert, {
605
662
  severity: "error",
606
663
  sx: {
@@ -620,8 +677,20 @@ const WINDOW_LABEL = {
620
677
  * topics so the drawer offers what this workspace actually has. Dates are
621
678
  * plain `date` inputs: a campaign window is a day at each end, and a time of
622
679
  * day would be a precision the model does not carry.
623
- */ function campaignFields(lists, topics) {
680
+ */ function campaignFields(lists, topics, /** The org's sites, on the org hub only — a site hub places on itself. */ sites) {
624
681
  return [
682
+ ...sites ? [
683
+ {
684
+ component: 'select',
685
+ name: 'siteIds',
686
+ label: 'Sites',
687
+ multiple: true,
688
+ initialValue: [],
689
+ helperText: 'The sites this campaign is offered on. Leave empty for every site.',
690
+ disableDefaultOption: true,
691
+ options: sites
692
+ }
693
+ ] : [],
625
694
  {
626
695
  component: 'text-field',
627
696
  name: 'startAt',
@@ -661,6 +730,20 @@ const WINDOW_LABEL = {
661
730
  }
662
731
  ];
663
732
  }
733
+ /**
734
+ * The Sites cell: where a campaign is offered.
735
+ *
736
+ * A container reads its `visibleTo`; a single send, which has no container,
737
+ * is on the one site it was sent as. An empty placement is said rather than
738
+ * left blank, because a blank cell reads as "every site" and it means none.
739
+ */ function campaignSitesLabel(mount, row, container) {
740
+ var _row_sends_;
741
+ if (row.legacy) return orgSiteName(mount, (_row_sends_ = row.sends[0]) == null ? void 0 : _row_sends_.hostId) || '—';
742
+ const ids = campaignSiteIds(container);
743
+ if (ids === null) return 'Every site';
744
+ if (!ids.length) return 'No site';
745
+ return ids.map((id)=>orgSiteName(mount, id)).join(', ');
746
+ }
664
747
  HostCampaignsCard.displayName = 'HostCampaignsCard';
665
748
  export default HostCampaignsCard;
666
749