mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-04-20 13:36:20 +00:00
Migrated VisitsParser to TS
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import bowser from 'bowser';
|
||||
import { zipObj } from 'ramda';
|
||||
import { Empty, hasValue } from '../utils';
|
||||
import { Stats, UserAgent } from '../../visits/types';
|
||||
|
||||
const DEFAULT = 'Others';
|
||||
const BROWSERS_WHITELIST = [
|
||||
@@ -17,11 +18,6 @@ const BROWSERS_WHITELIST = [
|
||||
'WeChat',
|
||||
];
|
||||
|
||||
interface UserAgent {
|
||||
browser: string;
|
||||
os: string;
|
||||
}
|
||||
|
||||
export const parseUserAgent = (userAgent: string | Empty): UserAgent => {
|
||||
if (!hasValue(userAgent)) {
|
||||
return { browser: DEFAULT, os: DEFAULT };
|
||||
@@ -42,5 +38,5 @@ export const extractDomain = (url: string | Empty): string => {
|
||||
return domain.split(':')[0];
|
||||
};
|
||||
|
||||
export const fillTheGaps = (stats: Record<string, number>, labels: string[]): number[] =>
|
||||
export const fillTheGaps = (stats: Stats, labels: string[]): number[] =>
|
||||
Object.values({ ...zipObj(labels, labels.map(() => 0)), ...stats });
|
||||
|
||||
Reference in New Issue
Block a user