Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Better Sentry tracking

Uku Taht7982c236c191
diff --git a/Dockerfile b/Dockerfile
index eba9f48597..09a26ce7a4 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -41,7 +41,9 @@ COPY lib ./lib
RUN npm run deploy --prefix ./assets && \
npm run deploy --prefix ./tracker && \
mix phx.digest priv/static && \
- mix download_country_database
+ mix download_country_database && \
+# https://hexdocs.pm/sentry/Sentry.Sources.html#module-source-code-storage
+ mix sentry_recompile
WORKDIR /app
COPY rel rel
diff --git a/config/runtime.exs b/config/runtime.exs
index c9bbb52dac..62b92f4717 100644
--- a/config/runtime.exs
+++ b/config/runtime.exs
@@ -112,7 +112,9 @@ config :sentry,
environment_name: env,
included_environments: ["prod", "staging"],
release: app_version,
- tags: %{app_version: app_version}
+ tags: %{app_version: app_version},
+ enable_source_code_context: true,
+ root_source_code_path: [File.cwd!()]
config :plausible, :paddle, vendor_auth_code: paddle_auth_code
diff --git a/lib/plausible/application.ex b/lib/plausible/application.ex
index 6b2a6b01d0..423f9383a9 100644
--- a/lib/plausible/application.ex
+++ b/lib/plausible/application.ex
@@ -21,7 +21,7 @@ defmodule Plausible.Application do
]
opts = [strategy: :one_for_one, name: Plausible.Supervisor]
- {:ok, _} = Logger.add_backend(Sentry.LoggerBackend)
+ Logger.add_backend(Sentry.LoggerBackend)
setup_cache_stats()
Application.put_env(:plausible, :server_start, Timex.now())
Supervisor.start_link(children, opts)
diff --git a/lib/plausible_web/endpoint.ex b/lib/plausible_web/endpoint.ex
index 8bd1555f9b..31a618fd6f 100644
--- a/lib/plausible_web/endpoint.ex
+++ b/lib/plausible_web/endpoint.ex
@@ -1,6 +1,6 @@
defmodule PlausibleWeb.Endpoint do
- use Phoenix.Endpoint, otp_app: :plausible
use Sentry.PlugCapture
+ use Phoenix.Endpoint, otp_app: :plausible
# Serve at "/" the static files from "priv/static" directory.
#
diff --git a/lib/plausible_web/plugs/auth_plug.ex b/lib/plausible_web/plugs/auth_plug.ex
index f4ffda03bd..ee116a8f12 100644
--- a/lib/plausible_web/plugs/auth_plug.ex
+++ b/lib/plausible_web/plugs/auth_plug.ex
@@ -20,7 +20,7 @@ defmodule PlausibleWeb.AuthPlug do
)
if user do
- Sentry.Context.set_user_context(%{id: user.id, name: user.name})
+ Sentry.Context.set_user_context(%{id: user.id, name: user.name, email: user.email})
assign(conn, :current_user, user)
else
conn
diff --git a/mix.exs b/mix.exs
index 905e46ce72..122793bc0c 100644
--- a/mix.exs
+++ b/mix.exs
@@ -102,7 +102,8 @@ 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"]
+ test: ["ecto.create --quiet", "ecto.migrate", "test", "clean_clickhouse"],
+ sentry_recompile: ["compile", "deps.compile sentry --force"]
]
end
end