: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): redirect bare /billing to organization billing (#87522)
posthog[bot]cf28e036c1f1
diff --git a/frontend/src/lib/utils/kea-router.test.ts b/frontend/src/lib/utils/kea-router.test.tsindex 62545ef1b7eb..a3a19dd5362f 100644--- a/frontend/src/lib/utils/kea-router.test.ts+++ b/frontend/src/lib/utils/kea-router.test.ts@@ -37,6 +37,10 @@ describe('router-utils', () => {const altered = addProjectIdIfMissing('/feature_flags/staff/cohorts', 123)expect(altered).toEqual('/feature_flags/staff/cohorts')})+ it('does not add a project id to billing URLs, which are organization-scoped', () => {+ expect(addProjectIdIfMissing('/billing', 123)).toEqual('/billing')+ expect(addProjectIdIfMissing('/billing/authorization_status', 123)).toEqual('/billing/authorization_status')+ })describe('relative path normalization', () => {it('normalizes ../ prefix to absolute path with project id', () => {diff --git a/frontend/src/lib/utils/kea-router.ts b/frontend/src/lib/utils/kea-router.tsindex 3958301934ff..3fa8d697b9f5 100644--- a/frontend/src/lib/utils/kea-router.ts+++ b/frontend/src/lib/utils/kea-router.ts@@ -7,6 +7,7 @@ const pathsWithoutProjectId = ['me','instance','organization',+ 'billing','preflight','login','signup',diff --git a/frontend/src/scenes/sceneLogic.test.tsx b/frontend/src/scenes/sceneLogic.test.tsxindex 88628733aef3..c6b18a70b77f 100644--- a/frontend/src/scenes/sceneLogic.test.tsx+++ b/frontend/src/scenes/sceneLogic.test.tsx@@ -81,6 +81,18 @@ describe('sceneLogic', () => {expect(removeProjectIdIfPresent(router.values.location.pathname)).toEqual(urls.featureFlag('123'))})+ it('redirects a bare /billing to /organization/billing instead of a 404', async () => {+ router.actions.push('/billing')+ await expectLogic(logic).delay(1)+ expect(removeProjectIdIfPresent(router.values.location.pathname)).toEqual(urls.organizationBilling())+ })++ it('keeps /billing/authorization_status on its own scene route, not the billing redirect', async () => {+ router.actions.push(urls.billingAuthorizationStatus())+ await expectLogic(logic).delay(1)+ expect(removeProjectIdIfPresent(router.values.location.pathname)).toEqual(urls.billingAuthorizationStatus())+ })+it('redirects /project/new to the create-project flow instead of a 404', async () => {router.actions.push('/project/new')await expectLogic(logic).delay(1)diff --git a/frontend/src/scenes/scenes.ts b/frontend/src/scenes/scenes.tsindex 204c6619f059..b43864ba5938 100644--- a/frontend/src/scenes/scenes.ts+++ b/frontend/src/scenes/scenes.ts@@ -646,6 +646,9 @@ export const redirects: Record<'/annotations/:id': ({ id }) => urls.annotation(id),'/batch_exports/:id': ({ id }) => urls.batchExport(id),'/batch_exports': urls.destinations(),+ // Billing lives at /organization/billing. A bare /billing has no scene, so send it there.+ // /billing/authorization_status keeps its own scene route, so it must not be caught here.+ '/billing': urls.organizationBilling(),// The scene lives at /code-review (hyphen); catch the old underscore variant, keeping the// ?review= / ?reviews_scope= deep links that PR status comments bake in'/code_review': (_params, searchParams, hashParams) => combineUrl(urls.codeReview(), searchParams, hashParams).url,