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): list pages in page reports (#123199)

Jordan Mryyane7ab5c8f52d4
diff --git a/frontend/src/scenes/web-analytics/PageReports.tsx b/frontend/src/scenes/web-analytics/PageReports.tsx
index 289d01b98f03..f1872b5f0e36 100644
--- a/frontend/src/scenes/web-analytics/PageReports.tsx
+++ b/frontend/src/scenes/web-analytics/PageReports.tsx
@@ -6,8 +6,12 @@ import { pngHoggie } from 'lib/brand/hoggies'
import { DateFilter } from 'lib/components/DateFilter/DateFilter'
import { FilterBar } from 'lib/components/FilterBar'
import { FEATURE_FLAGS } from 'lib/constants'
+import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'
import { LemonInputSelect } from 'lib/lemon-ui/LemonInputSelect/LemonInputSelect'
+import { PageReportsDirectory } from 'products/web_analytics/frontend/pageReports/PageReportsDirectory'
+import { pageReportsTeaserLogic } from 'products/web_analytics/frontend/pageReports/pageReportsTeaserLogic'
+
import { webAnalyticsDateMapping } from './constants'
import { pageReportsLogic } from './pageReportsLogic'
import { PathCleaningToggle } from './PathCleaningToggle'
@@ -34,8 +38,16 @@ function NoUrlSelectedMessage(): JSX.Element {
}
export function PageReportsFilters({ tabs }: { tabs: JSX.Element }): JSX.Element {
- const { pageUrlOptions, pageUrl, isLoading, dateFilter, pageUrlSearchTerm, featureFlags, isPathCleaningEnabled } =
- useValues(pageReportsLogic)
+ const {
+ pageUrlOptions,
+ pageUrl,
+ isLoading,
+ dateFilter,
+ pageUrlSearchTerm,
+ featureFlags,
+ isPathCleaningEnabled,
+ isDirectoryEnabled,
+ } = useValues(pageReportsLogic)
const { setPageUrl, setPageUrlSearchTerm, loadPages, setDates, setIsPathCleaningEnabled } =
useActions(pageReportsLogic)
@@ -61,22 +73,26 @@ export function PageReportsFilters({ tabs }: { tabs: JSX.Element }): JSX.Element
dateOptions={webAnalyticsDateMapping}
/>
<WebAnalyticsCompareFilter />
- <LemonInputSelect
- className="flex-1 min-w-0 basis-64"
- allowCustomValues={true}
- fullWidth={true}
- placeholder="Click or type to see top pages, or paste a URL"
- loading={isLoading}
- size="small"
- mode="single"
- value={pageUrl ? [pageUrl] : null}
- onChange={(val: string[]) => setPageUrl(val.length > 0 ? val[0] : null)}
- options={pageUrlOptions}
- onInputChange={(val: string) => setPageUrlSearchTerm(val)}
- data-attr="page-reports-url-search"
- onFocus={() => loadPages('')}
- emptyStateComponent={emptyStateComponent}
- />
+ {isDirectoryEnabled && !pageUrl ? (
+ <div className="flex-1" />
+ ) : (
+ <LemonInputSelect
+ className="flex-1 min-w-0 basis-64"
+ allowCustomValues={true}
+ fullWidth={true}
+ placeholder="Click or type to see top pages, or paste a URL"
+ loading={isLoading}
+ size="small"
+ mode="single"
+ value={pageUrl ? [pageUrl] : null}
+ onChange={(val: string[]) => setPageUrl(val.length > 0 ? val[0] : null)}
+ options={pageUrlOptions}
+ onInputChange={(val: string) => setPageUrlSearchTerm(val)}
+ data-attr="page-reports-url-search"
+ onFocus={() => loadPages('')}
+ emptyStateComponent={emptyStateComponent}
+ />
+ )}
<PathCleaningToggle value={isPathCleaningEnabled} onChange={setIsPathCleaningEnabled} />
<WebAnalyticsDomainSelector />
</div>
@@ -86,7 +102,24 @@ export function PageReportsFilters({ tabs }: { tabs: JSX.Element }): JSX.Element
}
export function PageReports(): JSX.Element {
- const { hasPageUrl, tiles } = useValues(pageReportsLogic)
+ const { hasPageUrl, tiles, isDirectoryEnabled, pageUrl } = useValues(pageReportsLogic)
+ const { recordPageReportsVisit } = useActions(pageReportsTeaserLogic)
+
+ useOnMountEffect(() => {
+ if (isDirectoryEnabled) {
+ recordPageReportsVisit()
+ }
+ })
+
+ if (isDirectoryEnabled) {
+ return pageUrl ? (
+ <div className="space-y-2 mt-2 h-full min-h-0">
+ <Tiles tiles={tiles} compact={true} />
+ </div>
+ ) : (
+ <PageReportsDirectory />
+ )
+ }
if (!hasPageUrl) {
return (
diff --git a/frontend/src/scenes/web-analytics/WebAnalyticsDashboard.tsx b/frontend/src/scenes/web-analytics/WebAnalyticsDashboard.tsx
index 239acb0f89e3..4ab3cdb73720 100644
--- a/frontend/src/scenes/web-analytics/WebAnalyticsDashboard.tsx
+++ b/frontend/src/scenes/web-analytics/WebAnalyticsDashboard.tsx
@@ -66,6 +66,7 @@ import { AgentAnalytics } from 'products/web_analytics/frontend/agent_analytics/
import { AgentAnalyticsFilters } from 'products/web_analytics/frontend/agent_analytics/AgentAnalyticsFilters'
import { ContentAutopilot } from 'products/web_analytics/frontend/contentAutopilot/ContentAutopilot'
import { MarketingAnalyticsFilterHint } from 'products/web_analytics/frontend/marketing/MarketingAnalyticsFilterHint'
+import { PageReportsTabLabel } from 'products/web_analytics/frontend/pageReports/PageReportsTabLabel'
import { BotAnalyticsFilters } from './BotAnalyticsFilters'
import { botAnalyticsLogic } from './botAnalyticsLogic'
@@ -121,7 +122,7 @@ export const Tiles = (props: { tiles?: WebAnalyticsTile[]; compact?: boolean }):
)
}
-const QueryTileItem = ({ tile }: { tile: QueryTile }): JSX.Element => {
+export const QueryTileItem = ({ tile }: { tile: QueryTile }): JSX.Element => {
const { query, title, layout, insightProps, control, showIntervalSelect, docs } = tile
const { featureFlags } = useValues(featureFlagLogic)
const useTileHeaderV2 = featureFlags[FEATURE_FLAGS.WEB_ANALYTICS_TILE_HEADER_V2] === 'test'
@@ -972,7 +973,15 @@ const WebAnalyticsTabs = (): JSX.Element => {
tabs={[
{ key: ProductTab.ANALYTICS, label: 'Web analytics', link: '/web' },
{ key: ProductTab.WEB_VITALS, label: 'Web vitals', link: '/web/web-vitals' },
- { key: ProductTab.PAGE_REPORTS, label: 'Page reports', link: '/web/page-reports' },
+ {
+ key: ProductTab.PAGE_REPORTS,
+ label: featureFlags[FEATURE_FLAGS.WEB_ANALYTICS_PAGE_REPORTS_DIRECTORY] ? (
+ <PageReportsTabLabel />
+ ) : (
+ 'Page reports'
+ ),
+ link: '/web/page-reports',
+ },
...liveTab(),
...botAnalyticsTab(featureFlags),
...pagePerformanceTab(featureFlags),
diff --git a/frontend/src/scenes/web-analytics/pageReportsLogic.ts b/frontend/src/scenes/web-analytics/pageReportsLogic.ts
index d3cde0f70e62..fbf5a7fd4f9b 100644
--- a/frontend/src/scenes/web-analytics/pageReportsLogic.ts
+++ b/frontend/src/scenes/web-analytics/pageReportsLogic.ts
@@ -217,6 +217,16 @@ export function createUrlPropertyFilter(url: string, stripQueryParams: boolean):
// kea-router JSON-parses query params (?pageURL=123 arrives as a number) and pageUrl is
// persisted, so a non-string value would otherwise crash `url.split` below on every recompute
const urlString: string = String(url ?? '')
+ if (urlString.startsWith('/')) {
+ return [
+ {
+ key: '$pathname',
+ value: urlString.split(/[?#]/)[0],
+ operator: PropertyOperator.Exact,
+ type: PropertyFilterType.Event,
+ },
+ ]
+ }
const parsed = parseWebAnalyticsURL(urlString)
if (parsed.isValid && parsed.host && parsed.pathname) {
@@ -1460,6 +1470,9 @@ export const pageReportsLogic = kea<pageReportsLogicType>({
listeners: ({ actions, values }) => ({
openPageReport: ({ source, position }) => {
posthog.capture('web analytics page report opened', { source, row_position: position })
+ if (values.isInitialLoad) {
+ actions.loadPages('')
+ }
},
backToDirectory: () => {
posthog.capture('web analytics page report back to directory', { method: 'breadcrumb' })
@@ -1474,8 +1487,16 @@ export const pageReportsLogic = kea<pageReportsLogicType>({
actions.loadPages(searchTerm)
},
loadPages: ({ searchTerm }) => {
+ if (values.isDirectoryEnabled && !values.pageUrl) {
+ return
+ }
actions.loadPagesUrls({ searchTerm })
},
+ setPageUrl: () => {
+ if (values.isDirectoryEnabled && values.pageUrl && values.isInitialLoad) {
+ actions.loadPages('')
+ }
+ },
setDates: () => {
if (values.featureFlags[FEATURE_FLAGS.PAGE_REPORTS_RANKED_URL_SEARCH]) {
actions.loadPages(values.pageUrlSearchTerm)
diff --git a/products/web_analytics/frontend/pageReports/PageDirectoryTable.tsx b/products/web_analytics/frontend/pageReports/PageDirectoryTable.tsx
new file mode 100644
index 000000000000..fb8c7b6f81b6
--- /dev/null
+++ b/products/web_analytics/frontend/pageReports/PageDirectoryTable.tsx
@@ -0,0 +1,238 @@
+import { useActions, useValues } from 'kea'
+import { router } from 'kea-router'
+import useResizeObserver from 'use-resize-observer'
+
+import { IconWarning } from '@posthog/icons'
+import { LemonSkeleton, LemonTable, LemonTableColumns, Link, Tooltip } from '@posthog/lemon-ui'
+
+import { humanFriendlyDuration } from 'lib/utils/durations'
+import { tryDecodeURIComponent } from 'lib/utils/url'
+import { pageReportsLogic } from 'scenes/web-analytics/pageReportsLogic'
+
+import { WebPageDirectoryMetric, WebPageDirectoryRow, WebPageDirectorySortBy } from '~/queries/schema/schema-general'
+
+import { CrawlerLogoStack } from './CrawlerLogoStack'
+import { PageDirectoryEmptyState } from './PageDirectoryEmptyState'
+import { PAGE_DIRECTORY_PAGE_SIZE, pageDirectoryLogic } from './pageDirectoryLogic'
+import { PageDirectoryMetricCell } from './PageDirectoryMetricCell'
+import { pageReportPath, pageReportUrlForPage, splitPageKey } from './pageReportsUtils'
+
+const NARROW_WIDTH = 560
+const COMPACT_WIDTH = 900
+const MEDIUM_WIDTH = 1200
+
+export function PageDirectoryTable(): JSX.Element {
+ const {
+ rows,
+ driverLoading,
+ hasMore,
+ pageIndex,
+ sortBy,
+ sortDirection,
+ visibleMetrics,
+ metricLoading,
+ hasServerLogs,
+ singleHost,
+ } = useValues(pageDirectoryLogic)
+ const { setSort, nextPage, previousPage } = useActions(pageDirectoryLogic)
+ const { searchParams } = useValues(router)
+ const { openPageReport } = useActions(pageReportsLogic)
+ const { ref, width = 0 } = useResizeObserver<HTMLDivElement>()
+
+ const sortColumnKey: string = sortBy
+ const isNarrow = width > 0 && width < NARROW_WIDTH
+ const isCompact = width > 0 && width < COMPACT_WIDTH
+ const isMedium = width > 0 && width < MEDIUM_WIDTH
+ const hiddenOnNarrow = (key: string): boolean =>
+ key !== sortColumnKey &&
+ ((isNarrow && key !== WebPageDirectoryMetric.Visitors) ||
+ (isCompact && key === WebPageDirectoryMetric.AiCrawls) ||
+ (isMedium && (key === WebPageDirectoryMetric.TimeOnPage || key === WebPageDirectoryMetric.Conversions)))
+ const isLoading = (metric: WebPageDirectoryMetric): boolean => driverLoading || !!metricLoading[metric]
+
+ const columns: LemonTableColumns<WebPageDirectoryRow> = [
+ {
+ key: 'page',
+ title: 'Page',
+ sorter: true,
+ render: (_, row, index) => {
+ const { host, path } = splitPageKey(tryDecodeURIComponent(row.page))
+ return (
+ <Tooltip title={pageReportUrlForPage(row.page)}>
+ <Link
+ to={pageReportPath(row.page, searchParams)}
+ subtle
+ className="flex flex-col min-w-0 max-w-80 py-0.5"
+ onClick={(event) => {
+ event.stopPropagation()
+ if (!event.metaKey && !event.ctrlKey && !event.shiftKey && event.button === 0) {
+ event.preventDefault()
+ openPageReport(pageReportUrlForPage(row.page), 'directory_row', index)
+ }
+ }}
+ data-attr="page-reports-directory-row"
+ >
+ <span className="truncate font-semibold text-primary">{path}</span>
+ {host && !singleHost ? (
+ <span className="truncate text-xs text-secondary">{host}</span>
+ ) : null}
+ </Link>
+ </Tooltip>
+ )
+ },
+ },
+ {
+ key: WebPageDirectoryMetric.Visitors,
+ title: 'Visitors',
+ align: 'right',
+ sorter: true,
+ isHidden: hiddenOnNarrow(WebPageDirectoryMetric.Visitors),
+ render: (_, row) => (
+ <PageDirectoryMetricCell
+ value={row.visitors}
+ tooltip="People who viewed this page"
+ loading={isLoading(WebPageDirectoryMetric.Visitors)}
+ />
+ ),
+ },
+ {
+ key: WebPageDirectoryMetric.GoogleSearch,
+ title: 'Google search',
+ tooltip: 'Visitors whose session started from a Google search result',
+ align: 'right',
+ sorter: true,
+ isHidden: hiddenOnNarrow(WebPageDirectoryMetric.GoogleSearch),
+ render: (_, row) => (
+ <PageDirectoryMetricCell
+ value={row.googleSearch}
+ tooltip="Visitors to this page who came from Google search"
+ loading={isLoading(WebPageDirectoryMetric.GoogleSearch)}
+ />
+ ),
+ },
+ {
+ key: WebPageDirectoryMetric.AiReferrals,
+ title: 'AI referrals',
+ tooltip: 'Visitors whose session started from an AI assistant such as ChatGPT, Claude or Perplexity',
+ align: 'right',
+ sorter: true,
+ isHidden: hiddenOnNarrow(WebPageDirectoryMetric.AiReferrals),
+ render: (_, row) => (
+ <PageDirectoryMetricCell
+ value={row.aiReferrals}
+ tooltip="Visitors to this page who came from an AI assistant"
+ loading={isLoading(WebPageDirectoryMetric.AiReferrals)}
+ />
+ ),
+ },
+ {
+ key: WebPageDirectoryMetric.AiCrawls,
+ title: 'AI crawls',
+ tooltip: 'Requests from AI crawlers. Crawlers are not counted as visitors.',
+ align: 'right',
+ sorter: true,
+ isHidden: hiddenOnNarrow(WebPageDirectoryMetric.AiCrawls),
+ render: (_, row) =>
+ hasServerLogs === false ? (
+ <Tooltip title="Forward your server logs to measure AI crawlers. Crawlers do not run the browser SDK.">
+ <span className="text-secondary">Not measured</span>
+ </Tooltip>
+ ) : (
+ <PageDirectoryMetricCell
+ value={row.aiCrawls}
+ detail={
+ row.aiCrawls?.current ? (
+ <CrawlerLogoStack names={row.aiCrawlerNames ?? []} count={row.aiCrawlers ?? 0} />
+ ) : null
+ }
+ tooltip="Requests from AI crawlers in this period"
+ loading={isLoading(WebPageDirectoryMetric.AiCrawls)}
+ />
+ ),
+ },
+ {
+ key: WebPageDirectoryMetric.Conversions,
+ title: 'Conversions',
+ align: 'right',
+ sorter: true,
+ isHidden:
+ !visibleMetrics.includes(WebPageDirectoryMetric.Conversions) ||
+ hiddenOnNarrow(WebPageDirectoryMetric.Conversions),
+ render: (_, row) => (
+ <PageDirectoryMetricCell
+ value={row.conversions}
+ tooltip="Conversion goal events that happened on this page"
+ loading={isLoading(WebPageDirectoryMetric.Conversions)}
+ />
+ ),
+ },
+ {
+ key: WebPageDirectoryMetric.TimeOnPage,
+ title: 'Time on page',
+ tooltip:
+ 'The time 90% of visitors spent on this page or less. A following pageview is needed, so the last page of a visit is not counted.',
+ align: 'right',
+ sorter: true,
+ isHidden: hiddenOnNarrow(WebPageDirectoryMetric.TimeOnPage),
+ render: (_, row) =>
+ row.timeOnPageP90 != null ? (
+ row.timeOnPageP90 < 1 ? (
+ <Tooltip title="Most visits end in under a second, which usually means this page redirects.">
+ <span className="inline-flex items-center gap-1 text-warning tabular-nums" translate="no">
+ <IconWarning />
+ Under 1s
+ </span>
+ </Tooltip>
+ ) : (
+ <span className="tabular-nums" translate="no">
+ {humanFriendlyDuration(row.timeOnPageP90)}
+ </span>
+ )
+ ) : isLoading(WebPageDirectoryMetric.TimeOnPage) ? (
+ <LemonSkeleton className="h-4 w-12 ml-auto" />
+ ) : (
+ <span className="text-secondary">-</span>
+ ),
+ },
+ ]
+
+ return (
+ <div ref={ref} className="min-w-0">
+ <LemonTable<WebPageDirectoryRow>
+ dataSource={rows}
+ columns={columns}
+ rowKey="page"
+ loading={driverLoading}
+ loadingSkeletonRows={10}
+ useURLForSorting={false}
+ noSortingCancellation
+ sorting={{ columnKey: sortColumnKey, order: sortDirection === 'ASC' ? 1 : -1 }}
+ onSort={(sorting) => {
+ if (!sorting) {
+ return
+ }
+ const column = sorting.columnKey as WebPageDirectorySortBy
+ if (column !== sortBy) {
+ setSort(column, column === WebPageDirectorySortBy.Page ? 'ASC' : 'DESC')
+ return
+ }
+ setSort(column, sortDirection === 'DESC' ? 'ASC' : 'DESC')
+ }}
+ onRow={(row, index) => ({
+ className: 'cursor-pointer',
+ onClick: () => openPageReport(pageReportUrlForPage(row.page), 'directory_row', index),
+ })}
+ pagination={{
+ controlled: true,
+ pageSize: PAGE_DIRECTORY_PAGE_SIZE,
+ currentPage: pageIndex + 1,
+ onForward: hasMore ? nextPage : undefined,
+ onBackward: pageIndex > 0 ? previousPage : undefined,
+ }}
+ nouns={['row', 'rows']}
+ emptyState={<PageDirectoryEmptyState />}
+ data-attr="page-reports-directory-table"
+ />
+ </div>
+ )
+}
diff --git a/products/web_analytics/frontend/pageReports/PageReportsDirectory.tsx b/products/web_analytics/frontend/pageReports/PageReportsDirectory.tsx
new file mode 100644
index 000000000000..dd4aba68ba96
--- /dev/null
+++ b/products/web_analytics/frontend/pageReports/PageReportsDirectory.tsx
@@ -0,0 +1,93 @@
+import { BindLogic, useActions, useValues } from 'kea'
+
+import { IconArrowRight } from '@posthog/icons'
+import { LemonBanner, LemonButton, LemonInput } from '@posthog/lemon-ui'
+
+import { pageReportsLogic } from 'scenes/web-analytics/pageReportsLogic'
+
+import { pageDirectoryLogic } from './pageDirectoryLogic'
+import { PageDirectorySummary } from './PageDirectorySummary'
+import { PageDirectoryTable } from './PageDirectoryTable'
+
+function PageDirectoryContent(): JSX.Element {
+ const { search, pastedUrl, directoryState, driverError, failedMetrics, isPathCleaningEnabled } =
+ useValues(pageDirectoryLogic)
+ const { setSearch, loadDriver, retryFailedMetrics } = useActions(pageDirectoryLogic)
+ const { openPageReport } = useActions(pageReportsLogic)
+
+ return (
+ <div className="flex flex-col gap-3 mt-2 pb-24" data-attr="page-reports-directory">
+ <div className="flex flex-col gap-1 min-w-0">
+ <h2 className="m-0">Pages</h2>
+ <p className="m-0 text-secondary">
+ How each page earns its traffic, from search engines through to AI assistants. Open a page to see
+ its full report.
+ </p>
+ </div>
+ <PageDirectorySummary />
+ <div className="flex flex-wrap items-center gap-2">
+ <LemonInput
+ type="search"
+ className="flex-1 min-w-60 max-w-160"
+ fullWidth
+ placeholder="Search pages, or paste a URL"
+ value={search}
+ onChange={setSearch}
+ onPressEnter={() => {
+ if (pastedUrl) {
+ openPageReport(pastedUrl, 'pasted_url')
+ }
+ }}
+ data-attr="page-reports-directory-search"
+ autoFocus
+ />
+ {pastedUrl ? (
+ <LemonButton
+ type="primary"
+ sideIcon={<IconArrowRight />}
+ onClick={() => openPageReport(pastedUrl, 'pasted_url')}
+ className="max-w-full"
+ truncate
+ data-attr="page-reports-directory-open-url"
+ >
+ Open report for this URL
+ </LemonButton>
+ ) : null}
+ </div>
+ {directoryState === 'error' ? (
+ <LemonBanner type="error" action={{ children: 'Try again', onClick: () => loadDriver(true) }}>
+ Couldn't load your pages. {driverError ? `${driverError}. ` : ''}Try again, or pick a shorter date
+ range.
+ </LemonBanner>
+ ) : (
+ <>
+ {failedMetrics.length > 0 ? (
+ <LemonBanner
+ type="warning"
+ action={{
+ children: 'Try again',
+ onClick: retryFailedMetrics,
+ 'data-attr': 'page-reports-directory-retry-metrics',
+ }}
+ >
+ Some columns couldn't load.
+ </LemonBanner>
+ ) : null}
+ <PageDirectoryTable />
+ </>
+ )}
+ <p className="m-0 text-xs text-secondary">
+ Images, scripts and other static files are hidden. Path cleaning is{' '}
+ <span>{isPathCleaningEnabled ? 'on, so similar paths are grouped' : 'off'}</span>.
+ </p>
+ </div>
+ )
+}
+
+export function PageReportsDirectory(): JSX.Element {
+ return (
+ <BindLogic logic={pageDirectoryLogic} props={{}}>
+ <PageDirectoryContent />
+ </BindLogic>
+ )
+}
diff --git a/products/web_analytics/frontend/pageReports/PageReportsTabLabel.tsx b/products/web_analytics/frontend/pageReports/PageReportsTabLabel.tsx
new file mode 100644
index 000000000000..f6fb7669afa9
--- /dev/null
+++ b/products/web_analytics/frontend/pageReports/PageReportsTabLabel.tsx
@@ -0,0 +1,44 @@
+import { useActions, useValues } from 'kea'
+
+import * as megaphonePng from '@posthog/brand/hoggies/png/megaphone'
+import { Tooltip } from '@posthog/lemon-ui'
+
+import { pngHoggie } from 'lib/brand/hoggies'
+
+import { pageReportsTeaserLogic } from './pageReportsTeaserLogic'
+
+const MegaphoneHog = pngHoggie(megaphonePng)
+
+export function PageReportsTabLabel(): JSX.Element {
+ const { showTeaser } = useValues(pageReportsTeaserLogic)
+ const { hoverTeaser } = useActions(pageReportsTeaserLogic)
+
+ if (!showTeaser) {
+ return <>Page reports</>
+ }
+
+ return (
+ <Tooltip
+ title={
+ <div className="flex flex-col gap-1 max-w-60">
+ <span className="font-semibold">New and improved!</span>
+ <span>
+ Page reports now lists every page with its Google and AI traffic. Open any page for its full
+ report.
+ </span>
+ </div>
+ }
+ placement="bottom"
+ >
+ <span className="group inline-flex items-center" onMouseEnter={hoverTeaser} data-attr="page-reports-teaser">
+ <span className="relative z-10">Page reports</span>
+ <span className="relative -my-3 -ml-2 h-7 w-8 translate-y-0.5 overflow-hidden" aria-hidden>
+ <MegaphoneHog
+ className="absolute left-0 top-2.5 w-8 rotate-6 transition-transform duration-300 ease-out group-hover:-translate-y-2 group-hover:rotate-0 motion-reduce:transition-none"
+ loading="eager"
+ />
+ </span>
+ </span>
+ </Tooltip>
+ )
+}
diff --git a/products/web_analytics/frontend/pageReports/pageReportsTeaserLogic.ts b/products/web_analytics/frontend/pageReports/pageReportsTeaserLogic.ts
new file mode 100644
index 000000000000..5f9c8050ca74
--- /dev/null
+++ b/products/web_analytics/frontend/pageReports/pageReportsTeaserLogic.ts
@@ -0,0 +1,68 @@
+import { MakeLogicType, actions, kea, listeners, path, reducers, selectors } from 'kea'
+import posthog from 'posthog-js'
+
+const PAGE_REPORTS_TEASER_VISIT_LIMIT = 3
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface pageReportsTeaserLogicValues {
+ pageReportsVisits: number
+ showTeaser: boolean
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface pageReportsTeaserLogicActions {
+ hoverTeaser: () => {
+ value: true
+ }
+ recordPageReportsVisit: () => {
+ value: true
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface pageReportsTeaserLogicMeta {
+ __keaTypeGenInternalSelectorTypes: {
+ showTeaser: (pageReportsVisits: number) => boolean
+ }
+}
+
+export type pageReportsTeaserLogicType = MakeLogicType<
+ pageReportsTeaserLogicValues,
+ pageReportsTeaserLogicActions,
+ Record<string, any>,
+ pageReportsTeaserLogicMeta
+>
+
+export const pageReportsTeaserLogic = kea<pageReportsTeaserLogicType>([
+ path(['products', 'webAnalytics', 'pageReports', 'pageReportsTeaserLogic']),
+ actions({
+ hoverTeaser: true,
+ recordPageReportsVisit: true,
+ }),
+ reducers({
+ pageReportsVisits: [
+ 0,
+ { persist: true },
+ {
+ recordPageReportsVisit: (state) => state + 1,
+ },
+ ],
+ }),
+ selectors({
+ showTeaser: [
+ (s) => [s.pageReportsVisits],
+ (pageReportsVisits: number): boolean => pageReportsVisits < PAGE_REPORTS_TEASER_VISIT_LIMIT,
+ ],
+ }),
+ listeners(({ values, cache }) => ({
+ hoverTeaser: () => {
+ if (cache.hoverTracked) {
+ return
+ }
+ cache.hoverTracked = true
+ posthog.capture('web analytics page reports teaser hovered', {
+ page_reports_visits: values.pageReportsVisits,
+ })
+ },
+ })),
+])
diff --git a/products/web_analytics/frontend/pageReports/pageReportsUtils.ts b/products/web_analytics/frontend/pageReports/pageReportsUtils.ts
index f5fdd69fe22c..5929bd15bcd7 100644
--- a/products/web_analytics/frontend/pageReports/pageReportsUtils.ts
+++ b/products/web_analytics/frontend/pageReports/pageReportsUtils.ts
@@ -52,8 +52,8 @@ export const valueChange = (value: WebPageDirectoryValue | null | undefined): nu
export const pageReportUrlForPage = (page: string): string =>
page.startsWith('/') || /^[a-z]+:\/\//i.test(page) ? page : `https://${page}`
-export const pageReportPath = (page: string): string =>
- combineUrl(urls.webAnalyticsPageReports(), { pageURL: pageReportUrlForPage(page) }).url
+export const pageReportPath = (page: string, searchParams: Record<string, any> = {}): string =>
+ combineUrl(urls.webAnalyticsPageReports(), { ...searchParams, pageURL: pageReportUrlForPage(page) }).url
export const looksLikePageUrl = (search: string): boolean => {
const trimmed = search.trim()