Skip to content

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

Only send sources when there are sources to send

Uku Taht7f9525e805a6
diff --git a/lib/plausible_web/templates/email/spike_notification.html.eex b/lib/plausible_web/templates/email/spike_notification.html.eex
index 901a913a36..6d27a9ed6f 100644
--- a/lib/plausible_web/templates/email/spike_notification.html.eex
+++ b/lib/plausible_web/templates/email/spike_notification.html.eex
@@ -1,24 +1,26 @@
There are currently <%= @current_visitors %> visitors on <%= link(@site.domain, to: "https://" <> @site.domain) %>.
<br />
<br />
-The top 3 sources for current visitors:<br />
+<%= if Enum.count(@sources) > 0 do %>
+ The top 3 sources for current visitors:<br />
-<table width="100%" cellpadding="0" cellspacing="0" style="max-width: 400px;">
- <thead>
- <tr>
- <th scope="col"><b>Page</b></th>
- <th scope="col"><b>Visitors</b></th>
- </tr>
- </thead>
- <tbody>
- <%= for %{"name" => source, "count" => visitors} <- @sources do %>
+ <table width="100%" cellpadding="0" cellspacing="0" style="max-width: 400px;">
+ <thead>
<tr>
- <td valign="top"><%= source %></td>
- <td valign="top"><%= visitors %></td>
+ <th scope="col"><b>Page</b></th>
+ <th scope="col"><b>Visitors</b></th>
</tr>
- <% end %>
- </tbody>
-</table>
+ </thead>
+ <tbody>
+ <%= for %{"name" => source, "count" => visitors} <- @sources do %>
+ <tr>
+ <td valign="top"><%= source %></td>
+ <td valign="top"><%= visitors %></td>
+ </tr>
+ <% end %>
+ </tbody>
+ </table>
+<% end %>
<%= if @link do %>
<br /><br />