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(insights): capitalize stickiness chart tooltip labels (#65477)

Thomas Obermüllercb8c4a9cd161
diff --git a/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart.test.tsx b/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart.test.tsx
index 4a5c3ed3f325..f57ae53aca6e 100644
--- a/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart.test.tsx
+++ b/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart.test.tsx
@@ -74,13 +74,13 @@ describe('StickinessBarChart', () => {
})
})
- it('tooltip: percent value + "stickiness on {interval} {day}" title (not a calendar date)', async () => {
+ it('tooltip: percent value + "Stickiness on {interval} {day}" title (not a calendar date)', async () => {
renderInsight({ query: stickinessBar() })
const tooltip = await chart.hoverTooltip(2)
// Days are 1-indexed in the mock, so bucket 2 == day 3.
expect(tooltip.row('Pageview')).toMatch(/%/)
- expect(tooltip.title()).toMatch(/stickiness on day 3/i)
+ expect(tooltip.title()).toMatch(/Stickiness on day 3/)
// Must NOT default to a Unix-epoch-derived calendar date.
expect(tooltip.title()).not.toMatch(/1970/i)
})
@@ -101,7 +101,7 @@ describe('StickinessBarChart', () => {
expect(screen.queryByRole('img', { name: /chart with/i })).not.toBeInTheDocument()
})
- it('click → persons modal: opens with a "stickiness on {interval} {day}" title', async () => {
+ it('click → persons modal: opens with a "Stickiness on {interval} {day}" title', async () => {
renderInsight({ query: stickinessBar() })
await chart.clickAtIndex(2)
@@ -112,7 +112,7 @@ describe('StickinessBarChart', () => {
},
{ timeout: 5000 }
)
- expect(personsModal.title()).toMatch(/stickiness on day 3/i)
+ expect(personsModal.title()).toMatch(/Stickiness on day 3/)
expect(personsModal.title()).toMatch(/Pageview/i)
})
diff --git a/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/StickinessLineChart.test.tsx b/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/StickinessLineChart.test.tsx
index 1b4429c22547..d52c5426b9e6 100644
--- a/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/StickinessLineChart.test.tsx
+++ b/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/StickinessLineChart.test.tsx
@@ -60,12 +60,12 @@ describe('StickinessLineChart', () => {
expect(tooltip.row('Pageview')).toMatch(/%/)
})
- it('uses "stickiness on {interval} {day}" as the tooltip title (not a calendar date)', async () => {
+ it('uses "Stickiness on {interval} {day}" as the tooltip title (not a calendar date)', async () => {
renderInsight({ query: buildStickinessQuery() })
const tooltip = await chart.hoverTooltip(2)
// Day at index 2 is 3 in the mock's 1-indexed stickiness days.
- expect(tooltip.title()).toMatch(/stickiness on day 3/i)
+ expect(tooltip.title()).toMatch(/Stickiness on day 3/)
// Critically — must NOT default to a Unix-epoch-derived calendar date.
expect(tooltip.title()).not.toMatch(/1970/i)
})
@@ -87,7 +87,7 @@ describe('StickinessLineChart', () => {
})
describe('click → persons modal', () => {
- it('opens the modal with a "stickiness on {interval} {day}" title', async () => {
+ it('opens the modal with a "Stickiness on {interval} {day}" title', async () => {
renderInsight({ query: buildStickinessQuery() })
await chart.clickAtIndex(2)
@@ -96,7 +96,7 @@ describe('StickinessLineChart', () => {
expect(personsModal.get()).toBeInTheDocument()
})
// The clicked bucket is index 2, days are 1-indexed in the mock, so day == 3.
- expect(personsModal.title()).toMatch(/stickiness on day 3/i)
+ expect(personsModal.title()).toMatch(/Stickiness on day 3/)
expect(personsModal.title()).toMatch(/Pageview/i)
})
diff --git a/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/handleStickinessChartClick.test.tsx b/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/handleStickinessChartClick.test.tsx
index 0599adb0e36f..4bf0731e6165 100644
--- a/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/handleStickinessChartClick.test.tsx
+++ b/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/handleStickinessChartClick.test.tsx
@@ -74,7 +74,7 @@ describe('handleStickinessChartClick', () => {
expect(call.orderBy).toBeUndefined()
})
- it('renders a "stickiness on {interval} {day}" title with the series label', () => {
+ it('renders a "Stickiness on {interval} {day}" title with the series label', () => {
const openPersonsModal = jest.fn()
const trendResult = makeTrendResult({ label: '$pageview' })
const deps = makeDeps({ openPersonsModal, interval: 'day', indexedResults: [trendResult] })
@@ -84,7 +84,7 @@ describe('handleStickinessChartClick', () => {
const { container } = render(<>{openPersonsModal.mock.calls[0][0].title}</>)
// PropertyKeyInfo wraps the raw label; the label text itself surfaces in textContent.
expect(container.textContent).toContain('$pageview')
- expect(container.textContent).toContain('stickiness on day 3')
+ expect(container.textContent).toContain('Stickiness on day 3')
})
it('uses "day" as the default interval when interval is null', () => {
@@ -95,7 +95,7 @@ describe('handleStickinessChartClick', () => {
handleStickinessChartClick(keyFor(trendResult), 0, deps)
const { container } = render(<>{openPersonsModal.mock.calls[0][0].title}</>)
- expect(container.textContent).toContain('stickiness on day 1')
+ expect(container.textContent).toContain('Stickiness on day 1')
})
it.each([
diff --git a/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/handleStickinessChartClick.tsx b/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/handleStickinessChartClick.tsx
index 0a49972b8d04..d23b722774ff 100644
--- a/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/handleStickinessChartClick.tsx
+++ b/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/handleStickinessChartClick.tsx
@@ -56,7 +56,7 @@ export function handleStickinessChartClick(seriesKey: string, dataIndex: number,
const label = dataset.label ?? ''
const title = (
<>
- <PropertyKeyInfo value={label} disablePopover /> stickiness on {deps.interval || 'day'} {day}
+ <PropertyKeyInfo value={label} disablePopover /> Stickiness on {deps.interval || 'day'} {day}
</>
)
diff --git a/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/stickinessChartTransforms.ts b/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/stickinessChartTransforms.ts
index 4b7351085239..f7a30ff5da70 100644
--- a/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/stickinessChartTransforms.ts
+++ b/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/stickinessChartTransforms.ts
@@ -1,6 +1,7 @@
import { DEFAULT_Y_AXIS_ID } from '@posthog/quill-charts'
import type { Series, TimeSeriesLineChartConfig, TooltipConfig, YAxisConfig } from '@posthog/quill-charts'
+import { capitalizeFirstLetter } from 'lib/utils/strings'
import type { SeriesDatum } from 'scenes/insights/InsightTooltip/insightTooltipUtils'
import { ChartDisplayType } from '~/types'
@@ -76,8 +77,7 @@ export function buildStickinessSeries<R extends StickinessResultLike, M = unknow
* duplicate the interval prefix when paired with a stickiness-style axis, so we
* synthesize them from the bucket count. Mirrors `formatIntervalLabels` in the legacy LineGraph. */
export function buildStickinessLabels(count: number, interval: string | null | undefined): string[] {
- const unit = interval ?? 'day'
- const prefix = `${unit.slice(0, 1).toUpperCase()}${unit.slice(1)}`
+ const prefix = capitalizeFirstLetter(interval ?? 'day')
return Array.from({ length: count }, (_, i) => `${prefix} ${i}`)
}
@@ -91,14 +91,14 @@ export function stickinessPercentFormatter(value: number): string {
export const STICKINESS_TOOLTIP_CONFIG: TooltipConfig = { pinnable: true, placement: 'top' }
/** Stickiness `date` is an interval-count integer (1, 2, …), not a date.
- * Render "stickiness on {interval} {day}" so InsightTooltip doesn't try to
+ * Render "Stickiness on {interval} {day}" so InsightTooltip doesn't try to
* format it as a calendar date (which would land on 1970-01-01). */
export function buildStickinessTooltipTitle(
interval: string | null | undefined
): (seriesData: SeriesDatum[]) => string {
return (seriesData) => {
const day = seriesData[0]?.date_label ?? ''
- return `stickiness on ${interval || 'day'} ${day}`
+ return `Stickiness on ${interval || 'day'} ${day}`
}
}