From 952d2061fd9a1947dc5f5c5c125452420e72c638 Mon Sep 17 00:00:00 2001
From: Benjamin Piouffle <benjamin@captainfact.io>
Date: Mon, 8 Jan 2024 23:17:37 +0100
Subject: [PATCH] debt: Remove rollbar

---
 apps/cf/config/config.exs    |  4 ----
 apps/cf/config/dev.exs       |  4 ----
 apps/cf/config/prod.exs      |  5 -----
 apps/cf/config/test.exs      |  4 ----
 apps/cf/lib/errors/errors.ex | 15 ++++++---------
 apps/cf/mix.exs              |  1 -
 config/releases.exs          |  8 --------
 mix.lock                     |  1 -
 8 files changed, 6 insertions(+), 36 deletions(-)

diff --git a/apps/cf/config/config.exs b/apps/cf/config/config.exs
index 575fc6e4..a6a864dd 100644
--- a/apps/cf/config/config.exs
+++ b/apps/cf/config/config.exs
@@ -53,10 +53,6 @@ config :cf,
 
 config :guardian, Guardian.DB, repo: DB.Repo
 
-# Configure Rollbar (errors reporting)
-config :rollbax,
-  enabled: :log
-
 config :scout_apm,
   name: "CaptainFact",
   key: {:system, "CF_SCOUT_APM_KEY"}
diff --git a/apps/cf/config/dev.exs b/apps/cf/config/dev.exs
index 7881c8ec..04d8ac1f 100644
--- a/apps/cf/config/dev.exs
+++ b/apps/cf/config/dev.exs
@@ -26,10 +26,6 @@ config :logger, :console, format: "[$level] $message\n"
 # in production as building large stacktraces may be expensive.
 config :phoenix, :stacktrace_depth, 20
 
-# Configure Rollbar (errors reporting)
-config :rollbax,
-  environment: "dev"
-
 # Mails
 config :cf, CF.Mailer, adapter: Bamboo.LocalAdapter
 
diff --git a/apps/cf/config/prod.exs b/apps/cf/config/prod.exs
index 2a65a989..6ca44729 100644
--- a/apps/cf/config/prod.exs
+++ b/apps/cf/config/prod.exs
@@ -1,9 +1,4 @@
 use Mix.Config
 
-# Configure Rollbar (errors reporting)
-config :rollbax,
-  environment: "prod",
-  enable_crash_reports: true
-
 # Do not print debug messages in production
 config :logger, level: :info
diff --git a/apps/cf/config/test.exs b/apps/cf/config/test.exs
index 0904feb8..306ecf23 100644
--- a/apps/cf/config/test.exs
+++ b/apps/cf/config/test.exs
@@ -26,7 +26,3 @@ config :bcrypt_elixir, :log_rounds, 4
 # Behaviours mock for testing
 config :cf, captions_fetcher: CF.Videos.CaptionsFetcherTest
 config :cf, use_test_video_metadata_fetcher: true
-
-# Configure Rollbar (errors reporting)
-config :rollbax,
-  environment: "test"
diff --git a/apps/cf/lib/errors/errors.ex b/apps/cf/lib/errors/errors.ex
index 1db9ce7e..b693fc34 100644
--- a/apps/cf/lib/errors/errors.ex
+++ b/apps/cf/lib/errors/errors.ex
@@ -1,9 +1,10 @@
 defmodule CF.Errors do
   @moduledoc """
-  Module to report errors, currenctly plugged on Rollbar with important metadata
-  added. It mostly mimics `Rollbax` API.
+  Module to report errors
   """
 
+  require Logger
+
   @type cf_error_params :: [
           user: DB.Schema.User.t(),
           custom: Map.t(),
@@ -36,13 +37,9 @@ defmodule CF.Errors do
 
   @spec do_report(:error | :exit | :throw, any(), [any()], cf_error_params()) :: :ok
   def do_report(type, value, stacktrace, params) do
-    Rollbax.report(
-      type,
-      value,
-      stacktrace,
-      params[:custom] || %{},
-      build_occurence_data(params)
-    )
+    # Any call to Sentry, Rollbar, etc. should be done here
+    Logger.error("[ERROR][#{type}] #{inspect(value)} - #{inspect(stacktrace)}")
+    :ok
   end
 
   defp build_occurence_data(params) do
diff --git a/apps/cf/mix.exs b/apps/cf/mix.exs
index 033dcbd6..447109e3 100644
--- a/apps/cf/mix.exs
+++ b/apps/cf/mix.exs
@@ -55,7 +55,6 @@ defmodule CF.Mixfile do
       {:bamboo, "~> 1.7.1"},
       {:hackney, "~> 1.17"},
       {:oauth2, "~> 0.9"},
-      {:rollbax, ">= 0.0.0"},
       {:sweet_xml, "~> 0.6"},
       {:burnex, "~> 1.0"},
       {:yaml_elixir, "~> 2.9.0"},
diff --git a/config/releases.exs b/config/releases.exs
index 41a2647b..32d45cf7 100644
--- a/config/releases.exs
+++ b/config/releases.exs
@@ -58,14 +58,6 @@ end
 # ---- [Global config keys] ----
 
 frontend_url = String.trim_trailing(load_secret.("frontend_url")) <> "/"
-rollbar_access_token = load_secret.({"rollbar_access_token", nil})
-
-if rollbar_access_token do
-  config :rollbax,
-    enabled: true,
-    access_token: rollbar_access_token,
-    environment: load_secret.({"rollbar_environment", "production"})
-end
 
 # ---- [APP CONFIG] :db ----
 
diff --git a/mix.lock b/mix.lock
index 8ee29947..200ee253 100644
--- a/mix.lock
+++ b/mix.lock
@@ -82,7 +82,6 @@
   "postgrex": {:hex, :postgrex, "0.17.1", "01c29fd1205940ee55f7addb8f1dc25618ca63a8817e56fac4f6846fc2cddcbe", [:mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "14b057b488e73be2beee508fb1955d8db90d6485c6466428fe9ccf1d6692a555"},
   "quantum": {:hex, :quantum, "2.3.3", "83f565de81ac43b8fda4dd4266b209eaed29545d1c41e17aa6b75b08736c80f6", [:mix], [{:calendar, "~> 0.17", [hex: :calendar, repo: "hexpm", optional: true]}, {:crontab, "~> 1.1", [hex: :crontab, repo: "hexpm", optional: false]}, {:gen_stage, "~> 0.12", [hex: :gen_stage, repo: "hexpm", optional: false]}, {:swarm, "~> 3.3", [hex: :swarm, repo: "hexpm", optional: false]}, {:timex, "~> 3.1", [hex: :timex, repo: "hexpm", optional: true]}], "hexpm", "01a63089a17f00f360ddad6c2f068c26d4e280999c2a6c2bce170d0bd6b2bd2e"},
   "ranch": {:hex, :ranch, "1.3.2", "e4965a144dc9fbe70e5c077c65e73c57165416a901bd02ea899cfd95aa890986", [:rebar3], [], "hexpm", "6e56493a862433fccc3aca3025c946d6720d8eedf6e3e6fb911952a7071c357f"},
-  "rollbax": {:hex, :rollbax, "0.10.0", "f4f5578767cedd272548d12fa7b14335938ef321e677fc3497d4bd725a193316", [:mix], [{:hackney, "~> 1.1", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "d783640ab1a80fec1b88bd0536ce0a66ed66eb35a289572fedb3da5a865ce460"},
   "scout_apm": {:hex, :scout_apm, "1.0.7", "0ca260f2c7f3c29bf6a5b361e90339bdce0a5f3ae0cf7b0ce166bfb22eefb89c", [:mix], [{:approximate_histogram, "~>0.1.1", [hex: :approximate_histogram, repo: "hexpm", optional: false]}, {:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:plug, "~>1.0", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.0 or ~> 0.3.0", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "a4a3c8318fb84e4586e68fcd7e889c5bfe17c1caa218cc6f333fb0e4c0ff4ec1"},
   "scrivener": {:hex, :scrivener, "2.7.2", "1d913c965ec352650a7f864ad7fd8d80462f76a32f33d57d1e48bc5e9d40aba2", [:mix], [], "hexpm", "7866a0ec4d40274efbee1db8bead13a995ea4926ecd8203345af8f90d2b620d9"},
   "scrivener_ecto": {:hex, :scrivener_ecto, "2.7.0", "cf64b8cb8a96cd131cdbcecf64e7fd395e21aaa1cb0236c42a7c2e34b0dca580", [:mix], [{:ecto, "~> 3.3", [hex: :ecto, repo: "hexpm", optional: false]}, {:scrivener, "~> 2.4", [hex: :scrivener, repo: "hexpm", optional: false]}], "hexpm", "e809f171687806b0031129034352f5ae44849720c48dd839200adeaf0ac3e260"},