diff --git a/services/web/app/src/Features/SplitTests/SplitTestHandler.js b/services/web/app/src/Features/SplitTests/SplitTestHandler.js index 05bf295555..ef226b161d 100644 --- a/services/web/app/src/Features/SplitTests/SplitTestHandler.js +++ b/services/web/app/src/Features/SplitTests/SplitTestHandler.js @@ -9,6 +9,7 @@ const SplitTestCache = require('./SplitTestCache') const { SplitTest } = require('../../models/SplitTest') const UserAnalyticsIdCache = require('../Analytics/UserAnalyticsIdCache') const { getAnalyticsIdFromMongoUser } = require('../Analytics/AnalyticsHelper') +const Features = require('../../infrastructure/Features') const DEFAULT_VARIANT = 'default' const ALPHA_PHASE = 'alpha' @@ -46,6 +47,10 @@ const DEFAULT_ASSIGNMENT = { * @returns {Promise<{variant: string, analytics: {segmentation: {splitTest: string, variant: string, phase: string, versionNumber: number}|{}}}>} */ async function getAssignment(req, res, splitTestName, { sync = false } = {}) { + if (!Features.hasFeature('saas')) { + return DEFAULT_ASSIGNMENT + } + const query = req.query || {} let assignment @@ -100,6 +105,10 @@ async function getAssignmentForUser( splitTestName, { sync = false } = {} ) { + if (!Features.hasFeature('saas')) { + return DEFAULT_ASSIGNMENT + } + const analyticsId = await UserAnalyticsIdCache.get(userId) return _getAssignment(splitTestName, { analyticsId, userId, sync }) } @@ -120,6 +129,10 @@ async function getAssignmentForMongoUser( splitTestName, { sync = false } = {} ) { + if (!Features.hasFeature('saas')) { + return DEFAULT_ASSIGNMENT + } + return _getAssignment(splitTestName, { analyticsId: getAnalyticsIdFromMongoUser(user), sync, @@ -132,6 +145,10 @@ async function getAssignmentForMongoUser( * Get a mapping of the active split test assignments for the given user */ async function getActiveAssignmentsForUser(userId) { + if (!Features.hasFeature('saas')) { + return {} + } + const user = await _getUser(userId) if (user == null) { return {} diff --git a/services/web/test/acceptance/src/PrimaryEmailCheckTests.js b/services/web/test/acceptance/src/PrimaryEmailCheckTests.js index 4d8cd70157..d05f89bb05 100644 --- a/services/web/test/acceptance/src/PrimaryEmailCheckTests.js +++ b/services/web/test/acceptance/src/PrimaryEmailCheckTests.js @@ -2,6 +2,7 @@ const UserHelper = require('./helpers/UserHelper') const Settings = require('@overleaf/settings') const { expect } = require('chai') const SplitTestManager = require('../../../app/src/Features/SplitTests/SplitTestManager') +const Features = require('../../../app/src/infrastructure/Features') // While the split test is in progress this must be appended to URLs during tests const SPLIT_TEST_QUERY = '?primary-email-check=active' @@ -12,6 +13,10 @@ describe('PrimaryEmailCheck', function () { // Create the primary-email-check split test because this is now required for the query string override to work. See // https://github.com/overleaf/internal/pull/7545#discussion_r848575736 before(async function () { + if (!Features.hasFeature('saas')) { + this.skip() + } + await SplitTestManager.createSplitTest({ name: 'primary-email-check', configuration: {