Skip to content

Commit

Permalink
replace Sentry.capture_message with Logger.error where appropriate fo…
Browse files Browse the repository at this point in the history
…r CE
  • Loading branch information
ruslandoga committed Jan 21, 2025
1 parent f0104cb commit 4c14a9d
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 23 deletions.
5 changes: 2 additions & 3 deletions lib/plausible/cache/adapter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,8 @@ defmodule Plausible.Cache.Adapter do
{:ok, result}
catch
:exit, {:timeout, _} ->
Sentry.capture_message(
"Timeout while executing with lock on key in '#{inspect(cache_name)}'",
extra: %{key: key}
Logger.error("Timeout while executing with lock on key in '#{inspect(cache_name)}'",
sentry: %{extra: %{key: key}}
)

{:error, :timeout}
Expand Down
6 changes: 5 additions & 1 deletion lib/plausible/google/http.ex
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ defmodule Plausible.Google.HTTP do
{:error, error}

{:error, %{reason: _} = e} ->
Sentry.capture_message("Error fetching Google queries", extra: %{error: inspect(e)})
# TODO
Logger.error("Error fetching Google queries",
sentry: %{extra: %{error: inspect(e)}}
)

{:error, :unknown_error}
end
end
Expand Down
16 changes: 8 additions & 8 deletions lib/plausible/ingestion/counters.ex
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ defmodule Plausible.Ingestion.Counters do

try do
{_, _} = AsyncInsertRepo.insert_all(Record, records)
catch
_, thrown ->
Sentry.capture_message(
"Caught an error when trying to flush ingest counters.",
extra: %{
number_of_records: Enum.count(records),
error: inspect(thrown)
}
rescue
e ->
msg = Exception.format_error(e, __STACKTRACE__)

# TODO
Logger.error("Caught an error when trying to flush ingest counters:\n " <> msg,
crash_reason: {e, __STACKTRACE__},
extra: %{number_of_records: Enum.count(records)}
)
end
end
Expand Down
7 changes: 5 additions & 2 deletions lib/plausible/ingestion/event.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ defmodule Plausible.Ingestion.Event do
alias Plausible.ClickhouseEventV2
alias Plausible.Site.GateKeeper

require Logger

defstruct domain: nil,
site: nil,
clickhouse_event_attrs: %{},
Expand Down Expand Up @@ -467,8 +469,9 @@ defmodule Plausible.Ingestion.Event do
nil

%Device{type: type} ->
Sentry.capture_message("Could not determine device type from UAInspector",
extra: %{type: type}
# TODO
Logger.error("Could not determine device type from UAInspector",
sentry: %{extra: %{type: type}}
)

nil
Expand Down
1 change: 1 addition & 0 deletions lib/plausible/verification/diagnostics.ex
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ defmodule Plausible.Verification.Diagnostics do
end

def interpret(diagnostics, url) do
# TODO
Sentry.capture_message("Unhandled case for site verification",
extra: %{
message: inspect(diagnostics),
Expand Down
2 changes: 1 addition & 1 deletion lib/plausible_web/controllers/api/external_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ defmodule PlausibleWeb.Api.ExternalController do
end

def error(conn, _params) do
Sentry.capture_message("JS snippet error")
Logger.error("JS snippet error")
send_resp(conn, 200, "")
end

Expand Down
2 changes: 1 addition & 1 deletion lib/plausible_web/controllers/auth_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ defmodule PlausibleWeb.AuthController do
|> redirect(external: redirect_route)

_any ->
Sentry.capture_message("Google OAuth callback failed. Reason: #{inspect(params)}")
Logger.error("Google OAuth callback failed. Reason: #{inspect(params)}")

conn
|> put_flash(
Expand Down
5 changes: 3 additions & 2 deletions lib/plausible_web/live/sites.ex
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,9 @@ defmodule PlausibleWeb.Live.Sites do

{:noreply, socket}
else
Sentry.capture_message("Attempting to toggle pin for invalid domain.",
extra: %{domain: domain, user: socket.assigns.current_user.id}
# TODO
Logger.error("Attempting to toggle pin for invalid domain.",
sentry: %{extra: %{domain: domain, user: socket.assigns.current_user.id}}
)

{:noreply, socket}
Expand Down
1 change: 1 addition & 0 deletions lib/plausible_web/views/email_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ defmodule PlausibleWeb.EmailView do
Calendar.strftime(date, "%-d %b %Y")
end

# TODO dsn() :: nil | {String.t(), String.t(), String.t()}
def sentry_link(trace_id, dsn \\ Sentry.Config.dsn()) do
search_query = URI.encode_query(%{query: trace_id})
path = "/organizations/sentry/issues/"
Expand Down
12 changes: 7 additions & 5 deletions lib/workers/import_analytics.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ defmodule Plausible.Workers.ImportAnalytics do
:ok

{:error, error, error_opts} ->
Sentry.capture_message("Failed to import from #{site_import.source}",
extra: %{
import_id: site_import.id,
site: site_import.site.domain,
error: inspect(error)
Logger.error("Failed to import from #{site_import.source}",
sentry: %{
extra: %{
import_id: site_import.id,
site: site_import.site.domain,
error: inspect(error)
}
}
)

Expand Down

0 comments on commit 4c14a9d

Please sign in to comment.