Sentry

Setup

Edit your mix.exs file to add it as a dependency and add the :sentry package to your applications:

    {:sentry, "~> 8.0"},
    {:jason, "~> 1.1"},

Config

config/prod.exs

config :sentry,
  dsn: "https://e9bdcefghij.ingest.sentry.io/5265101",
  environment_name: Mix.env(), #:prod 
  enable_source_code_context: true,
  root_source_code_path: File.cwd!,
  tags: %{
    env: "production"
  },
  included_environments: [:prod] #environment_name to send messages in

lib/react_phoenix_web/endpoint.ex

defmodule ReactPhoenixWeb.Router do
  use ReactPhoenixWeb, :router
  use Plug.ErrorHandler
  use Sentry.Plug

  #........

  plug Sentry.PlugContext
  plug Plug.MethodOverride
  plug Plug.Head
  plug Plug.Session, @session_options
  plug ReactPhoenixWeb.Router
end

Logger.error

Usage

Otherwise, we provide a simple way to capture exceptions manually:

Messages

Context

Complex because elixir processes isolated

Last updated