- {{ $t("You are not part of any group.") }}
+ {{ t("You are not part of any group.") }}
@@ -59,14 +59,14 @@
{{ $t("create a group") }}{{ t("create a group") }}
{{ $t("explore the groups") }}{{ t("explore the groups") }}
diff --git a/js/src/views/Moderation/LogsView.vue b/js/src/views/Moderation/LogsView.vue
index cb54fa9ae..3bdd627ad 100644
--- a/js/src/views/Moderation/LogsView.vue
+++ b/js/src/views/Moderation/LogsView.vue
@@ -21,11 +21,11 @@
>
-
+
diff --git a/lib/federation/activity_pub/actions/update.ex b/lib/federation/activity_pub/actions/update.ex
index 9c0f860ac..c58032fb2 100644
--- a/lib/federation/activity_pub/actions/update.ex
+++ b/lib/federation/activity_pub/actions/update.ex
@@ -36,8 +36,7 @@ defmodule Mobilizon.Federation.ActivityPub.Actions.Update do
{:ok, activity, entity}
{:error, err} ->
- Logger.error("Something went wrong while creating an activity")
- Logger.debug(inspect(err))
+ Logger.error("Something went wrong while creating an activity", err: inspect(err))
{:error, err}
end
end
diff --git a/lib/graphql/middleware/current_actor_provider.ex b/lib/graphql/middleware/current_actor_provider.ex
index abf7384cc..64037f233 100644
--- a/lib/graphql/middleware/current_actor_provider.ex
+++ b/lib/graphql/middleware/current_actor_provider.ex
@@ -18,7 +18,13 @@ defmodule Mobilizon.GraphQL.Middleware.CurrentActorProvider do
case Cachex.fetch(:default_actors, to_string(user_id), fn -> default(user) end) do
{status, %Actor{preferred_username: preferred_username} = current_actor}
when status in [:ok, :commit] ->
- Sentry.Context.set_user_context(%{name: preferred_username})
+ Logger.metadata(user_id: user_id)
+ Logger.metadata(actor_name: "@" <> preferred_username)
+
+ if Application.get_env(:sentry, :dsn) != nil do
+ Sentry.Context.set_user_context(%{name: preferred_username})
+ end
+
context = Map.put(context, :current_actor, current_actor)
%Absinthe.Resolution{resolution | context: context}
diff --git a/lib/graphql/middleware/operation_name_logger.ex b/lib/graphql/middleware/operation_name_logger.ex
new file mode 100644
index 000000000..7c0a888da
--- /dev/null
+++ b/lib/graphql/middleware/operation_name_logger.ex
@@ -0,0 +1,27 @@
+defmodule Mobilizon.GraphQL.Middleware.OperationNameLogger do
+ @moduledoc """
+ An Absinthe middleware to add to logging providers the GraphQL Operation name as context
+ """
+
+ @behaviour Absinthe.Middleware
+ alias Absinthe.Blueprint.Document.Operation
+
+ def call(resolution, _opts) do
+ case Enum.find(resolution.path, ¤t_operation?/1) do
+ %Operation{name: name} when not is_nil(name) ->
+ Logger.metadata(graphql_operation_name: name)
+
+ if Application.get_env(:sentry, :dsn) != nil do
+ Sentry.Context.set_extra_context(%{"graphql_operation_name" => name})
+ end
+
+ _ ->
+ Logger.metadata(graphql_operation_name: "#NULL")
+ end
+
+ resolution
+ end
+
+ defp current_operation?(%Operation{current: true}), do: true
+ defp current_operation?(_), do: false
+end
diff --git a/lib/graphql/schema.ex b/lib/graphql/schema.ex
index e89641b4a..8306808d1 100644
--- a/lib/graphql/schema.ex
+++ b/lib/graphql/schema.ex
@@ -20,7 +20,7 @@ defmodule Mobilizon.GraphQL.Schema do
alias Mobilizon.Actors.{Actor, Follower, Member}
alias Mobilizon.Discussions.Comment
alias Mobilizon.Events.{Event, Participant}
- alias Mobilizon.GraphQL.Middleware.{CurrentActorProvider, ErrorHandler}
+ alias Mobilizon.GraphQL.Middleware.{CurrentActorProvider, ErrorHandler, OperationNameLogger}
alias Mobilizon.GraphQL.Schema
alias Mobilizon.GraphQL.Schema.Custom
alias Mobilizon.Storage.Repo
@@ -199,7 +199,7 @@ defmodule Mobilizon.GraphQL.Schema do
@spec middleware(list(module()), any(), map()) :: list(module())
def middleware(middleware, _field, %{identifier: type}) when type in [:query, :mutation] do
- [CurrentActorProvider] ++ middleware ++ [ErrorHandler]
+ [CurrentActorProvider] ++ middleware ++ [ErrorHandler, OperationNameLogger]
end
def middleware(middleware, _field, _object) do