Skip to content

Commit 5b226cd

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

File tree

10 files changed

+44
-33
lines changed

10 files changed

+44
-33
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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ 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+
Logger.error("Error fetching Google queries",
97+
sentry: %{extra: %{error: inspect(e)}}
98+
)
99+
97100
{:error, :unknown_error}
98101
end
99102
end

lib/plausible/ingestion/counters.ex

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,13 @@ defmodule Plausible.Ingestion.Counters do
8484
{_, _} = AsyncInsertRepo.insert_all(Record, records)
8585
catch
8686
_, thrown ->
87-
Sentry.capture_message(
87+
Logger.error(
8888
"Caught an error when trying to flush ingest counters.",
89-
extra: %{
90-
number_of_records: Enum.count(records),
91-
error: inspect(thrown)
89+
sentry: %{
90+
extra: %{
91+
number_of_records: Enum.count(records),
92+
error: inspect(thrown)
93+
}
9294
}
9395
)
9496
end

lib/plausible/ingestion/event.ex

Lines changed: 4 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,8 @@ 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+
Logger.error("Could not determine device type from UAInspector",
473+
sentry: %{extra: %{type: type}}
472474
)
473475

474476
nil

lib/plausible/verification/diagnostics.ex

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,11 +363,13 @@ defmodule Plausible.Verification.Diagnostics do
363363
end
364364

365365
def interpret(diagnostics, url) do
366-
Sentry.capture_message("Unhandled case for site verification",
367-
extra: %{
368-
message: inspect(diagnostics),
369-
url: url,
370-
hash: :erlang.phash2(diagnostics)
366+
Logger.error("Unhandled case for site verification",
367+
sentry: %{
368+
extra: %{
369+
message: inspect(diagnostics),
370+
url: url,
371+
hash: :erlang.phash2(diagnostics)
372+
}
371373
}
372374
)
373375

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
@@ -5,6 +5,7 @@ defmodule PlausibleWeb.Live.Sites do
55

66
use PlausibleWeb, :live_view
77
import PlausibleWeb.Live.Components.Pagination
8+
require Logger
89

910
alias Plausible.Sites
1011

@@ -614,8 +615,8 @@ defmodule PlausibleWeb.Live.Sites do
614615

615616
{:noreply, socket}
616617
else
617-
Sentry.capture_message("Attempting to toggle pin for invalid domain.",
618-
extra: %{domain: domain, user: socket.assigns.current_user.id}
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: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ defmodule PlausibleWeb.EmailView do
2020
search_query = URI.encode_query(%{query: trace_id})
2121
path = "/organizations/sentry/issues/"
2222

23-
if is_binary(dsn) do
24-
dsn
25-
|> URI.parse()
26-
|> Map.replace(:userinfo, nil)
27-
|> Map.replace(:path, path)
28-
|> Map.replace(:query, search_query)
29-
|> URI.to_string()
30-
else
31-
""
23+
case dsn do
24+
{endpoint_uri, _public_key, _secret_key} when is_binary(endpoint_uri) ->
25+
URI.parse(endpoint_uri)
26+
|> Map.replace(:path, path)
27+
|> Map.replace(:query, search_query)
28+
|> URI.to_string()
29+
30+
_ ->
31+
""
3232
end
3333
end
3434
end

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)