Files
overleaf-cep/services/web/frontend/js/main/account-upgrade.ts
T
32664a1d12 [web] Update Share modal paywall CTAs to point to the plans interstitial (#34410)
* [web] Send paywall upgrade CTAs to the plans interstitial

* fix: encode upgradePlan campaign source with URLSearchParams

Co-authored-by: lzear <8427791+lzear@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
GitOrigin-RevId: ddde4d77d72e649f5ded5839a2a2155e5f679f53
2026-06-15 08:07:04 +00:00

49 lines
1.2 KiB
TypeScript

import * as eventTracking from '../infrastructure/event-tracking'
export function startFreeTrial(
source: string,
variant?: string,
segmentation?: eventTracking.Segmentation,
extraSearchParams?: Record<string, string>,
shouldNavigate: boolean = true
) {
const eventSegmentation: Record<string, string> = {
'paywall-type': source,
...segmentation,
}
if (variant) {
eventSegmentation.variant = variant
}
eventTracking.send('subscription-funnel', 'upgraded-free-trial', source)
eventTracking.sendMB('paywall-click', eventSegmentation)
if (shouldNavigate) {
const searchParams = new URLSearchParams({
itm_campaign: source,
'paywall-type': source,
...extraSearchParams,
})
window.open(
`/user/subscription/choose-your-plan?${searchParams.toString()}`
)
}
}
export function upgradePlan(source: string) {
const openedWindow = window.open()
if (typeof window.ga === 'function') {
window.ga('send', 'event', 'subscription-funnel', 'upgraded-plan', source)
}
if (openedWindow) {
const searchParams = new URLSearchParams({
itm_campaign: source,
})
openedWindow.location = `/user/subscription/choose-your-plan?${searchParams.toString()}`
}
}