overleaf/services/web/frontend/js/main/account-upgrade.js
Timothée Alby c5f883ad83 Merge pull request #5031 from overleaf/ab-paywall-events
Merge paywall-prompt and paywall-click events

GitOrigin-RevId: d567631d08b89565f9a3049f9b88cc2d14a799c1
2021-09-17 08:03:12 +00:00

52 lines
1.2 KiB
JavaScript

import * as eventTracking from '../infrastructure/event-tracking'
function startFreeTrial(source, version, $scope) {
const plan = 'collaborator_free_trial_7_days'
const w = window.open()
const go = function () {
let url
if (typeof ga === 'function') {
ga('send', 'event', 'subscription-funnel', 'upgraded-free-trial', source)
}
eventTracking.sendMB('paywall-click', { 'paywall-type': source })
url = `/user/subscription/new?planCode=${plan}&ssp=true`
url = `${url}&itm_campaign=${source}`
if (version) {
url = `${url}&itm_content=${version}`
}
if ($scope) {
$scope.startedFreeTrial = true
}
w.location = url
}
go()
}
function upgradePlan(source, $scope) {
const w = window.open()
const go = function () {
if (typeof ga === 'function') {
ga('send', 'event', 'subscription-funnel', 'upgraded-plan', source)
}
const url = '/user/subscription'
if ($scope) {
$scope.startedFreeTrial = true
}
w.location = url
}
go()
}
function paywallPrompt(source) {
eventTracking.sendMB('paywall-prompt', { 'paywall-type': source })
}
export { startFreeTrial, upgradePlan, paywallPrompt }