Skip to content

Commit

Permalink
chore(email): split test for welcome message
Browse files Browse the repository at this point in the history
  • Loading branch information
SabreCat committed Feb 22, 2019
1 parent 2d35009 commit 10b6998
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion website/server/libs/auth/index.js
Expand Up @@ -183,7 +183,12 @@ async function registerLocal (req, res, { isV3 = false }) {
EmailUnsubscription
.remove({email: savedUser.auth.local.email})
.then(() => {
if (!existingUser) sendTxnEmail(savedUser, 'welcome');
if (existingUser) return;
if (savedUser._ABtests && savedUser._ABtests.emailSplit && savedUser._ABtests.emailSplit === '20190222_welcome-v2') {
sendTxnEmail(savedUser, 'welcome-v2');
} else {
sendTxnEmail(savedUser, 'welcome');
}
});

if (!existingUser) {
Expand Down
7 changes: 7 additions & 0 deletions website/server/models/user/hooks.js
Expand Up @@ -128,6 +128,13 @@ function _setUpNewUser (user) {
user.purchased.background.violet = true;
user.preferences.background = 'violet';

const testGroup = Math.random();
if (testGroup < 0.5) {
user._ABtests.emailSplit = '20190222_welcome';
} else {
user._ABtests.emailSplit = '20190222_welcome-v2';
}

if (user.registeredThrough === 'habitica-web') {
taskTypes = ['habit', 'daily', 'todo', 'reward', 'tag'];

Expand Down

0 comments on commit 10b6998

Please sign in to comment.