diff --git a/assets/js/dashboard/stats/reports/metric-formatter.ts b/assets/js/dashboard/stats/reports/metric-formatter.ts index e67f5e04e..60e011dc2 100644 --- a/assets/js/dashboard/stats/reports/metric-formatter.ts +++ b/assets/js/dashboard/stats/reports/metric-formatter.ts @@ -14,6 +14,7 @@ export type FormattableMetric = | 'total_visitors' | 'current_visitors' | 'exit_rate' + | 'conversions' // eslint-disable-next-line @typescript-eslint/no-explicit-any export type ValueType = any @@ -30,6 +31,8 @@ export const MetricFormatterShort: Record< visitors: numberShortFormatter, visits: numberShortFormatter, + conversions: numberShortFormatter, + time_on_page: durationFormatter, visit_duration: durationFormatter, @@ -55,6 +58,8 @@ export const MetricFormatterLong: Record< visitors: numberLongFormatter, visits: numberLongFormatter, + conversions: numberLongFormatter, + time_on_page: durationFormatter, visit_duration: durationFormatter, diff --git a/assets/js/dashboard/util/money.ts b/assets/js/dashboard/util/money.ts index c329a3d39..db0dd006e 100644 --- a/assets/js/dashboard/util/money.ts +++ b/assets/js/dashboard/util/money.ts @@ -1,15 +1,21 @@ +import { numberLongFormatter, numberShortFormatter } from "./number-formatter" + type Money = { long: string, short: string } -export function formatMoneyShort(value: Money | null) { - if (value) { +export function formatMoneyShort(value: Money | number | null) { + if (typeof value == 'number') { + return numberShortFormatter(value) + } else if (value) { return value.short } else { return "-" } } -export function formatMoneyLong(value: Money | null) { - if (value) { +export function formatMoneyLong(value: Money | number | null) { + if (typeof value == 'number') { + return numberLongFormatter(value) + } else if (value) { return value.long } else { return "-"