Skip to content

Commit

Permalink
remove SUBSCRIBE_TO_ALL_PRODUCTS ff
Browse files Browse the repository at this point in the history
  • Loading branch information
zlwaterfield committed Jul 2, 2024
1 parent d45c5ee commit 8a7c1f0
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 181 deletions.
43 changes: 6 additions & 37 deletions frontend/src/lib/components/PayGateMini/PayGateButton.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import { LemonButton } from '@posthog/lemon-ui'
import { useValues } from 'kea'
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic, FeatureFlagsSet } from 'lib/logic/featureFlagLogic'
import { urls } from 'scenes/urls'

import { BillingFeatureType, BillingProductV2AddonType, BillingProductV2Type, BillingType } from '~/types'
import { BillingFeatureType, BillingProductV2AddonType, BillingProductV2Type } from '~/types'

interface PayGateButtonProps {
gateVariant: 'add-card' | 'contact-sales' | 'move-to-cloud' | null
productWithFeature: BillingProductV2AddonType | BillingProductV2Type
featureInfo: BillingFeatureType
onCtaClick: () => void
billing: BillingType | null
isAddonProduct?: boolean
scrollToProduct: boolean
}
Expand All @@ -21,28 +17,18 @@ export const PayGateButton = ({
productWithFeature,
featureInfo,
onCtaClick,
billing,
isAddonProduct,
scrollToProduct = true,
}: PayGateButtonProps): JSX.Element => {
const { featureFlags } = useValues(featureFlagLogic)
return (
<LemonButton
to={getCtaLink(
gateVariant,
productWithFeature,
featureInfo,
featureFlags,
billing?.subscription_level,
isAddonProduct,
scrollToProduct
)}
to={getCtaLink(gateVariant, productWithFeature, featureInfo, isAddonProduct, scrollToProduct)}
disableClientSideRouting={gateVariant === 'add-card' && !isAddonProduct}
type="primary"
center
onClick={onCtaClick}
>
{getCtaLabel(gateVariant, billing, featureFlags)}
{getCtaLabel(gateVariant)}
</LemonButton>
)
}
Expand All @@ -51,17 +37,10 @@ const getCtaLink = (
gateVariant: 'add-card' | 'contact-sales' | 'move-to-cloud' | null,
productWithFeature: BillingProductV2AddonType | BillingProductV2Type,
featureInfo: BillingFeatureType,
featureFlags: FeatureFlagsSet,
subscriptionLevel?: BillingType['subscription_level'],
isAddonProduct?: boolean,
scrollToProduct: boolean = true
): string | undefined => {
if (
gateVariant === 'add-card' &&
!isAddonProduct &&
featureFlags[FEATURE_FLAGS.SUBSCRIBE_TO_ALL_PRODUCTS] === 'test' &&
subscriptionLevel === 'free'
) {
if (gateVariant === 'add-card' && !isAddonProduct) {
return `/api/billing/activate?products=all_products:&redirect_path=${urls.organizationBilling()}&intent_product=${
productWithFeature.type
}`
Expand All @@ -75,19 +54,9 @@ const getCtaLink = (
return undefined
}

const getCtaLabel = (
gateVariant: 'add-card' | 'contact-sales' | 'move-to-cloud' | null,
billing: BillingType | null,
featureFlags: FeatureFlagsSet
): string => {
if (
gateVariant === 'add-card' &&
featureFlags[FEATURE_FLAGS.SUBSCRIBE_TO_ALL_PRODUCTS] === 'test' &&
billing?.subscription_level === 'free'
) {
const getCtaLabel = (gateVariant: 'add-card' | 'contact-sales' | 'move-to-cloud' | null): string => {
if (gateVariant === 'add-card') {
return 'Upgrade now'
} else if (gateVariant === 'add-card') {
return billing?.has_active_subscription ? 'Upgrade now' : 'Subscribe now'
} else if (gateVariant === 'contact-sales') {
return 'Contact sales'
}
Expand Down
40 changes: 5 additions & 35 deletions frontend/src/lib/components/PayGateMini/PayGateMini.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,13 @@ import { IconInfo, IconOpenSidebar } from '@posthog/icons'
import { LemonButton, Link, Tooltip } from '@posthog/lemon-ui'
import clsx from 'clsx'
import { useActions, useValues } from 'kea'
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic, FeatureFlagsSet } from 'lib/logic/featureFlagLogic'
import posthog from 'posthog-js'
import { useEffect } from 'react'
import { billingLogic } from 'scenes/billing/billingLogic'
import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { getProductIcon } from 'scenes/products/Products'

import {
AvailableFeature,
BillingFeatureType,
BillingProductV2AddonType,
BillingProductV2Type,
BillingType,
} from '~/types'
import { AvailableFeature, BillingFeatureType, BillingProductV2AddonType, BillingProductV2Type } from '~/types'

import { upgradeModalLogic } from '../UpgradeModal/upgradeModalLogic'
import { PayGateButton } from './PayGateButton'
Expand Down Expand Up @@ -60,7 +52,7 @@ export function PayGateMini({
featureInfoOnNextPlan,
} = useValues(payGateMiniLogic({ featureKey: feature, currentUsage }))
const { preflight, isCloudOrDev } = useValues(preflightLogic)
const { billing, billingLoading } = useValues(billingLogic)
const { billingLoading } = useValues(billingLogic)
const { hideUpgradeModal } = useActions(upgradeModalLogic)

const scrollToProduct = !(featureInfo?.key === AvailableFeature.ORGANIZATIONS_PROJECTS && !isAddonProduct)
Expand Down Expand Up @@ -103,7 +95,6 @@ export function PayGateMini({
productWithFeature={productWithFeature}
isGrandfathered={isGrandfathered}
isAddonProduct={isAddonProduct}
billing={billing}
featureInfoOnNextPlan={featureInfoOnNextPlan}
handleCtaClick={handleCtaClick}
>
Expand All @@ -113,7 +104,6 @@ export function PayGateMini({
productWithFeature={productWithFeature}
featureInfo={featureInfo}
onCtaClick={handleCtaClick}
billing={billing}
scrollToProduct={scrollToProduct}
isAddonProduct={isAddonProduct}
/>
Expand Down Expand Up @@ -145,7 +135,6 @@ interface PayGateContentProps {
productWithFeature: BillingProductV2AddonType | BillingProductV2Type
isGrandfathered?: boolean
isAddonProduct?: boolean
billing: BillingType | null
featureInfoOnNextPlan?: BillingFeatureType
children: React.ReactNode
handleCtaClick: () => void
Expand All @@ -160,12 +149,10 @@ function PayGateContent({
productWithFeature,
isGrandfathered,
isAddonProduct,
billing,
featureInfoOnNextPlan,
children,
handleCtaClick,
}: PayGateContentProps): JSX.Element {
const { featureFlags } = useValues(featureFlagLogic)
return (
<div
className={clsx(
Expand All @@ -184,8 +171,6 @@ function PayGateContent({
gateVariant,
featureInfo,
productWithFeature,
billing,
featureFlags,
isAddonProduct,
handleCtaClick
)}
Expand All @@ -202,8 +187,6 @@ const renderUsageLimitMessage = (
gateVariant: 'add-card' | 'contact-sales' | 'move-to-cloud' | null,
featureInfo: BillingFeatureType,
productWithFeature: BillingProductV2AddonType | BillingProductV2Type,
billing: BillingType | null,
featureFlags: FeatureFlagsSet,
isAddonProduct?: boolean,
handleCtaClick?: () => void
): JSX.Element => {
Expand Down Expand Up @@ -240,9 +223,7 @@ const renderUsageLimitMessage = (
.
</p>
</>
) : featureFlags[FEATURE_FLAGS.SUBSCRIBE_TO_ALL_PRODUCTS] === 'test' &&
billing?.subscription_level === 'free' &&
!isAddonProduct ? (
) : !isAddonProduct ? (
<p>Upgrade to create more {featureInfo.name}</p>
) : (
<p>
Expand All @@ -255,16 +236,14 @@ const renderUsageLimitMessage = (
return (
<>
<p className="max-w-140">{featureInfo.description}</p>
<p>{renderGateVariantMessage(gateVariant, productWithFeature, billing, featureFlags, isAddonProduct)}</p>
<p>{renderGateVariantMessage(gateVariant, productWithFeature, isAddonProduct)}</p>
</>
)
}

const renderGateVariantMessage = (
gateVariant: 'add-card' | 'contact-sales' | 'move-to-cloud' | null,
productWithFeature: BillingProductV2AddonType | BillingProductV2Type,
billing: BillingType | null,
featureFlags: FeatureFlagsSet,
isAddonProduct?: boolean
): JSX.Element => {
if (gateVariant === 'move-to-cloud') {
Expand All @@ -275,18 +254,9 @@ const renderGateVariantMessage = (
Subscribe to the <b>{productWithFeature?.name}</b> addon to use this feature.
</>
)
} else if (
featureFlags[FEATURE_FLAGS.SUBSCRIBE_TO_ALL_PRODUCTS] === 'test' &&
billing?.subscription_level === 'free'
) {
return <>Upgrade to use this feature.</>
}

return (
<>
Upgrade your <b>{productWithFeature?.name}</b> plan to use this feature.
</>
)
return <>Upgrade to use this feature.</>
}

const GrandfatheredMessage = (): JSX.Element => {
Expand Down
1 change: 0 additions & 1 deletion frontend/src/lib/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ export const FEATURE_FLAGS = {
PERSONLESS_EVENTS_NOT_SUPPORTED: 'personless-events-not-supported', // owner: @raquelmsmith
SESSION_REPLAY_UNIVERSAL_FILTERS: 'session-replay-universal-filters', // owner: #team-replay
ALERTS: 'alerts', // owner: github.com/nikitaevg
SUBSCRIBE_TO_ALL_PRODUCTS: 'subscribe-to-all-products', // owner: #team-growth
ERROR_TRACKING: 'error-tracking', // owner: #team-replay
SETTINGS_BOUNCE_RATE_PAGE_VIEW_MODE: 'settings-bounce-rate-page-view-mode', // owner: @robbie-c
SURVEYS_BRANCHING_LOGIC: 'surveys-branching-logic', // owner: @jurajmajerik #team-feature-success
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/scenes/billing/AllProductsPlanComparison.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,8 @@ export const AllProductsPlanComparison = ({
? 'mailto:[email protected]?subject=Enterprise%20plan%20request'
: getUpgradeProductLink({
product,
upgradeToPlanKey: plan.plan_key || '',
redirectPath,
includeAddons,
subscriptionLevel: billing?.subscription_level,
featureFlags,
})
}
type={plan.current_plan || i < currentPlanIndex ? 'secondary' : 'primary'}
Expand Down
18 changes: 3 additions & 15 deletions frontend/src/scenes/billing/Billing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,18 @@ import { Field, Form } from 'kea-forms'
import { router } from 'kea-router'
import { SurprisedHog } from 'lib/components/hedgehogs'
import { supportLogic } from 'lib/components/Support/supportLogic'
import { FEATURE_FLAGS } from 'lib/constants'
import { dayjs } from 'lib/dayjs'
import { useResizeBreakpoints } from 'lib/hooks/useResizeObserver'
import { LemonBanner } from 'lib/lemon-ui/LemonBanner'
import { LemonLabel } from 'lib/lemon-ui/LemonLabel/LemonLabel'
import { SpinnerOverlay } from 'lib/lemon-ui/Spinner/Spinner'
import { Tooltip } from 'lib/lemon-ui/Tooltip'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { useEffect } from 'react'
import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { SceneExport } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'

import { BillingCTAHero } from './BillingCTAHero'
import { BillingHero } from './BillingHero'
import { billingLogic } from './billingLogic'
import { BillingProduct } from './BillingProduct'
import { UnsubscribeCard } from './UnsubscribeCard'
Expand All @@ -46,7 +43,6 @@ export function Billing(): JSX.Element {
const { reportBillingShown } = useActions(billingLogic)
const { preflight, isCloudOrDev } = useValues(preflightLogic)
const { openSupportForm } = useActions(supportLogic)
const { featureFlags } = useValues(featureFlagLogic)

if (preflight && !isCloudOrDev) {
router.actions.push(urls.default())
Expand Down Expand Up @@ -124,15 +120,9 @@ export function Billing(): JSX.Element {
You are currently on a free trial until <b>{billing.free_trial_until.format('LL')}</b>
</LemonBanner>
) : null}
{!billing?.has_active_subscription && (
{!billing?.has_active_subscription && platformAndSupportProduct && (
<div className="mb-6">
{featureFlags[FEATURE_FLAGS.SUBSCRIBE_TO_ALL_PRODUCTS] === 'test' ? (
platformAndSupportProduct ? (
<BillingCTAHero product={platformAndSupportProduct} />
) : null
) : (
<BillingHero />
)}
<BillingCTAHero product={platformAndSupportProduct} />
</div>
)}

Expand Down Expand Up @@ -291,9 +281,7 @@ export function Billing(): JSX.Element {
</div>
))}
<div>
{featureFlags[FEATURE_FLAGS.SUBSCRIBE_TO_ALL_PRODUCTS] === 'test' &&
billing?.subscription_level == 'paid' &&
!!platformAndSupportProduct ? (
{billing?.subscription_level == 'paid' && !!platformAndSupportProduct ? (
<>
<LemonDivider />
<UnsubscribeCard product={platformAndSupportProduct} />
Expand Down
49 changes: 21 additions & 28 deletions frontend/src/scenes/billing/BillingProduct.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const BillingProduct = ({ product }: { product: BillingProductV2Type }):
const showUpgradeCard =
(upgradePlan?.product_key !== 'platform_and_support' || product?.addons?.length === 0) &&
upgradePlan &&
(featureFlags[FEATURE_FLAGS.SUBSCRIBE_TO_ALL_PRODUCTS] !== 'test' || billing?.subscription_level == 'custom')
billing?.subscription_level === 'custom'

const { ref, size } = useResizeBreakpoints({
0: 'small',
Expand Down Expand Up @@ -136,9 +136,7 @@ export const BillingProduct = ({ product }: { product: BillingProductV2Type }):
>
Learn how to reduce your bill
</LemonButton>
{(featureFlags[FEATURE_FLAGS.SUBSCRIBE_TO_ALL_PRODUCTS] !== 'test' ||
(featureFlags[FEATURE_FLAGS.SUBSCRIBE_TO_ALL_PRODUCTS] === 'test' &&
billing?.subscription_level === 'custom')) &&
{billing?.subscription_level === 'custom' &&
(product.plans?.length > 0 ? (
<LemonButton
fullWidth
Expand Down Expand Up @@ -292,28 +290,26 @@ export const BillingProduct = ({ product }: { product: BillingProductV2Type }):
{product.addons?.length > 0 && (
<div className="pb-8">
<h4 className="my-4">Add-ons</h4>
{featureFlags[FEATURE_FLAGS.SUBSCRIBE_TO_ALL_PRODUCTS] == 'test' &&
billing?.subscription_level == 'free' && (
<LemonBanner type="warning" className="text-sm mb-4" hideIcon>
<div className="flex justify-between items-center">
<div>
Add-ons are only available on paid plans. Upgrade to access these
features.
</div>
<LemonButton
className="shrink-0"
to={`/api/billing/activate?products=all_products:&redirect_path=${redirectPath}&intent_product=${product.type}`}
type="primary"
status="alt"
disableClientSideRouting
loading={!!billingProductLoading}
onClick={() => setBillingProductLoading(product.type)}
>
Upgrade now
</LemonButton>
{billing?.subscription_level == 'free' && (
<LemonBanner type="warning" className="text-sm mb-4" hideIcon>
<div className="flex justify-between items-center">
<div>
Add-ons are only available on paid plans. Upgrade to access these features.
</div>
</LemonBanner>
)}
<LemonButton
className="shrink-0"
to={`/api/billing/activate?products=all_products:&redirect_path=${redirectPath}&intent_product=${product.type}`}
type="primary"
status="alt"
disableClientSideRouting
loading={!!billingProductLoading}
onClick={() => setBillingProductLoading(product.type)}
>
Upgrade now
</LemonButton>
</div>
</LemonBanner>
)}
<div className="gap-y-4 flex flex-col">
{product.addons
// TODO: enhanced_persons: remove this filter
Expand Down Expand Up @@ -423,11 +419,8 @@ export const BillingProduct = ({ product }: { product: BillingProductV2Type }):
data-attr={`${product.type}-upgrade-cta`}
to={getUpgradeProductLink({
product,
upgradeToPlanKey: upgradeToPlanKey || '',
redirectPath,
includeAddons: false,
subscriptionLevel: billing?.subscription_level,
featureFlags,
})}
type="primary"
icon={<IconPlus />}
Expand Down
Loading

0 comments on commit 8a7c1f0

Please sign in to comment.