@@ -10,10 +10,18 @@ defmodule ErrorTracker.Integrations.Phoenix do
1010
1111 alias ErrorTracker.Integrations.Plug , as: PlugIntegration
1212
13- # https://hexdocs.pm/phoenix/Phoenix.Logger.html#module-instrumentation
1413 @ events [
14+ # https://hexdocs.pm/phoenix/Phoenix.Logger.html#module-instrumentation
1515 [ :phoenix , :router_dispatch , :start ] ,
16- [ :phoenix , :router_dispatch , :exception ]
16+ [ :phoenix , :router_dispatch , :exception ] ,
17+ # https://hexdocs.pm/phoenix_live_view/telemetry.html
18+ [ :phoenix , :live_view , :mount , :start ] ,
19+ [ :phoenix , :live_view , :mount , :exception ] ,
20+ [ :phoenix , :live_view , :handle_params , :start ] ,
21+ [ :phoenix , :live_view , :handle_params , :exception ] ,
22+ [ :phoenix , :live_view , :handle_event , :start ] ,
23+ [ :phoenix , :live_view , :handle_event , :exception ] ,
24+ [ :phoenix , :live_view , :render , :exception ]
1725 ]
1826
1927 def attach do
@@ -36,6 +44,30 @@ defmodule ErrorTracker.Integrations.Phoenix do
3644 { reason , kind , stack }
3745 end
3846
39- PlugIntegration . report_error ( metadata . conn , { reason , kind } , stack )
47+ PlugIntegration . report_error ( metadata . conn , { kind , reason } , stack )
48+ end
49+
50+ def handle_event ( [ :phoenix , :live_view , :mount , :start ] , _ , metadata , :no_config ) do
51+ ErrorTracker . set_context ( % {
52+ "live_view.view" => metadata . socket . view
53+ } )
54+ end
55+
56+ def handle_event ( [ :phoenix , :live_view , :handle_params , :start ] , _ , metadata , :no_config ) do
57+ ErrorTracker . set_context ( % {
58+ "live_view.uri" => metadata . uri ,
59+ "live_view.params" => metadata . params
60+ } )
61+ end
62+
63+ def handle_event ( [ :phoenix , :live_view , :handle_event , :start ] , _ , metadata , :no_config ) do
64+ ErrorTracker . set_context ( % {
65+ "live_view.event" => metadata . event ,
66+ "live_view.event_params" => metadata . params
67+ } )
68+ end
69+
70+ def handle_event ( [ :phoenix , :live_view , _action , :exception ] , _ , metadata , :no_config ) do
71+ ErrorTracker . report ( { metadata . kind , metadata . reason } , metadata . stacktrace )
4072 end
4173end
0 commit comments