Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update Sentry #4914

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,8 @@ config :sentry,
},
client: Plausible.Sentry.Client,
send_max_attempts: 1,
before_send: {Plausible.SentryFilter, :before_send}
before_send: {Plausible.SentryFilter, :before_send},
send_client_reports: false

config :plausible, :paddle,
vendor_auth_code: paddle_auth_code,
Expand Down
2 changes: 1 addition & 1 deletion extra/lib/plausible/help_scout.ex
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ defmodule Plausible.HelpScout do

error ->
Sentry.capture_message("Failed to obtain customer data from HelpScout API",
extra: %{error: inspect(error), customer_id: customer_id}
extra: %{error: error, customer_id: customer_id}
)

{:error, :unknown}
Expand Down
2 changes: 1 addition & 1 deletion lib/plausible/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ defmodule Plausible.Application do

defp maybe_add_sentry_pool(pool_config, default) do
case Sentry.Config.dsn() do
{"http" <> _rest = url, _, _} ->
%Sentry.DSN{endpoint_uri: "http" <> _rest = url} ->
Map.put(pool_config, url, Config.Reader.merge(default, size: 50))

nil ->
Expand Down
2 changes: 1 addition & 1 deletion lib/plausible/billing/billing.ex
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ defmodule Plausible.Billing do

if subscription.id != team.subscription.id do
Sentry.capture_message("Susbscription ID mismatch",
extra: %{subscription: inspect(subscription), team_id: team.id}
extra: %{subscription: subscription, team_id: team.id}
)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/plausible/billing/paddle_api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ defmodule Plausible.Billing.PaddleApi do
else
error ->
Sentry.capture_message("Failed to retrieve invoices from Paddle",
extra: %{extra: inspect(error), params: params, invoices_url: invoices_url()}
extra: %{extra: error, params: params, invoices_url: invoices_url()}
)

{:error, :request_failed}
Expand Down
2 changes: 1 addition & 1 deletion lib/plausible/google/ga4/http.ex
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ defmodule Plausible.Google.GA4.HTTP do
"[#{inspect(__MODULE__)}:#{report_request.property}] Request failed for #{report_request.dataset}: #{inspect(reason)}"
)

Sentry.Context.set_extra_context(%{ga_response: %{body: inspect(reason), status: 0}})
Sentry.Context.set_extra_context(%{ga_response: %{body: reason, status: 0}})

{:error, {:socket_failed, dataset: report_request.dataset, offset: report_request.offset}}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/plausible/google/http.ex
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ defmodule Plausible.Google.HTTP do
{:error, error}

{:error, %{reason: _} = e} ->
Sentry.capture_message("Error fetching Google queries", extra: %{error: inspect(e)})
Sentry.capture_message("Error fetching Google queries", extra: %{error: e})
{:error, :unknown_error}
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/plausible/ingestion/counters.ex
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ defmodule Plausible.Ingestion.Counters do
"Caught an error when trying to flush ingest counters.",
extra: %{
number_of_records: Enum.count(records),
error: inspect(thrown)
error: thrown
}
)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/plausible/timezones.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ defmodule Plausible.Timezones do

error ->
Sentry.capture_message("Failed to fetch timezone",
extra: %{code: timezone_code, error: inspect(error)}
extra: %{code: timezone_code, error: error}
)

acc
Expand Down
2 changes: 1 addition & 1 deletion lib/plausible/verification/diagnostics.ex
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ defmodule Plausible.Verification.Diagnostics do
def interpret(diagnostics, url) do
Sentry.capture_message("Unhandled case for site verification",
extra: %{
message: inspect(diagnostics),
message: diagnostics,
url: url,
hash: :erlang.phash2(diagnostics)
}
Expand Down
1 change: 1 addition & 0 deletions lib/plausible_web.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ defmodule PlausibleWeb do
use PlausibleWeb.Live.AuthContext

unless :no_sentry_context in unquote(opts) do
# TODO: on_mount Sentry.LiveViewHook?
use PlausibleWeb.Live.SentryContext
end

Expand Down
2 changes: 1 addition & 1 deletion lib/plausible_web/controllers/api/paddle_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ defmodule PlausibleWeb.Api.PaddleController do

error ->
Sentry.capture_message("Failed to fetch currency reference plan",
extra: %{error: inspect(error)}
extra: %{error: error}
)

{:error, :fetch_prices_failed}
Expand Down
2 changes: 1 addition & 1 deletion lib/plausible_web/controllers/billing_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ defmodule PlausibleWeb.BillingController do

Sentry.capture_message("Error changing plans",
extra: %{
errors: inspect(e),
errors: e,
message: msg,
new_plan_id: new_plan_id,
team_id: my_team.id,
Expand Down
1 change: 1 addition & 0 deletions lib/plausible_web/live/sentry_context.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ defmodule PlausibleWeb.Live.SentryContext do

defmacro __using__(_) do
quote do
# TODO on_mount Sentry.LiveViewHook?
on_mount PlausibleWeb.Live.SentryContext
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/plausible_web/views/email_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defmodule PlausibleWeb.EmailView do
Calendar.strftime(date, "%-d %b %Y")
end

def sentry_link(trace_id, dsn \\ Sentry.Config.dsn()) do
def sentry_link(trace_id, dsn \\ Sentry.get_dsn()) do
Copy link
Contributor Author

@ruslandoga ruslandoga Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was Sentry.Config.dsn() ever a binary? I remember it being an opaque tuple and now it's a struct ...

Really confusing API.

search_query = URI.encode_query(%{query: trace_id})
path = "/organizations/sentry/issues/"

Expand Down
11 changes: 0 additions & 11 deletions lib/sentry_filter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@ defmodule Plausible.SentryFilter do
def before_send(%{original_exception: %Plug.CSRFProtection.InvalidCSRFTokenError{}}), do: false
def before_send(%{original_exception: %Plug.Static.InvalidPathError{}}), do: false

def before_send(
%{exception: [%{type: "Clickhousex.Error"}], original_exception: %{code: code}} = event
Copy link
Contributor Author

@ruslandoga ruslandoga Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clickhousex is gone.

)
when is_atom(code) do
%{event | fingerprint: ["clickhouse", "db_connection", to_string(code)]}
end

def before_send(%{event_source: :logger, message: "Clickhousex.Protocol " <> _} = event) do
%{event | fingerprint: ["clickhouse", "db_connection", "protocol_error"]}
end

def before_send(
%{
exception: [%{type: "DBConnection.ConnectionError"}],
Expand Down
2 changes: 1 addition & 1 deletion lib/workers/import_analytics.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ defmodule Plausible.Workers.ImportAnalytics do
extra: %{
import_id: site_import.id,
site: site_import.site.domain,
error: inspect(error)
error: error
}
)

Expand Down
6 changes: 3 additions & 3 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"credo": {:hex, :credo, "1.7.7", "771445037228f763f9b2afd612b6aa2fd8e28432a95dbbc60d8e03ce71ba4446", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "8bc87496c9aaacdc3f90f01b7b0582467b69b4bd2441fe8aae3109d843cc2f2e"},
"ctx": {:hex, :ctx, "0.6.0", "8ff88b70e6400c4df90142e7f130625b82086077a45364a78d208ed3ed53c7fe", [:rebar3], [], "hexpm", "a14ed2d1b67723dbebbe423b28d7615eb0bdcba6ff28f2d1f1b0a7e1d4aa5fc2"},
"db_connection": {:hex, :db_connection, "2.7.0", "b99faa9291bb09892c7da373bb82cba59aefa9b36300f6145c5f201c7adf48ec", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "dcf08f31b2701f857dfc787fbad78223d61a32204f217f15e881dd93e4bdd3ff"},
"decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"},
"decimal": {:hex, :decimal, "2.3.0", "3ad6255aa77b4a3c4f818171b12d237500e63525c2fd056699967a3e7ea20f62", [:mix], [], "hexpm", "a4d66355cb29cb47c3cf30e71329e58361cfcb37c34235ef3bf1d7bf3773aeac"},
"dialyxir": {:hex, :dialyxir, "1.4.3", "edd0124f358f0b9e95bfe53a9fcf806d615d8f838e2202a9f430d59566b6b53b", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "bf2cfb75cd5c5006bec30141b131663299c661a864ec7fbbc72dfa557487a986"},
"digital_token": {:hex, :digital_token, "0.6.0", "13e6de581f0b1f6c686f7c7d12ab11a84a7b22fa79adeb4b50eec1a2d278d258", [:mix], [{:cldr_utils, "~> 2.17", [hex: :cldr_utils, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "2455d626e7c61a128b02a4a8caddb092548c3eb613ac6f6a85e4cbb6caddc4d1"},
"double": {:hex, :double, "0.8.2", "8e1cfcccdaef76c18846bc08e555555a2a699b806fa207b6468572a60513cc6a", [:mix], [], "hexpm", "90287642b2ec86125e0457aaba2ab0e80f7d7050cc80a0cef733e59bd70aa67c"},
Expand Down Expand Up @@ -90,7 +90,7 @@
"nanoid": {:hex, :nanoid, "2.1.0", "d192a5bf1d774258bc49762b480fca0e3128178fa6d35a464af2a738526607fd", [:mix], [], "hexpm", "ebc7a342d02d213534a7f93a091d569b9fea7f26fcd3a638dc655060fc1f76ac"},
"nimble_csv": {:hex, :nimble_csv, "1.2.0", "4e26385d260c61eba9d4412c71cea34421f296d5353f914afe3f2e71cce97722", [:mix], [], "hexpm", "d0628117fcc2148178b034044c55359b26966c6eaa8e2ce15777be3bbc91b12a"},
"nimble_options": {:hex, :nimble_options, "1.1.1", "e3a492d54d85fc3fd7c5baf411d9d2852922f66e69476317787a7b2bb000a61b", [:mix], [], "hexpm", "821b2470ca9442c4b6984882fe9bb0389371b8ddec4d45a9504f00a66f650b44"},
"nimble_ownership": {:hex, :nimble_ownership, "0.3.1", "99d5244672fafdfac89bfad3d3ab8f0d367603ce1dc4855f86a1c75008bce56f", [:mix], [], "hexpm", "4bf510adedff0449a1d6e200e43e57a814794c8b5b6439071274d248d272a549"},
"nimble_ownership": {:hex, :nimble_ownership, "1.0.1", "f69fae0cdd451b1614364013544e66e4f5d25f36a2056a9698b793305c5aa3a6", [:mix], [], "hexpm", "3825e461025464f519f3f3e4a1f9b68c47dc151369611629ad08b636b73bb22d"},
"nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"},
"nimble_pool": {:hex, :nimble_pool, "1.1.0", "bf9c29fbdcba3564a8b800d1eeb5a3c58f36e1e11d7b7fb2e084a643f645f06b", [:mix], [], "hexpm", "af2e4e6b34197db81f7aad230c1118eac993acc0dae6bc83bac0126d4ae0813a"},
"nimble_totp": {:hex, :nimble_totp, "1.0.0", "79753bae6ce59fd7cacdb21501a1dbac249e53a51c4cd22b34fa8438ee067283", [:mix], [], "hexpm", "6ce5e4c068feecdb782e85b18237f86f66541523e6bad123e02ee1adbe48eda9"},
Expand Down Expand Up @@ -135,7 +135,7 @@
"rustler_precompiled": {:hex, :rustler_precompiled, "0.7.3", "42cb9449785cd86c87453e39afdd27a0bdfa5c77a4ec5dc5ce45112e06b9f89b", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:rustler, "~> 0.23", [hex: :rustler, repo: "hexpm", optional: true]}], "hexpm", "cbc4b3777682e5f6f43ed39b0e0b4a42dccde8053aba91b4514e8f5ff9a5ac6d"},
"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"},
"sentry": {:hex, :sentry, "10.2.0", "046ca9fabfca3568b35ddb638d02c427e47380b2390416c4b26fee9c4ce56450", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: true]}, {:nimble_options, "~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_ownership, "~> 0.3.0", [hex: :nimble_ownership, repo: "hexpm", optional: false]}, {:plug, "~> 1.6", [hex: :plug, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "4786fa2a08c2ddf48bfd79c54787a8e5b2f321368d781052fd20327318da8188"},
"sentry": {:hex, :sentry, "10.8.1", "aa45309785e1521416225adb16e0b4d8b957578804527f3c7babb6fefbc5e456", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: true]}, {:nimble_options, "~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_ownership, "~> 0.3.0 or ~> 1.0", [hex: :nimble_ownership, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.6", [hex: :phoenix, repo: "hexpm", optional: true]}, {:phoenix_live_view, "~> 0.20 or ~> 1.0", [hex: :phoenix_live_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.6", [hex: :plug, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "495b3cdadad90ba72eef973aa3dec39b3b8b2a362fe87e2f4ef32133ac3b4097"},
"siphash": {:hex, :siphash, "3.2.0", "ec03fd4066259218c85e2a4b8eec4bb9663bc02b127ea8a0836db376ba73f2ed", [:make, :mix], [], "hexpm", "ba3810701c6e95637a745e186e8a4899087c3b079ba88fb8f33df054c3b0b7c3"},
"site_encrypt": {:git, "https://github.com/sasa1977/site_encrypt.git", "046fbeca11b889604dafd2df6a71001f8abe5e2c", []},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"},
Expand Down
Loading