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
Updated grid layouts. Fixed chart tooltip.
Mike Cao1d24e23a3438
diff --git a/package.json b/package.jsonindex d7cdf1cdd..2808907cd 100644--- a/package.json+++ b/package.json@@ -78,7 +78,7 @@"@react-spring/web": "^9.7.5","@tanstack/react-query": "^5.68.0","@umami/prisma-client": "^0.16.0",- "@umami/react-zen": "^0.77.0",+ "@umami/react-zen": "^0.79.0","@umami/redis-client": "^0.27.0","bcryptjs": "^2.4.3","chalk": "^4.1.2",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 3bc058b10..969e2c038 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -45,8 +45,8 @@ importers:specifier: ^0.16.0version: 0.16.0(@prisma/[email protected]([email protected]([email protected]))([email protected]))(@prisma/[email protected](@prisma/[email protected]([email protected]([email protected]))([email protected])))'@umami/react-zen':- specifier: ^0.77.0- version: 0.77.0(@babel/[email protected])(@types/[email protected])([email protected])([email protected]([email protected]))+ specifier: ^0.79.0+ version: 0.79.0(@babel/[email protected])(@types/[email protected])([email protected])([email protected]([email protected]))'@umami/redis-client':specifier: ^0.27.0version: 0.27.0@@ -2961,8 +2961,8 @@ packages:'@prisma/client': ^4.8.0'@prisma/extension-read-replicas': ^0.3.0- '@umami/[email protected]':- resolution: {integrity: sha512-tdoPdCMfPOhBMEiGXZ62zfTG8qjto7Ii+mWXNX2qdPjZ+SP5AB8wnQpqIGiXoUZUnP41iWw0GS97sTZq3xeEBQ==}+ '@umami/[email protected]':+ resolution: {integrity: sha512-qumZSV/dWvtq7iR7QwxEO5emE/jzgI5uPP5Y1E9S+MMGnJRhD5gQ1TvURf+jYAlTuiPubLysu6U3nKYmPNJxUg==}'@umami/[email protected]':resolution: {integrity: sha512-SbHTpxhgeZyTBUSp2zdZM+XUtpsaSL4Tad8QXIEhEtjWhvvfoornyT5kLuyYCVtzSAT4daALeGmOO1z6EE1KcA==}@@ -3329,8 +3329,8 @@ packages:resolution: {integrity: sha512-LoPe/D7zioC0REI5W73PeR1e1MLCipRGq/VkovJnd6Df+QVqT+vT33OXCp8QUd7kA7RZrHWxb1B36OQKI/0gOA==}- resolution: {integrity: sha512-NgL3vUTnDrPCZ3zTahp4fsugQ4dc7EKTSzwQDPEel6DMoMnfH2jhry9n2Zm8onbSR+f/QtKHFOA+iAQu4kbtWA==}+ resolution: {integrity: sha512-MBqPpGYYdQ7/hfKiet9SCI+nmN5/hp4ZzveOJubl5DTAMa5oggjAuoi0Z4onBpKPFI2ePGnQuQIzF3VxDjDJig==}resolution: {integrity: sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==}@@ -10646,7 +10646,7 @@ snapshots:transitivePeerDependencies:- supports-color- '@umami/[email protected](@babel/[email protected])(@types/[email protected])([email protected])([email protected]([email protected]))':+ '@umami/[email protected](@babel/[email protected])(@types/[email protected])([email protected])([email protected]([email protected]))':dependencies:'@fontsource/jetbrains-mono': 5.2.5@@ -11120,13 +11120,13 @@ snapshots:dependencies:browserslist: 4.24.4- caniuse-lite: 1.0.30001709+ caniuse-lite: 1.0.30001712lodash.memoize: 4.1.2lodash.uniq: 4.5.0- [email protected]: {}+ [email protected]: {}@@ -13667,7 +13667,7 @@ snapshots:'@swc/counter': 0.1.3'@swc/helpers': 0.5.15busboy: 1.6.0- caniuse-lite: 1.0.30001709+ caniuse-lite: 1.0.30001712postcss: 8.4.31react: 19.0.0react-dom: 19.0.0([email protected])@@ -13692,7 +13692,7 @@ snapshots:'@swc/counter': 0.1.3'@swc/helpers': 0.5.15busboy: 1.6.0- caniuse-lite: 1.0.30001709+ caniuse-lite: 1.0.30001712postcss: 8.4.31react: 19.1.0react-dom: 19.1.0([email protected])diff --git a/src/app/(main)/websites/[websiteId]/WebsiteHeader.tsx b/src/app/(main)/websites/[websiteId]/WebsiteHeader.tsxindex 9f33d0a3d..eafa6d32b 100644--- a/src/app/(main)/websites/[websiteId]/WebsiteHeader.tsx+++ b/src/app/(main)/websites/[websiteId]/WebsiteHeader.tsx@@ -10,15 +10,17 @@ import { WebsiteMenu } from '@/app/(main)/websites/[websiteId]/WebsiteMenu';import { WebsiteCompareBar } from '@/app/(main)/websites/[websiteId]/WebsiteCompareBar';export function WebsiteHeader({+ websiteId,showFilter = true,allowEdit = true,}: {+ websiteId: string;showFilter?: boolean;allowEdit?: boolean;compareMode?: boolean;}) {const website = useWebsite();- const { id: websiteId, name, domain } = website || {};+ const { name, domain } = website || {};return (<Column marginY="6" gap="6">diff --git a/src/app/(main)/websites/[websiteId]/WebsiteTableView.tsx b/src/app/(main)/websites/[websiteId]/WebsiteTableView.tsxindex acd268c8e..7395213d4 100644--- a/src/app/(main)/websites/[websiteId]/WebsiteTableView.tsx+++ b/src/app/(main)/websites/[websiteId]/WebsiteTableView.tsx@@ -1,4 +1,5 @@import { Grid } from '@umami/react-zen';+import { GridRow } from '@/components/common/GridRow';import { Panel } from '@/components/common/Panel';import { PagesTable } from '@/components/metrics/PagesTable';import { ReferrersTable } from '@/components/metrics/ReferrersTable';@@ -7,57 +8,37 @@ import { OSTable } from '@/components/metrics/OSTable';import { DevicesTable } from '@/components/metrics/DevicesTable';import { WorldMap } from '@/components/metrics/WorldMap';import { CountriesTable } from '@/components/metrics/CountriesTable';-import { EventsTable } from '@/components/metrics/EventsTable';-import { EventsChart } from '@/components/metrics/EventsChart';-import { usePathname } from 'next/navigation';export function WebsiteTableView({ websiteId }: { websiteId: string }) {- const pathname = usePathname();- const tableProps = {- websiteId,- limit: 10,- };- const isSharePage = pathname.includes('/share/');-return (<Grid gap="3">- <Grid gap="3" columns="repeat(auto-fill, minmax(500px, 1fr))">+ <GridRow layout="two"><Panel>- <PagesTable {...tableProps} />+ <PagesTable websiteId={websiteId} limit={10} /></Panel><Panel>- <ReferrersTable {...tableProps} />+ <ReferrersTable websiteId={websiteId} limit={10} /></Panel>- </Grid>- <Grid gap="3" columns="repeat(auto-fill, minmax(400px, 1fr))">+ </GridRow>+ <GridRow layout="three"><Panel>- <BrowsersTable {...tableProps} />+ <BrowsersTable websiteId={websiteId} limit={10} /></Panel><Panel>- <OSTable {...tableProps} />+ <OSTable websiteId={websiteId} limit={10} /></Panel><Panel>- <DevicesTable {...tableProps} />+ <DevicesTable websiteId={websiteId} limit={10} /></Panel>- </Grid>- <Grid gap="3" columns="2fr 1fr">- <Panel padding="0">+ </GridRow>+ <GridRow layout="two-one">+ <Panel padding="0" gridColumn="span 2"><WorldMap websiteId={websiteId} /></Panel><Panel>- <CountriesTable {...tableProps} />+ <CountriesTable websiteId={websiteId} limit={10} /></Panel>- </Grid>- {isSharePage && (- <Grid gap="3">- <Panel>- <EventsTable {...tableProps} />- </Panel>- <Panel>- <EventsChart websiteId={websiteId} />- </Panel>- </Grid>- )}+ </GridRow></Grid>);}diff --git a/src/components/charts/BarChart.tsx b/src/components/charts/BarChart.tsxindex 026bc3228..bc4ac6d3f 100644--- a/src/components/charts/BarChart.tsx+++ b/src/components/charts/BarChart.tsx@@ -82,19 +82,19 @@ export function BarChart(props: BarChartProps) {const handleTooltip = ({ tooltip }: { tooltip: any }) => {const { opacity } = tooltip;- setTooltip(- opacity ? <BarChartTooltip tooltip={tooltip} unit={unit} currency={currency} /> : null,- );+ setTooltip(opacity ? tooltip : null);};return (- <Chart- {...props}- type="bar"- chartOptions={options}- tooltip={tooltip}- onTooltip={handleTooltip}- style={{ height: 400 }}- />+ <>+ <Chart+ {...props}+ type="bar"+ chartOptions={options}+ onTooltip={handleTooltip}+ style={{ height: 400 }}+ />+ {tooltip && <BarChartTooltip tooltip={tooltip} unit={unit} currency={currency} />}+ </>);}diff --git a/src/components/charts/Chart.tsx b/src/components/charts/Chart.tsxindex e47ea3cda..9890b3ae5 100644--- a/src/components/charts/Chart.tsx+++ b/src/components/charts/Chart.tsx@@ -1,4 +1,4 @@-import { useState, useRef, useEffect, useMemo, ReactNode, HTMLAttributes } from 'react';+import { useState, useRef, useEffect, useMemo, HTMLAttributes } from 'react';import { Loading } from '@umami/react-zen';import ChartJS, { LegendItem, ChartOptions } from 'chart.js/auto';import { Legend } from '@/components/metrics/Legend';@@ -14,7 +14,6 @@ export interface ChartProps extends HTMLAttributes<HTMLDivElement> {onUpdate?: (chart: any) => void;onTooltip?: (model: any) => void;chartOptions?: ChartOptions;- tooltip?: ReactNode;}export function Chart({@@ -27,7 +26,6 @@ export function Chart({onUpdate,onTooltip,chartOptions,- tooltip,...props}: ChartProps) {const canvas = useRef(null);@@ -53,6 +51,7 @@ export function Chart({},tooltip: {enabled: false,+ intersect: true,external: onTooltip,},},@@ -139,7 +138,6 @@ export function Chart({<canvas ref={canvas} /></div><Legend items={legendItems} onClick={handleLegendClick} />- {tooltip}</>);}diff --git a/src/components/common/GridRow.tsx b/src/components/common/GridRow.tsxindex 9546651dc..b49ddbf9f 100644--- a/src/components/common/GridRow.tsx+++ b/src/components/common/GridRow.tsx@@ -2,10 +2,20 @@ import { Grid } from '@umami/react-zen';const LAYOUTS = {one: { columns: '1fr' },- two: { columns: { xs: '1fr', sm: '1fr', md: '1fr 1fr', lg: '1fr 1fr' } },- three: { columns: { xs: '1fr', sm: '1fr', md: '1fr 1fr 1fr', lg: '1fr 2fr' } },- 'one-two': { columns: { xs: '1fr', sm: '1fr', md: '1fr 2fr', lg: '1fr 2fr' } },- 'two-one': { columns: { xs: '1fr', sm: '1fr', md: '2fr 1fr', lg: '2fr 1fr', xl: '2fr 1fr' } },+ two: {+ columns: {+ xs: '1fr',+ md: 'repeat(auto-fill, minmax(600px, 1fr))',+ },+ },+ three: {+ columns: {+ xs: '1fr',+ md: 'repeat(auto-fill, minmax(400px, 1fr))',+ },+ },+ 'one-two': { columns: { xs: '1fr', lg: 'repeat(3, 1fr)' } },+ 'two-one': { columns: { xs: '1fr', lg: 'repeat(3, 1fr)' } },};export function GridRow(props: {diff --git a/src/components/common/TypeIcon.tsx b/src/components/common/TypeIcon.tsxindex 395052659..746d65933 100644--- a/src/components/common/TypeIcon.tsx+++ b/src/components/common/TypeIcon.tsx@@ -13,9 +13,9 @@ export function TypeIcon({return (<Row gap="3" alignItems="center"><img- src={`${process.env.basePath || ''}/images/${type}/${value- ?.replaceAll(' ', '-')- .toLowerCase()}.png`}+ src={`${process.env.basePath || ''}/images/${type}/${+ value?.replaceAll(' ', '-').toLowerCase() || 'xx'+ }.png`}onError={e => {e.currentTarget.src = `${process.env.basePath || ''}/images/${type}/unknown.png`;}}diff --git a/src/components/input/TeamsButton.tsx b/src/components/input/TeamsButton.tsxindex c1eb453ce..aea6d8a99 100644--- a/src/components/input/TeamsButton.tsx+++ b/src/components/input/TeamsButton.tsx@@ -1,4 +1,4 @@-import { useState } from 'react';+import { Key } from 'react';import { useRouter } from 'next/navigation';import {Text,@@ -30,16 +30,10 @@ export function TeamsButton({const { teamId } = useNavigation();const router = useRouter();const team = result?.data?.find(({ id }) => id === teamId);- const [selectedKeys, setSelectedKeys] = useState<any>(new Set([teamId || user.id]));+ const selectedKeys = new Set([teamId || user.id]);- const handleSelect = (keys: Set<string>) => {- if (keys.size > 0) {- const [id] = [...keys];-- router.push(id === user.id ? '/dashboard' : `/teams/${id}/dashboard`);-- setSelectedKeys(keys);- }+ const handleSelect = (id: Key) => {+ router.push(id === user.id ? '/dashboard' : `/teams/${id}/dashboard`);};if (!result?.count) {@@ -63,7 +57,7 @@ export function TeamsButton({selectionMode="single"selectedKeys={selectedKeys}autoFocus="last"- onSelectionChange={keys => handleSelect(keys as Set<string>)}+ onAction={handleSelect}><MenuSection title={formatMessage(labels.myAccount)}><MenuItem id={user.id}>