diff --git a/assets/js/app.js b/assets/js/app.js index a86f3c3..d0b74cf 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -25,25 +25,6 @@ import { LiveSocket } from "phoenix_live_view"; // topbar is loaded globally from vendor bundle const topbar = window.topbar; -// Sentry initialization happens via the loader script in the HTML -// Configure additional Sentry settings if needed -if (typeof window.Sentry !== "undefined" && window.Sentry.onLoad) { - window.Sentry.onLoad(function () { - window.Sentry.init({ - environment: "production", - integrations: [new window.Sentry.BrowserTracing()], - tracesSampleRate: 1.0, // Capture 100% of transactions for performance monitoring - sampleRate: 1.0, // Capture 100% of errors - beforeSend(event, hint) { - // Filter out known non-critical errors - if (hint.originalException?.message?.includes("ResizeObserver loop limit exceeded")) { - return null; - } - return event; - }, - }); - }); -} let csrfToken = document.querySelector("meta[name='csrf-token']")?.getAttribute("content") || ""; if (!csrfToken) { diff --git a/config/dev.exs b/config/dev.exs index b634f5e..94dc4b4 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -110,11 +110,4 @@ config :phoenix, :plug_init_mode, :runtime # configured to run both http and https servers on config :phoenix, :stacktrace_depth, 20 -# Configure Sentry for development (disabled by default) -config :sentry, - environment_name: :dev, - enable_source_code_context: true, - root_source_code_paths: [File.cwd!()], - before_send: {Aprsme.SentryFilter, :before_send} - config :swoosh, :api_client, false diff --git a/config/prod.exs b/config/prod.exs index bdda23e..81ee8d3 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -29,12 +29,5 @@ config :esbuild, # of environment variables, is done on config/runtime.exs. config :logger, level: :info -config :sentry, - dsn: "https://337ece4c07ff53c6719d900adfddd6e4@o4509627566063616.ingest.us.sentry.io/4509691336785920", - environment_name: Mix.env(), - enable_source_code_context: true, - root_source_code_paths: [File.cwd!()], - before_send: {Aprsme.SentryFilter, :before_send} - # Configures Swoosh API Client config :swoosh, :api_client, Swoosh.ApiClient.Req diff --git a/config/runtime.exs b/config/runtime.exs index 2bec382..d1e3549 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -175,8 +175,6 @@ if config_env() == :prod do "http://10.0.19.222:33897", "https://aprs.me", "https://www.aprs.me", - "https://js.sentry-cdn.com", - "https://sentry.io", "https://www.openstreetmap.org", "https://tile.openstreetmap.org", "https://static.cloudflareinsights.com" diff --git a/lib/aprsme/application.ex b/lib/aprsme/application.ex index 2d8812c..7eef90b 100644 --- a/lib/aprsme/application.ex +++ b/lib/aprsme/application.ex @@ -15,10 +15,6 @@ defmodule Aprsme.Application do # Run migrations on startup migrate() - :logger.add_handler(:my_sentry_handler, Sentry.LoggerHandler, %{ - config: %{metadata: [:file, :line]} - }) - children = [ # Start the Telemetry supervisor AprsmeWeb.Telemetry, diff --git a/lib/aprsme/sentry_filter.ex b/lib/aprsme/sentry_filter.ex deleted file mode 100644 index 8ae32fd..0000000 --- a/lib/aprsme/sentry_filter.ex +++ /dev/null @@ -1,101 +0,0 @@ -defmodule Aprsme.SentryFilter do - @moduledoc """ - Filters out certain errors from being sent to Sentry. - - This module helps reduce noise in Sentry by filtering out expected errors - like malformed HTTP requests that are missing required headers. - """ - - require Logger - - @doc """ - Callback function for Sentry's before_send hook. - - Returns nil to prevent the event from being sent to Sentry, - or returns the event to allow it to be sent. - """ - def before_send(event) do - if should_filter_event?(event) do - # Log locally but don't send to Sentry - Logger.debug("Filtered Sentry event: #{inspect_error(event)}") - nil - else - event - end - end - - # Check if the event should be filtered out - defp should_filter_event?(event) do - # Access the first exception from the list if it exists - first_exception = - case event.exception do - [first | _] -> first - _ -> nil - end - - error_type = if first_exception, do: first_exception.type - error_message = if first_exception, do: first_exception.value - - cond do - # Filter out Bandit errors for missing Host header - error_type == "Bandit.HTTPError" and - String.contains?(error_message || "", "No host header") -> - true - - # Filter out other common bot/scanner errors - error_type == "Bandit.HTTPError" and - String.contains?(error_message || "", "Unable to obtain host and port") -> - true - - # Filter out Phoenix.Router.NoRouteError for common bot paths - error_type == "Phoenix.Router.NoRouteError" and - is_bot_path?(event) -> - true - - # Allow all other errors through - true -> - false - end - end - - # Check if the request path looks like a bot/scanner - defp is_bot_path?(event) do - request_path = - case event.request do - %{url: url} when is_binary(url) -> url - _ -> "" - end - - bot_patterns = [ - ~r/\.php$/i, - ~r/\.asp$/i, - ~r/\.aspx$/i, - ~r/wp-admin/i, - ~r/wp-login/i, - ~r/wordpress/i, - ~r/admin/i, - ~r/\.env$/, - ~r/\.git/, - ~r/phpmyadmin/i, - ~r/mysql/i, - ~r/config\./i, - ~r/\.xml$/i, - ~r/sitemap/i, - ~r/robots\.txt$/i - ] - - Enum.any?(bot_patterns, &Regex.match?(&1, request_path)) - end - - # Extract a readable error description - defp inspect_error(event) do - # Access the first exception from the list if it exists - {error_type, error_message} = - case event.exception do - [%{type: type, value: value} | _] -> {type || "Unknown", value || "No message"} - _ -> {"Unknown", "No message"} - end - - "#{error_type}: #{error_message}" - end -end diff --git a/lib/aprsme_web/components/layouts/root.html.heex b/lib/aprsme_web/components/layouts/root.html.heex index c922418..b0b62a0 100644 --- a/lib/aprsme_web/components/layouts/root.html.heex +++ b/lib/aprsme_web/components/layouts/root.html.heex @@ -75,9 +75,6 @@ - {@inner_content} diff --git a/lib/aprsme_web/endpoint.ex b/lib/aprsme_web/endpoint.ex index a394415..f519251 100644 --- a/lib/aprsme_web/endpoint.ex +++ b/lib/aprsme_web/endpoint.ex @@ -1,7 +1,6 @@ defmodule AprsmeWeb.Endpoint do @moduledoc false use Phoenix.Endpoint, otp_app: :aprsme - use Sentry.PlugCapture # The session will be stored in the cookie and signed, # this means its contents can be read but not tampered with. @@ -48,7 +47,6 @@ defmodule AprsmeWeb.Endpoint do pass: ["*/*"], json_decoder: Phoenix.json_library() - plug Sentry.PlugContext plug Plug.MethodOverride plug Plug.Head plug Plug.Session, @session_options diff --git a/lib/aprsme_web/live/info_live/show.html.heex b/lib/aprsme_web/live/info_live/show.html.heex index 9c534e8..8abd466 100644 --- a/lib/aprsme_web/live/info_live/show.html.heex +++ b/lib/aprsme_web/live/info_live/show.html.heex @@ -1,16 +1,4 @@ - - - +
diff --git a/mix.exs b/mix.exs index 0a1f6e4..5de5d2d 100644 --- a/mix.exs +++ b/mix.exs @@ -105,10 +105,8 @@ defmodule Aprsme.MixProject do {:hammer, "~> 7.0"}, {:cachex, "~> 4.1"}, {:gettext_pseudolocalize, "~> 0.1"}, - {:sentry, "~> 11.0.4"}, {:wallaby, "~> 0.30.10", only: :test}, {:lazy_html, "~> 0.1.8", only: :test} - # Gleam dependencies ] end