: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(insights): enable refreshed quill chart styling behind a feature flag (#67779)
Sam Pennington5f63c6cd6256
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 6dd80b615fa4..c746f43fdbbb 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -6613,7 +6613,7 @@ snapshots:scenes-app-settings-environment--settings-environment-error-tracking--light:hash: v1.k794b7964.d2eb44367a4f4e948d2c45e4ad089bdfd0929ae4e1e6ae0e79c624a3a1d8d90f.IWh0_HTcd0w3UEmbt5VOFHToiunPwoEZDRHLYkGKc6cscenes-app-settings-environment--settings-environment-error-tracking-configuration--dark:- hash: v1.k794b7964.42e7194f3f699e0e1c6b3d1365af45ab9456df7c0f701e581a0552a957ea01df.7iaWNb9in0lKwH4twmtNliVTeJ9Nu7uUGlt3NcJrGuA+ hash: v1.k794b7964.9bb457d533f1e32f082fc500534edb11749cf44b05a082ea1998c96a008da1ab.Zyb0s0wuv8F6hbM0SDhIQIbuslPQEiEuiIFaD688RDwscenes-app-settings-environment--settings-environment-error-tracking-configuration--light:hash: v1.k794b7964.c092afb7f5eadc1db95ba9c8319f042adcf796e638181cb692ce0ea3c04d5a9d.frfFNTzuk-B2qahYl5KrtG3OMivCmCG3ZFLx2JzOyuoscenes-app-settings-environment--settings-environment-feature-flags--dark:diff --git a/frontend/src/lib/charts/hooks.ts b/frontend/src/lib/charts/hooks.tsindex 54693311bb11..306c22280bb7 100644--- a/frontend/src/lib/charts/hooks.ts+++ b/frontend/src/lib/charts/hooks.ts@@ -3,25 +3,71 @@ import { type DependencyList, useMemo } from 'react'import type { ChartTheme } from '@posthog/quill-charts'+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { themeLogic } from '~/layout/navigation-3000/themeLogic'import { buildTheme } from './utils/theme'+/** Rendering options the refreshed style turns on. Applied as config *defaults* — a chart's own+ * config always wins. All four are stable quill-charts config keys, so removing the flag later+ * means inlining these at the call sites (or flipping the library defaults), not deleting an API. */+const REFRESHED_CONFIG_DEFAULTS = {+ curve: 'monotone',+ showAxisLines: true,+ showTickMarks: true,+ showCrosshair: true,+ // Stacked bars round only the outermost segment, so this reads as "curved bar tops".+ barCornerRadius: 4,+} as const++function refreshedThemeOverrides(isDarkModeOn: boolean): Partial<ChartTheme> {+ return {+ gridColor: isDarkModeOn ? 'rgba(255,255,255,0.06)' : 'rgba(0,0,0,0.06)',+ gridDashPattern: [3, 3],+ axisLineColor: isDarkModeOn ? 'rgba(255,255,255,0.35)' : 'rgba(0,0,0,0.35)',+ // Dashed like the grid so the hover guide reads as a temporary sibling of the grid+ // lines, slightly stronger than them so it stays findable.+ crosshairColor: isDarkModeOn ? 'rgba(255,255,255,0.25)' : 'rgba(0,0,0,0.2)',+ crosshairDashPattern: [3, 3],+ }+}++export function useChartStyleRefreshEnabled(): boolean {+ const { featureFlags } = useValues(featureFlagLogic)+ return !!featureFlags[FEATURE_FLAGS.QUILL_CHART_STYLE_REFRESH]+}+/** Theme for app quill charts. `buildTheme()` reads CSS variables from the DOM, so the memo keys on- * `isDarkModeOn` to re-read them when the app theme flips. Pass a stable (memoized or module-level)- * `overrides` object — a fresh object every render defeats the memo. */+ * `isDarkModeOn` to re-read them when the app theme flips. Behind `QUILL_CHART_STYLE_REFRESH` it+ * also applies the refreshed chart colors (faint dashed grid, muted axis lines); caller `overrides`+ * win over both. Pass a stable (memoized or module-level) `overrides` object — a fresh object every+ * render defeats the memo. */export function useChartTheme(overrides?: Partial<ChartTheme>): ChartTheme {const { isDarkModeOn } = useValues(themeLogic)- // eslint-disable-next-line react-hooks/exhaustive-deps- return useMemo(() => buildTheme(overrides), [isDarkModeOn, overrides])+ const refreshEnabled = useChartStyleRefreshEnabled()+ return useMemo(+ () => buildTheme({ ...(refreshEnabled ? refreshedThemeOverrides(isDarkModeOn) : {}), ...overrides }),+ [isDarkModeOn, refreshEnabled, overrides]+ )}-/** Drop-in replacement for the `useMemo` that builds a chart's config object. This is the central- * seam for applying app-level rendering defaults to every quill chart config — currently a plain- * memo; config defaults (with the chart's own keys winning) hook in here. */+/** Drop-in replacement for the `useMemo` that builds a chart's config object. On top of memoizing,+ * it applies app-level rendering defaults — currently the refreshed style (monotone curve, axis+ * lines, tick marks, crosshair) behind `QUILL_CHART_STYLE_REFRESH`. Keys the config sets+ * explicitly (non-undefined) always win over the defaults. */export function useChartConfig<T extends object>(factory: () => T, deps: DependencyList): Texport function useChartConfig<T extends object>(factory: () => T | undefined, deps: DependencyList): T | undefinedexport function useChartConfig<T extends object>(factory: () => T | undefined, deps: DependencyList): T | undefined {+ const refreshEnabled = useChartStyleRefreshEnabled()// eslint-disable-next-line react-hooks/exhaustive-deps- return useMemo(factory, deps)+ const config = useMemo(factory, deps)+ return useMemo(() => {+ if (!refreshEnabled || !config) {+ return config+ }+ const defined = Object.fromEntries(Object.entries(config).filter(([, value]) => value !== undefined))+ return { ...REFRESHED_CONFIG_DEFAULTS, ...defined } as T+ }, [refreshEnabled, config])}diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex 17f94607143d..9797070a30a1 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -437,6 +437,7 @@ export const FEATURE_FLAGS = {PROMOTED_EVENT_PROPERTIES_EDIT: 'promoted-event-properties-edit', // owner: @pauldambra #team-product-analytics, gates the primary-property picker on the event definition edit page (flag slug kept as `promoted-event-properties-edit` to avoid migrating teams that already toggled it on)PROPERTY_ACCESS_CONTROL: 'property-access-control', // owner: @reecejones #team-platform-featuresQUICK_START_PULSE_INDICATOR: 'quick-start-pulse-indicator', // owner: @fercgomes #team-growth multivariate=control,test+ QUILL_CHART_STYLE_REFRESH: 'quill-chart-style-refresh', // owner: #team-product-analytics, gates refreshed quill chart styling (monotone curves, axis lines + tick marks, faint dashed grid, crosshair)QUILL_DATE_PICKER: 'quill-date-picker', // owner: @pauldambra, flips the lib/components/DatePicker seam from LemonUI to QuillRBAC_UI_REDESIGN: 'rbac-ui-redesign', // owner: @reece #team-platform-featuresREAD_ONLY_MODE: 'read-only-mode', // owner: @pauldambra, experiment: force users into read-only and steer mutations through Max/MCP