From 6d07707bfe6c0a4f40988eb2a996a0941ade8730 Mon Sep 17 00:00:00 2001 From: roo hutton Date: Fri, 27 Jun 2025 09:16:38 +0100 Subject: [PATCH] Merge pull request #26349 from overleaf/rh-cio-dashboard-assignment Assign customer.io split test on projects dashboard GitOrigin-RevId: 78a21bce31262db15f9701abc0599b44b9023ad2 --- .../Project/ProjectListController.mjs | 47 +++++++++++++++---- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/services/web/app/src/Features/Project/ProjectListController.mjs b/services/web/app/src/Features/Project/ProjectListController.mjs index 24e0ae44e8..2e1ca6a01a 100644 --- a/services/web/app/src/Features/Project/ProjectListController.mjs +++ b/services/web/app/src/Features/Project/ProjectListController.mjs @@ -29,6 +29,7 @@ import TutorialHandler from '../Tutorial/TutorialHandler.js' import SubscriptionHelper from '../Subscription/SubscriptionHelper.js' import PermissionsManager from '../Authorization/PermissionsManager.js' import SubscriptionLocator from '../Subscription/SubscriptionLocator.js' +import AnalyticsManager from '../Analytics/AnalyticsManager.js' /** * @import { GetProjectsRequest, GetProjectsResponse, AllUsersProjects, MongoProject } from "./types" @@ -423,14 +424,44 @@ async function projectListPage(req, res, next) { showAiAssistNotification = await _showAiAssistNotification(user) } - const customerIoEnabled = - await SplitTestHandler.promises.hasUserBeenAssignedToVariant( - req, - userId, - 'customer-io-trial-conversion', - 'enabled', - true - ) + const affiliations = userAffiliations || [] + const inEnterpriseCommons = affiliations.some( + affiliation => affiliation.institution?.enterpriseCommons + ) + + // customer.io: Premium nudge experiment + // Only do customer-io-trial-conversion assignment for users not in India/China and not in group/commons + let customerIoEnabled = false + if (!userIsMemberOfGroupSubscription && !inEnterpriseCommons) { + try { + const ip = req.ip + const { countryCode } = await GeoIpLookup.promises.getCurrencyCode(ip) + const excludedCountries = ['IN', 'CN'] + + if (!excludedCountries.includes(countryCode)) { + const cioAssignment = + await SplitTestHandler.promises.getAssignmentForUser( + userId, + 'customer-io-trial-conversion' + ) + if (cioAssignment.variant === 'enabled') { + customerIoEnabled = true + AnalyticsManager.setUserPropertyForUserInBackground( + userId, + 'customer-io-integration', + true + ) + } + } + } catch (err) { + logger.error( + { err }, + 'Error checking geo location for customer-io-trial-conversion' + ) + // Fallback to not enabled if geoip fails + customerIoEnabled = false + } + } res.render('project/list-react', { title: 'your_projects',