Skip to content

Commit

Permalink
add text_body to all CE emails
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslandoga committed Jun 23, 2024
1 parent a8b9505 commit 72291ca
Show file tree
Hide file tree
Showing 42 changed files with 302 additions and 42 deletions.
2 changes: 1 addition & 1 deletion lib/plausible/imported/csv_importer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ defmodule Plausible.Imported.CSVImporter do
def label(), do: "CSV"

@impl true
def email_template(), do: "csv_import.html"
def email_template(), do: :csv_import

@impl true
def parse_args(%{"uploads" => uploads, "storage" => storage}) do
Expand Down
2 changes: 1 addition & 1 deletion lib/plausible/imported/google_analytics4.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defmodule Plausible.Imported.GoogleAnalytics4 do
def label(), do: "Google Analytics 4"

@impl true
def email_template(), do: "google_analytics_import.html"
def email_template(), do: :google_analytics_import

@impl true
def before_start(site_import, opts) do
Expand Down
2 changes: 1 addition & 1 deletion lib/plausible/imported/importer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ defmodule Plausible.Imported.Importer do

@callback name() :: atom()
@callback label() :: String.t()
@callback email_template() :: String.t()
@callback email_template() :: atom | String.t()
@callback parse_args(map()) :: Keyword.t()
@callback import_data(SiteImport.t(), Keyword.t()) ::
:ok | {:error, any()} | {:error, any(), Keyword.t()}
Expand Down
2 changes: 1 addition & 1 deletion lib/plausible/imported/noop_importer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ defmodule Plausible.Imported.NoopImporter do

# reusing existing template from another source
@impl true
def email_template(), do: "google_analytics_import.html"
def email_template(), do: :google_analytics_import

@impl true
def parse_args(opts), do: opts
Expand Down
2 changes: 1 addition & 1 deletion lib/plausible/imported/universal_analytics.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule Plausible.Imported.UniversalAnalytics do
def label(), do: "Google Analytics"

@impl true
def email_template(), do: "google_analytics_import.html"
def email_template(), do: :google_analytics_import

@impl true
def parse_args(
Expand Down
72 changes: 36 additions & 36 deletions lib/plausible_web/email.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@ defmodule PlausibleWeb.Email do
|> to(user)
|> tag("activation-email")
|> subject("#{code} is your Plausible email verification code")
|> render("activation_email.html", user: user, code: code)
|> render(:activation_email, user: user, code: code)
end

def welcome_email(user) do
base_email()
|> to(user)
|> tag("welcome-email")
|> subject("Welcome to Plausible")
|> render("welcome_email.html", user: user)
|> render(:welcome_email, user: user)
end

def create_site_email(user) do
base_email()
|> 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, user: user)
end

def site_setup_help(user, site) do
base_email()
|> to(user)
|> tag("help-email")
|> subject("Your Plausible setup: Waiting for the first page views")
|> render("site_setup_help_email.html",
|> render(:site_setup_help_email,
user: user,
site: site
)
Expand All @@ -47,7 +47,7 @@ defmodule PlausibleWeb.Email do
|> to(user)
|> tag("setup-success-email")
|> subject("Plausible is now tracking your website stats")
|> render("site_setup_success_email.html",
|> render(:site_setup_success_email,
user: user,
site: site
)
Expand All @@ -58,39 +58,39 @@ 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, user: user)
end

def password_reset_email(email, reset_link) do
priority_email(%{layout: nil})
|> to(email)
|> tag("password-reset-email")
|> subject("Plausible password reset")
|> render("password_reset_email.html", reset_link: reset_link)
|> render(:password_reset_email, reset_link: reset_link)
end

def two_factor_enabled_email(user) do
priority_email()
|> to(user)
|> tag("two-factor-enabled-email")
|> subject("Plausible Two-Factor Authentication enabled")
|> render("two_factor_enabled_email.html", user: user)
|> render(:two_factor_enabled_email, user: user)
end

def two_factor_disabled_email(user) do
priority_email()
|> to(user)
|> tag("two-factor-disabled-email")
|> subject("Plausible Two-Factor Authentication disabled")
|> render("two_factor_disabled_email.html", user: user)
|> render(:two_factor_disabled_email, user: user)
end

def trial_one_week_reminder(user) do
base_email()
|> 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, user: user)
end

def trial_upgrade_email(user, day, usage) do
Expand All @@ -100,7 +100,7 @@ defmodule PlausibleWeb.Email do
|> to(user)
|> tag("trial-upgrade-email")
|> subject("Your Plausible trial ends #{day}")
|> render("trial_upgrade_email.html",
|> render(:trial_upgrade_email,
user: user,
day: day,
custom_events: usage.custom_events,
Expand All @@ -114,7 +114,7 @@ defmodule PlausibleWeb.Email do
|> to(user)
|> tag("trial-over-email")
|> subject("Your Plausible trial has ended")
|> render("trial_over_email.html",
|> render(:trial_over_email,
user: user,
extra_offset: Plausible.Auth.User.trial_accept_traffic_until_offset_days()
)
Expand All @@ -133,7 +133,7 @@ defmodule PlausibleWeb.Email do
|> to(email)
|> tag("spike-notification")
|> subject("Traffic Spike on #{site.domain}")
|> render("spike_notification.html", %{
|> render(:spike_notification, %{
site: site,
current_visitors: current_visitors,
sources: sources,
Expand All @@ -146,7 +146,7 @@ defmodule PlausibleWeb.Email do
|> to(user)
|> tag("over-limit")
|> subject("[Action required] You have outgrown your Plausible subscription tier")
|> render("over_limit.html", %{
|> render(:over_limit, %{
user: user,
usage: usage,
suggested_plan: suggested_plan
Expand All @@ -158,7 +158,7 @@ defmodule PlausibleWeb.Email do
|> to("enterprise@plausible.io")
|> tag("enterprise-over-limit")
|> subject("#{user.email} has outgrown their enterprise plan")
|> render("enterprise_over_limit_internal.html", %{
|> render(:enterprise_over_limit_internal, %{
user: user,
pageview_usage: pageview_usage,
site_usage: site_usage,
Expand All @@ -171,7 +171,7 @@ defmodule PlausibleWeb.Email do
|> to(user)
|> tag("dashboard-locked")
|> subject("[Action required] Your Plausible dashboard is now locked")
|> render("dashboard_locked.html", %{
|> render(:dashboard_locked, %{
user: user,
usage: usage,
suggested_plan: suggested_plan
Expand All @@ -185,7 +185,7 @@ defmodule PlausibleWeb.Email do
|> to(user)
|> tag("yearly-renewal")
|> subject("Your Plausible subscription is up for renewal")
|> render("yearly_renewal_notification.html", %{
|> render(:yearly_renewal_notification, %{
user: user,
date: date,
next_bill_amount: user.subscription.next_bill_amount,
Expand All @@ -205,7 +205,7 @@ defmodule PlausibleWeb.Email do
|> to(user)
|> tag("yearly-expiration")
|> subject("Your Plausible subscription is about to expire")
|> render("yearly_expiration_notification.html", %{
|> render(:yearly_expiration_notification, %{
user: user,
next_bill_date: next_bill_date,
accept_traffic_until: accept_traffic_until
Expand All @@ -217,15 +217,15 @@ defmodule PlausibleWeb.Email do
|> to(user.email)
|> tag("cancelled-email")
|> subject("Mind sharing your thoughts on Plausible?")
|> render("cancellation_email.html", user: user)
|> render(:cancellation_email, user: user)
end

def new_user_invitation(invitation) do
priority_email()
|> to(invitation.email)
|> tag("new-user-invitation")
|> subject("[#{Plausible.product_name()}] You've been invited to #{invitation.site.domain}")
|> render("new_user_invitation.html",
|> render(:new_user_invitation,
invitation: invitation
)
end
Expand All @@ -235,7 +235,7 @@ defmodule PlausibleWeb.Email do
|> to(invitation.email)
|> tag("existing-user-invitation")
|> subject("[#{Plausible.product_name()}] You've been invited to #{invitation.site.domain}")
|> render("existing_user_invitation.html",
|> render(:existing_user_invitation,
invitation: invitation
)
end
Expand All @@ -247,7 +247,7 @@ defmodule PlausibleWeb.Email do
|> subject(
"[#{Plausible.product_name()}] Request to transfer ownership of #{invitation.site.domain}"
)
|> render("ownership_transfer_request.html",
|> render(:ownership_transfer_request,
invitation: invitation,
new_owner_account: new_owner_account
)
Expand All @@ -260,7 +260,7 @@ defmodule PlausibleWeb.Email do
|> subject(
"[#{Plausible.product_name()}] #{invitation.email} accepted your invitation to #{invitation.site.domain}"
)
|> render("invitation_accepted.html",
|> render(:invitation_accepted,
user: invitation.inviter,
invitation: invitation
)
Expand All @@ -273,7 +273,7 @@ defmodule PlausibleWeb.Email do
|> subject(
"[#{Plausible.product_name()}] #{invitation.email} rejected your invitation to #{invitation.site.domain}"
)
|> render("invitation_rejected.html",
|> render(:invitation_rejected,
user: invitation.inviter,
invitation: invitation
)
Expand All @@ -286,7 +286,7 @@ defmodule PlausibleWeb.Email do
|> subject(
"[#{Plausible.product_name()}] #{invitation.email} accepted the ownership transfer of #{invitation.site.domain}"
)
|> render("ownership_transfer_accepted.html",
|> render(:ownership_transfer_accepted,
user: invitation.inviter,
invitation: invitation
)
Expand All @@ -299,7 +299,7 @@ defmodule PlausibleWeb.Email do
|> subject(
"[#{Plausible.product_name()}] #{invitation.email} rejected the ownership transfer of #{invitation.site.domain}"
)
|> render("ownership_transfer_rejected.html",
|> render(:ownership_transfer_rejected,
user: invitation.inviter,
invitation: invitation
)
Expand All @@ -312,7 +312,7 @@ defmodule PlausibleWeb.Email do
|> subject(
"[#{Plausible.product_name()}] Your access to #{membership.site.domain} has been revoked"
)
|> render("site_member_removed.html",
|> render(:site_member_removed,
user: membership.user,
membership: membership
)
Expand Down Expand Up @@ -371,7 +371,7 @@ defmodule PlausibleWeb.Email do
|> to(user)
|> tag("export-success")
|> subject("[#{Plausible.product_name()}] Your export is now ready for download")
|> render("export_success.html",
|> render(:export_success,
user: user,
site: site,
download_url: download_url,
Expand All @@ -383,7 +383,7 @@ defmodule PlausibleWeb.Email do
priority_email()
|> to(user)
|> subject("[#{Plausible.product_name()}] Your export has failed")
|> render("export_failure.html", user: user, site: site)
|> render(:export_failure, user: user, site: site)
end

def error_report(reported_by, trace_id, feedback) do
Expand All @@ -394,7 +394,7 @@ defmodule PlausibleWeb.Email do
|> put_param("ReplyTo", reported_by)
|> tag("sentry")
|> subject("Feedback to Sentry Trace #{trace_id}")
|> render("error_report_email.html", %{
|> render(:error_report_email, %{
reported_by: reported_by,
feedback: feedback,
trace_id: trace_id
Expand All @@ -406,7 +406,7 @@ defmodule PlausibleWeb.Email do
|> to(notification.email)
|> tag("drop-traffic-warning-first")
|> subject("We'll stop counting your stats")
|> render("approaching_accept_traffic_until.html",
|> render(:approaching_accept_traffic_until,
time: "next week",
user: %{email: notification.email, name: notification.name}
)
Expand All @@ -417,7 +417,7 @@ defmodule PlausibleWeb.Email do
|> to(notification.email)
|> tag("drop-traffic-warning-final")
|> subject("A reminder that we'll stop counting your stats tomorrow")
|> render("approaching_accept_traffic_until.html",
|> render(:approaching_accept_traffic_until,
time: "tomorrow",
user: %{email: notification.email, name: notification.name}
)
Expand All @@ -427,14 +427,14 @@ defmodule PlausibleWeb.Email do
Unlike the default 'base' emails, priority emails cannot be unsubscribed from. This is achieved
by sending them through a dedicated 'priority' message stream in Postmark.
"""
def priority_email(), do: priority_email(%{layout: "priority_email.html"})
def priority_email(), do: priority_email(%{layout: :priority_email})

def priority_email(%{layout: layout}) do
base_email(%{layout: layout})
|> put_param("MessageStream", "priority")
end

def base_email(), do: base_email(%{layout: "base_email.html"})
def base_email(), do: base_email(%{layout: :base_email})

def base_email(%{layout: layout}) do
mailer_from = Application.get_env(:plausible, :mailer_email)
Expand All @@ -447,7 +447,7 @@ defmodule PlausibleWeb.Email do

defp maybe_put_layout(email, nil), do: email

defp maybe_put_layout(email, layout) do
put_html_layout(email, {PlausibleWeb.LayoutView, layout})
defp maybe_put_layout(email, layout) when is_atom(layout) do
put_layout(email, {PlausibleWeb.LayoutView, layout})
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enter <%= @code %> to verify your email address. This code will expire in 4 hours.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
You used to have an active account with <%= Plausible.product_name() %>, a simple, lightweight, open source and privacy-first Google Analytics alternative.

We've noticed that you're still sending us stats so we're writing to inform you that we'll stop accepting stats from your sites <%= @time %>. We're an independent, bootstrapped service and we don't sell your data, so this will reduce our server costs and help keep us sustainable.

If you'd like to continue counting your site stats in a privacy-friendly way, please login to your Plausible account at <%= plausible_url() %> and start a subscription.

Do you have any questions or need help with anything? Just reply to this email and we'll gladly help.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is Marko, one of the co-founders of Plausible. I'd love to understand the reasons behind your decision to cancel your subscription. We're solely funded by our subscribers so we genuinely value your feedback. Even a few words would be beneficial in helping us improve our product. Please respond to this email with any insights you can share. Thank you for your time!
14 changes: 14 additions & 0 deletions lib/plausible_web/templates/email/check_stats_email.text.eex
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Plausible is tracking your website stats without compromising the user experience and the privacy of your visitors.

Here's how to get even more out of your Plausible experience:

* Set up custom events: https://plausible.io/docs/custom-event-goals and pageview goals: https://plausible.io/docs/pageview-goals to count actions you want your visitors to take
* Running an ecommerce? Assign monetary values to custom events to track revenue attribution: https://plausible.io/docs/ecommerce-revenue-tracking
* Follow the journey from a landing page to conversion with funnel analysis: https://plausible.io/docs/funnel-analysis
* Tag your social media, email and paid links: https://plausible.io/docs/manual-link-tagging to see which campaigns are responsible for most conversions
* Send custom properties: https://plausible.io/docs/custom-props/introduction to collect data that we don't track automatically
* Explore our stats API: https://plausible.io/docs/stats-api to retrieve your stats and our sites API: https://plausible.io/docs/sites-api to create and manage sites programmatically

View your Plausible dashboard now: <%= plausible_url() %> for the most valuable traffic insights at a glance.

Do reply back to this email if you have any questions or need some guidance.
5 changes: 5 additions & 0 deletions lib/plausible_web/templates/email/create_site_email.text.eex
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
You've activated your free 30-day trial of Plausible, a simple and privacy-friendly website analytics tool.

Click here: <%= "#{plausible_url()}/sites/new" %> to add your website URL, your timezone and install our one-line JavaScript snippet to start collecting visitor statistics.

Do reply back to this email if you have any questions or need some guidance.
Loading

0 comments on commit 72291ca

Please sign in to comment.