@@ -10,10 +10,18 @@ defmodule ErrorTracker.Integrations.Phoenix do
10
10
11
11
alias ErrorTracker.Integrations.Plug , as: PlugIntegration
12
12
13
- # https://hexdocs.pm/phoenix/Phoenix.Logger.html#module-instrumentation
14
13
@ events [
14
+ # https://hexdocs.pm/phoenix/Phoenix.Logger.html#module-instrumentation
15
15
[ :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 ]
17
25
]
18
26
19
27
def attach do
@@ -36,6 +44,30 @@ defmodule ErrorTracker.Integrations.Phoenix do
36
44
{ reason , kind , stack }
37
45
end
38
46
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 )
40
72
end
41
73
end
0 commit comments