Fix money values on graphs and conversions graph tooltips (#4717)

* Fix conversions graph tooltips

* Show revenue value instead of `undefined` in graph

This broke due to the unification of formatters. Not sure if this is the best fix
This commit is contained in:
Karl-Aksel Puulmann 2024-10-22 15:43:49 +03:00 committed by GitHub
parent d727ba5ed5
commit d648505a9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 4 deletions

View File

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

View File

@ -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 "-"