mirror of
https://github.com/plausible/analytics.git
synced 2024-12-22 17:11:36 +03:00
Add grace period to upgrade
This commit is contained in:
parent
f88956ef3c
commit
29cb7462e6
@ -17,6 +17,7 @@ defmodule Plausible.Auth.User do
|
|||||||
field :name, :string
|
field :name, :string
|
||||||
field :last_seen, :naive_datetime
|
field :last_seen, :naive_datetime
|
||||||
field :trial_expiry_date, :date
|
field :trial_expiry_date, :date
|
||||||
|
field :grace_period_end, :date
|
||||||
field :theme, :string
|
field :theme, :string
|
||||||
field :email_verified, :boolean
|
field :email_verified, :boolean
|
||||||
|
|
||||||
@ -79,6 +80,10 @@ defmodule Plausible.Auth.User do
|
|||||||
change(user, trial_expiry_date: Timex.today() |> Timex.shift(days: -1))
|
change(user, trial_expiry_date: Timex.today() |> Timex.shift(days: -1))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def start_grace_period(user) do
|
||||||
|
change(user, grace_period_end: Timex.today() |> Timex.shift(days: 7))
|
||||||
|
end
|
||||||
|
|
||||||
defp trial_expiry() do
|
defp trial_expiry() do
|
||||||
if Application.get_env(:plausible, :is_selfhost) do
|
if Application.get_env(:plausible, :is_selfhost) do
|
||||||
Timex.today() |> Timex.shift(years: 100)
|
Timex.today() |> Timex.shift(years: 100)
|
||||||
|
@ -2,9 +2,9 @@ Hey <%= user_salutation(@user) %>,
|
|||||||
<br /><br />
|
<br /><br />
|
||||||
Thanks for being a Plausible Analytics subscriber!
|
Thanks for being a Plausible Analytics subscriber!
|
||||||
<br /><br />
|
<br /><br />
|
||||||
This is a friendly reminder that your traffic has exceeded your subscription tier two months in a row. Congrats on all that traffic!
|
This is a notice that your traffic has exceeded your subscription tier two months in a row. Congrats on all that traffic!
|
||||||
<br /><br />
|
<br /><br />
|
||||||
We don't enforce any hard limits at the moment, we're still counting your stats and you have access to your dashboard, but we kindly ask you to upgrade your subscription plan to accommodate your new traffic levels.
|
In order to keep your stats running, we require you to upgrade your account to accommodate your new traffic levels. If you do not upgrade your account within the next 7 days, we will lock your sites and they won't be accessible.
|
||||||
<br /><br />
|
<br /><br />
|
||||||
In the last billing cycle (<%= date_format(@last_cycle.first) %> to <%= date_format(@last_cycle.last) %>), your account has used <%= PlausibleWeb.StatsView.large_number_format(@usage) %> billable pageviews.
|
In the last billing cycle (<%= date_format(@last_cycle.first) %> to <%= date_format(@last_cycle.last) %>), your account has used <%= PlausibleWeb.StatsView.large_number_format(@usage) %> billable pageviews.
|
||||||
<%= if @usage <= 20_000_000 do %>
|
<%= if @usage <= 20_000_000 do %>
|
||||||
@ -17,8 +17,6 @@ You can upgrade your subscription using our self-serve platform. The new charge
|
|||||||
This is more than our standard plans, so please reply back to this email to get a quote for your volume.
|
This is more than our standard plans, so please reply back to this email to get a quote for your volume.
|
||||||
<% end %>
|
<% end %>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
Were the last two months extraordinary and you don't expect these higher traffic levels to continue? Reply to this email and we'll figure it out.
|
|
||||||
<br /><br />
|
|
||||||
Have questions or need help with anything? Just reply to this email and we'll gladly help.
|
Have questions or need help with anything? Just reply to this email and we'll gladly help.
|
||||||
<br /><br />
|
<br /><br />
|
||||||
Thanks again for using our product and for your support!
|
Thanks again for using our product and for your support!
|
||||||
|
@ -96,6 +96,7 @@ defmodule Plausible.Workers.CheckUsage do
|
|||||||
)
|
)
|
||||||
|
|
||||||
Plausible.Mailer.send_email_safe(template)
|
Plausible.Mailer.send_email_safe(template)
|
||||||
|
Plausible.Auth.User.start_grace_period(subscriber) |> Repo.update()
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
nil
|
nil
|
||||||
|
9
priv/repo/migrations/20211028122202_grace_period_end.exs
Normal file
9
priv/repo/migrations/20211028122202_grace_period_end.exs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
defmodule Plausible.Repo.Migrations.GracePeriodEnd do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def change do
|
||||||
|
alter table(:users) do
|
||||||
|
add :grace_period_end, :date
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -24,6 +24,7 @@ defmodule Plausible.Workers.CheckUsageTest do
|
|||||||
CheckUsage.perform(nil)
|
CheckUsage.perform(nil)
|
||||||
|
|
||||||
assert_no_emails_delivered()
|
assert_no_emails_delivered()
|
||||||
|
assert Repo.reload(user).grace_period_end == nil
|
||||||
end
|
end
|
||||||
|
|
||||||
test "does not send an email if account has been over the limit for one billing month", %{
|
test "does not send an email if account has been over the limit for one billing month", %{
|
||||||
@ -45,6 +46,7 @@ defmodule Plausible.Workers.CheckUsageTest do
|
|||||||
CheckUsage.perform(nil, billing_stub)
|
CheckUsage.perform(nil, billing_stub)
|
||||||
|
|
||||||
assert_no_emails_delivered()
|
assert_no_emails_delivered()
|
||||||
|
assert Repo.reload(user).grace_period_end == nil
|
||||||
end
|
end
|
||||||
|
|
||||||
test "sends an email when an account is over their limit for two consecutive billing months", %{
|
test "sends an email when an account is over their limit for two consecutive billing months", %{
|
||||||
@ -69,6 +71,8 @@ defmodule Plausible.Workers.CheckUsageTest do
|
|||||||
to: [user],
|
to: [user],
|
||||||
subject: "You have outgrown your Plausible subscription tier"
|
subject: "You have outgrown your Plausible subscription tier"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
assert Repo.reload(user).grace_period_end == Timex.shift(Timex.today(), days: 7)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "enterprise customers" do
|
describe "enterprise customers" do
|
||||||
|
Loading…
Reference in New Issue
Block a user