diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2b065ad60820..0edbc5169800 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file.
## Unreleased
+### Fixed
+- Fixed weekly/monthly e-mail report [rendering issues](https://github.com/plausible/analytics/issues/284)
+
## v2.0.0 - 2023-07-12
### Added
diff --git a/lib/plausible_web/email.ex b/lib/plausible_web/email.ex
index f222500eca8b..fe5c5504e1e5 100644
--- a/lib/plausible_web/email.ex
+++ b/lib/plausible_web/email.ex
@@ -104,11 +104,13 @@ defmodule PlausibleWeb.Email do
end
def weekly_report(email, site, assigns) do
+ assigns = Keyword.put(assigns, :site, site)
+
base_email(%{layout: nil})
|> to(email)
|> tag("weekly-report")
|> subject("#{assigns[:name]} report for #{site.domain}")
- |> render("weekly_report.html", Keyword.put(assigns, :site, site))
+ |> html_body(PlausibleWeb.MJML.WeeklyReport.render(assigns))
end
def spike_notification(email, site, current_visitors, sources, dashboard_link) do
diff --git a/lib/plausible_web/mjml/templates/weekly_report.mjml.eex b/lib/plausible_web/mjml/templates/weekly_report.mjml.eex
new file mode 100644
index 000000000000..9fbd84b96df8
--- /dev/null
+++ b/lib/plausible_web/mjml/templates/weekly_report.mjml.eex
@@ -0,0 +1,181 @@
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ![]()
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <%= @name %> report for <%= @site.domain %> -
-
-
-
-
-
- <%= Timex.format!(@query.date_range.first, "{D} {Mshort}") %> – <%= Timex.format!(@query.date_range.last, "{D} {Mshort} {YYYY}") %>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- UNIQUE VISITORS
-
-
-
-
-
-
- <%= PlausibleWeb.StatsView.large_number_format(@unique_visitors) %> -
- <%= cond do %>
- <% @change_visitors == nil -> %>
-
-
-
-
-
- <% @change_visitors >= 0 -> %>
- N/A -
-
- <% @change_visitors < 0 -> %>
- +<%= @change_visitors %>% -
-
- <% end %>
- <%= @change_visitors %>% -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PAGEVIEWS
-
-
-
-
-
-
- <%= PlausibleWeb.StatsView.large_number_format(@pageviews) %> -
- <%= cond do %>
- <% @change_pageviews == nil -> %>
-
-
-
-
-
- <% @change_pageviews >= 0 -> %>
- N/A -
-
- <% @change_pageviews < 0 -> %>
- +<%= @change_pageviews %>% -
-
- <% end %>
- <%= @change_pageviews %>% -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- BOUNCE RATE
-
-
-
-
-
-
- <%= @bounce_rate %>% -
- <%= cond do %>
- <% @change_bounce_rate == nil -> %>
-
-
-
-
-
- <% @change_bounce_rate <= 0 -> %>
- N/A -
-
- <% @change_bounce_rate > 0 -> %>
- <%= @change_bounce_rate %>% -
-
- <% end %>
- +<%= @change_bounce_rate %>% -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <%= for source <- @sources do %>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Referrer -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Visitors -
-
- <% end %>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <%= source[:source] %> -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <%= PlausibleWeb.StatsView.large_number_format(source[:visitors]) %> -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <%= for page <- @pages do %>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Page -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Views -
-
- <% end %>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <%= page[:page] %> -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <%= PlausibleWeb.StatsView.large_number_format(page[:visitors]) %> -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Don't want to receive these emails? Click here to unsubscribe. - |
-