@aglyn/plugins-marketing 1.0.0-beta.220 → 1.0.0-beta.222
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/package.json +15 -15
- package/src/lib/components/campaign-conversions-card.js +53 -64
- package/src/lib/components/campaign-conversions-card.js.map +1 -1
- package/src/lib/components/campaign-detail-card.js +2 -1
- package/src/lib/components/campaign-detail-card.js.map +1 -1
- package/src/lib/components/campaign-edit-drawer.js +1 -1
- package/src/lib/components/campaign-edit-drawer.js.map +1 -1
- package/src/lib/components/campaign-queries.js +1 -1
- package/src/lib/components/campaign-queries.js.map +1 -1
- package/src/lib/components/campaign-reach-sections.js +1 -1
- package/src/lib/components/campaign-reach-sections.js.map +1 -1
- package/src/lib/components/campaign-report-card.js +5 -4
- package/src/lib/components/campaign-report-card.js.map +1 -1
- package/src/lib/components/campaigns-card.js +1 -1
- package/src/lib/components/campaigns-card.js.map +1 -1
- package/src/lib/components/email-compose-card.js +1 -1
- package/src/lib/components/email-compose-card.js.map +1 -1
- package/src/lib/components/email-detail.js +5 -4
- package/src/lib/components/email-detail.js.map +1 -1
- package/src/lib/components/email-template-report-card.d.ts +53 -0
- package/src/lib/components/email-template-report-card.js +469 -0
- package/src/lib/components/email-template-report-card.js.map +1 -0
- package/src/lib/components/emails-list-card.js +2 -2
- package/src/lib/components/emails-list-card.js.map +1 -1
- package/src/lib/components/host-experiments-card.component.js +3 -2
- package/src/lib/components/host-experiments-card.component.js.map +1 -1
- package/src/lib/components/site-runtime.js +3 -1
- package/src/lib/components/site-runtime.js.map +1 -1
- package/src/lib/declarations.server.d.ts +9 -0
- package/src/lib/declarations.server.js +62 -0
- package/src/lib/declarations.server.js.map +1 -1
- package/src/lib/model/campaign-container.d.ts +503 -0
- package/src/lib/model/campaign-container.js +498 -0
- package/src/lib/model/campaign-container.js.map +1 -0
- package/src/lib/model/campaign-conversions.d.ts +8 -1
- package/src/lib/model/campaign-conversions.js +11 -0
- package/src/lib/model/campaign-conversions.js.map +1 -1
- package/src/lib/model/campaign-report.d.ts +158 -0
- package/src/lib/model/campaign-report.js +268 -0
- package/src/lib/model/campaign-report.js.map +1 -0
- package/src/lib/model/campaign-revenue.d.ts +3 -3
- package/src/lib/model/campaign-revenue.js +3 -3
- package/src/lib/model/campaign-revenue.js.map +1 -1
- package/src/lib/model/campaign-send-time.js +2 -2
- package/src/lib/model/campaign-send-time.js.map +1 -1
- package/src/lib/model/compile-client-automations.d.ts +2 -2
- package/src/lib/model/compile-client-automations.js +3 -3
- package/src/lib/model/compile-client-automations.js.map +1 -1
- package/src/lib/model/email-record.d.ts +175 -0
- package/src/lib/model/email-record.js +206 -0
- package/src/lib/model/email-record.js.map +1 -0
- package/src/lib/model/site-contract.d.ts +2 -2
- package/src/lib/model/site-contract.js.map +1 -1
- package/src/lib/model/template-report.d.ts +158 -0
- package/src/lib/model/template-report.js +249 -0
- package/src/lib/model/template-report.js.map +1 -0
- package/src/lib/plugin.js +16 -0
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/preview-props.js.map +1 -1
- package/src/lib/server/campaign-attribution-store.d.ts +55 -0
- package/src/lib/server/campaign-attribution-store.js +98 -0
- package/src/lib/server/campaign-attribution-store.js.map +1 -0
- package/src/lib/server/campaign-conversion-attribution.d.ts +283 -0
- package/src/lib/server/campaign-conversion-attribution.js +447 -0
- package/src/lib/server/campaign-conversion-attribution.js.map +1 -0
- package/src/lib/server/campaign-manage.js +1 -1
- package/src/lib/server/campaign-manage.js.map +1 -1
- package/src/lib/server/campaign-org-refs.js +1 -1
- package/src/lib/server/campaign-org-refs.js.map +1 -1
- package/src/lib/server/campaign-recipients.js +7 -7
- package/src/lib/server/campaign-recipients.js.map +1 -1
- package/src/lib/server/campaign-send.js +25 -19
- package/src/lib/server/campaign-send.js.map +1 -1
- package/src/lib/server/conversion-creditor.d.ts +18 -0
- package/src/lib/server/conversion-creditor.js +131 -0
- package/src/lib/server/conversion-creditor.js.map +1 -0
- package/src/lib/server/email-campaign-touch.d.ts +81 -0
- package/src/lib/server/email-campaign-touch.js +227 -0
- package/src/lib/server/email-campaign-touch.js.map +1 -0
- package/src/lib/server/email-events.js +8 -6
- package/src/lib/server/email-events.js.map +1 -1
- package/src/lib/server/email-revenue-attribution.d.ts +186 -0
- package/src/lib/server/email-revenue-attribution.js +322 -0
- package/src/lib/server/email-revenue-attribution.js.map +1 -0
- package/src/lib/server/email-send-record-index.d.ts +34 -0
- package/src/lib/server/email-send-record-index.js +90 -0
- package/src/lib/server/email-send-record-index.js.map +1 -0
- package/src/lib/server/get-client-automations.js.map +1 -1
- package/src/lib/server/marketing-figures.js +3 -3
- package/src/lib/server/marketing-figures.js.map +1 -1
- package/src/lib/server/send-tally.d.ts +32 -0
- package/src/lib/server/send-tally.js +54 -0
- package/src/lib/server/send-tally.js.map +1 -0
- package/src/lib/testing/stand-in-person-records.d.ts +35 -0
- package/src/lib/testing/stand-in-person-records.js +67 -0
- package/src/lib/testing/stand-in-person-records.js.map +1 -0
- package/src/lib/testing/stand-in-record-counts.d.ts +26 -0
- package/src/lib/testing/stand-in-record-counts.js +70 -0
- package/src/lib/testing/stand-in-record-counts.js.map +1 -0
- package/src/lib/transfer/campaigns-package.d.ts +72 -0
- package/src/lib/transfer/campaigns-package.js +145 -0
- package/src/lib/transfer/campaigns-package.js.map +1 -0
- package/src/lib/transfer/campaigns-package.server.d.ts +33 -0
- package/src/lib/transfer/campaigns-package.server.js +305 -0
- package/src/lib/transfer/campaigns-package.server.js.map +1 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ /**
|
|
17
|
+
* READING ONE MESSAGE RECORD.
|
|
18
|
+
*
|
|
19
|
+
* A message — an email that was or will be sent — is a document under
|
|
20
|
+
* `hosts/{hostId}/campaigns`. Two facts about that document are awkward
|
|
21
|
+
* enough that every surface reading it gets them wrong the same way, so they
|
|
22
|
+
* are decided here once.
|
|
23
|
+
*/ /**
|
|
24
|
+
* When a message went out, or is due to.
|
|
25
|
+
*
|
|
26
|
+
* **There is no one SEND date field.** The send path writes `{status:'sent',
|
|
27
|
+
* sentAt}` from one branch and `{status:'scheduled', sendAtMs}` from another.
|
|
28
|
+
* So a list ordered on either field in Firestore does not mis-sort —
|
|
29
|
+
* `orderBy` DROPS every document missing the ordered field — and half the
|
|
30
|
+
* messages simply vanish. Sorting on this instead keeps both kinds in one
|
|
31
|
+
* ordered list.
|
|
32
|
+
*
|
|
33
|
+
* `sentAt` is a Firestore `Timestamp`, which the client SDK gives as an
|
|
34
|
+
* object with `seconds` and `toMillis()`; a document read from cache while a
|
|
35
|
+
* write is pending can carry a sentinel with neither, which reads as 0 and
|
|
36
|
+
* sorts last rather than throwing.
|
|
37
|
+
*
|
|
38
|
+
* A DRAFT correctly answers 0 here: it has no send time, and inventing one
|
|
39
|
+
* from its creation would put an unsent message on the timeline of mail that
|
|
40
|
+
* went out. Ordering a list is {@link emailListTimeMs}'s job.
|
|
41
|
+
*
|
|
42
|
+
* @returns epoch ms, or 0 when the message has no time at all.
|
|
43
|
+
*/ export function emailSendTimeMs(record) {
|
|
44
|
+
var _ref, _ref1;
|
|
45
|
+
var _record_staffReview;
|
|
46
|
+
// A send held for staff review is parked at a time no run reaches
|
|
47
|
+
// (AGL-3356). That is a mechanism, not a send time, and printed it reads as
|
|
48
|
+
// the year 9999 — so a held send answers "no time", like a draft, and the
|
|
49
|
+
// lists order it by when it was created.
|
|
50
|
+
if ((record == null ? void 0 : (_record_staffReview = record['staffReview']) == null ? void 0 : _record_staffReview['state']) === 'held' && String((_ref = record == null ? void 0 : record['status']) != null ? _ref : '') === 'scheduled') {
|
|
51
|
+
return 0;
|
|
52
|
+
}
|
|
53
|
+
const sentAt = record == null ? void 0 : record['sentAt'];
|
|
54
|
+
if (typeof (sentAt == null ? void 0 : sentAt.toMillis) === 'function') return sentAt.toMillis();
|
|
55
|
+
if (typeof (sentAt == null ? void 0 : sentAt.seconds) === 'number') return sentAt.seconds * 1000;
|
|
56
|
+
const scheduled = Number((_ref1 = record == null ? void 0 : record['sendAtMs']) != null ? _ref1 : 0);
|
|
57
|
+
return Number.isFinite(scheduled) ? scheduled : 0;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The field every writer of a message stamps when it MINTS the document.
|
|
61
|
+
*
|
|
62
|
+
* The one date on every message, which is what neither `sentAt` nor
|
|
63
|
+
* `sendAtMs` is — each is written by one branch of the send path and neither
|
|
64
|
+
* is on both kinds. A field carried by every record is the precondition for
|
|
65
|
+
* ordering this collection in Firestore rather than in the browser, because
|
|
66
|
+
* `orderBy` drops documents that lack the ordered field instead of
|
|
67
|
+
* mis-sorting them.
|
|
68
|
+
*
|
|
69
|
+
* Epoch milliseconds rather than a `Timestamp`, matching `sendAtMs` beside
|
|
70
|
+
* it: the two are compared against each other on every list that draws
|
|
71
|
+
* drafts and sends together, and a comparison that has to unwrap one side
|
|
72
|
+
* first is a comparison somebody writes wrong.
|
|
73
|
+
*/ export const EMAIL_CREATED_AT_FIELD = 'createdAtMs';
|
|
74
|
+
/**
|
|
75
|
+
* When a message was created, for the records that carry it.
|
|
76
|
+
*
|
|
77
|
+
* `null` — not 0 — for a record carrying no {@link EMAIL_CREATED_AT_FIELD},
|
|
78
|
+
* because 0 is a real instant at the far end of the sort and "we do not know"
|
|
79
|
+
* is not "1970". A null orders by the record's send time instead, so the list
|
|
80
|
+
* is correct for a record from any era.
|
|
81
|
+
*/ export function emailCreatedAtMs(record) {
|
|
82
|
+
var _ref;
|
|
83
|
+
const created = Number((_ref = record == null ? void 0 : record[EMAIL_CREATED_AT_FIELD]) != null ? _ref : Number.NaN);
|
|
84
|
+
return Number.isFinite(created) && created > 0 ? created : null;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* WHERE A MESSAGE SITS IN A LIST OF MESSAGES.
|
|
88
|
+
*
|
|
89
|
+
* Its send time where it has one, and its creation time where it does not.
|
|
90
|
+
*
|
|
91
|
+
* A draft has neither `sentAt` nor `sendAtMs`, so ordering a list on the send
|
|
92
|
+
* time alone gives every draft the key 0 and files it below mail sent years
|
|
93
|
+
* ago — the newest thing a merchant did, at the bottom of the page, behind
|
|
94
|
+
* whatever paging the list has. Falling back to creation puts it where the
|
|
95
|
+
* merchant left it.
|
|
96
|
+
*
|
|
97
|
+
* The fallback is deliberately not the other way round. A SENT message orders
|
|
98
|
+
* by when it went out, never by when it was drafted: the list is a record of
|
|
99
|
+
* what happened, and a message drafted in March and sent in June belongs in
|
|
100
|
+
* June.
|
|
101
|
+
*
|
|
102
|
+
* @returns epoch ms, or 0 for a record with no time of any kind — a draft
|
|
103
|
+
* written before the created stamp existed, which sorts last exactly as it
|
|
104
|
+
* did before.
|
|
105
|
+
*/ export function emailListTimeMs(record) {
|
|
106
|
+
return emailSendTimeMs(record) || emailCreatedAtMs(record) || 0;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Reader-facing text for a message's state.
|
|
110
|
+
*
|
|
111
|
+
* The KEYS are persisted values written by the send path and read by the
|
|
112
|
+
* scheduled-campaign processor — nothing here may change them, including
|
|
113
|
+
* `canceled`, which is already the American spelling and is a stored enum in
|
|
114
|
+
* either case. Only the right-hand side is display text, and an unrecognized
|
|
115
|
+
* state falls through as itself rather than being flattened into one of
|
|
116
|
+
* these: a state this list cannot name is worth seeing.
|
|
117
|
+
*
|
|
118
|
+
* `draft` is an email that has been created and not sent. `sending` is the
|
|
119
|
+
* claim the scheduled processor and the send-now route both take before they
|
|
120
|
+
* mail, and it is named here because a merchant who reloads mid-send would
|
|
121
|
+
* otherwise be shown the raw token.
|
|
122
|
+
*
|
|
123
|
+
* ⚠️ **Not what a console row should draw.** This names the STORED value, and
|
|
124
|
+
* an email delivering an audience larger than one batch is stored as
|
|
125
|
+
* `scheduled` between runs — so a row rendering this says "Scheduled" about a
|
|
126
|
+
* send that has already put five hundred messages in five hundred inboxes.
|
|
127
|
+
* `campaignSendDisplay` in `campaign-container.ts` reads the counters beside
|
|
128
|
+
* the status and is what every surface here draws. This remains the honest
|
|
129
|
+
* answer to the narrower question of what one stored token means.
|
|
130
|
+
*/ export function emailStateLabel(status) {
|
|
131
|
+
const value = String(status != null ? status : '');
|
|
132
|
+
if (value === 'sent') return 'Sent';
|
|
133
|
+
if (value === 'scheduled') return 'Scheduled';
|
|
134
|
+
if (value === 'canceled') return 'Canceled';
|
|
135
|
+
if (value === 'draft') return 'Draft';
|
|
136
|
+
if (value === 'sending') return 'Sending';
|
|
137
|
+
return value || 'Unknown';
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Whether an email has yet been mailed to anybody.
|
|
141
|
+
*
|
|
142
|
+
* The surfaces that report on a send need this because an unsent email has no
|
|
143
|
+
* `stats` at all, and a report that divides into an absent denominator
|
|
144
|
+
* presents "not sent yet" as a delivery rate of 0% — the same class of fault
|
|
145
|
+
* as a rate rendered over a denominator it does not name.
|
|
146
|
+
*/ export function emailIsUnsent(record) {
|
|
147
|
+
var _ref;
|
|
148
|
+
const value = String((_ref = record == null ? void 0 : record['status']) != null ? _ref : '');
|
|
149
|
+
return value === 'draft' || value === 'scheduled' || value === 'sending';
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Reader-facing names for the built-in audience kinds.
|
|
153
|
+
*
|
|
154
|
+
* The KEYS are the persisted `audience` values written on every message since
|
|
155
|
+
* the composer shipped; only the values on the right are display text. A
|
|
156
|
+
* `list` audience is deliberately absent — it is not a kind of audience, it
|
|
157
|
+
* is a NAMED one, and naming it is {@link emailAudienceLabel}'s job.
|
|
158
|
+
*/ export const EMAIL_AUDIENCE_LABELS = {
|
|
159
|
+
leads: 'All leads',
|
|
160
|
+
members: 'All site members',
|
|
161
|
+
segment: 'A contact segment',
|
|
162
|
+
manual: 'Addresses typed into the composer'
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Which audience a message went to, named for a reader.
|
|
166
|
+
*
|
|
167
|
+
* A list send is named by the name the SEND recorded, never by the name the
|
|
168
|
+
* list carries today: resolving it now would let a rename rewrite the history
|
|
169
|
+
* of a message that went out months ago, and a deletion erase it. A send that
|
|
170
|
+
* recorded no name says so instead of printing a document id, which is not
|
|
171
|
+
* something a merchant recognises as a list.
|
|
172
|
+
*/ export function emailAudienceLabel(record) {
|
|
173
|
+
var _ref, _ref1;
|
|
174
|
+
const audience = String((_ref = record == null ? void 0 : record['audience']) != null ? _ref : '');
|
|
175
|
+
if (audience !== 'list') {
|
|
176
|
+
var _ref2, _EMAIL_AUDIENCE_LABELS_audience;
|
|
177
|
+
return (_ref2 = (_EMAIL_AUDIENCE_LABELS_audience = EMAIL_AUDIENCE_LABELS[audience]) != null ? _EMAIL_AUDIENCE_LABELS_audience : audience) != null ? _ref2 : 'Not recorded';
|
|
178
|
+
}
|
|
179
|
+
const name = String((_ref1 = record == null ? void 0 : record['listName']) != null ? _ref1 : '');
|
|
180
|
+
if (name) return name;
|
|
181
|
+
return (record == null ? void 0 : record['listId']) ? 'A list this send did not name' : 'A list this send did not record';
|
|
182
|
+
}
|
|
183
|
+
export function emailSentAs(record) {
|
|
184
|
+
var _ref, _ref1, _ref2;
|
|
185
|
+
const stamp = record == null ? void 0 : record['sentAs'];
|
|
186
|
+
const from = String((_ref = stamp == null ? void 0 : stamp['from']) != null ? _ref : '').trim();
|
|
187
|
+
// The ADDRESS is what makes the stamp a record of a send. A `sentAs` map
|
|
188
|
+
// carrying only a display name is a partial write, and reporting it as
|
|
189
|
+
// recorded would put a name on screen beside an address nothing supplied.
|
|
190
|
+
if (!from) {
|
|
191
|
+
return {
|
|
192
|
+
recorded: false,
|
|
193
|
+
from: null,
|
|
194
|
+
fromName: null,
|
|
195
|
+
replyTo: null
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
return {
|
|
199
|
+
recorded: true,
|
|
200
|
+
from,
|
|
201
|
+
fromName: String((_ref1 = stamp == null ? void 0 : stamp['fromName']) != null ? _ref1 : '').trim() || null,
|
|
202
|
+
replyTo: String((_ref2 = stamp == null ? void 0 : stamp['replyTo']) != null ? _ref2 : '').trim() || null
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
//# sourceMappingURL=email-record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/marketing/src/lib/model/email-record.ts"],"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\n/**\n * READING ONE MESSAGE RECORD.\n *\n * A message — an email that was or will be sent — is a document under\n * `hosts/{hostId}/campaigns`. Two facts about that document are awkward\n * enough that every surface reading it gets them wrong the same way, so they\n * are decided here once.\n */\n\n/**\n * When a message went out, or is due to.\n *\n * **There is no one SEND date field.** The send path writes `{status:'sent',\n * sentAt}` from one branch and `{status:'scheduled', sendAtMs}` from another.\n * So a list ordered on either field in Firestore does not mis-sort —\n * `orderBy` DROPS every document missing the ordered field — and half the\n * messages simply vanish. Sorting on this instead keeps both kinds in one\n * ordered list.\n *\n * `sentAt` is a Firestore `Timestamp`, which the client SDK gives as an\n * object with `seconds` and `toMillis()`; a document read from cache while a\n * write is pending can carry a sentinel with neither, which reads as 0 and\n * sorts last rather than throwing.\n *\n * A DRAFT correctly answers 0 here: it has no send time, and inventing one\n * from its creation would put an unsent message on the timeline of mail that\n * went out. Ordering a list is {@link emailListTimeMs}'s job.\n *\n * @returns epoch ms, or 0 when the message has no time at all.\n */\nexport function emailSendTimeMs(\n record: Record<string, any> | null | undefined,\n): number {\n // A send held for staff review is parked at a time no run reaches\n // (AGL-3356). That is a mechanism, not a send time, and printed it reads as\n // the year 9999 — so a held send answers \"no time\", like a draft, and the\n // lists order it by when it was created.\n if (\n record?.['staffReview']?.['state'] === 'held' &&\n String(record?.['status'] ?? '') === 'scheduled'\n ) {\n return 0\n }\n const sentAt = record?.['sentAt'] as\n | { toMillis?: () => number; seconds?: number }\n | undefined\n if (typeof sentAt?.toMillis === 'function') return sentAt.toMillis()\n if (typeof sentAt?.seconds === 'number') return sentAt.seconds * 1000\n const scheduled = Number(record?.['sendAtMs'] ?? 0)\n return Number.isFinite(scheduled) ? scheduled : 0\n}\n\n/**\n * The field every writer of a message stamps when it MINTS the document.\n *\n * The one date on every message, which is what neither `sentAt` nor\n * `sendAtMs` is — each is written by one branch of the send path and neither\n * is on both kinds. A field carried by every record is the precondition for\n * ordering this collection in Firestore rather than in the browser, because\n * `orderBy` drops documents that lack the ordered field instead of\n * mis-sorting them.\n *\n * Epoch milliseconds rather than a `Timestamp`, matching `sendAtMs` beside\n * it: the two are compared against each other on every list that draws\n * drafts and sends together, and a comparison that has to unwrap one side\n * first is a comparison somebody writes wrong.\n */\nexport const EMAIL_CREATED_AT_FIELD = 'createdAtMs'\n\n/**\n * When a message was created, for the records that carry it.\n *\n * `null` — not 0 — for a record carrying no {@link EMAIL_CREATED_AT_FIELD},\n * because 0 is a real instant at the far end of the sort and \"we do not know\"\n * is not \"1970\". A null orders by the record's send time instead, so the list\n * is correct for a record from any era.\n */\nexport function emailCreatedAtMs(\n record: Record<string, any> | null | undefined,\n): number | null {\n const created = Number(record?.[EMAIL_CREATED_AT_FIELD] ?? Number.NaN)\n return Number.isFinite(created) && created > 0 ? created : null\n}\n\n/**\n * WHERE A MESSAGE SITS IN A LIST OF MESSAGES.\n *\n * Its send time where it has one, and its creation time where it does not.\n *\n * A draft has neither `sentAt` nor `sendAtMs`, so ordering a list on the send\n * time alone gives every draft the key 0 and files it below mail sent years\n * ago — the newest thing a merchant did, at the bottom of the page, behind\n * whatever paging the list has. Falling back to creation puts it where the\n * merchant left it.\n *\n * The fallback is deliberately not the other way round. A SENT message orders\n * by when it went out, never by when it was drafted: the list is a record of\n * what happened, and a message drafted in March and sent in June belongs in\n * June.\n *\n * @returns epoch ms, or 0 for a record with no time of any kind — a draft\n * written before the created stamp existed, which sorts last exactly as it\n * did before.\n */\nexport function emailListTimeMs(\n record: Record<string, any> | null | undefined,\n): number {\n return emailSendTimeMs(record) || emailCreatedAtMs(record) || 0\n}\n\n/**\n * Reader-facing text for a message's state.\n *\n * The KEYS are persisted values written by the send path and read by the\n * scheduled-campaign processor — nothing here may change them, including\n * `canceled`, which is already the American spelling and is a stored enum in\n * either case. Only the right-hand side is display text, and an unrecognized\n * state falls through as itself rather than being flattened into one of\n * these: a state this list cannot name is worth seeing.\n *\n * `draft` is an email that has been created and not sent. `sending` is the\n * claim the scheduled processor and the send-now route both take before they\n * mail, and it is named here because a merchant who reloads mid-send would\n * otherwise be shown the raw token.\n *\n * ⚠️ **Not what a console row should draw.** This names the STORED value, and\n * an email delivering an audience larger than one batch is stored as\n * `scheduled` between runs — so a row rendering this says \"Scheduled\" about a\n * send that has already put five hundred messages in five hundred inboxes.\n * `campaignSendDisplay` in `campaign-container.ts` reads the counters beside\n * the status and is what every surface here draws. This remains the honest\n * answer to the narrower question of what one stored token means.\n */\nexport function emailStateLabel(status: unknown): string {\n const value = String(status ?? '')\n if (value === 'sent') return 'Sent'\n if (value === 'scheduled') return 'Scheduled'\n if (value === 'canceled') return 'Canceled'\n if (value === 'draft') return 'Draft'\n if (value === 'sending') return 'Sending'\n return value || 'Unknown'\n}\n\n/**\n * Whether an email has yet been mailed to anybody.\n *\n * The surfaces that report on a send need this because an unsent email has no\n * `stats` at all, and a report that divides into an absent denominator\n * presents \"not sent yet\" as a delivery rate of 0% — the same class of fault\n * as a rate rendered over a denominator it does not name.\n */\nexport function emailIsUnsent(\n record: Record<string, any> | null | undefined,\n): boolean {\n const value = String(record?.['status'] ?? '')\n return value === 'draft' || value === 'scheduled' || value === 'sending'\n}\n\n/**\n * Reader-facing names for the built-in audience kinds.\n *\n * The KEYS are the persisted `audience` values written on every message since\n * the composer shipped; only the values on the right are display text. A\n * `list` audience is deliberately absent — it is not a kind of audience, it\n * is a NAMED one, and naming it is {@link emailAudienceLabel}'s job.\n */\nexport const EMAIL_AUDIENCE_LABELS: Record<string, string> = {\n leads: 'All leads',\n members: 'All site members',\n segment: 'A contact segment',\n manual: 'Addresses typed into the composer',\n}\n\n/**\n * Which audience a message went to, named for a reader.\n *\n * A list send is named by the name the SEND recorded, never by the name the\n * list carries today: resolving it now would let a rename rewrite the history\n * of a message that went out months ago, and a deletion erase it. A send that\n * recorded no name says so instead of printing a document id, which is not\n * something a merchant recognises as a list.\n */\nexport function emailAudienceLabel(\n record: Record<string, any> | null | undefined,\n): string {\n const audience = String(record?.['audience'] ?? '')\n if (audience !== 'list') {\n return EMAIL_AUDIENCE_LABELS[audience] ?? audience ?? 'Not recorded'\n }\n const name = String(record?.['listName'] ?? '')\n if (name) return name\n return record?.['listId']\n ? 'A list this send did not name'\n : 'A list this send did not record'\n}\n\n/**\n * The sender a message actually left with, as this record has it.\n *\n * `recorded` is the whole point of the shape. The address a send goes out on\n * is stamped by the send — see `sentAsStamp` — and every message sent before\n * that stamp existed carries nothing, so a surface has to be able to tell an\n * unrecorded sender apart from one it could compose. Composing it is the\n * thing that must not happen: a site's sending identity is a setting, and\n * resolving it now would answer \"what would this send as today\" on a report\n * whose subject is a message that went out months ago, under whatever address\n * the site held then.\n *\n * The same rule {@link emailAudienceLabel} follows for a list name, and for\n * the same reason: the report says what happened, not what would happen now.\n *\n * `replyTo` is null on a message that set none, which is not missing\n * information — a message with no `Reply-To:` takes replies at its `from`,\n * and that is a fact the record states by omission rather than one it lost.\n * The difference only reads correctly when `recorded` is true, which is why\n * a caller must consult that first.\n */\nexport interface EmailSentAs {\n /** False on a message sent before the send began stamping its sender. */\n recorded: boolean\n from: string | null\n /** The display name recipients saw, or null when the address stood alone. */\n fromName: string | null\n /** Where replies were pointed, or null when they go to `from`. */\n replyTo: string | null\n}\n\nexport function emailSentAs(\n record: Record<string, any> | null | undefined,\n): EmailSentAs {\n const stamp = record?.['sentAs'] as Record<string, any> | null | undefined\n const from = String(stamp?.['from'] ?? '').trim()\n // The ADDRESS is what makes the stamp a record of a send. A `sentAs` map\n // carrying only a display name is a partial write, and reporting it as\n // recorded would put a name on screen beside an address nothing supplied.\n if (!from) {\n return { recorded: false, from: null, fromName: null, replyTo: null }\n }\n return {\n recorded: true,\n from,\n fromName: String(stamp?.['fromName'] ?? '').trim() || null,\n replyTo: String(stamp?.['replyTo'] ?? '').trim() || null,\n }\n}\n"],"names":["emailSendTimeMs","record","String","sentAt","toMillis","seconds","scheduled","Number","isFinite","EMAIL_CREATED_AT_FIELD","emailCreatedAtMs","created","NaN","emailListTimeMs","emailStateLabel","status","value","emailIsUnsent","EMAIL_AUDIENCE_LABELS","leads","members","segment","manual","emailAudienceLabel","audience","name","emailSentAs","stamp","from","trim","recorded","fromName","replyTo"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;CAOC,GAED;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,SAASA,gBACdC,MAA8C;;QAO5CA;IALF,kEAAkE;IAClE,4EAA4E;IAC5E,0EAA0E;IAC1E,yCAAyC;IACzC,IACEA,CAAAA,2BAAAA,sBAAAA,MAAQ,CAAC,cAAc,qBAAvBA,mBAAyB,CAAC,QAAQ,MAAK,UACvCC,eAAOD,0BAAAA,MAAQ,CAAC,SAAS,mBAAI,QAAQ,aACrC;QACA,OAAO;IACT;IACA,MAAME,SAASF,0BAAAA,MAAQ,CAAC,SAAS;IAGjC,IAAI,QAAOE,0BAAAA,OAAQC,QAAQ,MAAK,YAAY,OAAOD,OAAOC,QAAQ;IAClE,IAAI,QAAOD,0BAAAA,OAAQE,OAAO,MAAK,UAAU,OAAOF,OAAOE,OAAO,GAAG;IACjE,MAAMC,YAAYC,gBAAON,0BAAAA,MAAQ,CAAC,WAAW,oBAAI;IACjD,OAAOM,OAAOC,QAAQ,CAACF,aAAaA,YAAY;AAClD;AAEA;;;;;;;;;;;;;;CAcC,GACD,OAAO,MAAMG,yBAAyB,cAAa;AAEnD;;;;;;;CAOC,GACD,OAAO,SAASC,iBACdT,MAA8C;;IAE9C,MAAMU,UAAUJ,eAAON,0BAAAA,MAAQ,CAACQ,uBAAuB,mBAAIF,OAAOK,GAAG;IACrE,OAAOL,OAAOC,QAAQ,CAACG,YAAYA,UAAU,IAAIA,UAAU;AAC7D;AAEA;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,SAASE,gBACdZ,MAA8C;IAE9C,OAAOD,gBAAgBC,WAAWS,iBAAiBT,WAAW;AAChE;AAEA;;;;;;;;;;;;;;;;;;;;;;CAsBC,GACD,OAAO,SAASa,gBAAgBC,MAAe;IAC7C,MAAMC,QAAQd,OAAOa,iBAAAA,SAAU;IAC/B,IAAIC,UAAU,QAAQ,OAAO;IAC7B,IAAIA,UAAU,aAAa,OAAO;IAClC,IAAIA,UAAU,YAAY,OAAO;IACjC,IAAIA,UAAU,SAAS,OAAO;IAC9B,IAAIA,UAAU,WAAW,OAAO;IAChC,OAAOA,SAAS;AAClB;AAEA;;;;;;;CAOC,GACD,OAAO,SAASC,cACdhB,MAA8C;;IAE9C,MAAMe,QAAQd,eAAOD,0BAAAA,MAAQ,CAAC,SAAS,mBAAI;IAC3C,OAAOe,UAAU,WAAWA,UAAU,eAAeA,UAAU;AACjE;AAEA;;;;;;;CAOC,GACD,OAAO,MAAME,wBAAgD;IAC3DC,OAAO;IACPC,SAAS;IACTC,SAAS;IACTC,QAAQ;AACV,EAAC;AAED;;;;;;;;CAQC,GACD,OAAO,SAASC,mBACdtB,MAA8C;;IAE9C,MAAMuB,WAAWtB,eAAOD,0BAAAA,MAAQ,CAAC,WAAW,mBAAI;IAChD,IAAIuB,aAAa,QAAQ;YAChBN,OAAAA;QAAP,QAAOA,SAAAA,kCAAAA,qBAAqB,CAACM,SAAS,YAA/BN,kCAAmCM,oBAAnCN,QAA+C;IACxD;IACA,MAAMO,OAAOvB,gBAAOD,0BAAAA,MAAQ,CAAC,WAAW,oBAAI;IAC5C,IAAIwB,MAAM,OAAOA;IACjB,OAAOxB,CAAAA,0BAAAA,MAAQ,CAAC,SAAS,IACrB,kCACA;AACN;AAiCA,OAAO,SAASyB,YACdzB,MAA8C;;IAE9C,MAAM0B,QAAQ1B,0BAAAA,MAAQ,CAAC,SAAS;IAChC,MAAM2B,OAAO1B,eAAOyB,yBAAAA,KAAO,CAAC,OAAO,mBAAI,IAAIE,IAAI;IAC/C,yEAAyE;IACzE,uEAAuE;IACvE,0EAA0E;IAC1E,IAAI,CAACD,MAAM;QACT,OAAO;YAAEE,UAAU;YAAOF,MAAM;YAAMG,UAAU;YAAMC,SAAS;QAAK;IACtE;IACA,OAAO;QACLF,UAAU;QACVF;QACAG,UAAU7B,gBAAOyB,yBAAAA,KAAO,CAAC,WAAW,oBAAI,IAAIE,IAAI,MAAM;QACtDG,SAAS9B,gBAAOyB,yBAAAA,KAAO,CAAC,UAAU,oBAAI,IAAIE,IAAI,MAAM;IACtD;AACF"}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* reads back. Pure types — shared by the /server graph and the client
|
|
21
21
|
* runtime without pulling either's dependencies.
|
|
22
22
|
*/
|
|
23
|
-
import type {
|
|
23
|
+
import type { ClientInteractionStep, SiteEventType } from '@aglyn/aglyn';
|
|
24
24
|
import type { ExperimentStatus } from './experiments';
|
|
25
25
|
export interface ClientAutomation {
|
|
26
26
|
id: string;
|
|
@@ -35,7 +35,7 @@ export interface ClientAutomation {
|
|
|
35
35
|
cooldownMinutes?: number;
|
|
36
36
|
/** Fire on every occurrence, not once per pageview (AGL-562). */
|
|
37
37
|
everyTime?: boolean;
|
|
38
|
-
steps:
|
|
38
|
+
steps: ClientInteractionStep[];
|
|
39
39
|
hasServerSteps: boolean;
|
|
40
40
|
}
|
|
41
41
|
export interface ScreenExperiment {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/marketing/src/lib/model/site-contract.ts"],"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\n/**\n * The marketing plugin's site wire contract (AGL-419): shapes its server\n * page-enricher writes into the page props and its client site-runtime\n * reads back. Pure types — shared by the /server graph and the client\n * runtime without pulling either's dependencies.\n */\n\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/marketing/src/lib/model/site-contract.ts"],"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\n/**\n * The marketing plugin's site wire contract (AGL-419): shapes its server\n * page-enricher writes into the page props and its client site-runtime\n * reads back. Pure types — shared by the /server graph and the client\n * runtime without pulling either's dependencies.\n */\n\nimport type { ClientInteractionStep, SiteEventType } from '@aglyn/aglyn'\nimport type { ExperimentStatus } from './experiments'\n\nexport interface ClientAutomation {\n id: string\n event: SiteEventType\n selector?: string\n threshold?: number\n /** Fire at most once per visitor (AGL-266). */\n oncePerVisitor?: boolean\n /** Fire at most once per browser session (AGL-274). */\n oncePerSession?: boolean\n /** Minimum minutes between fires for the same visitor (AGL-274). */\n cooldownMinutes?: number\n /** Fire on every occurrence, not once per pageview (AGL-562). */\n everyTime?: boolean\n steps: ClientInteractionStep[]\n hasServerSteps: boolean\n}\n\nexport interface ScreenExperiment {\n id: string\n target: 'screen' | 'section'\n status: ExperimentStatus\n nodeId?: string\n winnerVariantId?: string\n /** Past this the client runner serves the default (AGL-273). */\n endAtMs?: number\n goal?: { event: string; filter?: string }\n variants: Array<{ id: string; weight?: number; versionId?: string }>\n payloads: Record<string, Record<string, any> | null>\n}\n\nexport interface AnnouncementBarData {\n text: string\n href?: string\n backgroundColor?: string\n textColor?: string\n dismissible: boolean\n contentHash: string\n overlayId?: string\n}\n\nexport interface PopupData {\n headline?: string\n body: string\n imageUrl?: string\n /**\n * Alt text for {@link imageUrl} (AGL-1896).\n *\n * The popup image used to render with a hardcoded `alt=\"\"` and there was\n * no field anywhere that could have changed it — an author-chosen banner,\n * on a paying customer's published site, invisible to a screen reader by\n * construction. Defaults from the DAM asset's own alt when the author\n * picks one through \"Browse media\"; an empty value still renders `alt=\"\"`,\n * which is the right markup for a genuinely decorative banner.\n */\n imageAlt?: string\n ctaLabel?: string\n ctaHref?: string\n trigger: string\n triggerValue: number\n frequencyDays: number\n /**\n * Cap the popup to one showing per browser session (AGL-2174). When\n * set, `frequencyDays` is not consulted — the two are alternative\n * answers to the same question.\n */\n oncePerSession?: boolean\n collectEmail?: boolean\n startAtMs?: number\n endAtMs?: number\n contentHash: string\n overlayId?: string\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;CAKC,GA6CD,WA+BC"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* ONE DESIGN, MEASURED ACROSS EVERY CAMPAIGN THAT USED IT.
|
|
19
|
+
*
|
|
20
|
+
* ## What this adds to `campaign-report.ts`
|
|
21
|
+
*
|
|
22
|
+
* A campaign report divides two numbers that were recorded by the same send.
|
|
23
|
+
* A design report divides two SUMS, and a sum has a membership: which
|
|
24
|
+
* campaigns went into it. That is the whole difficulty, and it is a new way
|
|
25
|
+
* for the repo's rule — every rate names its denominator — to be broken.
|
|
26
|
+
*
|
|
27
|
+
* ## The rule, restated for a sum
|
|
28
|
+
*
|
|
29
|
+
* **A rate's numerator and its denominator are summed over the SAME set of
|
|
30
|
+
* campaigns, and the screen is told how large that set is.**
|
|
31
|
+
*
|
|
32
|
+
* `delivered` is written only by the delivery webhook, so a design used by
|
|
33
|
+
* five campaigns may have three that recorded it and two that never did.
|
|
34
|
+
* Summing `uniqueOpens` over all five and dividing by `delivered` summed over
|
|
35
|
+
* three produces an open rate that can exceed 100% and is, in every case,
|
|
36
|
+
* the flattering substitution `campaign-report.ts` exists to refuse — carried
|
|
37
|
+
* out by addition instead of by picking the wrong field.
|
|
38
|
+
*
|
|
39
|
+
* So each rate here is built from a FILTERED subset, and
|
|
40
|
+
* {@link TemplateRate.denominatorLabel} names the subset as well as the
|
|
41
|
+
* quantity: `delivered across 3 of 5 campaigns`. A reader comparing this
|
|
42
|
+
* design's open rate with another's can see the two were taken over different
|
|
43
|
+
* populations without being told separately.
|
|
44
|
+
*
|
|
45
|
+
* ## Counts are over everything; rates are over what can be divided
|
|
46
|
+
*
|
|
47
|
+
* The COUNTS — opens, clicks, unsubscribes — are summed over every campaign,
|
|
48
|
+
* because a count is true whatever else was recorded. Only the rates narrow.
|
|
49
|
+
* The two are labelled differently on screen for that reason, and the caveats
|
|
50
|
+
* say how many campaigns each rate left out.
|
|
51
|
+
*
|
|
52
|
+
* ## Why this is a pure module
|
|
53
|
+
*
|
|
54
|
+
* Same reason as `campaign-report.ts`: a division written in JSX is a
|
|
55
|
+
* denominator chosen by whoever writes the next card. Here it is worse — the
|
|
56
|
+
* subset is invisible in the output unless something carries it — so the
|
|
57
|
+
* subset is data, computed once, and the screen renders it.
|
|
58
|
+
*/
|
|
59
|
+
import { type SendRate, type SendStats } from '@aglyn/shared-ui-email-campaigns/model/send-report';
|
|
60
|
+
/** A rate over a sum, carrying how many campaigns the sum covers. */
|
|
61
|
+
export type TemplateRate = SendRate;
|
|
62
|
+
/**
|
|
63
|
+
* One campaign that used the design, as the report reads it.
|
|
64
|
+
*
|
|
65
|
+
* `sentAtMs` is nullable because a campaign document can exist without ever
|
|
66
|
+
* having been sent — a scheduled campaign holds `sendAtMs` and no `sentAt`.
|
|
67
|
+
* Those carry no engagement and the reader is shown their status rather than
|
|
68
|
+
* a row of zeroes.
|
|
69
|
+
*/
|
|
70
|
+
export interface TemplateCampaign {
|
|
71
|
+
campaignId: string;
|
|
72
|
+
subject: string;
|
|
73
|
+
/** Epoch ms, or null for a campaign that has not been sent. */
|
|
74
|
+
sentAtMs: number | null;
|
|
75
|
+
/** `'sent'`, `'scheduled'`, `'canceled'`. A persisted value; not relabeled. */
|
|
76
|
+
status: string;
|
|
77
|
+
/** The audience KIND — `'leads'`, `'members'`, `'segment'`, `'list'`. */
|
|
78
|
+
audience: string;
|
|
79
|
+
/** Set when `audience` is `'list'`. */
|
|
80
|
+
listId?: string;
|
|
81
|
+
/** The list's name AS IT WAS at send time, when the send recorded one. */
|
|
82
|
+
listName?: string;
|
|
83
|
+
stats: SendStats | undefined;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* One audience the design was sent to.
|
|
87
|
+
*
|
|
88
|
+
* A LIST is named by the name the send recorded, not by the name the list
|
|
89
|
+
* carries today: a renamed or deleted list would otherwise rewrite the
|
|
90
|
+
* history of a campaign that went out months ago, and a deleted one would
|
|
91
|
+
* erase it. The same reasoning as the campaign report's populations.
|
|
92
|
+
*/
|
|
93
|
+
export interface TemplateAudience {
|
|
94
|
+
/** Stable key — the list id, or the audience kind for the built-ins. */
|
|
95
|
+
id: string;
|
|
96
|
+
label: string;
|
|
97
|
+
/** How many campaigns using this design went to this audience. */
|
|
98
|
+
campaigns: number;
|
|
99
|
+
/** Addresses those campaigns ADDRESSED, summed. */
|
|
100
|
+
addressed: number;
|
|
101
|
+
/**
|
|
102
|
+
* The named list has since been deleted or renamed out of reach.
|
|
103
|
+
*
|
|
104
|
+
* Only ever true for a `list` audience, and only when the send recorded no
|
|
105
|
+
* name — an older send, before the name was stored. The screen says "list
|
|
106
|
+
* no longer named" rather than printing a raw document id as if it were
|
|
107
|
+
* something a merchant would recognise.
|
|
108
|
+
*/
|
|
109
|
+
unnamed?: boolean;
|
|
110
|
+
}
|
|
111
|
+
/** Why a number the design report would otherwise show is being withheld. */
|
|
112
|
+
export interface TemplateCaveat {
|
|
113
|
+
id: 'no-campaigns' | 'delivery-partial' | 'click-tracking-partial' | 'campaigns-truncated' | 'audience-truncated';
|
|
114
|
+
message: string;
|
|
115
|
+
}
|
|
116
|
+
/** Everything the design report screen renders. */
|
|
117
|
+
export interface TemplateReport {
|
|
118
|
+
/** Campaigns that used this design AND were sent. */
|
|
119
|
+
sentCampaigns: number;
|
|
120
|
+
/** Campaigns that used this design, sent or not. */
|
|
121
|
+
totalCampaigns: number;
|
|
122
|
+
/** Epoch ms of the most recent send, or null. */
|
|
123
|
+
lastSentAtMs: number | null;
|
|
124
|
+
recipients: number;
|
|
125
|
+
sent: number;
|
|
126
|
+
/** Summed over the campaigns that recorded it; null when none did. */
|
|
127
|
+
delivered: number | null;
|
|
128
|
+
opens: number;
|
|
129
|
+
clicks: number;
|
|
130
|
+
uniqueOpens: number | null;
|
|
131
|
+
uniqueClicks: number | null;
|
|
132
|
+
bounced: number;
|
|
133
|
+
complained: number;
|
|
134
|
+
unsubscribes: number;
|
|
135
|
+
/** Rates, each `null` when its denominator is zero or unrecorded. */
|
|
136
|
+
rates: {
|
|
137
|
+
delivery: TemplateRate | null;
|
|
138
|
+
open: TemplateRate | null;
|
|
139
|
+
click: TemplateRate | null;
|
|
140
|
+
clickToOpen: TemplateRate | null;
|
|
141
|
+
bounce: TemplateRate | null;
|
|
142
|
+
complaint: TemplateRate | null;
|
|
143
|
+
unsubscribe: TemplateRate | null;
|
|
144
|
+
};
|
|
145
|
+
audiences: TemplateAudience[];
|
|
146
|
+
caveats: TemplateCaveat[];
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Aggregates every campaign that used one design.
|
|
150
|
+
*
|
|
151
|
+
* @param campaigns every campaign document naming this design, sent or not.
|
|
152
|
+
* @param truncated the query that produced `campaigns` stopped at its read
|
|
153
|
+
* ceiling, so every total here is a FLOOR. Reported as a caveat rather
|
|
154
|
+
* than hidden, on the same reasoning as `audienceSizeTruncated`: a
|
|
155
|
+
* figure that is at least this large is useful, and a figure presented
|
|
156
|
+
* as complete when it is not is worse than none.
|
|
157
|
+
*/
|
|
158
|
+
export declare function templateReport(campaigns: readonly TemplateCampaign[], truncated?: boolean): TemplateReport;
|