• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / blurts-server / #12498

pending completion
#12498

push

circleci

web-flow
Merge pull request #2850 from mozilla/MNTOR-1106-Email-preview-non-auth

MNTOR-1106: Add non-auth email preview

282 of 1381 branches covered (20.42%)

Branch coverage included in aggregate %.

27 of 27 new or added lines in 6 files covered. (100.0%)

959 of 3745 relevant lines covered (25.61%)

2.08 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/views/emails/email-2022.js
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4

5
import AppConstants from '../../app-constants.js'
6
import { getMessage } from '../../utils/fluent.js'
7

8
const companyAddress = '2 Harrison St. #175, San Francisco, California 94105 USA'
×
9
const links = (data) => ({
×
10
  faq: 'https://support.mozilla.org/kb/firefox-monitor-faq',
11
  hibp: 'https://haveibeenpwned.com/',
12
  legal: `https://www.mozilla.org/about/legal?utm_source=fx-monitor&utm_medium=email&utm_campaign=${data.utmCampaign}&utm_content=email-footer-link`,
13
  termsAndPrivacy: `https://www.mozilla.org/privacy/firefox-monitor?utm_source=fx-monitor&utm_medium=email&utm_campaign=${data.utmCampaign}&utm_content=email-footer-link`
14
})
15

16
const images = {
×
17
  header: `${AppConstants.SERVER_URL}/images/email/person-at-desk.png`,
18
  footer: `${AppConstants.SERVER_URL}/images/email/mozilla-logo-bw.png`,
19
  logoDark: `${AppConstants.SERVER_URL}/images/email/monitor-logo-transparent-dark-mode.png`,
20
  logoLight: `${AppConstants.SERVER_URL}/images/email/monitor-logo-bg-light.png`
21
}
22

23
const bodyStyle = `
×
24
  color: black;
25
  font: normal 16px/1.2 sans-serif;
26
`
27

28
const tableStyle = `
×
29
  margin: auto;
30
  max-width: 1080px;
31
  text-align: center;
32
  width: 100%;
33
`
34

35
const headerTableStyle = `
×
36
  background-color: #321c64;
37
  color: white;
38
  height: 331px;
39
  text-align: left;
40
  width: 100%;
41
`
42

43
const headerImageContainerStyle = `
×
44
  background-color: #321c64;
45
  vertical-align: bottom;
46
  width: 50%;
47
`
48

49
const headerImageStyle = `
×
50
  display: block;
51
  margin-left: auto;
52
  max-width: 100%;
53
  object-fit: cover;
54
  object-position: left;
55
`
56

57
const footerContainerStyle = `
×
58
  background: #f9f9fa;
59
  border-top: 1px solid #dddddd;
60
  padding: 24px 0;
61
`
62

63
const footerImageStyle = `
×
64
  display: block;
65
  margin: 24px auto 0;
66
`
67

68
const emailHeader = (data) => `
×
69
  <tr class='logo'>
70
    <td height='100'></td>
71
  </tr>
72
  <tr class='header'>
73
    <td>
74
      <table
75
        border='0'
76
        cellpadding='0'
77
        cellspacing='0'
78
        role='presentation'
79
        style='${headerTableStyle}'
80
      >
81
        <tr>
82
          <td>
83
            <h1>
84
              ${getMessage(data.heading)}
85
            </h1>
86
            ${data.subhead !== ''
×
87
              ? `<p>${getMessage(data.subhead)}</p>`
88
              : ''
89
            }
90
          </td>
91
          <td
92
            class='header-image'
93
            style='${headerImageContainerStyle}'
94
          >
95
            <img
96
              alt=''
97
              height='331'
98
              src='${images.header}'
99
              style='${headerImageStyle}'
100
              width='476'
101
            >
102
          </td>
103
        </tr>
104
      </table>
105
    </td>
106
  </tr>
107
`
108

109
const emailFooter = (data) => `
×
110
  <tr class='footer'>
111
    <td style='${footerContainerStyle}'>
112
      <p>
113
        ${getEmailFooterCopy(data)}
114
      </p>
115
      <p>
116
        ${getMessage('email-2022-hibp-attribution', {
117
          'hibp-link-attr': `href='${links(data).hibp}' rel='noopener'`
118
        })}
119
      </p>
120
      <img
121
        alt='${getMessage('mozilla')}'
122
        src='${images.footer}'
123
        style='${footerImageStyle}'
124
        width='130px'
125
      >
126
      <p>
127
        ${companyAddress}
128
      </p>
129
      <p>
130
        <a href='${links(data).legal}'>
131
          ${getMessage('legal')}
132
        </a>
133
        ${' • '}
134
        <a href='${links(data).termsAndPrivacy}'>
135
          ${getMessage('terms-and-privacy')}
136
        </a>
137
      </p>
138
    </td>
139
  </tr>
140
`
141

142
function getEmailFooterCopy (data) {
143
  const unsubLink = `
×
144
    <a href='${data.unsubscribeUrl}'>
145
      ${getMessage('email-unsub-link')}
146
    </a>
147
  `
148
  const faqLink = `
×
149
    <a href='${links(data).faq}'>${getMessage('frequently-asked-questions')}</a>
150
  `
151

152
  return getMessage('email-footer-blurb', {
×
153
    unsubLink,
154
    faqLink
155
  })
156
}
157

158
const getStyles = () => `
×
159
  <style>
160
    .email-body,
161
    .email-body * {
162
      margin: 0;
163
      padding: 0;
164
    }
165

166
    body.email-body,
167
    .email-container {
168
      color: black;
169
      font: normal 16px/1.2 sans-serif;
170
    }
171

172
    .email-container h1,
173
    .email-container p {
174
      margin: 12px auto;
175
      max-width: 600px;
176
      padding: 0 24px;
177
    }
178

179
    .email-container a {
180
      color: #592acb;
181
      text-decoration: none;
182
    }
183

184
    .email-container table {
185
      table-layout: fixed;
186
    }
187

188
    .email-container .logo > td {
189
      height: 100px;
190
      background-color: #f9f9fa;
191
      background-position: 50%;
192
      background-image: url('${images.logoLight}');
193
      background-repeat: no-repeat;
194
      background-size: 240px 50px;
195
      width: 100%;
196
    }
197

198
    @media screen and (max-width:600px) {
199
      .email-container .header-image {
200
        display: none;
201
      }
202
    }
203

204
    @media (prefers-color-scheme: dark) {
205
      .email-container .logo > td {
206
        background-image: url('${images.logoDark}')
207
      }
208
    }
209
  </style>
210
`
211

212
const getEmailContent = (data, partial) => {
×
213
  return `
×
214
    <table
215
      border='0'
216
      class='email-container'
217
      cellpadding='0'
218
      cellspacing='0'
219
      role='presentation'
220
      style='${tableStyle}'
221
    >
222
      ${emailHeader({
223
        heading: data.heading,
224
        subhead: data.subheading ?? ''
×
225
      })}
226
      ${partial(data)}
227
      ${emailFooter(data)}
228
    </table>
229
  `
230
}
231

232
const getPreviewTemplate = (data, partial) => `
×
233
  ${getStyles()}
234
  ${getEmailContent(data, partial)}
235
`
236

237
const getTemplate = (data, partial) => {
×
238
  return `
×
239
    <!doctype html>
240
    <html>
241
      <head>
242
        <meta name='viewport' content='width=device-width, initial-scale=1.0' />
243
        <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
244

245
        <title>
246
          ${getMessage('brand-fx-monitor')}
247
        </title>
248

249
        ${getStyles()}
250
      </head>
251

252
      <body class='email-body' style='${bodyStyle}'>
253
        ${getEmailContent(data, partial)}
254
      </body>
255
    </html>
256
  `
257
}
258

259
export { getPreviewTemplate, getTemplate }
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc