bonfire-app/lib/error_reporting.ex

24 lines
442 B
Elixir
Raw Normal View History

2022-04-16 21:42:40 +00:00
defmodule Bonfire.ErrorReporting do
@behaviour Plug
2022-09-02 02:52:34 +00:00
import Untangle
2022-04-16 21:42:40 +00:00
defmacro __using__(_) do
quote do
require Bonfire.Common.Extend
2022-09-12 04:34:14 +00:00
Bonfire.Common.Extend.use_if_enabled(Sentry.PlugCapture)
2022-04-16 21:42:40 +00:00
end
end
@impl true
def init(_opts) do
[]
end
@impl true
def call(conn, opts) do
2022-09-12 04:34:14 +00:00
if Bonfire.Common.Extend.module_enabled?(Sentry),
do: Sentry.PlugContext.call(conn, opts),
else: conn
2022-04-16 21:42:40 +00:00
end
end