diff --git a/ee/billing/billing_types.py b/ee/billing/billing_types.py index f65bf988c7625..83cf2f3bae703 100644 --- a/ee/billing/billing_types.py +++ b/ee/billing/billing_types.py @@ -98,7 +98,7 @@ class CustomerInfo(TypedDict): current_total_amount_usd: Optional[str] current_total_amount_usd_after_discount: Optional[str] products: Optional[list[CustomerProduct]] - custom_limits_usd: Optional[dict[str, str]] + custom_limits_usd: Optional[dict[str, str | int]] usage_summary: Optional[dict[str, dict[str, Optional[int]]]] free_trial_until: Optional[str] discount_percent: Optional[int] diff --git a/frontend/__snapshots__/scenes-app-dashboards--insight-legend--light.png b/frontend/__snapshots__/scenes-app-dashboards--insight-legend--light.png index 4cc1ac52455a8..c067fa7a5cd00 100644 Binary files a/frontend/__snapshots__/scenes-app-dashboards--insight-legend--light.png and b/frontend/__snapshots__/scenes-app-dashboards--insight-legend--light.png differ diff --git a/frontend/__snapshots__/scenes-app-insights--funnel-top-to-bottom-edit--dark.png b/frontend/__snapshots__/scenes-app-insights--funnel-top-to-bottom-edit--dark.png index 1912f55d0ffa8..d83ed27fe8dca 100644 Binary files a/frontend/__snapshots__/scenes-app-insights--funnel-top-to-bottom-edit--dark.png and b/frontend/__snapshots__/scenes-app-insights--funnel-top-to-bottom-edit--dark.png differ diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx index 0fdbccfcb1435..64f4ac0cc2489 100644 --- a/frontend/src/lib/constants.tsx +++ b/frontend/src/lib/constants.tsx @@ -137,7 +137,6 @@ export const WEBHOOK_SERVICES: Record = { export const FEATURE_FLAGS = { // Experiments / beta features FUNNELS_CUE_OPT_OUT: 'funnels-cue-opt-out-7301', // owner: @neilkakkar - BILLING_LIMIT: 'billing-limit', // owner: @timgl KAFKA_INSPECTOR: 'kafka-inspector', // owner: @yakkomajuri HISTORICAL_EXPORTS_V2: 'historical-exports-v2', // owner @macobo PERSON_ON_EVENTS_ENABLED: 'person-on-events-enabled', //owner: @EDsCODE diff --git a/frontend/src/scenes/billing/billingLogic.tsx b/frontend/src/scenes/billing/billingLogic.tsx index 964c00e3ee1c7..ad74c76f34e60 100644 --- a/frontend/src/scenes/billing/billingLogic.tsx +++ b/frontend/src/scenes/billing/billingLogic.tsx @@ -190,7 +190,7 @@ export const billingLogic = kea([ return parseBillingResponse(response) }, - updateBillingLimits: async (limits: { [key: string]: string | null }) => { + updateBillingLimits: async (limits: { [key: string]: string | number | null }) => { const response = await api.update('api/billing', { custom_limits_usd: limits }) lemonToast.success('Billing limits updated') @@ -304,12 +304,12 @@ export const billingLogic = kea([ } let projectedTotal = 0 for (const product of billing.products || []) { - const billingLimit: string = + const billingLimit = billing?.custom_limits_usd?.[product.type] || - (product.usage_key ? billing?.custom_limits_usd?.[product.usage_key] || '0' : '0') + (product.usage_key ? billing?.custom_limits_usd?.[product.usage_key] || 0 : 0) projectedTotal += Math.min( parseFloat(product.projected_amount_usd || '0'), - parseFloat(billingLimit) + typeof billingLimit === 'number' ? billingLimit : parseFloat(billingLimit) ) } return projectedTotal diff --git a/frontend/src/scenes/billing/billingProductLogic.ts b/frontend/src/scenes/billing/billingProductLogic.ts index 2e03dda6c1d3c..4dee8a669fe9a 100644 --- a/frontend/src/scenes/billing/billingProductLogic.ts +++ b/frontend/src/scenes/billing/billingProductLogic.ts @@ -148,7 +148,7 @@ export const billingProductLogic = kea([ (billing, product) => { return ( billing?.custom_limits_usd?.[product.type] || - (product.usage_key ? billing?.custom_limits_usd?.[product.usage_key] : '') + (product.usage_key ? billing?.custom_limits_usd?.[product.usage_key] : null) ) }, ], @@ -197,7 +197,11 @@ export const billingProductLogic = kea([ productAndAddonTiers, billing?.discount_percent ) - : convertAmountToUsage(customLimitUsd || '', productAndAddonTiers, billing?.discount_percent) + : convertAmountToUsage( + typeof customLimitUsd === 'number' ? `${customLimitUsd}` : customLimitUsd || '', + productAndAddonTiers, + billing?.discount_percent + ) : 0 }, ], @@ -252,7 +256,11 @@ export const billingProductLogic = kea([ actions.setIsEditingBillingLimit(false) actions.setBillingLimitInput( values.customLimitUsd - ? parseInt(values.customLimitUsd) + ? parseInt( + typeof values.customLimitUsd === 'number' + ? `${values.customLimitUsd}` + : values.customLimitUsd || '' + ) : props.product.tiers && parseInt(props.product.projected_amount_usd || '0') ? parseInt(props.product.projected_amount_usd || '0') * 1.5 : DEFAULT_BILLING_LIMIT @@ -368,7 +376,7 @@ export const billingProductLogic = kea([ return } actions.updateBillingLimits({ - [props.product.type]: typeof input === 'number' ? `${input}` : null, + [props.product.type]: input, }) }, options: { diff --git a/frontend/src/types.ts b/frontend/src/types.ts index ceede7bd84355..d0bf6433cfdd9 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -1584,7 +1584,7 @@ export interface BillingType { products: BillingProductV2Type[] custom_limits_usd?: { - [key: string]: string | null | undefined + [key: string]: string | number | null | undefined } billing_period?: { current_period_start: Dayjs