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