-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(billing): subscribe to all products (client side) (#22768)
Co-authored-by: Raquel Smith <[email protected]> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
63f6486
commit 2f243ee
Showing
35 changed files
with
1,010 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+946 Bytes
(100%)
...s__/scenes-app-insights--funnel-left-to-right-breakdown-edit--light--webkit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+965 Bytes
(100%)
...s__/scenes-app-insights--funnel-top-to-bottom-breakdown-edit--light--webkit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-372 Bytes
(99%)
...tend/__snapshots__/scenes-other-billing-v2--billing-unsubscribe-modal--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-292 Bytes
(99%)
...end/__snapshots__/scenes-other-billing-v2--billing-unsubscribe-modal--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-371 Bytes
(99%)
...s__/scenes-other-billing-v2--billing-unsubscribe-modal-data-pipelines--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-275 Bytes
(100%)
...__/scenes-other-billing-v2--billing-unsubscribe-modal-data-pipelines--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+3.6 KB
(100%)
frontend/__snapshots__/scenes-other-billing-v2--billing-v-2--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+3.47 KB
(100%)
frontend/__snapshots__/scenes-other-billing-v2--billing-v-2--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-616 Bytes
(100%)
...tend/__snapshots__/scenes-other-billing-v2--billing-v-2-with-discount--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-741 Bytes
(99%)
...end/__snapshots__/scenes-other-billing-v2--billing-v-2-with-discount--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-740 Bytes
(99%)
...nes-other-billing-v2--billing-v-2-with-limit-and-100-percent-discount--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-802 Bytes
(99%)
...es-other-billing-v2--billing-v-2-with-limit-and-100-percent-discount--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-873 Bytes
(100%)
frontend/__snapshots__/scenes-other-onboarding--onboarding-billing--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-972 Bytes
(99%)
frontend/__snapshots__/scenes-other-onboarding--onboarding-billing--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
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 { BillingProductV2AddonType, BillingProductV2Type, BillingV2FeatureType, BillingV2Type } from '~/types' | ||
|
||
|
@@ -8,6 +12,7 @@ interface PayGateButtonProps { | |
featureInfo: BillingV2FeatureType | ||
onCtaClick: () => void | ||
billing: BillingV2Type | null | ||
isAddonProduct?: boolean | ||
scrollToProduct: boolean | ||
} | ||
|
||
|
@@ -17,16 +22,27 @@ export const PayGateButton = ({ | |
featureInfo, | ||
onCtaClick, | ||
billing, | ||
isAddonProduct, | ||
scrollToProduct = true, | ||
}: PayGateButtonProps): JSX.Element => { | ||
const { featureFlags } = useValues(featureFlagLogic) | ||
return ( | ||
<LemonButton | ||
to={getCtaLink(gateVariant, productWithFeature, featureInfo, scrollToProduct)} | ||
to={getCtaLink( | ||
gateVariant, | ||
productWithFeature, | ||
featureInfo, | ||
featureFlags, | ||
billing?.subscription_level, | ||
isAddonProduct, | ||
scrollToProduct | ||
)} | ||
disableClientSideRouting={gateVariant === 'add-card' && !isAddonProduct} | ||
type="primary" | ||
center | ||
onClick={onCtaClick} | ||
> | ||
{getCtaLabel(gateVariant, billing)} | ||
{getCtaLabel(gateVariant, billing, featureFlags)} | ||
</LemonButton> | ||
) | ||
} | ||
|
@@ -35,9 +51,21 @@ const getCtaLink = ( | |
gateVariant: 'add-card' | 'contact-sales' | 'move-to-cloud' | null, | ||
productWithFeature: BillingProductV2AddonType | BillingProductV2Type, | ||
featureInfo: BillingV2FeatureType, | ||
featureFlags: FeatureFlagsSet, | ||
subscriptionLevel?: BillingV2Type['subscription_level'], | ||
isAddonProduct?: boolean, | ||
scrollToProduct: boolean = true | ||
): string | undefined => { | ||
if (gateVariant === 'add-card') { | ||
if ( | ||
gateVariant === 'add-card' && | ||
!isAddonProduct && | ||
featureFlags[FEATURE_FLAGS.SUBSCRIBE_TO_ALL_PRODUCTS] === 'test' && | ||
subscriptionLevel === 'free' | ||
) { | ||
return `/api/billing/activate?products=all_products:&redirect_path=${urls.organizationBilling()}&intent_product=${ | ||
productWithFeature.type | ||
}` | ||
} else if (gateVariant === 'add-card') { | ||
return `/organization/billing${scrollToProduct ? `?products=${productWithFeature.type}` : ''}` | ||
} else if (gateVariant === 'contact-sales') { | ||
return `mailto:[email protected]?subject=Inquiring about ${featureInfo.name}` | ||
|
@@ -49,9 +77,16 @@ const getCtaLink = ( | |
|
||
const getCtaLabel = ( | ||
gateVariant: 'add-card' | 'contact-sales' | 'move-to-cloud' | null, | ||
billing: BillingV2Type | null | ||
billing: BillingV2Type | null, | ||
featureFlags: FeatureFlagsSet | ||
): string => { | ||
if (gateVariant === 'add-card') { | ||
if ( | ||
gateVariant === 'add-card' && | ||
featureFlags[FEATURE_FLAGS.SUBSCRIBE_TO_ALL_PRODUCTS] === 'test' && | ||
billing?.subscription_level === 'free' | ||
) { | ||
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' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.