Merge pull request #10191 from overleaf/msm-new-joiner-survey

Banner to recruit new joiners for survey

GitOrigin-RevId: f901818cb428f0338de55655885eb8b54e702268
This commit is contained in:
Miguel Serrano
2022-10-28 09:56:48 +02:00
committed by Copybot
parent b85ae6e58e
commit b299ccf139
4 changed files with 65 additions and 3 deletions

View File

@@ -509,6 +509,24 @@ const ProjectController = {
}
)
},
newJoinerSurveyBannerActive(cb) {
SplitTestHandler.getAssignment(
req,
res,
'new-joiner-survey-banner',
(err, assignment) => {
if (err) {
logger.warn(
{ err },
'failed to get "new-joiner-survey-banner" split test assignment'
)
cb(null, false)
} else {
cb(null, assignment.variant === 'active')
}
}
)
},
survey(cb) {
SurveyHandler.getSurvey(userId, (err, survey) => {
if (err) {
@@ -526,8 +544,13 @@ const ProjectController = {
OError.tag(err, 'error getting data for project list page')
return next(err)
}
const { notifications, user, userEmailsData, primaryEmailCheckActive } =
results
const {
notifications,
user,
userEmailsData,
primaryEmailCheckActive,
newJoinerSurveyBannerActive,
} = results
if (
user &&
@@ -656,6 +679,12 @@ const ProjectController = {
)
}
const isNewJoiner =
user.signUpDate &&
Date.now() - user.signUpDate.getTime() < 1000 * 60 * 60 * 24
const shouldDisplayNewJoinerBanner =
newJoinerSurveyBannerActive && isNewJoiner
ProjectController._injectProjectUsers(projects, (error, projects) => {
if (error != null) {
return next(error)
@@ -680,6 +709,7 @@ const ProjectController = {
showThinFooter: true, // don't show the fat footer on the projects dashboard, as there's a fixed space available
usersBestSubscription: results.usersBestSubscription,
survey: results.survey,
shouldDisplayNewJoinerBanner,
}
const paidUser =