From b299ccf139d14645a259e22de5340d5b159c5003 Mon Sep 17 00:00:00 2001 From: Miguel Serrano Date: Fri, 28 Oct 2022 09:56:48 +0200 Subject: [PATCH] Merge pull request #10191 from overleaf/msm-new-joiner-survey Banner to recruit new joiners for survey GitOrigin-RevId: f901818cb428f0338de55655885eb8b54e702268 --- .../src/Features/Project/ProjectController.js | 34 +++++++++++++++++-- services/web/app/views/project/list.pug | 22 ++++++++++++ .../js/main/project-list/project-list.js | 7 ++++ services/web/locales/en.json | 5 ++- 4 files changed, 65 insertions(+), 3 deletions(-) diff --git a/services/web/app/src/Features/Project/ProjectController.js b/services/web/app/src/Features/Project/ProjectController.js index 723d8bd8c6..ce943c8347 100644 --- a/services/web/app/src/Features/Project/ProjectController.js +++ b/services/web/app/src/Features/Project/ProjectController.js @@ -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 = diff --git a/services/web/app/views/project/list.pug b/services/web/app/views/project/list.pug index e7758a0776..bc8cd38d1a 100644 --- a/services/web/app/views/project/list.pug +++ b/services/web/app/views/project/list.pug @@ -65,6 +65,28 @@ block content ) × .project-list-main.col-md-10.col-xs-9 + + if shouldDisplayNewJoinerBanner + .alert.alert-info( + ng-if="shouldShowNewJoinerSurvey" + ) + .notification-body + strong #{translate("new_joiner_survey_text_1")} + |   + span #{translate("new_joiner_survey_text_2")} + span.pull-right + a.btn.btn-sm.btn-info( + href="https://docs.google.com/forms/d/e/1FAIpQLSduwnJnerjeqeRIwvyn209mRUfoL96-USTOx7B0INBsqhR48A/viewform?usp=sf_link" + target="_blank" + rel="noopener noreferrer" + ng-click="dismissNewJoinerSurvey()" + ) + strong #{translate("take_survey")} + |   + button(ng-click="dismissNewJoinerSurvey()").close + span(aria-hidden="true") × + span.sr-only #{translate("close")} + include ./list/notifications include ./list/project-list diff --git a/services/web/frontend/js/main/project-list/project-list.js b/services/web/frontend/js/main/project-list/project-list.js index a152652800..03253a8eef 100644 --- a/services/web/frontend/js/main/project-list/project-list.js +++ b/services/web/frontend/js/main/project-list/project-list.js @@ -38,6 +38,13 @@ App.controller( $scope.shouldShowSurveyLink = false } + $scope.shouldShowNewJoinerSurvey = + localStorage('dismissed-new-joiner-survey') !== true + $scope.dismissNewJoinerSurvey = () => { + localStorage('dismissed-new-joiner-survey', true) + $scope.shouldShowNewJoinerSurvey = false + } + $timeout(() => recalculateProjectListHeight(), 10) $scope.$watch( diff --git a/services/web/locales/en.json b/services/web/locales/en.json index 644d61091e..4dd3232035 100644 --- a/services/web/locales/en.json +++ b/services/web/locales/en.json @@ -1908,5 +1908,8 @@ "show_x_more_projects": "Show __x__ more projects", "showing_x_out_of_n_projects": "Showing __x__ out of __n__ projects.", "make_a_copy": "Make a copy", - "projects_list": "Projects list" + "projects_list": "Projects list", + "new_joiner_survey_text_1": "Are you new to Overleaf?", + "new_joiner_survey_text_2": "Tell us your first impressions for a chance to win 50 USD", + "take_survey": "Take Survey" }