mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
Implement interstitial payment page for free trial button on project page with split test (#8311)
GitOrigin-RevId: b24b4f91d281c2756aed68ec176d138fcdd52e54
This commit is contained in:
@@ -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) {
|
latexLogParserAssignment(cb) {
|
||||||
SplitTestHandler.getAssignment(
|
SplitTestHandler.getAssignment(
|
||||||
req,
|
req,
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
import * as eventTracking from '../infrastructure/event-tracking'
|
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) {
|
function startFreeTrial(source, version, $scope) {
|
||||||
const plan = 'collaborator_free_trial_7_days'
|
const plan = 'collaborator_free_trial_7_days'
|
||||||
@@ -11,7 +16,12 @@ function startFreeTrial(source, version, $scope) {
|
|||||||
}
|
}
|
||||||
eventTracking.sendMB('paywall-click', { 'paywall-type': source })
|
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}`
|
url = `${url}&itm_campaign=${source}`
|
||||||
if (version) {
|
if (version) {
|
||||||
url = `${url}&itm_content=${version}`
|
url = `${url}&itm_content=${version}`
|
||||||
|
|||||||
@@ -77,6 +77,8 @@ function setUpSubscriptionTracking(linkEl) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const searchParams = new URLSearchParams(window.location.search)
|
||||||
|
|
||||||
export function updateLinkTargets() {
|
export function updateLinkTargets() {
|
||||||
document.querySelectorAll('[data-ol-start-new-subscription]').forEach(el => {
|
document.querySelectorAll('[data-ol-start-new-subscription]').forEach(el => {
|
||||||
if (el.hasAttribute('data-ol-has-custom-href')) return
|
if (el.hasAttribute('data-ol-has-custom-href')) return
|
||||||
@@ -87,7 +89,21 @@ export function updateLinkTargets() {
|
|||||||
const planCode = `${plan}${suffix}`
|
const planCode = `${plan}${suffix}`
|
||||||
|
|
||||||
const location = el.getAttribute('data-ol-location')
|
const location = el.getAttribute('data-ol-location')
|
||||||
el.href = `/user/subscription/new?planCode=${planCode}¤cy=${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()}`
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { useCallback, useEffect } from 'react'
|
|||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Button } from 'react-bootstrap'
|
import { Button } from 'react-bootstrap'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
|
import { useSplitTestContext } from '../context/split-test-context'
|
||||||
import * as eventTracking from '../../infrastructure/event-tracking'
|
import * as eventTracking from '../../infrastructure/event-tracking'
|
||||||
|
|
||||||
export default function StartFreeTrialButton({
|
export default function StartFreeTrialButton({
|
||||||
@@ -13,6 +14,12 @@ export default function StartFreeTrialButton({
|
|||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|
||||||
|
const { splitTestVariants } = useSplitTestContext({
|
||||||
|
splitTestVariants: PropTypes.object,
|
||||||
|
})
|
||||||
|
const interstitialPaymentFromPaywallVariant =
|
||||||
|
splitTestVariants['interstitial-payment-from-paywall']
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
eventTracking.sendMB('paywall-prompt', { 'paywall-type': source })
|
eventTracking.sendMB('paywall-prompt', { 'paywall-type': source })
|
||||||
}, [source])
|
}, [source])
|
||||||
@@ -34,9 +41,15 @@ export default function StartFreeTrialButton({
|
|||||||
itm_campaign: source,
|
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 (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user