From 948d7638dc16e49d78152c7fd4a5d8aab8923328 Mon Sep 17 00:00:00 2001 From: Jimmy Domagala-Tang Date: Wed, 20 Dec 2023 09:01:57 -0500 Subject: [PATCH] Merge pull request #16310 from overleaf/jdt-remove-writefull-promo-delay Remove one day delay on Writefull project list advert GitOrigin-RevId: 43c07ed58d1eddb33655ccfbe2284b764fa766ff --- .../notifications/user-notifications.tsx | 17 ++------------ .../writefull-premium-promo-banner.tsx | 6 +---- .../notifications/writefull-promo-banner.tsx | 5 +--- .../components/notifications.test.tsx | 23 +------------------ 4 files changed, 5 insertions(+), 46 deletions(-) diff --git a/services/web/frontend/js/features/project-list/components/notifications/user-notifications.tsx b/services/web/frontend/js/features/project-list/components/notifications/user-notifications.tsx index 09522f38bd..68c60f274d 100644 --- a/services/web/frontend/js/features/project-list/components/notifications/user-notifications.tsx +++ b/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') diff --git a/services/web/frontend/js/features/project-list/components/notifications/writefull-premium-promo-banner.tsx b/services/web/frontend/js/features/project-list/components/notifications/writefull-premium-promo-banner.tsx index d55499d9f7..41cc75a95f 100644 --- a/services/web/frontend/js/features/project-list/components/notifications/writefull-premium-promo-banner.tsx +++ b/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() diff --git a/services/web/frontend/js/features/project-list/components/notifications/writefull-promo-banner.tsx b/services/web/frontend/js/features/project-list/components/notifications/writefull-promo-banner.tsx index fc2560ccd4..6af95607ad 100644 --- a/services/web/frontend/js/features/project-list/components/notifications/writefull-promo-banner.tsx +++ b/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() diff --git a/services/web/test/frontend/features/project-list/components/notifications.test.tsx b/services/web/test/frontend/features/project-list/components/notifications.test.tsx index 157b8a6563..36d9354800 100644 --- a/services/web/test/frontend/features/project-list/components/notifications.test.tsx +++ b/services/web/test/frontend/features/project-list/components/notifications.test.tsx @@ -1027,18 +1027,7 @@ describe('', 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('', 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('', 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)