2021-06-10 04:04:21 -04:00
|
|
|
import * as eventTracking from '../infrastructure/event-tracking'
|
|
|
|
|
|
|
|
function startFreeTrial(source, version, $scope) {
|
2021-01-14 10:16:54 -05:00
|
|
|
const plan = 'collaborator_free_trial_7_days'
|
|
|
|
|
|
|
|
const w = window.open()
|
2021-04-14 09:17:21 -04:00
|
|
|
const go = function () {
|
2021-01-14 10:16:54 -05:00
|
|
|
let url
|
|
|
|
if (typeof ga === 'function') {
|
|
|
|
ga('send', 'event', 'subscription-funnel', 'upgraded-free-trial', source)
|
|
|
|
}
|
2021-09-16 04:47:37 -04:00
|
|
|
eventTracking.sendMB('paywall-click', { 'paywall-type': source })
|
2021-06-10 04:04:21 -04:00
|
|
|
|
2021-01-14 10:16:54 -05:00
|
|
|
url = `/user/subscription/new?planCode=${plan}&ssp=true`
|
|
|
|
url = `${url}&itm_campaign=${source}`
|
|
|
|
if (version) {
|
|
|
|
url = `${url}&itm_content=${version}`
|
|
|
|
}
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2021-01-14 10:16:54 -05:00
|
|
|
if ($scope) {
|
2020-05-19 05:02:56 -04:00
|
|
|
$scope.startedFreeTrial = true
|
2021-01-14 10:16:54 -05:00
|
|
|
}
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2021-01-14 10:16:54 -05:00
|
|
|
w.location = url
|
2020-05-19 05:02:56 -04:00
|
|
|
}
|
2020-10-13 05:22:55 -04:00
|
|
|
|
2021-01-14 10:16:54 -05:00
|
|
|
go()
|
|
|
|
}
|
|
|
|
|
|
|
|
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 }
|