Implement new users micro survey for project dashboard page on react and non-react version (#11347)

* Implement new users micro survey for project dashboard page on react and non-react version

* Add 'new-users-micro-survey-click' and 'new-users-micro-survey-prompt' new event for the analytics

GitOrigin-RevId: 9aabe931987638b38995d404aa90ac4d40b2f3b5
This commit is contained in:
M Fahru
2023-01-20 06:52:41 -07:00
committed by Copybot
parent b8285fdf46
commit e2d3284674
9 changed files with 184 additions and 0 deletions
@@ -556,6 +556,26 @@ const ProjectController = {
}
)
},
newUsersMicroSurveyAssignment(cb) {
SplitTestHandler.getAssignment(
req,
res,
'new-users-micro-survey',
(err, assignment) => {
if (err) {
logger.error(
{ err },
'failed to get "new-users-micro-survey" split test assignment'
)
const defaultAssignment = { variant: 'default' }
cb(null, defaultAssignment)
} else {
cb(null, assignment)
}
}
)
},
survey(cb) {
SurveyHandler.getSurvey(userId, (err, survey) => {
if (err) {
@@ -578,6 +598,7 @@ const ProjectController = {
user,
userEmailsData,
groupsAndEnterpriseBannerAssignment,
newUsersMicroSurveyAssignment,
userIsMemberOfGroupSubscription,
} = results
@@ -718,6 +739,16 @@ const ProjectController = {
!userIsMemberOfGroupSubscription &&
!hasPaidAffiliation
const SEVEN_DAYS = 1000 * 60 * 60 * 24 * 7
const isUserLessThanSevenDaysOld =
user.signUpDate && Date.now() - user.signUpDate.getTime() < SEVEN_DAYS
const showNewUsersMicroSurvey =
Features.hasFeature('saas') &&
newUsersMicroSurveyAssignment.variant === 'enabled' &&
isUserLessThanSevenDaysOld
ProjectController._injectProjectUsers(projects, (error, projects) => {
if (error != null) {
return next(error)
@@ -745,6 +776,7 @@ const ProjectController = {
showGroupsAndEnterpriseBanner,
groupsAndEnterpriseBannerVariant:
groupsAndEnterpriseBannerAssignment.variant,
showNewUsersMicroSurvey,
}
const paidUser =