Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.
TypeScript analyticsaudience-segmentationchartscohort-analysisgoogle-analyticsproduct-analyticsstatisticsuser-journeyweb-analytics
feat(funnels): display per-step filters in funnel overview
Rudy B.4c306ac28755
diff --git a/src/app/(main)/websites/[websiteId]/(reports)/funnels/Funnel.tsx b/src/app/(main)/websites/[websiteId]/(reports)/funnels/Funnel.tsxindex e336a3db6..a16a802c3 100644--- a/src/app/(main)/websites/[websiteId]/(reports)/funnels/Funnel.tsx+++ b/src/app/(main)/websites/[websiteId]/(reports)/funnels/Funnel.tsx@@ -1,16 +1,15 @@import { Box, Column, Dialog, Grid, Icon, ProgressBar, Row, Text } from '@umami/react-zen';import { LoadingPanel } from '@/components/common/LoadingPanel';-import { useMessages, useResultQuery } from '@/components/hooks';+import { useMessages, useOperatorLabels, useResultQuery } from '@/components/hooks';import { File, User } from '@/components/icons';import { ReportEditButton } from '@/components/input/ReportEditButton';import { ChangeLabel } from '@/components/metrics/ChangeLabel';import { Lightning } from '@/components/svg';import { formatLongNumber } from '@/lib/format';+import type { FunnelStep } from '@/queries/sql/reports/getFunnel';import { FunnelEditForm } from './FunnelEditForm';-type FunnelResult = {- type: string;- value: string;+type FunnelResult = FunnelStep & {visitors: number;previous: number;dropped: number;@@ -18,13 +17,23 @@ type FunnelResult = {remaining: number;};-export function Funnel({ id, name, type, parameters, websiteId }) {+interface FunnelProps {+ id: string;+ name: string;+ type: string;+ parameters: Record<string, any>;+ websiteId: string;+}++export function Funnel({ id, name, type, parameters, websiteId }: FunnelProps) {const { formatMessage, labels } = useMessages();- const { data, error, isLoading } = useResultQuery(type, {+ const { data, error, isLoading } = useResultQuery<Array<FunnelResult>>(type, {websiteId,...parameters,});+ const operatorLabels = useOperatorLabels();+return (<LoadingPanel data={data} isLoading={isLoading} error={error}><Grid gap>@@ -54,7 +63,7 @@ export function Funnel({ id, name, type, parameters, websiteId }) {</Grid>{data?.map((- { type, value, visitors, previous, dropped, dropoff, remaining }: FunnelResult,+ { type, value, filters, visitors, previous, dropped, dropoff, remaining }: FunnelResult,index: number,) => {const isPage = type === 'path';@@ -92,10 +101,25 @@ export function Funnel({ id, name, type, parameters, websiteId }) {<Text color="muted">{formatMessage(labels.conversionRate)}</Text></Row><Row alignItems="center" justifyContent="space-between" gap>- <Row alignItems="center" gap>- <Icon>{type === 'path' ? <File /> : <Lightning />}</Icon>- <Text>{value}</Text>- </Row>+ <Column gap="1">+ <Row alignItems="center" gap>+ <Icon>{type === 'path' ? <File /> : <Lightning />}</Icon>+ <Text>{value}</Text>+ </Row>+ {filters?.map((f, i) => (+ <Row key={i} gap="1" style={{ paddingLeft: 28 }}>+ <Text size="1" color="muted">+ {f.property}+ </Text>+ <Text size="1" color="muted" transform="lowercase">+ {operatorLabels[f.operator] ?? f.operator}+ </Text>+ <Text size="1" color="muted">+ {f.value}+ </Text>+ </Row>+ ))}+ </Column><Row alignItems="center" gap>{index > 0 && (<ChangeLabel value={-dropped} title={`${-Math.round(dropoff * 100)}%`}>