|
|
|
|
@ -46,7 +46,7 @@ defmodule Plausible.Workers.SendEmailReports do
|
|
|
|
|
for site <- sites do
|
|
|
|
|
query = Query.from(site.timezone, %{"period" => "7d"})
|
|
|
|
|
|
|
|
|
|
for email <- site.weekly_report.recipients do
|
|
|
|
|
sent = Enum.map(site.weekly_report.recipients, fn email ->
|
|
|
|
|
Logger.info("Sending weekly report for #{URI.encode_www_form(site.domain)} to #{email}")
|
|
|
|
|
|
|
|
|
|
unsubscribe_link =
|
|
|
|
|
@ -54,9 +54,9 @@ defmodule Plausible.Workers.SendEmailReports do
|
|
|
|
|
"/sites/#{URI.encode_www_form(site.domain)}/weekly-report/unsubscribe?email=#{email}"
|
|
|
|
|
|
|
|
|
|
send_report(email, site, "Weekly", unsubscribe_link, query)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
weekly_report_sent(site, job_start)
|
|
|
|
|
if Enum.all?(sent), do: weekly_report_sent(site, job_start)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@ -94,7 +94,7 @@ defmodule Plausible.Workers.SendEmailReports do
|
|
|
|
|
"date" => Timex.format!(last_month, "{ISOdate}")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
for email <- site.monthly_report.recipients do
|
|
|
|
|
sent = Enum.map(site.monthly_report.recipients, fn email ->
|
|
|
|
|
Logger.info("Sending monthly report for #{site.domain} to #{email}")
|
|
|
|
|
|
|
|
|
|
unsubscribe_link =
|
|
|
|
|
@ -102,9 +102,9 @@ defmodule Plausible.Workers.SendEmailReports do
|
|
|
|
|
"/sites/#{URI.encode_www_form(site.domain)}/monthly-report/unsubscribe?email=#{email}"
|
|
|
|
|
|
|
|
|
|
send_report(email, site, Timex.format!(last_month, "{Mfull}"), unsubscribe_link, query)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
monthly_report_sent(site, job_start)
|
|
|
|
|
if Enum.all?(sent), do: monthly_report_sent(site, job_start)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@ -122,7 +122,7 @@ defmodule Plausible.Workers.SendEmailReports do
|
|
|
|
|
user = Plausible.Auth.find_user_by(email: email)
|
|
|
|
|
login_link = user && Plausible.Sites.is_owner?(user.id, site)
|
|
|
|
|
|
|
|
|
|
PlausibleWeb.Email.weekly_report(email, site,
|
|
|
|
|
template = PlausibleWeb.Email.weekly_report(email, site,
|
|
|
|
|
unique_visitors: unique_visitors,
|
|
|
|
|
change_visitors: change_visitors,
|
|
|
|
|
pageviews: pageviews,
|
|
|
|
|
@ -136,7 +136,13 @@ defmodule Plausible.Workers.SendEmailReports do
|
|
|
|
|
query: query,
|
|
|
|
|
name: name
|
|
|
|
|
)
|
|
|
|
|
|> Plausible.Mailer.send_email()
|
|
|
|
|
|
|
|
|
|
try do
|
|
|
|
|
Plausible.Mailer.send_email(template)
|
|
|
|
|
true
|
|
|
|
|
rescue
|
|
|
|
|
_ -> false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
defp weekly_report_sent(site, time) do
|
|
|
|
|
|