:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(billing): make the cumulative spend green for contract and remove usage/spend pages feature flag (#96832)
Alex Mays10a0df296b9c
diff --git a/ee/api/billing.py b/ee/api/billing.pyindex 97cae1ba93c8..109c7cb6f749 100644--- a/ee/api/billing.py+++ b/ee/api/billing.py@@ -268,9 +268,7 @@ class HasBillingAccess(permissions.BasePermission):class HasBillingUsageSpendReadAccess(permissions.BasePermission):"""- Permission for read-only billing usage/spend endpoints. The frontend additionally requires- usage-spend-dashboards before honoring the member grant, but that flag is not an authorization- input here or in the billing service.+ Permission for read-only billing usage/spend endpoints."""message = "You do not have access to billing usage and spend data for this organization."diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 286ce1ab3a06..e8937b1b318d 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -9601,9 +9601,9 @@ snapshots:scenes-other-billing-billingchart--with-billing-period-marker--light:hash: v1.k794b7964.e972fc46726ce6874dc6adfea01cee14baa536442751c978209ad53e30a06879.4ckO0mLH9CUDcsk6W2YPDWstE_VWVd-wQ__imlTrXWEscenes-other-billing-billingchart--with-cumulative-line--dark:- hash: v1.k794b7964.6fdee520f252041b31c61a4d3f67c0d4effc159accf8cc13b3863367d39c67b6.sP8S7IfryKZybHnT_ToboBSDZraVz4yaMcrqImCmg2I+ hash: v1.k794b7964.525be9426ff7315449e46f06e1a643f6dde1ebd33d1e8ca41d1b9cf55232ea30.wqbBjbSFZlzVTLeUGEE4AgjdSjzwhuWA9-YDeoUoi3Escenes-other-billing-billingchart--with-cumulative-line--light:- hash: v1.k794b7964.72d873cc79a295bcbd001f35600f7360f44e404d8afcd8246eaeb29952ed25ca.tXGdIHisBKN1F8Xy2gBzCwm_AhjJo7wwqDK_d2dmFeE+ hash: v1.k794b7964.35f50c82e1ba030e1aadf6a4b8f33002dcd70c374e45d709d247c27296f6f37e.TTZS1ClqrqNNihu171XHXxOa_kCTtMd_SxqSDMqaaVwscenes-other-billing-billingchart--with-marker-at-range-start--dark:hash: v1.k794b7964.924843ea467d84943495cc8a3056c6f469da31ea69ed097cb485f6348410f77e.8yNuOyhICLuFMdztMSn8zIAYwYnIQWGwSZOF4N7OIVwscenes-other-billing-billingchart--with-marker-at-range-start--light:diff --git a/frontend/src/lib/components/Account/AccountMenu.tsx b/frontend/src/lib/components/Account/AccountMenu.tsxindex a2da2ae1026e..3d4a77612076 100644--- a/frontend/src/lib/components/Account/AccountMenu.tsx+++ b/frontend/src/lib/components/Account/AccountMenu.tsx@@ -198,7 +198,7 @@ export function AccountMenu({ trigger, ...props }: AccountMenuProps): JSX.Elemen}}><IconReceipt />- {featureFlags[FEATURE_FLAGS.USAGE_SPEND_DASHBOARDS] ? 'Billing & Usage' : 'Billing'}+ Billing & Usage</Link></DropdownMenuItem>) : null}diff --git a/frontend/src/lib/components/Account/NewAccountMenu.tsx b/frontend/src/lib/components/Account/NewAccountMenu.tsxindex 90c0659296e5..b585770d4307 100644--- a/frontend/src/lib/components/Account/NewAccountMenu.tsx+++ b/frontend/src/lib/components/Account/NewAccountMenu.tsx@@ -13,11 +13,9 @@ import {IconToggle,} from '@posthog/icons'-import { FEATURE_FLAGS } from 'lib/constants'import { Link } from 'lib/lemon-ui/Link/Link'import { ProfilePicture } from 'lib/lemon-ui/ProfilePicture/ProfilePicture'import { UploadedLogo } from 'lib/lemon-ui/UploadedLogo/UploadedLogo'-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { preflightLogic } from 'lib/logic/preflightLogic'import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'import { DropdownMenuSeparator } from 'lib/ui/DropdownMenu/DropdownMenu'@@ -54,7 +52,6 @@ interface AccountMenuProps {export function NewAccountMenu({ isLayoutNavCollapsed }: AccountMenuProps): JSX.Element {const { user } = useValues(userLogic)const { isCloudOrDev } = useValues(preflightLogic)- const { featureFlags } = useValues(featureFlagLogic)const { showInviteModal } = useActions(inviteLogic)const { reportInviteMembersButtonClicked } = useActions(eventUsageLogic)const { logout } = useActions(userLogic)@@ -320,9 +317,7 @@ export function NewAccountMenu({ isLayoutNavCollapsed }: AccountMenuProps): JSX.}}><IconReceipt />- {featureFlags[FEATURE_FLAGS.USAGE_SPEND_DASHBOARDS]- ? 'Billing & usage'- : 'Billing'}+ Billing & usage</Link>)}/>diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex d61943423dcf..3efe9dbb336f 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -174,7 +174,6 @@ export const FEATURE_FLAGS = {SETTINGS_PERSONS_ON_EVENTS_HIDDEN: 'settings-persons-on-events-hidden', // owner: #team-platform-features, see `SettingsMap.tsx`SUPPORT_MESSAGE_OVERRIDE: 'support-message-override', // owner: #team-support, see `SidePanelSupport.tsx`THEME_OVERRIDE: 'theme', // owner: @aprilfools, see `themeLogic.ts`- USAGE_SPEND_DASHBOARDS: 'usage-spend-dashboards', // owner: #team-billing, see `Billing.tsx`, needed to exclude orgs with more than 100 teams// Holidays overrides, will be around foreverCHRISTMAS_OVERRIDE: 'christmas-override', // owner: #team-growth, overrides the checks for Christmas to return true when this is enableddiff --git a/frontend/src/scenes/billing/Billing.tsx b/frontend/src/scenes/billing/Billing.tsxindex c56a657b1c79..1ea1940e2d4c 100644--- a/frontend/src/scenes/billing/Billing.tsx+++ b/frontend/src/scenes/billing/Billing.tsx@@ -73,7 +73,7 @@ export function Billing(): JSX.Element {})useEffect(() => {- if (location.pathname === urls.organizationBilling() && featureFlags[FEATURE_FLAGS.USAGE_SPEND_DASHBOARDS]) {+ if (location.pathname === urls.organizationBilling()) {// View-only members can't see the Overview tab, so land them on Usage insteadrouter.actions.replace(urls.organizationBillingSection(canOnlyViewUsageAndSpend ? 'usage' : 'overview'),@@ -81,7 +81,7 @@ export function Billing(): JSX.Element {)return}- }, [featureFlags, location.pathname, searchParams, canOnlyViewUsageAndSpend])+ }, [location.pathname, searchParams, canOnlyViewUsageAndSpend])useEffect(() => {if (billing) {diff --git a/frontend/src/scenes/billing/BillingChart.test.tsx b/frontend/src/scenes/billing/BillingChart.test.tsxindex c1bd0fc04738..21984a299ca7 100644--- a/frontend/src/scenes/billing/BillingChart.test.tsx+++ b/frontend/src/scenes/billing/BillingChart.test.tsx@@ -20,6 +20,8 @@ import { BillingChart, orderSeriesForDrawing, runningTotal, type BillingSeriesTyjest.mock('lib/colors', () => ({...jest.requireActual('lib/colors'),getSeriesColor: (index: number) => ['#ff0000', '#0000ff'][index],+ // Likewise a fixed, valid color for the running total, which is drawn in the resolved success color.+ getColorVar: () => '#111111',}))const DATES = ['2026-01-01', '2026-01-02', '2026-01-03']@@ -267,6 +269,9 @@ describe('BillingChart', () => {// (10 + 1) + (20 + 2)const tooltip = createDefaultTooltipAccessor(await hoverUntilTooltip(chart.element, middle, DATES.length))await waitFor(() => expect(tooltip.value(LABEL)).toBe('33'))+ // A concrete color: the canvas cannot resolve a `var()`, and an unresolved color leaves the+ // line and its hover dot in whichever color the series before them used.+ expect(tooltip.swatchColors()[tooltip.rows().indexOf(LABEL)]).toBe('rgb(17, 17, 17)')})it('leaves hidden series out of the running total', async () => {@@ -318,11 +323,10 @@ describe('BillingChart', () => {await waitFor(() => expect(tooltip.value(LABEL)).toBe('12'))})- it('is drawn over lines too, and named under the chart since there is no legend', async () => {+ it('is drawn over lines too', async () => {render(<BillingChart series={SERIES} dates={DATES} hiddenSeries={[]} cumulativeLabel={LABEL} />)await waitFor(() => expect(getHogChart().seriesCount).toBe(3))- expect(await screen.findByText(/Dashed line: cumulative spend/)).toBeTruthy()})it('is not drawn unless asked for', async () => {@@ -331,7 +335,6 @@ describe('BillingChart', () => {const chart = getHogChart()await waitFor(() => expect(chart.seriesCount).toBe(2))expect(chart.hasRightAxis).toBe(false)- expect(screen.queryByText(/Dashed line/)).toBeNull()})})})diff --git a/frontend/src/scenes/billing/BillingChart.tsx b/frontend/src/scenes/billing/BillingChart.tsxindex 7d52d22b3c14..e3be6512fd1c 100644--- a/frontend/src/scenes/billing/BillingChart.tsx+++ b/frontend/src/scenes/billing/BillingChart.tsx@@ -9,7 +9,7 @@ import type {} from '@posthog/quill-charts'import { useChartConfig, useChartTheme } from 'lib/charts/hooks'-import { getSeriesColor } from 'lib/colors'+import { getColorVar, getSeriesColor } from 'lib/colors'import { makeChartErrorHandler } from 'products/product_analytics/frontend/insights/trends/shared/chartErrorHandler'@@ -55,8 +55,15 @@ const NO_MARKERS: BillingPeriodMarker[] = []/** Series keys are stringified ids, so a word cannot collide with one. */const CUMULATIVE_KEY = 'cumulative'const CUMULATIVE_AXIS_ID = 'cumulative'-/** Off the series palette, so it cannot be taken for one of the projects. */-const CUMULATIVE_COLOR = 'var(--text-3000)'++/**+ * A green off the series palette, so the running total cannot be taken for a project.+ * Resolved here: the canvas takes a concrete color, and a `var()` reaches it unresolved, so the+ * line and its hover dot would keep whatever color the series before them used.+ */+function cumulativeColor(): string {+ return getColorVar('success')+}/** The series billing folds the projects beyond the cap into; its label starts with the folded name. */function isFoldedSeries(s: BillingSeriesType): boolean {@@ -135,7 +142,7 @@ export function BillingChart({key: CUMULATIVE_KEY,label: cumulativeLabel,data: runningTotal(visible, dates.length),- color: CUMULATIVE_COLOR,+ color: cumulativeColor(),type: 'line',yAxisId: CUMULATIVE_AXIS_ID,stroke: { pattern: [6, 4] },@@ -221,12 +228,6 @@ export function BillingChart({</TimeSeriesLineChart>)}</div>- {cumulativeLabel && (- // Neither caller shows a legend, so the dashed line has to be named somewhere.- <div className="mt-1 text-xs text-secondary" data-attr="billing-chart-cumulative-note">- Dashed line: {cumulativeLabel.toLowerCase()} across the selected range, against the right-hand axis.- </div>- )}{omittedCount > 0 && (<div className="mt-1 text-xs text-secondary" data-attr="billing-chart-series-cap">Charting the {drawnCount.toLocaleString()} largest series. {omittedCount.toLocaleString()} more arediff --git a/frontend/src/scenes/billing/billing-utils.spec.ts b/frontend/src/scenes/billing/billing-utils.spec.tsindex b159415f83ed..8e1da22b45aa 100644--- a/frontend/src/scenes/billing/billing-utils.spec.ts+++ b/frontend/src/scenes/billing/billing-utils.spec.ts@@ -737,34 +737,18 @@ describe('canViewUsageAndSpend', () => {})describe('isMemberUsageSpendReadAccessEnabled', () => {- // Dropping the usage-spend-dashboards half of this lets a view-only member reach Usage and Spend- // by URL while the account menu and settings sidebar hide Billing from them entirely.it.each<{ case: string; featureFlags: FeatureFlagsSet; expected: boolean }>([{- case: 'both flags are on',- featureFlags: {- [FEATURE_FLAGS.MEMBER_BILLING_USAGE_SPEND_READ_ACCESS]: true,- [FEATURE_FLAGS.USAGE_SPEND_DASHBOARDS]: true,- },+ case: 'the grant is on',+ featureFlags: { [FEATURE_FLAGS.MEMBER_BILLING_USAGE_SPEND_READ_ACCESS]: true },expected: true,},{- case: 'the grant is on but there are no dashboards to reach',- featureFlags: {- [FEATURE_FLAGS.MEMBER_BILLING_USAGE_SPEND_READ_ACCESS]: true,- [FEATURE_FLAGS.USAGE_SPEND_DASHBOARDS]: false,- },+ case: 'the grant is off',+ featureFlags: { [FEATURE_FLAGS.MEMBER_BILLING_USAGE_SPEND_READ_ACCESS]: false },expected: false,},- {- case: 'the dashboards are on but the grant is not',- featureFlags: {- [FEATURE_FLAGS.MEMBER_BILLING_USAGE_SPEND_READ_ACCESS]: false,- [FEATURE_FLAGS.USAGE_SPEND_DASHBOARDS]: true,- },- expected: false,- },- { case: 'neither flag is present', featureFlags: {}, expected: false },+ { case: 'the flag is not present', featureFlags: {}, expected: false },])('returns $expected when $case', ({ featureFlags, expected }) => {expect(isMemberUsageSpendReadAccessEnabled(featureFlags)).toBe(expected)})diff --git a/frontend/src/scenes/billing/billing-utils.ts b/frontend/src/scenes/billing/billing-utils.tsindex 10a23766c517..9fd0178c8a82 100644--- a/frontend/src/scenes/billing/billing-utils.ts+++ b/frontend/src/scenes/billing/billing-utils.ts@@ -457,19 +457,9 @@ export function canAccessBilling(membershipLevel: number | null | undefined, ownreturn membershipLevel >= getMinimumBillingAccessLevel(ownerOnlyBilling)}-/**- * Whether the member-level read grant for usage and spend is in effect.- *- * The grant requires usage-spend-dashboards as well, because the tabbed dashboards are the only- * member-facing usage/spend surface. Honoring the grant without them would leave Usage and Spend- * reachable by URL while the account menu and settings sidebar hide Billing entirely. Admins reach- * usage and spend either way, so the second flag only ever narrows members.- */+/** Whether the member-level read grant for usage and spend is in effect. */export function isMemberUsageSpendReadAccessEnabled(featureFlags: FeatureFlagsSet): boolean {- return (- !!featureFlags[FEATURE_FLAGS.MEMBER_BILLING_USAGE_SPEND_READ_ACCESS] &&- !!featureFlags[FEATURE_FLAGS.USAGE_SPEND_DASHBOARDS]- )+ return !!featureFlags[FEATURE_FLAGS.MEMBER_BILLING_USAGE_SPEND_READ_ACCESS]}/**diff --git a/frontend/src/scenes/billing/billingLogic.test.ts b/frontend/src/scenes/billing/billingLogic.test.tsindex 184035f85fb2..157822ccf425 100644--- a/frontend/src/scenes/billing/billingLogic.test.ts+++ b/frontend/src/scenes/billing/billingLogic.test.ts@@ -242,11 +242,10 @@ describe('billingLogic', () => {it.each<BillingAccessCase>([{- name: 'member with both member-access flags',+ name: 'member with the read grant',membershipLevel: OrganizationMembershipLevel.Member,flags: {[FEATURE_FLAGS.MEMBER_BILLING_USAGE_SPEND_READ_ACCESS]: true,- [FEATURE_FLAGS.USAGE_SPEND_DASHBOARDS]: true,},expected: {canAccessBilling: false,@@ -255,26 +254,11 @@ describe('billingLogic', () => {billingEntryUrl: urls.organizationBillingSection('usage'),},},- {- name: 'member without the dashboards flag',- membershipLevel: OrganizationMembershipLevel.Member,- flags: {- [FEATURE_FLAGS.MEMBER_BILLING_USAGE_SPEND_READ_ACCESS]: true,- [FEATURE_FLAGS.USAGE_SPEND_DASHBOARDS]: false,- },- expected: {- canAccessBilling: false,- canViewUsageAndSpend: false,- canOnlyViewUsageAndSpend: false,- billingEntryUrl: null,- },- },{name: 'admin when owner-only billing is off',membershipLevel: OrganizationMembershipLevel.Admin,flags: {[FEATURE_FLAGS.OWNER_ONLY_BILLING]: false,- [FEATURE_FLAGS.USAGE_SPEND_DASHBOARDS]: true,},expected: {canAccessBilling: true,@@ -288,7 +272,6 @@ describe('billingLogic', () => {membershipLevel: OrganizationMembershipLevel.Admin,flags: {[FEATURE_FLAGS.OWNER_ONLY_BILLING]: true,- [FEATURE_FLAGS.USAGE_SPEND_DASHBOARDS]: true,},expected: {canAccessBilling: false,@@ -302,7 +285,6 @@ describe('billingLogic', () => {membershipLevel: OrganizationMembershipLevel.Owner,flags: {[FEATURE_FLAGS.OWNER_ONLY_BILLING]: true,- [FEATURE_FLAGS.USAGE_SPEND_DASHBOARDS]: true,},expected: {canAccessBilling: true,diff --git a/frontend/src/scenes/billing/billingLogic.tsx b/frontend/src/scenes/billing/billingLogic.tsxindex d5f9c5ada7af..753aba0e8698 100644--- a/frontend/src/scenes/billing/billingLogic.tsx+++ b/frontend/src/scenes/billing/billingLogic.tsx@@ -631,11 +631,7 @@ export interface billingLogicMeta {minimumUsageSpendReadAccessLevel: (featureFlags: FeatureFlagsSet) => OrganizationMembershipLevelcanViewUsageAndSpend: (currentOrganization: OrganizationType | null, featureFlags: FeatureFlagsSet) => booleancanOnlyViewUsageAndSpend: (canViewUsageAndSpend: boolean, canAccessBilling: boolean) => boolean- billingEntryUrl: (- canAccessBilling: boolean,- canOnlyViewUsageAndSpend: boolean,- featureFlags: FeatureFlagsSet- ) => string | null+ billingEntryUrl: (canAccessBilling: boolean, canOnlyViewUsageAndSpend: boolean) => string | nullupgradeLink: (preflight: PreflightStatus | null) => stringisUnlicensedDebug: (preflight: PreflightStatus | null, billing: BillingType | null) => booleansupportPlans: (billing: BillingType | null) => BillingPlanType[]@@ -1106,16 +1102,10 @@ export const billingLogic = kea<billingLogicType>([canViewUsageAndSpend && !canAccessBilling,],billingEntryUrl: [- (s) => [s.canAccessBilling, s.canOnlyViewUsageAndSpend, s.featureFlags],- (- canAccessBilling: boolean,- canOnlyViewUsageAndSpend: boolean,- featureFlags: FeatureFlagsSet- ): string | null => {+ (s) => [s.canAccessBilling, s.canOnlyViewUsageAndSpend],+ (canAccessBilling: boolean, canOnlyViewUsageAndSpend: boolean): string | null => {if (canAccessBilling) {- return featureFlags[FEATURE_FLAGS.USAGE_SPEND_DASHBOARDS]- ? urls.organizationBillingSection('overview')- : urls.organizationBilling()+ return urls.organizationBillingSection('overview')}if (canOnlyViewUsageAndSpend) {return urls.organizationBillingSection('usage')diff --git a/posthog/management/commands/sync_feature_flags.py b/posthog/management/commands/sync_feature_flags.pyindex 7dc2ddb6b3e6..f1cb406a8d50 100644--- a/posthog/management/commands/sync_feature_flags.py+++ b/posthog/management/commands/sync_feature_flags.py@@ -19,7 +19,6 @@ INACTIVE_FLAGS = ["billing-forecasting-issues","session-reset-on-load","support-message-override",- "usage-spend-dashboards","halloween-override","christmas-override","control_support_login",diff --git a/products/billing/frontend/e2e/billing-usage-spend.spec.ts b/products/billing/frontend/e2e/billing-usage-spend.spec.tsindex 0df8f6304407..07b3d776970c 100644--- a/products/billing/frontend/e2e/billing-usage-spend.spec.ts+++ b/products/billing/frontend/e2e/billing-usage-spend.spec.ts@@ -1,9 +1,6 @@-import { mockFeatureFlags } from '@playwright-utils/mockApi'import { PlaywrightWorkspaceSetupResult, expect, test } from '@playwright-utils/workspace-test-base'import { Locator, Page } from '@playwright/test'-import { FEATURE_FLAGS } from 'lib/constants'-import { billingJson } from '~/mocks/fixtures/_billing'/**@@ -192,7 +189,6 @@ test.describe('Billing usage and spend', () => {})test.beforeEach(async ({ page, playwrightSetup }) => {- await mockFeatureFlags(page, { [FEATURE_FLAGS.USAGE_SPEND_DASHBOARDS]: true })await playwrightSetup.login(page, workspace)})