Skip to content

Commit af8d84d

Browse files
committed
Filter exceptions
1 parent c5b44cc commit af8d84d

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

config/prod.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ config :sasl, sasl_error_logger: false
2222

2323
config :sentry,
2424
enable_source_code_context: true,
25-
root_source_code_paths: [File.cwd!()]
25+
root_source_code_paths: [File.cwd!()],
26+
before_send: {Diff.Application, :sentry_before_send}
2627

2728
config :logger, level: :info
2829

lib/diff/application.ex

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ defmodule Diff.Application do
3434
:ok
3535
end
3636

37+
def sentry_before_send(%Sentry.Event{original_exception: exception} = event) do
38+
cond do
39+
Plug.Exception.status(exception) < 500 -> nil
40+
Sentry.DefaultEventFilter.exclude_exception?(exception, event.source) -> nil
41+
true -> event
42+
end
43+
end
44+
3745
if Mix.env() == :prod do
3846
defp goth_spec() do
3947
credentials =

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ defmodule Diff.MixProject do
5050
{:phoenix_view, "~> 2.0"},
5151
{:phoenix, "~> 1.6"},
5252
{:plug_cowboy, "~> 2.1"},
53-
{:sentry, "~> 10.2"}
53+
{:sentry, "~> 10.8"}
5454
]
5555
end
5656

0 commit comments

Comments
 (0)