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(web-analytics): paginate breakdown tables in the expanded modal (#69948)

Xander0f839e6a50a7
diff --git a/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts b/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts
index 933a12882771..50777d6d90c6 100644
--- a/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts
+++ b/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts
@@ -65,6 +65,8 @@ import {
SessionsQueryResponse,
TracesQuery,
TracesQueryResponse,
+ WebStatsTableQuery,
+ WebStatsTableQueryResponse,
} from '~/queries/schema/schema-general'
import {
isAccountsQuery,
@@ -81,6 +83,7 @@ import {
isSessionQuery,
isSessionsQuery,
isTracesQuery,
+ isWebStatsTableQuery,
} from '~/queries/utils'
import { TeamType } from '~/types'
@@ -464,7 +467,8 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
isErrorTrackingQuery(props.query) ||
isSessionsQuery(props.query) ||
isMarketingAnalyticsTableQuery(props.query) ||
- isAccountsQuery(props.query)
+ isAccountsQuery(props.query) ||
+ isWebStatsTableQuery(props.query)
) {
const newResponse =
(await performQuery(
@@ -489,6 +493,7 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
| SessionsQueryResponse
| MarketingAnalyticsTableQueryResponse
| AccountsQueryResponse
+ | WebStatsTableQueryResponse
let results = [...(queryResponse?.results ?? []), ...(newResponse?.results ?? [])]
@@ -837,7 +842,8 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
isSessionQuery(query) ||
isSessionsQuery(query) ||
isMarketingAnalyticsTableQuery(query) ||
- isAccountsQuery(query)) &&
+ isAccountsQuery(query) ||
+ isWebStatsTableQuery(query)) &&
!responseError &&
!dataLoading
) {
@@ -853,6 +859,7 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
| SessionsQueryResponse
| MarketingAnalyticsTableQueryResponse
| AccountsQueryResponse
+ | WebStatsTableQueryResponse
)?.hasMore
) {
const sortKey =
@@ -890,6 +897,7 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
| SessionsQueryResponse
| MarketingAnalyticsTableQueryResponse
| AccountsQueryResponse
+ | WebStatsTableQueryResponse
)?.results
return {
...query,
@@ -908,6 +916,7 @@ export const dataNodeLogic = kea<dataNodeLogicType>([
| SessionsQuery
| MarketingAnalyticsTableQuery
| AccountsQuery
+ | WebStatsTableQuery
}
}
}
diff --git a/frontend/src/queries/nodes/DataTable/DataTable.tsx b/frontend/src/queries/nodes/DataTable/DataTable.tsx
index 1169ce3c86d0..93052e518053 100644
--- a/frontend/src/queries/nodes/DataTable/DataTable.tsx
+++ b/frontend/src/queries/nodes/DataTable/DataTable.tsx
@@ -1086,7 +1086,8 @@ export function DataTable({
}
footer={
(dataTableRows ?? []).length > 0 &&
- !sourceFeatures.has(QueryFeature.hideLoadNextButton) ? (
+ (context?.showLoadNextButton ||
+ !sourceFeatures.has(QueryFeature.hideLoadNextButton)) ? (
<LoadNext query={query.source} />
) : null
}
diff --git a/frontend/src/queries/types.ts b/frontend/src/queries/types.ts
index 52cbde35a952..84764b575cec 100644
--- a/frontend/src/queries/types.ts
+++ b/frontend/src/queries/types.ts
@@ -42,6 +42,11 @@ export interface QueryContext<Q extends QuerySchema = QuerySchema> {
refresh?: RefreshType
/** Extra source feature for Data Tables */
extraDataTableQueryFeatures?: QueryFeature[]
+ /**
+ * Force-show the DataTable "load more" footer even for query kinds that normally hide it
+ * (e.g. Web analytics breakdown tables when expanded in the "Show more" modal).
+ */
+ showLoadNextButton?: boolean
/** Allow customization of file name when exporting */
fileNameForExport?: string
/** Cohort ID to enable cohort-specific features like View Replays button */
diff --git a/frontend/src/scenes/web-analytics/WebAnalyticsModal.tsx b/frontend/src/scenes/web-analytics/WebAnalyticsModal.tsx
index 13722cd39891..74c9ae4647db 100644
--- a/frontend/src/scenes/web-analytics/WebAnalyticsModal.tsx
+++ b/frontend/src/scenes/web-analytics/WebAnalyticsModal.tsx
@@ -57,6 +57,7 @@ export const WebAnalyticsModal = (): JSX.Element | null => {
showIntervalSelect={modal.showIntervalSelect}
control={modal.control}
tileId={modal.tileId}
+ enablePagination
/>
</LemonModal.Content>
<div className="flex flex-row justify-end">
diff --git a/frontend/src/scenes/web-analytics/tiles/WebAnalyticsTile.tsx b/frontend/src/scenes/web-analytics/tiles/WebAnalyticsTile.tsx
index e6531af6fc24..cc989f2eb73a 100644
--- a/frontend/src/scenes/web-analytics/tiles/WebAnalyticsTile.tsx
+++ b/frontend/src/scenes/web-analytics/tiles/WebAnalyticsTile.tsx
@@ -918,12 +918,15 @@ export const WebStatsTableTile = ({
attachTo,
headerSlot,
uniqueKey,
+ enablePagination,
}: QueryWithInsightProps<DataTableNode> & {
breakdownBy: WebStatsBreakdown
control?: JSX.Element
tileId: TileId
headerSlot?: React.ReactNode
uniqueKey: string
+ /** Show the "load more" footer so long-tail breakdowns can be paginated (used by the expanded modal). */
+ enablePagination?: boolean
}): JSX.Element => {
const { togglePropertyFilter } = useActions(webAnalyticsLogic)
const { productTab } = useValues(webAnalyticsLogic)
@@ -1076,8 +1079,9 @@ export const WebStatsTableTile = ({
insightProps,
rowProps,
compareFilter: 'compareFilter' in query.source ? query.source.compareFilter : undefined,
+ showLoadNextButton: enablePagination,
}
- }, [onClick, insightProps, breakdownBy, key, type, isCompoundBreakdown, query])
+ }, [onClick, insightProps, breakdownBy, key, type, isCompoundBreakdown, query, enablePagination])
const numericColumns = PAGE_LIKE_BREAKDOWNS.has(breakdownBy) ? 3 : 2
const dataNodeLogicProps = buildDataTableTileDataNodeLogicProps({
@@ -1435,12 +1439,15 @@ export const WebQuery = ({
attachTo,
uniqueKey,
headerSlot,
+ enablePagination,
}: QueryWithInsightProps<QuerySchema> & {
showIntervalSelect?: boolean
control?: JSX.Element
tileId: TileId
uniqueKey: string
headerSlot?: React.ReactNode
+ /** Show the "load more" footer on breakdown tables (used by the expanded modal). */
+ enablePagination?: boolean
}): JSX.Element => {
const { productTab, shouldStripQueryParams: stripQueryParamsDashboard } = useValues(webAnalyticsLogic)
const { stripQueryParams: stripQueryParamsPageReports } = useValues(pageReportsLogic)
@@ -1469,6 +1476,7 @@ export const WebQuery = ({
tileId={tileId}
headerSlot={headerSlot}
uniqueKey={uniqueKey}
+ enablePagination={enablePagination}
/>
)
}