Skip to content
Permalink
Browse files

fix(email): remove old trailhead logic and promote trailhead templates

  • Loading branch information...
philbooth committed Oct 4, 2019
1 parent 1c206ca commit 77a2c2821af087d5e5ccdabeff7061d440986e10
@@ -421,7 +421,6 @@ Possible values for `${template}` include
| `unblockCodeEmail` | Email sent containing the account unblock code. |
| `verifyEmail` | Email sent to verify a user's account. |
| `verifyLoginEmail` | Sign-in confirmation email was sent. |
| `verifySyncEmail` | Email to verify a Sync user's account. |
| `postVerifySecondaryEmail` | Email sent when a user has added a secondary email. |
| `verifySecondaryEmail` | Email to confirm adding a secondary email. |

@@ -26,7 +26,6 @@ const EMAIL_TYPES = {
postChangePrimaryEmail: 'change_email',
postRemoveSecondaryEmail: 'secondary_email',
postVerifyEmail: 'registration',
postVerifyTrailheadEmail: 'registration',
postVerifySecondaryEmail: 'secondary_email',
postAddTwoStepAuthenticationEmail: '2fa',
postRemoveTwoStepAuthenticationEmail: '2fa',
@@ -41,9 +40,7 @@ const EMAIL_TYPES = {
verifyLoginEmail: 'login',
verifyLoginCodeEmail: 'login',
verifyPrimaryEmail: 'verify',
verifySyncEmail: 'registration',
verifySecondaryEmail: 'secondary_email',
verifyTrailheadEmail: 'registration',
};

const EVENTS = {
@@ -42,7 +42,6 @@ module.exports = function(log, config, oauthdb) {
postVerify: 'account-verified',
postChangePrimary: 'account-email-changed',
postVerifySecondary: 'account-email-verified',
postVerifyTrailhead: 'account-verified',
postAddTwoStepAuthentication: 'account-two-step-enabled',
postRemoveTwoStepAuthentication: 'account-two-step-disabled',
postConsumeRecoveryCode: 'account-consume-recovery-code',
@@ -56,9 +55,7 @@ module.exports = function(log, config, oauthdb) {
verifyLogin: 'new-signin',
verifyLoginCode: 'new-signin-verify-code',
verifyPrimary: 'welcome-primary',
verifySync: 'welcome-sync',
verifySecondary: 'welcome-secondary',
verifyTrailhead: 'welcome-trailhead',
};

// Email template to UTM content, this is typically the main call out link/button
@@ -75,7 +72,6 @@ module.exports = function(log, config, oauthdb) {
postVerify: 'connect-device',
postChangePrimary: 'account-email-changed',
postVerifySecondary: 'manage-account',
postVerifyTrailhead: 'connect-device',
postAddTwoStepAuthentication: 'manage-account',
postRemoveTwoStepAuthentication: 'manage-account',
postConsumeRecoveryCode: 'manage-account',
@@ -89,9 +85,7 @@ module.exports = function(log, config, oauthdb) {
verifyLogin: 'confirm-signin',
verifyLoginCode: 'new-signin-verify-code',
verifyPrimary: 'activate',
verifySync: 'activate-sync',
verifySecondary: 'activate',
verifyTrailhead: 'confirm-trailhead',
};

function extend(target, source) {
@@ -423,10 +417,9 @@ module.exports = function(log, config, oauthdb) {
Mailer.prototype.verifyEmail = async function(message) {
log.trace('mailer.verifyEmail', { email: message.email, uid: message.uid });

let templateName = 'verify';
const metricsTemplateName = templateName;
let subject = gettext('Verify your account');
let action = gettext('Activate now');
const templateName = 'verify';
const subject = gettext('Finish creating your account');
const action = gettext('Confirm email');
const query = {
uid: message.uid,
code: message.code,
@@ -457,27 +450,12 @@ module.exports = function(log, config, oauthdb) {
'X-Verify-Code': message.code,
};

let serviceName;

if (message.service === 'sync') {
subject = gettext('Confirm your email and start to sync!');
action = gettext('Verify email');
templateName = 'verifySync';
} else if (message.service) {
const clientInfo = await oauthClientInfo.fetch(message.service);
serviceName = clientInfo.name;
}

if (message.style === 'trailhead') {
subject = gettext('Finish creating your account');
action = gettext('Confirm email');
templateName = 'verifyTrailhead';
}
const clientInfo = await oauthClientInfo.fetch(message.service);
const serviceName = clientInfo.name;

return this.send({
...message,
headers,
metricsTemplate: metricsTemplateName,
subject,
template: templateName,
templateValues: {
@@ -1112,16 +1090,10 @@ module.exports = function(log, config, oauthdb) {
uid: message.uid,
});

let templateName = 'postVerify';
let subject = gettext('Account verified');
const templateName = 'postVerify';
const subject = gettext('Account confirmed');
const query = {};

if (message.style === 'trailhead') {
templateName = 'postVerifyTrailhead';
subject = gettext('Account confirmed');
query.style = 'trailhead';
}

const action = gettext('Connect another device');

const links = this._generateLinks(
@@ -9,7 +9,6 @@
"postRemoveSecondary": 4,
"postVerify": 4,
"postVerifySecondary": 4,
"postVerifyTrailhead": 4,
"recovery": 4,
"sms.installFirefox": 1,
"unblockCode": 4,
@@ -21,8 +20,6 @@
"verifyLoginCode": 5,
"verifyShortCode": 2,
"verifySecondary": 4,
"verifySync": 4,
"verifyTrailhead": 4,
"postAddTwoStepAuthentication": 7,
"postRemoveTwoStepAuthentication": 7,
"postConsumeRecoveryCode": 4,
@@ -1,8 +1,10 @@
<tr style="page-break-before: always">
<td valign="top">
<h1 style="font-family: sans-serif; font-size: 21px; line-height: 29px; font-weight: normal; margin: 0 0 11px 0; text-align: center;">{{t "Account verified!" }}</h1>
<h1 style="font-family: sans-serif; font-size: 21px; line-height: 29px; font-weight: normal; margin: 0 0 11px 0; text-align: center;">{{t "Welcome to the Firefox family" }}</h1>

<p class="primary" style="font-family: sans-serif; font-size: 14px; line-height: 21px; font-weight: normal; margin: 0 0 21px 0; text-align: center;">{{{t "You successfully connected your first device to your Firefox Account. Now you can sign in to Sync from your other devices, including Firefox for <a %(androidLinkAttributes)s>Android</a> and <a %(iosLinkAttributes)s>iOS</a>." }}}</p>
<p class="primary" style="font-family: sans-serif; font-size: 14px; line-height: 21px; font-weight: normal; margin: 0 0 21px 0; text-align: center;">{{t "You're signed in and ready to start exploring safely and securely."}}</p>

<p class="primary" style="font-family: sans-serif; font-size: 14px; line-height: 21px; font-weight: normal; margin: 0 0 21px 0; text-align: center;">{{t "Now get the most of Firefox by signing in everywhere you browse."}}</p>
</td>
</tr>

@@ -1,10 +1,12 @@
{{t "Account verified!" }}
{{t "Welcome to the Firefox family" }}

{{t "You successfully connected your first device to your Firefox Account. Now you can sign in to Sync from your other devices, including Firefox for Android and iOS." }}
{{{t "You're signed in and ready to start exploring safely and securely." }}}

{{t "Sign in to Sync:"}}
{{t "Now get the most of Firefox by signing in everywhere you browse." }}

{{t "Connect another device:"}}
{{{ link }}}

{{> automatedEmailNoAction}}

{{> support}}
{{{t "Have questions? Visit %(supportUrl)s"}}}

This file was deleted.

This file was deleted.

@@ -1,21 +1,10 @@
<tr style="page-break-before: always">
<td valign="top">
<h1 style="font-family: sans-serif; font-size: 21px; line-height: 29px; font-weight: normal; margin: 0 0 11px 0; text-align: center;">
{{#if serviceName}}
{{{t "Welcome to %(serviceName)s!"}}}
{{/if}}
{{^if serviceName}}
{{t "Welcome!"}}
{{/if}}
</h1>
<p class="primary" style="font-family: sans-serif; font-size: 14px; line-height: 21px; font-weight: normal; margin: 0 0 21px 0; text-align: center;">
{{#if serviceName}}
{{{t "Confirm this email address to activate your Firefox Account and continue to %(serviceName)s." }}}
{{/if}}
{{^if serviceName}}
{{t "Confirm this email address to activate your Firefox Account." }}
{{/if}}
</p>
<h1 style="font-family: sans-serif; font-size: 21px; line-height: 29px; font-weight: normal; margin: 0 0 11px 0; text-align: center;">{{t "Activate the Firefox family of products"}}</h1>

<p class="primary" style="font-family: sans-serif; font-size: 14px; line-height: 21px; font-weight: normal; margin: 0 0 21px 0; text-align: center;">{{t "Confirm your account and get the most out of Firefox everywhere you sign in starting with:"}}</p>

{{> location}}
</td>
</tr>

@@ -1,15 +1,8 @@
{{#if serviceName}}
{{{t "Welcome to %(serviceName)s!"}}}
{{t "Activate the Firefox family of products"}}

{{{t "Confirm this email address to activate your Firefox Account and continue to %(serviceName)s." }}}
{{/if}}
{{^if serviceName}}
{{t "Welcome!"}}
{{{t "Confirm your account and get the most out of Firefox everywhere you sign in." }}}

{{t "Confirm this email address to activate your Firefox Account." }}
{{/if}}

{{t "Activate now:"}}
{{t "Confirm email:"}}
{{{link}}}

{{> automatedEmailNoAction}}

This file was deleted.

This file was deleted.

@@ -1272,43 +1272,6 @@ describe('metrics/amplitude', () => {
});
});

describe('email.verifySyncEmail.bounced', () => {
beforeEach(() => {
return amplitude(
'email.verifySyncEmail.bounced',
mocks.mockRequest({})
);
});

it('did not call log.error', () => {
assert.equal(log.error.callCount, 0);
});

it('called log.amplitudeEvent correctly', () => {
assert.equal(log.amplitudeEvent.callCount, 1);
const args = log.amplitudeEvent.args[0];
assert.equal(args[0].event_type, 'fxa_email - bounced');
assert.equal(args[0].event_properties.email_type, 'registration');
});
});

describe('email.verifySyncEmail.sent', () => {
beforeEach(() => {
return amplitude('email.verifySyncEmail.sent', mocks.mockRequest({}));
});

it('did not call log.error', () => {
assert.equal(log.error.callCount, 0);
});

it('called log.amplitudeEvent correctly', () => {
assert.equal(log.amplitudeEvent.callCount, 1);
const args = log.amplitudeEvent.args[0];
assert.equal(args[0].event_type, 'fxa_email - sent');
assert.equal(args[0].event_properties.email_type, 'registration');
});
});

describe('email.verifySecondaryEmail.bounced', () => {
beforeEach(() => {
return amplitude(

0 comments on commit 77a2c28

Please sign in to comment.
You can’t perform that action at this time.