Add timezone handling

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-10-10 16:25:50 +02:00
parent eba3c70c9b
commit d58ca5743d
49 changed files with 1218 additions and 429 deletions

View File

@@ -27,23 +27,30 @@ defmodule Mobilizon.Web.Auth.Context do
user_agent = conn |> Plug.Conn.get_req_header("user-agent") |> List.first()
if SentryAdapter.enabled?() 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 ->
if SentryAdapter.enabled?() do
Sentry.Context.set_user_context(%{id: user_id, name: user_email})
Sentry.Context.set_request_context(%{
url: Plug.Conn.request_url(conn),
method: conn.method,
headers: %{
"User-Agent": user_agent
},
query_string: conn.query_string,
env: %{
REQUEST_ID: conn |> Plug.Conn.get_resp_header("x-request-id") |> List.first(),
SERVER_NAME: conn.host
}
Sentry.Context.set_user_context(%{
id: user_id,
email: user_email,
ip_address: context.ip
})
end