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(marketing): show every new dashboard section behind one flag (#102272)

Javier Bahamondes674888fd879c
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index ddaa4520dec1..1a9916d1d117 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -383,13 +383,13 @@ export const FEATURE_FLAGS = {
MANAGED_MIGRATIONS_TRIAL_RUNS: 'managed-migrations-trial-runs', // owner: #team-ingestion, gates trial runs for managed migrations
MANAGED_VIEWSETS: 'managed-viewsets', // owner: @rafaeelaudibert #team-revenue-analytics
MARKETING_ANALYTICS_AI: 'marketing-analytics-ai', // owner: @jabahamondes #team-web-analytics
- MARKETING_ANALYTICS_ATTRIBUTION: 'marketing-analytics-attribution', // owner: @jabahamondes #team-web-analytics — gates the Attribution tab
+ MARKETING_ANALYTICS_ATTRIBUTION: 'marketing-analytics-attribution', // owner: @jabahamondes #team-web-analytics — gates the legacy Attribution explorer tab; the new dashboard ignores it
MARKETING_ANALYTICS_COSTS_PRECOMPUTATION: 'marketing-analytics-costs-precomputation', // owner: @jabahamondes #team-web-analytics — gates reading the native cost precompute table
MARKETING_ANALYTICS_EXTENDED_DRILL_DOWN: 'marketing-analytics-extended-drill-down', // owner: @jabahamondes #team-web-analytics
MARKETING_ANALYTICS_MCP: 'marketing-analytics-mcp', // owner: @jabahamondes #team-web-analytics — gates MCP tool exposure (read-only marketing-analytics tools)
MARKETING_ANALYTICS_MULTI_TOUCH_ATTRIBUTION: 'marketing-analytics-multi-touch-attribution', // owner: @jabahamondes #team-web-analytics
- MARKETING_ANALYTICS_NEW_DASHBOARD: 'new-marketing-analytics-dashboard', // owner: @jabahamondes #team-web-analytics — gates the WIP redesigned dashboard tab
- MARKETING_ANALYTICS_RETENTION: 'marketing-analytics-retention', // owner: @jabahamondes #team-web-analytics — gates the Retention explorer tab
+ MARKETING_ANALYTICS_NEW_DASHBOARD: 'new-marketing-analytics-dashboard', // owner: @jabahamondes #team-web-analytics — gates the redesigned dashboard and all of its sections
+ MARKETING_ANALYTICS_RETENTION: 'marketing-analytics-retention', // owner: @jabahamondes #team-web-analytics — gates the legacy Retention explorer tab; the new dashboard ignores it
MARKETING_ANALYTICS_RETURN_METRICS: 'marketing-analytics-return-metrics', // owner: @jabahamondes #team-web-analytics — gates the ROAS column
MARKETING_ANALYTICS_SETUP: 'marketing-analytics-setup', // owner: @jabahamondes #team-web-analytics — gates the Setup tab and its setup_plan / apply_setup_ops endpoints
MARKETING_ANALYTICS_UTM_AUDIT: 'marketing-analytics-utm-audit', // owner: @jabahamondes #team-web-analytics
diff --git a/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.test.tsx b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.test.tsx
index 4fc525277655..977b744d3f6e 100644
--- a/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.test.tsx
+++ b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.test.tsx
@@ -1,8 +1,6 @@
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
import { useValues } from 'kea'
-import { FEATURE_FLAGS } from 'lib/constants'
-
import { NewMarketingAnalyticsDashboard } from 'products/marketing_analytics/frontend/dashboard/NewMarketingAnalyticsDashboard'
jest.mock('scenes/marketing-analytics/Setup/sectionRouting', () => ({ suggestionsForSection: () => [] }))
@@ -87,17 +85,8 @@ jest.mock('scenes/web-analytics/tabs/marketing-analytics/frontend/components/Ret
describe('NewMarketingAnalyticsDashboard', () => {
afterEach(cleanup)
- it.each([
- [false, false],
- [true, false],
- [false, true],
- [true, true],
- ])('keeps conversion (%s) and retention (%s) independently gated alongside traffic', (conversion, retention) => {
+ it('shows every section without per-section flags', () => {
jest.mocked(useValues).mockReturnValue({
- featureFlags: {
- [FEATURE_FLAGS.MARKETING_ANALYTICS_ATTRIBUTION]: conversion,
- [FEATURE_FLAGS.MARKETING_ANALYTICS_RETENTION]: retention,
- },
dateFilter: { dateFrom: '-30d', dateTo: null },
compareFilter: { compare: false },
shouldFilterTestAccounts: false,
@@ -137,26 +126,16 @@ describe('NewMarketingAnalyticsDashboard', () => {
})
expect(screen.queryByLabelText('Acquisition')).toBeNull()
expect(screen.getByLabelText('Engagement')).not.toBeNull()
- expect(screen.queryByText('Conversion') !== null).toBe(conversion)
- expect(screen.queryByText('Retention') !== null).toBe(retention)
- expect(screen.queryByText('Revenue') !== null).toBe(conversion)
- if (conversion) {
- fireEvent.click(screen.getByText('Conversion'))
- }
- expect(screen.queryByText('Attribution explorer') !== null).toBe(conversion)
- expect(screen.queryByLabelText('Engagement') !== null).toBe(!conversion)
- if (conversion) {
- fireEvent.click(screen.getByText('Revenue'))
- }
- expect(screen.queryByText('Attribution explorer')).toBeNull()
- expect(screen.queryByLabelText('Revenue') !== null).toBe(conversion)
- if (retention) {
- fireEvent.click(screen.getByText('Retention'))
- }
- expect(screen.queryByText('Retention explorer') !== null).toBe(retention)
- expect(screen.queryByText('Compare periods') !== null).toBe(!conversion && !retention)
- expect(screen.queryByText('Reload summary') !== null).toBe(!conversion && !retention)
+ fireEvent.click(screen.getByText('Conversion'))
+ expect(screen.getByText('Attribution explorer')).not.toBeNull()
+ expect(screen.queryByLabelText('Engagement')).toBeNull()
+ fireEvent.click(screen.getByText('Revenue'))
expect(screen.queryByText('Attribution explorer')).toBeNull()
+ expect(screen.getByLabelText('Revenue')).not.toBeNull()
+ fireEvent.click(screen.getByText('Retention'))
+ expect(screen.getByText('Retention explorer')).not.toBeNull()
+ expect(screen.queryByText('Compare periods')).toBeNull()
+ expect(screen.queryByText('Reload summary')).toBeNull()
fireEvent.click(screen.getByText('Acquisition'))
expect(screen.getByLabelText('Acquisition')).not.toBeNull()
expect(screen.queryByText('Compare periods')).not.toBeNull()
diff --git a/products/marketing_analytics/frontend/dashboard/NewMarketingAnalyticsDashboard.tsx b/products/marketing_analytics/frontend/dashboard/NewMarketingAnalyticsDashboard.tsx
index 9b42a2adf218..108f9ee75b71 100644
--- a/products/marketing_analytics/frontend/dashboard/NewMarketingAnalyticsDashboard.tsx
+++ b/products/marketing_analytics/frontend/dashboard/NewMarketingAnalyticsDashboard.tsx
@@ -6,9 +6,7 @@ import { LemonBanner, LemonButton, LemonCard, LemonCollapse, LemonSelect, LemonS
import { CompareFilter } from 'lib/components/CompareFilter/CompareFilter'
import { DateFilter } from 'lib/components/DateFilter/DateFilter'
-import { FEATURE_FLAGS } from 'lib/constants'
import { useLocalStorage } from 'lib/hooks/useLocalStorage'
-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { suggestionsForSection } from 'scenes/marketing-analytics/Setup/sectionRouting'
import { SuggestionRow } from 'scenes/marketing-analytics/Setup/SuggestionRow'
import { teamLogic } from 'scenes/teamLogic'
@@ -51,54 +49,46 @@ const TRAFFIC_BREAKDOWNS = [
{ value: WebStatsBreakdown.InitialPage, label: 'Landing page' },
]
+const SECTIONS = [
+ {
+ key: 'acquisition',
+ title: 'Acquisition',
+ description: 'Visitors, sessions and pageviews',
+ icon: <IconPeople />,
+ },
+ {
+ key: 'engagement',
+ title: 'Engagement',
+ description: 'Session duration and bounce rate',
+ icon: <IconCursor />,
+ },
+ {
+ key: 'retention',
+ title: 'Retention',
+ description: 'Returning visitors by cohort',
+ icon: <IconRetention />,
+ },
+ {
+ key: 'conversion',
+ title: 'Conversion',
+ description: 'Goals and conversion paths',
+ icon: <IconTarget />,
+ },
+ {
+ key: 'revenue',
+ title: 'Revenue',
+ description: 'Revenue by attribution model',
+ icon: <IconTrends />,
+ },
+]
+
// Scaffold for the redesigned marketing analytics dashboard, gated behind the
// `new-marketing-analytics-dashboard` feature flag.
export function NewMarketingAnalyticsDashboard(): JSX.Element {
const [selectedSection, setSelectedSection] = useState('acquisition')
const [trafficBreakdown, setTrafficBreakdown] = useState(WebStatsBreakdown.InitialChannelType)
const { currentTeam, currentTeamLoading } = useValues(teamLogic)
- const { featureFlags } = useValues(featureFlagLogic)
- const sections = [
- {
- key: 'acquisition',
- title: 'Acquisition',
- description: 'Visitors, sessions and pageviews',
- icon: <IconPeople />,
- },
- {
- key: 'engagement',
- title: 'Engagement',
- description: 'Session duration and bounce rate',
- icon: <IconCursor />,
- },
- ...(featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_RETENTION]
- ? [
- {
- key: 'retention',
- title: 'Retention',
- description: 'Returning visitors by cohort',
- icon: <IconRetention />,
- },
- ]
- : []),
- ...(featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_ATTRIBUTION]
- ? [
- {
- key: 'conversion',
- title: 'Conversion',
- description: 'Goals and conversion paths',
- icon: <IconTarget />,
- },
- {
- key: 'revenue',
- title: 'Revenue',
- description: 'Revenue by attribution model',
- icon: <IconTrends />,
- },
- ]
- : []),
- ]
- const activeSection = sections.some(({ key }) => key === selectedSection) ? selectedSection : 'acquisition'
+ const activeSection = SECTIONS.some(({ key }) => key === selectedSection) ? selectedSection : 'acquisition'
const isTraffic = activeSection === 'acquisition' || activeSection === 'engagement'
const { revenueGoals, selectedRevenueGoalId, revenueQuery, breakdownBy } = useValues(marketingAttributionLogic)
const { setRevenueGoalId, setBreakdownBy } = useActions(marketingAttributionLogic)
@@ -255,7 +245,7 @@ export function NewMarketingAnalyticsDashboard(): JSX.Element {
)}
</div>
<nav aria-label="Dashboard sections" className="flex flex-wrap gap-1 rounded border p-1 w-fit max-w-full">
- {sections.map(({ key, title, icon }) => (
+ {SECTIONS.map(({ key, title, icon }) => (
<LemonButton
key={key}
type="tertiary"
@@ -291,7 +281,7 @@ export function NewMarketingAnalyticsDashboard(): JSX.Element {
<section key={title} className="flex flex-col gap-2" aria-label={title}>
<h2 className="mb-0">{title}</h2>
<p className="text-secondary mb-2">
- {sections.find(({ key }) => key === activeSection)?.description}
+ {SECTIONS.find(({ key }) => key === activeSection)?.description}
</p>
<div className="grid grid-cols-[repeat(auto-fit,minmax(min(100%,12rem),1fr))] auto-rows-fr gap-2">
<div className="contents">
@@ -351,7 +341,7 @@ export function NewMarketingAnalyticsDashboard(): JSX.Element {
<section aria-label="Conversion" className="flex flex-col gap-2">
<h2 className="mb-0">Conversion</h2>
<p className="text-secondary mb-2">
- {sections.find(({ key }) => key === activeSection)?.description}
+ {SECTIONS.find(({ key }) => key === activeSection)?.description}
</p>
<AttributionTab />
</section>