Handle social auth in A/B testing (#8024)

* fix(AB-testing): handle social auth

* refactor(AB-testing): move to pre save hooks
This commit is contained in:
Sabe Jones
2016-09-16 12:13:21 -05:00
committed by Matteo Pagliazzi
parent 81b7eeeb71
commit 86c9bddc09
3 changed files with 20 additions and 10 deletions

View File

@@ -73,10 +73,18 @@ function _populateDefaultTasks (user, taskTypes) {
});
}
function _populateDefaultsForNewUser (user) {
function _setUpNewUser (user) {
let taskTypes;
let iterableFlags = user.flags.toObject();
// A/B Test 2016-09-12: Start with Sound Enabled?
if (Math.random() < 0.5) {
user.preferences.sound = 'rosstavoTheme';
user._ABtest = '20160912-soundEnabled';
} else {
user._ABtest = '20160912-soundDisabled';
}
if (user.registeredThrough === 'habitica-web' || user.registeredThrough === 'habitica-android') {
taskTypes = ['habit', 'daily', 'todo', 'reward', 'tag'];
@@ -158,7 +166,7 @@ schema.pre('save', true, function preSaveUser (next, done) {
// Populate new users with default content
if (this.isNew) {
_populateDefaultsForNewUser(this)
_setUpNewUser(this)
.then(() => done())
.catch(done);
} else {