diff --git a/public/intl/messages/en-US.json b/public/intl/messages/en-US.json index 25a94f3b4..969f9537c 100644 --- a/public/intl/messages/en-US.json +++ b/public/intl/messages/en-US.json @@ -288,6 +288,7 @@ "share": "Share", "share-url": "Share URL", "single-day": "Single day", + "slug": "Slug", "sms": "SMS", "source": "Source", "sources": "Sources", diff --git a/src/app/(main)/links/LinkEditForm.tsx b/src/app/(main)/links/LinkEditForm.tsx index 64bfb8dbc..50f3bdb60 100644 --- a/src/app/(main)/links/LinkEditForm.tsx +++ b/src/app/(main)/links/LinkEditForm.tsx @@ -94,7 +94,7 @@ export function LinkEditForm({ = { }; function formatMetricValue(metric: string, value: number): string { - if (metric === 'cls') { - return value.toFixed(3); - } + if (metric === 'cls') return value.toFixed(3); + if (value >= 1000) return `${(value / 1000).toFixed(2)} s`; return `${Math.round(value)} ms`; } @@ -138,6 +137,11 @@ export function Performance({ websiteId, startDate, endDate, unit }: Performance const renderXLabel = useCallback(renderDateLabels(unit, locale), [unit, locale]); const threshold = WEB_VITALS_THRESHOLDS[selectedMetric as keyof typeof WEB_VITALS_THRESHOLDS]; + const isCls = selectedMetric === 'cls'; + const metricLabel = t(labels[selectedMetric]) || selectedMetric.toUpperCase(); + const formatListCount = isCls + ? (n: number) => n.toFixed(3) + : (n: number) => `${(n / 1000).toFixed(2)} s`; return ( @@ -189,6 +193,7 @@ export function Performance({ websiteId, startDate, endDate, unit }: Performance renderYLabel={(label: string) => { const val = Number(label); if (selectedMetric === 'cls') return val.toFixed(2); + if (val >= 1000) return `${(val / 1000).toFixed(2)} s`; return `${Math.round(val)} ms`; }} height="400px" @@ -205,26 +210,40 @@ export function Performance({ websiteId, startDate, endDate, unit }: Performance ({ - label: name, - count: Number({ p50, p75, p95 }[selectedPercentile]), - percent: 0, - }))} + formatCount={formatListCount} + data={data.pages + ?.filter( + ({ p50, p75, p95 }: any) => + Number({ p50, p75, p95 }[selectedPercentile]) > 0, + ) + .slice(0, 20) + .map(({ name, p50, p75, p95 }: any) => ({ + label: name, + count: Number({ p50, p75, p95 }[selectedPercentile]), + percent: 0, + }))} renderLabel={({ label }: { label: string }) => {label}} /> ({ - label: name, - count: Number({ p50, p75, p95 }[selectedPercentile]), - percent: 0, - }))} - renderLabel={({ label }: { label: string }) => {label}} + formatCount={formatListCount} + data={data.pageTitles + ?.filter( + ({ p50, p75, p95 }: any) => + Number({ p50, p75, p95 }[selectedPercentile]) > 0, + ) + .slice(0, 20) + .map(({ name, p50, p75, p95 }: any) => ({ + label: name, + count: Number({ p50, p75, p95 }[selectedPercentile]), + percent: 0, + }))} + renderLabel={(row: any) => } /> @@ -238,36 +257,40 @@ export function Performance({ websiteId, startDate, endDate, unit }: Performance ({ - label: name, - count: Number({ p50, p75, p95 }[selectedPercentile]), - percent: 0, - }))} - renderLabel={({ label }: { label: string }) => ( - - - {label} - - )} + formatCount={formatListCount} + data={data.devices + ?.filter( + ({ p50, p75, p95 }: any) => + Number({ p50, p75, p95 }[selectedPercentile]) > 0, + ) + .slice(0, 20) + .map(({ name, p50, p75, p95 }: any) => ({ + label: name, + count: Number({ p50, p75, p95 }[selectedPercentile]), + percent: 0, + }))} + renderLabel={(row: any) => } /> ({ - label: name, - count: Number({ p50, p75, p95 }[selectedPercentile]), - percent: 0, - }))} - renderLabel={({ label }: { label: string }) => ( - - - {label} - - )} + formatCount={formatListCount} + data={data.browsers + ?.filter( + ({ p50, p75, p95 }: any) => + Number({ p50, p75, p95 }[selectedPercentile]) > 0, + ) + .slice(0, 20) + .map(({ name, p50, p75, p95 }: any) => ({ + label: name, + count: Number({ p50, p75, p95 }[selectedPercentile]), + percent: 0, + }))} + renderLabel={(row: any) => } /> diff --git a/src/components/input/FieldFilters.tsx b/src/components/input/FieldFilters.tsx index 4856cd1d1..7107aeb2f 100644 --- a/src/components/input/FieldFilters.tsx +++ b/src/components/input/FieldFilters.tsx @@ -95,6 +95,7 @@ export function FieldFilters({ > {groupLabels.map(({ key: groupKey, label }) => { const groupFields = groupedFields[groupKey]; + if (!groupFields || groupFields.length === 0) return null; return ( {groupFields.map(field => { diff --git a/src/components/input/FilterEditForm.tsx b/src/components/input/FilterEditForm.tsx index 6b3353f53..5e7e6020f 100644 --- a/src/components/input/FilterEditForm.tsx +++ b/src/components/input/FilterEditForm.tsx @@ -27,8 +27,28 @@ export function FilterEditForm({ websiteId, onChange, onClose }: FilterEditFormP const [currentCohort, setCurrentCohort] = useState(cohort); const [currentMatch, setCurrentMatch] = useState(match || 'all'); const { isMobile } = useMobile(); - const excludeFilters = !websiteId || pathname.includes('/pixels') || pathname.includes('/links'); + const isPixelLink = !websiteId || pathname.includes('/pixels') || pathname.includes('/links'); const excludeEvent = !pathname.endsWith('/events') && !pathname.endsWith('/replays'); + const isPerformance = pathname.includes('/performance'); + + const excludedFields = isPixelLink + ? ['path', 'title', 'hostname', 'distinctId', 'tag', 'event'] + : isPerformance + ? [ + 'referrer', + 'query', + 'event', + 'tag', + 'distinctId', + 'utmSource', + 'utmMedium', + 'utmCampaign', + 'utmContent', + 'utmTerm', + ] + : excludeEvent + ? ['event'] + : []; const handleReset = () => { setCurrentFilters([]); @@ -58,7 +78,7 @@ export function FilterEditForm({ websiteId, onChange, onClose }: FilterEditFormP {t(labels.fields)} - {!excludeFilters && ( + {!isPixelLink && ( <> {t(labels.segments)} {t(labels.cohorts)} @@ -72,13 +92,7 @@ export function FilterEditForm({ websiteId, onChange, onClose }: FilterEditFormP match={currentMatch} onChange={setCurrentFilters} onMatchChange={setCurrentMatch} - exclude={ - excludeFilters - ? ['path', 'title', 'hostname', 'distinctId', 'tag', 'event'] - : excludeEvent - ? ['event'] - : [] - } + exclude={excludedFields} /> diff --git a/src/components/messages.ts b/src/components/messages.ts index 6bd5b3fc1..11899a5c3 100644 --- a/src/components/messages.ts +++ b/src/components/messages.ts @@ -339,6 +339,7 @@ export const labels: Record = { saveCohort: 'label.save-cohort', analysis: 'label.analysis', destinationUrl: 'label.destination-url', + slug: 'label.slug', audience: 'label.audience', invalidUrl: 'label.invalid-url', environment: 'label.environment', diff --git a/src/components/metrics/ListTable.tsx b/src/components/metrics/ListTable.tsx index 9c2fb2360..75080de95 100644 --- a/src/components/metrics/ListTable.tsx +++ b/src/components/metrics/ListTable.tsx @@ -27,6 +27,7 @@ export interface ListTableProps { showPercentage?: boolean; itemCount?: number; currency?: string; + formatCount?: (n: number) => string; } export function ListTable({ @@ -40,6 +41,7 @@ export function ListTable({ showPercentage = true, itemCount = 10, currency, + formatCount, }: ListTableProps) { const { t, labels } = useMessages(); const { isPhone } = useMobile(); @@ -57,6 +59,7 @@ export function ListTable({ showPercentage={showPercentage} change={renderChange ? renderChange(row, index) : null} currency={currency} + formatCount={formatCount} isPhone={isPhone} /> ); @@ -106,6 +109,7 @@ const AnimatedRow = ({ animate, showPercentage = true, currency, + formatCount, isPhone, }) => { const props = useSpring({ @@ -135,7 +139,9 @@ const AnimatedRow = ({ {currency ? props.y?.to(n => formatLongCurrency(n, currency)) - : props.y?.to(formatLongNumber)} + : formatCount + ? props.y?.to(formatCount) + : props.y?.to(formatLongNumber)} diff --git a/src/components/metrics/PerformanceCard.module.css b/src/components/metrics/PerformanceCard.module.css index c0de4ae2d..ae650d4ee 100644 --- a/src/components/metrics/PerformanceCard.module.css +++ b/src/components/metrics/PerformanceCard.module.css @@ -3,7 +3,9 @@ } .card:hover { - box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 15%, transparent); + box-shadow: + 0 0 0 1px color-mix(in srgb, var(--primary) 40%, transparent), + 0 0 6px color-mix(in srgb, var(--primary) 15%, transparent); } .card.selected { diff --git a/src/components/metrics/PerformanceCard.tsx b/src/components/metrics/PerformanceCard.tsx index 96f909459..be745d47b 100644 --- a/src/components/metrics/PerformanceCard.tsx +++ b/src/components/metrics/PerformanceCard.tsx @@ -1,4 +1,7 @@ +import { config, useSpring } from '@react-spring/web'; import { Column, Text } from '@umami/react-zen'; +import { useRef } from 'react'; +import { AnimatedDiv } from '@/components/common/AnimatedDiv'; import { useMessages } from '@/components/hooks'; import { WEB_VITALS_THRESHOLDS } from '@/lib/constants'; import { formatNumber } from '@/lib/format'; @@ -31,6 +34,14 @@ export const PerformanceCard = ({ }: PerformanceCardProps) => { const { t, labels } = useMessages(); const rating = getRating(metric, value); + const prevMetricRef = useRef(metric); + const metricChanged = prevMetricRef.current !== metric; + if (metricChanged) prevMetricRef.current = metric; + + const spring = useSpring({ + value: !Number.isNaN(value) ? value : 0, + config: metricChanged ? { duration: 0 } : config.default, + }); return ( - {formatValue(value)} + {spring.value.to(n => formatValue(n))} {t(labels[rating === 'needs-improvement' ? 'needsImprovement' : rating])}