diff --git a/services/web/app/src/Features/Subscription/SubscriptionController.js b/services/web/app/src/Features/Subscription/SubscriptionController.js index d9791a20d0..504b180566 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionController.js +++ b/services/web/app/src/Features/Subscription/SubscriptionController.js @@ -32,7 +32,12 @@ const V1SubscriptionManager = require('./V1SubscriptionManager') const Errors = require('../Errors/Errors') const HttpErrorHandler = require('../Errors/HttpErrorHandler') const SubscriptionErrors = require('./Errors') +const SplitTestHandler = require('../SplitTests/SplitTestHandler') +const AnalyticsManager = require('../Analytics/AnalyticsManager') const OError = require('@overleaf/o-error') +const _ = require('lodash') + +const SUBSCRIPTION_PAGE_SPLIT_TEST = 'subscription-page' module.exports = SubscriptionController = { plansPage(req, res, next) { @@ -166,11 +171,47 @@ module.exports = SubscriptionController = { const plans = SubscriptionViewModelBuilder.buildPlansList( 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 = { title: 'your_subscription', plans, user, hasSubscription, + subscriptionCopy, fromPlansPage, personalSubscription, memberGroupSubscriptions, diff --git a/services/web/app/views/subscriptions/dashboard.pug b/services/web/app/views/subscriptions/dashboard.pug index 649d91911d..aa12cc46db 100644 --- a/services/web/app/views/subscriptions/dashboard.pug +++ b/services/web/app/views/subscriptions/dashboard.pug @@ -56,6 +56,14 @@ block content a(href="mailto:support@overleaf.com") support@overleaf.com | to find out more. else - p(ng-non-bindable) You're on the #{settings.appName} Free plan. - | - a(ng-controller="UpgradeSubscriptionController" href="/user/subscription/plans" ng-click="upgradeSubscription()").btn.btn-primary Upgrade now + 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 + p(ng-non-bindable) You're on the #{settings.appName} Free plan. + | + a(ng-controller="UpgradeSubscriptionController" href="/user/subscription/plans" ng-click="upgradeSubscription()").btn.btn-primary Upgrade now diff --git a/services/web/config/settings.defaults.coffee b/services/web/config/settings.defaults.coffee index cbab2b650e..b09bbedd9f 100644 --- a/services/web/config/settings.defaults.coffee +++ b/services/web/config/settings.defaults.coffee @@ -246,6 +246,16 @@ module.exports = settings = 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) + } + ] } ] diff --git a/services/web/config/settings.webpack.coffee b/services/web/config/settings.webpack.coffee new file mode 100644 index 0000000000..2f484f0092 --- /dev/null +++ b/services/web/config/settings.webpack.coffee @@ -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') + ] + } +} diff --git a/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js b/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js index f72b14b631..667797b15f 100644 --- a/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js +++ b/services/web/test/unit/src/Subscription/SubscriptionControllerTests.js @@ -115,6 +115,12 @@ describe('SubscriptionController', function () { unprocessableEntity: sinon.stub(), }), './Errors': SubscriptionErrors, + '../Analytics/AnalyticsManager': (this.AnalyticsManager = { + recordEvent: sinon.stub(), + }), + '../SplitTests/SplitTestHandler': (this.SplitTestHandler = { + getTestSegmentation: () => {}, + }), }, })