: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(web-analytics): add opt-in tile header and data table toolbar props (#127864)
Javier Bahamondes1deab44412dd
diff --git a/frontend/src/queries/nodes/DataTable/DataTable.tsx b/frontend/src/queries/nodes/DataTable/DataTable.tsxindex 0a391901ee25..19709d7a102c 100644--- a/frontend/src/queries/nodes/DataTable/DataTable.tsx+++ b/frontend/src/queries/nodes/DataTable/DataTable.tsx@@ -988,6 +988,7 @@ export function DataTable({fileNameForExport={context?.fileNameForExport}excludedColumns={context?.dataTableExportExcludedColumns}downloadQuery={context?.dataTableExportQuery}+ iconOnly={context?.dataTableExportIconOnly}/>) : null,showExport && showOpenEditorButton ? (@@ -1028,7 +1029,12 @@ export function DataTable({{context?.compactDataTableToolbar ? (<>{compactToolbarLeft.length > 0 || compactToolbarRight.length > 0 ? (- <div className="flex gap-2 items-center flex-wrap">+ <div+ className={clsx(+ 'flex gap-2 items-center flex-wrap',+ context?.dataTableToolbarClassName+ )}+ >{compactToolbarLeft}{compactToolbarLeft.length > 0 && compactToolbarRight.length > 0 ? (<div className="flex-1" />diff --git a/frontend/src/queries/nodes/DataTable/DataTableExport.tsx b/frontend/src/queries/nodes/DataTable/DataTableExport.tsxindex 6e79faf674c5..8ccd17b2019e 100644--- a/frontend/src/queries/nodes/DataTable/DataTableExport.tsx+++ b/frontend/src/queries/nodes/DataTable/DataTableExport.tsx@@ -116,6 +116,7 @@ interface DataTableExportProps {fileNameForExport?: stringexcludedColumns?: string[]downloadQuery?: DataTableNode+ iconOnly?: boolean}export function DataTableExport({@@ -123,6 +124,7 @@ export function DataTableExport({fileNameForExport,excludedColumns = [],downloadQuery,+ iconOnly = false,}: DataTableExportProps): JSX.Element | null {const { dataTableRows, columnsInResponse, columnsInQuery, queryWithDefaults } = useValues(dataTableLogic)const { startExport, createStaticCohort } = useActions(exportsLogic)@@ -139,6 +141,7 @@ export function DataTableExport({(isEventsQuery(source) || isPersonsNode(source) ? source.properties?.length || 0 : 0) +(isEventsQuery(source) && source.event ? 1 : 0) +(isPersonsNode(source) && source.search ? 1 : 0)+ const exportLabel = `Export${filterCount > 0 ? ` (${pluralize(filterCount, 'filter')})` : ''}`const canExportAllColumns = isEventsQuery(source) && source.select.includes('*')const showExportClipboardButtons =isPersonsNode(source) || isEventsQuery(source) || isHogQLQuery(source) || isMarketingAnalyticsTableQuery(source)@@ -302,8 +305,10 @@ export function DataTableExport({data-attr="data-table-export-menu"size="small"disabledReason={accessControlDisabledReason ?? undefined}+ tooltip={iconOnly ? exportLabel : undefined}+ aria-label={iconOnly ? exportLabel : undefined}>- Export{filterCount > 0 ? ` (${pluralize(filterCount, 'filter')})` : ''}+ {iconOnly ? null : exportLabel}</LemonButton></LemonMenu><DataTableExportColumnsModaldiff --git a/frontend/src/queries/types.ts b/frontend/src/queries/types.tsindex cbc612d66dc6..8adc640f1dce 100644--- a/frontend/src/queries/types.ts+++ b/frontend/src/queries/types.ts@@ -85,6 +85,8 @@ export interface QueryContext<Q extends QuerySchema = QuerySchema> {/** Expected total row count from another source. The footer shows "X of Y" when all rows are loaded and the counts differ. */dataTableExpectedTotalRows?: numbercompactDataTableToolbar?: boolean+ dataTableToolbarClassName?: string+ dataTableExportIconOnly?: booleanhideRecordingButton?: boolean/** Custom expandable config for DataTable rows */expandable?: ExpandableConfig<DataTableRow>diff --git a/frontend/src/scenes/web-analytics/WebTileHeader.tsx b/frontend/src/scenes/web-analytics/WebTileHeader.tsxindex 2c27ca56a952..46a662ab0945 100644--- a/frontend/src/scenes/web-analytics/WebTileHeader.tsx+++ b/frontend/src/scenes/web-analytics/WebTileHeader.tsx@@ -3,6 +3,7 @@ import { LemonButton, LemonMenu, LemonMenuItem, LemonSelectOptionLeaf } from '@pimport { useWindowSize } from 'lib/hooks/useWindowSize'import { IconOpenInNew, IconTableChart } from 'lib/lemon-ui/icons'+import { cn } from 'lib/utils/css-classes'import { TileId, TileVisualizationOption } from './common'import { LearnMorePopover, LearnMorePopoverProps } from './WebAnalyticsDashboard'@@ -19,6 +20,8 @@ export interface WebTileHeaderProps {title?: React.ReactNodetitlePrefix?: stringtitleDropdown?: DropdownConfig<string>+ breakdownDropdown?: DropdownConfig<string>+ className?: stringdocs?: LearnMorePopoverPropsintervalSelector?: {node: React.ReactNode@@ -28,10 +31,18 @@ export interface WebTileHeaderProps {onChange: (value: TileVisualizationOption) => void}openInsight?: WebTileOpenInsightProps- overflowMenuItems: LemonMenuItem[]+ overflowMenuItems?: LemonMenuItem[]}-function TitleDropdown({ tileId, dropdown }: { tileId: TileId; dropdown: DropdownConfig<string> }): JSX.Element {+function TitleDropdown({+ tileId,+ dropdown,+ dataAttrSuffix = '',+}: {+ tileId: TileId+ dropdown: DropdownConfig<string>+ dataAttrSuffix?: string+}): JSX.Element {const currentLabel = dropdown.options.find((o) => o.value === dropdown.value)?.label ?? dropdown.valueconst items: LemonMenuItem[] = dropdown.options.map((opt) => ({label: opt.label ?? String(opt.value),@@ -44,7 +55,7 @@ function TitleDropdown({ tileId, dropdown }: { tileId: TileId; dropdown: Dropdow<buttontype="button"className="inline-flex items-center gap-1 m-0 p-0 bg-transparent border-0 cursor-pointer text-base font-semibold text-current hover:text-accent underline decoration-dotted decoration-from-font underline-offset-4 min-w-0 max-w-full"- data-attr={`web-analytics-title-dropdown-${tileId}`}+ data-attr={`web-analytics-title-dropdown-${tileId}${dataAttrSuffix}`}><span className="truncate">{currentLabel}</span><IconChevronDown className="text-lg shrink-0" />@@ -58,6 +69,8 @@ export function WebTileHeader({title,titlePrefix,titleDropdown,+ breakdownDropdown,+ className,docs,intervalSelector,visualizationToggle,@@ -68,7 +81,7 @@ export function WebTileHeader({const isCompactHeader = isWindowLessThan('lg')const isGraph = visualizationToggle?.value === 'graph'const titleNode =- titleDropdown || title || docs ? (+ titleDropdown || title || docs || breakdownDropdown ? (<h2 className="flex-1 min-w-0 m-0 flex flex-row items-center gap-1.5 text-base font-semibold">{titlePrefix && <span className="shrink-0">{titlePrefix}</span>}{titleDropdown ? (@@ -76,6 +89,12 @@ export function WebTileHeader({) : (title && <span>{title}</span>)}+ {breakdownDropdown && (+ <>+ <span className="shrink-0">by</span>+ <TitleDropdown tileId={tileId} dropdown={breakdownDropdown} dataAttrSuffix="-breakdown" />+ </>+ )}{docs && <LearnMorePopover url={docs.url} title={docs.title} description={docs.description} />}</h2>) : (@@ -83,7 +102,12 @@ export function WebTileHeader({)return (- <div className="flex flex-row items-center self-stretch gap-1 sm:gap-2 min-h-10 px-3 py-2">+ <div+ className={cn(+ 'flex flex-row flex-wrap items-center self-stretch gap-1 sm:gap-2 min-h-10 px-3 py-2',+ className+ )}+ >{titleNode}{intervalSelector && (@@ -118,14 +142,16 @@ export function WebTileHeader({</LemonButton>)}- <LemonMenu items={overflowMenuItems} placement="bottom-end">- <LemonButton- icon={<IconEllipsis />}- size="small"- aria-label="More actions"- data-attr={`web-analytics-tile-overflow-${tileId}`}- />- </LemonMenu>+ {overflowMenuItems && overflowMenuItems.length > 0 && (+ <LemonMenu items={overflowMenuItems} placement="bottom-end">+ <LemonButton+ icon={<IconEllipsis />}+ size="small"+ aria-label="More actions"+ data-attr={`web-analytics-tile-overflow-${tileId}`}+ />+ </LemonMenu>+ )}</div>)}diff --git a/products/marketing_analytics/frontend/components/MetricSourceBadge.tsx b/products/marketing_analytics/frontend/components/MetricSourceBadge.tsxnew file mode 100644index 000000000000..9c98d5629b8f--- /dev/null+++ b/products/marketing_analytics/frontend/components/MetricSourceBadge.tsx@@ -0,0 +1,29 @@+import { IconGitBranch } from '@posthog/icons'+import { Tooltip } from '@posthog/lemon-ui'++import posthogIcon from 'public/posthog-icon.svg'++import type { OverviewMetricGroup as OverviewMetricSource } from '../overview/overviewMetricConfiguration'++const SOURCE_DESCRIPTIONS: Record<OverviewMetricSource, string> = {+ platforms: 'Reported directly by your ad platforms and added together',+ posthog: 'Calculated from your PostHog event data',+}++export function MetricSourceBadge({ source }: { source: OverviewMetricSource }): JSX.Element {+ return (+ <Tooltip title={SOURCE_DESCRIPTIONS[source]}>+ <span+ className="inline-flex shrink-0 items-center"+ aria-label={SOURCE_DESCRIPTIONS[source]}+ data-attr={`marketing-metric-source-${source}`}+ >+ {source === 'posthog' ? (+ <img src={posthogIcon} alt="" className="size-4" />+ ) : (+ <IconGitBranch className="size-4 text-secondary" />+ )}+ </span>+ </Tooltip>+ )+}