Improve compilation dependency in endpoint and context
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
b484629010
commit
c174e18b39
@ -6,7 +6,6 @@ defmodule Mobilizon.Web.Auth.Context do
|
|||||||
|
|
||||||
import Plug.Conn
|
import Plug.Conn
|
||||||
|
|
||||||
alias Mobilizon.Service.ErrorReporting.Sentry, as: SentryAdapter
|
|
||||||
alias Mobilizon.Users.User
|
alias Mobilizon.Users.User
|
||||||
|
|
||||||
@spec init(Plug.opts()) :: Plug.opts()
|
@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()
|
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(%{
|
Sentry.Context.set_request_context(%{
|
||||||
url: Plug.Conn.request_url(conn),
|
url: Plug.Conn.request_url(conn),
|
||||||
method: conn.method,
|
method: conn.method,
|
||||||
@ -46,7 +45,7 @@ defmodule Mobilizon.Web.Auth.Context do
|
|||||||
{conn, context} =
|
{conn, context} =
|
||||||
case Guardian.Plug.current_resource(conn) do
|
case Guardian.Plug.current_resource(conn) do
|
||||||
%User{id: user_id, email: user_email} = user ->
|
%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(%{
|
Sentry.Context.set_user_context(%{
|
||||||
id: user_id,
|
id: user_id,
|
||||||
email: user_email,
|
email: user_email,
|
||||||
|
@ -2,10 +2,9 @@ defmodule Mobilizon.Web.Endpoint do
|
|||||||
@moduledoc """
|
@moduledoc """
|
||||||
Endpoint for Mobilizon app
|
Endpoint for Mobilizon app
|
||||||
"""
|
"""
|
||||||
alias Mobilizon.Service.ErrorReporting.Sentry, as: SentryAdapter
|
|
||||||
|
|
||||||
if Application.fetch_env!(:mobilizon, :env) !== :test &&
|
if Application.fetch_env!(:mobilizon, :env) !== :test &&
|
||||||
SentryAdapter.enabled?() do
|
Application.get_env(:sentry, :dsn) != nil do
|
||||||
use Sentry.PlugCapture
|
use Sentry.PlugCapture
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -85,7 +84,7 @@ defmodule Mobilizon.Web.Endpoint do
|
|||||||
end
|
end
|
||||||
|
|
||||||
if Application.fetch_env!(:mobilizon, :env) !== :test &&
|
if Application.fetch_env!(:mobilizon, :env) !== :test &&
|
||||||
SentryAdapter.enabled?() do
|
Application.get_env(:sentry, :dsn) != nil do
|
||||||
plug(Sentry.PlugContext)
|
plug(Sentry.PlugContext)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user