mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #16310 from overleaf/jdt-remove-writefull-promo-delay
Remove one day delay on Writefull project list advert GitOrigin-RevId: 43c07ed58d1eddb33655ccfbe2284b764fa766ff
This commit is contained in:
parent
e7dfd14986
commit
948d7638dc
4 changed files with 5 additions and 46 deletions
|
@ -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')
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue