Skip to content

Commit 4c14a9d

Browse files
committed
replace Sentry.capture_message with Logger.error where appropriate for CE
1 parent f0104cb commit 4c14a9d

File tree

10 files changed

+34
-23
lines changed

10 files changed

+34
-23
lines changed

lib/plausible/cache/adapter.ex

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,8 @@ defmodule Plausible.Cache.Adapter do
120120
{:ok, result}
121121
catch
122122
:exit, {:timeout, _} ->
123-
Sentry.capture_message(
124-
"Timeout while executing with lock on key in '#{inspect(cache_name)}'",
125-
extra: %{key: key}
123+
Logger.error("Timeout while executing with lock on key in '#{inspect(cache_name)}'",
124+
sentry: %{extra: %{key: key}}
126125
)
127126

128127
{:error, :timeout}

lib/plausible/google/http.ex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ defmodule Plausible.Google.HTTP do
9393
{:error, error}
9494

9595
{:error, %{reason: _} = e} ->
96-
Sentry.capture_message("Error fetching Google queries", extra: %{error: inspect(e)})
96+
# TODO
97+
Logger.error("Error fetching Google queries",
98+
sentry: %{extra: %{error: inspect(e)}}
99+
)
100+
97101
{:error, :unknown_error}
98102
end
99103
end

lib/plausible/ingestion/counters.ex

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ defmodule Plausible.Ingestion.Counters do
8282

8383
try do
8484
{_, _} = AsyncInsertRepo.insert_all(Record, records)
85-
catch
86-
_, thrown ->
87-
Sentry.capture_message(
88-
"Caught an error when trying to flush ingest counters.",
89-
extra: %{
90-
number_of_records: Enum.count(records),
91-
error: inspect(thrown)
92-
}
85+
rescue
86+
e ->
87+
msg = Exception.format_error(e, __STACKTRACE__)
88+
89+
# TODO
90+
Logger.error("Caught an error when trying to flush ingest counters:\n " <> msg,
91+
crash_reason: {e, __STACKTRACE__},
92+
extra: %{number_of_records: Enum.count(records)}
9393
)
9494
end
9595
end

lib/plausible/ingestion/event.ex

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ defmodule Plausible.Ingestion.Event do
1010
alias Plausible.ClickhouseEventV2
1111
alias Plausible.Site.GateKeeper
1212

13+
require Logger
14+
1315
defstruct domain: nil,
1416
site: nil,
1517
clickhouse_event_attrs: %{},
@@ -467,8 +469,9 @@ defmodule Plausible.Ingestion.Event do
467469
nil
468470

469471
%Device{type: type} ->
470-
Sentry.capture_message("Could not determine device type from UAInspector",
471-
extra: %{type: type}
472+
# TODO
473+
Logger.error("Could not determine device type from UAInspector",
474+
sentry: %{extra: %{type: type}}
472475
)
473476

474477
nil

lib/plausible/verification/diagnostics.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ defmodule Plausible.Verification.Diagnostics do
363363
end
364364

365365
def interpret(diagnostics, url) do
366+
# TODO
366367
Sentry.capture_message("Unhandled case for site verification",
367368
extra: %{
368369
message: inspect(diagnostics),

lib/plausible_web/controllers/api/external_controller.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ defmodule PlausibleWeb.Api.ExternalController do
4343
end
4444

4545
def error(conn, _params) do
46-
Sentry.capture_message("JS snippet error")
46+
Logger.error("JS snippet error")
4747
send_resp(conn, 200, "")
4848
end
4949

lib/plausible_web/controllers/auth_controller.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ defmodule PlausibleWeb.AuthController do
476476
|> redirect(external: redirect_route)
477477

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

481481
conn
482482
|> put_flash(

lib/plausible_web/live/sites.ex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,9 @@ defmodule PlausibleWeb.Live.Sites do
614614

615615
{:noreply, socket}
616616
else
617-
Sentry.capture_message("Attempting to toggle pin for invalid domain.",
618-
extra: %{domain: domain, user: socket.assigns.current_user.id}
617+
# TODO
618+
Logger.error("Attempting to toggle pin for invalid domain.",
619+
sentry: %{extra: %{domain: domain, user: socket.assigns.current_user.id}}
619620
)
620621

621622
{:noreply, socket}

lib/plausible_web/views/email_view.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ defmodule PlausibleWeb.EmailView do
1616
Calendar.strftime(date, "%-d %b %Y")
1717
end
1818

19+
# TODO dsn() :: nil | {String.t(), String.t(), String.t()}
1920
def sentry_link(trace_id, dsn \\ Sentry.Config.dsn()) do
2021
search_query = URI.encode_query(%{query: trace_id})
2122
path = "/organizations/sentry/issues/"

lib/workers/import_analytics.ex

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ defmodule Plausible.Workers.ImportAnalytics do
3333
:ok
3434

3535
{:error, error, error_opts} ->
36-
Sentry.capture_message("Failed to import from #{site_import.source}",
37-
extra: %{
38-
import_id: site_import.id,
39-
site: site_import.site.domain,
40-
error: inspect(error)
36+
Logger.error("Failed to import from #{site_import.source}",
37+
sentry: %{
38+
extra: %{
39+
import_id: site_import.id,
40+
site: site_import.site.domain,
41+
error: inspect(error)
42+
}
4143
}
4244
)
4345

0 commit comments

Comments
 (0)