mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
tearing down split test (#17000)
GitOrigin-RevId: cdcca8635a81c697e9f91f31fb711ee420cc6f7d
This commit is contained in:
parent
f2bea32dd8
commit
c1f8647339
7 changed files with 14 additions and 179 deletions
|
@ -365,28 +365,14 @@ async function projectListPage(req, res, next) {
|
|||
|
||||
let showInrGeoBanner, inrGeoBannerSplitTestName
|
||||
let inrGeoBannerVariant = 'default'
|
||||
let showLATAMBanner = false
|
||||
let recommendedCurrency
|
||||
if (usersBestSubscription?.type === 'free') {
|
||||
const { currencyCode, countryCode } =
|
||||
await GeoIpLookup.promises.getCurrencyCode(req.ip)
|
||||
const { countryCode } = await GeoIpLookup.promises.getCurrencyCode(req.ip)
|
||||
// Split test is kept active, but all users geolocated in India can
|
||||
// now use the INR currency (See #13507)
|
||||
const { variant: inrGeoPricingVariant } =
|
||||
await SplitTestHandler.promises.getAssignment(req, res, 'geo-pricing-inr')
|
||||
const latamGeoPricingAssignment =
|
||||
await SplitTestHandler.promises.getAssignment(
|
||||
req,
|
||||
res,
|
||||
'geo-pricing-latam'
|
||||
)
|
||||
showLATAMBanner =
|
||||
latamGeoPricingAssignment.variant === 'latam' &&
|
||||
['BR', 'MX', 'CO', 'CL', 'PE'].includes(countryCode)
|
||||
// LATAM Banner needs to know which currency to display
|
||||
if (showLATAMBanner) {
|
||||
recommendedCurrency = currencyCode
|
||||
}
|
||||
|
||||
if (countryCode === 'IN') {
|
||||
inrGeoBannerSplitTestName =
|
||||
inrGeoPricingVariant === 'inr'
|
||||
|
@ -449,7 +435,6 @@ async function projectListPage(req, res, next) {
|
|||
showGroupsAndEnterpriseBanner,
|
||||
groupsAndEnterpriseBannerVariant,
|
||||
showWritefullPromoBanner,
|
||||
showLATAMBanner,
|
||||
recommendedCurrency,
|
||||
showInrGeoBanner,
|
||||
inrGeoBannerVariant,
|
||||
|
|
|
@ -38,12 +38,8 @@ async function plansPage(req, res) {
|
|||
if (GeoIpLookup.isValidCurrencyParam(queryCurrency)) {
|
||||
currency = queryCurrency
|
||||
}
|
||||
const {
|
||||
recommendedCurrency,
|
||||
countryCode,
|
||||
geoPricingINRTestVariant,
|
||||
geoPricingLATAMTestVariant,
|
||||
} = await _getRecommendedCurrency(req, res)
|
||||
const { recommendedCurrency, countryCode, geoPricingINRTestVariant } =
|
||||
await _getRecommendedCurrency(req, res)
|
||||
if (recommendedCurrency && currency == null) {
|
||||
currency = recommendedCurrency
|
||||
}
|
||||
|
@ -102,12 +98,6 @@ async function plansPage(req, res) {
|
|||
countryCode,
|
||||
'geo-pricing-inr-group': geoPricingINRTestVariant,
|
||||
'geo-pricing-inr-page': currency === 'INR' ? 'inr' : 'default',
|
||||
'geo-pricing-latam-group': geoPricingLATAMTestVariant,
|
||||
'geo-pricing-latam-page': ['BRL', 'MXN', 'COP', 'CLP', 'PEN'].includes(
|
||||
currency
|
||||
)
|
||||
? 'latam'
|
||||
: 'default',
|
||||
'annual-trials': annualTrialsAssignment.variant,
|
||||
'website-redesign': websiteRedesignVariant,
|
||||
}
|
||||
|
@ -247,12 +237,8 @@ async function userSubscriptionPage(req, res) {
|
|||
|
||||
async function interstitialPaymentPage(req, res) {
|
||||
const user = SessionManager.getSessionUser(req.session)
|
||||
const {
|
||||
recommendedCurrency,
|
||||
countryCode,
|
||||
geoPricingINRTestVariant,
|
||||
geoPricingLATAMTestVariant,
|
||||
} = await _getRecommendedCurrency(req, res)
|
||||
const { recommendedCurrency, countryCode, geoPricingINRTestVariant } =
|
||||
await _getRecommendedCurrency(req, res)
|
||||
|
||||
const hasSubscription =
|
||||
await LimitationsManager.promises.userHasV1OrV2Subscription(user)
|
||||
|
@ -289,12 +275,6 @@ async function interstitialPaymentPage(req, res) {
|
|||
countryCode,
|
||||
'geo-pricing-inr-group': geoPricingINRTestVariant,
|
||||
'geo-pricing-inr-page': recommendedCurrency === 'INR' ? 'inr' : 'default',
|
||||
'geo-pricing-latam-group': geoPricingLATAMTestVariant,
|
||||
'geo-pricing-latam-page': ['BRL', 'MXN', 'COP', 'CLP', 'PEN'].includes(
|
||||
recommendedCurrency
|
||||
)
|
||||
? 'latam'
|
||||
: 'default',
|
||||
'annual-trials': annualTrialsAssignment.variant,
|
||||
}
|
||||
if (inrGeoBannerSplitTestName) {
|
||||
|
@ -653,23 +633,15 @@ async function _getRecommendedCurrency(req, res) {
|
|||
res,
|
||||
'geo-pricing-inr'
|
||||
)
|
||||
// for #13559
|
||||
const assignmentLATAM = await SplitTestHandler.promises.getAssignment(
|
||||
req,
|
||||
res,
|
||||
'geo-pricing-latam'
|
||||
)
|
||||
if (
|
||||
['BRL', 'MXN', 'COP', 'CLP', 'PEN'].includes(recommendedCurrency) &&
|
||||
assignmentLATAM?.variant !== 'latam'
|
||||
) {
|
||||
|
||||
if (['BRL', 'MXN', 'COP', 'CLP', 'PEN'].includes(recommendedCurrency)) {
|
||||
recommendedCurrency = GeoIpLookup.DEFAULT_CURRENCY_CODE
|
||||
}
|
||||
|
||||
return {
|
||||
recommendedCurrency,
|
||||
countryCode,
|
||||
geoPricingINRTestVariant: assignmentINR?.variant,
|
||||
geoPricingLATAMTestVariant: assignmentLATAM?.variant,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ block append meta
|
|||
meta(name="ol-showInrGeoBanner" data-type="boolean" content=showInrGeoBanner)
|
||||
meta(name="ol-inrGeoBannerVariant" data-type="string" content=inrGeoBannerVariant)
|
||||
meta(name="ol-inrGeoBannerSplitTestName" data-type="string" content=inrGeoBannerSplitTestName)
|
||||
meta(name="ol-showLATAMBanner" data-type="boolean" content=showLATAMBanner)
|
||||
meta(name="ol-recommendedCurrency" data-type="string" content=recommendedCurrency)
|
||||
meta(name="ol-groupSubscriptionsPendingEnrollment" data-type="json" content=groupSubscriptionsPendingEnrollment)
|
||||
meta(name="ol-hasIndividualRecurlySubscription" data-type="boolean" content=hasIndividualRecurlySubscription)
|
||||
|
|
|
@ -640,7 +640,6 @@
|
|||
"last_resort_trouble_shooting_guide": "",
|
||||
"last_updated_date_by_x": "",
|
||||
"last_used": "",
|
||||
"latam_discount_offer": "",
|
||||
"latex_places_figures_according_to_a_special_algorithm": "",
|
||||
"latex_places_tables_according_to_a_special_algorithm": "",
|
||||
"layout": "",
|
||||
|
|
|
@ -1,114 +0,0 @@
|
|||
import { useCallback, useEffect, useRef } from 'react'
|
||||
import { Trans, useTranslation } from 'react-i18next'
|
||||
import usePersistedState from '../../../../../shared/hooks/use-persisted-state'
|
||||
import Notification from '../notification'
|
||||
import * as eventTracking from '../../../../../infrastructure/event-tracking'
|
||||
import { Button } from 'react-bootstrap'
|
||||
import getMeta from '../../../../../utils/meta'
|
||||
|
||||
const LATAM_CURRENCIES = {
|
||||
BRL: { name: 'Reais', discount: '50', flag: '🇧🇷' },
|
||||
MXN: { name: 'Pesos', discount: '40', flag: '🇲🇽' },
|
||||
COP: { name: 'Pesos', discount: '70', flag: '🇨🇴' },
|
||||
CLP: { name: 'Pesos', discount: '45', flag: '🇨🇱' },
|
||||
PEN: { name: 'Soles', discount: '50', flag: '🇵🇪' },
|
||||
}
|
||||
|
||||
export default function LATAMBanner() {
|
||||
const { t } = useTranslation()
|
||||
const newNotificationStyle = getMeta(
|
||||
'ol-newNotificationStyle',
|
||||
false
|
||||
) as boolean
|
||||
const [dismissedAt, setDismissedAt] = usePersistedState<Date | undefined>(
|
||||
`has_dismissed_latam_banner`
|
||||
)
|
||||
const viewEventSent = useRef<boolean>(false)
|
||||
|
||||
useEffect(() => {
|
||||
if (!dismissedAt) {
|
||||
return
|
||||
}
|
||||
const dismissedAtDate = new Date(dismissedAt)
|
||||
const recentlyDismissedCutoff = new Date()
|
||||
recentlyDismissedCutoff.setDate(recentlyDismissedCutoff.getDate() - 30) // 30 days
|
||||
// once dismissedAt passes the cut-off mark, banner will be shown again
|
||||
if (dismissedAtDate <= recentlyDismissedCutoff) {
|
||||
setDismissedAt(undefined)
|
||||
}
|
||||
}, [dismissedAt, setDismissedAt])
|
||||
|
||||
useEffect(() => {
|
||||
if (!dismissedAt && !viewEventSent.current) {
|
||||
eventTracking.sendMB('promo-prompt', {
|
||||
location: 'dashboard-banner',
|
||||
name: 'geo-pricing-latam',
|
||||
content: 'blue',
|
||||
})
|
||||
viewEventSent.current = true
|
||||
}
|
||||
}, [dismissedAt])
|
||||
|
||||
const handleClick = useCallback(() => {
|
||||
eventTracking.sendMB('promo-click', {
|
||||
location: 'dashboard-banner',
|
||||
name: 'geo-pricing-latam',
|
||||
content: 'blue',
|
||||
type: 'click',
|
||||
})
|
||||
|
||||
window.open('/user/subscription/plans')
|
||||
}, [])
|
||||
|
||||
const handleDismiss = useCallback(() => {
|
||||
eventTracking.sendMB('promo-dismiss', {
|
||||
location: 'dashboard-banner',
|
||||
name: 'geo-pricing-latam',
|
||||
content: 'blue',
|
||||
})
|
||||
|
||||
setDismissedAt(new Date())
|
||||
}, [setDismissedAt])
|
||||
|
||||
if (dismissedAt) {
|
||||
return null
|
||||
}
|
||||
|
||||
// Safety, but should always be a valid LATAM currency if ol-showLATAMBanner is true
|
||||
const currency = getMeta('ol-recommendedCurrency')
|
||||
if (!(currency in LATAM_CURRENCIES)) {
|
||||
return null
|
||||
}
|
||||
|
||||
const {
|
||||
flag,
|
||||
name: currencyName,
|
||||
discount: discountPercent,
|
||||
} = LATAM_CURRENCIES[currency as keyof typeof LATAM_CURRENCIES]
|
||||
|
||||
return (
|
||||
<Notification
|
||||
bsStyle="info"
|
||||
onDismiss={() => handleDismiss()}
|
||||
body={
|
||||
<Trans
|
||||
i18nKey="latam_discount_offer"
|
||||
components={[<b />]} // eslint-disable-line react/jsx-key
|
||||
values={{ flag, currencyName, discountPercent }}
|
||||
shouldUnescape
|
||||
tOptions={{ interpolation: { escapeValue: true } }}
|
||||
/>
|
||||
}
|
||||
action={
|
||||
<Button
|
||||
bsStyle={newNotificationStyle ? null : 'info'}
|
||||
bsSize="sm"
|
||||
className={newNotificationStyle ? 'btn-secondary' : 'pull-right'}
|
||||
onClick={handleClick}
|
||||
>
|
||||
{t('get_discounted_plan')}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
)
|
||||
}
|
|
@ -8,7 +8,6 @@ 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'
|
||||
import LATAMBanner from './ads/latam-banner'
|
||||
import getMeta from '../../../../utils/meta'
|
||||
import importOverleafModules from '../../../../../macros/import-overleaf-module.macro'
|
||||
import customLocalStorage from '../../../../infrastructure/local-storage'
|
||||
|
@ -50,7 +49,6 @@ function UserNotifications() {
|
|||
'ol-inrGeoBannerSplitTestName',
|
||||
'unassigned'
|
||||
)
|
||||
const showLATAMBanner = getMeta('ol-showLATAMBanner', false)
|
||||
const writefullIntegrationSplitTestEnabled = isSplitTestEnabled(
|
||||
'writefull-integration'
|
||||
)
|
||||
|
@ -107,18 +105,15 @@ function UserNotifications() {
|
|||
<Institution />
|
||||
<ConfirmEmail />
|
||||
<ReconfirmationInfo />
|
||||
{!showLATAMBanner &&
|
||||
!showInrGeoBanner &&
|
||||
!showWritefull &&
|
||||
!dismissedWritefull && <GroupsAndEnterpriseBanner />}
|
||||
{showLATAMBanner ? (
|
||||
<LATAMBanner />
|
||||
) : showInrGeoBanner ? (
|
||||
{!showInrGeoBanner && !showWritefull && !dismissedWritefull && (
|
||||
<GroupsAndEnterpriseBanner />
|
||||
)}
|
||||
{showInrGeoBanner && (
|
||||
<INRBanner
|
||||
variant={inrGeoBannerVariant}
|
||||
splitTestName={inrGeoBannerSplitTestName}
|
||||
/>
|
||||
) : null}
|
||||
)}
|
||||
{writefullIntegrationSplitTestEnabled || user?.writefull?.enabled ? (
|
||||
<WritefullPremiumPromoBanner
|
||||
show={showWritefull}
|
||||
|
|
|
@ -964,7 +964,6 @@
|
|||
"last_updated": "Last Updated",
|
||||
"last_updated_date_by_x": "__lastUpdatedDate__ by __person__",
|
||||
"last_used": "last used",
|
||||
"latam_discount_offer": "__flag__ Good news! You can now use __currencyName__ to pay for an Overleaf subscription, giving you a <0>__discountPercent__% discount</0> on our premium features.",
|
||||
"latex_articles_page_summary": "Papers, presentations, reports and more, written in LaTeX and published by our community. Search or browse below.",
|
||||
"latex_articles_page_title": "Articles - Papers, Presentations, Reports and more",
|
||||
"latex_editor_info": "Everything you need in a modern LaTeX editor --- spell check, intelligent autocomplete, syntax highlighting, dozens of color themes, vim and emacs bindings, help with LaTeX warnings and error messages, and much more.",
|
||||
|
|
Loading…
Reference in a new issue