Skip to content

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

Sentry cleanup (#2590)

Adam Rutkowski61bf624761ef
diff --git a/lib/plausible_web/controllers/api/stats_controller.ex b/lib/plausible_web/controllers/api/stats_controller.ex
index 20e774d545..4eab322655 100644
--- a/lib/plausible_web/controllers/api/stats_controller.ex
+++ b/lib/plausible_web/controllers/api/stats_controller.ex
@@ -5,6 +5,8 @@ defmodule PlausibleWeb.Api.StatsController do
alias Plausible.Stats
alias Plausible.Stats.{Query, Filters}
+ require Logger
+
@doc """
Returns a time-series based on given parameters.
@@ -805,7 +807,7 @@ defmodule PlausibleWeb.Api.StatsController do
country_entry = 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]})
+ Logger.warning("Could not find region info - code: #{inspect(region[:code])}")
Map.merge(region, %{name: region[:code]})
end
end)
@@ -842,7 +844,7 @@ defmodule PlausibleWeb.Api.StatsController do
country_flag: country_info.flag
})
else
- Sentry.capture_message("Could not find city info", extra: %{code: city[:code]})
+ Logger.warning("Could not find city info - code: #{inspect(city[:code])}")
Map.merge(city, %{name: "N/A"})
end
@@ -1173,7 +1175,7 @@ defmodule PlausibleWeb.Api.StatsController do
defp get_country(code) do
case Location.get_country(code) do
nil ->
- Sentry.capture_message("Could not find country info", extra: %{code: code})
+ Logger.warning("Could not find country info - code: #{inspect(code)}")
%Location.Country{
alpha_2: code,
diff --git a/lib/plausible_web/endpoint.ex b/lib/plausible_web/endpoint.ex
index 34078e93ea..90172f0c3a 100644
--- a/lib/plausible_web/endpoint.ex
+++ b/lib/plausible_web/endpoint.ex
@@ -13,7 +13,7 @@ defmodule PlausibleWeb.Endpoint do
at: "/",
from: :plausible,
gzip: false,
- only: ~w(css fonts images js favicon.ico robots.txt)
+ only: ~w(css images js favicon.ico robots.txt)
plug Plug.Static,
at: "/kaffy",
diff --git a/lib/sentry_filter.ex b/lib/sentry_filter.ex
index 84871972d2..700888030f 100644
--- a/lib/sentry_filter.ex
+++ b/lib/sentry_filter.ex
@@ -6,6 +6,8 @@ defmodule Plausible.SentryFilter do
def exclude_exception?(%Sentry.CrashError{}, _source), do: true
def exclude_exception?(%Phoenix.NotAcceptableError{}, _), do: true
+ def exclude_exception?(%Plug.CSRFProtection.InvalidCSRFTokenError{}, _), do: true
+ def exclude_exception?(%Plug.Static.InvalidPathError{}, _), do: true
def exclude_exception?(exception, source) do
Sentry.DefaultEventFilter.exclude_exception?(exception, source)
@@ -14,11 +16,6 @@ defmodule Plausible.SentryFilter do
@spec before_send(Sentry.Event.t()) :: Sentry.Event.t()
def before_send(event)
- # https://hexdocs.pm/sentry/readme.html#fingerprinting
- def before_send(%{exception: [%{type: DBConnection.ConnectionError}]} = event) do
- %{event | fingerprint: ["ecto", "db_connection", "timeout"]}
- end
-
def before_send(
%{exception: [%{type: "Clickhousex.Error"}], original_exception: %{code: code}} = event
)
@@ -26,6 +23,10 @@ defmodule Plausible.SentryFilter do
%{event | fingerprint: ["clickhouse", "db_connection", to_string(code)]}
end
+ def before_send(%{event_source: :logger, message: "Clickhousex.Protocol " <> _} = event) do
+ %{event | fingerprint: ["clickhouse", "db_connection", "protocol_error"]}
+ end
+
def before_send(event) do
event
end