feat: add GeoIP session location (country/city/coordinates from IP) - #1
Merged
Conversation
Resolves each session's IP through a local MaxMind GeoLite2/GeoIP2 mmdb (GEOIP_DB_PATH), mirroring the existing offline UA-detection approach so no visitor data is sent to a third-party geolocation API. Optional: with no database configured, geo fields just stay empty. Geo is stored per-session (like ip/user_agent already are) and exposed via two new GraphQL queries: sessionGeo and sessionsByCountry.
Adds a link to MaxMind's free GeoLite2 sign-up, a GraphQL usage example for the new sessionGeo/sessionsByCountry queries, a French privacy note in DOC.md, and fixes a stray line-wrap in the README feature list.
Sources a free GeoLite2-derived City .mmdb (IPv4 + IPv6) from sapics/ip-location-db on first boot and weekly thereafter, cached under ./data/geoip — no signup, no license key to rotate. If the download fails (no egress, air-gapped deploy), the server still starts and geo fields just stay empty, same as before. GeoLookup now opens a list of mmdb readers instead of a single one, so it can use the split per-family files this source publishes while still supporting a single combined MaxMind file via GEOIP_DB_PATH, which skips auto-download entirely.
Athenox14
force-pushed
the
claude/geoip-support-vzazg6
branch
from
July 13, 2026 18:56
51652d2 to
9f8f75e
Compare
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.mmdbfile (GEOIP_DB_PATHenv var), mirroring the existing offline UA-detection approach — no visitor data is ever sent to a third-party geolocation service.ip/user_agentcolumns on thesessionstable (added via a safepragma_table_info+ALTER TABLEmigration so existing databases pick up the new columns).sessionGeo(projectId, sessionId)andsessionsByCountry(projectId)(a visitors-by-country breakdown).Changes
crates/iris-core/src/geo.rs(new):GeoLookup, a thin wrapper over themaxminddbcrate with graceful fallback when no database is configured.crates/iris-core/src/models.rs: newGeoInfostruct.crates/iris-server/src/main.rs: loadsGeoLookupfromGEOIP_DB_PATHat startup, logs whether it's active.crates/iris-server/src/capture.rs: resolves geo from the request IP on/captureand/batch.crates/iris-server/src/storage.rs: schema migration for the newsessionscolumns, geo persisted on session upsert, newsession_geo/sessions_by_countryqueries.crates/iris-server/src/schema.rs: newsessionGeo/sessionsByCountryGraphQL queries.README.md/DOC.md: document the new (optional)GEOIP_DB_PATHconfig and feature..gitignore: ignore*.mmdbdatabase files.Test plan
cargo build --workspace— builds clean on all default features.cargo test --workspace— all tests pass, including newgeo::testscovering the no-database and invalid-IP fallback paths.GEOIP_DB_PATHset, posted to/capturewith a session, and queriedsessionGeo/sessionsByCountryover GraphQL — confirmed graceful empty-geo behavior with no errors.