mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #4359 from overleaf/ab-example-project-new-split-test
Update example project split test to new framework GitOrigin-RevId: 9b3f1cb2b7a84d0078abf9c748dcdf9c6c7637e1
This commit is contained in:
parent
547260b2b2
commit
5b5c7ebd01
3 changed files with 11 additions and 18 deletions
|
@ -15,7 +15,7 @@ const path = require('path')
|
||||||
const { callbackify } = require('util')
|
const { callbackify } = require('util')
|
||||||
const _ = require('underscore')
|
const _ = require('underscore')
|
||||||
const AnalyticsManager = require('../Analytics/AnalyticsManager')
|
const AnalyticsManager = require('../Analytics/AnalyticsManager')
|
||||||
const SplitTestHandler = require('../SplitTests/SplitTestHandler')
|
const SplitTestV2Handler = require('../SplitTests/SplitTestV2Handler')
|
||||||
|
|
||||||
const MONTH_NAMES = [
|
const MONTH_NAMES = [
|
||||||
'January',
|
'January',
|
||||||
|
@ -31,7 +31,7 @@ const MONTH_NAMES = [
|
||||||
'November',
|
'November',
|
||||||
'December',
|
'December',
|
||||||
]
|
]
|
||||||
const EXAMPLE_PROJECT_SPLITTEST_ID = 'example-project-v2'
|
const EXAMPLE_PROJECT_SPLITTEST_ID = 'example-project-v3'
|
||||||
|
|
||||||
async function createBlankProject(ownerId, projectName, attributes = {}) {
|
async function createBlankProject(ownerId, projectName, attributes = {}) {
|
||||||
const isImport = attributes && attributes.overleaf
|
const isImport = attributes && attributes.overleaf
|
||||||
|
@ -72,28 +72,21 @@ async function createBasicProject(ownerId, projectName) {
|
||||||
async function createExampleProject(ownerId, projectName) {
|
async function createExampleProject(ownerId, projectName) {
|
||||||
const project = await _createBlankProject(ownerId, projectName)
|
const project = await _createBlankProject(ownerId, projectName)
|
||||||
|
|
||||||
const testSegmentation = await SplitTestHandler.promises.getTestSegmentation(
|
const assignment = await SplitTestV2Handler.promises.getAssignment(
|
||||||
ownerId,
|
ownerId,
|
||||||
EXAMPLE_PROJECT_SPLITTEST_ID
|
EXAMPLE_PROJECT_SPLITTEST_ID
|
||||||
)
|
)
|
||||||
|
|
||||||
if (testSegmentation.variant === 'example-frog') {
|
if (assignment.variant === 'example-frog') {
|
||||||
await _addSplitTestExampleProjectFiles(ownerId, projectName, project)
|
await _addSplitTestExampleProjectFiles(ownerId, projectName, project)
|
||||||
} else {
|
} else {
|
||||||
await _addDefaultExampleProjectFiles(ownerId, projectName, project)
|
await _addDefaultExampleProjectFiles(ownerId, projectName, project)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (testSegmentation.enabled) {
|
|
||||||
AnalyticsManager.recordEvent(ownerId, 'project-created', {
|
AnalyticsManager.recordEvent(ownerId, 'project-created', {
|
||||||
projectId: project._id,
|
projectId: project._id,
|
||||||
splitTestId: EXAMPLE_PROJECT_SPLITTEST_ID,
|
...assignment.analytics.segmentation,
|
||||||
splitTestVariantId: testSegmentation.variant,
|
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
AnalyticsManager.recordEvent(ownerId, 'project-created', {
|
|
||||||
projectId: project._id,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return project
|
return project
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ class SplitTestCache extends CacheLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
serialize(value) {
|
serialize(value) {
|
||||||
return value.toObject()
|
return value ? value.toObject() : undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
deserialize(value) {
|
deserialize(value) {
|
||||||
|
|
|
@ -31,8 +31,8 @@ const BETA_PHASE = 'beta'
|
||||||
*
|
*
|
||||||
* @param userId the user's ID
|
* @param userId the user's ID
|
||||||
* @param splitTestName the unique name of the split test
|
* @param splitTestName the unique name of the split test
|
||||||
* @param options {sync: boolean} - for test purposes only, to force the synchronous update of the user's profile
|
* @param options {Object<sync: boolean>} - for test purposes only, to force the synchronous update of the user's profile
|
||||||
* @returns {Promise<{analytics: {segmentation: {}}, variant: string}|{analytics: {segmentation: {phase, splitTest, variant: string, versionNumber}}, variant: string}>}
|
* @returns {Promise<{variant: string, analytics: {segmentation: {splitTest: string, variant: string, phase: string, versionNumber: number}|{}}}>}
|
||||||
*/
|
*/
|
||||||
async function getAssignment(userId, splitTestName, options) {
|
async function getAssignment(userId, splitTestName, options) {
|
||||||
const splitTest = await splitTestCache.get(splitTestName)
|
const splitTest = await splitTestCache.get(splitTestName)
|
||||||
|
|
Loading…
Reference in a new issue