Kind: Function
Source: atloria-monorepo/apps/api/src/analytics/utils/tracking-utils.ts
Resolve a client IP to a 2-letter ISO country code using the bundled
MaxMind GeoLite2 database (via geoip-lite). This is the same approach
Umami, Plausible, and Matomo all use for server-side geolocation.
Returns null for:
- localhost / private IPs (127., 10., 192.168.*, etc.)
- IPs not found in the database
- malformed inputs
The GeoLite2 database is loaded into RAM once at startup (~2MB). All subsequent lookups are pure memory reads — sub-microsecond latency.
Signature
tsfunction lookupCountry(ip: string | null): string | null
Parameters
| Name | Type |
|---|---|
ip | `string |
Returns: string | null
Was this page helpful?