You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/setup-with-plug-and-phoenix.md
+21-5Lines changed: 21 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,15 @@
1
1
# Setup with Plug and Phoenix
2
2
3
-
You can capture errors in Plug (and Phoenix) applications with `Sentry.PlugContext` and `Sentry.PlugCapture`.`Sentry.PlugContext` adds contextual metadata from the current request which is then included in errors that are captured and reported by `Sentry.PlugCapture`.
3
+
You can enrich errors in Plug (and Phoenix) applications with `Sentry.PlugContext`.`Sentry.PlugContext` adds contextual metadata from the current request which is then included in errors.
4
4
5
5
## For Phoenix Applications
6
6
7
7
If you are using Phoenix:
8
8
9
-
1. Add `Sentry.PlugCapture` above the `use Phoenix.Endpoint` line in your endpoint file
10
9
1. Add `Sentry.PlugContext` below `Plug.Parsers`
11
10
12
11
```diff
13
12
defmodule MyAppWeb.Endpoint
14
-
+ use Sentry.PlugCapture
15
13
use Phoenix.Endpoint, otp_app: :my_app
16
14
17
15
# ...
@@ -24,6 +22,16 @@ If you are using Phoenix:
24
22
+ plug Sentry.PlugContext
25
23
```
26
24
25
+
1. If you're using Cowboy, also add `Sentry.PlugCapture` above the `use Phoenix.Endpoint` line in your endpoint file
26
+
27
+
```diff
28
+
defmodule MyAppWeb.Endpoint
29
+
+ use Sentry.PlugCapture
30
+
use Phoenix.Endpoint, otp_app: :my_app
31
+
32
+
# ...
33
+
```
34
+
27
35
If you're also using [Phoenix LiveView](https://github.com/phoenixframework/phoenix_live_view), consider also setting up your LiveViews to use the `Sentry.LiveViewHook` hook:
28
36
29
37
```elixir
@@ -72,13 +80,11 @@ end
72
80
73
81
If you are in a non-Phoenix Plug application:
74
82
75
-
1. Add `Sentry.PlugCapture` at the top of your Plug application
76
83
1. Add `Sentry.PlugContext` below `Plug.Parsers` (if it is in your stack)
77
84
78
85
```diff
79
86
defmodule MyApp.Router do
80
87
use Plug.Router
81
-
+ use Sentry.PlugCapture
82
88
83
89
# ...
84
90
@@ -87,3 +93,13 @@ If you are in a non-Phoenix Plug application:
87
93
88
94
+ plug Sentry.PlugContext
89
95
```
96
+
97
+
1. If you're using Cowboy, add `Sentry.PlugCapture` at the top of your Plug application
0 commit comments