Fixed visits normalization not converting empty strings into null

This commit is contained in:
Alejandro Celaya 2020-09-19 10:31:23 +02:00
parent 2951d0d75e
commit 23046c149c
2 changed files with 3 additions and 2 deletions

View file

@ -72,8 +72,8 @@ export const normalizeVisits = map(({ userAgent, date, referer, visitLocation }:
date,
...parseUserAgent(userAgent),
referer: extractDomain(referer),
country: visitLocation?.countryName ?? 'Unknown',
city: visitLocation?.cityName ?? 'Unknown',
country: visitLocation?.countryName || 'Unknown', // eslint-disable-line @typescript-eslint/prefer-nullish-coalescing
city: visitLocation?.cityName || 'Unknown', // eslint-disable-line @typescript-eslint/prefer-nullish-coalescing
latitude: visitLocation?.latitude,
longitude: visitLocation?.longitude,
}));

View file

@ -28,6 +28,7 @@ describe('VisitsParser', () => {
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36',
visitLocation: {
countryName: 'Spain',
cityName: '',
},
}),
Mock.of<Visit>({