2021-06-10 04:04:21 -04:00
|
|
|
import * as eventTracking from '../infrastructure/event-tracking'
|
|
|
|
|
2023-09-19 09:23:19 -04:00
|
|
|
function startFreeTrial(source, version, $scope, variant) {
|
|
|
|
const eventSegmentation = { 'paywall-type': source }
|
|
|
|
if (variant) {
|
|
|
|
eventSegmentation.variant = variant
|
|
|
|
}
|
|
|
|
|
2022-07-25 08:33:25 -04:00
|
|
|
eventTracking.send('subscription-funnel', 'upgraded-free-trial', source)
|
2023-09-19 09:23:19 -04:00
|
|
|
eventTracking.sendMB('paywall-click', eventSegmentation)
|
2021-06-10 04:04:21 -04:00
|
|
|
|
2022-07-25 08:33:25 -04:00
|
|
|
const searchParams = new URLSearchParams({
|
|
|
|
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-10-11 12:40:00 -04:00
|
|
|
window.open(`/user/subscription/choose-your-plan?${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 }
|