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.

feat(conversations): show plan response time in new ticket placeholder (#74142)

Christiaan Hendriksenb6c673ffb123
diff --git a/frontend/src/layout/navigation-3000/sidepanel/panels/support/SidePanelSupport.tsx b/frontend/src/layout/navigation-3000/sidepanel/panels/support/SidePanelSupport.tsx
index 00cb4efd5979..7d4fa02415fa 100644
--- a/frontend/src/layout/navigation-3000/sidepanel/panels/support/SidePanelSupport.tsx
+++ b/frontend/src/layout/navigation-3000/sidepanel/panels/support/SidePanelSupport.tsx
@@ -7,6 +7,12 @@ import { LemonButton, Link } from '@posthog/lemon-ui'
import { incidentStatusLogic } from 'lib/components/HelpMenu/incidentStatusLogic'
import { SupportForm } from 'lib/components/Support/SupportForm'
import { supportLogic } from 'lib/components/Support/supportLogic'
+import {
+ DEFAULT_PAID_RESPONSE_TIME,
+ PAY_AS_YOU_GO_RESPONSE_TIME,
+ getCurrentSupportPlan,
+ getSupportResponseTimeFeature,
+} from 'lib/components/Support/supportResponseTime'
import { FEATURE_FLAGS } from 'lib/constants'
import { dayjs } from 'lib/dayjs'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
@@ -16,7 +22,7 @@ import { urls } from 'scenes/urls'
import { userLogic } from 'scenes/userLogic'
import { ProductKey } from '~/queries/schema/schema-general'
-import { AvailableFeature, BillingFeatureType, BillingPlan, BillingType, SidePanelTab } from '~/types'
+import { BillingPlan, BillingType, SidePanelTab } from '~/types'
import { SidePanelTickets } from 'products/conversations/frontend/components/SidePanel/SidePanelTickets'
import { sidepanelTicketsLogic } from 'products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic'
@@ -114,37 +120,17 @@ const SupportResponseTimesTable = ({
const { supportPlans, billingPlan } = useValues(billingLogic)
const { user } = useValues(userLogic)
- const knownEnterpriseOrgIds = ['018713f3-8d56-0000-32fa-75ce97e6662f']
- const isKnownEnterpriseOrg = knownEnterpriseOrgIds.includes(user?.organization?.id || '')
-
const hasBoostTrial = billing?.trial?.status === 'active' && billing.trial?.target === 'boost'
const hasScaleTrial = billing?.trial?.status === 'active' && billing.trial?.target === 'scale'
const hasEnterpriseTrial = billing?.trial?.status === 'active' && billing.trial?.target === 'enterprise'
const hasExpiredTrial = billing?.trial?.status === 'expired'
const expiredTrialDate = hasExpiredTrial ? dayjs(billing?.trial?.expires_at) : null
- const getResponseTimeFeature = (planName: string): BillingFeatureType | undefined => {
- // Find the plan in supportPlans
- const plan = supportPlans?.find((p) => p.name?.includes(planName))
-
- // Return the support_response_time feature if found
- return plan?.features?.find((f) => f.key === AvailableFeature.SUPPORT_RESPONSE_TIME)
- }
-
- const getCurrentPlan = (): string => {
- if (isKnownEnterpriseOrg || hasEnterpriseTrial || billingPlan === BillingPlan.Enterprise) {
- return 'enterprise'
- } else if (hasScaleTrial) {
- return 'scale_trial'
- } else if (hasBoostTrial) {
- return 'boost_trial'
- } else if (billingPlan) {
- return billingPlan
- }
- return 'free'
- }
-
- const currentPlan = getCurrentPlan()
+ const currentPlan = getCurrentSupportPlan({
+ billing,
+ billingPlan,
+ organizationId: user?.organization?.id,
+ })
const plansToDisplay: {
name: string
@@ -156,29 +142,31 @@ const SupportResponseTimesTable = ({
}[] = [
{
name: 'Free',
- current_plan: currentPlan === '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 === 'paid',
- features: [{ note: '72 hours' }],
+ current_plan: currentPlan === BillingPlan.Paid,
+ features: [{ note: PAY_AS_YOU_GO_RESPONSE_TIME }],
plan_key: BillingPlan.Paid,
},
{
name: 'Boost',
- current_plan: currentPlan === 'boost',
- features: [getResponseTimeFeature('Boost') || { note: '1 business day' }],
+ 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 === 'teams',
- features: [getResponseTimeFeature('Teams') || { note: '1 business day' }],
+ current_plan: currentPlan === BillingPlan.Teams,
+ features: [
+ getSupportResponseTimeFeature(supportPlans, 'Teams') || { note: DEFAULT_PAID_RESPONSE_TIME },
+ ],
plan_key: BillingPlan.Teams,
legacy_product: true,
},
@@ -186,14 +174,16 @@ const SupportResponseTimesTable = ({
: []),
{
name: 'Scale',
- current_plan: currentPlan === 'scale',
- features: [getResponseTimeFeature('Scale') || { note: '1 business day' }],
+ current_plan: currentPlan === BillingPlan.Scale,
+ features: [getSupportResponseTimeFeature(supportPlans, 'Scale') || { note: DEFAULT_PAID_RESPONSE_TIME }],
plan_key: BillingPlan.Scale,
},
{
name: 'Enterprise',
- current_plan: currentPlan === 'enterprise',
- features: [getResponseTimeFeature('Enterprise') || { note: '1 business day' }],
+ current_plan: currentPlan === BillingPlan.Enterprise,
+ features: [
+ getSupportResponseTimeFeature(supportPlans, 'Enterprise') || { note: DEFAULT_PAID_RESPONSE_TIME },
+ ],
plan_key: BillingPlan.Enterprise,
},
]
@@ -249,7 +239,7 @@ const SupportResponseTimesTable = ({
{(hasBoostTrial || hasScaleTrial || hasEnterpriseTrial) && (
<>
<div className="font-bold border-t">Your trial</div>
- <div className="font-bold border-t text-right">1 business day</div>
+ <div className="font-bold border-t text-right">{DEFAULT_PAID_RESPONSE_TIME}</div>
{billing?.trial?.expires_at && (
<div className="col-span-2 text-sm">
(Trial expires {dayjs(billing.trial.expires_at).format('MMMM D, YYYY')})
diff --git a/frontend/src/lib/components/Support/supportResponseTime.test.ts b/frontend/src/lib/components/Support/supportResponseTime.test.ts
new file mode 100644
index 000000000000..7320e83d83e2
--- /dev/null
+++ b/frontend/src/lib/components/Support/supportResponseTime.test.ts
@@ -0,0 +1,72 @@
+import { AvailableFeature, BillingPlan, BillingPlanType, BillingType } from '~/types'
+
+import { KNOWN_ENTERPRISE_ORG_IDS, SupportPlanContext, getSupportResponseTime } from './supportResponseTime'
+
+const supportPlan = (name: string, note: string): BillingPlanType =>
+ ({
+ name,
+ features: [{ key: AvailableFeature.SUPPORT_RESPONSE_TIME, name: 'Support response time', note }],
+ }) as unknown as BillingPlanType
+
+const trial = (target: 'boost' | 'scale' | 'enterprise', status: 'active' | 'expired' = 'active'): BillingType =>
+ ({ trial: { status, target } }) as unknown as BillingType
+
+describe('getSupportResponseTime', () => {
+ const supportPlans = [
+ supportPlan('Boost', '48 hours'),
+ supportPlan('Scale', '24 hours'),
+ supportPlan('Enterprise', '8 hours'),
+ ]
+
+ it.each<[string, SupportPlanContext, string | null]>([
+ ['free plans get no response time', { billingPlan: BillingPlan.Free, supportPlans }, null],
+ ['nothing when billing has not loaded', {}, null],
+ ['pay-as-you-go gets its fixed target', { billingPlan: BillingPlan.Paid, supportPlans }, '72 hours'],
+ ['boost uses the time published by billing', { billingPlan: BillingPlan.Boost, supportPlans }, '48 hours'],
+ ['scale uses the time published by billing', { billingPlan: BillingPlan.Scale, supportPlans }, '24 hours'],
+ [
+ 'enterprise uses the time published by billing',
+ { billingPlan: BillingPlan.Enterprise, supportPlans },
+ '8 hours',
+ ],
+ ['plans billing publishes no time for get none', { billingPlan: BillingPlan.Teams, supportPlans }, null],
+ [
+ 'paid plan without support plans loaded still gets the fixed target',
+ { billingPlan: BillingPlan.Paid },
+ '72 hours',
+ ],
+ ['boost without support plans loaded gets none', { billingPlan: BillingPlan.Boost }, null],
+ [
+ 'a published value that is not a duration is not promised',
+ { billingPlan: BillingPlan.Scale, supportPlans: [supportPlan('Scale', 'Priority support')] },
+ null,
+ ],
+ [
+ 'active boost trial gets none',
+ { billingPlan: BillingPlan.Free, billing: trial('boost'), supportPlans },
+ null,
+ ],
+ [
+ 'active scale trial gets none',
+ { billingPlan: BillingPlan.Paid, billing: trial('scale'), supportPlans },
+ null,
+ ],
+ [
+ 'active enterprise trial gets none',
+ { billingPlan: BillingPlan.Paid, billing: trial('enterprise'), supportPlans },
+ null,
+ ],
+ [
+ 'expired trial falls back to the actual plan',
+ { billingPlan: BillingPlan.Paid, billing: trial('scale', 'expired'), supportPlans },
+ '72 hours',
+ ],
+ [
+ 'known enterprise org uses the enterprise time',
+ { organizationId: KNOWN_ENTERPRISE_ORG_IDS[0], supportPlans },
+ '8 hours',
+ ],
+ ])('%s', (_name, context, expected) => {
+ expect(getSupportResponseTime(context)).toBe(expected)
+ })
+})
diff --git a/frontend/src/lib/components/Support/supportResponseTime.ts b/frontend/src/lib/components/Support/supportResponseTime.ts
new file mode 100644
index 000000000000..5afec234b5b0
--- /dev/null
+++ b/frontend/src/lib/components/Support/supportResponseTime.ts
@@ -0,0 +1,83 @@
+import { AvailableFeature, BillingFeatureType, BillingPlan, BillingPlanType, BillingType } from '~/types'
+
+export const PAY_AS_YOU_GO_RESPONSE_TIME = '72 hours'
+export const DEFAULT_PAID_RESPONSE_TIME = '1 business day'
+
+export const KNOWN_ENTERPRISE_ORG_IDS = ['018713f3-8d56-0000-32fa-75ce97e6662f']
+
+export type CurrentSupportPlan = BillingPlan | 'boost_trial' | 'scale_trial'
+
+export interface SupportPlanContext {
+ billing?: BillingType | null
+ billingPlan?: BillingPlan | null
+ supportPlans?: BillingPlanType[] | null
+ organizationId?: string | null
+}
+
+export function getCurrentSupportPlan({
+ billing,
+ billingPlan,
+ organizationId,
+}: SupportPlanContext): CurrentSupportPlan {
+ const activeTrialTarget = billing?.trial?.status === 'active' ? billing.trial.target : null
+
+ if (
+ KNOWN_ENTERPRISE_ORG_IDS.includes(organizationId || '') ||
+ activeTrialTarget === 'enterprise' ||
+ billingPlan === BillingPlan.Enterprise
+ ) {
+ return BillingPlan.Enterprise
+ }
+ if (activeTrialTarget === 'scale') {
+ return 'scale_trial'
+ }
+ if (activeTrialTarget === 'boost') {
+ return 'boost_trial'
+ }
+ return billingPlan || BillingPlan.Free
+}
+
+export function getSupportResponseTimeFeature(
+ supportPlans: BillingPlanType[] | null | undefined,
+ planName: string
+): BillingFeatureType | undefined {
+ return supportPlans
+ ?.find((plan) => plan.name?.includes(planName))
+ ?.features?.find((feature) => feature.key === AvailableFeature.SUPPORT_RESPONSE_TIME)
+}
+
+/**
+ * Target support response time for the current plan, using exactly the values the help panel's
+ * response times table shows: the time billing publishes for the plan, or the fixed pay-as-you-go
+ * target. Returns null for free plans, active trials, and plans without a published duration, so
+ * callers can leave the promise out entirely rather than fall back to a made-up one.
+ */
+export function getSupportResponseTime(context: SupportPlanContext): string | null {
+ const activeTrialTarget = context.billing?.trial?.status === 'active' ? context.billing.trial.target : null
+ if (activeTrialTarget === 'boost' || activeTrialTarget === 'scale' || activeTrialTarget === 'enterprise') {
+ return null
+ }
+
+ const fromBilling = (planName: string): string | null => {
+ const note = getSupportResponseTimeFeature(context.supportPlans, planName)?.note?.trim()
+ return note && /^\d/.test(note) ? note : null
+ }
+
+ switch (getCurrentSupportPlan(context)) {
+ case BillingPlan.Enterprise:
+ return fromBilling('Enterprise')
+ case BillingPlan.Scale:
+ return fromBilling('Scale')
+ case BillingPlan.Teams:
+ return fromBilling('Teams')
+ case BillingPlan.Boost:
+ return fromBilling('Boost')
+ case 'scale_trial':
+ case 'boost_trial':
+ return null
+ case BillingPlan.Paid:
+ return PAY_AS_YOU_GO_RESPONSE_TIME
+ case BillingPlan.Free:
+ return null
+ }
+}
diff --git a/products/conversations/frontend/components/SidePanel/NewTicket.tsx b/products/conversations/frontend/components/SidePanel/NewTicket.tsx
index 566cb57db5d1..2031d1008699 100644
--- a/products/conversations/frontend/components/SidePanel/NewTicket.tsx
+++ b/products/conversations/frontend/components/SidePanel/NewTicket.tsx
@@ -7,9 +7,13 @@ import { MessageInput } from '../Chat/MessageInput'
import { sidepanelTicketsLogic } from './sidepanelTicketsLogic'
export function NewTicket(): JSX.Element {
- const { messageSending, newTicketDraft } = useValues(sidepanelTicketsLogic)
+ const { messageSending, newTicketDraft, supportResponseTime } = useValues(sidepanelTicketsLogic)
const { sendMessage, setView } = useActions(sidepanelTicketsLogic)
+ const placeholder = supportResponseTime
+ ? `Describe what you need help with and our support engineers aim to get back to you within ${supportResponseTime}.`
+ : 'Describe what you need help with and our support engineers will get back to you.'
+
return (
<div className="flex flex-col">
<div className="flex items-center gap-2">
@@ -28,7 +32,7 @@ export function NewTicket(): JSX.Element {
<MessageInput
onSendMessage={(content, _richContent, _isPrivate, onSuccess) => sendMessage(content, onSuccess)}
messageSending={messageSending}
- placeholder="Describe what you need help with and our support engineers will get back to you."
+ placeholder={placeholder}
buttonText="Submit ticket"
minRows={4}
draftContent={newTicketDraft}
diff --git a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts
index 7d69f3c3068f..760bbe209038 100644
--- a/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts
+++ b/products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts
@@ -16,6 +16,7 @@ import { subscriptions } from 'kea-subscriptions'
import posthog from 'posthog-js'
import { appendExceptionToMessage, supportLogic, warnIfMessageTooLong } from 'lib/components/Support/supportLogic'
+import { getSupportResponseTime } from 'lib/components/Support/supportResponseTime'
import { FEATURE_FLAGS } from 'lib/constants'
import { EMAIL_SUPPORT_BUTTON, lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
@@ -23,7 +24,7 @@ import { billingLogic } from 'scenes/billing/billingLogic'
import { organizationLogic } from 'scenes/organizationLogic'
import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'
-import type { BillingType } from '~/types'
+import type { BillingPlan, BillingPlanType, BillingType, OrganizationType } from '~/types'
import type {
SupportFormFields,
@@ -61,7 +62,10 @@ function messageToRichContent(message: string): JSONContent {
export interface sidepanelTicketsLogicValues {
billing: BillingType | null // billingLogic
billingLoading: boolean // billingLogic
+ billingPlan: BillingPlan | null // billingLogic
+ supportPlans: BillingPlanType[] // billingLogic
featureFlags: FeatureFlagsSet // featureFlagLogic
+ currentOrganization: OrganizationType | null // organizationLogic
isCurrentOrganizationNew: boolean // organizationLogic
sidePanelOpen: boolean // sidePanelStateLogic
isEmailFormOpen: boolean // supportLogic
@@ -85,6 +89,7 @@ export interface sidepanelTicketsLogicValues {
newTicketDraftRevision: number
restoreError: string | null
restoreState: RestoreFlowState
+ supportResponseTime: string | null
tickets: ConversationTicket[]
ticketsLoading: boolean
totalUnreadCount: number
@@ -194,6 +199,12 @@ export interface sidepanelTicketsLogicMeta {
hasBillingExemption: boolean
) => boolean
isBillingResolved: (billing: BillingType | null, billingLoading: boolean) => boolean
+ supportResponseTime: (
+ billing: BillingType | null,
+ supportPlans: BillingPlanType[],
+ billingPlan: BillingPlan | null,
+ currentOrganization: OrganizationType | null
+ ) => string | null
}
}
@@ -215,9 +226,9 @@ export const sidepanelTicketsLogic = kea<sidepanelTicketsLogicType>([
supportLogic,
['isEmailFormOpen', 'sendSupportRequest', 'pendingViewTicket', 'targetArea'],
billingLogic,
- ['billing', 'billingLoading'],
+ ['billing', 'billingLoading', 'billingPlan', 'supportPlans'],
organizationLogic,
- ['isCurrentOrganizationNew'],
+ ['currentOrganization', 'isCurrentOrganizationNew'],
],
actions: [
supportLogic,
@@ -375,6 +386,21 @@ export const sidepanelTicketsLogic = kea<sidepanelTicketsLogicType>([
(s) => [s.billing, s.billingLoading],
(billing: BillingType | null, billingLoading: boolean): boolean => !billingLoading && billing !== null,
],
+ supportResponseTime: [
+ (s) => [s.billing, s.supportPlans, s.billingPlan, s.currentOrganization],
+ (
+ billing: BillingType | null,
+ supportPlans: BillingPlanType[],
+ billingPlan: BillingPlan | null,
+ currentOrganization: OrganizationType | null
+ ): string | null =>
+ getSupportResponseTime({
+ billing,
+ billingPlan,
+ supportPlans,
+ organizationId: currentOrganization?.id,
+ }),
+ ],
}),
listeners(({ actions, values, cache }) => ({
initTickets: () => {