mirror of
https://github.com/plausible/analytics.git
synced 2024-11-27 09:16:25 +03:00
Notify Sentry when location code is not found
This commit is contained in:
parent
31d1afbcba
commit
81eb2b73df
@ -568,12 +568,22 @@ defmodule PlausibleWeb.Api.StatsController do
|
|||||||
Enum.map(countries, fn row ->
|
Enum.map(countries, fn row ->
|
||||||
country = Location.get_country(row["code"])
|
country = Location.get_country(row["code"])
|
||||||
|
|
||||||
Map.merge(row, %{
|
if country do
|
||||||
"name" => country.name,
|
Map.merge(row, %{
|
||||||
"flag" => country.flag,
|
"name" => country.name,
|
||||||
"alpha_3" => country.alpha_3,
|
"flag" => country.flag,
|
||||||
"code" => country.alpha_2
|
"alpha_3" => country.alpha_3,
|
||||||
})
|
"code" => country.alpha_2
|
||||||
|
})
|
||||||
|
else
|
||||||
|
Sentry.capture_message("Could not find country info", extra: %{code: row["code"]})
|
||||||
|
|
||||||
|
Map.merge(row, %{
|
||||||
|
"name" => row["code"],
|
||||||
|
"alpha_3" => row["code"],
|
||||||
|
"code" => row["code"]
|
||||||
|
})
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
json(conn, countries)
|
json(conn, countries)
|
||||||
@ -590,8 +600,14 @@ defmodule PlausibleWeb.Api.StatsController do
|
|||||||
|> transform_keys(%{"region" => "code"})
|
|> transform_keys(%{"region" => "code"})
|
||||||
|> Enum.map(fn region ->
|
|> Enum.map(fn region ->
|
||||||
region_entry = Location.get_subdivision(region["code"])
|
region_entry = Location.get_subdivision(region["code"])
|
||||||
country_entry = Location.get_country(region_entry.country_code)
|
|
||||||
Map.merge(region, %{"name" => region_entry.name, "country_flag" => country_entry.flag})
|
if region do
|
||||||
|
country_entry = Location.get_country(region_entry.country_code)
|
||||||
|
Map.merge(region, %{"name" => region_entry.name, "country_flag" => country_entry.flag})
|
||||||
|
else
|
||||||
|
Sentry.capture_message("Could not find region info", extra: %{code: region["code"]})
|
||||||
|
Map.merge(region, %{"name" => region["code"]})
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if params["csv"] do
|
if params["csv"] do
|
||||||
@ -626,6 +642,8 @@ defmodule PlausibleWeb.Api.StatsController do
|
|||||||
"country_flag" => country_info.flag
|
"country_flag" => country_info.flag
|
||||||
})
|
})
|
||||||
else
|
else
|
||||||
|
Sentry.capture_message("Could not find city info", extra: %{code: city["code"]})
|
||||||
|
|
||||||
Map.merge(city, %{"name" => "N/A"})
|
Map.merge(city, %{"name" => "N/A"})
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user