mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
2051caf28e
* 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
29 lines
636 B
JavaScript
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
|
|
}
|