Revert "Extend the new compile UI rollout, respecting existing allocations"

This reverts commit 61bfba3a05780ec0b3a3461bba50cca6474a1274.

GitOrigin-RevId: d0ffcb9a13e9597cebf95961c0c50ef8f950dd7a
This commit is contained in:
Paulo Jorge Reis 2021-06-28 11:43:44 +01:00 committed by Copybot
parent 41d2085abe
commit 1e43dd3495
3 changed files with 151 additions and 99 deletions

View file

@ -11,27 +11,26 @@ const NEW_UI_WITHOUT_POPUP = {
subvariant: 'new-logs-ui-without-popup',
}
function _getVariantForPercentile(percentile) {
// The current percentages are:
// - 33% New UI with pop-up (originally, 5%)
// - 33% New UI without pop-up (originally, 5%)
// - 34% Existing UI
// To ensure group stability, the implementation below respects the original partitions
// for the new UI variants: [0, 5[ and [5,10[.
// Two new partitions are added: [10, 38[ and [38, 66[. These represent an extra 28p.p.
// which, with to the original 5%, add up to 33%.
function _getVariantForPercentile(
percentile,
newLogsUIWithPopupPercentage,
newLogsUIWithoutPopupPercentage
) {
// The thresholds below are upper thresholds
const newLogsUIThreshold = newLogsUIWithPopupPercentage
const newLogsUIWithoutPopupThreshold =
newLogsUIWithPopupPercentage + newLogsUIWithoutPopupPercentage
if (percentile < 5) {
// This partition represents the "New UI with pop-up" group in the original roll-out (5%)
// The partitions for each of the variants (range is 0 to 99) are defined as:
// * New UI with pop-up: 0 to newLogsUIThreshold (exc)
// * New UI without pop-up: newLogsUIThreshold (inc) to newLogsUIWithoutPopupThreshold (exc)
// * Existing UI: newLogsUIWithoutPopupThreshold (inc) to 99
if (percentile < newLogsUIThreshold) {
return NEW_UI_WITH_POPUP
} else if (percentile >= 5 && percentile < 10) {
// This partition represents the "New UI without pop-up" group in the original roll-out (5%)
return NEW_UI_WITHOUT_POPUP
} else if (percentile >= 10 && percentile < 38) {
// This partition represents an extra 28% of users getting the "New UI with pop-up"
return NEW_UI_WITH_POPUP
} else if (percentile >= 38 && percentile < 66) {
// This partition represents an extra 28% of users getting the "New UI without pop-up"
} else if (
percentile >= newLogsUIThreshold &&
percentile < newLogsUIWithoutPopupThreshold
) {
return NEW_UI_WITHOUT_POPUP
} else {
return EXISTING_UI
@ -39,10 +38,12 @@ function _getVariantForPercentile(percentile) {
}
function getNewLogsUIVariantForUser(user) {
const { _id: userId, alphaProgram: isAlphaUser } = user
const isSaaS = Boolean(Settings.overleaf)
if (!userId || !isSaaS) {
const {
_id: userId,
alphaProgram: isAlphaUser,
betaProgram: isBetaUser,
} = user
if (!userId) {
return EXISTING_UI
}
@ -50,8 +51,18 @@ function getNewLogsUIVariantForUser(user) {
if (isAlphaUser) {
return NEW_UI_WITH_POPUP
} else if (isBetaUser) {
return _getVariantForPercentile(
userIdAsPercentile,
Settings.logsUIPercentageBeta,
Settings.logsUIPercentageWithoutPopupBeta
)
} else {
return _getVariantForPercentile(userIdAsPercentile)
return _getVariantForPercentile(
userIdAsPercentile,
Settings.logsUIPercentage,
Settings.logsUIPercentageWithoutPopup
)
}
}

View file

@ -393,6 +393,22 @@ module.exports = {
),
wsRetryHandshake: parseInt(process.env.WEBSOCKET_RETRY_HANDSHAKE || '5', 10),
// Compile UI rollout percentages
logsUIPercentageBeta: parseInt(
process.env.LOGS_UI_PERCENTAGE_BETA || '0',
10
),
logsUIPercentageWithoutPopupBeta: parseInt(
process.env.LOGS_UI_WITHOUT_POPUP_PERCENTAGE_BETA || '0',
10
),
logsUIPercentage: parseInt(process.env.LOGS_UI_PERCENTAGE || '0', 10),
logsUIPercentageWithoutPopup: parseInt(
process.env.LOGS_UI_WITHOUT_POPUP_PERCENTAGE || '0',
10
),
// cookie domain
// use full domain for cookies to only be accessible from that domain,
// replace subdomain with dot to have them accessible on all subdomains

View file

@ -27,24 +27,18 @@ describe('NewLogsUI helper', function () {
)
}
function getTestInterval(lowerBoundary, upperBoundary) {
const midpoint = Math.floor(
lowerBoundary + (upperBoundary - lowerBoundary) / 2
)
return [lowerBoundary, midpoint, upperBoundary]
}
beforeEach(function () {
this.user = {
alphaProgram: false,
betaProgram: false,
_id: ObjectId('60085414b76eeb00737d93aa'),
}
this.settings = {
overleaf: {
foo: 'bar',
},
logsUIPercentageBeta: 0,
logsUIPercentageWithoutPopupBeta: 0,
logsUIPercentage: 0,
logsUIPercentageWithoutPopup: 0,
}
NewLogsUI = SandboxedModule.require(MODULE_PATH, {
requires: {
mongodb: { ObjectId },
@ -53,87 +47,118 @@ describe('NewLogsUI helper', function () {
})
})
describe('In a non-SaaS context', function () {
it('should always show the new UI with popup for alpha users', function () {
this.user.alphaProgram = true
for (const percentile of [0, 20, 40, 60, 80]) {
this.user._id = userIdFromTime(percentile)
const variant = NewLogsUI.getNewLogsUIVariantForUser(this.user)
expect(isNewUIWithPopup(variant)).to.be.true
}
})
describe('for beta users', function () {
beforeEach(function () {
delete this.settings.overleaf
this.user.betaProgram = true
})
it('should always show the existing UI', function () {
for (const percentile of [0, 20, 40, 60, 80]) {
this.user._id = userIdFromTime(percentile)
describe('with a 0% rollout', function () {
it('should always show the existing UI', function () {
for (const percentile of [0, 20, 40, 60, 80]) {
this.user._id = userIdFromTime(percentile)
const variant = NewLogsUI.getNewLogsUIVariantForUser(this.user)
expect(isExistingUI(variant)).to.be.true
}
})
})
describe('with a new UI rollout', function () {
const newUIWithPopupPercentage = 33
const newUIWithoutPopupPercentage = 33
const newUIWithPopupThreshold = newUIWithPopupPercentage
const newUIWithoutPopupThreshold =
newUIWithPopupPercentage + newUIWithoutPopupPercentage
beforeEach(function () {
this.settings.logsUIPercentageBeta = newUIWithPopupPercentage
this.settings.logsUIPercentageWithoutPopupBeta = newUIWithoutPopupPercentage
})
it('should show the new UI with popup when the id is below the new UI with popup upper threshold (exc)', function () {
this.user._id = userIdFromTime(newUIWithPopupThreshold - 1)
const variant = NewLogsUI.getNewLogsUIVariantForUser(this.user)
expect(isNewUIWithPopup(variant)).to.be.true
})
it('should show the new UI without popup when the id is at the new UI with popup upper threshold (exc)', function () {
this.user._id = userIdFromTime(newUIWithPopupThreshold)
const variant = NewLogsUI.getNewLogsUIVariantForUser(this.user)
expect(isNewUIWithoutPopup(variant)).to.be.true
})
it('should show the new UI without popup when the id is above the new UI with popup upper threshold (inc) and below the new UI without popup upper threshold (exc)', function () {
this.user._id = userIdFromTime(newUIWithoutPopupThreshold - 1)
const variant = NewLogsUI.getNewLogsUIVariantForUser(this.user)
expect(isNewUIWithoutPopup(variant)).to.be.true
})
it('should show the existing UI when the id is at the new UI without popup upper threshold (exc)', function () {
this.user._id = userIdFromTime(newUIWithoutPopupThreshold)
const variant = NewLogsUI.getNewLogsUIVariantForUser(this.user)
expect(isExistingUI(variant)).to.be.true
}
})
it('should show the existing UI when the id is above the new UI without popup upper threshold (exc)', function () {
this.user._id = userIdFromTime(newUIWithoutPopupThreshold + 1)
const variant = NewLogsUI.getNewLogsUIVariantForUser(this.user)
expect(isExistingUI(variant)).to.be.true
})
})
})
describe('For alpha users', function () {
beforeEach(function () {
this.user.alphaProgram = true
describe('for regular users', function () {
describe('with a 0% rollout', function () {
it('should always show the existing UI', function () {
for (const percentile of [0, 20, 40, 60, 80]) {
this.user._id = userIdFromTime(percentile)
const variant = NewLogsUI.getNewLogsUIVariantForUser(this.user)
expect(isExistingUI(variant)).to.be.true
}
})
})
it('should always show the new UI with popup', function () {
for (const percentile of [0, 20, 40, 60, 80]) {
this.user._id = userIdFromTime(percentile)
const variant = NewLogsUI.getNewLogsUIVariantForUser(this.user)
expect(isNewUIWithPopup(variant)).to.be.true
}
})
})
describe('For regular users', function () {
it('should show the new UI with popup when the id is in the [0, 5[ interval', function () {
const testInterval = getTestInterval(0, 4)
for (const percentile of testInterval) {
this.user._id = userIdFromTime(percentile)
describe('with a new UI rollout', function () {
const newUIWithPopupPercentage = 33
const newUIWithoutPopupPercentage = 33
const newUIWithPopupThreshold = newUIWithPopupPercentage
const newUIWithoutPopupThreshold =
newUIWithPopupPercentage + newUIWithoutPopupPercentage
beforeEach(function () {
this.settings.logsUIPercentage = newUIWithPopupPercentage
this.settings.logsUIPercentageWithoutPopup = newUIWithoutPopupPercentage
})
it('should show the new UI with popup when the id is below the new UI with popup upper threshold (exc)', function () {
this.user._id = userIdFromTime(newUIWithPopupThreshold - 1)
const variant = NewLogsUI.getNewLogsUIVariantForUser(this.user)
expect(isNewUIWithPopup(variant)).to.be.true
}
this.user._id = userIdFromTime(5)
const variant = NewLogsUI.getNewLogsUIVariantForUser(this.user)
expect(isNewUIWithPopup(variant)).to.be.false
})
it('should show the new UI without popup when the id is in the [5, 10[ interval', function () {
const testInterval = getTestInterval(5, 9)
for (const percentile of testInterval) {
this.user._id = userIdFromTime(percentile)
})
it('should show the new UI without popup when the id is at the new UI with popup upper threshold (exc)', function () {
this.user._id = userIdFromTime(newUIWithPopupThreshold)
const variant = NewLogsUI.getNewLogsUIVariantForUser(this.user)
expect(isNewUIWithoutPopup(variant)).to.be.true
}
this.user._id = userIdFromTime(10)
const variant = NewLogsUI.getNewLogsUIVariantForUser(this.user)
expect(isNewUIWithoutPopup(variant)).to.be.false
})
it('should show the new UI with popup when the id is in the [10, 38[ interval', function () {
const testInterval = getTestInterval(10, 37)
for (const percentile of testInterval) {
this.user._id = userIdFromTime(percentile)
const variant = NewLogsUI.getNewLogsUIVariantForUser(this.user)
expect(isNewUIWithPopup(variant)).to.be.true
}
this.user._id = userIdFromTime(38)
const variant = NewLogsUI.getNewLogsUIVariantForUser(this.user)
expect(isNewUIWithPopup(variant)).to.be.false
})
it('should show the new UI without popup when the id is in the [38, 66[ interval', function () {
const testInterval = getTestInterval(38, 65)
for (const percentile of testInterval) {
this.user._id = userIdFromTime(percentile)
})
it('should show the new UI without popup when the id is above the new UI with popup upper threshold (inc) and below the new UI without popup upper threshold (exc)', function () {
this.user._id = userIdFromTime(newUIWithoutPopupThreshold - 1)
const variant = NewLogsUI.getNewLogsUIVariantForUser(this.user)
expect(isNewUIWithoutPopup(variant)).to.be.true
}
this.user._id = userIdFromTime(66)
const variant = NewLogsUI.getNewLogsUIVariantForUser(this.user)
expect(isNewUIWithoutPopup(variant)).to.be.false
})
it('should show the existing UI when the id is in the [66, 99] interval', function () {
const testInterval = getTestInterval(66, 99)
for (const percentile of testInterval) {
this.user._id = userIdFromTime(percentile)
})
it('should show the existing UI when the id is at the new UI without popup upper threshold (exc)', function () {
this.user._id = userIdFromTime(newUIWithoutPopupThreshold)
const variant = NewLogsUI.getNewLogsUIVariantForUser(this.user)
expect(isExistingUI(variant)).to.be.true
}
this.user._id = userIdFromTime(100)
const variant = NewLogsUI.getNewLogsUIVariantForUser(this.user)
expect(isExistingUI(variant)).to.be.false
})
it('should show the existing UI when the id is above the new UI without popup upper threshold (exc)', function () {
this.user._id = userIdFromTime(newUIWithoutPopupThreshold + 1)
const variant = NewLogsUI.getNewLogsUIVariantForUser(this.user)
expect(isExistingUI(variant)).to.be.true
})
})
})
})