overleaf/services/web/frontend/js/main/account-upgrade.js
Thomas b39effbb4b Merge pull request #14896 from overleaf/tm-compile-time-warning-would-display
Use standard paywall-types, extend paywall to include variant in segmentation

GitOrigin-RevId: 17a154c525fed3b05a5208a34f374608f045872f
2023-09-20 08:03:32 +00:00

49 lines
1.1 KiB
JavaScript

import * as eventTracking from '../infrastructure/event-tracking'
function startFreeTrial(source, version, $scope, variant) {
const eventSegmentation = { 'paywall-type': source }
if (variant) {
eventSegmentation.variant = variant
}
eventTracking.send('subscription-funnel', 'upgraded-free-trial', source)
eventTracking.sendMB('paywall-click', eventSegmentation)
const searchParams = new URLSearchParams({
itm_campaign: source,
})
if (version) {
searchParams.set('itm_content', version)
}
if ($scope) {
$scope.startedFreeTrial = true
}
window.open(`/user/subscription/choose-your-plan?${searchParams.toString()}`)
}
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 }