|
@@ -78,6 +78,15 @@ async function getAssignmentForSession(session, splitTestName, options) {
|
|
|
return _getAssignment(analyticsId, userId, session, splitTestName, options)
|
|
return _getAssignment(analyticsId, userId, session, splitTestName, options)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * Get the assignment of a user to a split test by their ID and stores it in the locals context.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param res the Express response object
|
|
|
|
|
+ * @param userId the user ID
|
|
|
|
|
+ * @param splitTestName the unique name of the split test
|
|
|
|
|
+ * @param options {Object<sync: boolean>} - for test purposes only, to force the synchronous update of the user's profile
|
|
|
|
|
+ * @returns {Promise<void>}
|
|
|
|
|
+ */
|
|
|
async function assignInLocalsContext(res, userId, splitTestName, options) {
|
|
async function assignInLocalsContext(res, userId, splitTestName, options) {
|
|
|
const assignment = await getAssignment(userId, splitTestName, options)
|
|
const assignment = await getAssignment(userId, splitTestName, options)
|
|
|
if (!res.locals.splitTestVariants) {
|
|
if (!res.locals.splitTestVariants) {
|
|
@@ -86,6 +95,15 @@ async function assignInLocalsContext(res, userId, splitTestName, options) {
|
|
|
res.locals.splitTestVariants[splitTestName] = assignment.variant
|
|
res.locals.splitTestVariants[splitTestName] = assignment.variant
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * Get the assignment of a user to a split test by their session and stores it in the locals context.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param res the Express response object
|
|
|
|
|
+ * @param session the request session
|
|
|
|
|
+ * @param splitTestName the unique name of the split test
|
|
|
|
|
+ * @param options {Object<sync: boolean>} - for test purposes only, to force the synchronous update of the user's profile
|
|
|
|
|
+ * @returns {Promise<void>}
|
|
|
|
|
+ */
|
|
|
async function assignInLocalsContextForSession(
|
|
async function assignInLocalsContextForSession(
|
|
|
res,
|
|
res,
|
|
|
session,
|
|
session,
|