overleaf/services/web/app/src/Features/Helpers/NewLogsUI.js
Paulo Jorge Reis 2051caf28e New compile UI admin panel (#3666)
* Extract new logs UI feature check to a helper function

* Add new logs UI per-user availability to the admin panel

* Stub NewLogsUIHelper in the unit tests

GitOrigin-RevId: b5344448d507c7cd7422b342286ada2b839b1785
2021-02-18 03:05:20 +00:00

29 lines
636 B
JavaScript

const { ObjectId } = require('mongodb')
const Settings = require('settings-sharelatex')
function shouldUserSeeNewLogsUI(user) {
const {
_id: userId,
alphaProgram: isAlphaUser,
betaProgram: isBetaUser
} = user
if (!userId) {
return false
}
const userIdAsPercentile = (ObjectId(userId).getTimestamp() / 1000) % 100
if (isAlphaUser) {
return true
} else if (isBetaUser && userIdAsPercentile < Settings.logsUIPercentageBeta) {
return true
} else if (userIdAsPercentile < Settings.logsUIPercentage) {
return true
} else {
return false
}
}
module.exports = {
shouldUserSeeNewLogsUI
}