: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
fix(insights): render stickiness area chart with fill (#60170)
Sam Penningtonec0d8fb540d8
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 5c7050df6c0e..8ad9211e8a11 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -1956,6 +1956,10 @@ snapshots:hash: v1.k794b7964.d669cc7bd939e7cd9bae4003a228e194a6c383d827feb04baf491a89dfc0b698.eD11DZ4cr8p1GMBdBaTW1doXInEVj9CIhnyMP8RNpFoinsights-insightstable--is-legend--light:hash: v1.k794b7964.d9eec920b0b2f3c9ea87c9e0d2b298bc37339217e4211d0cf1a147630f09b75d.xGcJlQO8pvoNnHyoMNZ4F58uqKh5PDg_UiGlO5bAMn8+ insights-stickinesslinechart--area--dark:+ hash: v1.k794b7964.c8f70afcdd044f3df9c45bd8f83a5f7b9b6c2ff56fd36da9f74f196ebc0b56b9.0zlUNlGlxnyFebgcM3MlWfSHhFSI2YJb2jxigbCMjkQ+ insights-stickinesslinechart--area--light:+ hash: v1.k794b7964.5d7b49d8f4ebb24543f100ed4014d0f8a5832a5db40525f482fb096eadd7acb4.DMdwu1bhfT1dAJWNVYf72l00l5XMKia53ratuSW3CyEinsights-stickinesslinechart--default--dark:hash: v1.k794b7964.f6ce3c9177a7fa2b7d23d13e7121d089a2617f581baec1eaff9980bd40905199.A5l8DG-UgcNxzLuJwxvElIEzmOGud3QUrquboobhJvMinsights-stickinesslinechart--default--light:diff --git a/products/product_analytics/frontend/insights/trends/StickinessLineChart/StickinessLineChart.stories.tsx b/products/product_analytics/frontend/insights/trends/StickinessLineChart/StickinessLineChart.stories.tsxindex a1f5b647c143..5967029f069f 100644--- a/products/product_analytics/frontend/insights/trends/StickinessLineChart/StickinessLineChart.stories.tsx+++ b/products/product_analytics/frontend/insights/trends/StickinessLineChart/StickinessLineChart.stories.tsx@@ -10,7 +10,7 @@ import { dataNodeLogic } from '~/queries/nodes/DataNode/dataNodeLogic'import type { DataNodeLogicProps } from '~/queries/nodes/DataNode/dataNodeLogic'import { insightVizDataNodeKey } from '~/queries/nodes/InsightViz/InsightViz'import { getCachedResults } from '~/queries/nodes/InsightViz/utils'-import { InsightLogicProps, InsightShortId } from '~/types'+import { ChartDisplayType, InsightLogicProps, InsightShortId } from '~/types'import { StickinessLineChart } from './StickinessLineChart'@@ -74,3 +74,18 @@ function StickinessLineChartStory({ insightFixture }: { insightFixture: any }):export const Default: Story = {render: () => <StickinessLineChartStory insightFixture={stickinessFixture} />,}++const areaFixture = {+ ...stickinessFixture,+ query: {+ ...stickinessFixture.query,+ source: {+ ...stickinessFixture.query.source,+ stickinessFilter: { display: ChartDisplayType.ActionsAreaGraph },+ },+ },+}++export const Area: Story = {+ render: () => <StickinessLineChartStory insightFixture={areaFixture} />,+}diff --git a/products/product_analytics/frontend/insights/trends/StickinessLineChart/StickinessLineChart.tsx b/products/product_analytics/frontend/insights/trends/StickinessLineChart/StickinessLineChart.tsxindex 5d8fb5645676..6050927a584f 100644--- a/products/product_analytics/frontend/insights/trends/StickinessLineChart/StickinessLineChart.tsx+++ b/products/product_analytics/frontend/insights/trends/StickinessLineChart/StickinessLineChart.tsx@@ -41,6 +41,7 @@ export function StickinessLineChart({ context }: StickinessLineChartProps): JSX.const {indexedResults,+ display,interval,yAxisScaleType,showMultipleYAxes,@@ -72,11 +73,12 @@ export function StickinessLineChart({ context }: StickinessLineChartProps): JSX.() =>buildStickinessSeries<IndexedTrendResult, TrendsSeriesMeta>(indexedResults ?? [], {showMultipleYAxes: showMultipleYAxes ?? undefined,+ display: display ?? undefined,getColor: getTrendsColor,getHidden: getTrendsHidden,buildMeta: buildTrendsSeriesMeta,}),- [indexedResults, getTrendsColor, getTrendsHidden, showMultipleYAxes]+ [indexedResults, display, getTrendsColor, getTrendsHidden, showMultipleYAxes])const chartConfig: TimeSeriesLineChartConfig = useMemo(diff --git a/products/product_analytics/frontend/insights/trends/StickinessLineChart/stickinessChartTransforms.test.ts b/products/product_analytics/frontend/insights/trends/StickinessLineChart/stickinessChartTransforms.test.tsindex e1aa521e8364..f38eaf52b53c 100644--- a/products/product_analytics/frontend/insights/trends/StickinessLineChart/stickinessChartTransforms.test.ts+++ b/products/product_analytics/frontend/insights/trends/StickinessLineChart/stickinessChartTransforms.test.ts@@ -1,6 +1,8 @@import { DEFAULT_Y_AXIS_ID } from 'lib/hog-charts'import type { TooltipConfig } from 'lib/hog-charts'+import { ChartDisplayType } from '~/types'+import {buildStickinessLabels,buildStickinessLineTimeSeriesConfig,@@ -92,6 +94,18 @@ describe('stickinessChartTransforms', () => {expect(series.yAxisId).toBe(DEFAULT_Y_AXIS_ID)})+ it.each<[string, ChartDisplayType | undefined, Record<string, never> | undefined]>([+ ['ActionsAreaGraph sets fill', ChartDisplayType.ActionsAreaGraph, {}],+ ['ActionsLineGraph leaves fill undefined', ChartDisplayType.ActionsLineGraph, undefined],+ ['undefined display leaves fill undefined', undefined, undefined],+ ])('%s', (_, display, expected) => {+ const series = buildStickinessMainSeries(makeResult(), 0, {+ getColor: () => RED,+ display,+ })+ expect(series.fill).toEqual(expected)+ })+it('passes the result index through to getColor and buildMeta', () => {const getColor = jest.fn(() => RED)const buildMeta = jest.fn(() => ({}))diff --git a/products/product_analytics/frontend/insights/trends/StickinessLineChart/stickinessChartTransforms.ts b/products/product_analytics/frontend/insights/trends/StickinessLineChart/stickinessChartTransforms.tsindex 9ea93e7d4417..9039bc1de31c 100644--- a/products/product_analytics/frontend/insights/trends/StickinessLineChart/stickinessChartTransforms.ts+++ b/products/product_analytics/frontend/insights/trends/StickinessLineChart/stickinessChartTransforms.ts@@ -2,6 +2,8 @@ import { DEFAULT_Y_AXIS_ID } from 'lib/hog-charts'import type { Series, TimeSeriesLineChartConfig, TooltipConfig, YAxisConfig } from 'lib/hog-charts'import type { SeriesDatum } from 'scenes/insights/InsightTooltip/insightTooltipUtils'+import { ChartDisplayType } from '~/types'+// Shape both IndexedTrendResult (kea) and StickinessResultItem (MCP) satisfy.export interface StickinessResultLike {id?: string | number@@ -21,6 +23,7 @@ export type StickinessYAxisScaleType = string | null | undefinedexport interface BuildStickinessSeriesOpts<R extends StickinessResultLike, M = unknown> {showMultipleYAxes?: boolean+ display?: ChartDisplayType | nullgetColor: (r: R, index: number) => stringgetHidden?: (r: R, index: number) => booleanbuildMeta?: (r: R, index: number) => M@@ -50,6 +53,7 @@ export function buildStickinessMainSeries<R extends StickinessResultLike, M = uncolor: opts.getColor(r, index),yAxisId,meta,+ fill: opts.display === ChartDisplayType.ActionsAreaGraph ? {} : undefined,visibility: excluded ? { excluded: true } : undefined,}}