Просмотр исходного кода

Merge pull request #16310 from overleaf/jdt-remove-writefull-promo-delay

Remove one day delay on Writefull project list advert

GitOrigin-RevId: 43c07ed58d1eddb33655ccfbe2284b764fa766ff
Jimmy Domagala-Tang 2 лет назад
Родитель
Сommit
948d7638dc

+ 2 - 15
services/web/frontend/js/features/project-list/components/notifications/user-notifications.tsx

@@ -15,7 +15,6 @@ import customLocalStorage from '../../../../infrastructure/local-storage'
 import { sendMB } from '../../../../infrastructure/event-tracking'
 import { isSplitTestEnabled } from '@/utils/splitTestUtils'
 
-const WRITEFULL_PROMO_DELAY_MS = 24 * 60 * 60 * 1000 // 1 day
 const isChromium = () =>
   (window.navigator as any).userAgentData?.brands?.some(
     (item: { brand: string }) => item.brand === 'Chromium'
@@ -62,21 +61,9 @@ function UserNotifications() {
 
     let show = false
     if (writefullIntegrationSplitTestEnabled) {
-      // Show the Writefull promo 1 day after it has been enabled
+      // only show to users who have writefull installed once the integration is live
       const user = getMeta('ol-user')
-      if (user.writefull?.enabled) {
-        const scheduledAt = customLocalStorage.getItem(
-          'writefull_promo_scheduled_at'
-        )
-        if (scheduledAt == null) {
-          customLocalStorage.setItem(
-            'writefull_promo_scheduled_at',
-            new Date(Date.now() + WRITEFULL_PROMO_DELAY_MS).toISOString()
-          )
-        } else if (new Date() >= new Date(scheduledAt)) {
-          show = true
-        }
-      }
+      show = user.writefull?.enabled === true
     } else {
       // Only show the Writefull extension promo on Chrome browsers
       show = isChromium() && getMeta('ol-showWritefullPromoBanner')

+ 1 - 5
services/web/frontend/js/features/project-list/components/notifications/writefull-premium-promo-banner.tsx

@@ -20,11 +20,7 @@ function WritefullPremiumPromoBanner({
   onDismiss: () => void
 }) {
   const handleClose = useCallback(() => {
-    customLocalStorage.setItem(
-      'has_dismissed_writefull_promo_banner',
-      new Date()
-    )
-    customLocalStorage.removeItem('writefull_promo_scheduled_at')
+    customLocalStorage.setItem('has_dismissed_writefull_promo_banner', true)
     setShow(false)
     sendMB('promo-dismiss', eventSegmentation)
     onDismiss()

+ 1 - 4
services/web/frontend/js/features/project-list/components/notifications/writefull-promo-banner.tsx

@@ -23,10 +23,7 @@ function WritefullPromoBanner({
   }, [])
 
   const handleClose = useCallback(() => {
-    customLocalStorage.setItem(
-      'has_dismissed_writefull_promo_banner',
-      new Date()
-    )
+    customLocalStorage.setItem('has_dismissed_writefull_promo_banner', true)
     setShow(false)
     sendMB('promo-dismiss', eventSegmentation)
     onDismiss()

+ 1 - 22
services/web/test/frontend/features/project-list/components/notifications.test.tsx

@@ -1027,18 +1027,7 @@ describe('<UserNotifications />', function () {
             writefull: { enabled: true },
           })
         })
-
-        it('schedules the notification for the next day', function () {
-          renderWithinProjectListProvider(UserNotifications)
-          expect(localStorage.getItem('writefull_promo_scheduled_at')).to.exist
-          expect(screen.queryByRole('link', { name: /Writefull/ })).to.be.null
-        })
-
-        it('shows the banner after it has been scheduled', function () {
-          localStorage.setItem(
-            'writefull_promo_scheduled_at',
-            new Date(Date.now() - 1000)
-          )
+        it('shows the banner', function () {
           renderWithinProjectListProvider(UserNotifications)
           const ctaLink = screen.getByRole('link', {
             name: 'Get Writefull Premium',
@@ -1049,10 +1038,6 @@ describe('<UserNotifications />', function () {
         })
 
         it('dismisses the banner when the close button is clicked', function () {
-          localStorage.setItem(
-            'writefull_promo_scheduled_at',
-            new Date(Date.now() - 1000)
-          )
           renderWithinProjectListProvider(UserNotifications)
           screen.getByRole('link', { name: /Writefull/ })
           const closeButton = screen.getByRole('button', { name: 'Close' })
@@ -1060,15 +1045,9 @@ describe('<UserNotifications />', function () {
           expect(screen.queryByRole('link', { name: /Writefull/ })).to.be.null
           expect(localStorage.getItem('has_dismissed_writefull_promo_banner'))
             .to.exist
-          expect(localStorage.getItem('writefull_promo_scheduled_at')).not.to
-            .exist
         })
 
         it("doesn't show the banner if it has been dismissed", function () {
-          localStorage.setItem(
-            'writefull_promo_scheduled_at',
-            new Date(Date.now() - 1000)
-          )
           localStorage.setItem(
             'has_dismissed_writefull_promo_banner',
             new Date(Date.now() - 500)