Skip to content

Commit

Permalink
Split Phoenix vs Plug config for better skimmability (#5780)
Browse files Browse the repository at this point in the history
* Split Phoenix vs Plug config for better skimmability

After being confused by the one code block containing code for both Phoenix projects and Plug-only projects, I figured it would be best to split that code into two blocks, one for each environment type.

Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
  • Loading branch information
2 people authored and lforst committed Nov 22, 2022
1 parent 6ebdc94 commit d96efcc
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/platforms/elixir/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,23 @@ config :sentry, dsn: "___PUBLIC_DSN___",

In this example, we are getting the environment name from the `RELEASE_LEVEL` environment variable. If that variable does not exist, it will default to `"development"`. Now, on our servers, we can set the environment variable appropriately. On our local development machines, exceptions will never be sent, because the default value is not in the list of `included_environments`.

If using an environment with Plug or Phoenix, add the following to `Plug.Router` or `Phoenix.Endpoint`:
If you're using an environment with Phoenix, add the following to `Plug.Router` and `Phoenix.Endpoint`:

```elixir
# Phoenix
# Endpoint
use Sentry.PlugCapture
use Phoenix.Endpoint, otp_app: :my_app
# ...

# Endpoint or Router
plug Plug.Parsers,
parsers: [:urlencoded, :multipart, :json],
pass: ["*/*"],
json_decoder: Phoenix.json_library()
plug Sentry.PlugContext
# Plug
```

If you're not using Phoenix but are using Plug, add the following to your plug pipeline:
```elixir
use Plug.Router
use Sentry.PlugCapture
# ...
Expand Down

0 comments on commit d96efcc

Please sign in to comment.