🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
Refactor geolocation data extraction in getLocationFromIPAPI function
Bill Yang2bd00d24f9dd
diff --git a/server/src/db/geolocation/geolocation.ts b/server/src/db/geolocation/geolocation.tsindex 97632ad97..f470b19d2 100644--- a/server/src/db/geolocation/geolocation.ts+++ b/server/src/db/geolocation/geolocation.ts@@ -175,14 +175,9 @@ async function getLocationFromIPAPI(ips: string[]): Promise<Record<string, Locatcontinue;}+ const localInfo = await (reader as ExtendedReader).city(ip);const locationData: LocationResponse = {- city: item.location?.city,- country: item.location?.country,- countryIso: item.location?.country_code,- region: localInfo[ip]?.region,- latitude: item.location?.latitude,- longitude: item.location?.longitude,- timeZone: item.location?.timezone,+ ...extractLocationData(localInfo),vpn: item.vpn?.service,crawler: typeof item.is_crawler === "string" ? item.is_crawler : undefined,datacenter: item.datacenter?.datacenter,