Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Simplify geolix database config

Uku Taht950bd012d546
diff --git a/config/runtime.exs b/config/runtime.exs
index 72a208bac2..f31c2bc41b 100644
--- a/config/runtime.exs
+++ b/config/runtime.exs
@@ -386,7 +386,8 @@ if config_env() != :test && geolite2_country_db do
%{
id: :country,
adapter: Geolix.Adapter.MMDB2,
- source: geolite2_country_db
+ source: geolite2_country_db,
+ result_as: :raw
}
]
end
diff --git a/lib/plausible_web/controllers/api/external_controller.ex b/lib/plausible_web/controllers/api/external_controller.ex
index 26ec39cc5c..900bad93b3 100644
--- a/lib/plausible_web/controllers/api/external_controller.ex
+++ b/lib/plausible_web/controllers/api/external_controller.ex
@@ -194,9 +194,7 @@ defmodule PlausibleWeb.Api.ExternalController do
PlausibleWeb.RemoteIp.get(conn)
|> Geolix.lookup()
- if result && result[:country] && result[:country].country do
- result[:country].country.iso_code
- end
+ get_in(result, [:country, :country, :iso_code])
end
defp parse_referrer(_, nil), do: nil