Skip to content

armgit / umami

Public Imported from GitHub
0

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.

update property names for list table to label, count, percent

Francis Cao6d9d8b353f25
diff --git a/src/app/(main)/websites/[websiteId]/(reports)/attribution/Attribution.tsx b/src/app/(main)/websites/[websiteId]/(reports)/attribution/Attribution.tsx
index 192d2c4fe..af947df8d 100644
--- a/src/app/(main)/websites/[websiteId]/(reports)/attribution/Attribution.tsx
+++ b/src/app/(main)/websites/[websiteId]/(reports)/attribution/Attribution.tsx
@@ -61,18 +61,24 @@ export function Attribution({
]
: [];
- function UTMTable({ data = [], title }: { data: any; title: string }) {
+ function AttributionTable({ data = [], title }: { data: any; title: string }) {
+ const attributionData = percentFilter(
+ data.map(({ name, value }) => ({
+ x: name,
+ y: Number(value),
+ })),
+ );
+
return (
<ListTable
title={title}
metric={formatMessage(currency ? labels.revenue : labels.visitors)}
currency={currency}
- data={percentFilter(
- data.map(({ name, value }) => ({
- x: name,
- y: Number(value),
- })),
- )}
+ data={attributionData.map(({ x, y, z }: { x: string; y: number; z: number }) => ({
+ label: x,
+ count: y,
+ percent: z,
+ }))}
/>
);
}
@@ -91,48 +97,34 @@ export function Attribution({
<SectionHeader title={formatMessage(labels.sources)} />
<Grid columns="1fr 1fr" gap>
<Panel>
- <ListTable
- title={formatMessage(labels.referrer)}
- metric={formatMessage(currency ? labels.revenue : labels.visitors)}
- currency={currency}
- data={percentFilter(
- data?.['referrer']?.map(({ name, value }) => ({
- x: name,
- y: Number(value),
- })),
- )}
- />
+ <AttributionTable data={data?.['referrer']} title={formatMessage(labels.referrer)} />
</Panel>
<Panel>
- <ListTable
- title={formatMessage(labels.paidAds)}
- metric={formatMessage(currency ? labels.revenue : labels.visitors)}
- currency={currency}
- data={percentFilter(
- data?.['paidAds']?.map(({ name, value }) => ({
- x: name,
- y: Number(value),
- })),
- )}
- />
+ <AttributionTable data={data?.['paidAds']} title={formatMessage(labels.paidAds)} />
</Panel>
</Grid>
<SectionHeader title="UTM" />
<Grid columns="1fr 1fr" gap>
<Panel>
- <UTMTable data={data?.['utm_source']} title={formatMessage(labels.sources)} />
+ <AttributionTable data={data?.['utm_source']} title={formatMessage(labels.sources)} />
</Panel>
<Panel>
- <UTMTable data={data?.['utm_medium']} title={formatMessage(labels.medium)} />
+ <AttributionTable data={data?.['utm_medium']} title={formatMessage(labels.medium)} />
</Panel>
<Panel>
- <UTMTable data={data?.['utm_cmapaign']} title={formatMessage(labels.campaigns)} />
+ <AttributionTable
+ data={data?.['utm_cmapaign']}
+ title={formatMessage(labels.campaigns)}
+ />
</Panel>
<Panel>
- <UTMTable data={data?.['utm_content']} title={formatMessage(labels.content)} />
+ <AttributionTable
+ data={data?.['utm_content']}
+ title={formatMessage(labels.content)}
+ />
</Panel>
<Panel>
- <UTMTable data={data?.['utm_term']} title={formatMessage(labels.terms)} />
+ <AttributionTable data={data?.['utm_term']} title={formatMessage(labels.terms)} />
</Panel>
</Grid>
</Column>
diff --git a/src/app/(main)/websites/[websiteId]/(reports)/revenue/Revenue.tsx b/src/app/(main)/websites/[websiteId]/(reports)/revenue/Revenue.tsx
index 5963c3c0a..420c94fec 100644
--- a/src/app/(main)/websites/[websiteId]/(reports)/revenue/Revenue.tsx
+++ b/src/app/(main)/websites/[websiteId]/(reports)/revenue/Revenue.tsx
@@ -38,7 +38,7 @@ export function Revenue({ websiteId, startDate, endDate }: RevenueProps) {
});
const renderCountryName = useCallback(
- ({ x: code }) => (
+ ({ label: code }) => (
<Row className={classNames(locale)} gap>
<TypeIcon type="country" value={code} />
<Text>{countryNames[code] || formatMessage(labels.unknown)}</Text>
@@ -136,9 +136,9 @@ export function Revenue({ websiteId, startDate, endDate }: RevenueProps) {
title={formatMessage(labels.country)}
metric={formatMessage(labels.revenue)}
data={data?.country.map(({ name, value }: { name: string; value: number }) => ({
- x: name,
- y: value,
- z: (value / data?.total.sum) * 100,
+ label: name,
+ count: value,
+ percent: (value / data?.total.sum) * 100,
}))}
currency={currency}
renderLabel={renderCountryName}
diff --git a/src/app/(main)/websites/[websiteId]/(reports)/utm/UTM.tsx b/src/app/(main)/websites/[websiteId]/(reports)/utm/UTM.tsx
index 47c17b6a7..1df95893b 100644
--- a/src/app/(main)/websites/[websiteId]/(reports)/utm/UTM.tsx
+++ b/src/app/(main)/websites/[websiteId]/(reports)/utm/UTM.tsx
@@ -26,6 +26,7 @@ export function UTM({ websiteId, startDate, endDate }: UTMProps) {
<Column gap>
{UTM_PARAMS.map(param => {
const items = data?.[param];
+
const chartData = {
labels: items.map(({ utm }) => utm),
datasets: [
@@ -50,9 +51,9 @@ export function UTM({ websiteId, startDate, endDate }: UTMProps) {
<ListTable
metric={formatMessage(labels.views)}
data={items.map(({ utm, views }) => ({
- x: utm,
- y: views,
- z: (views / total) * 100,
+ label: utm,
+ count: views,
+ percent: (views / total) * 100,
}))}
/>
</Column>
diff --git a/src/app/(main)/websites/[websiteId]/realtime/RealtimeCountries.tsx b/src/app/(main)/websites/[websiteId]/realtime/RealtimeCountries.tsx
index 85640fad9..2c16bced1 100644
--- a/src/app/(main)/websites/[websiteId]/realtime/RealtimeCountries.tsx
+++ b/src/app/(main)/websites/[websiteId]/realtime/RealtimeCountries.tsx
@@ -11,7 +11,7 @@ export function RealtimeCountries({ data }) {
const { countryNames } = useCountryNames(locale);
const renderCountryName = useCallback(
- ({ x: code }) => (
+ ({ label: code }) => (
<span className={classNames(styles.row)}>
<TypeIcon type="country" value={code} />
{countryNames[code]}
@@ -24,7 +24,11 @@ export function RealtimeCountries({ data }) {
<ListTable
title={formatMessage(labels.countries)}
metric={formatMessage(labels.visitors)}
- data={data}
+ data={data.map(({ x, y, z }: { x: string; y: number; z: number }) => ({
+ label: x,
+ count: y,
+ percent: z,
+ }))}
renderLabel={renderCountryName}
/>
);
diff --git a/src/app/(main)/websites/[websiteId]/realtime/RealtimeUrls.tsx b/src/app/(main)/websites/[websiteId]/realtime/RealtimeUrls.tsx
index a6e90763e..5bb51c92c 100644
--- a/src/app/(main)/websites/[websiteId]/realtime/RealtimeUrls.tsx
+++ b/src/app/(main)/websites/[websiteId]/realtime/RealtimeUrls.tsx
@@ -27,7 +27,7 @@ export function RealtimeUrls({ data }: { data: any }) {
},
];
- const renderLink = ({ x }) => {
+ const renderLink = ({ label: x }) => {
const domain = x.startsWith('/') ? website?.domain : '';
return (
<a href={`//${domain}${x}`} target="_blank" rel="noreferrer noopener">
@@ -70,7 +70,11 @@ export function RealtimeUrls({ data }: { data: any }) {
title={formatMessage(labels.referrers)}
metric={formatMessage(labels.views)}
renderLabel={renderLink}
- data={domains}
+ data={domains.map(({ x, y, z }: { x: string; y: number; z: number }) => ({
+ label: x,
+ count: y,
+ percent: z,
+ }))}
/>
)}
{filter === FILTER_PAGES && (
@@ -78,7 +82,11 @@ export function RealtimeUrls({ data }: { data: any }) {
title={formatMessage(labels.pages)}
metric={formatMessage(labels.views)}
renderLabel={renderLink}
- data={pages}
+ data={pages.map(({ x, y, z }: { x: string; y: number; z: number }) => ({
+ label: x,
+ count: y,
+ percent: z,
+ }))}
/>
)}
</>