mirror of
https://github.com/overleaf/overleaf.git
synced 2025-03-22 02:04:31 +00:00
Merge pull request #5348 from overleaf/ab-alpha-beta-properties
alpha and beta program user properties GitOrigin-RevId: 633a61df83dd8206e780f67c85dd3403902f00f2
This commit is contained in:
parent
4cecc6383a
commit
98db86b8f0
2 changed files with 32 additions and 0 deletions
|
@ -1,10 +1,12 @@
|
|||
const { callbackify } = require('util')
|
||||
const metrics = require('@overleaf/metrics')
|
||||
const UserUpdater = require('../User/UserUpdater')
|
||||
const AnalyticsManager = require('../Analytics/AnalyticsManager')
|
||||
|
||||
async function optIn(userId) {
|
||||
await UserUpdater.promises.updateUser(userId, { $set: { betaProgram: true } })
|
||||
metrics.inc('beta-program.opt-in')
|
||||
AnalyticsManager.setUserPropertyForUser(userId, 'beta-program', true)
|
||||
}
|
||||
|
||||
async function optOut(userId) {
|
||||
|
@ -12,6 +14,7 @@ async function optOut(userId) {
|
|||
$set: { betaProgram: false },
|
||||
})
|
||||
metrics.inc('beta-program.opt-out')
|
||||
AnalyticsManager.setUserPropertyForUser(userId, 'beta-program', false)
|
||||
}
|
||||
|
||||
const BetaProgramHandler = {
|
||||
|
|
|
@ -27,6 +27,9 @@ describe('BetaProgramHandler', function () {
|
|||
updateUser: sinon.stub().resolves(),
|
||||
},
|
||||
}),
|
||||
'../Analytics/AnalyticsManager': (this.AnalyticsManager = {
|
||||
setUserPropertyForUser: sinon.stub().resolves(),
|
||||
}),
|
||||
},
|
||||
})
|
||||
})
|
||||
|
@ -47,6 +50,19 @@ describe('BetaProgramHandler', function () {
|
|||
})
|
||||
})
|
||||
|
||||
it('should set beta-program user property to true', function (done) {
|
||||
this.call(err => {
|
||||
expect(err).to.not.exist
|
||||
sinon.assert.calledWith(
|
||||
this.AnalyticsManager.setUserPropertyForUser,
|
||||
this.user_id,
|
||||
'beta-program',
|
||||
true
|
||||
)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should not produce an error', function (done) {
|
||||
this.call(err => {
|
||||
expect(err).to.not.exist
|
||||
|
@ -85,6 +101,19 @@ describe('BetaProgramHandler', function () {
|
|||
})
|
||||
})
|
||||
|
||||
it('should set beta-program user property to false', function (done) {
|
||||
this.call(err => {
|
||||
expect(err).to.not.exist
|
||||
sinon.assert.calledWith(
|
||||
this.AnalyticsManager.setUserPropertyForUser,
|
||||
this.user_id,
|
||||
'beta-program',
|
||||
false
|
||||
)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should not produce an error', function (done) {
|
||||
this.call(err => {
|
||||
expect(err).to.not.exist
|
||||
|
|
Loading…
Reference in a new issue