diff --git a/db/clickhouse/schema.sql b/db/clickhouse/schema.sql index be277743..d6294d44 100644 --- a/db/clickhouse/schema.sql +++ b/db/clickhouse/schema.sql @@ -57,7 +57,7 @@ CREATE TABLE umami.event_data event_name String, data_key String, string_value Nullable(String), - number_value Nullable(Decimal64(22, 4)), + number_value Nullable(Decimal(22, 4)), date_value Nullable(DateTime('UTC')), data_type UInt32, created_at DateTime('UTC'), @@ -73,7 +73,7 @@ CREATE TABLE umami.session_data session_id UUID, data_key String, string_value Nullable(String), - number_value Nullable(Decimal64(22, 4)), + number_value Nullable(Decimal(22, 4)), date_value Nullable(DateTime('UTC')), data_type UInt32, distinct_id String, diff --git a/src/app/(main)/websites/[websiteId]/(reports)/utm/UTM.tsx b/src/app/(main)/websites/[websiteId]/(reports)/utm/UTM.tsx index f2aadec9..47c17b6a 100644 --- a/src/app/(main)/websites/[websiteId]/(reports)/utm/UTM.tsx +++ b/src/app/(main)/websites/[websiteId]/(reports)/utm/UTM.tsx @@ -1,12 +1,10 @@ -import { Grid, Column, Heading, Text } from '@umami/react-zen'; -import { firstBy } from 'thenby'; -import { CHART_COLORS, UTM_PARAMS } from '@/lib/constants'; -import { useResultQuery } from '@/components/hooks'; import { PieChart } from '@/components/charts/PieChart'; -import { ListTable } from '@/components/metrics/ListTable'; -import { useMessages } from '@/components/hooks'; -import { Panel } from '@/components/common/Panel'; import { LoadingPanel } from '@/components/common/LoadingPanel'; +import { Panel } from '@/components/common/Panel'; +import { useMessages, useResultQuery } from '@/components/hooks'; +import { ListTable } from '@/components/metrics/ListTable'; +import { CHART_COLORS, UTM_PARAMS } from '@/lib/constants'; +import { Column, Grid, Heading, Text } from '@umami/react-zen'; export interface UTMProps { websiteId: string; @@ -27,19 +25,19 @@ export function UTM({ websiteId, startDate, endDate }: UTMProps) { {data && ( {UTM_PARAMS.map(param => { - const items = toArray(data?.[param]); + const items = data?.[param]; const chartData = { - labels: items.map(({ name }) => name), + labels: items.map(({ utm }) => utm), datasets: [ { - data: items.map(({ value }) => value), + data: items.map(({ views }) => views), backgroundColor: CHART_COLORS, borderWidth: 0, }, ], }; - const total = items.reduce((sum, { value }) => { - return +sum + +value; + const total = items.reduce((sum, { views }) => { + return +sum + +views; }, 0); return ( @@ -51,10 +49,10 @@ export function UTM({ websiteId, startDate, endDate }: UTMProps) { ({ - x: name, - y: value, - z: (value / total) * 100, + data={items.map(({ utm, views }) => ({ + x: utm, + y: views, + z: (views / total) * 100, }))} /> @@ -70,11 +68,3 @@ export function UTM({ websiteId, startDate, endDate }: UTMProps) { ); } - -function toArray(data: Record = {}) { - return Object.keys(data) - .map(key => { - return { name: key, value: data[key] }; - }) - .sort(firstBy('value', -1)); -} diff --git a/src/app/(main)/websites/[websiteId]/WebsiteLayout.tsx b/src/app/(main)/websites/[websiteId]/WebsiteLayout.tsx index b095afdb..152c2a8f 100644 --- a/src/app/(main)/websites/[websiteId]/WebsiteLayout.tsx +++ b/src/app/(main)/websites/[websiteId]/WebsiteLayout.tsx @@ -10,7 +10,7 @@ export function WebsiteLayout({ websiteId, children }: { websiteId: string; chil return ( - + diff --git a/src/app/(main)/websites/[websiteId]/events/EventProperties.tsx b/src/app/(main)/websites/[websiteId]/events/EventProperties.tsx index 25e65405..26d2f265 100644 --- a/src/app/(main)/websites/[websiteId]/events/EventProperties.tsx +++ b/src/app/(main)/websites/[websiteId]/events/EventProperties.tsx @@ -36,7 +36,7 @@ export function EventProperties({ websiteId }: { websiteId: string }) { gap="6" > {data && ( - +