Move Sentry request context to new module and load it everytime

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2022-03-29 11:27:53 +02:00
parent 3c8a2a1313
commit 4a8064f24f
3 changed files with 36 additions and 22 deletions

View File

@@ -26,22 +26,6 @@ defmodule Mobilizon.Web.Auth.Context do
user_agent = conn |> Plug.Conn.get_req_header("user-agent") |> List.first()
if Application.get_env(:sentry, :dsn) != nil do
Sentry.Context.set_request_context(%{
url: Plug.Conn.request_url(conn),
method: conn.method,
headers: %{
"User-Agent": user_agent,
Referer: conn |> Plug.Conn.get_req_header("referer") |> List.first()
},
query_string: conn.query_string,
env: %{
REQUEST_ID: conn |> Plug.Conn.get_resp_header("x-request-id") |> List.first(),
SERVER_NAME: conn.host
}
})
end
{conn, context} =
case Guardian.Plug.current_resource(conn) do
%User{id: user_id, email: user_email} = user ->