Skip to content

armgit / umami

Public Imported from GitHub
0

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.

Merge branch 'dev' into os-names

Mike Cao37e28bbf74ff
diff --cc src/components/hooks/useFormat.ts
index 2b4d0200d,3057e9d87..57edfa520
--- a/src/components/hooks/useFormat.ts
+++ b/src/components/hooks/useFormat.ts
@@@ -1,8 -1,8 +1,8 @@@
import useMessages from './useMessages';
-import { BROWSERS } from 'lib/constants';
+import { BROWSERS, OS_NAMES } from 'lib/constants';
import useLocale from './useLocale';
import useCountryNames from './useCountryNames';
- import regions from 'public/iso-3166-2.json';
+ import regions from '../../../public/iso-3166-2.json';
export function useFormat() {
const { formatMessage, labels } = useMessages();
@@@ -31,17 -23,17 +31,17 @@@
};
const formatCity = (value: string, country?: string): string => {
- return `${value}, ${countryNames[country]}`;
+ return countryNames[country] ? `${value}, ${countryNames[country]}` : value;
};
- const formatDevice = (value: string): string => {
- return formatMessage(labels[value] || labels.unknown);
- };
-
const formatValue = (value: string, type: string, data?: { [key: string]: any }): string => {
switch (type) {
+ case 'os':
+ return formatOS(value);
case 'browser':
return formatBrowser(value);
+ case 'device':
+ return formatDevice(value);
case 'country':
return formatCountry(value);
case 'region':
diff --cc src/components/metrics/OSTable.tsx
index d262c36a6,d27108f19..d822e3afc
--- a/src/components/metrics/OSTable.tsx
+++ b/src/components/metrics/OSTable.tsx
@@@ -1,7 -1,12 +1,6 @@@
import MetricsTable, { MetricsTableProps } from './MetricsTable';
import FilterLink from 'components/common/FilterLink';
- import useMessages from 'components/hooks/useMessages';
- import useFormat from 'components/hooks/useFormat';
-import { useMessages } from 'components/hooks';
-
-const names = {
- 'Mac OS': 'macOS',
- 'Chrome OS': 'ChromeOS',
- 'Sun OS': 'SunOS',
-};
++import { useMessages, useFormat } from 'components/hooks';
export function OSTable(props: MetricsTableProps) {
const { formatMessage, labels } = useMessages();