|
|
@@ -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',
|