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..a2e6a0db3 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] @@ -276,12 +277,16 @@ config :mobilizon, Oban, repo: Mobilizon.Storage.Repo, log: false, queues: [default: 10, search: 5, mailers: 10, background: 5], - crontab: [ - {"@hourly", Mobilizon.Service.Workers.BuildSiteMap, queue: :background}, - {"17 * * * *", Mobilizon.Service.Workers.RefreshGroups, queue: :background}, - # To be activated in Mobilizon 1.2 - # {"@hourly", Mobilizon.Service.Workers.CleanOrphanMediaWorker, queue: :background}, - {"@hourly", Mobilizon.Service.Workers.CleanUnconfirmedUsersWorker, queue: :background} + plugins: [ + {Oban.Plugins.Cron, + crontab: [ + {"@hourly", Mobilizon.Service.Workers.BuildSiteMap, queue: :background}, + {"17 * * * *", Mobilizon.Service.Workers.RefreshGroups, queue: :background}, + # To be activated in Mobilizon 1.2 + # {"@hourly", Mobilizon.Service.Workers.CleanOrphanMediaWorker, queue: :background}, + {"@hourly", Mobilizon.Service.Workers.CleanUnconfirmedUsersWorker, queue: :background} + ]}, + {Oban.Plugins.Pruner, max_age: 300} ] config :mobilizon, :rich_media, diff --git a/config/test.exs b/config/test.exs index 38f132bd4..28d61d351 100644 --- a/config/test.exs +++ b/config/test.exs @@ -53,7 +53,7 @@ config :tesla, Mobilizon.Service.HTTP.GeospatialClient, config :mobilizon, Mobilizon.Service.Geospatial, service: Mobilizon.Service.Geospatial.Mock -config :mobilizon, Oban, queues: false, crontab: false, plugins: false +config :mobilizon, Oban, queues: false, plugins: false config :mobilizon, Mobilizon.Web.Auth.Guardian, secret_key: "some secret" 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..07c108add 100644 --- a/mix.lock +++ b/mix.lock @@ -96,7 +96,7 @@ "nimble_pool": {:hex, :nimble_pool, "0.1.0", "ffa9d5be27eee2b00b0c634eb649aa27f97b39186fec3c493716c2a33e784ec6", [:mix], [], "hexpm", "343a1eaa620ddcf3430a83f39f2af499fe2370390d4f785cd475b4df5acaf3f9"}, "oauth2": {:hex, :oauth2, "2.0.0", "338382079fe16c514420fa218b0903f8ad2d4bfc0ad0c9f988867dfa246731b0", [:mix], [{:hackney, "~> 1.13", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "881b8364ac7385f9fddc7949379cbe3f7081da37233a1aa7aab844670a91e7e7"}, "oauther": {:hex, :oauther, "1.1.1", "7d8b16167bb587ecbcddd3f8792beb9ec3e7b65c1f8ebd86b8dd25318d535752", [:mix], [], "hexpm", "9374f4302045321874cccdc57eb975893643bd69c3b22bf1312dab5f06e5788e"}, - "oban": {:hex, :oban, "2.3.4", "ec7509b9af2524d55f529cb7aee93d36131ae0bf0f37706f65d2fe707f4d9fd8", [:mix], [{:ecto_sql, ">= 3.4.3", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.14", [hex: :postgrex, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "c70ca0434758fd1805422ea4446af5e910ddc697c0c861549c8f0eb0cfbd2fdf"}, + "oban": {:hex, :oban, "2.4.1", "f567090ea38e898dd42328c20c7a4696814d3de19aeb914a44ecb4819ca3ebf0", [:mix], [{:ecto_sql, ">= 3.4.3", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.14", [hex: :postgrex, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "aa15da86f8851a9bb6f2266993fc1980b2c7851e06d7f45939a155cd3984d5df"}, "parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"}, "phoenix": {:hex, :phoenix, "1.5.7", "2923bb3af924f184459fe4fa4b100bd25fa6468e69b2803dfae82698269aa5e0", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_html, "~> 2.13", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.2", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.1.2 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "774cd64417c5a3788414fdbb2be2eb9bcd0c048d9e6ad11a0c1fd67b7c0d0978"}, "phoenix_ecto": {:hex, :phoenix_ecto, "4.2.1", "13f124cf0a3ce0f1948cf24654c7b9f2347169ff75c1123f44674afee6af3b03", [:mix], [{:ecto, "~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.14.2 or ~> 2.15", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "478a1bae899cac0a6e02be1deec7e2944b7754c04e7d4107fc5a517f877743c0"}, @@ -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"}, diff --git a/priv/repo/migrations/20210127153325_upgrade_oban_jobs_to_v10.exs b/priv/repo/migrations/20210127153325_upgrade_oban_jobs_to_v10.exs new file mode 100644 index 000000000..4b69af253 --- /dev/null +++ b/priv/repo/migrations/20210127153325_upgrade_oban_jobs_to_v10.exs @@ -0,0 +1,6 @@ +defmodule Mobilizon.Storage.Repo.Migrations.UpgradeObanJobsToV10 do + use Ecto.Migration + + defdelegate up, to: Oban.Migrations + defdelegate down, to: Oban.Migrations +end