Merge pull request #26349 from overleaf/rh-cio-dashboard-assignment

Assign customer.io split test on projects dashboard

GitOrigin-RevId: 78a21bce31262db15f9701abc0599b44b9023ad2
This commit is contained in:
roo hutton
2025-06-27 09:16:38 +01:00
committed by Copybot
parent 72dbdcd3e3
commit 6d07707bfe
@@ -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',