Add wrapper to Sentry to not load it when not configured

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-06-27 13:15:24 +02:00
parent 3ed25bab81
commit 7ec6f158ec
13 changed files with 102 additions and 24 deletions

View File

@@ -2,7 +2,10 @@ defmodule Mobilizon.Web.Endpoint do
@moduledoc """
Endpoint for Mobilizon app
"""
if Application.fetch_env!(:mobilizon, :env) !== :test do
alias Mobilizon.Service.ErrorReporting.Sentry, as: SentryAdapter
if Application.fetch_env!(:mobilizon, :env) !== :test &&
SentryAdapter.enabled?() do
use Sentry.PlugCapture
end
@@ -92,7 +95,8 @@ defmodule Mobilizon.Web.Endpoint do
String.replace_leading(url(), "http", "ws")
end
if Application.fetch_env!(:mobilizon, :env) !== :test do
if Application.fetch_env!(:mobilizon, :env) !== :test &&
SentryAdapter.enabled?() do
plug(Sentry.PlugContext)
end
end