Implement interstitial payment page for free trial button on project page with split test (#8311)

GitOrigin-RevId: b24b4f91d281c2756aed68ec176d138fcdd52e54
This commit is contained in:
M Fahru 2022-06-28 09:36:13 -04:00 committed by Copybot
parent 054b0e2e28
commit d5bc7c450c
4 changed files with 58 additions and 4 deletions

View file

@ -919,6 +919,21 @@ const ProjectController = {
}
)
},
interstitialPaymentFromPaywallAssignment(cb) {
SplitTestHandler.getAssignment(
req,
res,
'interstitial-payment-from-paywall',
(error, assignment) => {
// do not fail editor load if assignment fails
if (error) {
cb(null, { variant: 'default' })
} else {
cb(null, assignment)
}
}
)
},
latexLogParserAssignment(cb) {
SplitTestHandler.getAssignment(
req,

View file

@ -1,4 +1,9 @@
import * as eventTracking from '../infrastructure/event-tracking'
import getMeta from '../utils/meta'
const interstitialPaymentAfterPaywallVariant =
getMeta('ol-splitTestVariants')?.['interstitial-payment-from-paywall'] ??
'default'
function startFreeTrial(source, version, $scope) {
const plan = 'collaborator_free_trial_7_days'
@ -11,7 +16,12 @@ function startFreeTrial(source, version, $scope) {
}
eventTracking.sendMB('paywall-click', { 'paywall-type': source })
url = `/user/subscription/new?planCode=${plan}&ssp=true`
if (interstitialPaymentAfterPaywallVariant === 'active') {
url = '/user/subscription/choose-your-plan'
} else {
url = `/user/subscription/new?planCode=${plan}&ssp=true`
}
url = `${url}&itm_campaign=${source}`
if (version) {
url = `${url}&itm_content=${version}`

View file

@ -77,6 +77,8 @@ function setUpSubscriptionTracking(linkEl) {
})
}
const searchParams = new URLSearchParams(window.location.search)
export function updateLinkTargets() {
document.querySelectorAll('[data-ol-start-new-subscription]').forEach(el => {
if (el.hasAttribute('data-ol-has-custom-href')) return
@ -87,7 +89,21 @@ export function updateLinkTargets() {
const planCode = `${plan}${suffix}`
const location = el.getAttribute('data-ol-location')
el.href = `/user/subscription/new?planCode=${planCode}&currency=${currentCurrencyCode}&itm_campaign=plans&itm_content=${location}`
const itmCampaign = searchParams.get('itm_campaign') || 'plans'
const itmContent =
itmCampaign === 'plans' ? location : searchParams.get('itm_content')
const queryString = new URLSearchParams({
planCode,
currency: currentCurrencyCode,
itm_campaign: itmCampaign,
})
if (itmContent) {
queryString.set('itm_content', itmContent)
}
el.href = `/user/subscription/new?${queryString.toString()}`
})
}

View file

@ -2,6 +2,7 @@ import { useCallback, useEffect } from 'react'
import { useTranslation } from 'react-i18next'
import { Button } from 'react-bootstrap'
import PropTypes from 'prop-types'
import { useSplitTestContext } from '../context/split-test-context'
import * as eventTracking from '../../infrastructure/event-tracking'
export default function StartFreeTrialButton({
@ -13,6 +14,12 @@ export default function StartFreeTrialButton({
}) {
const { t } = useTranslation()
const { splitTestVariants } = useSplitTestContext({
splitTestVariants: PropTypes.object,
})
const interstitialPaymentFromPaywallVariant =
splitTestVariants['interstitial-payment-from-paywall']
useEffect(() => {
eventTracking.sendMB('paywall-prompt', { 'paywall-type': source })
}, [source])
@ -34,9 +41,15 @@ export default function StartFreeTrialButton({
itm_campaign: source,
})
window.open(`/user/subscription/new?${params}`)
if (interstitialPaymentFromPaywallVariant === 'active') {
window.open(
`/user/subscription/choose-your-plan?itm_campaign=${source}`
)
} else {
window.open(`/user/subscription/new?${params}`)
}
},
[setStartedFreeTrial, source]
[setStartedFreeTrial, source, interstitialPaymentFromPaywallVariant]
)
return (