@@ -36,10 +36,47 @@ Setup the application production environment in your ``config/prod.exs``
3636
3737 config :sentry,
3838 dsn: "https://public:[email protected] /1", 39+ environment_name: :prod
3940 tags: %{
4041 env: "production"
4142 },
42- included_environments: ~w(prod)a
43+ included_environments: [:prod]
44+
45+
46+ The ``environment_name `` and ``included_environments `` work together to determine
47+ if and when Sentry should record exceptions. The ``environment_name `` is the
48+ name of the current environment. In the example above, we have explicitly set
49+ the environment to ``:prod `` which works well if you are inside an environment
50+ specific configuration like ``config/prod.exs ``.
51+
52+ An alternative is to use ``Mix.env `` in your general configuration file:
53+
54+ .. code-block :: elixir
55+
56+ config :sentry, dsn: "https://public:[email protected] /1" 57+ included_environments: [:prod],
58+ environment_name: Mix.env
59+
60+ This will set the environment name to whatever the current Mix environment
61+ atom is, but it will only send events if the current environment is ``:prod ``,
62+ since that is the only entry in the ``included_environments `` key.
63+
64+ You can even rely on more custom determinations of the environment name. It's
65+ not uncommmon for most applications to have a "staging" environment. In order
66+ to handle this without adding an additional Mix environment, you can set an
67+ environment variable that determines the release level.
68+
69+ .. code-block :: elixir
70+
71+ config :sentry, dsn: "https://public:[email protected] /1" 72+ included_environments: ~w(production staging),
73+ environment_name: System.get_env("RELEASE_LEVEL") || "development"
74+
75+ In this example, we are getting the environment name from the ``RELEASE_LEVEL ``
76+ environment variable. If that variable does not exist, we default to ``"development" ``.
77+ Now, on our servers, we can set the environment variable appropriately. On
78+ our local development machines, exceptions will never be sent, because the
79+ default value is not in the list of ``included_environments ``.
4380
4481If using an environment with Plug or Phoenix add the following to your router:
4582
0 commit comments