mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #14913 from overleaf/jpa-no-cache-for-anon
[web] purge split test cache for anonymous users GitOrigin-RevId: e268b30ac03d4cab0f7976657089c58bc3c84210
This commit is contained in:
parent
a2cf7b459c
commit
926d8911e1
1 changed files with 10 additions and 2 deletions
|
@ -248,7 +248,15 @@ async function _getAssignment(
|
||||||
return DEFAULT_ASSIGNMENT
|
return DEFAULT_ASSIGNMENT
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session) {
|
// Do not cache assignments for anonymous users. All the context for their assignments is in the session:
|
||||||
|
// They cannot be part of the alpha or beta program, and they will use their analyticsId for assignments.
|
||||||
|
const canUseSessionCache = session && SessionManager.isUserLoggedIn(session)
|
||||||
|
if (session && !canUseSessionCache) {
|
||||||
|
// Purge the existing cache
|
||||||
|
delete session.cachedSplitTestAssignments
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canUseSessionCache) {
|
||||||
const cachedVariant = _getCachedVariantFromSession(
|
const cachedVariant = _getCachedVariantFromSession(
|
||||||
session,
|
session,
|
||||||
splitTest.name,
|
splitTest.name,
|
||||||
|
@ -275,7 +283,7 @@ async function _getAssignment(
|
||||||
user = user || (userId && (await _getUser(userId, splitTestName)))
|
user = user || (userId && (await _getUser(userId, splitTestName)))
|
||||||
const { activeForUser, selectedVariantName, phase, versionNumber } =
|
const { activeForUser, selectedVariantName, phase, versionNumber } =
|
||||||
await _getAssignmentMetadata(analyticsId, user, splitTest)
|
await _getAssignmentMetadata(analyticsId, user, splitTest)
|
||||||
if (session) {
|
if (canUseSessionCache) {
|
||||||
_setVariantInSession({
|
_setVariantInSession({
|
||||||
session,
|
session,
|
||||||
splitTestName,
|
splitTestName,
|
||||||
|
|
Loading…
Reference in a new issue