Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Update Sentry (#3843)
ruslandoga07b714a14354
diff --git a/Dockerfile b/Dockerfileindex 1411c7b44e..5915fe3cc4 100644--- a/Dockerfile+++ b/Dockerfile@@ -47,8 +47,7 @@ RUN npm run deploy --prefix ./tracker && \mix assets.deploy && \mix phx.digest priv/static && \mix download_country_database && \- # https://hexdocs.pm/sentry/Sentry.Sources.html#module-source-code-storage- mix sentry_recompile+ mix sentry.package_source_codeWORKDIR /appCOPY rel reldiff --git a/config/config.exs b/config/config.exsindex f7f2f32d80..531b243856 100644--- a/config/config.exs+++ b/config/config.exs@@ -73,4 +73,8 @@ config :ex_cldr,default_locale: "en",default_backend: Plausible.Cldr+config :sentry,+ enable_source_code_context: true,+ root_source_code_path: [File.cwd!()]+import_config "#{config_env()}.exs"diff --git a/config/runtime.exs b/config/runtime.exsindex 2d283b241c..cd1fbbb75a 100644--- a/config/runtime.exs+++ b/config/runtime.exs@@ -335,21 +335,16 @@ elsedatabase: get_var_from_path_or_env(config_dir, "DATABASE_NAME", "plausible")end-included_environments = if sentry_dsn, do: ["prod", "staging", "dev"], else: []sentry_app_version = runtime_metadata[:version] || app_versionconfig :sentry,dsn: sentry_dsn,environment_name: env,- included_environments: included_environments,release: sentry_app_version,tags: %{app_version: sentry_app_version},- enable_source_code_context: true,- root_source_code_path: [File.cwd!()],client: Plausible.Sentry.Client,send_max_attempts: 1,- filter: Plausible.SentryFilter,- before_send_event: {Plausible.SentryFilter, :before_send}+ before_send: {Plausible.SentryFilter, :before_send}config :plausible, :paddle,vendor_auth_code: paddle_auth_code,diff --git a/lib/plausible/application.ex b/lib/plausible/application.exindex bdc0aa9bc2..3f8117f42b 100644--- a/lib/plausible/application.ex+++ b/lib/plausible/application.ex@@ -122,10 +122,10 @@ defmodule Plausible.Application dodefp maybe_add_sentry_pool(pool_config) docase Sentry.Config.dsn() do- dsn when is_binary(dsn) ->- Map.put(pool_config, dsn, size: 50)+ {"http" <> _rest = url, _, _} ->+ Map.put(pool_config, url, size: 50)- _ ->+ nil ->pool_configendenddiff --git a/lib/plausible/sentry/client.ex b/lib/plausible/sentry/client.exindex ec7885a55e..7cbf28839a 100644--- a/lib/plausible/sentry/client.ex+++ b/lib/plausible/sentry/client.ex@@ -5,17 +5,6 @@ defmodule Plausible.Sentry.Client dorequire Logger- @doc """- The Sentry.HTTPClient behaviour requires a child spec to be supplied.- In this case we don't want Sentry to manage our Finch instances, hence it's fed- with a dummy module for the sake of the contract.-- XXX: Submit a Sentry PR making the child spec callback optional.- """- def child_spec do- Task.child_spec(fn -> :noop end)- end-def post(url, headers, body) doreq_opts = Application.get_env(:plausible, __MODULE__)[:finch_request_opts] || []diff --git a/lib/plausible_web/live/sentry_context.ex b/lib/plausible_web/live/sentry_context.exindex e58fb450f2..c3730662cf 100644--- a/lib/plausible_web/live/sentry_context.ex+++ b/lib/plausible_web/live/sentry_context.ex@@ -26,15 +26,9 @@ defmodule PlausibleWeb.Live.SentryContext douser_agent =Phoenix.LiveView.get_connect_info(socket, :user_agent)- socket_host =- case socket.host_uri do- :not_mounted_at_router -> :not_mounted_at_router- %URI{host: host} -> host- end-request_context =%{- host: socket_host,+ url: socket.host_uri,env: %{"REMOTE_ADDR" => get_ip(peer),"REMOTE_PORT" => peer && peer.port,diff --git a/lib/sentry_filter.ex b/lib/sentry_filter.exindex 68fe4a2ddd..9b71cbc06d 100644--- a/lib/sentry_filter.ex+++ b/lib/sentry_filter.ex@@ -2,20 +2,14 @@ defmodule Plausible.SentryFilter do@moduledoc """Sentry callbacks for filtering and grouping events"""- @behaviour Sentry.EventFilter-- def exclude_exception?(%Sentry.CrashError{}, _source), do: true- def exclude_exception?(%Phoenix.NotAcceptableError{}, _), do: true- def exclude_exception?(%Plug.CSRFProtection.InvalidCSRFTokenError{}, _), do: true- def exclude_exception?(%Plug.Static.InvalidPathError{}, _), do: true-- def exclude_exception?(exception, source) do- Sentry.DefaultEventFilter.exclude_exception?(exception, source)- end@spec before_send(Sentry.Event.t()) :: Sentry.Event.t()def before_send(event)+ def before_send(%{original_exception: %Phoenix.NotAcceptableError{}}), do: false+ 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)diff --git a/mix.exs b/mix.exsindex 5d3e1fee20..1700af5da9 100644--- a/mix.exs+++ b/mix.exs@@ -118,7 +118,7 @@ defmodule Plausible.MixProject do{:public_suffix, git: "https://github.com/axelson/publicsuffix-elixir"},{:ref_inspector, "~> 2.0"},{:referrer_blocklist, git: "https://github.com/plausible/referrer-blocklist.git"},- {:sentry, "~> 8.0"},+ {:sentry, "~> 10.0"},{:siphash, "~> 3.2"},{:timex, "~> 3.7"},{:ua_inspector, "~> 3.0"},@@ -151,7 +151,6 @@ defmodule Plausible.MixProject do"ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],"ecto.reset": ["ecto.drop", "ecto.setup"],test: ["ecto.create --quiet", "ecto.migrate", "test", "clean_clickhouse"],- sentry_recompile: ["compile", "deps.compile sentry --force"],"assets.setup": ["tailwind.install --if-missing", "esbuild.install --if-missing"],"assets.build": ["tailwind default",diff --git a/mix.lock b/mix.lockindex 3418a8c695..cb25e31616 100644--- a/mix.lock+++ b/mix.lock@@ -89,7 +89,8 @@"mua": {:hex, :mua, "0.1.5", "e0dd3a47ab96c2ffebde031c802368e0fee5eb1b992e728a7cd99ca1df71c200", [:mix], [{:castore, "~> 0.1.0 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}], "hexpm", "576ca89e03e176bdb0fd4f2501feca3fbb746b701230c0f40a7251b79dbb6b36"},"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.0.2", "92098a74df0072ff37d0c12ace58574d26880e522c22801437151a159392270e", [:mix], [], "hexpm", "fd12a8db2021036ce12a309f26f564ec367373265b53e25403f0ee697380f1b8"},+ "nimble_options": {:hex, :nimble_options, "1.1.0", "3b31a57ede9cb1502071fade751ab0c7b8dbe75a9a4c2b5bbb0943a690b63172", [:mix], [], "hexpm", "8bbbb3941af3ca9acc7835f5655ea062111c9c27bcac53e004460dfd19008a99"},+ "nimble_ownership": {:hex, :nimble_ownership, "0.3.1", "99d5244672fafdfac89bfad3d3ab8f0d367603ce1dc4855f86a1c75008bce56f", [:mix], [], "hexpm", "4bf510adedff0449a1d6e200e43e57a814794c8b5b6439071274d248d272a549"},"nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"},"nimble_pool": {:hex, :nimble_pool, "1.0.0", "5eb82705d138f4dd4423f69ceb19ac667b3b492ae570c9f5c900bb3d2f50a847", [:mix], [], "hexpm", "80be3b882d2d351882256087078e1b1952a28bf98d0a287be87e4a24a710b67a"},"nimble_totp": {:hex, :nimble_totp, "1.0.0", "79753bae6ce59fd7cacdb21501a1dbac249e53a51c4cd22b34fa8438ee067283", [:mix], [], "hexpm", "6ce5e4c068feecdb782e85b18237f86f66541523e6bad123e02ee1adbe48eda9"},@@ -119,7 +120,7 @@"phoenix_view": {:hex, :phoenix_view, "2.0.3", "4d32c4817fce933693741deeb99ef1392619f942633dde834a5163124813aad3", [:mix], [{:phoenix_html, "~> 2.14.2 or ~> 3.0 or ~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}], "hexpm", "cd34049af41be2c627df99cd4eaa71fc52a328c0c3d8e7d4aa28f880c30e7f64"},"php_serializer": {:hex, :php_serializer, "2.0.0", "b43f31aca22ed7321f32da2b94fe2ddf9b6739a965cb51541969119e572e821d", [:mix], [], "hexpm", "61e402e99d9062c0225a3f4fcf7e43b4cba1b8654944c0e7c139c3ca9de481da"},"plug": {:hex, :plug, "1.15.3", "712976f504418f6dff0a3e554c40d705a9bcf89a7ccef92fc6a5ef8f16a30a97", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "cc4365a3c010a56af402e0809208873d113e9c38c401cabd88027ef4f5c01fd2"},- "plug_cowboy": {:hex, :plug_cowboy, "2.6.1", "9a3bbfceeb65eff5f39dab529e5cd79137ac36e913c02067dba3963a26efe9b2", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "de36e1a21f451a18b790f37765db198075c25875c64834bcc82d90b309eb6613"},+ "plug_cowboy": {:hex, :plug_cowboy, "2.7.0", "3ae9369c60641084363b08fe90267cbdd316df57e3557ea522114b30b63256ea", [:mix], [{:cowboy, "~> 2.7.0 or ~> 2.8.0 or ~> 2.9.0 or ~> 2.10.0", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "d85444fb8aa1f2fc62eabe83bbe387d81510d773886774ebdcb429b3da3c1a4a"},"plug_crypto": {:hex, :plug_crypto, "1.2.5", "918772575e48e81e455818229bf719d4ab4181fcbf7f85b68a35620f78d89ced", [:mix], [], "hexpm", "26549a1d6345e2172eb1c233866756ae44a9609bd33ee6f99147ab3fd87fd842"},"postgrex": {:hex, :postgrex, "0.17.4", "5777781f80f53b7c431a001c8dad83ee167bcebcf3a793e3906efff680ab62b3", [:mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "6458f7d5b70652bc81c3ea759f91736c16a31be000f306d3c64bcdfe9a18b3cc"},"prom_ex": {:hex, :prom_ex, "1.9.0", "63e6dda6c05cdeec1f26c48443dcc38ffd2118b3665ae8d2bd0e5b79f2aea03e", [:mix], [{:absinthe, ">= 1.6.0", [hex: :absinthe, repo: "hexpm", optional: true]}, {:broadway, ">= 1.0.2", [hex: :broadway, repo: "hexpm", optional: true]}, {:ecto, ">= 3.5.0", [hex: :ecto, repo: "hexpm", optional: true]}, {:finch, "~> 0.15", [hex: :finch, repo: "hexpm", optional: false]}, {:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: false]}, {:oban, ">= 2.4.0", [hex: :oban, repo: "hexpm", optional: true]}, {:octo_fetch, "~> 0.3", [hex: :octo_fetch, repo: "hexpm", optional: false]}, {:phoenix, ">= 1.5.0", [hex: :phoenix, repo: "hexpm", optional: true]}, {:phoenix_live_view, ">= 0.14.0", [hex: :phoenix_live_view, repo: "hexpm", optional: true]}, {:plug, ">= 1.12.1", [hex: :plug, repo: "hexpm", optional: true]}, {:plug_cowboy, "~> 2.5", [hex: :plug_cowboy, repo: "hexpm", optional: false]}, {:telemetry, ">= 1.0.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:telemetry_metrics, "~> 0.6", [hex: :telemetry_metrics, repo: "hexpm", optional: false]}, {:telemetry_metrics_prometheus_core, "~> 1.0", [hex: :telemetry_metrics_prometheus_core, repo: "hexpm", optional: false]}, {:telemetry_poller, "~> 1.0", [hex: :telemetry_poller, repo: "hexpm", optional: false]}], "hexpm", "01f3d4f69ec93068219e686cc65e58a29c42bea5429a8ff4e2121f19db178ee6"},@@ -131,7 +132,7 @@"rustler_precompiled": {:hex, :rustler_precompiled, "0.6.2", "d2218ba08a43fa331957f30481d00b666664d7e3861431b02bd3f4f30eec8e5b", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:rustler, "~> 0.23", [hex: :rustler, repo: "hexpm", optional: true]}], "hexpm", "b9048eaed8d7d14a53f758c91865cc616608a438d2595f621f6a4b32a5511709"},"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, "8.1.0", "8d235b62fce5f8e067ea1644e30939405b71a5e1599d9529ff82899d11d03f2b", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: true]}, {:plug, "~> 1.6", [hex: :plug, repo: "hexpm", optional: true]}, {:plug_cowboy, "~> 2.3", [hex: :plug_cowboy, repo: "hexpm", optional: true]}], "hexpm", "f9fc7641ef61e885510f5e5963c2948b9de1de597c63f781e9d3d6c9c8681ab4"},+ "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"},"siphash": {:hex, :siphash, "3.2.0", "ec03fd4066259218c85e2a4b8eec4bb9663bc02b127ea8a0836db376ba73f2ed", [:make, :mix], [], "hexpm", "ba3810701c6e95637a745e186e8a4899087c3b079ba88fb8f33df054c3b0b7c3"},"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"},"sweet_xml": {:hex, :sweet_xml, "0.7.4", "a8b7e1ce7ecd775c7e8a65d501bc2cd933bff3a9c41ab763f5105688ef485d08", [:mix], [], "hexpm", "e7c4b0bdbf460c928234951def54fe87edf1a170f6896675443279e2dbeba167"},diff --git a/test/plausible_web/live/sentry_context_test.exs b/test/plausible_web/live/sentry_context_test.exsindex feb0446bba..6ab47718c8 100644--- a/test/plausible_web/live/sentry_context_test.exs+++ b/test/plausible_web/live/sentry_context_test.exs@@ -36,7 +36,7 @@ defmodule PlausibleWeb.Live.SentryContextTest do"REMOTE_PORT" => port,"SEVER_NAME" => "www.example.com"},- host: :not_mounted_at_router+ url: :not_mounted_at_router},user: %{},tags: %{},