2021-06-10 04:04:21 -04:00
|
|
|
import * as eventTracking from '../infrastructure/event-tracking'
|
2022-06-28 09:36:13 -04:00
|
|
|
import getMeta from '../utils/meta'
|
|
|
|
|
|
|
|
const interstitialPaymentAfterPaywallVariant =
|
|
|
|
getMeta('ol-splitTestVariants')?.['interstitial-payment-from-paywall'] ??
|
|
|
|
'default'
|
2021-06-10 04:04:21 -04:00
|
|
|
|
|
|
|
function startFreeTrial(source, version, $scope) {
|
2021-01-14 10:16:54 -05:00
|
|
|
const plan = 'collaborator_free_trial_7_days'
|
|
|
|
|
2022-07-25 08:33:25 -04:00
|
|
|
eventTracking.send('subscription-funnel', 'upgraded-free-trial', source)
|
|
|
|
eventTracking.sendMB('paywall-click', { 'paywall-type': source })
|
2021-06-10 04:04:21 -04:00
|
|
|
|
2022-07-25 08:33:25 -04:00
|
|
|
const searchParams = new URLSearchParams({
|
|
|
|
planCode: 'collaborator_free_trial_7_days',
|
|
|
|
ssp: 'true',
|
|
|
|
itm_campaign: source,
|
|
|
|
})
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2022-07-25 08:33:25 -04:00
|
|
|
if (version) {
|
|
|
|
searchParams.set('itm_content', version)
|
|
|
|
}
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2022-07-25 08:33:25 -04:00
|
|
|
if ($scope) {
|
|
|
|
$scope.startedFreeTrial = true
|
2020-05-19 05:02:56 -04:00
|
|
|
}
|
2020-10-13 05:22:55 -04:00
|
|
|
|
2022-07-25 08:33:25 -04:00
|
|
|
if (interstitialPaymentAfterPaywallVariant === 'active') {
|
|
|
|
window.open(
|
|
|
|
`/user/subscription/choose-your-plan?${searchParams.toString()}`
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
searchParams.set('ssp', 'true')
|
|
|
|
searchParams.set('planCode', plan)
|
|
|
|
window.open(`/user/subscription/new?${searchParams.toString()}`)
|
|
|
|
}
|
2021-01-14 10:16:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function upgradePlan(source, $scope) {
|
|
|
|
const w = window.open()
|
2021-04-14 09:17:21 -04:00
|
|
|
const go = function () {
|
2021-01-14 10:16:54 -05:00
|
|
|
if (typeof ga === 'function') {
|
|
|
|
ga('send', 'event', 'subscription-funnel', 'upgraded-plan', source)
|
2020-10-13 05:22:55 -04:00
|
|
|
}
|
2021-05-05 09:05:04 -04:00
|
|
|
const url = '/user/subscription'
|
2020-10-13 05:22:55 -04:00
|
|
|
|
2021-01-14 10:16:54 -05:00
|
|
|
if ($scope) {
|
|
|
|
$scope.startedFreeTrial = true
|
|
|
|
}
|
|
|
|
|
|
|
|
w.location = url
|
2020-10-13 05:22:55 -04:00
|
|
|
}
|
2021-01-14 10:16:54 -05:00
|
|
|
|
|
|
|
go()
|
|
|
|
}
|
|
|
|
|
2021-06-10 04:04:21 -04:00
|
|
|
function paywallPrompt(source) {
|
2021-09-16 04:47:37 -04:00
|
|
|
eventTracking.sendMB('paywall-prompt', { 'paywall-type': source })
|
2021-06-10 04:04:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export { startFreeTrial, upgradePlan, paywallPrompt }
|