: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
refactor(support): share the support plan rows between side panels (#119011)
Adam Leith52f223dfc22e
diff --git a/frontend/src/layout/navigation-3000/sidepanel/panels/support/SidePanelSupport.tsx b/frontend/src/layout/navigation-3000/sidepanel/panels/support/SidePanelSupport.tsxindex a7c1d0ea238c..97054552242a 100644--- a/frontend/src/layout/navigation-3000/sidepanel/panels/support/SidePanelSupport.tsx+++ b/frontend/src/layout/navigation-3000/sidepanel/panels/support/SidePanelSupport.tsx@@ -5,12 +5,7 @@ import { IconExpand45, IconFeatures, IconHelmet, IconMap, IconWarning } from '@pimport { LemonButton, Link } from '@posthog/lemon-ui'import { incidentStatusLogic } from 'lib/components/HelpMenu/incidentStatusLogic'-import {- DEFAULT_PAID_RESPONSE_TIME,- PAY_AS_YOU_GO_RESPONSE_TIME,- getCurrentSupportPlan,- getSupportResponseTimeFeature,-} from 'lib/components/Support/supportResponseTime'+import { DEFAULT_PAID_RESPONSE_TIME, getSupportPlanRows } from 'lib/components/Support/supportResponseTime'import { FEATURE_FLAGS } from 'lib/constants'import { dayjs } from 'lib/dayjs'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'@@ -124,86 +119,28 @@ const SupportResponseTimesTable = ({const hasExpiredTrial = billing?.trial?.status === 'expired'const expiredTrialDate = hasExpiredTrial ? dayjs(billing?.trial?.expires_at) : null- const currentPlan = getCurrentSupportPlan({+ const plansToDisplay = getSupportPlanRows({billing,billingPlan,+ supportPlans,organizationId: user?.organization?.id,})- const plansToDisplay: {- name: string- current_plan: boolean | undefined- features: any[]- plan_key: string- link?: string- legacy_product?: boolean | null- }[] = [- {- name: 'Free',- current_plan: currentPlan === BillingPlan.Free,- features: [{ note: 'Community support only' }],- plan_key: BillingPlan.Free,- link: 'https://posthog.com/questions',- },- {- name: 'Pay-as-you-go',- current_plan: currentPlan === BillingPlan.Paid,- features: [{ note: PAY_AS_YOU_GO_RESPONSE_TIME }],- plan_key: BillingPlan.Paid,- },- {- name: 'Boost',- current_plan: currentPlan === BillingPlan.Boost,- features: [getSupportResponseTimeFeature(supportPlans, 'Boost') || { note: DEFAULT_PAID_RESPONSE_TIME }],- plan_key: BillingPlan.Boost,- },- ...(billingPlan === BillingPlan.Teams- ? [- {- name: 'Teams',- current_plan: currentPlan === BillingPlan.Teams,- features: [- getSupportResponseTimeFeature(supportPlans, 'Teams') || { note: DEFAULT_PAID_RESPONSE_TIME },- ],- plan_key: BillingPlan.Teams,- legacy_product: true,- },- ]- : []),- {- name: 'Scale',- current_plan: currentPlan === BillingPlan.Scale,- features: [getSupportResponseTimeFeature(supportPlans, 'Scale') || { note: DEFAULT_PAID_RESPONSE_TIME }],- plan_key: BillingPlan.Scale,- },- {- name: 'Enterprise',- current_plan: currentPlan === BillingPlan.Enterprise,- features: [- getSupportResponseTimeFeature(supportPlans, 'Enterprise') || { note: DEFAULT_PAID_RESPONSE_TIME },- ],- plan_key: BillingPlan.Enterprise,- },- ]-return (<div className="grid grid-cols-2 border rounded *:px-2 *:py-0.5 bg-surface-primary mb-2">{plansToDisplay.map((plan, index) => {- const isBold = plan.current_plan-- const responseNote = plan.features.find((f: any) => f.note)?.note+ const isBold = plan.isCurrentPlan+ const responseNote = plan.responseTimereturn (- <React.Fragment key={plan.plan_key}>+ <React.Fragment key={plan.key}><divclassName={`${index > 0 ? 'border-t' : ''} col-span-1 ${isBold ? 'font-semibold' : ''}`}data-attr="support-plan-name"><span className={`${isCompact ? '' : 'text-sm'}`}>{plan.name}- {plan.legacy_product && (- <span className="text-muted text-xs font-normal"> (legacy)</span>- )}+ {plan.legacy && <span className="text-muted text-xs font-normal"> (legacy)</span>}{isBold && ' '}{isBold && <span className="text-muted text-xs font-normal">(your plan)</span>}</span>diff --git a/frontend/src/lib/components/Support/supportResponseTime.ts b/frontend/src/lib/components/Support/supportResponseTime.tsindex 5afec234b5b0..790854ea9c13 100644--- a/frontend/src/lib/components/Support/supportResponseTime.ts+++ b/frontend/src/lib/components/Support/supportResponseTime.ts@@ -81,3 +81,68 @@ export function getSupportResponseTime(context: SupportPlanContext): string | nureturn null}}++export interface SupportPlanRow {+ key: string+ name: string+ isCurrentPlan: boolean+ /** Null when billing lists the plan's response time feature without a note. */+ responseTime: string | null+ /** Where a plan without a response time points instead, e.g. the community forum. */+ link?: string+ legacy?: boolean+}++/** The rows of the help panel's support response times table, one per plan, with the current plan marked. */+export function getSupportPlanRows(context: SupportPlanContext): SupportPlanRow[] {+ const currentPlan = getCurrentSupportPlan(context)+ const paidResponseTime = (planName: string): string | null => {+ const feature = getSupportResponseTimeFeature(context.supportPlans, planName)+ return feature ? (feature.note ?? null) : DEFAULT_PAID_RESPONSE_TIME+ }++ return [+ {+ key: BillingPlan.Free,+ name: 'Free',+ isCurrentPlan: currentPlan === BillingPlan.Free,+ responseTime: 'Community support only',+ link: 'https://posthog.com/questions',+ },+ {+ key: BillingPlan.Paid,+ name: 'Pay-as-you-go',+ isCurrentPlan: currentPlan === BillingPlan.Paid,+ responseTime: PAY_AS_YOU_GO_RESPONSE_TIME,+ },+ {+ key: BillingPlan.Boost,+ name: 'Boost',+ isCurrentPlan: currentPlan === BillingPlan.Boost,+ responseTime: paidResponseTime('Boost'),+ },+ ...(context.billingPlan === BillingPlan.Teams+ ? [+ {+ key: BillingPlan.Teams,+ name: 'Teams',+ isCurrentPlan: currentPlan === BillingPlan.Teams,+ responseTime: paidResponseTime('Teams'),+ legacy: true,+ },+ ]+ : []),+ {+ key: BillingPlan.Scale,+ name: 'Scale',+ isCurrentPlan: currentPlan === BillingPlan.Scale,+ responseTime: paidResponseTime('Scale'),+ },+ {+ key: BillingPlan.Enterprise,+ name: 'Enterprise',+ isCurrentPlan: currentPlan === BillingPlan.Enterprise,+ responseTime: paidResponseTime('Enterprise'),+ },+ ]+}