Skip to content

feat(checkout): Correct flag check for selectable products #93072

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

Merged
merged 3 commits into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 1 addition & 6 deletions static/gsApp/views/amCheckout/steps/planSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,7 @@ function PlanSelect({
/>
{isActive && renderBody()}
{isActive && (
<ProductSelect
activePlan={activePlan}
organization={organization}
formData={formData}
onUpdate={onUpdate}
/>
<ProductSelect activePlan={activePlan} formData={formData} onUpdate={onUpdate} />
)}
{isActive && renderFooter()}
</Panel>
Expand Down
13 changes: 11 additions & 2 deletions static/gsApp/views/amCheckout/steps/productSelect.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('ProductSelect', function () {
const params = {};

beforeEach(function () {
organization.features = ['seer-billing'];
MockApiClient.clearMockResponses();
subscription.reservedBudgets = [];
SubscriptionStore.set(organization.slug, subscription);

Expand Down Expand Up @@ -80,7 +80,16 @@ describe('ProductSelect', function () {
});

it('does not render products if flags are missing', async function () {
organization.features = [];
const mockBillingConfig = structuredClone(BillingConfigFixture(PlanTier.AM3));
mockBillingConfig.planList.forEach(plan => {
plan.features = plan.features.filter(feature => feature !== 'seer-billing');
});
MockApiClient.addMockResponse({
url: `/customers/${organization.slug}/billing-config/`,
method: 'GET',
body: mockBillingConfig,
});

render(
<AMCheckout
{...RouteComponentPropsFixture()}
Expand Down
5 changes: 2 additions & 3 deletions static/gsApp/views/amCheckout/steps/productSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ function ProductSelect({
activePlan,
formData,
onUpdate,
organization,
}: Pick<StepProps, 'activePlan' | 'organization' | 'onUpdate' | 'formData'>) {
}: Pick<StepProps, 'activePlan' | 'onUpdate' | 'formData'>) {
const availableProducts = Object.values(activePlan.availableReservedBudgetTypes)
.filter(
productInfo =>
productInfo.isFixed && // NOTE: for now, we only supported fixed budget products in checkout
productInfo.billingFlag &&
organization.features.includes(productInfo.billingFlag)
activePlan.features.includes(productInfo.billingFlag)
)
.map(productInfo => {
return productInfo;
Expand Down
14 changes: 14 additions & 0 deletions tests/js/getsentry-test/fixtures/am1Plans.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import {
SEER_TIERS,
SEER_TIERS_ANNUAL,
SEER_TIERS_DEVELOPER,
SEER_TIERS_TRIAL_OR_ENTERPRISE,
} from 'getsentry-test/fixtures/am3Plans';
import {SeerReservedBudgetCategoryFixture} from 'getsentry-test/fixtures/reservedBudget';

import type {DataCategory} from 'sentry/types/core';
Expand Down Expand Up @@ -62,6 +68,7 @@ const AM1_TEAM_FEATURES = [
'sso-basic',
'weekly-reports',
'on-demand-metrics-prefill',
'seer-billing',
];

const AM1_BUSINESS_FEATURES = [
Expand Down Expand Up @@ -163,6 +170,7 @@ const AM1_PLANS: Record<string, Plan> = {
events: 1,
},
],
...SEER_TIERS_DEVELOPER,
},
features: AM1_FREE_FEATURES,
budgetTerm: BUDGET_TERM,
Expand Down Expand Up @@ -235,6 +243,7 @@ const AM1_PLANS: Record<string, Plan> = {
events: 0,
},
],
...SEER_TIERS_TRIAL_OR_ENTERPRISE,
},
features: AM1_TRIAL_FEATURES,
budgetTerm: BUDGET_TERM,
Expand Down Expand Up @@ -817,6 +826,7 @@ const AM1_PLANS: Record<string, Plan> = {
events: 1,
},
],
...SEER_TIERS,
},
features: AM1_TEAM_FEATURES,
budgetTerm: BUDGET_TERM,
Expand Down Expand Up @@ -1399,6 +1409,7 @@ const AM1_PLANS: Record<string, Plan> = {
events: 1,
},
],
...SEER_TIERS_ANNUAL,
},
features: AM1_TEAM_FEATURES,
budgetTerm: BUDGET_TERM,
Expand Down Expand Up @@ -1981,6 +1992,7 @@ const AM1_PLANS: Record<string, Plan> = {
events: 1,
},
],
...SEER_TIERS,
},
features: AM1_BUSINESS_FEATURES,
budgetTerm: BUDGET_TERM,
Expand Down Expand Up @@ -2563,6 +2575,7 @@ const AM1_PLANS: Record<string, Plan> = {
events: 1,
},
],
...SEER_TIERS,
},
features: AM1_BUSINESS_FEATURES,
budgetTerm: BUDGET_TERM,
Expand Down Expand Up @@ -2643,6 +2656,7 @@ const AM1_PLANS: Record<string, Plan> = {
price: 0,
},
],
...SEER_TIERS_TRIAL_OR_ENTERPRISE,
},
budgetTerm: BUDGET_TERM,
availableReservedBudgetTypes: AM1_AVAILABLE_RESERVED_BUDGET_TYPES,
Expand Down
79 changes: 15 additions & 64 deletions tests/js/getsentry-test/fixtures/am2Plans.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import {
SEER_TIERS,
SEER_TIERS_ANNUAL,
SEER_TIERS_DEVELOPER,
SEER_TIERS_TRIAL_OR_ENTERPRISE,
} from 'getsentry-test/fixtures/am3Plans';
import {SeerReservedBudgetCategoryFixture} from 'getsentry-test/fixtures/reservedBudget';

import type {DataCategory} from 'sentry/types/core';
Expand Down Expand Up @@ -71,6 +77,7 @@ const AM2_TEAM_FEATURES = [
'sso-basic',
'weekly-reports',
'on-demand-metrics-prefill',
'seer-billing',
];

const AM2_BUSINESS_FEATURES = [
Expand Down Expand Up @@ -104,68 +111,6 @@ const AM2_TRIAL_FEATURES = AM2_BUSINESS_FEATURES.filter(

const BUDGET_TERM = 'on-demand';

const SEER_TIERS = {
seerAutofix: [
{
events: -2,
unitPrice: 0,
price: 20_00,
onDemandPrice: 125,
},
{
events: 0,
unitPrice: 0,
price: 0,
onDemandPrice: 125,
},
],
seerScanner: [
{
events: -2,
unitPrice: 0,
price: 0,
onDemandPrice: 1.25,
},
{
events: 0,
unitPrice: 0,
price: 0,
onDemandPrice: 1.25,
},
],
};

const SEER_TIERS_ANNUAL = {
seerAutofix: [
{
events: -2,
unitPrice: 0,
price: 216_00,
onDemandPrice: 125,
},
{
events: 0,
unitPrice: 0,
price: 0,
onDemandPrice: 125,
},
],
seerScanner: [
{
events: -2,
unitPrice: 0,
price: 0,
onDemandPrice: 1.25,
},
{
events: 0,
unitPrice: 0,
price: 0,
onDemandPrice: 1.25,
},
],
};

// TODO: Update with correct pricing and structure
const AM2_PLANS: Record<string, Plan> = {
am2_business: {
Expand Down Expand Up @@ -971,6 +916,7 @@ const AM2_PLANS: Record<string, Plan> = {
price: 0,
},
],
...SEER_TIERS_DEVELOPER,
},
budgetTerm: BUDGET_TERM,
availableReservedBudgetTypes: AM2_AVAILABLE_RESERVED_BUDGET_TYPES,
Expand Down Expand Up @@ -1779,6 +1725,7 @@ const AM2_PLANS: Record<string, Plan> = {
price: 0,
},
],
...SEER_TIERS_TRIAL_OR_ENTERPRISE,
},
budgetTerm: BUDGET_TERM,
availableReservedBudgetTypes: AM2_AVAILABLE_RESERVED_BUDGET_TYPES,
Expand Down Expand Up @@ -3187,7 +3134,7 @@ const AM2_PLANS: Record<string, Plan> = {
},
categoryDisplayNames: AM2_CATEGORY_DISPLAY_NAMES,
budgetTerm: BUDGET_TERM,
availableReservedBudgetTypes: AM2_AVAILABLE_RESERVED_BUDGET_TYPES,
availableReservedBudgetTypes: {},
},
am2_sponsored_team_auf: {
id: 'am2_sponsored_team_auf',
Expand Down Expand Up @@ -3226,7 +3173,7 @@ const AM2_PLANS: Record<string, Plan> = {
},
categoryDisplayNames: AM2_CATEGORY_DISPLAY_NAMES,
budgetTerm: BUDGET_TERM,
availableReservedBudgetTypes: AM2_AVAILABLE_RESERVED_BUDGET_TYPES,
availableReservedBudgetTypes: {},
},
am2_business_bundle: {
id: 'am2_business_bundle',
Expand Down Expand Up @@ -3717,6 +3664,7 @@ const AM2_PLANS: Record<string, Plan> = {
price: 0,
},
],
...SEER_TIERS,
},
availableReservedBudgetTypes: AM2_AVAILABLE_RESERVED_BUDGET_TYPES,
},
Expand Down Expand Up @@ -4259,6 +4207,7 @@ const AM2_PLANS: Record<string, Plan> = {
price: 0,
},
],
...SEER_TIERS,
},
availableReservedBudgetTypes: AM2_AVAILABLE_RESERVED_BUDGET_TYPES,
},
Expand Down Expand Up @@ -4816,6 +4765,7 @@ const AM2_PLANS: Record<string, Plan> = {
price: 0,
},
],
...SEER_TIERS,
},
availableReservedBudgetTypes: AM2_AVAILABLE_RESERVED_BUDGET_TYPES,
},
Expand Down Expand Up @@ -4990,6 +4940,7 @@ const AM2_PLANS: Record<string, Plan> = {
price: 0,
},
],
...SEER_TIERS_TRIAL_OR_ENTERPRISE,
},
availableReservedBudgetTypes: AM2_AVAILABLE_RESERVED_BUDGET_TYPES,
},
Expand Down
Loading
Loading