mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 13:17:24 +01:00
Analytics: clean up old A/B test code & add username verify flag (#10754)
* chore(analytics): clean up old A/B test code & add username verify * fix(lint): more AB cleanup
This commit is contained in:
@@ -276,7 +276,7 @@ describe('POST /user/auth/local/register', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('enrolls new users in an A/B test', async () => {
|
||||
xit('enrolls new users in an A/B test', async () => {
|
||||
let username = generateRandomUserName();
|
||||
let email = `${username}@example.com`;
|
||||
let password = 'password';
|
||||
|
||||
@@ -80,7 +80,7 @@ describe('POST /user/auth/social', () => {
|
||||
expect(response.newUser).to.be.false;
|
||||
});
|
||||
|
||||
it('enrolls a new user in an A/B test', async () => {
|
||||
xit('enrolls a new user in an A/B test', async () => {
|
||||
await api.post(endpoint, {
|
||||
authResponse: {access_token: randomAccessToken}, // eslint-disable-line camelcase
|
||||
network,
|
||||
@@ -136,7 +136,7 @@ describe('POST /user/auth/social', () => {
|
||||
expect(response.newUser).to.be.false;
|
||||
});
|
||||
|
||||
it('enrolls a new user in an A/B test', async () => {
|
||||
xit('enrolls a new user in an A/B test', async () => {
|
||||
await api.post(endpoint, {
|
||||
authResponse: {access_token: randomAccessToken}, // eslint-disable-line camelcase
|
||||
network,
|
||||
|
||||
@@ -127,10 +127,6 @@ api.createGroup = {
|
||||
user.achievements.joinedGuild = true;
|
||||
user.addNotification('GUILD_JOINED_ACHIEVEMENT');
|
||||
}
|
||||
if (user._ABtests && user._ABtests.guildReminder && user._ABtests.counter !== -1) {
|
||||
user._ABtests.counter = -1;
|
||||
user.markModified('_ABtests');
|
||||
}
|
||||
} else {
|
||||
if (group.privacy !== 'private') throw new NotAuthorized(res.t('partyMustbePrivate'));
|
||||
if (user.party._id) throw new NotAuthorized(res.t('messageGroupAlreadyInParty'));
|
||||
@@ -570,10 +566,6 @@ api.joinGroup = {
|
||||
user.achievements.joinedGuild = true;
|
||||
user.addNotification('GUILD_JOINED_ACHIEVEMENT');
|
||||
}
|
||||
if (user._ABtests && user._ABtests.guildReminder && user._ABtests.counter !== -1) {
|
||||
user._ABtests.counter = -1;
|
||||
user.markModified('_ABtests');
|
||||
}
|
||||
}
|
||||
if (!isUserInvited) throw new NotAuthorized(res.t('messageGroupRequiresInvite'));
|
||||
|
||||
|
||||
@@ -630,18 +630,6 @@ api.scoreTask = {
|
||||
|
||||
setNextDue(task, user);
|
||||
|
||||
if (user._ABtests && user._ABtests.guildReminder && user._ABtests.counter !== -1) {
|
||||
user._ABtests.counter++;
|
||||
if (user._ABtests.counter > 1) {
|
||||
if (user._ABtests.guildReminder.indexOf('timing1') !== -1 || user._ABtests.counter > 4) {
|
||||
user._ABtests.counter = -1;
|
||||
let textVariant = user._ABtests.guildReminder.indexOf('text2');
|
||||
user.addNotification('GUILD_PROMPT', {textVariant});
|
||||
}
|
||||
}
|
||||
user.markModified('_ABtests');
|
||||
}
|
||||
|
||||
let promises = [
|
||||
user.save(),
|
||||
task.save(),
|
||||
|
||||
@@ -70,8 +70,8 @@ let _formatUserData = (user) => {
|
||||
|
||||
properties.balance = user.balance;
|
||||
properties.balanceGemAmount = properties.balance * 4;
|
||||
|
||||
properties.tutorialComplete = user.flags && user.flags.tour && user.flags.tour.intro === -2;
|
||||
properties.verifiedUsername = user.flags && user.flags.verifiedUsername;
|
||||
|
||||
if (user.habits && user.dailys && user.todos && user.rewards) {
|
||||
properties['Number Of Tasks'] = {
|
||||
@@ -90,9 +90,6 @@ let _formatUserData = (user) => {
|
||||
properties.subscription = user.purchased.plan.planId;
|
||||
}
|
||||
|
||||
if (user._ABtest) {
|
||||
properties.ABtest = user._ABtest;
|
||||
}
|
||||
if (user._ABtests) {
|
||||
properties.ABtests = toArray(user._ABtests);
|
||||
}
|
||||
|
||||
@@ -200,8 +200,6 @@ function trackCronAnalytics (analytics, user, _progress, options) {
|
||||
|
||||
function awardLoginIncentives (user) {
|
||||
if (user.loginIncentives > MAX_INCENTIVES) return;
|
||||
// A/B test 2016-12-21: Should we deliver notifications for upcoming incentives on days when users don't receive rewards?
|
||||
if (!loginIncentives[user.loginIncentives].rewardKey && user._ABtests && user._ABtests.checkInModals === '20161221_noCheckInPreviews') return;
|
||||
|
||||
// Remove old notifications if they exists
|
||||
user.notifications.forEach((notif, index) => {
|
||||
|
||||
@@ -124,25 +124,6 @@ function _setUpNewUser (user) {
|
||||
let taskTypes;
|
||||
let iterableFlags = user.flags.toObject();
|
||||
|
||||
// A/B test 2017-05-11: Can we encourage people to join Guilds with a pester modal?
|
||||
let testGroup = Math.random();
|
||||
if (testGroup < 0.1) {
|
||||
user._ABtests.guildReminder = '20170511_noGuildReminder'; // control group, don't pester about Guilds
|
||||
user._ABtests.counter = -1;
|
||||
} else if (testGroup < 0.235) {
|
||||
user._ABtests.guildReminder = '20170511_text1timing1'; // first sample text, show after two clicks
|
||||
user._ABtests.counter = 0;
|
||||
} else if (testGroup < 0.46) {
|
||||
user._ABtests.guildReminder = '20170511_text2timing1'; // second sample text, show after two clicks
|
||||
user._ABtests.counter = 0;
|
||||
} else if (testGroup < 0.685) {
|
||||
user._ABtests.guildReminder = '20170511_text1timing2'; // first sample text, show after five clicks
|
||||
user._ABtests.counter = 0;
|
||||
} else {
|
||||
user._ABtests.guildReminder = '20170511_text2timing2'; // second sample text, show after five clicks
|
||||
user._ABtests.counter = 0;
|
||||
}
|
||||
|
||||
user.items.quests.dustbunnies = 1;
|
||||
user.purchased.background.violet = true;
|
||||
user.preferences.background = 'violet';
|
||||
|
||||
Reference in New Issue
Block a user