mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-03 14:19:01 +02:00
e075611632
[web] Read anonymous split test assignments in session from both old&new fields GitOrigin-RevId: 5235bb3e7d72d5ff9e89c6543b70fb80e9f1213c
31 lines
726 B
JavaScript
31 lines
726 B
JavaScript
const { callbackify } = require('util')
|
|
const Metrics = require('@overleaf/metrics')
|
|
const UserGetter = require('../User/UserGetter')
|
|
|
|
async function getUser(id, splitTestName) {
|
|
const projection = {
|
|
analyticsId: 1,
|
|
alphaProgram: 1,
|
|
betaProgram: 1,
|
|
}
|
|
if (splitTestName) {
|
|
projection[`splitTests.${splitTestName}`] = 1
|
|
} else {
|
|
projection.splitTests = 1
|
|
}
|
|
const user = await UserGetter.promises.getUser(id, projection)
|
|
Metrics.histogram(
|
|
'split_test_get_user_from_mongo_size',
|
|
JSON.stringify(user).length,
|
|
[0, 100, 500, 1000, 2000, 5000, 10000, 15000, 20000, 50000, 100000]
|
|
)
|
|
return user
|
|
}
|
|
|
|
module.exports = {
|
|
getUser: callbackify(getUser),
|
|
promises: {
|
|
getUser,
|
|
},
|
|
}
|