From fe46c39c10ec9c11ae6d8f04fbb232d8a9129944 Mon Sep 17 00:00:00 2001 From: Emiel Date: Thu, 24 Oct 2024 11:07:58 +0200 Subject: [PATCH 1/2] Added Sentry integration for Phoenix LiveView --- core/frameworks/fabric/live_view.ex | 2 ++ core/lib/core_web/endpoint.ex | 2 ++ 2 files changed, 4 insertions(+) diff --git a/core/frameworks/fabric/live_view.ex b/core/frameworks/fabric/live_view.ex index 2881826bb..3ca680f0c 100644 --- a/core/frameworks/fabric/live_view.ex +++ b/core/frameworks/fabric/live_view.ex @@ -7,6 +7,7 @@ defmodule Fabric.LiveView do defmacro __using__(layout) do quote do use Phoenix.LiveView, layout: {unquote(layout), :live} + on_mount(Sentry.LiveViewHook) unquote(helpers()) end end @@ -14,6 +15,7 @@ defmodule Fabric.LiveView do defmacro __using__() do quote do use Phoenix.LiveView + on_mount(Sentry.LiveViewHook) unquote(helpers()) end end diff --git a/core/lib/core_web/endpoint.ex b/core/lib/core_web/endpoint.ex index a8adcbeec..d05ff00ce 100644 --- a/core/lib/core_web/endpoint.ex +++ b/core/lib/core_web/endpoint.ex @@ -1,4 +1,5 @@ defmodule CoreWeb.Endpoint do + use Sentry.PlugCapture use Phoenix.Endpoint, otp_app: :core require Systems.Content.Plug @@ -69,6 +70,7 @@ defmodule CoreWeb.Endpoint do json_decoder: Phoenix.json_library() ) + plug(Sentry.PlugContext) plug(Plug.MethodOverride) plug(Plug.Head) plug(Plug.Session, @session_options) From a99b57f84d1e5a6e32d997c1a5476edbff6dd188 Mon Sep 17 00:00:00 2001 From: Emiel Date: Thu, 24 Oct 2024 11:20:37 +0200 Subject: [PATCH 2/2] Changed Sentry logging config --- core/lib/core/application.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/lib/core/application.ex b/core/lib/core/application.ex index 5bbe5f487..db590f558 100644 --- a/core/lib/core/application.ex +++ b/core/lib/core/application.ex @@ -6,7 +6,9 @@ defmodule Core.Application do use Application def start(_type, _args) do - :logger.add_handler(:sentry_handler, Sentry.LoggerHandler, %{}) + :logger.add_handler(:sentry_handler, Sentry.LoggerHandler, %{ + config: %{capture_log_messages: true, level: :error} + }) topologies = [ example: [