Skip to content

Commit 0f44f6d

Browse files
committed
improve display of plaintext version of email, make expiry time more clear on html email
1 parent 338e176 commit 0f44f6d

File tree

1 file changed

+43
-34
lines changed
  • ab-testing/notification-lambda/src/lib

1 file changed

+43
-34
lines changed

ab-testing/notification-lambda/src/lib/email.ts

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ const getEmailBodyHtml = (expiryChecks: ABExpiryChecks): string => {
1212
accentColour: "firebrick",
1313
},
1414
within1Day: {
15-
title: "Expiring today at 23:59",
15+
title: "Expiring today after 23:59",
1616
accentColour: "chocolate",
1717
},
1818
within2Days: {
19-
title: "Expires tomorrow at 23:59",
19+
title: "Expires tomorrow after 23:59",
2020
accentColour: "peru",
2121
},
2222
};
@@ -70,42 +70,51 @@ const getEmailBodyHtml = (expiryChecks: ABExpiryChecks): string => {
7070
};
7171

7272
const getEmailBodyPlainText = (expiryChecks: ABExpiryChecks): string => {
73-
return `AB Tests Expiry Reminder
73+
return [
74+
`AB Tests Expiry Reminder\n`,
7475

75-
Expired:
76-
${expiryChecks.expired
77-
.map(
78-
({ name, expirationDate, owners }) =>
79-
`${name} expired ${expirationDate}. Owners: ${owners.join(
80-
", ",
81-
)}`,
82-
)
83-
.join("\n")}
84-
85-
Expiring today (at 23:59):
86-
${expiryChecks.within1Day
87-
.map(
88-
({ name, expirationDate, owners }) =>
89-
`${name} expires ${expirationDate} at 00:00. Owners: ${owners.join(
90-
", ",
91-
)}`,
92-
)
93-
.join("\n")}
76+
`${expiryChecks.expired.length ? "Expired:" : ""}`,
77+
`${expiryChecks.expired
78+
.map(({ name, owners, description }) =>
79+
[
80+
`\tName: ${name}`,
81+
`Description: ${description}`,
82+
`Owners: ${owners.join(", ")}`,
83+
].join("\n\t"),
84+
)
85+
.join("\n\n")}`,
9486

95-
Expiring tomorrow (at 23:59):
96-
${expiryChecks.within2Days
97-
.map(
98-
({ name, expirationDate, owners }) =>
99-
`${name} expires ${expirationDate} at 00:00. Owners: ${owners.join(
100-
", ",
101-
)}`,
102-
)
103-
.join("\n")}
87+
`${
88+
expiryChecks.within1Day.length ? "Expiring today at midnight:" : ""
89+
}`,
90+
`${expiryChecks.within1Day
91+
.map(({ name, owners, description }) =>
92+
[
93+
`\tName: ${name}`,
94+
`Description: ${description}`,
95+
`Owners: ${owners.join(", ")}`,
96+
].join("\n\t"),
97+
)
98+
.join("\n\n")}`,
10499

105-
If you are not ready to remove a test yet but are happy to leave it expired for now, please turn it OFF in the code (https://github.com/guardian/dotcom-rendering/blob/main/ab-testing/config/abTests.ts)
100+
`${
101+
expiryChecks.within2Days.length
102+
? "Expiring tomorrow at midnight:"
103+
: ""
104+
}`,
105+
`${expiryChecks.within2Days
106+
.map(({ name, owners, description }) =>
107+
[
108+
`\tName: ${name}`,
109+
`Description: ${description}`,
110+
`Owners: ${owners.join(", ")}`,
111+
].join("\n\t"),
112+
)
113+
.join("\n\n")}`,
106114

107-
See https://frontend.gutools.co.uk/analytics/ab-testing for more details
108-
`;
115+
`If you are not ready to remove a test yet but are happy to leave it expired for now, please turn it OFF in the code (https://github.com/guardian/dotcom-rendering/blob/main/ab-testing/config/abTests.ts)\n`,
116+
`See https://frontend.gutools.co.uk/analytics/ab-testing for more details\n`,
117+
].join("\n");
109118
};
110119

111120
export const sendEmail = async (

0 commit comments

Comments
 (0)