Merge pull request #4052 from overleaf/ab-subscription-page-split-test-2

Subscription page split test

GitOrigin-RevId: 022a91d97f20d584e47e1f6b5575e689983df129
This commit is contained in:
Timothée Alby 2021-05-19 10:29:21 +02:00 committed by Copybot
parent ec3400c7cd
commit 03b2d184b5
5 changed files with 89 additions and 3 deletions

View file

@ -32,7 +32,12 @@ const V1SubscriptionManager = require('./V1SubscriptionManager')
const Errors = require('../Errors/Errors') const Errors = require('../Errors/Errors')
const HttpErrorHandler = require('../Errors/HttpErrorHandler') const HttpErrorHandler = require('../Errors/HttpErrorHandler')
const SubscriptionErrors = require('./Errors') const SubscriptionErrors = require('./Errors')
const SplitTestHandler = require('../SplitTests/SplitTestHandler')
const AnalyticsManager = require('../Analytics/AnalyticsManager')
const OError = require('@overleaf/o-error') const OError = require('@overleaf/o-error')
const _ = require('lodash')
const SUBSCRIPTION_PAGE_SPLIT_TEST = 'subscription-page'
module.exports = SubscriptionController = { module.exports = SubscriptionController = {
plansPage(req, res, next) { plansPage(req, res, next) {
@ -166,11 +171,47 @@ module.exports = SubscriptionController = {
const plans = SubscriptionViewModelBuilder.buildPlansList( const plans = SubscriptionViewModelBuilder.buildPlansList(
personalSubscription ? personalSubscription.plan : undefined personalSubscription ? personalSubscription.plan : undefined
) )
let subscriptionCopy = 'default'
if (
personalSubscription ||
hasSubscription ||
(memberGroupSubscriptions &&
memberGroupSubscriptions.length > 0) ||
(confirmedMemberAffiliations &&
confirmedMemberAffiliations.length > 0 &&
_.find(confirmedMemberAffiliations, affiliation => {
return affiliation.licence && affiliation.licence !== 'free'
}))
) {
AnalyticsManager.recordEvent(user._id, 'subscription-page-view')
} else {
const testSegmentation = SplitTestHandler.getTestSegmentation(
user._id,
SUBSCRIPTION_PAGE_SPLIT_TEST
)
if (testSegmentation.enabled) {
subscriptionCopy = testSegmentation.variant
AnalyticsManager.recordEvent(
user._id,
'subscription-page-view',
{
splitTestId: SUBSCRIPTION_PAGE_SPLIT_TEST,
splitTestVariantId: testSegmentation.variant,
}
)
} else {
AnalyticsManager.recordEvent(user._id, 'subscription-page-view')
}
}
const data = { const data = {
title: 'your_subscription', title: 'your_subscription',
plans, plans,
user, user,
hasSubscription, hasSubscription,
subscriptionCopy,
fromPlansPage, fromPlansPage,
personalSubscription, personalSubscription,
memberGroupSubscriptions, memberGroupSubscriptions,

View file

@ -55,6 +55,14 @@ block content
p(ng-non-bindable) You're on an #{settings.appName} Paid plan. Contact p(ng-non-bindable) You're on an #{settings.appName} Paid plan. Contact
a(href="mailto:support@overleaf.com") support@overleaf.com a(href="mailto:support@overleaf.com") support@overleaf.com
| to find out more. | to find out more.
else
if (subscriptionCopy === 'new')
p(ng-non-bindable) You are on the #{settings.appName} Free plan. Upgrade to access these Premium Features:
ul
li Invite more collaborators
for feature in ['realtime_track_changes', 'full_doc_history', 'reference_search', 'reference_sync', 'dropbox_integration_lowercase', 'github_integration_lowercase', 'priority_support']
li #{translate(feature)}
a(ng-controller="UpgradeSubscriptionController" href="/user/subscription/plans" ng-click="upgradeSubscription()").btn.btn-primary Upgrade now
else else
p(ng-non-bindable) You're on the #{settings.appName} Free plan. p(ng-non-bindable) You're on the #{settings.appName} Free plan.
| |

View file

@ -246,6 +246,16 @@ module.exports = settings =
rolloutPercent: parseInt(process.env['SPLITTEST_EXAMPLE_PROJECT_FROG_VARIANT_ROLLOUT_PERCENT'] || '0', 10) rolloutPercent: parseInt(process.env['SPLITTEST_EXAMPLE_PROJECT_FROG_VARIANT_ROLLOUT_PERCENT'] || '0', 10)
} }
] ]
},
{
id: 'subscription-page'
active: process.env['SPLITTEST_SUBSCRIPTION_PAGE_ACTIVE'] == 'true'
variants: [
{
id: 'new'
rolloutPercent: parseInt(process.env['SPLITTEST_SUBSCRIPTION_PAGE_NEW_VARIANT_ROLLOUT_PERCENT'] || '0', 10)
}
]
} }
] ]

View file

@ -0,0 +1,21 @@
Path = require('path')
module.exports = {
overleafModuleImports: {
# modules to import (an array of paths relative to this file in /app/config at build time)
createFileModes: [
Path.resolve(__dirname, '../modules/tpr-webmodule/frontend/js/components/create-file-mode-mendeley.js'),
Path.resolve(__dirname, '../modules/tpr-webmodule/frontend/js/components/create-file-mode-zotero.js')
],
tprLinkedFileInfo: [
Path.resolve(__dirname, '../modules/tpr-webmodule/frontend/js/components/linked-file-info.js')
],
tprLinkedFileRefreshError: [
Path.resolve(__dirname, '../modules/tpr-webmodule/frontend/js/components/linked-file-refresh-error.js')
],
gitBridge: [Path.resolve(__dirname, '../modules/git-bridge/frontend/js/components/git-bridge-modal.js')]
publishModal: [
Path.resolve(__dirname, '../modules/publish-modal/frontend/js/components/publish-toolbar-button')
]
}
}

View file

@ -115,6 +115,12 @@ describe('SubscriptionController', function () {
unprocessableEntity: sinon.stub(), unprocessableEntity: sinon.stub(),
}), }),
'./Errors': SubscriptionErrors, './Errors': SubscriptionErrors,
'../Analytics/AnalyticsManager': (this.AnalyticsManager = {
recordEvent: sinon.stub(),
}),
'../SplitTests/SplitTestHandler': (this.SplitTestHandler = {
getTestSegmentation: () => {},
}),
}, },
}) })