Merge pull request #2431 from plausible/fix-email-links

Fix email links
pull/2441/head
RobertJoonas 4 years ago committed by GitHub
commit 47bf003c29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -19,7 +19,7 @@ defmodule PlausibleWeb.Email do
|> to(user)
|> tag("welcome-email")
|> subject("Welcome to Plausible")
|> render("welcome_email.html", user: user)
|> render("welcome_email.html", user: user, unsubscribe: true)
end
def create_site_email(user) do
@ -27,7 +27,7 @@ defmodule PlausibleWeb.Email do
|> to(user)
|> tag("create-site-email")
|> subject("Your Plausible setup: Add your website details")
|> render("create_site_email.html", user: user)
|> render("create_site_email.html", user: user, unsubscribe: true)
end
def site_setup_help(user, site) do
@ -35,7 +35,11 @@ defmodule PlausibleWeb.Email do
|> to(user)
|> tag("help-email")
|> subject("Your Plausible setup: Waiting for the first page views")
|> render("site_setup_help_email.html", user: user, site: site)
|> render("site_setup_help_email.html",
user: user,
site: site,
unsubscribe: true
)
end
def site_setup_success(user, site) do
@ -43,7 +47,11 @@ defmodule PlausibleWeb.Email do
|> to(user)
|> tag("setup-success-email")
|> subject("Plausible is now tracking your website stats")
|> render("site_setup_success_email.html", user: user, site: site)
|> render("site_setup_success_email.html",
user: user,
site: site,
unsubscribe: true
)
end
def check_stats_email(user) do
@ -51,11 +59,11 @@ defmodule PlausibleWeb.Email do
|> to(user)
|> tag("check-stats-email")
|> subject("Check your Plausible website stats")
|> render("check_stats_email.html", user: user)
|> render("check_stats_email.html", user: user, unsubscribe: true)
end
def password_reset_email(email, reset_link) do
base_email()
base_email(%{layout: nil})
|> to(email)
|> tag("password-reset-email")
|> subject("Plausible password reset")
@ -67,7 +75,7 @@ defmodule PlausibleWeb.Email do
|> to(user)
|> tag("trial-one-week-reminder")
|> subject("Your Plausible trial expires next week")
|> render("trial_one_week_reminder.html", user: user)
|> render("trial_one_week_reminder.html", user: user, unsubscribe: true)
end
def trial_upgrade_email(user, day, {pageviews, custom_events}) do
@ -82,7 +90,8 @@ defmodule PlausibleWeb.Email do
day: day,
custom_events: custom_events,
usage: pageviews + custom_events,
suggested_plan: suggested_plan
suggested_plan: suggested_plan,
unsubscribe: true
)
end
@ -91,11 +100,11 @@ defmodule PlausibleWeb.Email do
|> to(user)
|> tag("trial-over-email")
|> subject("Your Plausible trial has ended")
|> render("trial_over_email.html", user: user)
|> render("trial_over_email.html", user: user, unsubscribe: true)
end
def weekly_report(email, site, assigns) do
base_email()
base_email(%{layout: nil})
|> to(email)
|> tag("weekly-report")
|> subject("#{assigns[:name]} report for #{site.domain}")
@ -124,12 +133,13 @@ defmodule PlausibleWeb.Email do
user: user,
usage: usage,
last_cycle: last_cycle,
suggested_plan: suggested_plan
suggested_plan: suggested_plan,
unsubscribe: true
})
end
def enterprise_over_limit_internal_email(user, usage, last_cycle, site_usage, site_allowance) do
base_email()
base_email(%{layout: nil})
|> to("enterprise@plausible.io")
|> tag("enterprise-over-limit")
|> subject("#{user.email} has outgrown their enterprise plan")
@ -188,7 +198,7 @@ defmodule PlausibleWeb.Email do
|> to(user.email)
|> tag("cancelled-email")
|> subject("Your Plausible Analytics subscription has been canceled")
|> render("cancellation_email.html", name: user.name)
|> render("cancellation_email.html", user: user)
end
def new_user_invitation(invitation) do
@ -230,6 +240,7 @@ defmodule PlausibleWeb.Email do
"[Plausible Analytics] #{invitation.email} accepted your invitation to #{invitation.site.domain}"
)
|> render("invitation_accepted.html",
user: invitation.inviter,
invitation: invitation
)
end
@ -242,6 +253,7 @@ defmodule PlausibleWeb.Email do
"[Plausible Analytics] #{invitation.email} rejected your invitation to #{invitation.site.domain}"
)
|> render("invitation_rejected.html",
user: invitation.inviter,
invitation: invitation
)
end
@ -254,6 +266,7 @@ defmodule PlausibleWeb.Email do
"[Plausible Analytics] #{invitation.email} accepted the ownership transfer of #{invitation.site.domain}"
)
|> render("ownership_transfer_accepted.html",
user: invitation.inviter,
invitation: invitation
)
end
@ -266,6 +279,7 @@ defmodule PlausibleWeb.Email do
"[Plausible Analytics] #{invitation.email} rejected the ownership transfer of #{invitation.site.domain}"
)
|> render("ownership_transfer_rejected.html",
user: invitation.inviter,
invitation: invitation
)
end
@ -276,6 +290,7 @@ defmodule PlausibleWeb.Email do
|> tag("site-member-removed")
|> subject("[Plausible Analytics] Your access to #{membership.site.domain} has been revoked")
|> render("site_member_removed.html",
user: membership.user,
membership: membership
)
end
@ -305,11 +320,21 @@ defmodule PlausibleWeb.Email do
})
end
defp base_email() do
def base_email(), do: base_email(%{layout: "base_email.html"})
def base_email(%{layout: layout}) do
mailer_from = Application.get_env(:plausible, :mailer_email)
new_email()
|> put_param("TrackOpens", false)
|> from(mailer_from)
|> maybe_put_layout(layout)
end
defp maybe_put_layout(email, nil), do: email
defp maybe_put_layout(email, layout) do
email
|> put_html_layout({PlausibleWeb.LayoutView, layout})
end
end

@ -1,3 +1 @@
Hey <%= user_salutation(@user) %>,
<br /><br />
Enter <%= @code %> to verify your email address. This code will expire in 4 hours.

@ -1,10 +1,7 @@
Hi <%= @name %>,
<br /><br />
Thanks for being a Plausible Analytics subscriber and I'm sorry to see you go.<br/><br/>
Thanks for being a Plausible Analytics subscriber and we're sorry to see you go.<br/><br/>
I'd love to hear about your experience and how you think we can improve Plausible Analytics for our other subscribers (and for you if you decide to come back). Please reply back to this email with your feedback.<br /><br />
We'd love to hear about your experience and how you think we can improve Plausible Analytics for our other subscribers (and for you if you decide to come back). Please reply back to this email with your feedback.<br /><br />
If you decide you'd like to continue keeping track of your site traffic while respecting the privacy of your visitors, obviously we'd love to have you back. You can restart your subscription from your <a href="https://plausible.io/settings">account settings</a>.<br /><br />
Hope to see you around!<br />
Uku Taht
Hope to see you around!

@ -1,15 +1,5 @@
Hey <%= user_salutation(@user) %>,
<br /><br />
Plausible is tracking your website stats without compromising the user experience and the privacy of your visitors.
<br /><br />
<%= link("View your Plausible dashboard now", to: "#{plausible_url()}") %> for the most valuable traffic insights at a glance.
<br /><br />
Do reply back to this email if you have any questions or need some guidance.
<br /></br>
Thanks,<br />
Uku Taht
<br /><br />
--
<br /><br />
<%= plausible_url() %><br />
{{{ pm:unsubscribe }}}

@ -1,13 +1,5 @@
Hey <%= user_salutation(@user) %>,
<br /><br />
You've activated your free 30-day trial of Plausible, a simple and privacy-friendly website analytics tool.
<br /><br />
<%= link("Click here", to: "#{plausible_url()}/sites/new") %> to add your website URL, your timezone and install our one-line JavaScript snippet to start collecting visitor statistics.
<br /><br />
Do reply back to this email if you have any questions or need some guidance.
<br /></br>
Thanks,<br />
Uku and Marko<br />
--<br />
<%= plausible_url() %><br />
{{{ pm:unsubscribe }}}

@ -1,5 +1,3 @@
Hey <%= user_salutation(@user) %>,
<br /><br />
Last week we sent a reminder that your traffic has exceeded your Plausible Analytics subscription tier two months in a row.
<br /><br />
Your dashboard is now locked. We're still counting your stats, but you no longer have access to the stats. As you have outgrown your subscription tier, we kindly ask you to upgrade your subscription to accommodate your new traffic levels.
@ -16,8 +14,3 @@ Based on that we recommend you select the <%= @suggested_plan[:volume] %>/mo pla
The new charge will be prorated to reflect the amount you have already paid and the time until your current subscription is supposed to expire. We will unlock your dashboard immediately after your account has been upgraded to the appropriate tier.
<br /><br />
Thanks for understanding and for being a Plausible subscriber!
<br /><br />
Thanks,<br />
Uku and Marko<br />
--<br />
<%= plausible_url() %><br />

@ -4,6 +4,3 @@ Customer email: <%= @user.email %><br />
Last billing cycle: <%= date_format(@last_cycle.first) %> to <%= date_format(@last_cycle.last) %><br >
Pageview Usage: <%= PlausibleWeb.StatsView.large_number_format(@usage) %> billable pageviews<br />
Site usage: <%= @site_usage %> / <%= @site_allowance %> allowed sites<br />
--<br />
<%= plausible_url() %><br />

@ -1,10 +1,3 @@
Hey,
<br /><br />
<%= @invitation.inviter.email %> has invited you to the <%= @invitation.site.domain %> site on Plausible Analytics.
<%= link("Click here", to: Routes.site_url(PlausibleWeb.Endpoint, :index)) %> to view and respond to the invitation. The invitation
will expire 48 hours after this email is sent.
<br /><br />
Thanks,<br />
Uku and Marko<br />
--<br />
<%= plausible_url() %><br />

@ -1,5 +1,3 @@
Hey <%= user_salutation(@user) %>,
<br /><br />
<%= if @success do %>
Your Google Analytics import has completed successfully. The Plausible dashboard for <%= @site.domain %> now contains historical imported data from <%= date_format(@site.imported_data.start_date) %> to <%= date_format(@site.imported_data.end_date) %>
<br /><br />
@ -31,14 +29,6 @@ Hey <%= user_salutation(@user) %>,
<%= if !Application.get_env(:plausible, :is_selfhost) do %>
<br /> <br />
Please reply to this email to let us know if you're still experiencing issues with the import. Thanks!
<br /> <br />
The Plausible Team 💌
Please reply to this email to let us know if you're still experiencing issues with the import.
<% end %>
<% end %>
<br /><br />
--
<br /><br />
<%= plausible_url() %><br />

@ -1,9 +1,2 @@
Hey <%= user_salutation(@invitation.inviter) %>,
<br /><br />
<%= @invitation.email %> has accepted your invitation to <%= @invitation.site.domain %>.
<%= link("Click here", to: Routes.site_url(PlausibleWeb.Endpoint, :settings_general, @invitation.site.domain)) %> to view site settings.
<br /><br />
Thanks,<br />
Uku and Marko<br />
--<br />
<%= plausible_url() %><br />

@ -1,9 +1,2 @@
Hey <%= user_salutation(@invitation.inviter) %>,
<br /><br />
<%= @invitation.email %> has rejected your invitation to <%= @invitation.site.domain %>.
<%= link("Click here", to: Routes.site_url(PlausibleWeb.Endpoint, :settings_general, @invitation.site.domain)) %> to view site settings.
<br /><br />
Thanks,<br />
Uku and Marko<br />
--<br />
<%= plausible_url() %><br />

@ -1,11 +1,4 @@
Hey,
<br /><br />
<%= @invitation.inviter.email %> has invited you to join the <%= @invitation.site.domain %> site on Plausible Analytics.
<%= link("Click here", to: Routes.auth_url(PlausibleWeb.Endpoint, :register_from_invitation_form, @invitation.invitation_id)) %> to create your account. The link is valid for 48 hours after this email is sent.
<br /><br />
Plausible is a lightweight and open-source website analytics tool. We hope you like our simple and ethical approach to tracking website visitors.
<br /><br />
Thanks,<br />
Uku and Marko<br />
--<br />
<%= plausible_url() %><br />

@ -1,5 +1,3 @@
Hey <%= user_salutation(@user) %>,
<br /><br />
Thanks for being a Plausible Analytics subscriber!
<br /><br />
This is a notice that your traffic has exceeded your subscription tier two months in a row. Congrats on all that traffic!
@ -20,9 +18,3 @@ You can upgrade your subscription using our self-serve platform. The new charge
Have questions or need help with anything? Just reply to this email and we'll gladly help.
<br /><br />
Thanks again for using our product and for your support!
<br /><br />
Thanks,<br />
Uku and Marko<br />
--<br />
<%= plausible_url() %><br />
{{{ pm:unsubscribe }}}

@ -1,10 +1,3 @@
Hey <%= user_salutation(@invitation.inviter) %>,
<br /><br />
<%= @invitation.email %> has accepted the ownership transfer of <%= @invitation.site.domain %>. They will be responsible for billing of it going
forward and your role has been changed to <b>admin</b>.
<%= link("Click here", to: Routes.site_url(PlausibleWeb.Endpoint, :settings_general, @invitation.site.domain)) %> to view site settings.
<br /><br />
Thanks,<br />
Uku and Marko<br />
--<br />
<%= plausible_url() %><br />

@ -1,9 +1,2 @@
Hey <%= user_salutation(@invitation.inviter) %>,
<br /><br />
<%= @invitation.email %> has rejected the ownership transfer of <%= @invitation.site.domain %>.
<%= link("Click here", to: Routes.site_url(PlausibleWeb.Endpoint, :settings_general, @invitation.site.domain)) %> to view site settings.
<br /><br />
Thanks,<br />
Uku and Marko<br />
--<br />
<%= plausible_url() %><br />

@ -1,5 +1,3 @@
Hey,
<br /><br />
<%= @invitation.inviter.email %> has requested to transfer the ownership of <%= @invitation.site.domain %> site on Plausible Analytics to you.
<%= if @new_owner_account do %>
<%= link("Click here", to: Routes.site_url(PlausibleWeb.Endpoint, :index)) %> to view and respond to the invitation.
@ -8,8 +6,3 @@ Hey,
<br /><br />
Plausible is a lightweight and open-source website analytics tool. We hope you like our simple and ethical approach to tracking website visitors.
<% end %>
<br /><br />
Thanks,<br />
Uku and Marko<br />
--<br />
<%= plausible_url() %><br />

@ -1,10 +1,3 @@
Hey <%= user_salutation(@membership.user) %>,
<br /><br />
An administrator of <%= @membership.site.domain %> has removed you as a member. You won't be able to see the stats anymore.
<br /><br />
<%= link("Click here", to: Routes.site_url(PlausibleWeb.Endpoint, :index)) %> to view your sites.
<br /><br />
Thanks,<br />
Uku and Marko<br />
--<br />
<%= plausible_url() %><br />

@ -1,5 +1,3 @@
Hey <%= user_salutation(@user) %>,
<br /><br />
<%= if Plausible.Billing.on_trial?(@user) do %>
You signed up for a free 30-day trial of Plausible, a simple and privacy-friendly website analytics tool.
<br /><br />
@ -9,9 +7,3 @@ To finish your setup for <%= @site.domain %>, you need to install <%= link("this
This Plausible script is 45 times smaller than Google Analytics script so you’ll have a fast loading site while getting all the important traffic insights on one single page.
<br /><br />
Do reply back to this email if you have any questions or need some guidance.
<br /><br />
Thanks,<br />
Uku and Marko<br />
--<br />
<%= plausible_url() %><br />
{{{ pm:unsubscribe }}}

@ -1,5 +1,3 @@
Hey <%= user_salutation(@user) %>,
<br /><br />
Congrats! The Plausible script has been installed correctly on <%= link(@site.domain, to: "https://#{@site.domain}") %>. Your website traffic is now being tracked without compromising the user experience and the privacy of your visitors.
<br /><br />
<%= link("Check your stats", to: "#{plausible_url()}/#{URI.encode_www_form(@site.domain)}") %>
@ -11,9 +9,3 @@ Congrats! The Plausible script has been installed correctly on <%= link(@site.do
PS: You can import your historical Google Analytics (Universal Analytics) stats into your Plausible dashboard. <%= link("Learn how our GA importer works", to: "https://plausible.io/docs/google-analytics-import") %>.
<br /><br />
Do reply back to this email if you have any questions.
<br /><br />
Thanks,<br />
Uku and Marko<br />
--<br />
<%= plausible_url() %><br />
{{{ pm:unsubscribe }}}

@ -10,9 +10,8 @@ There are currently <%= @current_visitors %> visitors on <%= link(@site.domain,
<%= if @link do %>
<br /><br />
View dashboard: @link
View dashboard: <%= link(@link, to: @link) %>
<% end %>
<br /><br />
--
<br /><br />
<%= plausible_url() %><br />
Congrats on the spike in traffic!

@ -1,15 +1,7 @@
Hey <%= user_salutation(@user) %>,
<br /><br />
Time flies! Your 30-day free trial of Plausible will end next week.
<br /><br />
Over the last three weeks, I hope you got to experience the potential benefits of having website stats in a simple dashboard while respecting the privacy of your visitors, not annoying them with the cookie and privacy notices and still having a fast loading site.
Over the last three weeks, We hope you got to experience the potential benefits of having website stats in a simple dashboard while respecting the privacy of your visitors, not annoying them with the cookie and privacy notices and still having a fast loading site.
<br /><br />
In order to continue receiving valuable website traffic insights at a glance, you’ll need to <%= link("Upgrade your account", to: "#{plausible_url()}/billing/upgrade") %>.
<br /><br />
If you have any questions or feedback for me, feel free to reply to this email.
<br /><br />
Thanks,<br />
Uku and Marko<br />
--<br />
<%= plausible_url() %><br />
{{{ pm:unsubscribe }}}
If you have any questions or feedback for us, feel free to reply to this email.

@ -1,15 +1,6 @@
Hey <%= user_salutation(@user) %>,
<br /><br />
Your free Plausible trial has now expired. Upgrade your account to continue receiving valuable website traffic insights at a glance while respecting the privacy of your visitors and still having a fast loading site. <br /><br />
<%= link("Upgrade now", to: "#{plausible_url()}/billing/upgrade") %>
<br /><br />
We will keep recording stats for another month to give you time to upgrade.
<br /><br />
Thanks,<br />
Uku and Marko<br />
--<br />
<%= plausible_url() %><br />
{{{ pm:unsubscribe }}}

@ -1,5 +1,3 @@
Hey <%= user_salutation(@user) %>,
<br /><br />
Thanks for exploring Plausible, a simple and privacy-friendly alternative to Google Analytics. Your free 30-day trial is ending <%= @day %>, but you can keep using Plausible by upgrading to a paid plan.
<br /><br />
In the last month, your account has used <%= PlausibleWeb.AuthView.delimit_integer(@usage) %> billable pageviews<%= if @custom_events > 0, do: " and custom events in total", else: "" %>.
@ -12,9 +10,3 @@ Have a question, feedback or need some guidance? Just reply to this email to get
<% else %>
This is more than our standard plans, so please reply back to this email to get a quote for your volume.
<% end %>
<br /><br />
Thanks,<br />
Uku and Marko<br />
--<br />
<%= plausible_url() %><br />
{{{ pm:unsubscribe }}}

@ -1,5 +1,3 @@
Hey <%= user_salutation(@user) %>,
<br /><br />
We are building Plausible to provide a simple and ethical approach to tracking website visitors.
We're super excited to have you on board!
<br /><br />
@ -15,11 +13,3 @@ Here's how to get the most out of your Plausible experience:
Then you're ready to start exploring your fast loading, ethical and actionable <%= link("Plausible dashboard", to: "https://plausible.io/sites") %>.
<br /><br />
Have a question, feedback or need some guidance? Do reply back to this email.
<br /><br />
Thanks,<br />
Uku and Marko
<br />
--
<br />
<%= plausible_url() %><br />
{{{ pm:unsubscribe }}}

@ -1,5 +1,3 @@
Hey <%= user_salutation(@user) %>,
<br /><br />
Time flies! This is a reminder that your annual subscription for Plausible Analytics will expire on <%= @date %>.
<br /><br />
You need to renew your subscription on <%= link("account settings page", to: "#{plausible_url()}/billing/upgrade") %> if you want to continue using Plausible to count your website stats in a privacy-friendly way.
@ -7,8 +5,3 @@ You need to renew your subscription on <%= link("account settings page", to: "#{
If you don't want to continue your subscription, there's no action required. You will lose access to the stats on <%= @date %>.
<br /><br />
Have a question, feedback or need some guidance? Just reply to this email to get in touch!
<br /><br />
Thanks,<br />
Uku and Marko<br />
--<br />
<%= plausible_url() %><br />

@ -1,5 +1,3 @@
Hey <%= user_salutation(@user) %>,
<br /><br />
Time flies! This is a reminder that your annual subscription for Plausible Analytics is due to renew on <%= @date %>. We will automatically charge <%= PlausibleWeb.BillingView.present_currency(@currency) %><%= @next_bill_amount %> from your preferred billing method.
<br /><br />
There's no action required if you're happy to continue using Plausible to count your website stats in a privacy-friendly way.
@ -7,8 +5,3 @@ There's no action required if you're happy to continue using Plausible to count
If you don't want to continue your subscription, you can cancel it on your <%= link("account settings page", to: "#{plausible_url()}/settings") %>.
<br /><br />
Have a question, feedback or need some guidance? Do reply back to this email.
<br /><br />
Thanks,<br />
Uku and Marko<br />
--<br />
<%= plausible_url() %><br />

@ -0,0 +1,17 @@
<%= PlausibleWeb.EmailView.greet_recipient(assigns) %>
<br /><br />
<%= @inner_content %>
<br /><br />
Regards,<br />
The Plausible Team 💌
<br /><br />
--
<br /><br />
<%= link(plausible_url(), to: plausible_url()) %><br />
<%= if Map.get(assigns, :unsubscribe, false) do %>
{{{ pm:unsubscribe }}}
<% end %>

@ -9,14 +9,12 @@ defmodule PlausibleWeb.EmailView do
PlausibleWeb.Endpoint.host()
end
def user_salutation(user) do
if user.name do
String.split(user.name) |> List.first()
else
""
end
def greet_recipient(%{user: %{name: name}}) when is_binary(name) do
"Hey #{String.split(name) |> List.first()},"
end
def greet_recipient(_), do: "Hey,"
def date_format(date) do
Timex.format!(date, "{D} {Mshort} {YYYY}")
end

@ -31,7 +31,7 @@ defmodule Plausible.Workers.SpikeNotifier do
:ok
end
def notify(notification, current_visitors, sources) do
defp notify(notification, current_visitors, sources) do
for recipient <- notification.recipients do
send_notification(recipient, notification.site, current_visitors, sources)
end
@ -45,7 +45,7 @@ defmodule Plausible.Workers.SpikeNotifier do
site = Repo.preload(site, :members)
dashboard_link =
if Enum.member?(site.members, recipient) do
if Enum.any?(site.members, &(&1.email == recipient)) do
PlausibleWeb.Endpoint.url() <> "/" <> URI.encode_www_form(site.domain)
end

@ -0,0 +1,68 @@
defmodule PlausibleWeb.EmailTest do
alias PlausibleWeb.Email
use ExUnit.Case, async: true
import Plausible.Factory
describe "base_email layout" do
test "greets user by first name if user in template assigns" do
email =
Email.base_email()
|> Email.render("activation_email.html", %{
user: build(:user, name: "John Doe"),
code: "123"
})
assert email.html_body =~ "Hey John,"
end
test "greets impersonally when user not in template assigns" do
email =
Email.base_email()
|> Email.render("password_reset_email.html", %{
reset_link: "imaginary"
})
assert email.html_body =~ "Hey,"
end
test "renders plausible link" do
email =
Email.base_email()
|> Email.render("cancellation_email.html")
assert email.html_body =~ plausible_link()
end
test "does not render unsubscribe placeholder by default" do
email =
Email.base_email()
|> Email.render("welcome_email.html")
refute email.html_body =~ "{{{ pm:unsubscribe }}}"
end
test "renders unsubscribe placeholder if told" do
email =
Email.base_email()
|> Email.render("welcome_email.html", %{unsubscribe: true})
assert email.html_body =~ "{{{ pm:unsubscribe }}}"
end
test "can be disabled with a nil layout" do
email =
Email.base_email(%{layout: nil})
|> Email.render("welcome_email.html", %{
user: build(:user, name: "John Doe")
})
refute email.html_body =~ "Hey John,"
refute email.html_body =~ plausible_link()
end
end
def plausible_link() do
plausible_url = PlausibleWeb.EmailView.plausible_url()
"<a href=\"#{plausible_url}\">#{plausible_url}</a>"
end
end

@ -1,16 +0,0 @@
defmodule PlausibleWeb.EmailViewTest do
use PlausibleWeb.ConnCase, async: true
alias PlausibleWeb.EmailView
describe "user salutation" do
test "picks first name if full name has two parts" do
user1 = %Plausible.Auth.User{name: "Jane"}
user2 = %Plausible.Auth.User{name: "Jane Doe"}
user3 = %Plausible.Auth.User{name: "Jane Alice Doe"}
assert EmailView.user_salutation(user1) == "Jane"
assert EmailView.user_salutation(user2) == "Jane"
assert EmailView.user_salutation(user3) == "Jane"
end
end
end

@ -85,4 +85,18 @@ defmodule Plausible.Workers.SpikeNotifierTest do
assert_no_emails_delivered()
end
test "adds a dashboard link if recipient has access to the site" do
user = insert(:user, email: "robert@example.com")
site = insert(:site, domain: "example.com", members: [user])
insert(:spike_notification, site: site, threshold: 10, recipients: ["robert@example.com"])
clickhouse_stub =
stub(Plausible.Stats.Clickhouse, :current_visitors, fn _site, _query -> 10 end)
|> stub(:top_sources, fn _site, _query, _limit, _page, _show_noref -> [] end)
SpikeNotifier.perform(nil, clickhouse_stub)
assert_email_delivered_with(html_body: ~r/View dashboard: <a href=\"http.+\/example.com/)
end
end

Loading…
Cancel
Save