From 7a6bcdd01197c8fd6ae9bc8b52fed2468a0cd0f5 Mon Sep 17 00:00:00 2001 From: Davinder Singh Date: Tue, 13 Feb 2024 11:50:57 +0000 Subject: [PATCH] tearing down split test (#17000) GitOrigin-RevId: cdcca8635a81c697e9f91f31fb711ee420cc6f7d --- .../Features/Project/ProjectListController.js | 19 +-- .../Subscription/SubscriptionController.js | 42 ++----- services/web/app/views/project/list-react.pug | 1 - .../web/frontend/extracted-translations.json | 1 - .../notifications/ads/latam-banner.tsx | 114 ------------------ .../notifications/user-notifications.tsx | 15 +-- services/web/locales/en.json | 1 - 7 files changed, 14 insertions(+), 179 deletions(-) delete mode 100644 services/web/frontend/js/features/project-list/components/notifications/ads/latam-banner.tsx diff --git a/services/web/app/src/Features/Project/ProjectListController.js b/services/web/app/src/Features/Project/ProjectListController.js index 914a3d2ada..e9f875fe84 100644 --- a/services/web/app/src/Features/Project/ProjectListController.js +++ b/services/web/app/src/Features/Project/ProjectListController.js @@ -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, diff --git a/services/web/app/src/Features/Subscription/SubscriptionController.js b/services/web/app/src/Features/Subscription/SubscriptionController.js index c1ca2a94ec..c4bc1a2194 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionController.js +++ b/services/web/app/src/Features/Subscription/SubscriptionController.js @@ -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, } } diff --git a/services/web/app/views/project/list-react.pug b/services/web/app/views/project/list-react.pug index de297e9bc4..cc4f81eb59 100644 --- a/services/web/app/views/project/list-react.pug +++ b/services/web/app/views/project/list-react.pug @@ -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) diff --git a/services/web/frontend/extracted-translations.json b/services/web/frontend/extracted-translations.json index 11be0ceae2..04c8ab9fae 100644 --- a/services/web/frontend/extracted-translations.json +++ b/services/web/frontend/extracted-translations.json @@ -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": "", diff --git a/services/web/frontend/js/features/project-list/components/notifications/ads/latam-banner.tsx b/services/web/frontend/js/features/project-list/components/notifications/ads/latam-banner.tsx deleted file mode 100644 index e549785f3a..0000000000 --- a/services/web/frontend/js/features/project-list/components/notifications/ads/latam-banner.tsx +++ /dev/null @@ -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( - `has_dismissed_latam_banner` - ) - const viewEventSent = useRef(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 ( - handleDismiss()} - body={ - ]} // eslint-disable-line react/jsx-key - values={{ flag, currencyName, discountPercent }} - shouldUnescape - tOptions={{ interpolation: { escapeValue: true } }} - /> - } - action={ - - } - /> - ) -} 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 b2f13ae2a2..3d038d3073 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 @@ -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() { - {!showLATAMBanner && - !showInrGeoBanner && - !showWritefull && - !dismissedWritefull && } - {showLATAMBanner ? ( - - ) : showInrGeoBanner ? ( + {!showInrGeoBanner && !showWritefull && !dismissedWritefull && ( + + )} + {showInrGeoBanner && ( - ) : null} + )} {writefullIntegrationSplitTestEnabled || user?.writefull?.enabled ? ( __discountPercent__% discount 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.",