performance page polish

This commit is contained in:
Francis Cao committed 2026-03-05 12:21:34 -08:00
1 parent 31caa0d62e
commit 383922ab17
9 files changed
+113 -54

No files matched your search

+1
View File
@@ -95,6 +95,7 @@ export function FieldFilters({
>
{groupLabels.map(({ key: groupKey, label }) => {
const groupFields = groupedFields[groupKey];
if (!groupFields || groupFields.length === 0) return null;
return (
<MenuSection key={groupKey} title={label}>
{groupFields.map(field => {
+23 -9
View File
@@ -27,8 +27,28 @@ export function FilterEditForm({ websiteId, onChange, onClose }: FilterEditFormP
const [currentCohort, setCurrentCohort] = useState(cohort);
const [currentMatch, setCurrentMatch] = useState<string>(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
<Tabs>
<TabList>
<Tab id="fields">{t(labels.fields)}</Tab>
{!excludeFilters && (
{!isPixelLink && (
<>
<Tab id="segments">{t(labels.segments)}</Tab>
<Tab id="cohorts">{t(labels.cohorts)}</Tab>
@@ -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}
/>
</TabPanel>
<TabPanel id="segments">
+1
View File
@@ -339,6 +339,7 @@ export const labels: Record<string, string> = {
saveCohort: 'label.save-cohort',
analysis: 'label.analysis',
destinationUrl: 'label.destination-url',
slug: 'label.slug',
audience: 'label.audience',
invalidUrl: 'label.invalid-url',
environment: 'label.environment',
+7 -1
View File
@@ -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 = ({
<AnimatedDiv title={props?.y as any}>
{currency
? props.y?.to(n => formatLongCurrency(n, currency))
: props.y?.to(formatLongNumber)}
: formatCount
? props.y?.to(formatCount)
: props.y?.to(formatLongNumber)}
</AnimatedDiv>
</Text>
</Row>
@@ -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 {
+12 -1
View File
@@ -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 (
<Column
@@ -49,7 +60,7 @@ export const PerformanceCard = ({
{label}
</Text>
<Text size="4xl" weight="bold" wrap="nowrap">
{formatValue(value)}
<AnimatedDiv>{spring.value.to(n => formatValue(n))}</AnimatedDiv>
</Text>
<Text size="sm" className={styles.rating}>
{t(labels[rating === 'needs-improvement' ? 'needsImprovement' : rating])}