Merge pull request #6559 from overleaf/tm-teardown-onboarding-email-split-test

Implement 'send-email' variant for trial onboarding email for all users

GitOrigin-RevId: f53b86d875a1a4e146dc57603b7a83ac098f9cdf
This commit is contained in:
Thomas 2022-02-11 13:07:44 +01:00 committed by Copybot
parent 1c5949f715
commit 45ac55c7f0
2 changed files with 2 additions and 31 deletions

View file

@ -1,5 +1,4 @@
const AnalyticsManager = require('../Analytics/AnalyticsManager')
const SplitTestHandler = require('../SplitTests/SplitTestHandler')
const SubscriptionEmailHandler = require('./SubscriptionEmailHandler')
const { ObjectID } = require('mongodb')
@ -66,16 +65,8 @@ async function _sendSubscriptionStartedEvent(userId, eventData) {
isTrial
)
// send the trial onboarding email
if (isTrial) {
const assignment = await SplitTestHandler.promises.getAssignmentForUser(
userId,
'trial-onboarding-email'
)
if (assignment.variant === 'send-email') {
await SubscriptionEmailHandler.sendTrialOnboardingEmail(userId)
}
await SubscriptionEmailHandler.sendTrialOnboardingEmail(userId)
}
}

View file

@ -29,11 +29,6 @@ describe('RecurlyEventHandler', function () {
'./SubscriptionEmailHandler': (this.SubscriptionEmailHandler = {
sendTrialOnboardingEmail: sinon.stub(),
}),
'../SplitTests/SplitTestHandler': (this.SplitTestHandler = {
promises: {
getAssignmentForUser: sinon.stub().resolves({ variant: 'default' }),
},
}),
'../Analytics/AnalyticsManager': (this.AnalyticsManager = {
recordEventForUser: sinon.stub(),
setUserPropertyForUser: sinon.stub(),
@ -75,28 +70,14 @@ describe('RecurlyEventHandler', function () {
'subscription-is-trial',
true
)
sinon.assert.calledWith(
this.SplitTestHandler.promises.getAssignmentForUser,
this.userId,
'trial-onboarding-email'
)
})
it('sends free trial onboarding email if user in ab group', async function () {
this.SplitTestHandler.promises.getAssignmentForUser = sinon
.stub()
.resolves({ variant: 'send-email' })
it('sends free trial onboarding email if user starting a trial', async function () {
await this.RecurlyEventHandler.sendRecurlyAnalyticsEvent(
'new_subscription_notification',
this.eventData
)
sinon.assert.calledWith(
this.SplitTestHandler.promises.getAssignmentForUser,
this.userId,
'trial-onboarding-email'
)
sinon.assert.called(this.SubscriptionEmailHandler.sendTrialOnboardingEmail)
})
@ -356,6 +337,5 @@ describe('RecurlyEventHandler', function () {
sinon.assert.notCalled(this.AnalyticsManager.setUserPropertyForUser)
sinon.assert.notCalled(this.AnalyticsManager.setUserPropertyForUser)
sinon.assert.notCalled(this.AnalyticsManager.setUserPropertyForUser)
sinon.assert.notCalled(this.SplitTestHandler.promises.getAssignmentForUser)
})
})