Skip to content

Commit

Permalink
Report errors coming from LiveComponents (#74)
Browse files Browse the repository at this point in the history
This commit expands the Phoenix integration to handle LiveComponents
errors in addition to LiveView errors.
  • Loading branch information
numso authored Aug 30, 2024
1 parent 720470c commit 317432f
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion lib/error_tracker/integrations/phoenix.ex
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ defmodule ErrorTracker.Integrations.Phoenix do
[:phoenix, :live_view, :handle_params, :exception],
[:phoenix, :live_view, :handle_event, :start],
[:phoenix, :live_view, :handle_event, :exception],
[:phoenix, :live_view, :render, :exception]
[:phoenix, :live_view, :render, :exception],
[:phoenix, :live_component, :update, :exception],
[:phoenix, :live_component, :handle_event, :exception]
]

@doc false
Expand Down Expand Up @@ -111,4 +113,23 @@ defmodule ErrorTracker.Integrations.Phoenix do
def handle_event([:phoenix, :live_view, _action, :exception], _, metadata, :no_config) do
ErrorTracker.report({metadata.kind, metadata.reason}, metadata.stacktrace)
end

def handle_event([:phoenix, :live_component, :update, :exception], _, metadata, :no_config) do
ErrorTracker.report({metadata.kind, metadata.reason}, metadata.stacktrace, %{
"live_view.component" => metadata.component
})
end

def handle_event(
[:phoenix, :live_component, :handle_event, :exception],
_,
metadata,
:no_config
) do
ErrorTracker.report({metadata.kind, metadata.reason}, metadata.stacktrace, %{
"live_view.component" => metadata.component,
"live_view.event" => metadata.event,
"live_view.event_params" => metadata.params
})
end
end

0 comments on commit 317432f

Please sign in to comment.