From ded18dd09b444c53d5f2b3b1f9025cfa827b27d5 Mon Sep 17 00:00:00 2001 From: M Fahru Date: Thu, 11 Jan 2024 10:49:55 -0700 Subject: [PATCH] Merge pull request #16244 from overleaf/mf-website-redesign-analytics [web] Implement analytics that will be used for the website-redesign split test analysis GitOrigin-RevId: 49bc0fe2049a5bf2ff676dfde93c1396002735c2 --- .../web/app/src/Features/StaticPages/HomeController.js | 1 + .../src/Features/Subscription/SubscriptionController.js | 4 ++++ services/web/app/src/Features/User/UserCreator.js | 7 +++++++ 3 files changed, 12 insertions(+) diff --git a/services/web/app/src/Features/StaticPages/HomeController.js b/services/web/app/src/Features/StaticPages/HomeController.js index 2013785199..343f8059c1 100644 --- a/services/web/app/src/Features/StaticPages/HomeController.js +++ b/services/web/app/src/Features/StaticPages/HomeController.js @@ -58,6 +58,7 @@ module.exports = HomeController = { ) AnalyticsManager.recordEventForSession(req.session, 'home-page-view', { page: req.url, + 'website-redesign': websiteRedesignVariant, }) if (websiteRedesignActive) { diff --git a/services/web/app/src/Features/Subscription/SubscriptionController.js b/services/web/app/src/Features/Subscription/SubscriptionController.js index dc9fe602bf..ab14929706 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionController.js +++ b/services/web/app/src/Features/Subscription/SubscriptionController.js @@ -110,6 +110,9 @@ async function plansPage(req, res) { ) } + const websiteRedesignVariant = + res.locals.splitTestVariants?.['website-redesign'] + const plansPageViewSegmentation = { currency: recommendedCurrency, countryCode, @@ -122,6 +125,7 @@ async function plansPage(req, res) { ? 'latam' : 'default', 'annual-trials': annualTrialsAssignment.variant, + 'website-redesign': websiteRedesignVariant, } if (inrGeoBannerSplitTestName) { plansPageViewSegmentation[inrGeoBannerSplitTestName] = inrGeoBannerVariant diff --git a/services/web/app/src/Features/User/UserCreator.js b/services/web/app/src/Features/User/UserCreator.js index ea5760dd91..637aee163d 100644 --- a/services/web/app/src/Features/User/UserCreator.js +++ b/services/web/app/src/Features/User/UserCreator.js @@ -43,10 +43,17 @@ async function recordRegistrationEvent(user) { 'onboarding-flow' ) + const websiteRedesignAssignment = + await SplitTestHandler.promises.getAssignmentForUser( + user._id, + 'website-redesign' + ) + try { const segmentation = { 'home-registration': 'default', 'onboarding-flow': onboardingFlowAssignment.variant, + 'website-redesign': websiteRedesignAssignment.variant, } if (user.thirdPartyIdentifiers && user.thirdPartyIdentifiers.length > 0) { segmentation.provider = user.thirdPartyIdentifiers[0].providerId