Send welcome email after first site creation

pull/477/head
Uku Taht 6 years ago
parent aa7ae87811
commit 9c4493de66

@ -72,9 +72,6 @@ defmodule PlausibleWeb.AuthController do
case Auth.verify_email(user, code) do
:ok ->
PlausibleWeb.Email.welcome_email(user)
|> Plausible.Mailer.send_email()
redirect(conn, to: "/sites/new")
{:error, :incorrect} ->
render(conn, "activate.html",

@ -37,6 +37,17 @@ defmodule PlausibleWeb.SiteController do
{:ok, %{site: site}} ->
Plausible.Slack.notify("#{user.name} created #{site.domain} [email=#{user.email}]")
is_first_site = !Repo.exists?(
from sm in Plausible.Site.Membership,
where: sm.user_id == ^user.id
and sm.site_id != ^site.id
)
if is_first_site do
PlausibleWeb.Email.welcome_email(user)
|> Plausible.Mailer.send_email()
end
conn
|> put_session(site.domain <> "_offer_email_report", true)
|> redirect(to: "/#{URI.encode_www_form(site.domain)}/snippet")

@ -1,14 +1,22 @@
Hey <%= user_salutation(@user) %>,
<br /><br />
I'm building Plausible to provide a simple and ethical approach to tracking website visitors.
I'm super excited to have you on board!
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 />
To start collecting stats, you need to <%= link("add a site on Plausible", to: "#{plausible_url()}/sites/new") %>.
Here are five steps to get the most out of your Plausible experience:
<br /><br />
* Serve the script as a <%= link("first party connection from your custom domain", to: "https://docs.plausible.io/custom-domain") %><br />
* <%= link("Enable email reports", to: "https://docs.plausible.io/email-reports/") %> and notifications for <%= link("traffic spikes", to: "https://docs.plausible.io/traffic-spikes/") %><br />
* <%= link("Integrate with Search Console", to: "https://docs.plausible.io/google-search-console-integration/") %> to get keyword phrases people find your site with<br />
* Set up some easy goals including <%= link("404 error pages", to: "https://docs.plausible.io/404-error-pages-tracking") %> and <%= link("outbound link clicks", to: "https://docs.plausible.io/outbound-link-click-tracking/") %><br />
* <%= link("Opt out from counting your own visits", to: "https://docs.plausible.io/excluding/") %><br />
<br /><br />
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 Taht
Uku and Marko
<br /><br />
--
<br /><br />

@ -1,6 +1,7 @@
defmodule PlausibleWeb.SiteControllerTest do
use PlausibleWeb.ConnCase
use Plausible.Repo
use Bamboo.Test
import Plausible.TestUtils
describe "GET /sites/new" do
@ -45,6 +46,30 @@ defmodule PlausibleWeb.SiteControllerTest do
assert Repo.exists?(Plausible.Site, domain: "example.com")
end
test "sends welcome email if this is the user's first site", %{conn: conn} do
post(conn, "/sites", %{
"site" => %{
"domain" => "example.com",
"timezone" => "Europe/London"
}
})
assert_email_delivered_with(subject: "Welcome to Plausible")
end
test "does not send welcome email if user already has a previous site", %{conn: conn, user: user} do
insert(:site, members: [user])
post(conn, "/sites", %{
"site" => %{
"domain" => "example.com",
"timezone" => "Europe/London"
}
})
assert_no_emails_delivered()
end
test "cleans up the url", %{conn: conn} do
conn =
post(conn, "/sites", %{

Loading…
Cancel
Save