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(insights): gate the chart type gallery on its experiment variant (#106718)

Sam Pennington5302b3297ab4
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 36f30eeb0c27..f4cf3897aca8 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -444,7 +444,7 @@ export const FEATURE_FLAGS = {
POSTHOG_CODE_BILLING: 'posthog-code-billing', // owner: #team-desktop
POSTHOG_CONNECT: 'posthog-connect', // owner: @Gilbert09, gates the "connect another PostHog project" personal integration
POSTHOG_DESKTOP_CLOUD_COMPUTE_BILLING: 'posthog-desktop-cloud-compute-billing', // owner: #team-desktop
- PRODUCT_ANALYTICS_CHART_ALTERNATIVES: 'product-analytics-chart-alternatives', // owner: #team-product-analytics
+ PRODUCT_ANALYTICS_CHART_ALTERNATIVES: 'product-analytics-chart-gallery', // owner: #team-product-analytics
PRODUCT_ANALYTICS_DASHBOARD_COLORS: 'dashboard-colors', // owner: @thmsobrmlr #team-product-analytics
PRODUCT_ANALYTICS_DASHBOARD_MODAL_SMART_DEFAULTS: 'product-analytics-dashboard-modal-smart-defaults', // owner: @sam #team-product-analytics
PRODUCT_ANALYTICS_HOME_TAB: 'product-analytics-home-tab', // owner: #team-product-analytics
diff --git a/products/product_analytics/frontend/insights/chartAlternatives/ChartAlternatives.test.tsx b/products/product_analytics/frontend/insights/chartAlternatives/ChartAlternatives.test.tsx
index d8eef2827277..d74579e2da47 100644
--- a/products/product_analytics/frontend/insights/chartAlternatives/ChartAlternatives.test.tsx
+++ b/products/product_analytics/frontend/insights/chartAlternatives/ChartAlternatives.test.tsx
@@ -55,7 +55,7 @@ describe('ChartAlternatives', () => {
initKeaTests()
featureFlagLogic.mount()
featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.PRODUCT_ANALYTICS_CHART_ALTERNATIVES], {
- [FEATURE_FLAGS.PRODUCT_ANALYTICS_CHART_ALTERNATIVES]: true,
+ [FEATURE_FLAGS.PRODUCT_ANALYTICS_CHART_ALTERNATIVES]: 'test',
})
insightLogic(insightProps).mount()
@@ -124,12 +124,19 @@ describe('ChartAlternatives', () => {
)
})
- it('renders the chart switch control only while the flag is on', async () => {
+ it.each([
+ ['the flag is off', [], {}],
+ [
+ 'the control variant is served',
+ [FEATURE_FLAGS.PRODUCT_ANALYTICS_CHART_ALTERNATIVES],
+ { [FEATURE_FLAGS.PRODUCT_ANALYTICS_CHART_ALTERNATIVES]: 'control' },
+ ],
+ ])('hides the chart switch control when %s', async (_, flags, variants) => {
setQuery(makeTrendsQuery())
alternativesLogic()
await waitFor(() => expect(document.querySelector('[data-attr="chart-alternatives-all"]')).toBeInTheDocument())
- featureFlagLogic.actions.setFeatureFlags([], {})
+ featureFlagLogic.actions.setFeatureFlags(flags, variants)
await waitFor(() =>
expect(document.querySelector('[data-attr="chart-alternatives-all"]')).not.toBeInTheDocument()
)
diff --git a/products/product_analytics/frontend/insights/chartAlternatives/chartAlternativesLogic.ts b/products/product_analytics/frontend/insights/chartAlternatives/chartAlternativesLogic.ts
index f4912f3356c3..34e35163e92a 100644
--- a/products/product_analytics/frontend/insights/chartAlternatives/chartAlternativesLogic.ts
+++ b/products/product_analytics/frontend/insights/chartAlternatives/chartAlternativesLogic.ts
@@ -267,7 +267,7 @@ export const chartAlternativesLogic = kea<chartAlternativesLogicType>([
query: Node | null,
trendsSource: TrendsQuery | null
): boolean =>
- !!featureFlags[FEATURE_FLAGS.PRODUCT_ANALYTICS_CHART_ALTERNATIVES] &&
+ featureFlags[FEATURE_FLAGS.PRODUCT_ANALYTICS_CHART_ALTERNATIVES] === 'test' &&
isEditableSurface &&
isTrends &&
!!query &&
diff --git a/products/product_analytics/frontend/insights/chartAlternatives/chartPreviewsLogic.test.ts b/products/product_analytics/frontend/insights/chartAlternatives/chartPreviewsLogic.test.ts
index 5e8ee74ca529..335f5deed112 100644
--- a/products/product_analytics/frontend/insights/chartAlternatives/chartPreviewsLogic.test.ts
+++ b/products/product_analytics/frontend/insights/chartAlternatives/chartPreviewsLogic.test.ts
@@ -60,7 +60,7 @@ describe('chartPreviewsLogic', () => {
initKeaTests()
featureFlagLogic.mount()
featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.PRODUCT_ANALYTICS_CHART_ALTERNATIVES], {
- [FEATURE_FLAGS.PRODUCT_ANALYTICS_CHART_ALTERNATIVES]: true,
+ [FEATURE_FLAGS.PRODUCT_ANALYTICS_CHART_ALTERNATIVES]: 'test',
})
insightLogic(insightProps).mount()
insightDataLogic(insightProps).mount()