Sfoglia il codice sorgente

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

GitOrigin-RevId: af3e4b56812f014ad7c40d1a98ee6db16798890b
Jakob Ackermann 4 anni fa
parent
commit
7493be028d

+ 8 - 1
services/web/app/src/Features/Compile/CompileController.js

@@ -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.

+ 3 - 6
services/web/app/src/Features/SplitTests/SplitTestHandler.js

@@ -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),