: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
chore(charts): render the shared Sparkline via quill unconditionally (#87831)
Sam Pennington8dc4a6105546
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 9410739d3363..843b5115bccb 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -1937,9 +1937,9 @@ snapshots:components-slack-channel-picker--recently-subscribed-first--light:hash: v1.k794b7964.54bc88c73e7d32bbab8a32b91162eab1fb1ba78215aa188aa748b65b9fb531b8.YkOXS4kFGcgECAArUGil25uNoJVbhGKe_zYYmpzzu44components-sparkline--bar-chart--dark:- hash: v1.k794b7964.cb1d1d3239f78521823c1278cadb102e136422579a910c3a691c2b6b17ebb962.aj9xFX3wR7NQKuqnk4Tgypbsd2Ase4rHeCGuKjORB3w+ hash: v1.k794b7964.65da75bd15e9d0d9f2e575e4eb04e0aaafdb39e02dbc19ba5006cf3651cb792d.zeJ6dGjiWJ_9biIrGypyok73SsFJJ-NLmGNHZJDCJ-wcomponents-sparkline--bar-chart--light:- hash: v1.k794b7964.31239811ce1a1008b0f7ce278672dea78cc73785762735c6dc75437b165e6546.6_LSwYHJwrSsIBtnEhFwPCl3X6531Z_0iJaYpOj5sIU+ hash: v1.k794b7964.6eb3adde804dad4d1679afdac8ba0885d492ce67b8b9e6165a8c249f44ecdd15.WmlBW3Ty9XLHt-AeaJBxjzmnlYaDXpGa28EO2xhdVvocomponents-sparkline--bar-chart-quill--dark:hash: v1.k794b7964.65da75bd15e9d0d9f2e575e4eb04e0aaafdb39e02dbc19ba5006cf3651cb792d.4h71v2aMuCoUCk73AbsUPFhaiOPh4OZNrsDfJF_hB8gcomponents-sparkline--bar-chart-quill--light:@@ -6241,9 +6241,9 @@ snapshots:scenes-app-discussions--threads--light:hash: v1.k794b7964.28ac830bf83be5cbb6d7a397d67c9b9c61711904a822de38402b82220b0f7a49.7wENY7hvo1-qAJwq5fcsvKGJsfRAF_vDkpnM8iqFZccscenes-app-engineering-analytics-repo-overview--repo-overview--dark:- hash: v1.k794b7964.ea0cac6dc4e88af4e62d1bec32c9abfb613c44f74713205c1990fa44d467190a._Jn8n4C9-F5naZmW4FU1Utu9_wVDapw2ekc7qSlbgvc+ hash: v1.k794b7964.8e6b4034168c2ae8907ac92efb3941209867a95ef8388505b9bcb7a57830c243._1Y9xmZSpOpt_qzloETiebDiX0ROe1GBE2c00TKYaDMscenes-app-engineering-analytics-repo-overview--repo-overview--light:- hash: v1.k794b7964.646864073ca10e6cd01f9523215da333ea50b674caede591e12c8e241f4f1590.h76KD47dx5rmRHXFYEen7HjjKJDRtqHIn8vcJ2g1Azk+ hash: v1.k794b7964.4a0774ee6bc116b4fa7a71bcb3ede68edc930a93231ade9fbf72f16a5b9eba1c.OII3xJtYXX1Udah76yG4WxQE6d5Am0PRCSBrCfGDGcMscenes-app-engineering-analytics-run-activity-chart--default--dark:hash: v1.k794b7964.7f17c5ac7c6862493f7c4d59e6e3c3146c42e3d7b08908ee1716d387c129ba64.lPsE9KrOSZee9wJq8zjqYnvk09numvEFWOn4mdCOgJEscenes-app-engineering-analytics-run-activity-chart--default--light:diff --git a/frontend/src/lib/components/Sparkline.stories.tsx b/frontend/src/lib/components/Sparkline.stories.tsxindex 27cf4ccb326c..558b5cac05d4 100644--- a/frontend/src/lib/components/Sparkline.stories.tsx+++ b/frontend/src/lib/components/Sparkline.stories.tsx@@ -19,6 +19,9 @@ export const BarChart: Story = {data: [10, 5, 3, 30, 22, 10, 2],labels: ['Mon', 'Tue', 'Wed', 'Thurs', 'Fri', 'Sat', 'Sun'],},+ // `Sparkline` now dispatches to the quill chart, whose canvas has no intrinsic size, so the+ // wrapper needs an explicit height — a bare `w-full` collapses to zero height under the runner.+ render: (args) => <Sparkline {...args} className="w-64 h-16" />,}const dataRange = Array.from({ length: 50 }, (_, i) => i)@@ -56,10 +59,9 @@ export const TimeseriesChart: Story = {},}-// Quill-rendered variants (see docs/internal/quill-migration-sparkline.md), for side-by-side-// comparison with the legacy stories above. These render `QuillSparkline` directly rather than-// flipping the `quill-sparkline` flag: the flag dispatch is unusable under Storybook, whose-// implicit-action args inject an `onSelectionChange` spy that the dispatch reads as a+// Quill-rendered variants, for side-by-side comparison with the legacy stories above. These+// render `QuillSparkline` directly: the dispatch in `Sparkline` is unusable under Storybook,+// whose implicit-action args inject an `onSelectionChange` spy that the dispatch reads as a// legacy-only feature. The quill chart paints onto an absolutely-positioned canvas that adds no// intrinsic size, so the wrapper needs an explicit width and height — a `w-full` here would// collapse to a zero-width, unsnapshottable root under the test runner.diff --git a/frontend/src/lib/components/Sparkline.test.tsx b/frontend/src/lib/components/Sparkline.test.tsxindex f98814de3468..586abba102ff 100644--- a/frontend/src/lib/components/Sparkline.test.tsx+++ b/frontend/src/lib/components/Sparkline.test.tsx@@ -10,9 +10,6 @@ import {setupSyncRaf,} from '@posthog/quill-charts/testing'-import { FEATURE_FLAGS } from 'lib/constants'-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'-import { initKeaTests } from '~/test/init'import { Sparkline, SparklineProps } from './Sparkline'@@ -31,13 +28,8 @@ afterEach(() => {cleanup()})-function renderSparkline(props: SparklineProps, { quillFlag = true }: { quillFlag?: boolean } = {}): void {+function renderSparkline(props: SparklineProps): void {initKeaTests()- const ffLogic = featureFlagLogic()- ffLogic.mount()- // Always set the flag explicitly — the featureFlags reducer is kea-persisted to localStorage,- // which survives across tests in this file, so an unset flag would leak the previous test's value.- ffLogic.actions.setFeatureFlags([FEATURE_FLAGS.QUILL_SPARKLINE], { [FEATURE_FLAGS.QUILL_SPARKLINE]: quillFlag })render(<Sparkline {...props} />)}@@ -50,18 +42,12 @@ const DATA = [10, 5, 3, 30]const LABELS = ['Mon', 'Tue', 'Wed', 'Thu']describe('Sparkline', () => {- it('renders via quill when the flag is on and only simple props are used', () => {+ it('renders via quill when only simple props are used', () => {renderSparkline({ data: DATA, labels: LABELS })expect(quillCanvas()).toBeTruthy()expect(legacyCanvas()).toBeNull()})- it('renders via Chart.js when the flag is off', () => {- renderSparkline({ data: DATA, labels: LABELS }, { quillFlag: false })- expect(legacyCanvas()).toBeTruthy()- expect(quillCanvas()).toBeNull()- })-it.each<{ feature: string; props: Partial<SparklineProps> }>([{ feature: 'onSelectionChange', props: { onSelectionChange: () => {} } },{ feature: 'highlightedRange', props: { highlightedRange: { xMin: 'Mon', xMax: 'Tue' } } },@@ -69,7 +55,7 @@ describe('Sparkline', () => {{ feature: 'referenceLines', props: { referenceLines: [{ value: 20 }] } },{ feature: 'withXScale', props: { withXScale: (x) => x } },{ feature: 'withYScale', props: { withYScale: (y) => y } },- ])('keeps Chart.js when $feature is passed, even with the flag on', ({ props }) => {+ ])('keeps Chart.js when $feature is passed', ({ props }) => {renderSparkline({ data: DATA, labels: LABELS, ...props })expect(legacyCanvas()).toBeTruthy()expect(quillCanvas()).toBeNull()diff --git a/frontend/src/lib/components/Sparkline.tsx b/frontend/src/lib/components/Sparkline.tsxindex 660c63841958..f0bced9cca01 100644--- a/frontend/src/lib/components/Sparkline.tsx+++ b/frontend/src/lib/components/Sparkline.tsx@@ -11,7 +11,6 @@ import { Chart, ScaleOptions, TooltipModel } from 'lib/Chart'import { getColorVar } from 'lib/colors'import { useChart } from 'lib/hooks/useChart'import { useEventListener } from 'lib/hooks/useEventListener'-import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'import { useKeyboardHotkeys } from 'lib/hooks/useKeyboardHotkeys'import { useLingeringTooltip } from 'lib/hooks/useLingeringTooltip'import { hexToRGBA } from 'lib/utils/colors'@@ -175,9 +174,8 @@ function sparklineClassName(dataPointCount: number, className?: string): string}export function Sparkline(props: SparklineProps): JSX.Element {- const quillEnabled = useFeatureFlag('QUILL_SPARKLINE')// Features the quill path doesn't cover yet. Consumers passing them stay on Chart.js until- // their migration wave lands — see docs/internal/quill-migration-sparkline.md.+ // their migration wave lands.const needsLegacyFeatures = !!(props.onSelectionChange ||props.highlightedRange ||@@ -187,7 +185,7 @@ export function Sparkline(props: SparklineProps): JSX.Element {props.withXScale ||props.withYScale)- return quillEnabled && !needsLegacyFeatures ? <QuillSparkline {...props} /> : <LegacySparkline {...props} />+ return needsLegacyFeatures ? <LegacySparkline {...props} /> : <QuillSparkline {...props} />}/** Legacy consumers pass vars.scss color names ('success', 'danger', 'muted'); quill takes CSS colors. */@@ -196,7 +194,7 @@ function resolveSparklineColor(color: string | undefined): string {return /^(#|rgb|hsl|var\()/.test(value) ? value : getColorVar(value)}-/** The quill rendering path. Exported for Storybook only — the flag dispatch in `Sparkline` is+/** The quill rendering path. Exported for Storybook only — the dispatch in `Sparkline` is* unusable there (Storybook's implicit-action args inject an `onSelectionChange` spy, which the* dispatch reads as a legacy-only feature). Consumers always use `Sparkline`. */export function QuillSparkline({diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex f93a6271ff81..294f562ea83a 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -461,7 +461,6 @@ export const FEATURE_FLAGS = {PULSE: 'pulse', // owner: #team-analytics-platformQUICK_START_PULSE_INDICATOR: 'quick-start-pulse-indicator', // owner: @fercgomes #team-growth multivariate=control,testQUILL_DATE_PICKER: 'quill-date-picker', // owner: @pauldambra, flips the lib/components/DatePicker seam from LemonUI to Quill- QUILL_SPARKLINE: 'quill-sparkline', // owner: @sampennington #team-product-analytics, gates rendering the shared lib Sparkline via @posthog/quill-charts (docs/internal/quill-migration-sparkline.md)READ_ONLY_MODE: 'read-only-mode', // owner: @pauldambra, experiment: force users into read-only and steer mutations through Max/MCPREAL_TIME_NOTIFICATIONS: 'real-time-notifications', // owner: #team-platform-featuresREALTIME_COHORT_FLAG_TARGETING: 'realtime-cohort-flag-targeting', // owner: @dmarticus #team-feature-flags