2022-07-14 03:03:59 +03:00
|
|
|
defmodule Plausible.SentryFilter do
|
2022-09-22 18:24:54 +03:00
|
|
|
@moduledoc """
|
|
|
|
Sentry callbacks for filtering and grouping events
|
|
|
|
"""
|
2022-07-14 03:03:59 +03:00
|
|
|
@behaviour Sentry.EventFilter
|
|
|
|
|
|
|
|
def exclude_exception?(%Sentry.CrashError{}, _source), do: true
|
2022-07-28 15:17:47 +03:00
|
|
|
def exclude_exception?(%Phoenix.NotAcceptableError{}, _), do: true
|
2022-07-14 03:26:59 +03:00
|
|
|
|
|
|
|
def exclude_exception?(exception, source) do
|
|
|
|
Sentry.DefaultEventFilter.exclude_exception?(exception, source)
|
|
|
|
end
|
2022-09-22 18:24:54 +03:00
|
|
|
|
|
|
|
@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
|
|
|
|
|
2023-01-12 19:22:45 +03:00
|
|
|
def before_send(
|
|
|
|
%{exception: [%{type: "Clickhousex.Error"}], original_exception: %{code: code}} = event
|
|
|
|
)
|
|
|
|
when is_atom(code) do
|
|
|
|
%{event | fingerprint: ["clickhouse", "db_connection", to_string(code)]}
|
|
|
|
end
|
|
|
|
|
2022-09-22 18:24:54 +03:00
|
|
|
def before_send(event) do
|
|
|
|
event
|
|
|
|
end
|
2022-07-14 03:03:59 +03:00
|
|
|
end
|