From c174e18b39353bddb8e579f4923df700ed0dc056 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 15 Dec 2021 09:47:52 +0100 Subject: [PATCH] Improve compilation dependency in endpoint and context Signed-off-by: Thomas Citharel --- lib/web/auth/context.ex | 5 ++--- lib/web/endpoint.ex | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/web/auth/context.ex b/lib/web/auth/context.ex index 4e3eaaae6..86ac41b36 100644 --- a/lib/web/auth/context.ex +++ b/lib/web/auth/context.ex @@ -6,7 +6,6 @@ defmodule Mobilizon.Web.Auth.Context do import Plug.Conn - alias Mobilizon.Service.ErrorReporting.Sentry, as: SentryAdapter alias Mobilizon.Users.User @spec init(Plug.opts()) :: Plug.opts() @@ -27,7 +26,7 @@ defmodule Mobilizon.Web.Auth.Context do user_agent = conn |> Plug.Conn.get_req_header("user-agent") |> List.first() - if SentryAdapter.enabled?() do + if Application.get_env(:sentry, :dsn) != nil do Sentry.Context.set_request_context(%{ url: Plug.Conn.request_url(conn), method: conn.method, @@ -46,7 +45,7 @@ defmodule Mobilizon.Web.Auth.Context do {conn, context} = case Guardian.Plug.current_resource(conn) do %User{id: user_id, email: user_email} = user -> - if SentryAdapter.enabled?() do + if Application.get_env(:sentry, :dsn) != nil do Sentry.Context.set_user_context(%{ id: user_id, email: user_email, diff --git a/lib/web/endpoint.ex b/lib/web/endpoint.ex index 40eb6638c..fe82f4e58 100644 --- a/lib/web/endpoint.ex +++ b/lib/web/endpoint.ex @@ -2,10 +2,9 @@ defmodule Mobilizon.Web.Endpoint do @moduledoc """ Endpoint for Mobilizon app """ - alias Mobilizon.Service.ErrorReporting.Sentry, as: SentryAdapter if Application.fetch_env!(:mobilizon, :env) !== :test && - SentryAdapter.enabled?() do + Application.get_env(:sentry, :dsn) != nil do use Sentry.PlugCapture end @@ -85,7 +84,7 @@ defmodule Mobilizon.Web.Endpoint do end if Application.fetch_env!(:mobilizon, :env) !== :test && - SentryAdapter.enabled?() do + Application.get_env(:sentry, :dsn) != nil do plug(Sentry.PlugContext) end end