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"])
|
||||||
|
|
||||||
|
if country do
|
||||||
Map.merge(row, %{
|
Map.merge(row, %{
|
||||||
"name" => country.name,
|
"name" => country.name,
|
||||||
"flag" => country.flag,
|
"flag" => country.flag,
|
||||||
"alpha_3" => country.alpha_3,
|
"alpha_3" => country.alpha_3,
|
||||||
"code" => country.alpha_2
|
"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"])
|
||||||
|
|
||||||
|
if region do
|
||||||
country_entry = Location.get_country(region_entry.country_code)
|
country_entry = Location.get_country(region_entry.country_code)
|
||||||
Map.merge(region, %{"name" => region_entry.name, "country_flag" => country_entry.flag})
|
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