Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve downgrade flow in onboarding #22436

Merged
merged 41 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2f1dca2
improve downgrade flow in onboarding
raquelmsmith May 22, 2024
d40fa21
undo this
raquelmsmith May 22, 2024
7393844
Update UI snapshots for `chromium` (2)
github-actions[bot] May 22, 2024
6c4daa7
Update UI snapshots for `chromium` (2)
github-actions[bot] May 22, 2024
f62e7c6
Merge branch 'master' into fix/downgrade-button-action
raquelmsmith May 29, 2024
d9fe649
Update UI snapshots for `chromium` (1)
github-actions[bot] May 29, 2024
d659495
Update UI snapshots for `chromium` (2)
github-actions[bot] May 29, 2024
0ce1de3
merge master in
zlwaterfield Jul 2, 2024
50d9a43
Merge remote-tracking branch 'origin/master' into fix/downgrade-butto…
zlwaterfield Jul 4, 2024
5f6b545
Merge branch 'master' into fix/downgrade-button-action
zlwaterfield Jul 23, 2024
bdb408b
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 23, 2024
62dcdcb
improve downgrade loading
zlwaterfield Jul 23, 2024
f50eab5
Improve loading
zlwaterfield Jul 24, 2024
3ef98b8
Update PlanComparison.tsx
zlwaterfield Jul 24, 2024
3f85d87
Update PlanComparison.tsx
zlwaterfield Jul 24, 2024
efe0169
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
d3627ea
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
a13e503
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
e8aeb88
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
3d5c883
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
6ebb0ab
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
f6f0628
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
1afab16
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
958314b
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
c234f14
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
a48ef4b
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
6a0fa3b
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
2a2edfe
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
dc900e3
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
f82e8f2
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
79c4042
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
fbffbae
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
ca3ccb3
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
9b5df2a
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
1b78ad6
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
1a4d212
add breakpoint to wait for action
zlwaterfield Jul 24, 2024
6e269a9
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
eddd438
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
8469d51
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
8bc8523
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
0246efe
Update UI snapshots for `chromium` (1)
github-actions[bot] Jul 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions frontend/src/scenes/billing/PlanComparison.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,12 @@ export const PlanComparison = ({
const { width, ref: planComparisonRef } = useResizeObserver()
const { reportBillingUpgradeClicked } = useActions(eventUsageLogic)
const currentPlanIndex = plans.findIndex((plan) => plan.current_plan)
const { surveyID, comparisonModalHighlightedFeatureKey } = useValues(billingProductLogic({ product }))
const { reportSurveyShown, setSurveyResponse } = useActions(billingProductLogic({ product }))
const { surveyID, comparisonModalHighlightedFeatureKey, billingProductLoading } = useValues(
billingProductLogic({ product })
)
const { reportSurveyShown, setSurveyResponse, setBillingProductLoading } = useActions(
billingProductLogic({ product })
)
const billingDaysRemaining = billing?.billing_period?.current_period_end.diff(dayjs(), 'days')
const billingDaysTotal = billing?.billing_period?.current_period_end.diff(
billing.billing_period?.current_period_start,
Expand All @@ -136,6 +140,8 @@ export const PlanComparison = ({
to={
plan.contact_support
? 'mailto:[email protected]?subject=Enterprise%20plan%20request'
: i < currentPlanIndex
? undefined // Downgrade action handled in onClick
: !plan.included_if
? getUpgradeProductLink(product, plan.plan_key || '', redirectPath, includeAddons)
: plan.included_if == 'has_subscription' &&
Expand Down Expand Up @@ -166,12 +172,14 @@ export const PlanComparison = ({
if (!plan.current_plan) {
// TODO: add current plan key and new plan key
reportBillingUpgradeClicked(product.type)
setBillingProductLoading(product.type)
}
if (plan.included_if == 'has_subscription' && !plan.current_plan && i < currentPlanIndex) {
if (!plan.included_if && !plan.current_plan && i < currentPlanIndex) {
setSurveyResponse(product.type, '$survey_response_1')
reportSurveyShown(UNSUBSCRIBE_SURVEY_ID, product.type)
}
}}
loading={billingProductLoading === product.type && !plan.current_plan && !plan.contact_support}
data-attr={`upgrade-${plan.name}`}
>
{plan.current_plan
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/scenes/billing/billingLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ export const billingLogic = kea<billingLogicType>([
},

deactivateProduct: async (key: string) => {
// clear upgrade params from URL
const currentURL = new URL(window.location.href)
currentURL.searchParams.delete('upgraded')
currentURL.searchParams.delete('products')
zlwaterfield marked this conversation as resolved.
Show resolved Hide resolved
router.actions.push(currentURL.pathname + currentURL.search)

actions.resetUnsubscribeError()
try {
const response = await api.getResponse('api/billing-v2/deactivate?products=' + key)
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/scenes/billing/billingProductLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const billingProductLogic = kea<billingProductLogicType>([
[
'updateBillingLimits',
'updateBillingLimitsSuccess',
'loadBilling',
raquelmsmith marked this conversation as resolved.
Show resolved Hide resolved
'loadBillingSuccess',
'deactivateProduct',
'setProductSpecificAlert',
Expand Down Expand Up @@ -266,6 +267,7 @@ export const billingProductLogic = kea<billingProductLogicType>([
? actions.reportSurveySent(values.surveyID, values.surveyResponse)
: actions.reportSurveyDismissed(values.surveyID)
}
location.reload()
zlwaterfield marked this conversation as resolved.
Show resolved Hide resolved
},
setScrollToProductKey: ({ scrollToProductKey }) => {
if (scrollToProductKey && scrollToProductKey === props.product.type) {
Expand Down
15 changes: 9 additions & 6 deletions frontend/src/scenes/onboarding/OnboardingBillingStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const OnboardingBillingStep = ({
product: BillingProductV2Type
stepKey?: OnboardingStepKey
}): JSX.Element => {
const { billing, redirectPath } = useValues(billingLogic)
const { billing, redirectPath, billingLoading } = useValues(billingLogic)
const { productKey } = useValues(onboardingLogic)
const { currentAndUpgradePlans } = useValues(billingProductLogic({ product }))
const { reportBillingUpgradeClicked } = useActions(eventUsageLogic)
Expand All @@ -39,13 +39,14 @@ export const OnboardingBillingStep = ({
showSkip={!product.subscribed}
stepKey={stepKey}
continueOverride={
product?.subscribed ? undefined : (
product?.subscribed && !billingLoading ? undefined : (
<BillingUpgradeCTA
// TODO: redirect path won't work properly until navigation is properly set up
to={getUpgradeProductLink(product, plan.plan_key || '', redirectPath, true)}
to={getUpgradeProductLink(product, plan?.plan_key || '', redirectPath, true)}
type="primary"
status="alt"
center
disabledReason={billingLoading && 'Please wait...'}
disableClientSideRouting
onClick={() => {
reportBillingUpgradeClicked(product.type)
Expand All @@ -57,7 +58,7 @@ export const OnboardingBillingStep = ({
)
}
>
{billing?.products && productKey && product ? (
{billing?.products && productKey && product && !billingLoading ? (
zlwaterfield marked this conversation as resolved.
Show resolved Hide resolved
<div className="mt-6">
{product.subscribed && (
<div className="mb-8">
Expand Down Expand Up @@ -92,15 +93,17 @@ export const OnboardingBillingStep = ({
</div>
)}

{(!product.subscribed || showPlanComp) && (
{(!product.subscribed || showPlanComp) && !billingLoading && (
<>
<BillingHero />
<PlanComparison product={product} includeAddons />
</>
)}
</div>
) : (
<Spinner className="text-lg" />
<div className="flex items-center justify-center my-6">
<Spinner className="text-2xl text-muted" />
</div>
)}
</OnboardingStep>
)
Expand Down
Loading