diff --git a/src/app/(main)/console/TestConsole.tsx b/src/app/(main)/console/TestConsole.tsx
index d33f95e9dc..544aaa9ae0 100644
--- a/src/app/(main)/console/TestConsole.tsx
+++ b/src/app/(main)/console/TestConsole.tsx
@@ -55,35 +55,35 @@ export function TestConsole({ websiteId }: { websiteId: string }) {
referrer: 'https://www.google.com',
}));
window['umami'].track('checkout-cart', {
- revenue: parseFloat((Math.random() * 100000).toFixed(2)),
- currency: 'SHIBA',
+ revenue: parseFloat((Math.random() * 1000).toFixed(2)),
+ currency: 'USD',
});
window['umami'].track('affiliate-link', {
- revenue: parseFloat((Math.random() * 100000).toFixed(2)),
- currency: 'ETH',
+ revenue: parseFloat((Math.random() * 1000).toFixed(2)),
+ currency: 'USD',
});
window['umami'].track('promotion-link', {
- revenue: parseFloat((Math.random() * 100000).toFixed(2)),
+ revenue: parseFloat((Math.random() * 1000).toFixed(2)),
currency: 'USD',
});
window['umami'].track('checkout-cart', {
- revenue: parseFloat((Math.random() * 100000).toFixed(2)),
+ revenue: parseFloat((Math.random() * 1000).toFixed(2)),
currency: 'EUR',
});
window['umami'].track('promotion-link', {
- revenue: parseFloat((Math.random() * 100000).toFixed(2)),
+ revenue: parseFloat((Math.random() * 1000).toFixed(2)),
currency: 'EUR',
});
window['umami'].track('affiliate-link', {
item1: {
productIdentity: 'ABC424',
- revenue: parseFloat((Math.random() * 100000).toFixed(2)),
- currency: 'MXN',
+ revenue: parseFloat((Math.random() * 10000).toFixed(2)),
+ currency: 'JPY',
},
item2: {
productIdentity: 'ZYW684',
- revenue: parseFloat((Math.random() * 100000).toFixed(2)),
- currency: 'MXN',
+ revenue: parseFloat((Math.random() * 10000).toFixed(2)),
+ currency: 'JPY',
},
});
}
diff --git a/src/app/(main)/reports/revenue/RevenueTable.tsx b/src/app/(main)/reports/revenue/RevenueTable.tsx
index bf7114e8fc..0b9fcdc3d5 100644
--- a/src/app/(main)/reports/revenue/RevenueTable.tsx
+++ b/src/app/(main)/reports/revenue/RevenueTable.tsx
@@ -23,7 +23,7 @@ export function RevenueTable() {
{row => formatLongCurrency(row.sum, row.currency)}
- {row => formatLongCurrency(row.avg, row.currency)}
+ {row => formatLongCurrency(row.count ? row.sum / row.count : 0, row.currency)}
{row => row.count}
diff --git a/src/app/(main)/reports/revenue/RevenueView.tsx b/src/app/(main)/reports/revenue/RevenueView.tsx
index cd53129a1c..2d559893f5 100644
--- a/src/app/(main)/reports/revenue/RevenueView.tsx
+++ b/src/app/(main)/reports/revenue/RevenueView.tsx
@@ -87,7 +87,7 @@ export function RevenueView({ isLoading }: RevenueViewProps) {
const metricData = useMemo(() => {
if (!data) return [];
- const { sum, avg, count, unique_count } = data.total;
+ const { sum, count, unique_count } = data.total;
return [
{
@@ -96,7 +96,7 @@ export function RevenueView({ isLoading }: RevenueViewProps) {
formatValue: n => formatLongCurrency(n, currency),
},
{
- value: avg,
+ value: count ? sum / count : 0,
label: formatMessage(labels.average),
formatValue: n => formatLongCurrency(n, currency),
},
diff --git a/src/lib/format.ts b/src/lib/format.ts
index 71e4916d13..e497464a65 100644
--- a/src/lib/format.ts
+++ b/src/lib/format.ts
@@ -114,5 +114,5 @@ export function formatLongCurrency(value: number, currency: string, locale = 'en
return `${formatCurrency(n / 1000, currency, locale)}k`;
}
- return formatCurrency(n / 1000, currency, locale);
+ return formatCurrency(n, currency, locale);
}
diff --git a/src/queries/analytics/reports/getRevenue.ts b/src/queries/analytics/reports/getRevenue.ts
index 5fb419c0e4..caef94694e 100644
--- a/src/queries/analytics/reports/getRevenue.ts
+++ b/src/queries/analytics/reports/getRevenue.ts
@@ -32,11 +32,10 @@ async function relationalQuery(
): Promise<{
chart: { x: string; t: string; y: number }[];
country: { name: string; value: number }[];
- total: { sum: number; avg: number; count: number; unique_count: number };
+ total: { sum: number; count: number; unique_count: number };
table: {
currency: string;
sum: number;
- avg: number;
count: number;
unique_count: number;
}[];
@@ -96,7 +95,6 @@ async function relationalQuery(
`
select
sum(coalesce(cast(number_value as decimal(10,2)), cast(string_value as decimal(10,2)))) as sum,
- avg(coalesce(cast(number_value as decimal(10,2)), cast(string_value as decimal(10,2)))) as avg,
count(distinct event_id) as count,
count(distinct session_id) as unique_count
from event_data ed
@@ -119,7 +117,6 @@ async function relationalQuery(
select
c.currency,
sum(coalesce(cast(number_value as decimal(10,2)), cast(string_value as decimal(10,2)))) as sum,
- avg(coalesce(cast(number_value as decimal(10,2)), cast(string_value as decimal(10,2)))) as avg,
count(distinct ed.website_event_id) as count,
count(distinct we.session_id) as unique_count
from event_data ed
@@ -153,11 +150,10 @@ async function clickhouseQuery(
): Promise<{
chart: { x: string; t: string; y: number }[];
country: { name: string; value: number }[];
- total: { sum: number; avg: number; count: number; unique_count: number };
+ total: { sum: number; count: number; unique_count: number };
table: {
currency: string;
sum: number;
- avg: number;
count: number;
unique_count: number;
}[];
@@ -230,7 +226,6 @@ async function clickhouseQuery(
`
select
sum(coalesce(toDecimal64(number_value, 2), toDecimal64(string_value, 2))) as sum,
- avg(coalesce(toDecimal64(number_value, 2), toDecimal64(string_value, 2))) as avg,
uniqExact(event_id) as count,
uniqExact(session_id) as unique_count
from event_data
@@ -259,7 +254,6 @@ async function clickhouseQuery(
select
c.currency,
sum(coalesce(toDecimal64(ed.number_value, 2), toDecimal64(ed.string_value, 2))) as sum,
- avg(coalesce(toDecimal64(ed.number_value, 2), toDecimal64(ed.string_value, 2))) as avg,
uniqExact(ed.event_id) as count,
uniqExact(ed.session_id) as unique_count
from event_data ed