mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 06:33:55 +01:00
* [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
49 lines
1.2 KiB
TypeScript
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()}`
|
|
}
|
|
}
|