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.
TypeScript analyticsaudience-segmentationchartscohort-analysisgoogle-analyticsproduct-analyticsstatisticsuser-journeyweb-analytics
Export and use formatCity.
Maxime-J53449d65bb1c
diff --git a/src/components/hooks/useFormat.ts b/src/components/hooks/useFormat.tsindex 57edfa520..11bfcd493 100644--- a/src/components/hooks/useFormat.ts+++ b/src/components/hooks/useFormat.ts@@ -53,7 +53,7 @@ export function useFormat() {}};- return { formatOS, formatBrowser, formatDevice, formatCountry, formatRegion, formatValue };+ return { formatOS, formatBrowser, formatDevice, formatCountry, formatRegion, formatCity, formatValue };}export default useFormat;diff --git a/src/components/metrics/CitiesTable.tsx b/src/components/metrics/CitiesTable.tsxindex d275e6504..7ef3223f3 100644--- a/src/components/metrics/CitiesTable.tsx+++ b/src/components/metrics/CitiesTable.tsx@@ -1,23 +1,16 @@import MetricsTable, { MetricsTableProps } from './MetricsTable';import { emptyFilter } from 'lib/filters';import FilterLink from 'components/common/FilterLink';-import { useLocale } from 'components/hooks';import { useMessages } from 'components/hooks';-import { useCountryNames } from 'components/hooks';+import { useFormat } from 'components/hooks';export function CitiesTable(props: MetricsTableProps) {- const { locale } = useLocale();const { formatMessage, labels } = useMessages();- const countryNames = useCountryNames(locale);-- const renderLabel = (city: string, country: string) => {- const countryName = countryNames[country];- return countryName ? `${city}, ${countryName}` : city;- };+ const { formatCity } = useFormat();const renderLink = ({ x: city, country }) => {return (- <FilterLink id="city" value={city} label={renderLabel(city, country)}>+ <FilterLink id="city" value={city} label={formatCity(city, country)}>{country && (<imgsrc={`${process.env.basePath}/images/flags/${country?.toLowerCase() || 'xx'}.png`}