From 88707ff729123e49775a56fc2b866f55e64dd754 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 27 Jan 2021 16:31:46 +0100 Subject: [PATCH] Add Sentry We use Sentry 7.x for now because Sentry 8.0 requires Elixir 1.10 Signed-off-by: Thomas Citharel --- .sobelow-skips | 2 +- config/config.exs | 1 + lib/web/endpoint.ex | 1 + lib/web/router.ex | 2 ++ mix.exs | 1 + mix.lock | 1 + 6 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.sobelow-skips b/.sobelow-skips index 9e3133f2f..d31ffad24 100644 --- a/.sobelow-skips +++ b/.sobelow-skips @@ -1,2 +1,2 @@ -752C0E897CA81ACD81F4BB215FA5F8E4 \ No newline at end of file +5048AE33D6269B15E21CF28C6F545AB6 diff --git a/config/config.exs b/config/config.exs index f20c3768c..250e035dc 100644 --- a/config/config.exs +++ b/config/config.exs @@ -112,6 +112,7 @@ config :mobilizon, Mobilizon.Web.Email.Mailer, # Configures Elixir's Logger config :logger, :console, + backends: [:console, Sentry.LoggerBackend], format: "$time $metadata[$level] $message\n", metadata: [:request_id] diff --git a/lib/web/endpoint.ex b/lib/web/endpoint.ex index 24ba70034..8424e3e0e 100644 --- a/lib/web/endpoint.ex +++ b/lib/web/endpoint.ex @@ -4,6 +4,7 @@ defmodule Mobilizon.Web.Endpoint do """ use Phoenix.Endpoint, otp_app: :mobilizon use Absinthe.Phoenix.Endpoint + use Sentry.Phoenix.Endpoint plug(Mobilizon.Web.Plugs.SetLocalePlug) plug(Mobilizon.Web.Plugs.HTTPSecurityPlug) diff --git a/lib/web/router.ex b/lib/web/router.ex index a74a84bfd..b37d75c4e 100644 --- a/lib/web/router.ex +++ b/lib/web/router.ex @@ -3,6 +3,8 @@ defmodule Mobilizon.Web.Router do Router for mobilizon app """ use Mobilizon.Web, :router + use Plug.ErrorHandler + use Sentry.Plug pipeline :graphql do # plug(:accepts, ["json"]) diff --git a/mix.exs b/mix.exs index 8ef31afda..22aa3764a 100644 --- a/mix.exs +++ b/mix.exs @@ -141,6 +141,7 @@ defmodule Mobilizon.Mixfile do {:remote_ip, "~> 0.2.0"}, {:ex_cldr_languages, "~> 0.2.1"}, {:slugger, "~> 0.3"}, + {:sentry, "~> 7.0"}, # Dev and test dependencies {:phoenix_live_reload, "~> 1.2", only: [:dev, :e2e]}, {:ex_machina, "~> 2.3", only: [:dev, :test]}, diff --git a/mix.lock b/mix.lock index 3c2025d6b..57db62114 100644 --- a/mix.lock +++ b/mix.lock @@ -112,6 +112,7 @@ "ranch": {:hex, :ranch, "1.7.1", "6b1fab51b49196860b733a49c07604465a47bdb78aa10c1c16a3d199f7f8c881", [:rebar3], [], "hexpm", "451d8527787df716d99dc36162fca05934915db0b6141bbdac2ea8d3c7afc7d7"}, "remote_ip": {:hex, :remote_ip, "0.2.1", "cd27cd8ea54ecaaf3532776ff4c5e353b3804e710302e88c01eadeaaf42e7e24", [:mix], [{:combine, "~> 0.10", [hex: :combine, repo: "hexpm", optional: false]}, {:inet_cidr, "~> 1.0", [hex: :inet_cidr, repo: "hexpm", optional: false]}, {:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "2e7ab1a461cc3cd5719f37e116a08f45c8b8493923063631b164315d6b7ee8e0"}, "rsa_ex": {:hex, :rsa_ex, "0.4.0", "e28dd7dc5236e156df434af0e4aa822384c8866c928e17b785d4edb7c253b558", [:mix], [], "hexpm", "40e1f08e8401da4be59a6dd0f4da30c42d5bb01703161f0208d839d97db27f4e"}, + "sentry": {:hex, :sentry, "7.2.5", "570db92c3bbacd6ad02ac81cba8ac5af11235a55d65ac4375e3ec833975b83d3", [:mix], [{:hackney, "~> 1.8 or 1.6.5", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.3", [hex: :phoenix, repo: "hexpm", optional: true]}, {:plug, "~> 1.6", [hex: :plug, repo: "hexpm", optional: true]}, {:plug_cowboy, "~> 1.0 or ~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}], "hexpm", "ea84ed6848505ff2a246567df562f465d2b34c317d3ecba7c7df58daa56e5e5d"}, "shortuuid": {:hex, :shortuuid, "2.1.2", "14dbafdb2f6c7213fdfcc05c7572384b5051a7b1621170018ad4c05504bd96c1", [:mix], [], "hexpm", "d9b0c4f37500ea5199b6275ece872e213e9f45a015caf4aa777cec84f63ad353"}, "sitemapper": {:hex, :sitemapper, "0.5.0", "23b0bb7b3888f03d4e4e5bedb7034e6d2979e169366372d960d6f433112b9bdf", [:mix], [{:ex_aws_s3, "~> 2.0", [hex: :ex_aws_s3, repo: "hexpm", optional: true]}, {:xml_builder, "~> 2.1.1", [hex: :xml_builder, repo: "hexpm", optional: false]}], "hexpm", "be7acff8d0245aa7ca125b9c4d0751009bbbca26ef866d888fef4fdf98670e41"}, "sleeplocks": {:hex, :sleeplocks, "1.1.1", "3d462a0639a6ef36cc75d6038b7393ae537ab394641beb59830a1b8271faeed3", [:rebar3], [], "hexpm", "84ee37aeff4d0d92b290fff986d6a95ac5eedf9b383fadfd1d88e9b84a1c02e1"},