mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
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:
committed by
Matteo Pagliazzi
parent
81b7eeeb71
commit
86c9bddc09
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user