update avg aggregate for revenue report

This commit is contained in:
Francis Cao 2024-10-15 09:24:19 -07:00
parent 9d0da45c09
commit 065499a3fa
5 changed files with 17 additions and 23 deletions

View file

@ -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',
},
});
}

View file

@ -23,7 +23,7 @@ export function RevenueTable() {
{row => formatLongCurrency(row.sum, row.currency)}
</GridColumn>
<GridColumn name="currency" label={formatMessage(labels.average)} alignment="end">
{row => formatLongCurrency(row.avg, row.currency)}
{row => formatLongCurrency(row.count ? row.sum / row.count : 0, row.currency)}
</GridColumn>
<GridColumn name="currency" label={formatMessage(labels.transactions)} alignment="end">
{row => row.count}

View file

@ -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),
},