Skip to content

: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.

fix(frontend): keep billing off the login page and make storybook zod jitless (#115334)

Paul D'Ambra44b2f2d04f09
diff --git a/common/storybook/.storybook/main.ts b/common/storybook/.storybook/main.ts
index 3a507dbd8f4d..b501c9c2715a 100644
--- a/common/storybook/.storybook/main.ts
+++ b/common/storybook/.storybook/main.ts
@@ -4,6 +4,7 @@ import { fileURLToPath } from 'node:url'
import * as path from 'path'
import { mergeConfig, type Rollup } from 'vite'
+import { zodJitlessPlugin } from '../../../frontend/plugins/vite-zod-jitless-plugin.ts'
import { frontendResolvePlugin } from './plugins/vite-frontend-resolve-plugin.ts'
import { moduleGraphPlugin } from './plugins/vite-module-graph-plugin.ts'
import { sqlRawPlugin } from './plugins/vite-sql-raw-plugin.ts'
@@ -70,7 +71,13 @@ const config: StorybookConfig = {
viteFinal: (viteConfig) =>
mergeConfig(viteConfig, {
- plugins: [frontendResolvePlugin(REPO_ROOT), tailwindcss(), sqlRawPlugin(), moduleGraphPlugin(REPO_ROOT)],
+ plugins: [
+ frontendResolvePlugin(REPO_ROOT),
+ tailwindcss(),
+ sqlRawPlugin(),
+ moduleGraphPlugin(REPO_ROOT),
+ zodJitlessPlugin(),
+ ],
resolve: {
dedupe: SINGLETON_PACKAGES,
alias: {
@@ -116,6 +123,9 @@ const config: StorybookConfig = {
// pure ESM, so serving it unbundled is safe, and Vite's build handles the URL
// pattern natively.
exclude: ['@posthog/brand'],
+ rolldownOptions: {
+ plugins: [zodJitlessPlugin()],
+ },
},
build: {
rollupOptions: {
diff --git a/frontend/bin/check-eager-graph.mjs b/frontend/bin/check-eager-graph.mjs
index 50837591ef2a..def6cf7cf2c9 100644
--- a/frontend/bin/check-eager-graph.mjs
+++ b/frontend/bin/check-eager-graph.mjs
@@ -70,10 +70,10 @@ const ROOTS = [
root: LOGGED_OUT_BOOT,
label: 'logged-out boot: index + App + bootApp (preloaded by every page, including /login)',
// The backend preloads the App closure for logged-out pages too (preload-manifest.json
- // `js`), so this is the whole JS cost of /login. 2026-10-11: 3.01 MiB eager output = 2.21 MiB
- // JS (646 files) + 0.80 MiB stable CSS.
+ // `js`), so this is the whole JS cost of /login. 2026-10-12: 2.86 MiB eager output = 2.06 MiB
+ // JS (615 files) + 0.80 MiB stable CSS.
// ~6% headroom so routine churn doesn't trip the warn; ratchet down on a split win.
- budgetBytes: 3_345_000,
+ budgetBytes: 3_180_000,
forbidden: [
'node_modules/monaco-editor/',
// Authenticated-only code. Either of these on the App path means a component that
@@ -91,6 +91,10 @@ const ROOTS = [
// file that builds a schema. Move the zod-free code of that file into its own module, as
// sqlEditorDraftCleanup does for sqlEditorDraftStorage.
'node_modules/zod/',
+ // Billing is for logged-in users, and billingLogic pulls in eventUsageLogic and the credit
+ // purchase UI. A hit means a module on the App path imports billingLogic. Read billing values
+ // from a logic or component that only logged-in pages load.
+ 'src/scenes/billing/billingLogic.tsx',
],
},
{
diff --git a/frontend/src/layout/navigation/projectNoticeLogic.tsx b/frontend/src/layout/navigation/projectNoticeLogic.tsx
index f221e3ab9956..1d3d615752bb 100644
--- a/frontend/src/layout/navigation/projectNoticeLogic.tsx
+++ b/frontend/src/layout/navigation/projectNoticeLogic.tsx
@@ -344,7 +344,7 @@ export type projectNoticeLogicType = MakeLogicType<
export const projectNoticeLogic = kea<projectNoticeLogicType>([
path(['layout', 'navigation', 'projectNoticeLogic']),
connect(() => ({
- logic: [verifyEmailLogic],
+ logic: [verifyEmailLogic, billingLogic],
values: [
membersLogic,
['memberCount'],
diff --git a/frontend/src/lib/components/Support/supportLogic.ts b/frontend/src/lib/components/Support/supportLogic.ts
index 43cf5a045b01..af45b34b1e30 100644
--- a/frontend/src/lib/components/Support/supportLogic.ts
+++ b/frontend/src/lib/components/Support/supportLogic.ts
@@ -6,16 +6,13 @@ import posthog from 'posthog-js'
import { EMAIL_SUPPORT_BUTTON, lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
import { isEmail } from 'lib/utils/url'
-import { billingLogic } from 'scenes/billing/billingLogic'
import { userLogic } from 'scenes/userLogic'
import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'
-import { BillingPlan, BillingPlanType, SidePanelTab, UserType } from '~/types'
+import { SidePanelTab, UserType } from '~/types'
-import type { BillingType } from '../../../types'
import { parseExceptionEvent } from './exceptionUtils'
import { openSupportModal } from './SupportModal'
-import { getSupportResponseTime } from './supportResponseTime'
const SUPPORT_TICKET_KIND_TO_TITLE: Record<SupportTicketKind, string> = {
support: 'Contact support',
@@ -234,9 +231,6 @@ export type SupportFormFields = {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface supportLogicValues {
- billing: BillingType | null // billingLogic
- billingPlan: BillingPlan | null // billingLogic
- supportPlans: BillingPlanType[] // billingLogic
sidePanelAvailable: boolean // sidePanelStateLogic
user: UserType | null // userLogic
isBillingIssue: boolean
@@ -261,7 +255,6 @@ export interface supportLogicValues {
sendSupportRequestTouches: Record<string, boolean>
sendSupportRequestValidationErrors: DeepPartialMap<SupportFormFields, ValidationErrorType>
showSendSupportRequestErrors: boolean
- supportResponseTime: string | null
title: string
}
@@ -353,12 +346,6 @@ export interface supportLogicMeta {
title: (arg: SupportFormFields) => string
isBillingIssue: (sendSupportRequest: SupportFormFields) => boolean
isErrorReport: (sendSupportRequest: SupportFormFields) => boolean
- supportResponseTime: (
- billing: BillingType | null,
- billingPlan: BillingPlan | null,
- supportPlans: BillingPlanType[],
- user: UserType | null
- ) => string | null
}
}
@@ -373,14 +360,7 @@ export const supportLogic = kea<supportLogicType>([
props({} as SupportFormLogicProps),
path(['lib', 'components', 'support', 'supportLogic']),
connect(() => ({
- values: [
- userLogic,
- ['user'],
- billingLogic,
- ['billing', 'billingPlan', 'supportPlans'],
- sidePanelStateLogic,
- ['sidePanelAvailable'],
- ],
+ values: [userLogic, ['user'], sidePanelStateLogic, ['sidePanelAvailable']],
actions: [sidePanelStateLogic, ['openSidePanel', 'setSidePanelOptions']],
})),
actions(() => ({
@@ -473,21 +453,6 @@ export const supportLogic = kea<supportLogicType>([
(s) => [s.sendSupportRequest],
(sendSupportRequest: SupportFormFields) => !!sendSupportRequest.exception_event,
],
- supportResponseTime: [
- (s) => [s.billing, s.billingPlan, s.supportPlans, s.user],
- (
- billing: BillingType | null,
- billingPlan: BillingPlan | null,
- supportPlans: BillingPlanType[],
- user: UserType | null
- ): string | null =>
- getSupportResponseTime({
- billing,
- billingPlan,
- supportPlans,
- organizationId: user?.organization?.id,
- }),
- ],
}),
listeners(({ actions, props, values }) => ({
updateUrlParams: async () => {
diff --git a/frontend/src/lib/lemon-ui/LemonField/LemonField.tsx b/frontend/src/lib/lemon-ui/LemonField/LemonField.tsx
index fe9bc8d1f621..fe1ed8e4dbb7 100644
--- a/frontend/src/lib/lemon-ui/LemonField/LemonField.tsx
+++ b/frontend/src/lib/lemon-ui/LemonField/LemonField.tsx
@@ -6,8 +6,6 @@ import { IconErrorOutline } from 'lib/lemon-ui/icons'
import { LemonLabel } from 'lib/lemon-ui/LemonLabel/LemonLabel'
import { cn } from 'lib/utils/css-classes'
-import { AvailableFeature } from '~/types'
-
export type LemonPureFieldProps = {
/** The label name to be displayed */
label?: React.ReactNode
@@ -31,8 +29,6 @@ export type LemonPureFieldProps = {
htmlFor?: string
/** The class name override for the label */
labelClassName?: string
- /** Shows "locked" icon next to the label, opens payment on click */
- premiumFeature?: AvailableFeature
}
const LemonFieldError = ({ error }: { error: string }): JSX.Element => {
@@ -57,7 +53,6 @@ const LemonPureField = ({
onClick,
renderError,
labelClassName,
- premiumFeature,
}: LemonPureFieldProps): JSX.Element => {
return (
<div
@@ -79,7 +74,6 @@ const LemonPureField = ({
'cursor-pointer': !!onClick,
})}
htmlFor={htmlFor}
- premiumFeature={premiumFeature}
>
{label}
</LemonLabel>
@@ -103,7 +97,6 @@ export const LemonField = ({
info,
renderError,
labelClassName,
- premiumFeature,
htmlFor,
...keaFieldProps
}: LemonFieldProps): JSX.Element => {
@@ -126,7 +119,6 @@ export const LemonField = ({
info={info}
renderError={renderError}
labelClassName={labelClassName}
- premiumFeature={premiumFeature}
htmlFor={inputId}
>
{renderedKids as React.ReactNode}
diff --git a/frontend/src/lib/lemon-ui/LemonLabel/LemonLabel.tsx b/frontend/src/lib/lemon-ui/LemonLabel/LemonLabel.tsx
index c5fc2266ad6c..07ecc501f65c 100644
--- a/frontend/src/lib/lemon-ui/LemonLabel/LemonLabel.tsx
+++ b/frontend/src/lib/lemon-ui/LemonLabel/LemonLabel.tsx
@@ -4,10 +4,6 @@ import clsx from 'clsx'
import { IconInfo } from '@posthog/icons'
-import { PayGateIcon } from 'lib/components/PayGateMini/PayGateButton'
-
-import { AvailableFeature } from '~/types'
-
import { Link, LinkProps } from '../Link'
import { Tooltip } from '../Tooltip'
@@ -20,7 +16,6 @@ export interface LemonLabelProps extends Pick<
showOptional?: boolean
onExplanationClick?: () => void
htmlFor?: string
- premiumFeature?: AvailableFeature
}
export function LemonLabel({
@@ -31,7 +26,6 @@ export function LemonLabel({
onExplanationClick,
infoLink,
htmlFor,
- premiumFeature,
...props
}: LemonLabelProps): JSX.Element {
return (
@@ -57,8 +51,6 @@ export function LemonLabel({
)}
</Tooltip>
) : null}
-
- {premiumFeature && <PayGateIcon feature={premiumFeature} />}
</label>
)
}
diff --git a/frontend/src/scenes/AuthenticatedShell.tsx b/frontend/src/scenes/AuthenticatedShell.tsx
index 66375abcc3cc..714973af6aa3 100644
--- a/frontend/src/scenes/AuthenticatedShell.tsx
+++ b/frontend/src/scenes/AuthenticatedShell.tsx
@@ -11,6 +11,7 @@ import { eventIngestionRestrictionLogic } from 'lib/logic/eventIngestionRestrict
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { isEmbeddedPageFrame } from 'lib/utils/embeddedPageFrame'
import { lazyWithRetry } from 'lib/utils/retryImport'
+import { billingLogic } from 'scenes/billing/billingLogic'
import { WizardHandoffDialog } from 'scenes/onboarding/shared/wizard-sync/WizardHandoffDialog'
import { WizardSyncDebugPanel } from 'scenes/onboarding/shared/wizard-sync/WizardSyncDebugPanel'
import { WizardSyncFab } from 'scenes/onboarding/shared/wizard-sync/WizardSyncFab'
@@ -45,6 +46,8 @@ export default function AuthenticatedShell({ children }: { children: React.React
useMountedLogic(breadcrumbsLogic)
useMountedLogic(globalSetupLogic)
useMountedLogic(webmcpLogic)
+ // Mount billing for the whole session, so billing data and alerts stay loaded when the scene changes.
+ useMountedLogic(billingLogic)
useSetupHighlight()
const { sceneConfig } = useValues(sceneLogic)
diff --git a/frontend/src/scenes/billing/billingLogic.tsx b/frontend/src/scenes/billing/billingLogic.tsx
index c5116a7afafb..34a3b5706c6c 100644
--- a/frontend/src/scenes/billing/billingLogic.tsx
+++ b/frontend/src/scenes/billing/billingLogic.tsx
@@ -8,6 +8,7 @@ import posthog from 'posthog-js'
import { LemonDialog, Link, lemonToast } from '@posthog/lemon-ui'
import api, { getJSONOrNull } from 'lib/api'
+import { getSupportResponseTime } from 'lib/components/Support/supportResponseTime'
import { FEATURE_FLAGS, FeatureFlagKey, OrganizationMembershipLevel } from 'lib/constants'
import { dayjs } from 'lib/dayjs'
import { LemonBannerAction } from 'lib/lemon-ui/LemonBanner/LemonBanner'
@@ -300,6 +301,7 @@ export interface billingLogicValues {
startupProgramLabelCurrent: StartupProgramLabel | null
startupProgramLabelPrevious: StartupProgramLabel | null
supportPlans: BillingPlanType[]
+ supportResponseTime: string | null
switchPlanLoading: string | null
timeRemainingInSeconds: number
timeTotalInSeconds: number
@@ -644,6 +646,12 @@ export interface billingLogicMeta {
) => number
creditDiscount: (computedDiscount: number | null) => number
billingPlan: (billing: BillingType | null) => BillingPlan | null
+ supportResponseTime: (
+ billing: BillingType | null,
+ billingPlan: BillingPlan | null,
+ supportPlans: BillingPlanType[],
+ currentOrganization: OrganizationType | null
+ ) => string | null
startupProgramLabelCurrent: (billing: BillingType | null) => StartupProgramLabel | null
startupProgramLabelPrevious: (billing: BillingType | null) => StartupProgramLabel | null
isAnnualPlanCustomer: (billing: BillingType | null) => boolean
@@ -1204,6 +1212,21 @@ export const billingLogic = kea<billingLogicType>([
(s) => [s.billing],
(billing: BillingType | null): BillingPlan | null => billing?.billing_plan || null,
],
+ supportResponseTime: [
+ (s) => [s.billing, s.billingPlan, s.supportPlans, s.currentOrganization],
+ (
+ billing: BillingType | null,
+ billingPlan: BillingPlan | null,
+ supportPlans: BillingPlanType[],
+ currentOrganization: OrganizationType | null
+ ): string | null =>
+ getSupportResponseTime({
+ billing,
+ billingPlan,
+ supportPlans,
+ organizationId: currentOrganization?.id,
+ }),
+ ],
startupProgramLabelCurrent: [
(s) => [s.billing],
(billing: BillingType | null): StartupProgramLabel | null => billing?.startup_program_label || null,
diff --git a/frontend/src/scenes/billing/paymentEntryLogic.ts b/frontend/src/scenes/billing/paymentEntryLogic.ts
index f25eb565c106..494c767d2f44 100644
--- a/frontend/src/scenes/billing/paymentEntryLogic.ts
+++ b/frontend/src/scenes/billing/paymentEntryLogic.ts
@@ -77,6 +77,7 @@ export type paymentEntryLogicType = MakeLogicType<paymentEntryLogicValues, payme
export const paymentEntryLogic = kea<paymentEntryLogicType>([
path(['scenes', 'billing', 'PaymentEntryLogic']),
connect({
+ logic: [billingLogic],
actions: [userLogic, ['loadUser'], organizationLogic, ['loadCurrentOrganization']],
}),
actions({
diff --git a/frontend/src/scenes/max/TicketPrompt.tsx b/frontend/src/scenes/max/TicketPrompt.tsx
index cbb1b2720d4b..f95f43583c55 100644
--- a/frontend/src/scenes/max/TicketPrompt.tsx
+++ b/frontend/src/scenes/max/TicketPrompt.tsx
@@ -5,6 +5,7 @@ import { LemonButton, LemonInput, LemonModal, lemonToast } from '@posthog/lemon-
import { SupportForm } from 'lib/components/Support/SupportForm'
import { supportLogic } from 'lib/components/Support/supportLogic'
+import { billingLogic } from 'scenes/billing/billingLogic'
import { userLogic } from 'scenes/userLogic'
import { maxThreadLogic } from './maxThreadLogic'
@@ -31,7 +32,8 @@ export function TicketPrompt({ conversationId, traceId, summary, initialText }:
const [hasSubmitted, setHasSubmitted] = useState(false)
const [isSupportModalOpen, setIsSupportModalOpen] = useState(false)
- const { sendSupportRequest, supportResponseTime } = useValues(supportLogic)
+ const { sendSupportRequest } = useValues(supportLogic)
+ const { supportResponseTime } = useValues(billingLogic)
const { resetSendSupportRequest, closeSupportForm } = useActions(supportLogic)
const { appendMessageToConversation } = useActions(maxThreadLogic)
const { user } = useValues(userLogic)
diff --git a/frontend/src/scenes/sceneLogic.tsx b/frontend/src/scenes/sceneLogic.tsx
index 6752287fde5f..f5e4072b6d73 100644
--- a/frontend/src/scenes/sceneLogic.tsx
+++ b/frontend/src/scenes/sceneLogic.tsx
@@ -53,9 +53,7 @@ import { isSharedView } from '~/exporter/exporterViewLogic'
import { FileSystemIconType, ProductKey } from '~/queries/schema/schema-general'
import { AccessControlLevel } from '~/types'
-import type { BillingType } from '../types'
import { handleLoginRedirect } from './authentication/login/loginLogic'
-import { billingLogic } from './billing/billingLogic'
import { parseCouponCampaign } from './coupons/utils'
import { isOnboardingRedirectSuppressed } from './onboarding/legacy/onboardingDelegationState'
import { organizationLogic } from './organizationLogic'
@@ -259,7 +257,6 @@ function withForwardedHashAndSearchParams(
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface sceneLogicValues {
- billing: BillingType | null // billingLogic
featureFlags: FeatureFlagsSet // featureFlagLogic
organizationBeingDeleted: string | null // organizationLogic
activeExportedScene: SceneExport<SceneProps> | null
@@ -418,14 +415,7 @@ export const sceneLogic = kea<sceneLogicType>([
connect(() => ({
logic: [router, userLogic, preflightLogic, teamLogic],
actions: [inviteLogic, ['hideInviteModal']],
- values: [
- billingLogic,
- ['billing'],
- organizationLogic,
- ['organizationBeingDeleted'],
- featureFlagLogic,
- ['featureFlags'],
- ],
+ values: [organizationLogic, ['organizationBeingDeleted'], featureFlagLogic, ['featureFlags']],
})),
afterMount(({ cache }) => {
cache.mountedSceneLogic = null as MountedSceneLogic | null
diff --git a/frontend/src/scenes/surveys/SurveyWidgetCustomization.tsx b/frontend/src/scenes/surveys/SurveyWidgetCustomization.tsx
index 28d4e354539f..c082a049e9b7 100644
--- a/frontend/src/scenes/surveys/SurveyWidgetCustomization.tsx
+++ b/frontend/src/scenes/surveys/SurveyWidgetCustomization.tsx
@@ -2,6 +2,7 @@ import { useActions, useValues } from 'kea'
import { LemonCheckbox, LemonInput, LemonSelect } from '@posthog/lemon-ui'
+import { PayGateIcon } from 'lib/components/PayGateMini/PayGateButton'
import { LemonField } from 'lib/lemon-ui/LemonField'
import { surveyLogic } from 'scenes/surveys/surveyLogic'
@@ -98,9 +99,13 @@ export function SurveyWidgetCustomization(): JSX.Element {
/>
</LemonField.Pure>
<LemonField.Pure
- label="Button position"
+ label={
+ <>
+ Button position
+ <PayGateIcon feature={AvailableFeature.SURVEYS_STYLING} />
+ </>
+ }
className="gap-1 col-span-2"
- premiumFeature={AvailableFeature.SURVEYS_STYLING}
info="Requires at least version 1.294.0 of posthog-js"
>
<div className="flex items-center gap-2">
diff --git a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts
index 05c90b8e5b0b..5ee075aa5bb0 100644
--- a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts
+++ b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts
@@ -83,6 +83,7 @@ function messageToRichContent(message: string): JSONContent {
export interface sidepanelTicketsLogicValues {
billing: BillingType | null // billingLogic
billingLoading: boolean // billingLogic
+ supportResponseTime: string | null // billingLogic
isCurrentOrganizationNew: boolean // organizationLogic
isCloudOrDev: boolean | undefined // preflightLogic
selectedTab: SidePanelTab | null // sidePanelStateLogic
@@ -97,7 +98,6 @@ export interface sidepanelTicketsLogicValues {
status: string
} | null // supportLogic
sendSupportRequest: SupportFormFields // supportLogic
- supportResponseTime: string | null // supportLogic
canCreateTicket: boolean
currentTicket: ConversationTicket | null
filteredTickets: ConversationTicket[]
@@ -253,16 +253,9 @@ export const sidepanelTicketsLogic = kea<sidepanelTicketsLogicType>([
sidePanelStateLogic,
['sidePanelOpen', 'selectedTab', 'selectedTabOptions'],
supportLogic,
- [
- 'isEmailFormOpen',
- 'sendSupportRequest',
- 'pendingViewTicket',
- 'isBillingIssue',
- 'isErrorReport',
- 'supportResponseTime',
- ],
+ ['isEmailFormOpen', 'sendSupportRequest', 'pendingViewTicket', 'isBillingIssue', 'isErrorReport'],
billingLogic,
- ['billing', 'billingLoading'],
+ ['billing', 'billingLoading', 'supportResponseTime'],
organizationLogic,
['isCurrentOrganizationNew'],
preflightLogic,