From 2ce5e4c56ed543d1b235ecdede2f41d47a47f11d Mon Sep 17 00:00:00 2001 From: Anthony Shull Date: Mon, 26 Aug 2024 13:32:35 -0500 Subject: [PATCH] Upgrade Sentry from 7 to 10 (#2160) * sentry 8 * sentry 9 * sentry 10 * use interpolation --- config/config.exs | 4 ++++ config/deps/sentry.exs | 9 --------- deploy/dotcom/prod/Dockerfile | 4 +++- lib/dotcom_web/endpoint.ex | 2 ++ lib/dotcom_web/router.ex | 2 -- lib/dotcom_web/views/helpers.ex | 2 +- mix.exs | 3 +-- mix.lock | 5 +++-- 8 files changed, 14 insertions(+), 17 deletions(-) delete mode 100644 config/deps/sentry.exs diff --git a/config/config.exs b/config/config.exs index b8d57ca19d..77c10ee3ec 100644 --- a/config/config.exs +++ b/config/config.exs @@ -29,6 +29,10 @@ config :dotcom, :redix_pub_sub, Redix.PubSub config :dotcom, :otp_module, OpenTripPlannerClient config :dotcom, :req_module, Req +config :sentry, + filter: Dotcom.SentryFilter, + json_library: Poison + for config_file <- Path.wildcard("config/{deps,dotcom}/*.exs") do import_config("../#{config_file}") end diff --git a/config/deps/sentry.exs b/config/deps/sentry.exs deleted file mode 100644 index 40daa04ccf..0000000000 --- a/config/deps/sentry.exs +++ /dev/null @@ -1,9 +0,0 @@ -import Config - -# Centralize Error reporting -config :sentry, - enable_source_code_context: true, - filter: Dotcom.SentryFilter, - included_environments: ~w(prod dev dev-green dev-blue), - json_library: Poison, - root_source_code_path: File.cwd!() diff --git a/deploy/dotcom/prod/Dockerfile b/deploy/dotcom/prod/Dockerfile index 219e06deaa..271a25eea6 100644 --- a/deploy/dotcom/prod/Dockerfile +++ b/deploy/dotcom/prod/Dockerfile @@ -52,12 +52,14 @@ WORKDIR /root # Add frontend assets, required by phx.digest COPY --from=assets-builder /root/priv/static ./priv/static +# package source code for Sentry +RUN mix sentry.package_source_code + # re-compile the application after the assets are copied, since some of them # are built into the application (SVG icons) RUN mix do compile, phx.digest RUN mix release - # 4) Use the nodejs container for the runtime environment # Since we're server-rendering the React templates, we need a Javascript engine running inside the container. FROM node:18.17.1-buster-slim diff --git a/lib/dotcom_web/endpoint.ex b/lib/dotcom_web/endpoint.ex index 7a15a337b7..6933d30fbb 100644 --- a/lib/dotcom_web/endpoint.ex +++ b/lib/dotcom_web/endpoint.ex @@ -2,6 +2,7 @@ defmodule DotcomWeb.Endpoint do @moduledoc false use Phoenix.Endpoint, otp_app: :dotcom + use Sentry.PlugCapture @session_options store: :cookie, key: "_site_key", @@ -57,6 +58,7 @@ defmodule DotcomWeb.Endpoint do json_decoder: Poison ) + plug(Sentry.PlugContext) plug(Plug.MethodOverride) plug(Plug.Head) diff --git a/lib/dotcom_web/router.ex b/lib/dotcom_web/router.ex index 0d8fa8d86a..c9aa822586 100644 --- a/lib/dotcom_web/router.ex +++ b/lib/dotcom_web/router.ex @@ -2,8 +2,6 @@ defmodule DotcomWeb.Router do @moduledoc false use DotcomWeb, :router - use Plug.ErrorHandler - use Sentry.Plug alias DotcomWeb.StaticPage diff --git a/lib/dotcom_web/views/helpers.ex b/lib/dotcom_web/views/helpers.ex index 01d6d3e982..0ae7f8b429 100644 --- a/lib/dotcom_web/views/helpers.ex +++ b/lib/dotcom_web/views/helpers.ex @@ -150,7 +150,7 @@ defmodule DotcomWeb.ViewHelpers do end defp report_missing_icon(message) do - Sentry.capture_message("Missing icon #{message}") + Sentry.capture_message("Missing icon %s", interpolation_parameters: [message]) end def bus_icon_pill(route) do diff --git a/mix.exs b/mix.exs index 50cf94a1c7..e0de3e67c3 100644 --- a/mix.exs +++ b/mix.exs @@ -132,8 +132,7 @@ defmodule DotCom.Mixfile do {:redix, "1.5.1"}, {:req, "0.5.6"}, {:rstar, github: "armon/erl-rstar"}, - # latest version 10.1.0; cannot upgrade because setup appears to have changed - {:sentry, "7.2.5"}, + {:sentry, "10.7.0"}, {:server_sent_event_stage, "1.2.1"}, {:sizeable, "1.0.2"}, {:sweet_xml, "0.7.4", only: [:prod, :dev]}, diff --git a/mix.lock b/mix.lock index c43e3181e9..86bbf0ce05 100644 --- a/mix.lock +++ b/mix.lock @@ -58,6 +58,7 @@ "nebulex": {:hex, :nebulex, "2.6.3", "78af348ed9f8a338871b41e0b6de718c1808e627ce03fbe86598cbda2bdda2f5", [:mix], [{:decorator, "~> 1.4", [hex: :decorator, repo: "hexpm", optional: true]}, {:shards, "~> 1.1", [hex: :shards, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "09cdcbb62f8463ffcec7cae4936425ce91e25d92a6cd37e48b5dda7c851958d5"}, "nebulex_redis_adapter": {:hex, :nebulex_redis_adapter, "2.4.0", "bebd7aac9fc92378115131b9d90f094c62e5d72869d97191550fb0591d6c1d8a", [:mix], [{:crc, "~> 0.10", [hex: :crc, repo: "hexpm", optional: true]}, {:jchash, "~> 0.1", [hex: :jchash, repo: "hexpm", optional: true]}, {:nebulex, "~> 2.6", [hex: :nebulex, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.5 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:redix, "~> 1.3", [hex: :redix, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "0934142f92b71519fb81324721fab7bc164036c5b91eef7e879a63b98e659814"}, "nimble_options": {:hex, :nimble_options, "1.1.1", "e3a492d54d85fc3fd7c5baf411d9d2852922f66e69476317787a7b2bb000a61b", [:mix], [], "hexpm", "821b2470ca9442c4b6984882fe9bb0389371b8ddec4d45a9504f00a66f650b44"}, + "nimble_ownership": {:hex, :nimble_ownership, "1.0.0", "3f87744d42c21b2042a0aa1d48c83c77e6dd9dd357e425a038dd4b49ba8b79a1", [:mix], [], "hexpm", "7c16cc74f4e952464220a73055b557a273e8b1b7ace8489ec9d86e9ad56cb2cc"}, "nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"}, "nimble_pool": {:hex, :nimble_pool, "1.1.0", "bf9c29fbdcba3564a8b800d1eeb5a3c58f36e1e11d7b7fb2e084a643f645f06b", [:mix], [], "hexpm", "af2e4e6b34197db81f7aad230c1118eac993acc0dae6bc83bac0126d4ae0813a"}, "open_trip_planner_client": {:git, "https://github.com/thecristen/open_trip_planner_client.git", "3664bb3184a6ff7a27cfb5d930edbea941c4671a", [tag: "v0.9.3"]}, @@ -87,7 +88,7 @@ "redix": {:hex, :redix, "1.5.1", "a2386971e69bf23630fb3a215a831b5478d2ee7dc9ea7ac811ed89186ab5d7b7", [:mix], [{:castore, "~> 0.1.0 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:nimble_options, "~> 0.5.0 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "85224eb2b683c516b80d472eb89b76067d5866913bf0be59d646f550de71f5c4"}, "req": {:hex, :req, "0.5.6", "8fe1eead4a085510fe3d51ad854ca8f20a622aae46e97b302f499dfb84f726ac", [:mix], [{:brotli, "~> 0.3.1", [hex: :brotli, repo: "hexpm", optional: true]}, {:ezstd, "~> 1.0", [hex: :ezstd, repo: "hexpm", optional: true]}, {:finch, "~> 0.17", [hex: :finch, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mime, "~> 2.0.6 or ~> 2.1", [hex: :mime, repo: "hexpm", optional: false]}, {:nimble_csv, "~> 1.0", [hex: :nimble_csv, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "cfaa8e720945d46654853de39d368f40362c2641c4b2153c886418914b372185"}, "rstar": {:git, "https://github.com/armon/erl-rstar.git", "a406b2cce609029bf65b9ccfbe93a0416c0ee0cd", []}, - "sentry": {:hex, :sentry, "7.2.5", "570db92c3bbacd6ad02ac81cba8ac5af11235a55d65ac4375e3ec833975b83d3", [:mix], [{:hackney, "1.6.5 or ~> 1.8", [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"}, + "sentry": {:hex, :sentry, "10.7.0", "22af74d002229238b027d051d2bdd26bcd9789db5fea7335170aa41de7a658ce", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: true]}, {:nimble_options, "~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_ownership, "~> 0.3.0 or ~> 1.0", [hex: :nimble_ownership, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.6", [hex: :phoenix, repo: "hexpm", optional: true]}, {:phoenix_live_view, "~> 0.20", [hex: :phoenix_live_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.6", [hex: :plug, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "ca732b35480b8023db2d6dd36418a603c54bdcb9111dbcc246f9d7219669b531"}, "server_sent_event_stage": {:hex, :server_sent_event_stage, "1.2.1", "ede8c63496e19f039972503aa242cb4c16a301d495be7d9fdda2f952298cbf0c", [:mix], [{:castore, "~> 0.1.0 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:ex_doc, "~> 0.22", [hex: :ex_doc, repo: "hexpm", optional: true]}, {:gen_stage, "~> 1.1", [hex: :gen_stage, repo: "hexpm", optional: false]}, {:mint, "~> 1.4", [hex: :mint, repo: "hexpm", optional: false]}], "hexpm", "5b84b2c886bfa3ab38143d424eff6ec9d224e65ca576652aab762ed9d11847c3"}, "sizeable": {:hex, :sizeable, "1.0.2", "625fe06a5dad188b52121a140286f1a6ae1adf350a942cf419499ecd8a11ee29", [:mix], [], "hexpm", "4bab548e6dfba777b400ca50830a9e3a4128e73df77ab1582540cf5860601762"}, "slipstream": {:hex, :slipstream, "1.1.1", "7e56f62f1a9ee81351e3c36f57b9b187e00dc2f470e70ba46ea7ad16e80b061f", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:mint_web_socket, "~> 0.2 or ~> 1.0", [hex: :mint_web_socket, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.1 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "c20e420cde1654329d38ec3aa1c0e4debbd4c91ca421491e7984ad4644e638a6"}, @@ -109,7 +110,7 @@ "wallaby": {:hex, :wallaby, "0.30.9", "51d60682092c3c428c63b656b818e2258202b9f9a31ec37230659647ae20325b", [:mix], [{:ecto_sql, ">= 3.0.0", [hex: :ecto_sql, repo: "hexpm", optional: true]}, {:httpoison, "~> 0.12 or ~> 1.0 or ~> 2.0", [hex: :httpoison, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:phoenix_ecto, ">= 3.0.0", [hex: :phoenix_ecto, repo: "hexpm", optional: true]}, {:web_driver_client, "~> 0.2.0", [hex: :web_driver_client, repo: "hexpm", optional: false]}], "hexpm", "62e3ccb89068b231b50ed046219022020516d44f443eebef93a19db4be95b808"}, "web_driver_client": {:hex, :web_driver_client, "0.2.0", "63b76cd9eb3b0716ec5467a0f8bead73d3d9612e63f7560d21357f03ad86e31a", [:mix], [{:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:tesla, "~> 1.3", [hex: :tesla, repo: "hexpm", optional: false]}], "hexpm", "83cc6092bc3e74926d1c8455f0ce927d5d1d36707b74d9a65e38c084aab0350f"}, "websock": {:hex, :websock, "0.5.3", "2f69a6ebe810328555b6fe5c831a851f485e303a7c8ce6c5f675abeb20ebdadc", [:mix], [], "hexpm", "6105453d7fac22c712ad66fab1d45abdf049868f253cf719b625151460b8b453"}, - "websock_adapter": {:hex, :websock_adapter, "0.5.6", "0437fe56e093fd4ac422de33bf8fc89f7bc1416a3f2d732d8b2c8fd54792fe60", [:mix], [{:bandit, ">= 0.6.0", [hex: :bandit, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.6", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "e04378d26b0af627817ae84c92083b7e97aca3121196679b73c73b99d0d133ea"}, + "websock_adapter": {:hex, :websock_adapter, "0.5.7", "65fa74042530064ef0570b75b43f5c49bb8b235d6515671b3d250022cb8a1f9e", [:mix], [{:bandit, ">= 0.6.0", [hex: :bandit, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.6", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "d0f478ee64deddfec64b800673fd6e0c8888b079d9f3444dd96d2a98383bdbd1"}, "yamerl": {:hex, :yamerl, "0.10.0", "4ff81fee2f1f6a46f1700c0d880b24d193ddb74bd14ef42cb0bcf46e81ef2f8e", [:rebar3], [], "hexpm", "346adb2963f1051dc837a2364e4acf6eb7d80097c0f53cbdc3046ec8ec4b4e6e"}, "yaml_elixir": {:hex, :yaml_elixir, "2.11.0", "9e9ccd134e861c66b84825a3542a1c22ba33f338d82c07282f4f1f52d847bd50", [:mix], [{:yamerl, "~> 0.10", [hex: :yamerl, repo: "hexpm", optional: false]}], "hexpm", "53cc28357ee7eb952344995787f4bb8cc3cecbf189652236e9b163e8ce1bc242"}, "ymlr": {:hex, :ymlr, "5.1.3", "a8061add5a378e20272a31905be70209a5680fdbe0ad51f40cb1af4bdd0a010b", [:mix], [], "hexpm", "8663444fa85101a117887c170204d4c5a2182567e5f84767f0071cf15f2efb1e"},