Merge pull request #17369 from overleaf/jdt-rm-old-wf-prj-list-ad

removing old writefull ad from project list and removing uneeded spli…

GitOrigin-RevId: 84722949c4972ba0b7c8e0bf6d2884608e26a613
This commit is contained in:
Jimmy Domagala-Tang 2024-03-12 08:45:46 -04:00 committed by Copybot
parent ce19b5f568
commit 5701a1cccd
4 changed files with 23 additions and 191 deletions

View file

@ -357,12 +357,6 @@ async function projectListPage(req, res, next) {
}
}
await SplitTestHandler.promises.getAssignment(
req,
res,
'writefull-oauth-promotion'
)
let showInrGeoBanner = false
let showBrlGeoBanner = false
let recommendedCurrency

View file

@ -4,7 +4,6 @@ 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 WritefullPromoBanner from './writefull-promo-banner'
import WritefullPremiumPromoBanner from './writefull-premium-promo-banner'
import GroupSsoSetupSuccess from './groups/group-sso-setup-success'
import INRBanner from './ads/inr-banner'
@ -13,14 +12,8 @@ import importOverleafModules from '../../../../../macros/import-overleaf-module.
import customLocalStorage from '../../../../infrastructure/local-storage'
import { sendMB } from '../../../../infrastructure/event-tracking'
import classNames from 'classnames'
import { isSplitTestEnabled } from '@/utils/splitTestUtils'
import BRLBanner from './ads/brl-banner'
const isChromium = () =>
(window.navigator as any).userAgentData?.brands?.some(
(item: { brand: string }) => item.brand === 'Chromium'
)
type Subscription = {
groupId: string
groupName: string
@ -45,9 +38,6 @@ function UserNotifications() {
)
const showInrGeoBanner = getMeta('ol-showInrGeoBanner', false)
const showBrlGeoBanner = getMeta('ol-showBrlGeoBanner', false)
const writefullOauthPromotionSplitTestEnabled = isSplitTestEnabled(
'writefull-oauth-promotion'
)
const user = getMeta('ol-user')
// Temporary workaround to prevent also showing groups/enterprise banner
@ -60,20 +50,14 @@ function UserNotifications() {
}
const show =
user?.writefull?.enabled === true || // show to any users who have writefull enabled regardless of split test
(!writefullOauthPromotionSplitTestEnabled && // show old banner to users who are not in the split test, who are on chrome and havent dismissed
isChromium() &&
getMeta('ol-showWritefullPromoBanner'))
user?.writefull?.enabled === true ||
window.writefull?.type === 'extension'
if (show) {
sendMB('promo-prompt', {
location: 'dashboard-banner',
page: '/project',
name:
user?.writefull?.enabled === true ||
writefullOauthPromotionSplitTestEnabled
? 'writefull-premium'
: 'writefull',
name: 'writefull-premium',
})
}
@ -81,15 +65,6 @@ function UserNotifications() {
})
const [dismissedWritefull, setDismissedWritefull] = useState(false)
const hasWritefullExtensionAlreadyInstalled =
window.writefull?.type === 'extension'
const usesWritefullIntegration =
writefullOauthPromotionSplitTestEnabled || user?.writefull?.enabled
const writefullBannerVariant =
hasWritefullExtensionAlreadyInstalled || usesWritefullIntegration
? 'plans-page'
: 'chrome-store'
return (
<div
className={classNames('user-notifications', {
@ -112,24 +87,15 @@ function UserNotifications() {
<ReconfirmationInfo />
{!showWritefull && !dismissedWritefull && <GroupsAndEnterpriseBanner />}
{showInrGeoBanner && <INRBanner />}
<WritefullPremiumPromoBanner
show={showWritefull}
setShow={setShowWritefull}
onDismiss={() => {
setDismissedWritefull(true)
}}
/>
{showBrlGeoBanner && <BRLBanner />}
{writefullBannerVariant === 'plans-page' ? (
<WritefullPremiumPromoBanner
show={showWritefull}
setShow={setShowWritefull}
onDismiss={() => {
setDismissedWritefull(true)
}}
/>
) : (
<WritefullPromoBanner
show={showWritefull}
setShow={setShowWritefull}
onDismiss={() => {
setDismissedWritefull(true)
}}
/>
)}
</ul>
</div>
)

View file

@ -1,80 +0,0 @@
import { memo, useCallback } from 'react'
import Notification from './notification'
import { sendMB } from '../../../../infrastructure/event-tracking'
import customLocalStorage from '../../../../infrastructure/local-storage'
import getMeta from '@/utils/meta'
const eventSegmentation = {
location: 'dashboard-banner',
page: '/project',
name: 'writefull',
}
function WritefullPromoBanner({
show,
setShow,
onDismiss,
}: {
show: boolean
setShow: (value: boolean) => void
onDismiss: () => void
}) {
const newNotificationStyle = getMeta(
'ol-newNotificationStyle',
false
) as boolean
const handleOpenLink = useCallback(() => {
sendMB('promo-click', eventSegmentation)
}, [])
const handleClose = useCallback(() => {
customLocalStorage.setItem('has_dismissed_writefull_promo_banner', true)
setShow(false)
sendMB('promo-dismiss', eventSegmentation)
onDismiss()
}, [setShow, onDismiss])
if (!show) {
return null
}
return (
<Notification
bsStyle="info"
onDismiss={handleClose}
className="centered-alert"
body={
<span>
Get <b>10% off</b> Writefull premiumAI-based language feedback and
TeXGPT to help you write great papers faster. Use code:{' '}
<b>OVERLEAF10</b>
</span>
}
action={
<a
className={
newNotificationStyle
? 'btn btn-secondary btn-sm'
: 'pull-right btn btn-info btn-sm'
}
href="https://my.writefull.com/overleaf-invite?code=OVERLEAF10"
target="_blank"
rel="noreferrer"
onClick={handleOpenLink}
>
<img
alt="Writefull Logo"
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAIRlWElmTU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAIdpAAQAAAABAAAAWgAAAAAAAABIAAAAAQAAAEgAAAABAAOgAQADAAAAAQABAACgAgAEAAAAAQAAACCgAwAEAAAAAQAAACAAAAAAX7wP8AAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDYuMC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpP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YtMOHlf2E3e2/nBLV+Mj39i0Unj0qkmy3DBVicJy1asyCXrSMI9dfhkNMHbnakiB8bkDVlxS6JcCDppz482R7qX3jiytoCimUsxo0OMTrJ6LOoQIOYylkWPCWMRWoklLQBTLc60IHAkm/nKlICYbhamCtzyL7aL6TS49koE22JQ5IpA7QbM2aeAZXD4gfBBt1rATKyk9DHQ8UCAkTDoXpCLnbMgGlNQ0M8DzowahdyfQvgeGpMXGOQdQE0Gi7w0VIacLh8krNgKMGOt1CfnKORmynhS4OP0kxejIkFbzYQCd6YIfJjEOWBaTEOmU0QIdOocsBkipojXxqAmCdFuRoi3gW4vJmyZZ2ELw07AepRiF+OmwbSIyTSRn+CYJ3CVGjJC8rKTBMk9rd6YPgMsnQHOa3d8lkBXl0Ji8TYDTFql4PSQCEHVVPlD2eHZzXGDa82XvczF8zHjtMFYgipFNhWZoBv2tagw8hfAvjZew2CWAIwFMRU8rXLMNORl5M/JN6njW82RiJfDYT++usNODz/kFO48GW1COgVR1nAlA2numwYaGkVNmNpUwGz2NioTUPc0PUis1ld/gyJsgiJOQpMt41lamYwron2HZXpZ/XPrwU8fTq5JXWfPwUx044VHvVzkUKxJJ31KGlR7IMG9hA0mRzvDYdGT8a2Dv2AKNNZNCKVWJiDHIQnW2nMMmL0Wst4ALIpHyBPXNNTsmKV5eXuP1f7xNqkvb0SCUz6szosvuXlzdyyqa7pOIIh+MsEiOW6fSC659z57+8hRBZ4KyEn7ug0HD8iVq4YT+9/CGx+gM7LD4WO7n5ZC7AUdK141RIJe0MHBxI+3PZX/dpmDXy7H7KFV+wIvZHNgQ9lnKFvwL99u0rFU4pfe2+ydfSN4ZtO1W88QB4MXVO7oyo58790vhHohuXB8S38cSJUzt7JfzwkOqPtBTQ+k6ASjna2n27BcPrNlRBo1kHnxr1bdKNB/Qu9vAayGEgUZb7kAAAAASUVORK5CYII="
height={16}
width={16}
style={{ marginRight: 4 }}
aria-hidden="true"
/>
<span>Get Writefull for Overleaf</span>
</a>
}
/>
)
}
export default memo(WritefullPromoBanner)

View file

@ -977,23 +977,19 @@ describe('<UserNotifications />', function () {
window.metaAttributesCache = window.metaAttributesCache || new Map()
})
describe('when writefull-oauth-promotion split test is not enabled', function () {
describe('when the writefull integration is enabled', function () {
beforeEach(function () {
window.metaAttributesCache.set('ol-splitTestVariants', {
'writefull-oauth-promotion': 'default',
})
window.metaAttributesCache.set('ol-user', {
writefull: { enabled: false },
writefull: { enabled: true },
})
})
it('shows the older banner', function () {
it('shows the banner', function () {
renderWithinProjectListProvider(UserNotifications)
const ctaLink = screen.getByRole('link', {
name: 'Get Writefull for Overleaf',
name: 'Get Writefull Premium',
})
expect(ctaLink.getAttribute('href')).to.equal(
'https://my.writefull.com/overleaf-invite?code=OVERLEAF10'
'https://my.writefull.com/overleaf-invite?code=OVERLEAF10&redirect=plans'
)
})
@ -1010,67 +1006,23 @@ describe('<UserNotifications />', function () {
it("doesn't show the banner if it has been dismissed", function () {
localStorage.setItem(
'has_dismissed_writefull_promo_banner',
new Date(Date.now() - 1000)
new Date(Date.now() - 500)
)
renderWithinProjectListProvider(UserNotifications)
expect(screen.queryByRole('link', { name: /Writefull/ })).to.be.null
})
})
describe('when writefull-oauth-promotion split test is enabled', function () {
describe('when the writefull integration is not enabled', function () {
beforeEach(function () {
window.metaAttributesCache.set('ol-splitTestVariants', {
'writefull-oauth-promotion': 'enabled',
window.metaAttributesCache.set('ol-user', {
writefull: { enabled: false },
})
})
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('link', {
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('link', { name: /Writefull/ })
const closeButton = screen.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
})
it("doesn't show the banner", function () {
renderWithinProjectListProvider(UserNotifications)
expect(screen.queryByRole('link', { name: /Writefull/ })).to.be.null
})
})
})