Skip to content

Commit 317432f

Browse files
authored
Report errors coming from LiveComponents (#74)
This commit expands the Phoenix integration to handle LiveComponents errors in addition to LiveView errors.
1 parent 720470c commit 317432f

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

lib/error_tracker/integrations/phoenix.ex

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ defmodule ErrorTracker.Integrations.Phoenix do
6060
[:phoenix, :live_view, :handle_params, :exception],
6161
[:phoenix, :live_view, :handle_event, :start],
6262
[:phoenix, :live_view, :handle_event, :exception],
63-
[:phoenix, :live_view, :render, :exception]
63+
[:phoenix, :live_view, :render, :exception],
64+
[:phoenix, :live_component, :update, :exception],
65+
[:phoenix, :live_component, :handle_event, :exception]
6466
]
6567

6668
@doc false
@@ -111,4 +113,23 @@ defmodule ErrorTracker.Integrations.Phoenix do
111113
def handle_event([:phoenix, :live_view, _action, :exception], _, metadata, :no_config) do
112114
ErrorTracker.report({metadata.kind, metadata.reason}, metadata.stacktrace)
113115
end
116+
117+
def handle_event([:phoenix, :live_component, :update, :exception], _, metadata, :no_config) do
118+
ErrorTracker.report({metadata.kind, metadata.reason}, metadata.stacktrace, %{
119+
"live_view.component" => metadata.component
120+
})
121+
end
122+
123+
def handle_event(
124+
[:phoenix, :live_component, :handle_event, :exception],
125+
_,
126+
metadata,
127+
:no_config
128+
) do
129+
ErrorTracker.report({metadata.kind, metadata.reason}, metadata.stacktrace, %{
130+
"live_view.component" => metadata.component,
131+
"live_view.event" => metadata.event,
132+
"live_view.event_params" => metadata.params
133+
})
134+
end
114135
end

0 commit comments

Comments
 (0)