: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
feat(product-analytics): quill insight type tabs and a collapsible description (#130004)
Sam Pennington8a7261f5d564
diff --git a/frontend/src/layout/scenes/components/QuillSceneName.tsx b/frontend/src/layout/scenes/components/QuillSceneName.tsxindex 5d8be8f9e4f8..9b2ab65d6dd5 100644--- a/frontend/src/layout/scenes/components/QuillSceneName.tsx+++ b/frontend/src/layout/scenes/components/QuillSceneName.tsx@@ -17,6 +17,8 @@ export interface QuillSceneNameProps {onGenerateMetadata?: () => voidisGeneratingMetadata?: booleansuffix?: ReactNode+ /** Shown after the open field, where `suffix` is hidden. */+ fieldSuffix?: ReactNodeeditDataAttr?: string}@@ -34,6 +36,7 @@ export function QuillSceneName({onGenerateMetadata,isGeneratingMetadata = false,suffix,+ fieldSuffix,editDataAttr = 'scene-name-edit',}: QuillSceneNameProps): JSX.Element {const { name, isEditing, containerRef, startEditing, change, blur, saveFromEnter, cancel } = useSceneNameEditing({@@ -59,7 +62,12 @@ export function QuillSceneName({if (editable && isEditing) {return (- <div ref={containerRef} className="flex min-w-0 flex-1 items-center gap-1" data-attr="scene-name-edit-row">+ <div+ ref={containerRef}+ onBlur={blur}+ className="flex min-w-0 flex-1 items-center gap-1"+ data-attr="scene-name-edit-row"+ ><Inputaria-label="Name"name="name"@@ -67,7 +75,6 @@ export function QuillSceneName({readOnly={isGeneratingMetadata}placeholder="Enter name"onChange={(event: React.ChangeEvent<HTMLInputElement>) => change(event.target.value)}- onBlur={blur}onKeyDown={(event: React.KeyboardEvent<HTMLInputElement>) => {if (event.key === 'Enter') {event.preventDefault()@@ -104,6 +111,7 @@ export function QuillSceneName({</TooltipContent></Tooltip>)}+ {fieldSuffix}</div>)}diff --git a/frontend/src/layout/scenes/components/QuillSceneTitleSection.tsx b/frontend/src/layout/scenes/components/QuillSceneTitleSection.tsxindex 4e42cca2df07..524ad3dc5860 100644--- a/frontend/src/layout/scenes/components/QuillSceneTitleSection.tsx+++ b/frontend/src/layout/scenes/components/QuillSceneTitleSection.tsx@@ -34,6 +34,7 @@ export function QuillSceneTitleSection({canEdit = false,forceEdit = false,descriptionAlwaysVisible = false,+ descriptionIgnoresForceEdit = false,renameDebounceMs,saveOnBlur = false,noPadding = false,@@ -59,10 +60,22 @@ export function QuillSceneTitleSection({[releaseStageSceneId, name])const staticName = name !== null && !titleInPhoneHeader && !(onNameChange && canEdit) && !forceEdit && !isLoading+ const descriptionForceEdit = forceEdit && !descriptionIgnoresForceEditconst hasDescription = description != null && (description || canEdit)const descriptionShown =hasDescription &&- (descriptionAlwaysVisible || (showDescription && !titleInPhoneHeader && !staticName) || forceEdit)+ (descriptionAlwaysVisible || (showDescription && !titleInPhoneHeader && !staticName) || descriptionForceEdit)+ const descriptionToggle = hasDescription && !descriptionAlwaysVisible && (+ <Button+ variant="default"+ size="icon-sm"+ aria-label={showDescription ? 'Hide description' : 'Show description'}+ onClick={toggleShowDescription}+ data-attr={showDescription ? 'toggle-description-button-collapse' : 'toggle-description-button-expand'}+ >+ {showDescription || descriptionForceEdit ? <IconCollapse /> : <IconExpand />}+ </Button>+ )const backTo = forceBackTo || (breadcrumbs.length > 2 ? breadcrumbs[breadcrumbs.length - 2] : undefined)const backPath = !titleInPhoneHeader && backTo && 'path' in backTo ? backTo.path : undefinedconst resourceIcon = name !== null && !titleInPhoneHeader ? sceneResourceIcon(resourceType) : undefined@@ -120,24 +133,11 @@ export function QuillSceneTitleSection({saveOnBlur={saveOnBlur}onGenerateMetadata={onGenerateMetadata}isGeneratingMetadata={isGeneratingMetadata}+ fieldSuffix={descriptionIgnoresForceEdit && descriptionToggle}suffix={<>{nameSuffixes}- {hasDescription && !descriptionAlwaysVisible && (- <Button- variant="default"- size="icon-sm"- aria-label={showDescription ? 'Hide description' : 'Show description'}- onClick={toggleShowDescription}- data-attr={- showDescription- ? 'toggle-description-button-collapse'- : 'toggle-description-button-expand'- }- >- {showDescription || forceEdit ? <IconCollapse /> : <IconExpand />}- </Button>- )}+ {descriptionToggle}</>}/>@@ -165,7 +165,7 @@ export function QuillSceneTitleSection({isLoading={isLoading}onChange={onDescriptionChange}canEdit={canEdit}- forceEdit={forceEdit}+ forceEdit={descriptionForceEdit}renameDebounceMs={renameDebounceMs}saveOnBlur={saveOnBlur}maxLength={descriptionMaxLength}diff --git a/frontend/src/layout/scenes/components/SceneTitleSection.tsx b/frontend/src/layout/scenes/components/SceneTitleSection.tsxindex fda93020ebb0..c8ee6f40e8ab 100644--- a/frontend/src/layout/scenes/components/SceneTitleSection.tsx+++ b/frontend/src/layout/scenes/components/SceneTitleSection.tsx@@ -75,6 +75,8 @@ export type SceneMainTitleProps = {* If true, the description is always rendered and the show/hide toggle is omitted*/descriptionAlwaysVisible?: boolean+ /** Only the rail navigation honours it. */+ descriptionIgnoresForceEdit?: boolean/*** The number of milliseconds to debounce the name and description changes* useful for renaming resources that update too fastdiff --git a/products/product_analytics/frontend/insights/InsightNav/insightNavLogic.tsx b/products/product_analytics/frontend/insights/InsightNav/insightNavLogic.tsxindex 82bcc7ce0f4c..eba292d99e41 100644--- a/products/product_analytics/frontend/insights/InsightNav/insightNavLogic.tsx+++ b/products/product_analytics/frontend/insights/InsightNav/insightNavLogic.tsx@@ -3,7 +3,6 @@ import { router } from 'kea-router'import { FEATURE_FLAGS } from 'lib/constants'import { keyForInsightLogicProps } from 'lib/insights/sharedUtils'-import { LemonTag } from 'lib/lemon-ui/LemonTag'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import type { FeatureFlagsSet } from 'lib/logic/featureFlagLogic'import { identifierToHuman } from 'lib/utils/strings'@@ -96,9 +95,10 @@ import { PRODUCT_ANALYTICS_DEFAULT_QUERY_TAGS } from 'products/product_analyticsimport { expandGroupNodes } from './expandGroupNodes'export interface Tab {- label: string | JSX.Element+ label: stringtype: InsightTypedataAttr: string+ beta?: boolean}type OmitConflictingProperties<T> = Omit<T, 'resultCustomizations'>@@ -691,11 +691,8 @@ export const insightNavLogic = kea<insightNavLogicType>([// Visible when flagged or when viewing an existing journeys insight, so links never dead-endif (featureFlags[FEATURE_FLAGS.PRODUCT_ANALYTICS_PATHS_V2] || activeView === InsightType.JOURNEYS) {tabs.push({- label: (- <>- Journeys <LemonTag type="warning">BETA</LemonTag>- </>- ),+ label: 'Journeys',+ beta: true,type: InsightType.JOURNEYS,dataAttr: 'insight-journeys-tab',})@@ -716,7 +713,7 @@ export const insightNavLogic = kea<insightNavLogicType>([if (featureFlags[FEATURE_FLAGS.HOG] || activeView === InsightType.HOG) {tabs.push({- label: <>Hog 🦔</>,+ label: 'Hog 🦔',type: InsightType.HOG,dataAttr: 'insight-hog-tab',})diff --git a/products/product_analytics/frontend/insights/insightScene/InsightPageHeader.tsx b/products/product_analytics/frontend/insights/insightScene/InsightPageHeader.tsxindex b8aec5b5881c..8144dc1207bd 100644--- a/products/product_analytics/frontend/insights/insightScene/InsightPageHeader.tsx+++ b/products/product_analytics/frontend/insights/insightScene/InsightPageHeader.tsx@@ -148,6 +148,7 @@ export function InsightPageHeader({ insightLogicProps }: { insightLogicProps: InrenameDebounceMs={0}saveOnBlur={insightMode !== ItemMode.Edit}descriptionMaxLength={400}+ descriptionIgnoresForceEditmaxToolProps={readDataMaxToolProps}actions={todayRailNav ? (diff --git a/products/product_analytics/frontend/insights/insightScene/InsightsNav.tsx b/products/product_analytics/frontend/insights/insightScene/InsightsNav.tsxindex fabc27982719..a33959ef7078 100644--- a/products/product_analytics/frontend/insights/insightScene/InsightsNav.tsx+++ b/products/product_analytics/frontend/insights/insightScene/InsightsNav.tsx@@ -1,48 +1,69 @@import { useActions, useValues } from 'kea'import posthog from 'posthog-js'+import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'import { LemonTabs } from 'lib/lemon-ui/LemonTabs'+import { LemonTag } from 'lib/lemon-ui/LemonTag'import { Link } from 'lib/lemon-ui/Link'import { Tooltip } from 'lib/lemon-ui/Tooltip'import { insightLogic } from 'scenes/insights/insightLogic'import { INSIGHT_TYPE_URLS } from 'scenes/insights/utils'import { INSIGHT_TYPES_METADATA } from 'scenes/saved-insights/insightTypesMetadata'+import { InsightType } from '~/types'+import { AlertDeletionWarning } from 'products/alerts/frontend/components/AlertDeletionWarning'import { insightNavLogic } from 'products/product_analytics/frontend/insights/InsightNav/insightNavLogic'+import { QuillInsightsNav } from './QuillInsightsNav'+export function InsightsNav(): JSX.Element {const { insightProps, insight } = useValues(insightLogic)const { activeView, tabs } = useValues(insightNavLogic(insightProps))const { setActiveView } = useActions(insightNavLogic(insightProps))+ const todayRailNav = useFeatureFlag('TODAY_RAIL_NAV')++ const onChange = (newKey: InsightType): void => {+ posthog.capture('insight type tab clicked', { insight_type: newKey, previous_type: activeView })+ setActiveView(newKey)+ }return (<>{insight.short_id && <AlertDeletionWarning />}- <LemonTabs- activeKey={activeView}- onChange={(newKey) => {- posthog.capture('insight type tab clicked', { insight_type: newKey, previous_type: activeView })- setActiveView(newKey)- }}- tabs={tabs.map(({ label, type, dataAttr }) => ({- key: type,- label: (- <Link to={INSIGHT_TYPE_URLS[type]} preventClick data-attr={dataAttr}>- <Tooltip- placement="top"- title={- INSIGHT_TYPES_METADATA[type].tooltipDescription ||- INSIGHT_TYPES_METADATA[type].description- }- docLink={INSIGHT_TYPES_METADATA[type].tooltipDocLink}- >- <span>{label}</span>- </Tooltip>- </Link>- ),- }))}- />+ {todayRailNav ? (+ <QuillInsightsNav tabs={tabs} activeView={activeView} onChange={onChange} />+ ) : (+ <LemonTabs+ activeKey={activeView}+ onChange={onChange}+ tabs={tabs.map(({ label, type, dataAttr, beta }) => ({+ key: type,+ label: (+ <Link to={INSIGHT_TYPE_URLS[type]} preventClick data-attr={dataAttr}>+ <Tooltip+ placement="top"+ title={+ INSIGHT_TYPES_METADATA[type].tooltipDescription ||+ INSIGHT_TYPES_METADATA[type].description+ }+ docLink={INSIGHT_TYPES_METADATA[type].tooltipDocLink}+ >+ <span>+ {label}+ {beta && (+ <>+ {' '}+ <LemonTag type="warning">BETA</LemonTag>+ </>+ )}+ </span>+ </Tooltip>+ </Link>+ ),+ }))}+ />+ )}</>)}diff --git a/products/product_analytics/frontend/insights/insightScene/QuillInsightsNav.tsx b/products/product_analytics/frontend/insights/insightScene/QuillInsightsNav.tsxnew file mode 100644index 000000000000..746d387d117a--- /dev/null+++ b/products/product_analytics/frontend/insights/insightScene/QuillInsightsNav.tsx@@ -0,0 +1,68 @@+import { Badge, Tabs, TabsList, TabsTrigger, Tooltip, TooltipContent, TooltipTrigger } from '@posthog/quill'++import { LinkPrimitive } from 'lib/lemon-ui/Link'+import { INSIGHT_TYPE_URLS } from 'scenes/insights/utils'+import { INSIGHT_TYPES_METADATA } from 'scenes/saved-insights/insightTypesMetadata'++import { InsightType } from '~/types'++import type { Tab } from 'products/product_analytics/frontend/insights/InsightNav/insightNavLogic'++export interface QuillInsightsNavProps {+ tabs: Tab[]+ activeView: InsightType+ onChange: (type: InsightType) => void+}++export function QuillInsightsNav({ tabs, activeView, onChange }: QuillInsightsNavProps): JSX.Element {+ return (+ <Tabs+ value={activeView}+ onValueChange={(value) => onChange(value as InsightType)}+ className="border-b border-border"+ data-quill+ >+ <TabsList variant="line" className="max-w-full justify-start overflow-x-auto">+ {tabs.map(({ label, type, dataAttr, beta }) => {+ const metadata = INSIGHT_TYPES_METADATA[type]+ const docLink = metadata.tooltipDocLink+ const Icon = metadata.icon+ return (+ <TabsTrigger key={type} value={type}>+ <LinkPrimitive+ to={INSIGHT_TYPE_URLS[type]}+ preventClick+ className="text-inherit hover:text-inherit"+ data-attr={dataAttr}+ >+ <Tooltip>+ <TooltipTrigger render={<span className="inline-flex items-center gap-1.5" />}>+ <Icon className="size-3.5 shrink-0" />+ {label}+ {beta && <Badge variant="warning">Beta</Badge>}+ </TooltipTrigger>+ <TooltipContent side="top">+ <div className="flex flex-col gap-1">+ <span>{metadata.tooltipDescription || metadata.description}</span>+ {docLink && (+ <LinkPrimitive+ to={docLink}+ target="_blank"+ className="text-xs text-primary-on-foreground underline"+ data-ph-capture-attribute-autocapture-event-name="clicked tooltip doc link"+ data-ph-capture-attribute-doclink={docLink}+ >+ Read the docs+ </LinkPrimitive>+ )}+ </div>+ </TooltipContent>+ </Tooltip>+ </LinkPrimitive>+ </TabsTrigger>+ )+ })}+ </TabsList>+ </Tabs>+ )+}