Skip to content

Commit

Permalink
Add sentry exception filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmj committed Dec 16, 2024
1 parent dc01151 commit 683f70b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ config :sasl, sasl_error_logger: false

config :sentry,
enable_source_code_context: true,
root_source_code_paths: [File.cwd!()]
root_source_code_paths: [File.cwd!()],
before_send: {Preview.Application, :sentry_before_send}

config :phoenix, :serve_endpoints, true

Expand Down
8 changes: 8 additions & 0 deletions lib/preview/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ defmodule Preview.Application do
%{default: [size: 50, count: 1, conn_max_idle_time: 10_000]}
end

def sentry_before_send(%Sentry.Event{original_exception: exception} = event) do
cond do
Plug.Exception.status(exception) < 500 -> nil
Sentry.DefaultEventFilter.exclude_exception?(exception, event.source) -> nil
true -> event
end
end

if Mix.env() == :prod do
defp goth_spec() do
credentials =
Expand Down

0 comments on commit 683f70b

Please sign in to comment.