4f02a85aa4
GitOrigin-RevId: 399c594dd1bbf739d91874df6be3b70e57fe01e3
36 lines
832 B
JavaScript
36 lines
832 B
JavaScript
import { callbackify } from 'node:util'
|
|
import metrics from '@overleaf/metrics'
|
|
import UserUpdater from '../User/UserUpdater.mjs'
|
|
import AnalyticsManager from '../Analytics/AnalyticsManager.mjs'
|
|
|
|
async function optIn(userId) {
|
|
await UserUpdater.promises.updateUser(userId, { $set: { betaProgram: true } })
|
|
metrics.inc('beta-program.opt-in')
|
|
AnalyticsManager.setUserPropertyForUserInBackground(
|
|
userId,
|
|
'beta-program',
|
|
true
|
|
)
|
|
}
|
|
|
|
async function optOut(userId) {
|
|
await UserUpdater.promises.updateUser(userId, {
|
|
$set: { betaProgram: false },
|
|
})
|
|
metrics.inc('beta-program.opt-out')
|
|
AnalyticsManager.setUserPropertyForUserInBackground(
|
|
userId,
|
|
'beta-program',
|
|
false
|
|
)
|
|
}
|
|
|
|
export default {
|
|
optIn: callbackify(optIn),
|
|
optOut: callbackify(optOut),
|
|
promises: {
|
|
optIn,
|
|
optOut,
|
|
},
|
|
}
|