Remove Writefull promo banner from projects dashboard (#22568)

GitOrigin-RevId: 49f95f1317462248f4841882ec0ef0ac23c45fe3
This commit is contained in:
Alf Eaton
2024-12-18 10:20:09 +00:00
committed by Copybot
parent 0621984f85
commit 37e065b993
5 changed files with 2 additions and 197 deletions
@@ -370,23 +370,6 @@ async function projectListPage(req, res, next) {
showGroupsAndEnterpriseBanner &&
_.sample(['on-premise', 'FOMO', 'FOMO', 'FOMO'])
let showWritefullPromoBanner = false
if (Features.hasFeature('saas') && !req.session.justRegistered) {
try {
const { variant } = await SplitTestHandler.promises.getAssignment(
req,
res,
'writefull-promo-banner'
)
showWritefullPromoBanner = variant === 'enabled'
} catch (error) {
logger.warn(
{ err: error },
'failed to get "writefull-promo-banner" split test assignment'
)
}
}
let showInrGeoBanner = false
let showBrlGeoBanner = false
let showLATAMBanner = false
@@ -461,7 +444,6 @@ async function projectListPage(req, res, next) {
groupsAndEnterpriseBannerVariant,
showUSGovBanner,
usGovBannerVariant,
showWritefullPromoBanner,
showLATAMBanner,
recommendedCurrency,
showInrGeoBanner,
@@ -29,7 +29,6 @@ block append meta
}))
meta(name="ol-currentUrl" data-type="string" content=currentUrl)
meta(name="ol-showGroupsAndEnterpriseBanner" data-type="boolean" content=showGroupsAndEnterpriseBanner)
meta(name="ol-showWritefullPromoBanner" data-type="boolean" content=showWritefullPromoBanner)
meta(name="ol-groupsAndEnterpriseBannerVariant" data-type="string" content=groupsAndEnterpriseBannerVariant)
meta(name="ol-showInrGeoBanner" data-type="boolean" content=showInrGeoBanner)
meta(name="ol-showBrlGeoBanner" data-type="boolean" content=showBrlGeoBanner)
@@ -1,15 +1,12 @@
import { JSXElementConstructor, useState } from 'react'
import { JSXElementConstructor } from 'react'
import Common from './groups/common'
import Institution from './groups/institution'
import ConfirmEmail from './groups/confirm-email'
import ReconfirmationInfo from './groups/affiliation/reconfirmation-info'
import GroupsAndEnterpriseBanner from './groups-and-enterprise-banner'
import WritefullPremiumPromoBanner from './writefull-premium-promo-banner'
import GroupSsoSetupSuccess from './groups/group-sso-setup-success'
import getMeta from '../../../../utils/meta'
import importOverleafModules from '../../../../../macros/import-overleaf-module.macro'
import customLocalStorage from '../../../../infrastructure/local-storage'
import { sendMB } from '../../../../infrastructure/event-tracking'
import GeoBanners from './geo-banners'
import AccessibilitySurveyBanner from './accessibility-survey-banner'
@@ -30,32 +27,6 @@ const USGovBanner: JSXElementConstructor<Record<string, never>> =
function UserNotifications() {
const groupSubscriptionsPendingEnrollment =
getMeta('ol-groupSubscriptionsPendingEnrollment') || []
const user = getMeta('ol-user')
// Temporary workaround to prevent also showing groups/enterprise banner
const [showWritefull, setShowWritefull] = useState(() => {
const dismissed = customLocalStorage.getItem(
'has_dismissed_writefull_promo_banner'
)
if (dismissed) {
return false
}
const show =
user?.writefull?.enabled === true ||
window.writefull?.type === 'extension'
if (show) {
sendMB('promo-prompt', {
location: 'dashboard-banner',
page: '/project',
name: 'writefull-premium',
})
}
return show
})
const [dismissedWritefull, setDismissedWritefull] = useState(false)
return (
<div className="user-notifications notification-list">
@@ -74,18 +45,10 @@ function UserNotifications() {
<ConfirmEmail />
<ReconfirmationInfo />
<GeoBanners />
{!showWritefull && !dismissedWritefull && <GroupsAndEnterpriseBanner />}
<GroupsAndEnterpriseBanner />
{USGovBanner && <USGovBanner />}
<AccessibilitySurveyBanner />
<WritefullPremiumPromoBanner
show={showWritefull}
setShow={setShowWritefull}
onDismiss={() => {
setDismissedWritefull(true)
}}
/>
</ul>
</div>
)
@@ -1,71 +0,0 @@
import { memo, useCallback } from 'react'
import Notification from './notification'
import { sendMB } from '@/infrastructure/event-tracking'
import customLocalStorage from '@/infrastructure/local-storage'
import WritefullLogo from '@/shared/svgs/writefull-logo'
import OLButton from '@/features/ui/components/ol/ol-button'
import getMeta from '@/utils/meta'
const eventSegmentation = {
location: 'dashboard-banner',
page: '/project',
name: 'writefull-premium',
}
function WritefullPremiumPromoBanner({
show,
setShow,
onDismiss,
}: {
show: boolean
setShow: (value: boolean) => void
onDismiss: () => void
}) {
// dont show the add to WF commons users since their license already includes it
const userAffiliations = getMeta('ol-userAffiliations') || []
const hasWritefullCommons = userAffiliations.some(
affil => affil.institution?.writefullCommonsAccount
)
const handleClose = useCallback(() => {
customLocalStorage.setItem('has_dismissed_writefull_promo_banner', true)
setShow(false)
sendMB('promo-dismiss', eventSegmentation)
onDismiss()
}, [setShow, onDismiss])
if (!show || hasWritefullCommons) {
return null
}
return (
<div data-testid="writefull-premium-promo-banner">
<Notification
type="info"
onDismiss={handleClose}
content={
<>
Enjoying Writefull? Get <strong>10% off Writefull Premium</strong>,
giving you access to TeXGPTAI assistance to generate LaTeX code.
Use <strong>OVERLEAF10</strong> at the checkout.
</>
}
action={
<OLButton
variant="secondary"
href="https://my.writefull.com/overleaf-invite?code=OVERLEAF10&redirect=plans"
target="_blank"
rel="noreferrer"
onClick={() => {
sendMB('promo-click', eventSegmentation)
}}
>
<WritefullLogo width="16" height="16" />{' '}
<span>Get Writefull Premium</span>
</OLButton>
}
/>
</div>
)
}
export default memo(WritefullPremiumPromoBanner)
@@ -26,7 +26,6 @@ import Common from '../../../../../frontend/js/features/project-list/components/
import Institution from '../../../../../frontend/js/features/project-list/components/notifications/groups/institution'
import ConfirmEmail from '../../../../../frontend/js/features/project-list/components/notifications/groups/confirm-email'
import ReconfirmationInfo from '../../../../../frontend/js/features/project-list/components/notifications/groups/affiliation/reconfirmation-info'
import UserNotifications from '../../../../../frontend/js/features/project-list/components/notifications/user-notifications'
import { ProjectListProvider } from '../../../../../frontend/js/features/project-list/context/project-list-context'
import { SplitTestProvider } from '@/shared/context/split-test-context'
import {
@@ -932,73 +931,6 @@ describe('<UserNotifications />', function () {
})
})
describe('<WritefullPromoBanner>', function () {
beforeEach(function () {
Object.assign(getMeta('ol-ExposedSettings'), exposedSettings)
window.metaAttributesCache.set('ol-showWritefullPromoBanner', true)
// The older banner is only shown to Chrome users
const navigator = window.navigator as any
navigator.userAgentData = { brands: [{ brand: 'Chromium' }] }
localStorage.clear()
})
describe('when the writefull integration is enabled', function () {
beforeEach(function () {
window.metaAttributesCache.set('ol-user', {
writefull: { enabled: true },
})
})
it('shows the banner', function () {
renderWithinProjectListProvider(UserNotifications)
const ctaLink = screen.getByRole('button', {
name: 'Get Writefull Premium',
})
expect(ctaLink.getAttribute('href')).to.equal(
'https://my.writefull.com/overleaf-invite?code=OVERLEAF10&redirect=plans'
)
})
it('dismisses the banner when the close button is clicked', function () {
renderWithinProjectListProvider(UserNotifications)
screen.getByRole('button', { name: /Writefull/ })
const WritefullPromoBanner = screen.getByTestId(
'writefull-premium-promo-banner'
)
const closeButton = within(WritefullPromoBanner).getByRole('button', {
name: 'Close',
})
fireEvent.click(closeButton)
expect(screen.queryByRole('link', { name: /Writefull/ })).to.be.null
expect(localStorage.getItem('has_dismissed_writefull_promo_banner')).to
.exist
})
it("doesn't show the banner if it has been dismissed", function () {
localStorage.setItem(
'has_dismissed_writefull_promo_banner',
new Date(Date.now() - 500)
)
renderWithinProjectListProvider(UserNotifications)
expect(screen.queryByRole('link', { name: /Writefull/ })).to.be.null
})
})
describe('when the writefull integration is not enabled', function () {
beforeEach(function () {
window.metaAttributesCache.set('ol-user', {
writefull: { enabled: false },
})
})
it("doesn't show the banner", function () {
renderWithinProjectListProvider(UserNotifications)
expect(screen.queryByRole('link', { name: /Writefull/ })).to.be.null
})
})
})
describe('GroupSsoSetupSuccess', function () {
it('shows group SSO linked notification', function () {
window.metaAttributesCache.set('ol-groupSsoSetupSuccess', true)