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(funnels): flag bar labels and a name-only step legend (#110551)

Sam Pennington634f58af09f6
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 177469049164..2469c9a8a2f8 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -3648,6 +3648,14 @@ snapshots:
hash: v1.k794b7964.311f6f62c92c4d57da0b590f8a10ee96eab682f58229d0e542643ea7982e0870.HjRKhvWCBYWS6qVwoa_4U68G5x-fMIfuiqowpJd_EH8
insights-funnelpropertycorrelationtable--default--light:
hash: v1.k794b7964.056fc912fbb2878e0a70884298f340ea9af0f1a57c80aebc7967fa1715982135.SbiTtmaSnj5V3ocDF2cHYLFAghsAJzD45d1x-3LS1co
+ insights-funnelstepsbarchart--bar-labels-breakdown--dark:
+ hash: v1.k794b7964.1b81a37668d87d9e22111138a41b64ba2a35df1e2ade467aaee188f2c8d04f3c.UKeyJfLXVsNRZ8KxhlOZvv62ThvYUL_o399r-hVnvO0
+ insights-funnelstepsbarchart--bar-labels-breakdown--light:
+ hash: v1.k794b7964.c0c82357191864f94bcaff7b5b10b488167a0b280e703373d0148325cfc2355e.AdRk7JPu1Ee4wOEJR3vBS_e7YpIBee-ZV_lscrfYQlk
+ insights-funnelstepsbarchart--bar-labels-many-steps--dark:
+ hash: v1.k794b7964.10eb1afc21f49174149c7679c740deeb02d6483d9535e1083b8cef2d6ffb7f26.jQR-MrvgFYeHiqHWGcaOkLNHXfwz0aC-2Hl_ERddPNQ
+ insights-funnelstepsbarchart--bar-labels-many-steps--light:
+ hash: v1.k794b7964.8c792f8d561d28f5468edd450b1495b5e475b2507f126d3d17534856e8e26f15.mG7etoFQtpXzqFLbq5bJ3psNR5r7RjklLaexltXIrpw
insights-funnelstepsbarchart--breakdown--dark:
hash: v1.k794b7964.790ff5760fabe3a875385fc7f09cd89d8096abf331d4b36a59abee7f0a35bc23.3uG4AjVvDhojZ8UlnAa4vzwgAdjl3zsbKVnN6ysAHls
insights-funnelstepsbarchart--breakdown--light:
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index ffbc2db468f2..fe85783afc20 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -194,6 +194,7 @@ export const FEATURE_FLAGS = {
CUSTOM_CSS_THEMES: 'custom-css-themes', // owner: #team-growth, used to enable custom CSS for teams who want to have fun
EXPERIMENT_ACTIVATION_EVENT: 'experiment-activation-event', // owner: #team-experiments, offers an activation event on top of the default exposure instead of legacy custom exposure events
EXPERIMENT_EXPOSURE_EVENT: 'experiment-exposure-event', // owner: #team-experiments, switches new experiments to the dedicated exposure event
+ FUNNEL_STEPS_BAR_LABELS: 'funnel-steps-bar-labels', // owner: @sampennington #team-product-analytics, left-to-right funnel with value labels on the bars, a name-only step legend and steps that shrink to fit
GAME_CENTER: 'game-center', // owner: everybody, this is just internal for now
HEDGEHOG_SKIN_SPIDERHOG: 'hedgehog-skin-spiderhog', // owner: #team-web-analytics, used to reward beta users for web analytics
HIGH_FREQUENCY_BATCH_EXPORTS: 'high-frequency-batch-exports', // owner: #team-batch-exports, allow batch exports to be run every 5min/15min
diff --git a/packages/quill/packages/charts/src/charts/FunnelChart/FunnelChart.tsx b/packages/quill/packages/charts/src/charts/FunnelChart/FunnelChart.tsx
index e5caeb7be7cf..cf431a9360ff 100644
--- a/packages/quill/packages/charts/src/charts/FunnelChart/FunnelChart.tsx
+++ b/packages/quill/packages/charts/src/charts/FunnelChart/FunnelChart.tsx
@@ -52,6 +52,10 @@ export interface FunnelChartConfig {
/** Min pixel height of the chart region when `stepFooter` is set, so a tall footer can't
* collapse the canvas to zero height in a height-constrained parent. */
chartMinHeight?: number
+ /** Where each `stepFooter` cell sits relative to its step's bars. `start` (default) begins the
+ * cell at the bars' left edge and extends it over the gap to the right. `center` extends it
+ * over half the gap on each side, so centered footer content lines up under the bars. */
+ stepFooterAlign?: 'start' | 'center'
}
export interface FunnelStepClickData<Meta = unknown> extends PointClickData<Meta> {
@@ -112,17 +116,17 @@ function StepBandProbe({ onBands }: { onBands: (bands: StepBand[]) => void }): n
return null
}
-function StepFooterRow({
- bands,
- stepFooter,
-}: {
- bands: StepBand[]
- stepFooter: (stepIndex: number) => React.ReactNode
-}): React.ReactElement {
- // One gutter column before each band column, so cells sit in normal flow (the row grows to
- // the tallest cell) while staying pixel-aligned with the bars above. Each cell also spans
- // the gutter to its right (the last one a trailing 1fr), so footer content can use the
- // dead space between bands; `pr-3` keeps neighbouring cells from touching.
+interface StepFooterLayout {
+ columns: string[]
+ cellClassName: string
+ cellColumn: (stepIndex: number) => string
+}
+
+// One gutter column before each band column, so cells sit in normal flow (the row grows to
+// the tallest cell) while staying pixel-aligned with the bars above. Each cell also spans
+// the gutter to its right (the last one a trailing 1fr), so footer content can use the
+// dead space between bands; `pr-3` keeps neighbouring cells from touching.
+function startAlignedFooterLayout(bands: StepBand[]): StepFooterLayout {
const columns: string[] = []
let cursor = 0
for (const band of bands) {
@@ -130,19 +134,50 @@ function StepFooterRow({
cursor = band.left + band.width
}
columns.push('1fr')
+ return {
+ columns,
+ cellClassName: 'min-w-0 pr-3',
+ cellColumn: (stepIndex) => `${2 * stepIndex + 2} / span 2`,
+ }
+}
+
+// One column per cell, each reaching the same distance past both sides of its band, so the band
+// is centered in the cell. The reach is half the gap between bands, capped by the space before
+// the first band so that cell stays symmetric too.
+function centerAlignedFooterLayout(bands: StepBand[]): StepFooterLayout {
+ const first = bands[0]
+ const gap = bands.length > 1 ? bands[1].left - (first.left + first.width) : 0
+ const reach = Math.max(0, Math.min(gap / 2, first.left))
+ return {
+ columns: [`${first.left - reach}px`, ...bands.map((band) => `${band.width + 2 * reach}px`), '1fr'],
+ cellClassName: 'min-w-0',
+ cellColumn: (stepIndex) => `${stepIndex + 2}`,
+ }
+}
+
+function StepFooterRow({
+ bands,
+ stepFooter,
+ align,
+}: {
+ bands: StepBand[]
+ stepFooter: (stepIndex: number) => React.ReactNode
+ align: 'start' | 'center'
+}): React.ReactElement {
+ const layout = align === 'center' ? centerAlignedFooterLayout(bands) : startAlignedFooterLayout(bands)
return (
// eslint-disable-next-line react/forbid-dom-props
<div
className="grid shrink-0"
- style={{ gridTemplateColumns: columns.join(' ') }}
+ style={{ gridTemplateColumns: layout.columns.join(' ') }}
data-attr="hog-funnel-step-footer"
>
{bands.map((_, stepIndex) => (
// eslint-disable-next-line react/forbid-dom-props
<div
key={stepIndex}
- className="min-w-0 pr-3"
- style={{ gridColumn: `${2 * stepIndex + 2} / span 2`, gridRow: 1 }}
+ className={layout.cellClassName}
+ style={{ gridColumn: layout.cellColumn(stepIndex), gridRow: 1 }}
data-attr="hog-funnel-step-footer-cell"
>
{stepFooter(stepIndex)}
@@ -182,6 +217,7 @@ export function FunnelChart<Meta = unknown>({
minBarSize,
maxBandRange,
chartMinHeight,
+ stepFooterAlign = 'start',
} = config ?? {}
const hasStepFooter = stepFooter != null
@@ -279,7 +315,7 @@ export function FunnelChart<Meta = unknown>({
{chart}
</div>
{bands && bands.length > 0 && (
- <StepFooterRow bands={bands.slice(0, steps.length)} stepFooter={stepFooter} />
+ <StepFooterRow bands={bands.slice(0, steps.length)} stepFooter={stepFooter} align={stepFooterAlign} />
)}
</div>
)
diff --git a/packages/quill/packages/charts/src/docs/chart-types.md b/packages/quill/packages/charts/src/docs/chart-types.md
index 74c39472f4cc..ee084ba0d28a 100644
--- a/packages/quill/packages/charts/src/docs/chart-types.md
+++ b/packages/quill/packages/charts/src/docs/chart-types.md
@@ -34,7 +34,7 @@ A thin wrapper over grouped `BarChart` that owns the funnel look: hatched `track
- `steps` is a `string[]` of display labels; duplicates are fine, bands are keyed by step index.
- Each `Series.data[stepIndex]` is the conversion from the first step as a percent (0..100). `funnelFromCounts` builds the single-series case from raw `{ label, count }` steps (a zero basis yields 0, not `NaN`).
- `onStepClick` replaces `onPointClick` and reports `{ stepIndex, converted }`; `converted: false` means the hatched drop-off track above the bar was clicked.
-- `stepFooter(stepIndex)` renders per-step content in a row below the plot, pixel-aligned under each step's bars, and hides the built-in step labels. Use it for step legends richer than an axis label.
+- `stepFooter(stepIndex)` renders per-step content in a row below the plot, pixel-aligned under each step's bars, and hides the built-in step labels. Use it for step legends richer than an axis label. A cell starts at the bars' left edge and runs over the gap to the right; set `stepFooterAlign: 'center'` in the config to center each cell on its bars instead, for centered footer content.
- Config: `hideStepLabels`, `hideValueAxis`, `barCornerRadius`, `bandPadding`, `minBarSize` (hover and click floor for near-zero bars; default `FUNNEL_MIN_BAR_SIZE` of 4px, applied with `minBarSizeScope: 'hover'` so the resting bar keeps its true size and grows to a clickable nub under the cursor; pass 0 to disable), `maxBandRange` (cluster a two or three step funnel instead of stretching it), `chartMinHeight` (floor the plot height when `stepFooter` is set, so a tall footer cannot starve the canvas to zero height in a height-constrained column), plus the usual `tooltip`, `legend`, `margins`.
- Compare mode uses `trackData` to draw a shorter period's volume gap as empty space; see [bars.md](./bars.md).
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/FunnelBarVertical.scss b/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/FunnelBarVertical.scss
index de653b3bea26..cd4f9f5035f3 100644
--- a/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/FunnelBarVertical.scss
+++ b/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/FunnelBarVertical.scss
@@ -213,6 +213,23 @@
}
}
+.StepNameLabel {
+ container-type: inline-size;
+ height: 100%;
+ border-left: 1px solid var(--color-border-primary);
+
+ .StepNameLabel__name {
+ display: -webkit-box;
+ -webkit-line-clamp: 2;
+ -webkit-box-orient: vertical;
+ overflow: hidden;
+
+ // `anywhere` (unlike `break-word`) shrinks the intrinsic min-content width, so an
+ // unbroken event name wraps instead of blowing the row past its step column.
+ overflow-wrap: anywhere;
+ }
+}
+
.FunnelTooltip {
width: 20rem;
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/FunnelStepsBarChart.stories.tsx b/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/FunnelStepsBarChart.stories.tsx
index 560e5ec8e9e9..ef0cf10cdd73 100644
--- a/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/FunnelStepsBarChart.stories.tsx
+++ b/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/FunnelStepsBarChart.stories.tsx
@@ -2,6 +2,7 @@ import { Meta, StoryObj } from '@storybook/react'
import { BindLogic } from 'kea'
import { useState } from 'react'
+import { FEATURE_FLAGS } from 'lib/constants'
import {
createInsightStory,
expandFirstPropertyFilter,
@@ -40,14 +41,14 @@ export default meta
let uniqueNode = 0
-function Stage({ children }: { children: React.ReactNode }): JSX.Element {
+function Stage({ children, width = 720 }: { children: React.ReactNode; width?: number }): JSX.Element {
return (
// eslint-disable-next-line react/forbid-dom-props
- <div style={{ height: 420, width: 720, display: 'flex', flexDirection: 'column' }}>{children}</div>
+ <div style={{ height: 420, width, display: 'flex', flexDirection: 'column' }}>{children}</div>
)
}
-function StoryRender({ insightFixture }: { insightFixture: any }): JSX.Element {
+function StoryRender({ insightFixture, width }: { insightFixture: any; width?: number }): JSX.Element {
const [dashboardItemId] = useState(() => `FunnelStepsBarChartStory.${uniqueNode++}` as InsightShortId)
const source = insightFixture.query.source
const cachedInsight = { ...insightFixture, short_id: dashboardItemId }
@@ -63,7 +64,7 @@ function StoryRender({ insightFixture }: { insightFixture: any }): JSX.Element {
return (
<BindLogic logic={insightLogic} props={insightProps}>
<BindLogic logic={dataNodeLogic} props={dataNodeLogicProps}>
- <Stage>
+ <Stage width={width}>
<FunnelStepsBarChart />
</Stage>
</BindLogic>
@@ -75,6 +76,39 @@ export const Default: Story = {
render: () => <StoryRender insightFixture={funnelTopToBottomFixture} />,
}
+const manyStepsFixture = {
+ ...funnelTopToBottomFixture,
+ result: Array.from({ length: 10 }, (_, i) => ({
+ ...funnelTopToBottomFixture.result[0],
+ action_id: `step_${i + 1}`,
+ name: `step_${i + 1}`,
+ order: i,
+ count: Math.round(12000 * 0.9 ** i),
+ })),
+ query: {
+ ...funnelTopToBottomFixture.query,
+ source: {
+ ...funnelTopToBottomFixture.query.source,
+ series: Array.from({ length: 10 }, (_, i) => ({
+ event: `step_${i + 1}`,
+ kind: 'EventsNode',
+ name: `step_${i + 1}`,
+ })),
+ },
+ },
+}
+
+// Steps shrink to fit the width instead of scrolling, with the rate on each bar.
+export const BarLabelsManySteps: Story = {
+ render: () => <StoryRender insightFixture={manyStepsFixture} width={1520} />,
+ parameters: { featureFlags: [FEATURE_FLAGS.FUNNEL_STEPS_BAR_LABELS] },
+}
+
+export const BarLabelsBreakdown: Story = {
+ render: () => <StoryRender insightFixture={funnelTopToBottomBreakdownFixture} />,
+ parameters: { featureFlags: [FEATURE_FLAGS.FUNNEL_STEPS_BAR_LABELS] },
+}
+
export const Breakdown: Story = {
render: () => <StoryRender insightFixture={funnelTopToBottomBreakdownFixture} />,
}
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/FunnelStepsBarChart.tsx b/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/FunnelStepsBarChart.tsx
index 7d5f9524e9dd..875263adf38b 100644
--- a/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/FunnelStepsBarChart.tsx
+++ b/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/FunnelStepsBarChart.tsx
@@ -1,12 +1,15 @@
+import clsx from 'clsx'
import { useActions, useValues } from 'kea'
import posthog from 'posthog-js'
import { useCallback, useMemo, type ErrorInfo } from 'react'
-import { DEFAULT_MARGINS, FunnelChart } from '@posthog/quill-charts'
+import { DEFAULT_MARGINS, FunnelChart, ValueLabels } from '@posthog/quill-charts'
import type { FunnelChartConfig, FunnelStepClickData, TooltipContext } from '@posthog/quill-charts'
import { useChartTheme } from 'lib/charts/hooks'
import { ScrollableShadows } from 'lib/components/ScrollableShadows/ScrollableShadows'
+import { FEATURE_FLAGS } from 'lib/constants'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { insightLogic } from 'scenes/insights/insightLogic'
import { groupsModel } from '~/models/groupsModel'
@@ -17,16 +20,19 @@ import { funnelPersonsModalLogic } from '../funnelPersonsModalLogic'
import { FunnelStepsBarTooltip } from './FunnelStepsBarTooltip'
import {
buildFunnelStepsBarData,
+ formatFunnelStepBarLabel,
FUNNEL_STEPS_BAR_TOOLTIP_CONFIG,
resolveFunnelStepClick,
type FunnelStepsBarSeriesMeta,
} from './funnelStepsBarTransforms'
import { StepLegend } from './StepLegend'
+import { StepNameLabel } from './StepNameLabel'
-const BASE_STEP_WIDTH_PX = 240
+const MIN_STEP_WIDTH_PX = 144
+const MAX_STEP_WIDTH_PX = 240
const PER_BAR_WIDTH_PX = 20
-const CHART_CONFIG: FunnelChartConfig = {
+const LEGACY_CHART_CONFIG: FunnelChartConfig = {
animateHover: true,
// Keep the chart from collapsing under a tall StepLegend footer.
chartMinHeight: 150,
@@ -34,6 +40,8 @@ const CHART_CONFIG: FunnelChartConfig = {
tooltip: FUNNEL_STEPS_BAR_TOOLTIP_CONFIG,
}
+const CHART_CONFIG: FunnelChartConfig = { ...LEGACY_CHART_CONFIG, stepFooterAlign: 'center' }
+
const handleChartError = (error: Error, info: ErrorInfo): void => {
posthog.captureException(error, {
feature: 'funnels-steps-bar-chart',
@@ -46,6 +54,8 @@ export function FunnelStepsBarChart({
inCardView,
}: ChartParams): JSX.Element | null {
const theme = useChartTheme()
+ const { featureFlags } = useValues(featureFlagLogic)
+ const hasBarLabels = !!featureFlags[FEATURE_FLAGS.FUNNEL_STEPS_BAR_LABELS]
const { insightProps } = useValues(insightLogic)
const { visibleStepsWithConversionMetrics, getFunnelsColor, breakdownFilter, querySource, insightData } = useValues(
funnelDataLogic(insightProps)
@@ -73,8 +83,10 @@ export function FunnelStepsBarChart({
const showTime = steps.some((step) => step.average_conversion_time != null)
const breakdownCount = series.length
- const stepWidthPx = Math.max(BASE_STEP_WIDTH_PX, breakdownCount * PER_BAR_WIDTH_PX)
- const chartWidth = DEFAULT_MARGINS.left + steps.length * stepWidthPx + DEFAULT_MARGINS.right
+ const chartWidth = (stepWidthPx: number): number =>
+ DEFAULT_MARGINS.left +
+ steps.length * Math.max(stepWidthPx, breakdownCount * PER_BAR_WIDTH_PX) +
+ DEFAULT_MARGINS.right
const onStepClick = useCallback(
(clickData: FunnelStepClickData<FunnelStepsBarSeriesMeta>): void => {
@@ -108,7 +120,9 @@ export function FunnelStepsBarChart({
if (!step) {
return null
}
- return (
+ return hasBarLabels ? (
+ <StepNameLabel step={step} stepIndex={stepIndex} />
+ ) : (
<StepLegend
step={step}
stepIndex={stepIndex}
@@ -118,7 +132,7 @@ export function FunnelStepsBarChart({
/>
)
},
- [steps, showTime, showPersonsModal, inCardView]
+ [steps, hasBarLabels, showTime, showPersonsModal, inCardView]
)
if (steps.length === 0) {
@@ -128,18 +142,28 @@ export function FunnelStepsBarChart({
return (
<ScrollableShadows direction="horizontal" className="flex-1" contentClassName="flex h-full flex-col">
{/* eslint-disable-next-line react/forbid-dom-props */}
- <div className="flex flex-1 flex-col" style={{ width: chartWidth }} data-attr="funnel-steps-bar-chart">
+ <div
+ className={clsx('flex flex-1 flex-col', hasBarLabels && 'w-full')}
+ style={
+ hasBarLabels
+ ? { minWidth: chartWidth(MIN_STEP_WIDTH_PX), maxWidth: chartWidth(MAX_STEP_WIDTH_PX) }
+ : { width: chartWidth(MAX_STEP_WIDTH_PX) }
+ }
+ data-attr="funnel-steps-bar-chart"
+ >
<FunnelChart<FunnelStepsBarSeriesMeta>
steps={stepLabels}
series={series}
theme={theme}
- config={CHART_CONFIG}
+ config={hasBarLabels ? CHART_CONFIG : LEGACY_CHART_CONFIG}
tooltip={renderTooltip}
onStepClick={showPersonsModal ? onStepClick : undefined}
stepFooter={renderStepFooter}
dataAttr="funnel-steps-bar-chart-canvas"
onError={handleChartError}
- />
+ >
+ {hasBarLabels && <ValueLabels valueFormatter={formatFunnelStepBarLabel} offset={4} />}
+ </FunnelChart>
</div>
</ScrollableShadows>
)
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/StepNameLabel.tsx b/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/StepNameLabel.tsx
new file mode 100644
index 000000000000..0226d22087d0
--- /dev/null
+++ b/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/StepNameLabel.tsx
@@ -0,0 +1,60 @@
+import './FunnelBarVertical.scss'
+
+import { useValues } from 'kea'
+
+import { EntityFilterInfo } from 'lib/components/EntityFilterInfo'
+import { LemonDropdown } from 'lib/lemon-ui/LemonDropdown'
+import { insightLogic } from 'scenes/insights/insightLogic'
+import { userLogic } from 'scenes/userLogic'
+
+import { AvailableFeature, FunnelStepWithConversionMetrics } from '~/types'
+
+import { funnelDataLogic } from '../funnelDataLogic'
+import { FunnelStepPathLinks } from '../shared/FunnelStepPathLinks'
+import { getActionFilterFromFunnelStep } from '../shared/funnelStepTableUtils'
+
+type StepNameLabelProps = {
+ step: FunnelStepWithConversionMetrics
+ stepIndex: number
+}
+
+export function StepNameLabel({ step, stepIndex }: StepNameLabelProps): JSX.Element {
+ const { insightProps } = useValues(insightLogic)
+ const { isStepOptional, querySource } = useValues(funnelDataLogic(insightProps))
+ const { hasAvailableFeature } = useValues(userLogic)
+
+ const isOptionalStep = isStepOptional(stepIndex + 1)
+ // Paths are user-based, so there is nothing to link to when aggregating by groups.
+ const hasPathLinks =
+ hasAvailableFeature(AvailableFeature.PATHS_ADVANCED) && querySource?.aggregation_group_type_index == null
+
+ const name = (
+ <span className="StepNameLabel__name font-semibold leading-5">
+ <EntityFilterInfo filter={getActionFilterFromFunnelStep(step)} allowWrap />
+ {isOptionalStep ? <span className="ml-1 text-xs font-normal">(optional)</span> : null}
+ </span>
+ )
+
+ return (
+ <div
+ className="StepNameLabel flex items-start justify-center px-1 text-center text-sm"
+ data-attr="funnel-step-legend"
+ style={{ opacity: isOptionalStep ? 0.6 : 1 }}
+ >
+ {hasPathLinks ? (
+ <LemonDropdown overlay={<FunnelStepPathLinks stepIndex={stepIndex} />} placement="bottom" actionable>
+ <button
+ type="button"
+ className="max-w-full cursor-pointer rounded px-1 hover:bg-fill-button-tertiary-hover"
+ aria-haspopup="menu"
+ data-attr="funnel-step-paths-menu"
+ >
+ {name}
+ </button>
+ </LemonDropdown>
+ ) : (
+ <div className="max-w-full px-1">{name}</div>
+ )}
+ </div>
+ )
+}
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/funnelStepsBarTransforms.ts b/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/funnelStepsBarTransforms.ts
index a1b931609391..5f28cd7f93bf 100644
--- a/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/funnelStepsBarTransforms.ts
+++ b/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/funnelStepsBarTransforms.ts
@@ -1,5 +1,7 @@
import type { PointClickData, TooltipConfig } from '@posthog/quill-charts'
+import { percentage } from 'lib/utils/numbers'
+
import type { BreakdownKeyType, FunnelStepWithConversionMetrics } from '~/types'
import { INSIGHT_TOOLTIP_CONFIG } from '../../shared/tooltipConfig'
@@ -147,3 +149,7 @@ export function resolveFunnelStepClick(
const variant = step.nested_breakdown?.[breakdownIndex] ?? step
return { step, series: variant, converted: !clickData.inTrackArea }
}
+
+export function formatFunnelStepBarLabel(ratePercent: number): string {
+ return percentage(ratePercent / RATE_TO_PERCENT, 0)
+}
diff --git a/products/product_analytics/frontend/insights/funnels/shared/FunnelStepMore.tsx b/products/product_analytics/frontend/insights/funnels/shared/FunnelStepMore.tsx
index dcfdb203dd3f..4e3305960b3c 100644
--- a/products/product_analytics/frontend/insights/funnels/shared/FunnelStepMore.tsx
+++ b/products/product_analytics/frontend/insights/funnels/shared/FunnelStepMore.tsx
@@ -1,15 +1,10 @@
import { useValues } from 'kea'
-import { useCallback } from 'react'
-import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { More } from 'lib/lemon-ui/LemonButton/More'
import { insightLogic } from 'scenes/insights/insightLogic'
-import { urls } from 'scenes/urls'
-
-import { InsightVizNode, NodeKind } from '~/queries/schema/schema-general'
-import { FunnelPathType, PathType } from '~/types'
import { funnelDataLogic } from '../funnelDataLogic'
+import { FunnelStepPathLinks } from './FunnelStepPathLinks'
type FunnelStepMoreProps = {
stepIndex: number
@@ -20,32 +15,6 @@ export function FunnelStepMore({ stepIndex, className }: FunnelStepMoreProps): J
const { insightProps } = useValues(insightLogic)
const { querySource } = useValues(funnelDataLogic(insightProps))
- const stepNumber = stepIndex + 1
- const getPathUrl = useCallback(
- (funnelPathType: FunnelPathType, dropOff = false): string => {
- const query: InsightVizNode = {
- kind: NodeKind.InsightVizNode,
- source: {
- kind: NodeKind.PathsQuery,
- funnelPathsFilter: {
- funnelStep: dropOff ? stepNumber * -1 : stepNumber,
- funnelSource: querySource!,
- funnelPathType,
- },
- pathsFilter: {
- includeEventTypes: [PathType.PageView, PathType.CustomEvent],
- },
- dateRange: {
- date_from: querySource?.dateRange?.date_from,
- },
- },
- }
-
- return urls.insightNew({ query })
- },
- [querySource, stepNumber]
- )
-
// Don't show paths modal if aggregating by groups - paths is user-based!
if (querySource?.aggregation_group_type_index != null) {
return null
@@ -56,33 +25,7 @@ export function FunnelStepMore({ stepIndex, className }: FunnelStepMoreProps): J
className={className}
placement="bottom-start"
noPadding
- overlay={
- <>
- {stepNumber > 1 && (
- <LemonButton fullWidth to={getPathUrl(FunnelPathType.before)} targetBlank>
- Show user paths leading to step
- </LemonButton>
- )}
- {stepNumber > 1 && (
- <LemonButton fullWidth to={getPathUrl(FunnelPathType.between)} targetBlank>
- Show user paths between previous step and this step
- </LemonButton>
- )}
- <LemonButton fullWidth to={getPathUrl(FunnelPathType.after)} targetBlank>
- Show user paths after step
- </LemonButton>
- {stepNumber > 1 && (
- <LemonButton fullWidth to={getPathUrl(FunnelPathType.after, true)} targetBlank>
- Show user paths after dropoff
- </LemonButton>
- )}
- {stepNumber > 1 && (
- <LemonButton fullWidth to={getPathUrl(FunnelPathType.before, true)} targetBlank>
- Show user paths before dropoff
- </LemonButton>
- )}
- </>
- }
+ overlay={<FunnelStepPathLinks stepIndex={stepIndex} />}
/>
)
}
diff --git a/products/product_analytics/frontend/insights/funnels/shared/FunnelStepPathLinks.tsx b/products/product_analytics/frontend/insights/funnels/shared/FunnelStepPathLinks.tsx
new file mode 100644
index 000000000000..89325a97ac31
--- /dev/null
+++ b/products/product_analytics/frontend/insights/funnels/shared/FunnelStepPathLinks.tsx
@@ -0,0 +1,74 @@
+import { useValues } from 'kea'
+import { useCallback } from 'react'
+
+import { LemonButton } from 'lib/lemon-ui/LemonButton'
+import { insightLogic } from 'scenes/insights/insightLogic'
+import { urls } from 'scenes/urls'
+
+import { InsightVizNode, NodeKind } from '~/queries/schema/schema-general'
+import { FunnelPathType, PathType } from '~/types'
+
+import { funnelDataLogic } from '../funnelDataLogic'
+
+type FunnelStepPathLinksProps = {
+ stepIndex: number
+}
+
+export function FunnelStepPathLinks({ stepIndex }: FunnelStepPathLinksProps): JSX.Element {
+ const { insightProps } = useValues(insightLogic)
+ const { querySource } = useValues(funnelDataLogic(insightProps))
+
+ const stepNumber = stepIndex + 1
+ const getPathUrl = useCallback(
+ (funnelPathType: FunnelPathType, dropOff = false): string => {
+ const query: InsightVizNode = {
+ kind: NodeKind.InsightVizNode,
+ source: {
+ kind: NodeKind.PathsQuery,
+ funnelPathsFilter: {
+ funnelStep: dropOff ? stepNumber * -1 : stepNumber,
+ funnelSource: querySource!,
+ funnelPathType,
+ },
+ pathsFilter: {
+ includeEventTypes: [PathType.PageView, PathType.CustomEvent],
+ },
+ dateRange: {
+ date_from: querySource?.dateRange?.date_from,
+ },
+ },
+ }
+
+ return urls.insightNew({ query })
+ },
+ [querySource, stepNumber]
+ )
+
+ return (
+ <>
+ {stepNumber > 1 && (
+ <LemonButton fullWidth to={getPathUrl(FunnelPathType.before)} targetBlank>
+ Show user paths leading to step
+ </LemonButton>
+ )}
+ {stepNumber > 1 && (
+ <LemonButton fullWidth to={getPathUrl(FunnelPathType.between)} targetBlank>
+ Show user paths between previous step and this step
+ </LemonButton>
+ )}
+ <LemonButton fullWidth to={getPathUrl(FunnelPathType.after)} targetBlank>
+ Show user paths after step
+ </LemonButton>
+ {stepNumber > 1 && (
+ <LemonButton fullWidth to={getPathUrl(FunnelPathType.after, true)} targetBlank>
+ Show user paths after dropoff
+ </LemonButton>
+ )}
+ {stepNumber > 1 && (
+ <LemonButton fullWidth to={getPathUrl(FunnelPathType.before, true)} targetBlank>
+ Show user paths before dropoff
+ </LemonButton>
+ )}
+ </>
+ )
+}