diff --git a/test/api/unit/middlewares/cronMiddleware.js b/test/api/unit/middlewares/cronMiddleware.js index e3e797189d..873bbb70a7 100644 --- a/test/api/unit/middlewares/cronMiddleware.js +++ b/test/api/unit/middlewares/cronMiddleware.js @@ -293,90 +293,4 @@ describe('cron middleware', () => { }); }); }); - - context('Drop Cap A/B Test', async () => { - it('enrolls web users', async () => { - user.lastCron = moment(new Date()).subtract({ days: 2 }); - await user.save(); - req.headers['x-client'] = 'habitica-web'; - - await new Promise((resolve, reject) => { - cronMiddleware(req, res, async err => { - if (err) return reject(err); - user = await User.findById(user._id).exec(); - expect(user._ABtests.dropCapNotif).to.be.a.string; - - return resolve(); - }); - }); - }); - - it('enables the new notification for 50% of users', async () => { - sandbox.stub(Math, 'random').returns(0.5); - user.lastCron = moment(new Date()).subtract({ days: 2 }); - await user.save(); - req.headers['x-client'] = 'habitica-web'; - - await new Promise((resolve, reject) => { - cronMiddleware(req, res, async err => { - if (err) return reject(err); - user = await User.findById(user._id).exec(); - expect(user._ABtests.dropCapNotif).to.be.equal('drop-cap-notif-enabled'); - - return resolve(); - }); - }); - }); - - it('disables the new notification for 50% of users', async () => { - sandbox.stub(Math, 'random').returns(0.51); - user.lastCron = moment(new Date()).subtract({ days: 2 }); - await user.save(); - req.headers['x-client'] = 'habitica-web'; - - await new Promise((resolve, reject) => { - cronMiddleware(req, res, async err => { - if (err) return reject(err); - user = await User.findById(user._id).exec(); - expect(user._ABtests.dropCapNotif).to.be.equal('drop-cap-notif-disabled'); - - return resolve(); - }); - }); - }); - - it('does not affect subscribers', async () => { - sandbox.stub(Math, 'random').returns(0.2); - user.lastCron = moment(new Date()).subtract({ days: 2 }); - await user.save(); - req.headers['x-client'] = 'habitica-web'; - sandbox.stub(User.prototype, 'isSubscribed').returns(true); - - await new Promise((resolve, reject) => { - cronMiddleware(req, res, async err => { - if (err) return reject(err); - user = await User.findById(user._id).exec(); - expect(user._ABtests.dropCapNotif).to.not.exist; - - return resolve(); - }); - }); - }); - - it('does not affect mobile users', async () => { - user.lastCron = moment(new Date()).subtract({ days: 2 }); - await user.save(); - req.headers['x-client'] = 'habitica-ios'; - - await new Promise((resolve, reject) => { - cronMiddleware(req, res, async err => { - if (err) return reject(err); - user = await User.findById(user._id).exec(); - expect(user._ABtests.dropCapNotif).to.not.exist; - - return resolve(); - }); - }); - }); - }); }); diff --git a/test/common/fns/randomDrop.test.js b/test/common/fns/randomDrop.test.js index 440bb4506d..3ce03286b1 100644 --- a/test/common/fns/randomDrop.test.js +++ b/test/common/fns/randomDrop.test.js @@ -1,5 +1,4 @@ import randomDrop from '../../../website/common/script/fns/randomDrop'; -import i18n from '../../../website/common/script/i18n'; import { generateUser, generateTodo, @@ -145,148 +144,5 @@ describe('common.fns.randomDrop', () => { expect(acceptableDrops).to.contain(user._tmp.drop.key); // always Desert }); }); - - context('drop cap notification', () => { - let analytics; - const req = {}; - let isSubscribedStub; - - beforeEach(() => { - user.addNotification = () => {}; - sandbox.stub(user, 'addNotification'); - user.isSubscribed = () => {}; - isSubscribedStub = sandbox.stub(user, 'isSubscribed'); - isSubscribedStub.returns(false); - analytics = { track () {} }; - sandbox.stub(analytics, 'track'); - }); - - it('sends a notification if A/B test is enabled when drop cap is reached', () => { - user._ABtests.dropCapNotif = 'drop-cap-notif-enabled'; - predictableRandom.returns(0.1); - - // Max Drop Count is 5 - expect(user.items.lastDrop.count).to.equal(0); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - expect(user.items.lastDrop.count).to.equal(5); - expect(user.addNotification).to.be.calledOnce; - expect(user.addNotification).to.be.calledWith('DROP_CAP_REACHED', { - message: i18n.t('dropCapReached'), - items: 5, - }); - }); - - it('does not send a notification if user is enrolled in disabled A/B test group', () => { - user._ABtests.dropCapNotif = 'drop-cap-notif-disabled'; - predictableRandom.returns(0.1); - - // Max Drop Count is 5 - expect(user.items.lastDrop.count).to.equal(0); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - expect(user.items.lastDrop.count).to.equal(5); - expect(user.addNotification).to.not.be.called; - }); - - it('does not send a notification if user is enrolled in disabled A/B test group', () => { - user._ABtests.dropCapNotif = 'drop-cap-notif-not-enrolled'; - predictableRandom.returns(0.1); - - // Max Drop Count is 5 - expect(user.items.lastDrop.count).to.equal(0); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - expect(user.items.lastDrop.count).to.equal(5); - expect(user.addNotification).to.not.be.called; - }); - - it('does not send a notification if drop cap is not reached', () => { - user._ABtests.dropCapNotif = 'drop-cap-notif-enabled'; - predictableRandom.returns(0.1); - - // Max Drop Count is 5 - expect(user.items.lastDrop.count).to.equal(0); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - expect(user.items.lastDrop.count).to.equal(4); - expect(user.addNotification).to.not.be.called; - }); - - it('does not send a notification if user is subscribed', () => { - user._ABtests.dropCapNotif = 'drop-cap-notif-enabled'; - predictableRandom.returns(0.1); - isSubscribedStub.returns(true); - - // Max Drop Count is 5 - expect(user.items.lastDrop.count).to.equal(0); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - expect(user.items.lastDrop.count).to.equal(5); - expect(user.addNotification).to.not.be.called; - }); - - it('tracks drop cap reached event for enrolled users (notification enabled)', () => { - user._ABtests.dropCapNotif = 'drop-cap-notif-enabled'; - predictableRandom.returns(0.1); - isSubscribedStub.returns(true); - - // Max Drop Count is 5 - expect(user.items.lastDrop.count).to.equal(0); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - expect(user.items.lastDrop.count).to.equal(5); - expect(analytics.track).to.be.calledWith('drop cap reached'); - }); - - it('tracks drop cap reached event for enrolled users (notification disabled)', () => { - user._ABtests.dropCapNotif = 'drop-cap-notif-disabled'; - predictableRandom.returns(0.1); - isSubscribedStub.returns(true); - - // Max Drop Count is 5 - expect(user.items.lastDrop.count).to.equal(0); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - expect(user.items.lastDrop.count).to.equal(5); - expect(analytics.track).to.be.calledWith('drop cap reached'); - }); - - it('does not track drop cap reached event for users not enrolled in A/B test', () => { - user._ABtests.dropCapNotif = 'drop-cap-notif-not-enrolled'; - predictableRandom.returns(0.1); - isSubscribedStub.returns(true); - - // Max Drop Count is 5 - expect(user.items.lastDrop.count).to.equal(0); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - randomDrop(user, { task, predictableRandom }, req, analytics); - expect(user.items.lastDrop.count).to.equal(5); - expect(analytics.track).to.not.be.calledWith('drop cap reached'); - }); - }); }); }); diff --git a/test/common/ops/buy/buyMysterySet.js b/test/common/ops/buy/buyMysterySet.js index 6a7a0650a3..b485f2f164 100644 --- a/test/common/ops/buy/buyMysterySet.js +++ b/test/common/ops/buy/buyMysterySet.js @@ -88,14 +88,6 @@ describe('shared.ops.buyMysterySet', () => { expect(user.items.gear.owned).to.have.property('armor_mystery_301404', true); expect(user.items.gear.owned).to.have.property('head_mystery_301404', true); expect(user.items.gear.owned).to.have.property('eyewear_mystery_301404', true); - expect(analytics.track).to.be.calledOnce; - expect(analytics.track).to.be.calledWithMatch('acquire item', { - uuid: user._id, - itemKey: '301404', - itemType: 'Subscriber Gear', - acquireMethod: 'Hourglass', - category: 'behavior', - }); }); }); }); diff --git a/website/client/src/components/achievements/dropCapReached.vue b/website/client/src/components/achievements/dropCapReached.vue deleted file mode 100644 index a804fd78fa..0000000000 --- a/website/client/src/components/achievements/dropCapReached.vue +++ /dev/null @@ -1,250 +0,0 @@ - - - - - - - diff --git a/website/client/src/components/appFooter.vue b/website/client/src/components/appFooter.vue index e9059f2440..4e0aa946f0 100644 --- a/website/client/src/components/appFooter.vue +++ b/website/client/src/components/appFooter.vue @@ -466,7 +466,6 @@ footer { import axios from 'axios'; import moment from 'moment'; import { mapState } from '@/libs/store'; -import * as Analytics from '@/libs/analytics'; import gryphon from '@/assets/svg/gryphon.svg'; import twitter from '@/assets/svg/twitter.svg'; import facebook from '@/assets/svg/facebook.svg'; @@ -580,12 +579,6 @@ export default { this.$root.$emit('bv::show::modal', 'modify-inventory'); }, donate () { - Analytics.track({ - hitType: 'event', - eventCategory: 'button', - eventAction: 'click', - eventLabel: 'Gems > Donate', - }); this.$root.$emit('bv::show::modal', 'buy-gems', { alreadyTracked: true }); }, }, diff --git a/website/client/src/components/group-plans/createGroupModalPages.vue b/website/client/src/components/group-plans/createGroupModalPages.vue index e8cd2698fd..1bd76ac8fc 100644 --- a/website/client/src/components/group-plans/createGroupModalPages.vue +++ b/website/client/src/components/group-plans/createGroupModalPages.vue @@ -133,7 +133,6 @@ diff --git a/website/client/src/components/header/notificationsDropdown.vue b/website/client/src/components/header/notificationsDropdown.vue index cfbb7ece7c..fc1ac8ef57 100644 --- a/website/client/src/components/header/notificationsDropdown.vue +++ b/website/client/src/components/header/notificationsDropdown.vue @@ -146,7 +146,6 @@ import ACHIEVEMENT_MIND_OVER_MATTER from './notifications/mindOverMatter'; import ONBOARDING_COMPLETE from './notifications/onboardingComplete'; import GIFT_ONE_GET_ONE from './notifications/g1g1'; import OnboardingGuide from './onboardingGuide'; -import DROP_CAP_REACHED from './notifications/dropCapReached'; export default { components: { @@ -176,7 +175,6 @@ export default { OnboardingGuide, ONBOARDING_COMPLETE, GIFT_ONE_GET_ONE, - DROP_CAP_REACHED, }, data () { return { @@ -202,7 +200,7 @@ export default { 'GROUP_TASK_CLAIMED', 'NEW_MYSTERY_ITEMS', 'CARD_RECEIVED', 'NEW_INBOX_MESSAGE', 'NEW_CHAT_MESSAGE', 'UNALLOCATED_STATS_POINTS', 'ACHIEVEMENT_JUST_ADD_WATER', 'ACHIEVEMENT_LOST_MASTERCLASSER', 'ACHIEVEMENT_MIND_OVER_MATTER', - 'VERIFY_USERNAME', 'ONBOARDING_COMPLETE', 'DROP_CAP_REACHED', + 'VERIFY_USERNAME', 'ONBOARDING_COMPLETE', ], }; }, diff --git a/website/client/src/components/header/userDropdown.vue b/website/client/src/components/header/userDropdown.vue index 295f2720f6..c8c612d00d 100644 --- a/website/client/src/components/header/userDropdown.vue +++ b/website/client/src/components/header/userDropdown.vue @@ -139,7 +139,6 @@