[web] drop rate of compile-result-backend events to 1%

GitOrigin-RevId: af3e4b56812f014ad7c40d1a98ee6db16798890b
This commit is contained in:
Jakob Ackermann 2022-11-03 14:37:06 +00:00 committed by Copybot
parent 19dd2f67e2
commit 7493be028d
2 changed files with 11 additions and 7 deletions

View file

@ -141,7 +141,14 @@ module.exports = CompileController = {
pdfDownloadDomain += outputUrlPrefix
}
if (limits) {
if (
limits &&
SplitTestHandler.getPercentile(
AnalyticsManager.getIdsFromSession(req.session).analyticsId,
'compile-result-backend',
'release'
) === 1
) {
// For a compile request to be sent to clsi we need limits.
// If we get here without having the limits object populated, it is
// a reasonable assumption to make that nothing was compiled.

View file

@ -263,11 +263,7 @@ async function _getAssignmentMetadata(analyticsId, user, splitTest) {
}
}
const userId = user?._id.toString()
const percentile = _getPercentile(
analyticsId || userId,
splitTest.name,
phase
)
const percentile = getPercentile(analyticsId || userId, splitTest.name, phase)
const selectedVariantName = _getVariantFromPercentile(
currentVersion.variants,
percentile
@ -280,7 +276,7 @@ async function _getAssignmentMetadata(analyticsId, user, splitTest) {
}
}
function _getPercentile(analyticsId, splitTestName, splitTestPhase) {
function getPercentile(analyticsId, splitTestName, splitTestPhase) {
const hash = crypto
.createHash('md5')
.update(analyticsId + splitTestName + splitTestPhase)
@ -408,6 +404,7 @@ async function _loadSplitTestInfoInLocals(locals, splitTestName) {
}
module.exports = {
getPercentile,
getAssignment: callbackify(getAssignment),
getAssignmentForMongoUser: callbackify(getAssignmentForMongoUser),
getAssignmentForUser: callbackify(getAssignmentForUser),