diff --git a/telemetry-worker/src/report-email.ts b/telemetry-worker/src/report-email.ts index 8f47bad5..ecb33a1b 100644 --- a/telemetry-worker/src/report-email.ts +++ b/telemetry-worker/src/report-email.ts @@ -4,41 +4,33 @@ // - Pure: the same report gives the same email. Everything from outside (app and page names, the model's words, // design sites, pull request names) goes through esc() and is a line of text; links are https and built in // src/report.ts or here from the report's own origin. -// - Email-safe HTML: tables, inline styles, no script, no external CSS, one image (the logo, from genclass.dev). A -// `; /** The HTML body. Pure. */ export function htmlOf(r: Report): string { - const head = ` - -
GenClass${esc(day(r.generated))}, ${esc(clock(r.generated))}
`; - // a new account's first step is to connect its app: that card comes before the empty numbers + const l = leadOf(r); + // the date (the subject says which report); the hour too when reports come hourly or this is an alert + const when = `${r.kind === "alert" ? "Alert · " : r.kind === "test" ? "Test · " : ""}${day(r.generated)}${r.kind === "alert" || r.every === "hourly" ? `, ${clock(r.generated)}` : ""}`; + const head = ` + +
GenClass${esc(when)}
`; + // a new account's first step is to connect its app: that section comes before the empty numbers const setupFirst = !measured(r).length || r.items.some((i) => i.section === "setup" && i.p === 0); - const body = + // a single alert is all lead (its text, pages, prompt and dashboard); several get a row each below it, and so does + // one whose prompt has no link (it is printed there) + const details = r.kind === "alert" - ? [hero(r), card(itemRows(r, r.items, true), "What GenClass saw")].join("") + ? r.items.length > 1 || r.items.some((i) => i.prompt && !r.promptLinks[i.prompt]) + ? section(r.items.length > 1 ? "What GenClass saw" : "The fix prompt", itemRows(r, r.items, true)) + : "" : [ - hero(r), - halfCard(r), - summaryCard(r), - needsCard(r), - setupFirst ? setupCard(r) : "", - appsCard(r), - prsCard(r), - visitorsCard(r), - securityCard(r), - setupFirst ? "" : setupCard(r), - laterCard(r), - knowsSites(r) ? suggestionsCard(r) : "", - knowsSites(r) ? designCard(r) : nextCard(r), - upgradeCard(r), + halfBox(r), + needsSection(r), + setupFirst ? setupSection(r) : "", + appsSection(r), + prsSection(r), + visitorsSection(r), + securitySection(r), + setupFirst ? "" : setupSection(r), + laterSection(r), + knowsSites(r) ? suggestionsSection(r) : "", + knowsSites(r) ? designSection(r) : ideasSection(r), + quietLine(r), ].join(""); + // the inbox's preview line: the summary, not the header's words + const preview = `
${esc(l.text.slice(0, 180))}${"‌ ".repeat(40)}
`; return `${esc(subjectOf(r))}${DARK} - -