mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-05 09:53:18 -05:00
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
|
import { sendMB } from '@/infrastructure/event-tracking'
|
||
|
import { getSplitTestVariant } from '@/utils/splitTestUtils'
|
||
|
import getMeta from '@/utils/meta'
|
||
|
|
||
|
export function sendPlansViewEvent() {
|
||
|
document.addEventListener(
|
||
|
'DOMContentLoaded',
|
||
|
function () {
|
||
|
const currency = getMeta('ol-recommendedCurrency')
|
||
|
const countryCode = getMeta('ol-countryCode')
|
||
|
const geoPricingLATAMTestVariant = getSplitTestVariant(
|
||
|
'geo-pricing-latam-v2'
|
||
|
)
|
||
|
|
||
|
const websiteRedesignPlansTestVariant = getMeta(
|
||
|
'ol-websiteRedesignPlansVariant'
|
||
|
)
|
||
|
|
||
|
const device = window.matchMedia('(max-width: 767px)').matches
|
||
|
? 'mobile'
|
||
|
: 'desktop'
|
||
|
|
||
|
const plansPageViewSegmentation = {
|
||
|
currency,
|
||
|
countryCode,
|
||
|
device,
|
||
|
'geo-pricing-latam-v2': geoPricingLATAMTestVariant,
|
||
|
'website-redesign-plans': websiteRedesignPlansTestVariant,
|
||
|
}
|
||
|
|
||
|
const isPlansPage = window.location.href.includes(
|
||
|
'user/subscription/plans'
|
||
|
)
|
||
|
const isInterstitialPaymentPage = window.location.href.includes(
|
||
|
'user/subscription/choose-your-plan'
|
||
|
)
|
||
|
|
||
|
if (isPlansPage) {
|
||
|
sendMB('plans-page-view', plansPageViewSegmentation)
|
||
|
} else if (isInterstitialPaymentPage) {
|
||
|
sendMB('paywall-plans-page-view', plansPageViewSegmentation)
|
||
|
}
|
||
|
},
|
||
|
{ once: true }
|
||
|
)
|
||
|
}
|