From e954afa1c206ec273d55848005fa0c382467bcec Mon Sep 17 00:00:00 2001 From: roo hutton Date: Mon, 17 Feb 2025 10:48:10 +0000 Subject: [PATCH] Merge pull request #23618 from overleaf/rh-compile-timeout-paywall-event-tracking Add events to compile timeout paywall GitOrigin-RevId: 2982e1a8c6494bafbc3137a25f5e9eb08182812b --- ...imeout-message-after-paywall-dismissal.tsx | 18 ++++++++- .../timeout-upgrade-paywall-prompt.tsx | 37 ++++++++++++++++++- .../js/shared/components/upgrade-prompt.tsx | 14 ++++++- 3 files changed, 64 insertions(+), 5 deletions(-) diff --git a/services/web/frontend/js/features/pdf-preview/components/timeout-message-after-paywall-dismissal.tsx b/services/web/frontend/js/features/pdf-preview/components/timeout-message-after-paywall-dismissal.tsx index 281e8c55f7..18390820ef 100644 --- a/services/web/frontend/js/features/pdf-preview/components/timeout-message-after-paywall-dismissal.tsx +++ b/services/web/frontend/js/features/pdf-preview/components/timeout-message-after-paywall-dismissal.tsx @@ -1,11 +1,12 @@ import getMeta from '@/utils/meta' import { Trans, useTranslation } from 'react-i18next' -import { memo, useCallback } from 'react' +import { memo, useCallback, useEffect } from 'react' import { useDetachCompileContext } from '@/shared/context/detach-compile-context' import StartFreeTrialButton from '@/shared/components/start-free-trial-button' import { useFeatureFlag } from '@/shared/context/split-test-context' import MaterialIcon from '@/shared/components/material-icon' import { useStopOnFirstError } from '@/shared/hooks/use-stop-on-first-error' +import * as eventTracking from '@/infrastructure/event-tracking' import PdfLogEntry from './pdf-log-entry' function TimeoutMessageAfterPaywallDismissal() { @@ -51,6 +52,20 @@ const CompileTimeout = memo(function CompileTimeout({ const hasNewPaywallCta = useFeatureFlag('paywall-cta') + useEffect(() => { + eventTracking.sendMB('paywall-prompt', { + 'paywall-type': 'compile-timeout', + 'paywall-version': 'secondary', + }) + }, []) + + function onPaywallClick() { + eventTracking.sendMB('paywall-click', { + 'paywall-type': 'compile-timeout', + 'paywall-version': 'secondary', + }) + } + return ( {hasNewPaywallCta ? t('get_more_compile_time') diff --git a/services/web/frontend/js/features/pdf-preview/components/timeout-upgrade-paywall-prompt.tsx b/services/web/frontend/js/features/pdf-preview/components/timeout-upgrade-paywall-prompt.tsx index 33b456c3d6..2104347144 100644 --- a/services/web/frontend/js/features/pdf-preview/components/timeout-upgrade-paywall-prompt.tsx +++ b/services/web/frontend/js/features/pdf-preview/components/timeout-upgrade-paywall-prompt.tsx @@ -1,5 +1,6 @@ +import { useEffect, useMemo, useState } from 'react' import getMeta from '@/utils/meta' -import { useMemo, useState } from 'react' +import * as eventTracking from '@/infrastructure/event-tracking' import TimeoutMessageAfterPaywallDismissal from './timeout-message-after-paywall-dismissal' import { UpgradePrompt } from '@/shared/components/upgrade-prompt' @@ -10,6 +11,11 @@ const studentRoles = [ 'Doctoral student (e.g. PhD, MD, EngD)', ] +type Segmentation = Record< + string, + string | number | boolean | undefined | unknown | any +> + function TimeoutUpgradePaywallPrompt() { const odcRole = getMeta('ol-odcRole') const planPrices = getMeta('ol-paywallPlans') @@ -17,10 +23,35 @@ function TimeoutUpgradePaywallPrompt() { const [isPaywallDismissed, setIsPaywallDismissed] = useState(false) + function sendPaywallEvent(event: string, segmentation?: Segmentation) { + eventTracking.sendMB(event, { + 'paywall-type': 'compile-timeout', + 'paywall-version': 'primary', + ...segmentation, + }) + } + function onClose() { + sendPaywallEvent('paywall-dismiss') setIsPaywallDismissed(true) } + function onClickInfoLink() { + sendPaywallEvent('paywall-info-click', { content: 'plans' }) + } + + function onClickPaywall() { + sendPaywallEvent('paywall-click', { + plan: isStudent ? 'student' : 'collaborator', + }) + } + + useEffect(() => { + sendPaywallEvent('paywall-prompt', { + plan: isStudent ? 'student' : 'collaborator', + }) + }, [isStudent]) + return (
{!isPaywallDismissed ? ( @@ -32,8 +63,10 @@ function TimeoutUpgradePaywallPrompt() { student: planPrices?.student, standard: planPrices?.collaborator, }} - itmCampaign="storybook" + itmCampaign="compile-timeout" isStudent={isStudent} + onClickInfoLink={onClickInfoLink} + onClickPaywall={onClickPaywall} /> ) : ( diff --git a/services/web/frontend/js/shared/components/upgrade-prompt.tsx b/services/web/frontend/js/shared/components/upgrade-prompt.tsx index 7eba68a478..1d6bd1e447 100644 --- a/services/web/frontend/js/shared/components/upgrade-prompt.tsx +++ b/services/web/frontend/js/shared/components/upgrade-prompt.tsx @@ -25,17 +25,20 @@ function IconListItem({ icon, children }: IconListItemProps) { type PlansLinkProps = { itmCampaign: string + onClick?: React.MouseEventHandler } function PlansLink({ children, itmCampaign, + onClick, }: PropsWithChildren) { return ( {children} @@ -50,6 +53,8 @@ type UpgradePromptProps = { planPricing: { student: string; standard: string } itmCampaign: string isStudent?: boolean + onClickInfoLink?: React.MouseEventHandler + onClickPaywall?: React.MouseEventHandler } export function UpgradePrompt({ @@ -59,6 +64,8 @@ export function UpgradePrompt({ planPricing, itmCampaign, isStudent = false, + onClickInfoLink, + onClickPaywall, }: UpgradePromptProps) { const { t } = useTranslation() const planPrice = isStudent ? planPricing.student : planPricing.standard @@ -111,6 +118,7 @@ export function UpgradePrompt({ {t('try_for_free')} @@ -155,7 +163,9 @@ export function UpgradePrompt({ {/* eslint-disable react/jsx-key */} ]} + components={[ + , + ]} /> {/* eslint-disable react/jsx-key */}