Przeglądaj źródła

Merge pull request #28438 from overleaf/dp-itm-content

Add itm-content param indicating split test variant to compile timeout paywalls

GitOrigin-RevId: 809e13f8e548498d890c055d20d7ce30fd6ead7f
Mathias Jakobsen 1 rok temu
rodzic
commit
d8c7acfe62

+ 22 - 1
services/web/frontend/js/features/ide-redesign/components/pdf-preview/pdf-error-state/compile-timeout-error-state.tsx

@@ -11,7 +11,11 @@ import {
   populateEditorRedesignSegmentation,
   useEditorAnalytics,
 } from '@/shared/hooks/use-editor-analytics'
-import { useIsNewEditorEnabled } from '@/features/ide-redesign/utils/new-editor-utils'
+import {
+  isNewUser,
+  useIsNewEditorEnabled,
+} from '@/features/ide-redesign/utils/new-editor-utils'
+import { getSplitTestVariant } from '@/utils/splitTestUtils'
 
 export const ShortCompileTimeoutErrorState = () => {
   const { t } = useTranslation()
@@ -41,6 +45,22 @@ export const ShortCompileTimeoutErrorState = () => {
     })
   }, [segmentation, sendEvent])
 
+  const extraSearchParams = useMemo(() => {
+    if (!isNewUser()) {
+      return undefined
+    }
+
+    const variant = getSplitTestVariant('editor-redesign-new-users')
+
+    if (!variant) {
+      return undefined
+    }
+
+    return {
+      itm_content: variant,
+    }
+  }, [])
+
   return (
     <ErrorState
       title={t('your_compile_timed_out')}
@@ -100,6 +120,7 @@ export const ShortCompileTimeoutErrorState = () => {
             source="compile-timeout"
             buttonProps={{ variant: 'premium', size: 'sm' }}
             segmentation={segmentation}
+            extraSearchParams={extraSearchParams}
           >
             {t('start_a_free_trial')}
           </StartFreeTrialButton>

+ 1 - 1
services/web/frontend/js/features/ide-redesign/utils/new-editor-utils.ts

@@ -5,7 +5,7 @@ import { isSplitTestEnabled, getSplitTestVariant } from '@/utils/splitTestUtils'
 // TODO: change this when we have a launch date
 const NEW_USER_CUTOFF_DATE = new Date('2100-01-01')
 
-const isNewUser = () => {
+export const isNewUser = () => {
   const user = getMeta('ol-user')
 
   if (!user.signUpDate) return false

+ 22 - 1
services/web/frontend/js/features/pdf-preview/components/timeout-upgrade-prompt-new.tsx

@@ -11,7 +11,11 @@ import {
   populateEditorRedesignSegmentation,
   useEditorAnalytics,
 } from '@/shared/hooks/use-editor-analytics'
-import { useIsNewEditorEnabled } from '@/features/ide-redesign/utils/new-editor-utils'
+import {
+  isNewUser,
+  useIsNewEditorEnabled,
+} from '@/features/ide-redesign/utils/new-editor-utils'
+import { getSplitTestVariant } from '@/utils/splitTestUtils'
 
 function TimeoutUpgradePromptNew() {
   const {
@@ -75,6 +79,22 @@ const CompileTimeout = memo(function CompileTimeout({
 }: CompileTimeoutProps) {
   const { t } = useTranslation()
 
+  const extraSearchParams = useMemo(() => {
+    if (!isNewUser()) {
+      return undefined
+    }
+
+    const variant = getSplitTestVariant('editor-redesign-new-users')
+
+    if (!variant) {
+      return undefined
+    }
+
+    return {
+      itm_content: variant,
+    }
+  }, [])
+
   return (
     <PdfLogEntry
       autoExpand
@@ -110,6 +130,7 @@ const CompileTimeout = memo(function CompileTimeout({
                   source="compile-timeout"
                   buttonProps={{ variant: 'primary', className: 'w-100' }}
                   segmentation={segmentation}
+                  extraSearchParams={extraSearchParams}
                 >
                   {t('start_a_free_trial')}
                 </StartFreeTrialButton>

+ 3 - 1
services/web/frontend/js/main/account-upgrade.ts

@@ -3,7 +3,8 @@ import * as eventTracking from '../infrastructure/event-tracking'
 export function startFreeTrial(
   source: string,
   variant?: string,
-  segmentation?: eventTracking.Segmentation
+  segmentation?: eventTracking.Segmentation,
+  extraSearchParams?: Record<string, string>
 ) {
   const eventSegmentation: Record<string, string> = {
     'paywall-type': source,
@@ -18,6 +19,7 @@ export function startFreeTrial(
 
   const searchParams = new URLSearchParams({
     itm_campaign: source,
+    ...extraSearchParams,
   })
 
   window.open(`/user/subscription/choose-your-plan?${searchParams.toString()}`)

+ 4 - 2
services/web/frontend/js/shared/components/start-free-trial-button.tsx

@@ -11,6 +11,7 @@ type StartFreeTrialButtonProps = {
   children?: React.ReactNode
   handleClick?: React.ComponentProps<typeof OLButton>['onClick']
   segmentation?: eventTracking.Segmentation
+  extraSearchParams?: Record<string, string>
 }
 
 export default function StartFreeTrialButton({
@@ -22,6 +23,7 @@ export default function StartFreeTrialButton({
   source,
   variant,
   segmentation,
+  extraSearchParams,
 }: StartFreeTrialButtonProps) {
   const { t } = useTranslation()
 
@@ -44,9 +46,9 @@ export default function StartFreeTrialButton({
         handleClick(event)
       }
 
-      startFreeTrial(source, variant, segmentation)
+      startFreeTrial(source, variant, segmentation, extraSearchParams)
     },
-    [handleClick, source, variant, segmentation]
+    [handleClick, source, variant, segmentation, extraSearchParams]
   )
 
   return (