Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Remove custom domains support + update build options (#3559)

hq1a4b9c3b8ba79
diff --git a/config/runtime.exs b/config/runtime.exs
index ef71eb492a..2148fee563 100644
--- a/config/runtime.exs
+++ b/config/runtime.exs
@@ -6,7 +6,7 @@ if config_env() in [:dev, :test] do
Envy.load(["config/.env.#{config_env()}"])
end
-if config_env() == :small do
+if config_env() == :small_dev do
Envy.load(["config/.env.dev"])
end
diff --git a/config/small.exs b/config/small.exs
index eaa8a34e62..c98cd2d4ab 100644
--- a/config/small.exs
+++ b/config/small.exs
@@ -1,6 +1,6 @@
import Config
-import_config "dev.exs"
+import_config "prod.exs"
config :esbuild,
default: [
diff --git a/config/small_dev.exs b/config/small_dev.exs
new file mode 100644
index 0000000000..eaa8a34e62
--- /dev/null
+++ b/config/small_dev.exs
@@ -0,0 +1,11 @@
+import Config
+
+import_config "dev.exs"
+
+config :esbuild,
+ default: [
+ args:
+ ~w(js/app.js js/dashboard.js js/embed.host.js js/embed.content.js --bundle --target=es2017 --loader:.js=jsx --outdir=../priv/static/js --define:BUILD_EXTRA=false),
+ cd: Path.expand("../assets", __DIR__),
+ env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
+ ]
diff --git a/extra/lib/plausible/stats/sampling.ex b/extra/lib/plausible/stats/sampling.ex
new file mode 100644
index 0000000000..836ef7ce5a
--- /dev/null
+++ b/extra/lib/plausible/stats/sampling.ex
@@ -0,0 +1,41 @@
+defmodule Plausible.Stats.Sampling do
+ @moduledoc """
+ Sampling related functions
+ """
+ @default_sample_threshold 20_000_000
+
+ import Ecto.Query
+
+ @spec add_query_hint(Ecto.Query.t(), Plausible.Stats.Query.t()) :: Ecto.Query.t()
+ def add_query_hint(%Ecto.Query{} = db_query, %Plausible.Stats.Query{} = query) do
+ case query.sample_threshold do
+ :infinite ->
+ db_query
+
+ threshold ->
+ add_query_hint(db_query, threshold)
+ end
+ end
+
+ @spec add_query_hint(Ecto.Query.t(), pos_integer()) :: Ecto.Query.t()
+ def add_query_hint(%Ecto.Query{} = query, threshold) when is_integer(threshold) do
+ from(x in query, hints: [sample: threshold])
+ end
+
+ @spec add_query_hint(Ecto.Query.t()) :: Ecto.Query.t()
+ def add_query_hint(%Ecto.Query{} = query) do
+ add_query_hint(query, @default_sample_threshold)
+ end
+
+ @spec put_threshold(Plausible.Stats.Query.t(), map()) :: Plausible.Stats.Query.t()
+ def put_threshold(query, params) do
+ sample_threshold =
+ case params["sample_threshold"] do
+ nil -> @default_sample_threshold
+ "infinite" -> :infinite
+ value -> String.to_integer(value)
+ end
+
+ Map.put(query, :sample_threshold, sample_threshold)
+ end
+end
diff --git a/lib/plausible.ex b/lib/plausible.ex
index c0a2f01c45..a8fe326fa3 100644
--- a/lib/plausible.ex
+++ b/lib/plausible.ex
@@ -3,7 +3,7 @@ defmodule Plausible do
Build-related macros
"""
- @small_builds [:small, :small_test]
+ @small_builds [:small, :small_test, :small_dev]
defmacro __using__(_) do
quote do
diff --git a/lib/plausible/auth/auth.ex b/lib/plausible/auth/auth.ex
index 4248826c58..41cc124f8b 100644
--- a/lib/plausible/auth/auth.ex
+++ b/lib/plausible/auth/auth.ex
@@ -1,4 +1,5 @@
defmodule Plausible.Auth do
+ use Plausible
use Plausible.Repo
alias Plausible.Auth
@@ -56,11 +57,15 @@ defmodule Plausible.Auth do
)
end
- def is_super_admin?(nil), do: false
- def is_super_admin?(%Plausible.Auth.User{id: id}), do: is_super_admin?(id)
+ on_full_build do
+ def is_super_admin?(nil), do: false
+ def is_super_admin?(%Plausible.Auth.User{id: id}), do: is_super_admin?(id)
- def is_super_admin?(user_id) when is_integer(user_id) do
- user_id in Application.get_env(:plausible, :super_admin_user_ids)
+ def is_super_admin?(user_id) when is_integer(user_id) do
+ user_id in Application.get_env(:plausible, :super_admin_user_ids)
+ end
+ else
+ def is_super_admin?(_), do: false
end
def enterprise_configured?(nil), do: false
diff --git a/lib/plausible/auth/user.ex b/lib/plausible/auth/user.ex
index 6980da2a0d..b62c771e4a 100644
--- a/lib/plausible/auth/user.ex
+++ b/lib/plausible/auth/user.ex
@@ -11,6 +11,7 @@ defimpl FunWithFlags.Actor, for: Plausible.Auth.User do
end
defmodule Plausible.Auth.User do
+ use Plausible
use Ecto.Schema
import Ecto.Changeset
@@ -209,10 +210,10 @@ defmodule Plausible.Auth.User do
end
defp trial_expiry() do
- if Application.get_env(:plausible, :is_selfhost) do
- Timex.today() |> Timex.shift(years: 100)
- else
+ on_full_build do
Timex.today() |> Timex.shift(days: 30)
+ else
+ Timex.today() |> Timex.shift(years: 100)
end
end
diff --git a/lib/plausible/billing/billing.ex b/lib/plausible/billing/billing.ex
index 0ae80dcf89..ccab138358 100644
--- a/lib/plausible/billing/billing.ex
+++ b/lib/plausible/billing/billing.ex
@@ -1,4 +1,5 @@
defmodule Plausible.Billing do
+ use Plausible
use Plausible.Repo
require Plausible.Billing.Subscription.Status
alias Plausible.Billing.{Subscription, Plans, Quota}
@@ -116,11 +117,15 @@ defmodule Plausible.Billing do
defp subscription_is_active?(%Subscription{}), do: false
defp subscription_is_active?(nil), do: false
- def on_trial?(%Plausible.Auth.User{trial_expiry_date: nil}), do: false
+ on_full_build do
+ def on_trial?(%Plausible.Auth.User{trial_expiry_date: nil}), do: false
- def on_trial?(user) do
- user = Plausible.Users.with_subscription(user)
- !subscription_is_active?(user.subscription) && trial_days_left(user) >= 0
+ def on_trial?(user) do
+ user = Plausible.Users.with_subscription(user)
+ !subscription_is_active?(user.subscription) && trial_days_left(user) >= 0
+ end
+ else
+ def on_trial?(_), do: false
end
def trial_days_left(user) do
diff --git a/lib/plausible/billing/quota.ex b/lib/plausible/billing/quota.ex
index e747e7284d..24b7406a2b 100644
--- a/lib/plausible/billing/quota.ex
+++ b/lib/plausible/billing/quota.ex
@@ -26,44 +26,51 @@ defmodule Plausible.Billing.Quota do
end
end
- @limit_sites_since ~D[2021-05-05]
- @spec site_limit(User.t()) :: non_neg_integer() | :unlimited
@doc """
Returns the limit of sites a user can have.
For enterprise customers, returns :unlimited. The site limit is checked in a
background job so as to avoid service disruption.
"""
- def site_limit(user) do
- cond do
- Application.get_env(:plausible, :is_selfhost) -> :unlimited
- Timex.before?(user.inserted_at, @limit_sites_since) -> :unlimited
- true -> get_site_limit_from_plan(user)
+ on_full_build do
+ @limit_sites_since ~D[2021-05-05]
+ @spec site_limit(User.t()) :: non_neg_integer() | :unlimited
+ def site_limit(user) do
+ if Timex.before?(user.inserted_at, @limit_sites_since) do
+ :unlimited
+ else
+ get_site_limit_from_plan(user)
+ end
end
- end
- @site_limit_for_trials 10
- @site_limit_for_legacy_trials 50
- @site_limit_for_free_10k 50
- defp get_site_limit_from_plan(user) do
- user = Plausible.Users.with_subscription(user)
+ @site_limit_for_trials 10
+ @site_limit_for_legacy_trials 50
+ @site_limit_for_free_10k 50
+ defp get_site_limit_from_plan(user) do
+ user = Plausible.Users.with_subscription(user)
- case Plans.get_subscription_plan(user.subscription) do
- %EnterprisePlan{} ->
- :unlimited
+ case Plans.get_subscription_plan(user.subscription) do
+ %EnterprisePlan{} ->
+ :unlimited
- %Plan{site_limit: site_limit} ->
- site_limit
+ %Plan{site_limit: site_limit} ->
+ site_limit
- :free_10k ->
- @site_limit_for_free_10k
+ :free_10k ->
+ @site_limit_for_free_10k
- nil ->
- if Timex.before?(user.inserted_at, Plans.business_tier_launch()) do
- @site_limit_for_legacy_trials
- else
- @site_limit_for_trials
- end
+ nil ->
+ if Timex.before?(user.inserted_at, Plans.business_tier_launch()) do
+ @site_limit_for_legacy_trials
+ else
+ @site_limit_for_trials
+ end
+ end
+ end
+ else
+ @spec site_limit(any()) :: non_neg_integer() | :unlimited
+ def site_limit(_) do
+ :unlimited
end
end
@@ -203,13 +210,7 @@ defmodule Plausible.Billing.Quota do
stats_api_usage = from a in Plausible.Auth.ApiKey, where: a.user_id == ^user.id
queries =
- if Plausible.Release.selfhost?() do
- [
- {Props, props_usage_query},
- {RevenueGoals, revenue_goals_usage},
- {StatsAPI, stats_api_usage}
- ]
- else
+ on_full_build do
funnels_usage_query =
from f in "funnels",
inner_join: os in subquery(owned_sites_query(user)),
@@ -221,6 +222,12 @@ defmodule Plausible.Billing.Quota do
{RevenueGoals, revenue_goals_usage},
{StatsAPI, stats_api_usage}
]
+ else
+ [
+ {Props, props_usage_query},
+ {RevenueGoals, revenue_goals_usage},
+ {StatsAPI, stats_api_usage}
+ ]
end
Enum.reduce(queries, [], fn {feature, query}, acc ->
diff --git a/lib/plausible/plugins/api/token.ex b/lib/plausible/plugins/api/token.ex
index 4330da0d99..4f64ccbe84 100644
--- a/lib/plausible/plugins/api/token.ex
+++ b/lib/plausible/plugins/api/token.ex
@@ -10,6 +10,7 @@ defmodule Plausible.Plugins.API.Token do
It is prefixed with a plain text identifier allowing source scanning
for leaked secrets.
"""
+ use Plausible
use Ecto.Schema
import Ecto.Changeset
@@ -63,10 +64,15 @@ defmodule Plausible.Plugins.API.Token do
can scan repositories for accidental secret commits.
"""
def prefix() do
- case {Plausible.Release.selfhost?(), Application.get_env(:plausible, :environment)} do
- {true, _} -> "plausible-plugin-selfhost"
- {false, "prod"} -> "plausible-plugin"
- {false, env} -> "plausible-plugin-#{env}"
+ on_full_build do
+ env = Application.get_env(:plausible, :environment)
+
+ case env do
+ "prod" -> "plausible-plugin"
+ env -> "plausible-plugin-#{env}"
+ end
+ else
+ "plausible-plugin-selfhost"
end
end
diff --git a/lib/plausible/site.ex b/lib/plausible/site.ex
index f18fc5b034..35b9dc2e50 100644
--- a/lib/plausible/site.ex
+++ b/lib/plausible/site.ex
@@ -39,7 +39,6 @@ defmodule Plausible.Site do
has_one :google_auth, GoogleAuth
has_one :weekly_report, Plausible.Site.WeeklyReport
has_one :monthly_report, Plausible.Site.MonthlyReport
- has_one :custom_domain, Plausible.Site.CustomDomain
has_one :spike_notification, Plausible.Site.SpikeNotification
has_one :ownership, Plausible.Site.Membership, where: [role: :owner]
has_one :owner, through: [:ownership, :user]
@@ -49,7 +48,7 @@ defmodule Plausible.Site do
# strictly necessary.
field :from_cache?, :boolean, virtual: true, default: false
- # Used in the context of paginated sites list to order in relation to
+ # Used in the context of paginated sites list to order in relation to
# user's membership state. Currently it can be either "invitation",
# "pinned_site" or "site", where invitations are first.
field :entry_type, :string, virtual: true
diff --git a/lib/plausible/site/custom_domain.ex b/lib/plausible/site/custom_domain.ex
deleted file mode 100644
index 325b72bb04..0000000000
--- a/lib/plausible/site/custom_domain.ex
+++ /dev/null
@@ -1,11 +0,0 @@
-defmodule Plausible.Site.CustomDomain do
- use Ecto.Schema
-
- schema "custom_domains" do
- field :domain, :string
- field :has_ssl_certificate, :boolean
- belongs_to :site, Plausible.Site
-
- timestamps()
- end
-end
diff --git a/lib/plausible/site/memberships/accept_invitation.ex b/lib/plausible/site/memberships/accept_invitation.ex
index 4ba1720a11..a96b16c976 100644
--- a/lib/plausible/site/memberships/accept_invitation.ex
+++ b/lib/plausible/site/memberships/accept_invitation.ex
@@ -50,7 +50,7 @@ defmodule Plausible.Site.Memberships.AcceptInvitation do
@spec accept_invitation(String.t(), Auth.User.t(), Keyword.t()) ::
{:ok, Site.Membership.t()} | {:error, :invitation_not_found | Ecto.Changeset.t()}
def accept_invitation(invitation_id, user, opts \\ []) do
- selfhost? = Keyword.get(opts, :selfhost?, Plausible.Release.selfhost?())
+ selfhost? = Keyword.get(opts, :selfhost?, small_build?())
with {:ok, invitation} <- Invitations.find_for_user(invitation_id, user) do
membership = get_or_create_membership(invitation, user)
diff --git a/lib/plausible/stats/base.ex b/lib/plausible/stats/base.ex
index ecdb922ff9..684d2676fa 100644
--- a/lib/plausible/stats/base.ex
+++ b/lib/plausible/stats/base.ex
@@ -4,8 +4,6 @@ defmodule Plausible.Stats.Base do
alias Plausible.Stats.{Query, Filters}
import Ecto.Query
- # Ecto typespec has not been updated for this PR: https://github.com/elixir-ecto/ecto/pull/3592
- @dialyzer {:nowarn_function, add_sample_hint: 2}
@no_ref "Direct / None"
@not_set "(not set)"
@@ -40,7 +38,10 @@ defmodule Plausible.Stats.Base do
where: e.site_id == ^site.id,
where: e.timestamp >= ^first_datetime and e.timestamp < ^last_datetime
)
- |> add_sample_hint(query)
+
+ on_full_build do
+ q = Plausible.Stats.Sampling.add_query_hint(q, query)
+ end
q = from(e in q, where: ^dynamic_filter_condition(query, "event:page", :pathname))
@@ -211,8 +212,12 @@ defmodule Plausible.Stats.Base do
where: s.site_id == ^site.id,
where: s.start >= ^first_datetime and s.start < ^last_datetime
)
- |> add_sample_hint(query)
- |> filter_by_entry_props(query)
+
+ on_full_build do
+ sessions_q = Plausible.Stats.Sampling.add_query_hint(sessions_q, query)
+ end
+
+ sessions_q = filter_by_entry_props(sessions_q, query)
Enum.reduce(Filters.visit_props(), sessions_q, fn prop_name, sessions_q ->
filter_key = "visit:" <> prop_name
@@ -549,16 +554,6 @@ defmodule Plausible.Stats.Base do
end)
end
- defp add_sample_hint(db_q, query) do
- case query.sample_threshold do
- :infinite ->
- db_q
-
- threshold ->
- from(e in db_q, hints: [sample: threshold])
- end
- end
-
defp split_goals(clauses, map_fn \\ &Function.identity/1) do
groups =
Enum.group_by(clauses, fn {goal_type, _v} -> goal_type end, fn {_k, val} -> map_fn.(val) end)
diff --git a/lib/plausible/stats/clickhouse.ex b/lib/plausible/stats/clickhouse.ex
index adefd18228..909f71f566 100644
--- a/lib/plausible/stats/clickhouse.ex
+++ b/lib/plausible/stats/clickhouse.ex
@@ -1,4 +1,5 @@
defmodule Plausible.Stats.Clickhouse do
+ use Plausible
use Plausible.Repo
use Plausible.ClickhouseRepo
use Plausible.Stats.Fragments
@@ -236,7 +237,6 @@ defmodule Plausible.Stats.Clickhouse do
current_q =
from(
e in "events_v2",
- hints: [sample: 20_000_000],
join: total_q in subquery(total_q),
on: e.site_id == total_q.site_id,
where: e.site_id in ^Map.keys(site_id_to_domain_mapping),
@@ -252,6 +252,10 @@ defmodule Plausible.Stats.Clickhouse do
order_by: [e.site_id, fragment("toStartOfHour(timestamp)")]
)
+ on_full_build do
+ current_q = Plausible.Stats.Sampling.add_query_hint(current_q)
+ end
+
result =
current_q
|> ClickhouseRepo.all()
@@ -275,17 +279,22 @@ defmodule Plausible.Stats.Clickhouse do
end
defp visitors_24h_total(now, offset1, offset2, site_id_to_domain_mapping) do
- from(e in "events_v2",
- hints: [sample: 20_000_000],
- where: e.site_id in ^Map.keys(site_id_to_domain_mapping),
- where: e.timestamp >= ^NaiveDateTime.add(now, offset1, :hour),
- where: e.timestamp <= ^NaiveDateTime.add(now, offset2, :hour),
- select: %{
- site_id: e.site_id,
- total_visitors: fragment("toUInt64(round(uniq(user_id) * any(_sample_factor)))")
- },
- group_by: [e.site_id]
- )
+ query =
+ from e in "events_v2",
+ where: e.site_id in ^Map.keys(site_id_to_domain_mapping),
+ where: e.timestamp >= ^NaiveDateTime.add(now, offset1, :hour),
+ where: e.timestamp <= ^NaiveDateTime.add(now, offset2, :hour),
+ select: %{
+ site_id: e.site_id,
+ total_visitors: fragment("toUInt64(round(uniq(user_id) * any(_sample_factor)))")
+ },
+ group_by: [e.site_id]
+
+ on_full_build do
+ query = Plausible.Stats.Sampling.add_query_hint(query)
+ end
+
+ query
end
defp empty_24h_intervals(now) do
@@ -306,11 +315,14 @@ defmodule Plausible.Stats.Clickhouse do
q =
from(s in "sessions_v2",
- hints: ["SAMPLE 10000000"],
where: s.site_id == ^site.id,
where: s.timestamp >= ^first_datetime and s.start < ^last_datetime
)
+ on_full_build do
+ q = Plausible.Stats.Sampling.add_query_hint(q, 10_000_000)
+ end
+
q =
if query.filters["source"] do
source = query.filters["source"]
@@ -425,11 +437,14 @@ defmodule Plausible.Stats.Clickhouse do
q =
from(e in "events_v2",
- hints: ["SAMPLE 10000000"],
where: e.site_id == ^site.id,
where: e.timestamp >= ^first_datetime and e.timestamp < ^last_datetime
)
+ on_full_build do
+ q = Plausible.Stats.Sampling.add_query_hint(q, 10_000_000)
+ end
+
q =
if query.filters["screen"] do
size = query.filters["screen"]
diff --git a/lib/plausible/stats/query.ex b/lib/plausible/stats/query.ex
index 6c52f79e9e..d00b27eaab 100644
--- a/lib/plausible/stats/query.ex
+++ b/lib/plausible/stats/query.ex
@@ -1,4 +1,6 @@
defmodule Plausible.Stats.Query do
+ use Plausible
+
defstruct date_range: nil,
interval: nil,
period: nil,
@@ -7,19 +9,24 @@ defmodule Plausible.Stats.Query do
imported_data_requested: false,
include_imported: false
- @default_sample_threshold 20_000_000
require OpenTelemetry.Tracer, as: Tracer
alias Plausible.Stats.{FilterParser, Interval}
@type t :: %__MODULE__{}
def from(site, params) do
- query_by_period(site, params)
- |> put_interval(params)
- |> put_parsed_filters(params)
- |> put_imported_opts(site, params)
- |> put_sample_threshold(params)
- |> maybe_drop_prop_filter(site)
+ query =
+ query_by_period(site, params)
+ |> put_interval(params)
+ |> put_parsed_filters(params)
+ |> put_imported_opts(site, params)
+ |> maybe_drop_prop_filter(site)
+
+ on_full_build do
+ query = Plausible.Stats.Sampling.put_threshold(query, params)
+ end
+
+ query
end
defp query_by_period(site, %{"period" => "realtime"}) do
@@ -163,17 +170,6 @@ defmodule Plausible.Stats.Query do
Map.put(query, :filters, FilterParser.parse_filters(params["filters"]))
end
- defp put_sample_threshold(query, params) do
- sample_threshold =
- case params["sample_threshold"] do
- nil -> @default_sample_threshold
- "infinite" -> :infinite
- value -> String.to_integer(value)
- end
-
- Map.put(query, :sample_threshold, sample_threshold)
- end
-
def put_filter(query, key, val) do
%__MODULE__{
query
diff --git a/lib/plausible_release.ex b/lib/plausible_release.ex
index 766873ff20..057e3bc53b 100644
--- a/lib/plausible_release.ex
+++ b/lib/plausible_release.ex
@@ -1,4 +1,5 @@
defmodule Plausible.Release do
+ use Plausible
use Plausible.Repo
require Logger
@@ -10,13 +11,12 @@ defmodule Plausible.Release do
:ecto
]
- @spec selfhost? :: boolean
- def selfhost? do
- Application.fetch_env!(@app, :is_selfhost)
- end
-
def should_be_first_launch? do
- selfhost?() and not (_has_users? = Repo.exists?(Plausible.Auth.User))
+ on_full_build do
+ false
+ else
+ not (_has_users? = Repo.exists?(Plausible.Auth.User))
+ end
end
def migrate do
diff --git a/lib/plausible_web/controllers/auth_controller.ex b/lib/plausible_web/controllers/auth_controller.ex
index a54b348518..d30bff50df 100644
--- a/lib/plausible_web/controllers/auth_controller.ex
+++ b/lib/plausible_web/controllers/auth_controller.ex
@@ -31,12 +31,6 @@ defmodule PlausibleWeb.AuthController do
]
)
- plug(:assign_is_selfhost)
-
- defp assign_is_selfhost(conn, _opts) do
- assign(conn, :is_selfhost, Plausible.Release.selfhost?())
- end
-
def register(conn, %{"user" => %{"email" => email, "password" => password}}) do
with {:ok, user} <- login_user(conn, email, password) do
conn = set_user_session(conn, user)
diff --git a/lib/plausible_web/controllers/site_controller.ex b/lib/plausible_web/controllers/site_controller.ex
index c4a493c01a..0b99499399 100644
--- a/lib/plausible_web/controllers/site_controller.ex
+++ b/lib/plausible_web/controllers/site_controller.ex
@@ -61,7 +61,7 @@ defmodule PlausibleWeb.SiteController do
def add_snippet(conn, _params) do
user = conn.assigns[:current_user]
- site = conn.assigns[:site] |> Repo.preload(:custom_domain)
+ site = conn.assigns[:site]
is_first_site =
!Repo.exists?(
@@ -121,9 +121,7 @@ defmodule PlausibleWeb.SiteController do
end
def settings_general(conn, _params) do
- site =
- conn.assigns[:site]
- |> Repo.preload([:custom_domain])
+ site = conn.assigns[:site]
conn
|> render("settings_general.html",
@@ -137,7 +135,7 @@ defmodule PlausibleWeb.SiteController do
def settings_people(conn, _params) do
site =
conn.assigns[:site]
- |> Repo.preload(memberships: :user, invitations: [], custom_domain: [])
+ |> Repo.preload(memberships: :user, invitations: [])
conn
|> render("settings_people.html",
@@ -148,7 +146,7 @@ defmodule PlausibleWeb.SiteController do
end
def settings_visibility(conn, _params) do
- site = conn.assigns[:site] |> Repo.preload(:custom_domain)
+ site = conn.assigns[:site]
shared_links = Repo.all(from l in Plausible.Site.SharedLink, where: l.site_id == ^site.id)
conn
@@ -161,7 +159,7 @@ defmodule PlausibleWeb.SiteController do
end
def settings_goals(conn, _params) do
- site = Repo.preload(conn.assigns[:site], [:custom_domain, :owner])
+ site = Repo.preload(conn.assigns[:site], [:owner])
owner = Plausible.Users.with_subscription(site.owner)
site = Map.put(site, :owner, owner)
@@ -175,7 +173,7 @@ defmodule PlausibleWeb.SiteController do
end
def settings_funnels(conn, _params) do
- site = Repo.preload(conn.assigns[:site], [:custom_domain, :owner])
+ site = Repo.preload(conn.assigns[:site], [:owner])
owner = Plausible.Users.with_subscription(site.owner)
site = Map.put(site, :owner, owner)
@@ -189,7 +187,7 @@ defmodule PlausibleWeb.SiteController do
end
def settings_props(conn, _params) do
- site = Repo.preload(conn.assigns[:site], [:custom_domain, :owner])
+ site = Repo.preload(conn.assigns[:site], [:owner])
owner = Plausible.Users.with_subscription(site.owner)
site = Map.put(site, :owner, owner)
@@ -203,7 +201,7 @@ defmodule PlausibleWeb.SiteController do
end
def settings_email_reports(conn, _params) do
- site = conn.assigns[:site] |> Repo.preload(:custom_domain)
+ site = conn.assigns[:site]
conn
|> render("settings_email_reports.html",
@@ -216,21 +214,8 @@ defmodule PlausibleWeb.SiteController do
)
end
- def settings_custom_domain(conn, _params) do
- site =
- conn.assigns[:site]
- |> Repo.preload(:custom_domain)
-
- conn
- |> assign(:skip_plausible_tracking, true)
- |> render("settings_custom_domain.html",
- site: site,
- layout: {PlausibleWeb.LayoutView, "site_settings.html"}
- )
- end
-
def settings_danger_zone(conn, _params) do
- site = conn.assigns[:site] |> Repo.preload(:custom_domain)
+ site = conn.assigns[:site]
conn
|> render("settings_danger_zone.html",
@@ -243,7 +228,7 @@ defmodule PlausibleWeb.SiteController do
def settings_integrations(conn, _params) do
site =
conn.assigns.site
- |> Repo.preload([:google_auth, :custom_domain])
+ |> Repo.preload([:google_auth])
search_console_domains =
if site.google_auth do
@@ -295,7 +280,7 @@ defmodule PlausibleWeb.SiteController do
end
def update_settings(conn, %{"site" => site_params}) do
- site = conn.assigns[:site] |> Repo.preload(:custom_domain)
+ site = conn.assigns[:site]
changeset = Plausible.Site.update_changeset(site, site_params)
case Repo.update(changeset) do
@@ -624,27 +609,6 @@ defmodule PlausibleWeb.SiteController do
end
end
- def delete_custom_domain(conn, %{"id" => domain_id}) do
- site = conn.assigns[:site]
- site_id = site.id
-
- case Repo.delete_all(
- from d in Plausible.Site.CustomDomain,
- where: d.site_id == ^site_id,
- where: d.id == ^domain_id
- ) do
- {1, _} ->
- conn
- |> put_flash(:success, "Custom domain deleted successfully")
- |> redirect(to: "/#{URI.encode_www_form(site.domain)}/settings/general")
-
- {0, _} ->
- conn
- |> put_flash(:error, "Failed to delete custom domain")
- |> redirect(to: "/#{URI.encode_www_form(site.domain)}/settings/general")
- end
- end
-
def import_from_google_user_metric_notice(conn, %{
"view_id" => view_id,
"access_token" => access_token,
@@ -874,7 +838,7 @@ defmodule PlausibleWeb.SiteController do
end
def add_snippet_after_domain_change(conn, _params) do
- site = conn.assigns[:site] |> Repo.preload(:custom_domain)
+ site = conn.assigns[:site]
conn
|> assign(:skip_plausible_tracking, true)
diff --git a/lib/plausible_web/controllers/stats_controller.ex b/lib/plausible_web/controllers/stats_controller.ex
index 149ca599d1..ff149aa777 100644
--- a/lib/plausible_web/controllers/stats_controller.ex
+++ b/lib/plausible_web/controllers/stats_controller.ex
@@ -363,14 +363,13 @@ defmodule PlausibleWeb.StatsController do
end
defp is_dbip() do
- is_or_nil =
- if Application.get_env(:plausible, :is_selfhost) do
- if type = Plausible.Geo.database_type() do
- String.starts_with?(type, "DBIP")
- end
- end
-
- !!is_or_nil
+ on_full_build do
+ false
+ else
+ Plausible.Geo.database_type()
+ |> to_string()
+ |> String.starts_with?("DBIP")
+ end
end
defp title(%{path_info: ["plausible.io"]}, _) do
diff --git a/lib/plausible_web/live/goal_settings/form.ex b/lib/plausible_web/live/goal_settings/form.ex
index 1a5b282332..4da4681cfa 100644
--- a/lib/plausible_web/live/goal_settings/form.ex
+++ b/lib/plausible_web/live/goal_settings/form.ex
@@ -24,7 +24,7 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do
site =
user_id
|> Plausible.Sites.get_for_user!(domain, [:owner, :admin, :super_admin])
- |> Repo.preload([:custom_domain, :owner])
+ |> Repo.preload([:owner])
owner = Plausible.Users.with_subscription(site.owner)
site = Map.put(site, :owner, owner)
diff --git a/lib/plausible_web/live/register_form.ex b/lib/plausible_web/live/register_form.ex
index 143ca30ded..258c6b52a3 100644
--- a/lib/plausible_web/live/register_form.ex
+++ b/lib/plausible_web/live/register_form.ex
@@ -5,6 +5,7 @@ defmodule PlausibleWeb.Live.RegisterForm do
use Phoenix.LiveView
use Phoenix.HTML
+ use Plausible
import PlausibleWeb.Live.Components.Form
@@ -37,7 +38,6 @@ defmodule PlausibleWeb.Live.RegisterForm do
form: to_form(changeset),
captcha_error: nil,
password_strength: Auth.User.password_strength(changeset),
- is_selfhost: Plausible.Release.selfhost?(),
trigger_submit: false
)}
end
@@ -68,7 +68,7 @@ defmodule PlausibleWeb.Live.RegisterForm do
~H"""
<div class="mx-auto mt-6 text-center dark:text-gray-300">
<h1 class="text-3xl font-black">
- <%= if @is_selfhost or @live_action == :register_from_invitation_form do %>
+ <%= if small_build?() or @live_action == :register_from_invitation_form do %>
Register your Plausible Analytics account
<% else %>
Register your 30-day free trial
@@ -162,7 +162,7 @@ defmodule PlausibleWeb.Live.RegisterForm do
<% end %>
<% submit_text =
- if @is_selfhost or @invitation do
+ if small_build?() or @invitation do
"Create my account →"
else
"Start my free trial →"
diff --git a/lib/plausible_web/plugs/first_launch_plug.ex b/lib/plausible_web/plugs/first_launch_plug.ex
index 6588e338bf..8bf81056a5 100644
--- a/lib/plausible_web/plugs/first_launch_plug.ex
+++ b/lib/plausible_web/plugs/first_launch_plug.ex
@@ -3,6 +3,17 @@ defmodule PlausibleWeb.FirstLaunchPlug do
Redirects first-launch users to registration page.
"""
+ defmodule Test do
+ @moduledoc """
+ Test helper for setup blocks allowing to skip the plug processing
+ """
+ @spec skip(map()) :: {:ok, map()}
+ def skip(context) do
+ conn = Plug.Conn.put_private(context.conn, PlausibleWeb.FirstLaunchPlug, :skip)
+ {:ok, Map.put(context, :conn, conn)}
+ end
+ end
+
@behaviour Plug
alias Plausible.Release
@@ -12,6 +23,7 @@ defmodule PlausibleWeb.FirstLaunchPlug do
end
@impl true
+ def call(%Plug.Conn{private: %{__MODULE__ => :skip}} = conn, _), do: conn
def call(%Plug.Conn{request_path: path} = conn, path), do: conn
def call(conn, redirect_to) do
diff --git a/lib/plausible_web/plugs/maybe_disable_registration.ex b/lib/plausible_web/plugs/maybe_disable_registration.ex
index 5cfdc7afcb..7c05a7b910 100644
--- a/lib/plausible_web/plugs/maybe_disable_registration.ex
+++ b/lib/plausible_web/plugs/maybe_disable_registration.ex
@@ -20,18 +20,13 @@ defmodule PlausibleWeb.Plugs.MaybeDisableRegistration do
disable_registration = Keyword.fetch!(selfhost_config, :disable_registration)
first_launch? = Release.should_be_first_launch?()
- cond do
- first_launch? ->
- conn
-
- disable_registration in disabled_for ->
- conn
- |> put_flash(:error, "Registration is disabled on this instance")
- |> redirect(to: Routes.auth_path(conn, :login_form))
- |> halt()
-
- true ->
- conn
+ if not first_launch? and disable_registration in disabled_for do
+ conn
+ |> put_flash(:error, "Registration is disabled on this instance")
+ |> redirect(to: Routes.auth_path(conn, :login_form))
+ |> halt()
+ else
+ conn
end
end
end
diff --git a/lib/plausible_web/router.ex b/lib/plausible_web/router.ex
index d8bfc57e1a..b6d1e00c95 100644
--- a/lib/plausible_web/router.ex
+++ b/lib/plausible_web/router.ex
@@ -10,7 +10,7 @@ defmodule PlausibleWeb.Router do
plug :fetch_live_flash
plug :put_secure_browser_headers
plug PlausibleWeb.Plugs.NoRobots
- plug PlausibleWeb.FirstLaunchPlug, redirect_to: "/register"
+ on_full_build(do: nil, else: plug(PlausibleWeb.FirstLaunchPlug, redirect_to: "/register"))
plug PlausibleWeb.SessionTimeoutPlug, timeout_after_seconds: @two_weeks_in_seconds
plug PlausibleWeb.AuthPlug
plug PlausibleWeb.LastSeenPlug
@@ -278,8 +278,6 @@ defmodule PlausibleWeb.Router do
put "/sites/:website/shared-links/:slug", SiteController, :update_shared_link
delete "/sites/:website/shared-links/:slug", SiteController, :delete_shared_link
- delete "/sites/:website/custom-domains/:id", SiteController, :delete_custom_domain
-
get "/sites/:website/memberships/invite", Site.MembershipController, :invite_member_form
post "/sites/:website/memberships/invite", Site.MembershipController, :invite_member
@@ -311,7 +309,6 @@ defmodule PlausibleWeb.Router do
end
get "/:website/settings/email-reports", SiteController, :settings_email_reports
- get "/:website/settings/custom-domain", SiteController, :settings_custom_domain
get "/:website/settings/danger-zone", SiteController, :settings_danger_zone
get "/:website/settings/integrations", SiteController, :settings_integrations
diff --git a/lib/plausible_web/templates/auth/activate.html.eex b/lib/plausible_web/templates/auth/activate.html.eex
deleted file mode 100644
index 789c97d94e..0000000000
--- a/lib/plausible_web/templates/auth/activate.html.eex
+++ /dev/null
@@ -1,71 +0,0 @@
-<div class="w-full max-w-3xl mt-4 mx-auto flex">
- <%= if @has_email_code? do %>
- <%= form_for @conn, "/activate", [class: "w-full max-w-lg mx-auto bg-white dark:bg-gray-800 shadow-md rounded px-8 py-6 mb-4 mt-8"], fn f -> %>
- <h2 class="text-xl font-black dark:text-gray-100">
- <%= if @has_any_memberships? do %>
- Verify your email address
- <% else %>
- Activate your account
- <% end %>
- </h2>
-
- <div class="mt-2 text-sm text-gray-500 dark:text-gray-200 leading-tight">
- Please enter the 4-digit code we sent to <b><%= @conn.assigns[:current_user].email %></b>
- </div>
-
- <div class="mt-12 flex items-stretch flex-grow">
- <div>
- <%= text_input f, :code, class: "tracking-widest font-medium shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-36 px-8 border-gray-300 dark:border-gray-500 rounded-l-md dark:text-gray-200 dark:bg-gray-900", oninput: "this.value=this.value.replace(/[^0-9]/g, ''); if (this.value.length >= 4) document.getElementById('submit').focus()", onclick: "this.select();", maxlength: "4", placeholder: "••••", style: "letter-spacing: 10px;", required: "required" %>
- </div>
- <button id="submit" class="button rounded-l-none">Activate &rarr;</button>
- </div>
- <%= error_tag(assigns, :error) %>
-
- <div class="mt-16 text-sm dark:text-gray-100">
- Didn't receive an email?
- </div>
- <ol class="list-disc text-xs text-gray-500 leading-tight space-y-1 mt-1">
- <li>Check your spam folder</li>
- <li><%= link("Send a new code", class: "underline text-indigo-600", to: "/activate/request-code", method: :post) %> to <%= @conn.assigns[:current_user].email %></li>
- <%= if Application.get_env(:plausible, :is_selfhost) do %>
- <li>Ask on our <%= link("community-supported forum", to: "https://github.com/plausible/analytics/discussions", class: "text-indigo-600 underline" ) %></li>
- <% else %>
- <li><a class="underline text-indigo-600" href="https://plausible.io/contact">Contact us</a> if the problem persists</li>
- <% end %>
- </ol>
- <div class="mt-4 text-sm dark:text-gray-100">
- Entered the wrong email address?
- </div>
- <ul class="list-disc text-xs text-gray-500 leading-tight mt-1">
- <%= if @has_any_memberships? do %>
- <li>
- <%= link("Change email back to", class: "underline text-indigo-600", to: "/settings/email/cancel", method: "post") %> to <%= @conn.assigns[:current_user].previous_email %>
- </li>
- <% else %>
- <li>
- <%= link("Delete this account", class: "underline text-indigo-600", to: "/me?redirect=/register", method: "delete", data: [confirm: "Deleting your account cannot be reversed. Are you sure?"]) %> and start over
- </li>
- <% end %>
- </ul>
- <% end %>
- <% else %>
- <div class="w-full max-w-lg mx-auto bg-white dark:bg-gray-800 shadow-md rounded px-8 py-6 mb-4 mt-8">
- <h2 class="text-xl font-black dark:text-gray-100">Activate your account</h2>
-
- <div class="mt-2 text-sm text-gray-500 dark:text-gray-200 leading-tight">
- A 4-digit activation code will be sent to <b><%= @conn.assigns[:current_user].email %></b>
- </div>
-
- <%= error_tag(assigns, :error) %>
-
- <%= button("Request activation code", to: "/activate/request-code", method: :post, class: "button mt-12") %>
-
- </div>
- <% end %>
-
- <%= if !@has_any_invitations? and !@has_any_memberships? do %>
- <div class="pt-12 pl-8 hidden md:block">
- <%= render(PlausibleWeb.AuthView, "_onboarding_steps.html", current_step: 1) %>
- </div>
- <% end %>
-</div>
diff --git a/lib/plausible_web/templates/auth/activate.html.heex b/lib/plausible_web/templates/auth/activate.html.heex
new file mode 100644
index 0000000000..93e940525a
--- /dev/null
+++ b/lib/plausible_web/templates/auth/activate.html.heex
@@ -0,0 +1,109 @@
+<div class="w-full max-w-3xl mt-4 mx-auto flex">
+ <%= if @has_email_code? do %>
+ <%= form_for @conn, "/activate", [class: "w-full max-w-lg mx-auto bg-white dark:bg-gray-800 shadow-md rounded px-8 py-6 mb-4 mt-8"], fn f -> %>
+ <h2 class="text-xl font-black dark:text-gray-100">
+ <%= if @has_any_memberships? do %>
+ Verify your email address
+ <% else %>
+ Activate your account
+ <% end %>
+ </h2>
+
+ <div class="mt-2 text-sm text-gray-500 dark:text-gray-200 leading-tight">
+ Please enter the 4-digit code we sent to <b><%= @conn.assigns[:current_user].email %></b>
+ </div>
+
+ <div class="mt-12 flex items-stretch flex-grow">
+ <div>
+ <%= text_input(f, :code,
+ class:
+ "tracking-widest font-medium shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-36 px-8 border-gray-300 dark:border-gray-500 rounded-l-md dark:text-gray-200 dark:bg-gray-900",
+ oninput:
+ "this.value=this.value.replace(/[^0-9]/g, ''); if (this.value.length >= 4) document.getElementById('submit').focus()",
+ onclick: "this.select();",
+ maxlength: "4",
+ placeholder: "••••",
+ style: "letter-spacing: 10px;",
+ required: "required"
+ ) %>
+ </div>
+ <button id="submit" class="button rounded-l-none">Activate &rarr;</button>
+ </div>
+ <%= error_tag(assigns, :error) %>
+
+ <div class="mt-16 text-sm dark:text-gray-100">
+ Didn't receive an email?
+ </div>
+ <ol class="list-disc text-xs text-gray-500 leading-tight space-y-1 mt-1">
+ <li>Check your spam folder</li>
+ <li>
+ <%= link("Send a new code",
+ class: "underline text-indigo-600",
+ to: "/activate/request-code",
+ method: :post
+ ) %> to <%= @conn.assigns[:current_user].email %>
+ </li>
+ <%= if full_build?() do %>
+ <li>
+ <a class="underline text-indigo-600" href="https://plausible.io/contact">
+ Contact us
+ </a>
+ if the problem persists
+ </li>
+ <% else %>
+ <li>
+ Ask on our <%= link("community-supported forum",
+ to: "https://github.com/plausible/analytics/discussions",
+ class: "text-indigo-600 underline"
+ ) %>
+ </li>
+ <% end %>
+ </ol>
+ <div class="mt-4 text-sm dark:text-gray-100">
+ Entered the wrong email address?
+ </div>
+ <ul class="list-disc text-xs text-gray-500 leading-tight mt-1">
+ <%= if @has_any_memberships? do %>
+ <li>
+ <%= link("Change email back to",
+ class: "underline text-indigo-600",
+ to: "/settings/email/cancel",
+ method: "post"
+ ) %> to <%= @conn.assigns[:current_user].previous_email %>
+ </li>
+ <% else %>
+ <li>
+ <%= link("Delete this account",
+ class: "underline text-indigo-600",
+ to: "/me?redirect=/register",
+ method: "delete",
+ data: [confirm: "Deleting your account cannot be reversed. Are you sure?"]
+ ) %> and start over
+ </li>
+ <% end %>
+ </ul>
+ <% end %>
+ <% else %>
+ <div class="w-full max-w-lg mx-auto bg-white dark:bg-gray-800 shadow-md rounded px-8 py-6 mb-4 mt-8">
+ <h2 class="text-xl font-black dark:text-gray-100">Activate your account</h2>
+
+ <div class="mt-2 text-sm text-gray-500 dark:text-gray-200 leading-tight">
+ A 4-digit activation code will be sent to <b><%= @conn.assigns[:current_user].email %></b>
+ </div>
+
+ <%= error_tag(assigns, :error) %>
+
+ <%= button("Request activation code",
+ to: "/activate/request-code",
+ method: :post,
+ class: "button mt-12"
+ ) %>
+ </div>
+ <% end %>
+
+ <%= if !@has_any_invitations? and !@has_any_memberships? do %>
+ <div class="pt-12 pl-8 hidden md:block">
+ <%= render(PlausibleWeb.AuthView, "_onboarding_steps.html", current_step: 1) %>
+ </div>
+ <% end %>
+</div>
diff --git a/lib/plausible_web/templates/auth/password_reset_request_success.html.eex b/lib/plausible_web/templates/auth/password_reset_request_success.html.heex
similarity index 64%
rename from lib/plausible_web/templates/auth/password_reset_request_success.html.eex
rename to lib/plausible_web/templates/auth/password_reset_request_success.html.heex
index a3bde0d4f0..846a7c03e2 100644
--- a/lib/plausible_web/templates/auth/password_reset_request_success.html.eex
+++ b/lib/plausible_web/templates/auth/password_reset_request_success.html.heex
@@ -1,20 +1,27 @@
<div class="bg-white dark:bg-gray-800 max-w-md w-full mx-auto shadow-md rounded px-8 pt-6 pb-8 mb-4 mt-8">
<h2 class="text-xl font-black dark:text-gray-100">Success!</h2>
<div class="my-4 leading-tight dark:text-gray-100">
- We've sent an email containing password reset instructions to <b><%= @email %></b> if it's registered in our system.
+ We've sent an email containing password reset instructions to <b><%= @email %></b>
+ if it's registered in our system.
</div>
<div class="mt-8 text-sm dark:text-gray-100">
Didn't receive the email within a few minutes?
</div>
<div class="mt-2 text-sm text-gray-600 dark:text-gray-400 leading-tight">
You might have used an email address that's not registered in our database. Please verify the email address associated with your Plausible account and attempt the password reset once more.
- </div>
- <div class="mt-2 text-sm text-gray-600 dark:text-gray-400 leading-tight">
- <%= if Application.get_env(:plausible, :is_selfhost) do %>
- Certain that you're using the correct email address but still aren't receiving the password reset email? Please check your spam folder or ask on our <a href="https://github.com/plausible/analytics/discussions" class="text-indigo-500">community-supported forum</a>.
- <% else %>
- Certain that you're using the correct email address but still aren't receiving the password reset email? Please check your spam folder or <a href="https://plausible.io/contact" class="text-indigo-500">contact us</a>.
- <% end %>
- </div>
+ </div>
+ <div class="mt-2 text-sm text-gray-600 dark:text-gray-400 leading-tight">
+ <span :if={small_build?()}>
+ Certain that you're using the correct email address but still aren't receiving the password reset email? Please check your spam folder or ask on our <a
+ href="https://github.com/plausible/analytics/discussions"
+ class="text-indigo-500"
+ >community-supported forum</a>.
+ </span>
+ <span :if={full_build?()}>
+ Certain that you're using the correct email address but still aren't receiving the password reset email? Please check your spam folder or <a
+ href="https://plausible.io/contact"
+ class="text-indigo-500"
+ >contact us</a>.
+ </span>
</div>
</div>
diff --git a/lib/plausible_web/templates/auth/user_settings.html.heex b/lib/plausible_web/templates/auth/user_settings.html.heex
index ac373d707f..6ede880e47 100644
--- a/lib/plausible_web/templates/auth/user_settings.html.heex
+++ b/lib/plausible_web/templates/auth/user_settings.html.heex
@@ -1,4 +1,4 @@
-<%= if !Application.get_env(:plausible, :is_selfhost) do %>
+<%= if full_build?() do %>
<div class="max-w-2xl px-8 pt-4 pb-8 mx-auto mt-24 bg-white border-t-2 border-orange-200 rounded rounded-t-none shadow-md dark:bg-gray-800 dark:border-orange-200 ">
<div class="flex flex-wrap justify-between">
<h2 class="text-xl font-black dark:text-gray-100 w-max mr-4 mt-2">Subscription Plan</h2>
diff --git a/lib/plausible_web/templates/email/google_analytics_import.html.eex b/lib/plausible_web/templates/email/google_analytics_import.html.heex
similarity index 82%
rename from lib/plausible_web/templates/email/google_analytics_import.html.eex
rename to lib/plausible_web/templates/email/google_analytics_import.html.heex
index a99c2f91a4..d7d1ce539f 100644
--- a/lib/plausible_web/templates/email/google_analytics_import.html.eex
+++ b/lib/plausible_web/templates/email/google_analytics_import.html.heex
@@ -1,19 +1,16 @@
<%= 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 />
-<%= link("Click here", to: @link) %> to view your dashboard.
+ 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 />
+ <%= link("Click here", to: @link) %> to view your dashboard.
<% else %>
Unfortunately, your Google Analytics import for <%= @site.domain %> did not complete successfully. Sorry about that!
<br /> <br />
-
This may be due to the user metric setting in your Google Analytics account. We found that changing the user metric setting is necessary to get the correct data out of the Google API.
<br /> <br />
-
Please log into your Google Analytics account and go to Admin -> Property Settings -> User Analysis. Then make sure that "Enable User Metric in Reporting" is set to OFF. Then try importing again. You can switch the setting back after the import.
- <br /> <br />
-
- If you've already changed that setting, then it is something else:
- <br />
+ <br /> <br /> If you've already changed that setting, then it is something else: <br />
<ul>
<li>
@@ -24,10 +21,8 @@
</li>
</ul>
<br />
-
If all of the above is fine, please try to do the import once again. Sometimes the Google Analytics API just randomly returns empty data. It's intermittent and random. Trying to do the import again may return what you need.
-
- <%= if !Application.get_env(:plausible, :is_selfhost) do %>
+ <%= if full_build?() do %>
<br /> <br />
Please reply to this email to let us know if you're still experiencing issues with the import.
<% end %>
diff --git a/lib/plausible_web/templates/error/server_error.html.eex b/lib/plausible_web/templates/error/server_error.html.eex
deleted file mode 100644
index d6d26a1982..0000000000
--- a/lib/plausible_web/templates/error/server_error.html.eex
+++ /dev/null
@@ -1,54 +0,0 @@
-<div class="w-full max-w-3xl mt-4 mx-auto flex">
- <div class="max-w-lg w-full mx-auto bg-white dark:bg-gray-800 shadow-lg rounded px-8 pt-6 pb-8 mb-4 mt-8" >
- <h2 class="text-xl font-black dark:text-gray-100">Oops, sorry about that...</h2>
-
- <div class="rounded-md bg-yellow-50 dark:bg-transparent dark:border border-yellow-200 p-4 mt-4">
- <div class="flex">
- <div class="flex-shrink-0">
- <svg class="h-5 w-5 text-yellow-400 dark:text-yellow-300" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
- <path fill-rule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clip-rule="evenodd" />
- </svg>
- </div>
- <div class="ml-3">
- <h3 class="text-sm font-medium text-yellow-800 dark:text-yellow-400">
- There has been a server error.
- <%= if !assigns[:selfhosted?] do %>
- But don't worry, we're on it!
- <% end %>
- </h3>
-
- <div class="mt-2 text-sm text-yellow-700 dark:text-yellow-300">
- <p>
- <%= if assigns[:trace_id] && !assigns[:selfhosted?] do %>
- If you would like to help, tell us what you were trying to do. Our development team will receive your report.
- <% else %>
- We have been notified.
- <% end %>
- </p>
- </div>
- </div>
- </div>
- </div>
-
- <%= if !assigns[:selfhosted?] do %>
- <%= if assigns[:trace_id] do %>
- <div class="my-6">
- <%= form_for :error, Routes.error_report_path(PlausibleWeb.Endpoint, :submit_error_report), fn f -> %>
- <%= hidden_input f, :trace_id, value: @trace_id %>
- <%= label f, "What happened?", class: "block text-sm font-medium text-gray-700 dark:text-gray-300" %>
- <%= textarea f, :user_feedback, rows: 5, class: "block w-full max-w-xl border-gray-300 dark:border-gray-700 resize-none shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md dark:bg-gray-900 dark:text-gray-300", placeholder: "I clicked on 'X' and then hit 'Confirm'..." %>
- <%= submit "Send feedback →", class: "button mt-4 w-full" %>
- <% end %>
- </div>
- <% end %>
-
- <div class="mb-6 mt-12">
- <p class="text-sm text-center">
- <%= link("Home page", to: "/", class: "text-indigo-500 mr-8") %>
- <%= link("Status page", to: "https://status.plausible.io", class: "mr-8 text-indigo-500") %>
- <%= link("Contact us", to: "https://plausible.io/contact", class: "text-indigo-500") %>
- </p>
- </div>
- <% end %>
- </div>
-</div>
diff --git a/lib/plausible_web/templates/error/server_error.html.heex b/lib/plausible_web/templates/error/server_error.html.heex
new file mode 100644
index 0000000000..24077e525a
--- /dev/null
+++ b/lib/plausible_web/templates/error/server_error.html.heex
@@ -0,0 +1,74 @@
+<div class="w-full max-w-3xl mt-4 mx-auto flex">
+ <div class="max-w-lg w-full mx-auto bg-white dark:bg-gray-800 shadow-lg rounded px-8 pt-6 pb-8 mb-4 mt-8">
+ <h2 class="text-xl font-black dark:text-gray-100">Oops, sorry about that...</h2>
+
+ <div class="rounded-md bg-yellow-50 dark:bg-transparent dark:border border-yellow-200 p-4 mt-4">
+ <div class="flex">
+ <div class="flex-shrink-0">
+ <svg
+ class="h-5 w-5 text-yellow-400 dark:text-yellow-300"
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 20 20"
+ fill="currentColor"
+ aria-hidden="true"
+ >
+ <path
+ fill-rule="evenodd"
+ d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z"
+ clip-rule="evenodd"
+ />
+ </svg>
+ </div>
+ <div class="ml-3">
+ <h3 class="text-sm font-medium text-yellow-800 dark:text-yellow-400">
+ There has been a server error.
+ <%= if full_build?() do %>
+ But don't worry, we're on it!
+ <% end %>
+ </h3>
+
+ <div class="mt-2 text-sm text-yellow-700 dark:text-yellow-300">
+ <p>
+ <%= if assigns[:trace_id] && full_build?() do %>
+ If you would like to help, tell us what you were trying to do. Our development team will receive your report.
+ <% else %>
+ We have been notified.
+ <% end %>
+ </p>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <%= if full_build?() do %>
+ <%= if assigns[:trace_id] do %>
+ <div class="my-6">
+ <%= form_for :error, Routes.error_report_path(PlausibleWeb.Endpoint, :submit_error_report), fn f -> %>
+ <%= hidden_input(f, :trace_id, value: @trace_id) %>
+ <%= label(f, "What happened?",
+ class: "block text-sm font-medium text-gray-700 dark:text-gray-300"
+ ) %>
+ <%= textarea(f, :user_feedback,
+ rows: 5,
+ class:
+ "block w-full max-w-xl border-gray-300 dark:border-gray-700 resize-none shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md dark:bg-gray-900 dark:text-gray-300",
+ placeholder: "I clicked on 'X' and then hit 'Confirm'..."
+ ) %>
+ <%= submit("Send feedback →", class: "button mt-4 w-full") %>
+ <% end %>
+ </div>
+ <% end %>
+
+ <div class="mb-6 mt-12">
+ <p class="text-sm text-center">
+ <%= link("Home page", to: "/", class: "text-indigo-500 mr-8") %>
+ <%= link("Status page",
+ to: "https://status.plausible.io",
+ class: "mr-8 text-indigo-500"
+ ) %>
+ <%= link("Contact us", to: "https://plausible.io/contact", class: "text-indigo-500") %>
+ </p>
+ </div>
+ <% end %>
+ </div>
+</div>
diff --git a/lib/plausible_web/templates/layout/_footer.html.eex b/lib/plausible_web/templates/layout/_footer.html.eex
deleted file mode 100644
index 6e0d5e5cf1..0000000000
--- a/lib/plausible_web/templates/layout/_footer.html.eex
+++ /dev/null
@@ -1,190 +0,0 @@
-<div class="mt-24 bg-gray-800 dark:bg-gray-800">
- <div class="container px-4 py-12 sm:px-6 lg:py-16 lg:px-8">
- <div class="xl:grid xl:grid-cols-3 xl:gap-8">
- <div class="my-8 xl:my-0">
- <h4 class="font-semibold tracking-wider text-gray-300 leading-5">
- <img src="/images/icon/plausible_logo_sm.png" class="inline-block w-6 mr-1" />
- Plausible Analytics
- </h4>
- <p class="mt-4 text-base text-gray-400 leading-6">
- <%= if !Application.get_env(:plausible, :is_selfhost) do %>
- Made and hosted in the EU <span class="text-lg">🇪🇺</span><br />
- <% end %>
- Solely funded by our subscribers.<br />
- </p>
- <%= if Application.get_env(:plausible, :is_selfhost) do %>
- <div class="mt-4">
- <a href="https://github.com/sponsors/plausible" class="inline-flex items-center px-4 py-2 text-sm font-medium bg-gray-700 border border-transparent shadow-sm rounded-md text-gray-50 hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-gray-500">
- <svg class="w-5 h-5 mr-2 -ml-1 text-pink-600" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"></path></svg>
- Sponsor @plausible
- </a>
- </div>
- <% end %>
- </div>
- <div class="grid grid-cols-2 gap-8 xl:col-span-2">
- <div class="md:grid md:grid-cols-2 md:gap-8">
- <div>
- <h4 class="text-sm font-semibold tracking-wider text-gray-400 uppercase leading-5">
- Why Plausible?
- </h4>
- <ul class="mt-4">
- <li>
- <a rel="noreferrer" href="https://plausible.io/simple-web-analytics" class="text-base text-gray-300 leading-6 hover:text-white">
- Simple metrics
- </a>
- </li>
- <li class="mt-4">
- <a rel="noferrer" href="https://plausible.io/lightweight-web-analytics" class="text-base text-gray-300 leading-6 hover:text-white">
- Lightweight script
- </a>
- </li>
- <li class="mt-4">
- <a rel="noreferrer" href="https://plausible.io/privacy-focused-web-analytics" class="text-base text-gray-300 leading-6 hover:text-white">
- Privacy focused
- </a>
- </li>
- <li class="mt-4">
- <a rel="noreferrer" href="https://plausible.io/open-source-website-analytics" class="text-base text-gray-300 leading-6 hover:text-white">
- Open source
- </a>
- </li>
- <li class="mt-4">
- <a rel="noreferrer" href="https://plausible.io/for-bloggers-creators" class="text-base leading-6 text-gray-300 hover:text-white">
- For creators
- </a>
- </li>
- <li class="mt-4">
- <a rel="noreferrer" href="https://plausible.io/for-freelancers-agencies" class="text-base leading-6 text-gray-300 hover:text-white">
- For agencies
- </a>
- </li>
- <li class="mt-4">
- <a rel="noreferrer" href="https://plausible.io/for-ecommerce-saas" class="text-base leading-6 text-gray-300 hover:text-white">
- For ecommerce
- </a>
- </li>
- <li class="mt-4">
- <a rel="noreferrer" href="https://plausible.io/white-label-web-analytics" class="text-base leading-6 text-gray-300 hover:text-white">
- White label
- </a>
- </li>
- </ul>
- </div>
- <div class="mt-32 md:mt-0">
- <h4 class="text-sm font-semibold tracking-wider text-gray-400 uppercase leading-5">
- Comparisons
- </h4>
- <ul class="mt-4">
- <li>
- <a rel="noferrer" href="https://plausible.io/vs-google-analytics" class="text-base text-gray-300 leading-6 hover:text-white">
- vs Google Analytics
- </a>
- </li>
- <li class="mt-4">
- <a rel="noferrer" href="https://plausible.io/vs-matomo" class="text-base text-gray-300 leading-6 hover:text-white">
- vs Matomo
- </a>
- </li>
- <li class="mt-4">
- <a rel="noferrer" href="https://plausible.io/vs-cloudflare-web-analytics" class="text-base text-gray-300 leading-6 hover:text-white">
- vs Cloudflare
- </a>
- </li>
- </ul>
- </div>
- </div>
-<div class="md:grid md:grid-cols-2 md:gap-8">
- <div>
- <h4 class="text-sm leading-5 font-semibold tracking-wider text-gray-400 uppercase">
- Community
- </h4>
- <ul class="mt-4">
- <li>
- <a rel="noreferrer" href="https://plausible.io/blog" class="text-base leading-6 text-gray-300 hover:text-white">
- Blog
- </a>
- </li>
- <li class="mt-4">
- <a ref="noreferrer" target="_blank" href="https://plausible.io/status" class="text-base leading-6 text-gray-300 hover:text-white">
- Status
- </a>
- </li>
- <li class="mt-4">
- <a rel="noreferrer" href="https://plausible.io/docs" class="text-base leading-6 text-gray-300 hover:text-white">
- Documentation
- </a>
- </li>
- <li class="mt-4">
- <a rel="noreferrer" target="_blank" href="https://github.com/plausible/analytics" class="text-base leading-6 text-gray-300 hover:text-white">
- GitHub
- </a>
- </li>
- <li class="mt-4">
- <a rel="noreferrer" target="_blank" href="https://twitter.com/plausiblehq" class="text-base leading-6 text-gray-300 hover:text-white">
- Twitter
- </a>
- </li>
- <li class="mt-4">
- <a rel="noreferrer" target="_blank" rel="me" href="https://fosstodon.org/@plausible" class="text-base leading-6 text-gray-300 hover:text-white">
- Mastodon
- </a>
- </li>
- <li class="mt-4">
- <a rel="noreferrer" target="_blank" href="https://www.linkedin.com/company/plausible-analytics/" class="text-base leading-6 text-gray-300 hover:text-white">
- LinkedIn
- </a>
- </li>
- </ul>
- </div>
- <div class="mt-12 md:mt-0">
- <h4 class="text-sm leading-5 font-semibold tracking-wider text-gray-400 uppercase">
- Company
- </h4>
- <ul class="mt-4">
- <li class="mt-4">
- <a rel="noreferrer" href="https://plausible.io/about" class="text-base leading-6 text-gray-300 hover:text-white">
- About
- </a>
- </li>
- <li class="mt-4">
- <a rel="noreferrer" href="https://plausible.io/contact" class="text-base leading-6 text-gray-300 hover:text-white">
- Contact
- </a>
- </li>
- <li class="mt-4">
- <a rel="noreferrer" href="https://plausible.io/privacy" class="text-base leading-6 text-gray-300 hover:text-white">
- Privacy
- </a>
- </li>
- <li class="mt-4">
- <a rel="noreferrer" href="https://plausible.io/data-policy" class="text-base leading-6 text-gray-300 hover:text-white">
- Data policy
- </a>
- </li>
- <li class="mt-4">
- <a rel="noreferrer" href="https://plausible.io/terms" class="text-base leading-6 text-gray-300 hover:text-white">
- Terms
- </a>
- </li>
- <li class="mt-4">
- <a rel="noreferrer" href="https://plausible.io/dpa" class="text-base leading-6 text-gray-300 hover:text-white">
- DPA
- </a>
- </li>
- <li class="mt-4">
- <a rel="noreferrer" href="https://plausible.io/security" class="text-base leading-6 text-gray-300 hover:text-white">
- Security
- </a>
- </li>
- <li class="mt-4">
- <a rel="noreferrer" href="https://plausible.io/imprint" class="text-base leading-6 text-gray-300 hover:text-white">
- Imprint
- </a>
- </li>
- </ul>
- </div>
- </div>
- </div>
- </div>
- </div>
-</div>
diff --git a/lib/plausible_web/templates/layout/_footer.html.heex b/lib/plausible_web/templates/layout/_footer.html.heex
new file mode 100644
index 0000000000..a6454d23b2
--- /dev/null
+++ b/lib/plausible_web/templates/layout/_footer.html.heex
@@ -0,0 +1,317 @@
+<div class="mt-24 bg-gray-800 dark:bg-gray-800">
+ <div class="container px-4 py-12 sm:px-6 lg:py-16 lg:px-8">
+ <div class="xl:grid xl:grid-cols-3 xl:gap-8">
+ <div class="my-8 xl:my-0">
+ <h4 class="font-semibold tracking-wider text-gray-300 leading-5">
+ <img src="/images/icon/plausible_logo_sm.png" class="inline-block w-6 mr-1" />
+ Plausible Analytics
+ </h4>
+ <p class="mt-4 text-base text-gray-400 leading-6">
+ <%= if full_build?() do %>
+ Made and hosted in the EU <span class="text-lg">🇪🇺</span> <br />
+ <% end %>
+ Solely funded by our subscribers.<br />
+ </p>
+ <%= if small_build?() do %>
+ <div class="mt-4">
+ <a
+ href="https://github.com/sponsors/plausible"
+ class="inline-flex items-center px-4 py-2 text-sm font-medium bg-gray-700 border border-transparent shadow-sm rounded-md text-gray-50 hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-gray-500"
+ >
+ <svg
+ class="w-5 h-5 mr-2 -ml-1 text-pink-600"
+ fill="none"
+ stroke="currentColor"
+ viewBox="0 0 24 24"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"
+ >
+ </path>
+ </svg>
+ Sponsor @plausible
+ </a>
+ </div>
+ <% end %>
+ </div>
+ <div class="grid grid-cols-2 gap-8 xl:col-span-2">
+ <div class="md:grid md:grid-cols-2 md:gap-8">
+ <div>
+ <h4 class="text-sm font-semibold tracking-wider text-gray-400 uppercase leading-5">
+ Why Plausible?
+ </h4>
+ <ul class="mt-4">
+ <li>
+ <a
+ rel="noreferrer"
+ href="https://plausible.io/simple-web-analytics"
+ class="text-base text-gray-300 leading-6 hover:text-white"
+ >
+ Simple metrics
+ </a>
+ </li>
+ <li class="mt-4">
+ <a
+ rel="noferrer"
+ href="https://plausible.io/lightweight-web-analytics"
+ class="text-base text-gray-300 leading-6 hover:text-white"
+ >
+ Lightweight script
+ </a>
+ </li>
+ <li class="mt-4">
+ <a
+ rel="noreferrer"
+ href="https://plausible.io/privacy-focused-web-analytics"
+ class="text-base text-gray-300 leading-6 hover:text-white"
+ >
+ Privacy focused
+ </a>
+ </li>
+ <li class="mt-4">
+ <a
+ rel="noreferrer"
+ href="https://plausible.io/open-source-website-analytics"
+ class="text-base text-gray-300 leading-6 hover:text-white"
+ >
+ Open source
+ </a>
+ </li>
+ <li class="mt-4">
+ <a
+ rel="noreferrer"
+ href="https://plausible.io/for-bloggers-creators"
+ class="text-base leading-6 text-gray-300 hover:text-white"
+ >
+ For creators
+ </a>
+ </li>
+ <li class="mt-4">
+ <a
+ rel="noreferrer"
+ href="https://plausible.io/for-freelancers-agencies"
+ class="text-base leading-6 text-gray-300 hover:text-white"
+ >
+ For agencies
+ </a>
+ </li>
+ <li class="mt-4">
+ <a
+ rel="noreferrer"
+ href="https://plausible.io/for-ecommerce-saas"
+ class="text-base leading-6 text-gray-300 hover:text-white"
+ >
+ For ecommerce
+ </a>
+ </li>
+ <li class="mt-4">
+ <a
+ rel="noreferrer"
+ href="https://plausible.io/white-label-web-analytics"
+ class="text-base leading-6 text-gray-300 hover:text-white"
+ >
+ White label
+ </a>
+ </li>
+ </ul>
+ </div>
+ <div class="mt-32 md:mt-0">
+ <h4 class="text-sm font-semibold tracking-wider text-gray-400 uppercase leading-5">
+ Comparisons
+ </h4>
+ <ul class="mt-4">
+ <li>
+ <a
+ rel="noferrer"
+ href="https://plausible.io/vs-google-analytics"
+ class="text-base text-gray-300 leading-6 hover:text-white"
+ >
+ vs Google Analytics
+ </a>
+ </li>
+ <li class="mt-4">
+ <a
+ rel="noferrer"
+ href="https://plausible.io/vs-matomo"
+ class="text-base text-gray-300 leading-6 hover:text-white"
+ >
+ vs Matomo
+ </a>
+ </li>
+ <li class="mt-4">
+ <a
+ rel="noferrer"
+ href="https://plausible.io/vs-cloudflare-web-analytics"
+ class="text-base text-gray-300 leading-6 hover:text-white"
+ >
+ vs Cloudflare
+ </a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ <div class="md:grid md:grid-cols-2 md:gap-8">
+ <div>
+ <h4 class="text-sm leading-5 font-semibold tracking-wider text-gray-400 uppercase">
+ Community
+ </h4>
+ <ul class="mt-4">
+ <li>
+ <a
+ rel="noreferrer"
+ href="https://plausible.io/blog"
+ class="text-base leading-6 text-gray-300 hover:text-white"
+ >
+ Blog
+ </a>
+ </li>
+ <li class="mt-4">
+ <a
+ ref="noreferrer"
+ target="_blank"
+ href="https://plausible.io/status"
+ class="text-base leading-6 text-gray-300 hover:text-white"
+ >
+ Status
+ </a>
+ </li>
+ <li class="mt-4">
+ <a
+ rel="noreferrer"
+ href="https://plausible.io/docs"
+ class="text-base leading-6 text-gray-300 hover:text-white"
+ >
+ Documentation
+ </a>
+ </li>
+ <li class="mt-4">
+ <a
+ rel="noreferrer"
+ target="_blank"
+ href="https://github.com/plausible/analytics"
+ class="text-base leading-6 text-gray-300 hover:text-white"
+ >
+ GitHub
+ </a>
+ </li>
+ <li class="mt-4">
+ <a
+ rel="noreferrer"
+ target="_blank"
+ href="https://twitter.com/plausiblehq"
+ class="text-base leading-6 text-gray-300 hover:text-white"
+ >
+ Twitter
+ </a>
+ </li>
+ <li class="mt-4">
+ <a
+ rel="noreferrer"
+ target="_blank"
+ rel="me"
+ href="https://fosstodon.org/@plausible"
+ class="text-base leading-6 text-gray-300 hover:text-white"
+ >
+ Mastodon
+ </a>
+ </li>
+ <li class="mt-4">
+ <a
+ rel="noreferrer"
+ target="_blank"
+ href="https://www.linkedin.com/company/plausible-analytics/"
+ class="text-base leading-6 text-gray-300 hover:text-white"
+ >
+ LinkedIn
+ </a>
+ </li>
+ </ul>
+ </div>
+ <div class="mt-12 md:mt-0">
+ <h4 class="text-sm leading-5 font-semibold tracking-wider text-gray-400 uppercase">
+ Company
+ </h4>
+ <ul class="mt-4">
+ <li class="mt-4">
+ <a
+ rel="noreferrer"
+ href="https://plausible.io/about"
+ class="text-base leading-6 text-gray-300 hover:text-white"
+ >
+ About
+ </a>
+ </li>
+ <li class="mt-4">
+ <a
+ rel="noreferrer"
+ href="https://plausible.io/contact"
+ class="text-base leading-6 text-gray-300 hover:text-white"
+ >
+ Contact
+ </a>
+ </li>
+ <li class="mt-4">
+ <a
+ rel="noreferrer"
+ href="https://plausible.io/privacy"
+ class="text-base leading-6 text-gray-300 hover:text-white"
+ >
+ Privacy
+ </a>
+ </li>
+ <li class="mt-4">
+ <a
+ rel="noreferrer"
+ href="https://plausible.io/data-policy"
+ class="text-base leading-6 text-gray-300 hover:text-white"
+ >
+ Data policy
+ </a>
+ </li>
+ <li class="mt-4">
+ <a
+ rel="noreferrer"
+ href="https://plausible.io/terms"
+ class="text-base leading-6 text-gray-300 hover:text-white"
+ >
+ Terms
+ </a>
+ </li>
+ <li class="mt-4">
+ <a
+ rel="noreferrer"
+ href="https://plausible.io/dpa"
+ class="text-base leading-6 text-gray-300 hover:text-white"
+ >
+ DPA
+ </a>
+ </li>
+ <li class="mt-4">
+ <a
+ rel="noreferrer"
+ href="https://plausible.io/security"
+ class="text-base leading-6 text-gray-300 hover:text-white"
+ >
+ Security
+ </a>
+ </li>
+ <li class="mt-4">
+ <a
+ rel="noreferrer"
+ href="https://plausible.io/imprint"
+ class="text-base leading-6 text-gray-300 hover:text-white"
+ >
+ Imprint
+ </a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
diff --git a/lib/plausible_web/templates/layout/_header.html.heex b/lib/plausible_web/templates/layout/_header.html.heex
index 753f746f85..450a5daa71 100644
--- a/lib/plausible_web/templates/layout/_header.html.heex
+++ b/lib/plausible_web/templates/layout/_header.html.heex
@@ -24,15 +24,16 @@
<%= cond do %>
<% @conn.assigns[:current_user] -> %>
<ul class="flex items-center w-full sm:w-auto">
- <%= if Plausible.Billing.on_trial?(@conn.assigns[:current_user]) && !Application.get_env(:plausible, :is_selfhost) do %>
- <li class="hidden mr-6 sm:block">
- <%= link(trial_notificaton(@conn.assigns[:current_user]),
- to: "/settings",
- class:
- "text-sm text-yellow-900 dark:text-yellow-900 rounded px-3 py-2 rounded-md bg-yellow-100 dark:bg-yellow-100"
- ) %>
- </li>
- <% end %>
+ <li
+ :if={Plausible.Billing.on_trial?(@conn.assigns[:current_user])}
+ class="hidden mr-6 sm:block"
+ >
+ <%= link(trial_notificaton(@conn.assigns[:current_user]),
+ to: "/settings",
+ class:
+ "text-sm text-yellow-900 dark:text-yellow-900 rounded px-3 py-2 rounded-md bg-yellow-100 dark:bg-yellow-100"
+ ) %>
+ </li>
<li class="w-full sm:w-auto">
<.dropdown>
<:button class="flex items-center gap-3 px-3 py-2 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800">
@@ -57,17 +58,17 @@
<.dropdown_link new_tab href="https://plausible.io/docs">
Help Center
</.dropdown_link>
- <%= if Application.get_env(:plausible, :is_selfhost) do %>
- <.dropdown_link new_tab href="https://github.com/plausible/analytics">
- Github Repo
- </.dropdown_link>
- <% else %>
+ <%= if full_build?() do %>
<.dropdown_link new_tab href="https://plausible.io/contact">
Contact Support
</.dropdown_link>
<.dropdown_link new_tab href={feedback_link(@conn.assigns[:current_user])}>
Feature Requests
</.dropdown_link>
+ <% else %>
+ <.dropdown_link new_tab href="https://github.com/plausible/analytics">
+ Github Repo
+ </.dropdown_link>
<% end %>
</div>
<div class="py-1.5" role="none">
@@ -76,7 +77,7 @@
</:panel>
</.dropdown>
</li>
- <%= if @conn.assigns[:current_user] && !Application.get_env(:plausible, :is_selfhost) do %>
+ <%= if @conn.assigns[:current_user] && full_build?() do %>
<li id="changelog-notification" class="relative py-2"></li>
<% end %>
</ul>
diff --git a/lib/plausible_web/templates/layout/_tracking.html.heex b/lib/plausible_web/templates/layout/_tracking.html.heex
index 9e3cc9b1c2..2d1ea894a0 100644
--- a/lib/plausible_web/templates/layout/_tracking.html.heex
+++ b/lib/plausible_web/templates/layout/_tracking.html.heex
@@ -1,4 +1,4 @@
-<%= if !Application.get_env(:plausible, :is_selfhost) && [email protected][:skip_plausible_tracking] do %>
+<%= if full_build?() && [email protected][:skip_plausible_tracking] do %>
<script
defer
data-api={dogfood_api_destination()}
diff --git a/lib/plausible_web/templates/site/settings_custom_domain.html.eex b/lib/plausible_web/templates/site/settings_custom_domain.html.eex
deleted file mode 100644
index 304eff6718..0000000000
--- a/lib/plausible_web/templates/site/settings_custom_domain.html.eex
+++ /dev/null
@@ -1,39 +0,0 @@
-<div class="rounded-md bg-yellow-50 dark:bg-transparent dark:border border-yellow-200 p-4">
- <div class="flex">
- <div class="flex-shrink-0">
- <svg class="h-5 w-5 text-yellow-400 dark:text-yellow-300" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
- <path fill-rule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clip-rule="evenodd" />
- </svg>
- </div>
- <div class="ml-3">
- <h3 class="text-sm font-medium text-yellow-800 dark:text-yellow-400">
- Deprecated feature
- </h3>
- <div class="mt-2 text-sm text-yellow-700 dark:text-yellow-300">
- <p>
- We are moving away from CNAME-based custom domains. If you're concerned about adblockers, we recommend
- <%= link("setting up a proxy", class: "underline text-yellow-800 dark:text-yellow-400", to: "https://plausible.io/docs/proxy/introduction", target: "_blank", rel: "noferrer") %> for your analytics script instead.
- </p>
- </div>
- </div>
- </div>
-</div>
-
-<div class="shadow bg-white dark:bg-gray-800 sm:rounded-md sm:overflow-hidden py-6 px-4 sm:p-6">
- <header class="relative">
- <h2 class="text-lg leading-6 font-medium text-gray-900 dark:text-gray-100">Custom domain</h2>
- <p class="mt-1 text-sm leading-5 text-gray-500 dark:text-gray-200">Serve the tracking script from your domain name as a first-party resource instead of loading the script from our domain.</p>
-
- <%= link(to: "https://plausible.io/docs/proxy/introduction", target: "_blank") do %>
- <svg class="w-6 h-6 absolute top-0 right-0 text-gray-400" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd"></path></svg>
- <% end %>
- </header>
- <div class="mt-6 dark:text-gray-100 flex justify-between items-center">
- <%= if @site.custom_domain do %>
- <span>
- Configured domain: <b><%= @site.custom_domain.domain %></b>
- </span>
- <%= link("Remove custom domain", to: "/sites/#{URI.encode_www_form(@site.domain)}/custom-domains/#{@site.custom_domain.id}", class: "inline-block mt-4 px-4 py-2 border border-gray-300 dark:border-gray-500 text-sm leading-5 font-medium rounded-md text-red-700 bg-white dark:bg-gray-800 hover:text-red-500 dark:hover:text-red-400 focus:outline-none focus:border-blue-300 focus:ring active:text-red-800 active:bg-gray-50 transition ease-in-out duration-150", method: "delete") %>
- <% end %>
- </div>
-</div>
diff --git a/lib/plausible_web/templates/stats/waiting_first_pageview.html.eex b/lib/plausible_web/templates/stats/waiting_first_pageview.html.eex
deleted file mode 100644
index 7a297b84ab..0000000000
--- a/lib/plausible_web/templates/stats/waiting_first_pageview.html.eex
+++ /dev/null
@@ -1,37 +0,0 @@
-<script>
- function updateStatus() {
- fetch("/api/<%= URI.encode_www_form(@site.domain) %>/status")
- .then(function(res) { return res.json() })
- .then(function(status) {
- if (status === "READY") {
- window.location.reload()
- }
- })
- }
-
- setInterval(updateStatus, 5000)
-</script>
-
-<div class="w-full max-w-md mx-auto mt-8">
- <%= if @site.locked do %>
- <div class="w-full px-4 py-4 text-sm font-bold text-center text-yellow-800 bg-yellow-100 rounded transition" style="top: 91px" role="alert">
- <p>This dashboard is actually locked. You are viewing it with super-admin access</p>
- </div>
- <% end %>
- <div class="bg-white dark:bg-gray-800 shadow-md rounded px-8 pt-6 pb-8 mb-4 mt-16 relative text-center">
- <h2 class="text-xl font-bold dark:text-gray-100">Waiting for first pageview</h2>
- <h2 class="text-xl font-bold dark:text-gray-100">on <%= @site.domain %></h2>
- <div class="my-44">
- <div class="block pulsating-circle top-1/2 left-1/2"></div>
- <p class="text-gray-600 dark:text-gray-400 text-xs absolute left-0 bottom-0 mb-6 w-full text-center leading-normal">
- Need to see the snippet again? <%= link("Click here", to: "/#{URI.encode_www_form(@site.domain)}/snippet", class: "text-indigo-600 dark:text-indigo-500 text-underline")%><br />
- Not working? <%= link("Troubleshoot the integration", to: "https://plausible.io/docs/troubleshoot-integration#check-for-the-plausible-snippet-in-your-source-code", class: "text-indigo-600 dark:text-indigo-500 text-underline", rel: "noreferrer") %> with our guide
- <%= if Application.get_env(:plausible, :is_selfhost) do %>
- first<br /> Still not working? Ask on our <%= link("community-supported forum", to: "https://github.com/plausible/analytics/discussions", class: "text-indigo-600 dark:text-indigo-500 text-underline" ) %>
- <% else %>
- first<br /> Still not working? <%= link("Contact us", to: "https://plausible.io/contact", class: "text-indigo-600 dark:text-indigo-500 text-underline" ) %> and we will help you with your setup
- <% end %>
- </p>
- </div>
- </div>
-</div>
diff --git a/lib/plausible_web/templates/stats/waiting_first_pageview.html.heex b/lib/plausible_web/templates/stats/waiting_first_pageview.html.heex
new file mode 100644
index 0000000000..1c8af5e7ee
--- /dev/null
+++ b/lib/plausible_web/templates/stats/waiting_first_pageview.html.heex
@@ -0,0 +1,59 @@
+<script>
+ function updateStatus() {
+ fetch("/api/<%= URI.encode_www_form(@site.domain) %>/status")
+ .then(function(res) { return res.json() })
+ .then(function(status) {
+ if (status === "READY") {
+ window.location.reload()
+ }
+ })
+ }
+
+ setInterval(updateStatus, 5000)
+</script>
+
+<div class="w-full max-w-md mx-auto mt-8">
+ <%= if @site.locked do %>
+ <div
+ class="w-full px-4 py-4 text-sm font-bold text-center text-yellow-800 bg-yellow-100 rounded transition"
+ style="top: 91px"
+ role="alert"
+ >
+ <p>This dashboard is actually locked. You are viewing it with super-admin access</p>
+ </div>
+ <% end %>
+ <div class="bg-white dark:bg-gray-800 shadow-md rounded px-8 pt-6 pb-8 mb-4 mt-16 relative text-center">
+ <h2 class="text-xl font-bold dark:text-gray-100">Waiting for first pageview</h2>
+ <h2 class="text-xl font-bold dark:text-gray-100">on <%= @site.domain %></h2>
+ <div class="my-44">
+ <div class="block pulsating-circle top-1/2 left-1/2"></div>
+ <p class="text-gray-600 dark:text-gray-400 text-xs absolute left-0 bottom-0 mb-6 w-full text-center leading-normal">
+ Need to see the snippet again?
+ <.styled_link href={"/#{URI.encode_www_form(@site.domain)}/snippet"}>
+ Click here
+ </.styled_link>
+
+ <br /> Not working?
+ <.styled_link
+ new_tab
+ href="https://plausible.io/docs/troubleshoot-integration#check-for-the-plausible-snippet-in-your-source-code"
+ >
+ Troubleshoot the integration
+ </.styled_link>
+
+ <br />
+ <span :if={full_build?()}>
+ Still not working?
+ <.styled_link new_tab href="https://plausible.io/contact">Contact us</.styled_link>
+ and we will help you with your setup
+ </span>
+ <span :if={small_build?()}>
+ Still not working? Ask on our
+ <.styled_link new_tab href="https://github.com/plausible/analytics/discussions">
+ community-supported forum
+ </.styled_link>
+ </span>
+ </p>
+ </div>
+ </div>
+</div>
diff --git a/lib/plausible_web/views/auth_view.ex b/lib/plausible_web/views/auth_view.ex
index ec2ab0dfb2..b7f26d29f8 100644
--- a/lib/plausible_web/views/auth_view.ex
+++ b/lib/plausible_web/views/auth_view.ex
@@ -1,4 +1,5 @@
defmodule PlausibleWeb.AuthView do
+ use Plausible
use PlausibleWeb, :view
require Plausible.Billing.Subscription.Status
alias Plausible.Billing.{Plans, Subscription}
diff --git a/lib/plausible_web/views/email_view.ex b/lib/plausible_web/views/email_view.ex
index 786efb5378..e2c6db164c 100644
--- a/lib/plausible_web/views/email_view.ex
+++ b/lib/plausible_web/views/email_view.ex
@@ -1,4 +1,5 @@
defmodule PlausibleWeb.EmailView do
+ use Plausible
use PlausibleWeb, :view
def plausible_url do
diff --git a/lib/plausible_web/views/error_view.ex b/lib/plausible_web/views/error_view.ex
index 1e133e6f59..3f770e73ee 100644
--- a/lib/plausible_web/views/error_view.ex
+++ b/lib/plausible_web/views/error_view.ex
@@ -1,9 +1,10 @@
defmodule PlausibleWeb.ErrorView do
+ use Plausible
use PlausibleWeb, :view
def render("500.json", %{conn: %{private: %{PlausibleWeb.Plugins.API.Router => _}}}) do
contact_support_note =
- if not Plausible.Release.selfhost?() do
+ on_full_build do
"If the problem persists please contact [email protected]"
end
@@ -32,23 +33,21 @@ defmodule PlausibleWeb.ErrorView do
def render(<<"5", _error_5xx::binary-size(2), ".html">>, assigns) do
current_user = assigns[:current_user]
- selfhosted? = Plausible.Release.selfhost?()
last_event = Sentry.get_last_event_id_and_source()
- case {selfhosted?, current_user, last_event} do
- {false, current_user, {event_id, :plug}}
+ case {current_user, last_event} do
+ {current_user, {event_id, :plug}}
when is_binary(event_id) and not is_nil(current_user) ->
opts = %{
trace_id: event_id,
user_name: current_user.name,
- user_email: current_user.email,
- selfhosted?: selfhosted?
+ user_email: current_user.email
}
render("server_error.html", Map.merge(opts, assigns))
_ ->
- render("server_error.html", Map.put(assigns, :selfhosted?, selfhosted?))
+ render("server_error.html", assigns)
end
end
diff --git a/lib/plausible_web/views/layout_view.ex b/lib/plausible_web/views/layout_view.ex
index 092b6871dd..707b24b387 100644
--- a/lib/plausible_web/views/layout_view.ex
+++ b/lib/plausible_web/views/layout_view.ex
@@ -83,9 +83,6 @@ defmodule PlausibleWeb.LayoutView do
[key: "Custom Properties", value: "properties"],
[key: "Integrations", value: "integrations"],
[key: "Email Reports", value: "email-reports"],
- if !is_selfhost() && conn.assigns[:site].custom_domain do
- [key: "Custom domain", value: "custom-domain"]
- end,
if conn.assigns[:current_user_role] == :owner do
[key: "Danger zone", value: "danger-zone"]
end
@@ -123,8 +120,4 @@ defmodule PlausibleWeb.LayoutView do
def is_current_tab(conn, tab) do
List.last(conn.path_info) == tab
end
-
- defp is_selfhost() do
- Application.get_env(:plausible, :is_selfhost)
- end
end
diff --git a/lib/plausible_web/views/site_view.ex b/lib/plausible_web/views/site_view.ex
index 6c95abeb3c..b7f97920f9 100644
--- a/lib/plausible_web/views/site_view.ex
+++ b/lib/plausible_web/views/site_view.ex
@@ -23,12 +23,7 @@ defmodule PlausibleWeb.SiteView do
end
def render_snippet(site) do
- tracker =
- if site.custom_domain do
- "https://" <> site.custom_domain.domain <> "/js/index.js"
- else
- "#{plausible_url()}/js/script.js"
- end
+ tracker = "#{plausible_url()}/js/script.js"
"""
<script defer data-domain="#{site.domain}" src="#{tracker}"></script>
diff --git a/lib/plausible_web/views/stats_view.ex b/lib/plausible_web/views/stats_view.ex
index a8babcd2ea..70e5e10bd8 100644
--- a/lib/plausible_web/views/stats_view.ex
+++ b/lib/plausible_web/views/stats_view.ex
@@ -1,5 +1,6 @@
defmodule PlausibleWeb.StatsView do
use PlausibleWeb, :view
+ use Plausible
def base_domain do
PlausibleWeb.Endpoint.host()
diff --git a/mix.exs b/mix.exs
index c4b558a0b9..96cfb84264 100644
--- a/mix.exs
+++ b/mix.exs
@@ -49,7 +49,7 @@ defmodule Plausible.MixProject do
defp elixirc_paths(env) when env in [:test, :dev],
do: ["lib", "test/support", "extra/lib"]
- defp elixirc_paths(env) when env in [:small_test],
+ defp elixirc_paths(env) when env in [:small_test, :small_dev],
do: ["lib", "test/support"]
defp elixirc_paths(:small), do: ["lib"]
@@ -80,10 +80,10 @@ defmodule Plausible.MixProject do
{:ecto, "~> 3.10.0"},
{:ecto_sql, "~> 3.10.0"},
{:envy, "~> 1.1.1"},
- {:ex_machina, "~> 2.3", only: [:dev, :test, :small, :small_test]},
+ {:ex_machina, "~> 2.3", only: [:dev, :test, :small_dev, :small_test]},
{:excoveralls, "~> 0.10", only: :test},
{:finch, "~> 0.16.0"},
- {:floki, "~> 0.34.3", only: [:dev, :test, :small, :small_test]},
+ {:floki, "~> 0.34.3", only: [:dev, :test, :small_dev, :small_test]},
{:fun_with_flags, "~> 1.9.0"},
{:fun_with_flags_ui, "~> 0.8"},
{:locus, "~> 2.3"},
@@ -110,7 +110,7 @@ defmodule Plausible.MixProject do
{:phoenix_view, "~> 2.0"},
{:phoenix_ecto, "~> 4.0"},
{:phoenix_html, "~> 3.3", override: true},
- {:phoenix_live_reload, "~> 1.2", only: [:dev, :small]},
+ {:phoenix_live_reload, "~> 1.2", only: [:dev, :small_dev]},
{:phoenix_pubsub, "~> 2.0"},
{:phoenix_live_view, "~> 0.18"},
{:php_serializer, "~> 2.0"},
@@ -134,8 +134,8 @@ defmodule Plausible.MixProject do
{:joken, "~> 2.5"},
{:paginator, git: "https://github.com/duffelhq/paginator.git"},
{:scrivener_ecto, "~> 2.0"},
- {:esbuild, "~> 0.7", runtime: Mix.env() in [:dev, :small]},
- {:tailwind, "~> 0.2.0", runtime: Mix.env() in [:dev, :small]},
+ {:esbuild, "~> 0.7", runtime: Mix.env() in [:dev, :small_dev]},
+ {:tailwind, "~> 0.2.0", runtime: Mix.env() in [:dev, :small_dev]},
{:ex_json_logger, "~> 1.3.0"}
]
end
diff --git a/priv/repo/migrations/20231127132321_remove_custom_domains.exs b/priv/repo/migrations/20231127132321_remove_custom_domains.exs
new file mode 100644
index 0000000000..d53307a9bb
--- /dev/null
+++ b/priv/repo/migrations/20231127132321_remove_custom_domains.exs
@@ -0,0 +1,7 @@
+defmodule Plausible.Repo.Migrations.RemoveCustomDomains do
+ use Ecto.Migration
+
+ def change do
+ drop table(:custom_domains)
+ end
+end
diff --git a/test/plausible/billing/billing_test.exs b/test/plausible/billing/billing_test.exs
index 51da2403e5..1e4d30c00f 100644
--- a/test/plausible/billing/billing_test.exs
+++ b/test/plausible/billing/billing_test.exs
@@ -108,6 +108,7 @@ defmodule Plausible.BillingTest do
end
describe "on_trial?" do
+ @describetag :full_build_only
test "is true with >= 0 trial days left" do
user = insert(:user)
diff --git a/test/plausible/billing/feature_test.exs b/test/plausible/billing/feature_test.exs
index 4ce91fca80..845a0b7f46 100644
--- a/test/plausible/billing/feature_test.exs
+++ b/test/plausible/billing/feature_test.exs
@@ -74,7 +74,7 @@ defmodule Plausible.Billing.FeatureTest do
end
test "Plausible.Billing.Feature.StatsAPI.check_availability/2 returns error when user trial hasn't started and was created after the business tier launch" do
- user = insert(:user, inserted_at: ~N[2024-01-01T00:00:00], trial_expiry_date: nil)
+ user = insert(:user, trial_expiry_date: nil)
assert {:error, :upgrade_required} ==
Plausible.Billing.Feature.StatsAPI.check_availability(user)
diff --git a/test/plausible/billing/plans_test.exs b/test/plausible/billing/plans_test.exs
index 4536045674..7c50052a0f 100644
--- a/test/plausible/billing/plans_test.exs
+++ b/test/plausible/billing/plans_test.exs
@@ -68,7 +68,7 @@ defmodule Plausible.Billing.PlansTest do
end
test "growth_plans_for/1 shows v4 plans for everyone else" do
- insert(:user, inserted_at: ~U[2024-01-01T00:00:00Z])
+ insert(:user)
|> Plans.growth_plans_for()
|> assert_generation(4)
end
@@ -144,7 +144,7 @@ defmodule Plausible.Billing.PlansTest do
end
test "business_plans_for/1 returns v4 business plans for everyone else" do
- user = insert(:user, inserted_at: ~U[2024-01-01T00:00:00Z])
+ user = insert(:user)
business_plans = Plans.business_plans_for(user)
assert Enum.all?(business_plans, &(&1.kind == :business))
@@ -318,14 +318,14 @@ defmodule Plausible.Billing.PlansTest do
describe "suggest_tier/1" do
test "suggests Business when user has used a premium feature" do
- user = insert(:user, inserted_at: ~N[2024-01-01 10:00:00])
+ user = insert(:user)
insert(:api_key, user: user)
assert Plans.suggest_tier(user) == :business
end
test "suggests Growth when no premium features used" do
- user = insert(:user, inserted_at: ~N[2024-01-01 10:00:00])
+ user = insert(:user)
site = insert(:site, members: [user])
insert(:goal, site: site, event_name: "goals_is_not_premium")
diff --git a/test/plausible/billing/quota_test.exs b/test/plausible/billing/quota_test.exs
index 9795eacaf4..e70be213e2 100644
--- a/test/plausible/billing/quota_test.exs
+++ b/test/plausible/billing/quota_test.exs
@@ -16,6 +16,7 @@ defmodule Plausible.Billing.QuotaTest do
@v3_business_plan_id "857481"
describe "site_limit/1" do
+ @describetag :full_build_only
test "returns 50 when user is on an old plan" do
user_on_v1 = insert(:user, subscription: build(:subscription, paddle_plan_id: @v1_plan_id))
user_on_v2 = insert(:user, subscription: build(:subscription, paddle_plan_id: @v2_plan_id))
@@ -50,8 +51,7 @@ defmodule Plausible.Billing.QuotaTest do
test "returns 10 when user in on trial" do
user =
insert(:user,
- trial_expiry_date: Timex.shift(Timex.now(), days: 7),
- inserted_at: ~U[2024-01-01T00:00:00Z]
+ trial_expiry_date: Timex.shift(Timex.now(), days: 7)
)
assert 10 == Quota.site_limit(user)
@@ -81,8 +81,7 @@ defmodule Plausible.Billing.QuotaTest do
user =
insert(:user,
enterprise_plan: build(:enterprise_plan, paddle_plan_id: "123321"),
- subscription: nil,
- inserted_at: ~U[2024-01-01T00:00:00Z]
+ subscription: nil
)
assert 10 == Quota.site_limit(user)
@@ -385,8 +384,7 @@ defmodule Plausible.Billing.QuotaTest do
test "returns 5 when user in on trial" do
user =
insert(:user,
- trial_expiry_date: Timex.shift(Timex.now(), days: 7),
- inserted_at: ~U[2024-01-01T00:00:00Z]
+ trial_expiry_date: Timex.shift(Timex.now(), days: 7)
)
assert 3 == Quota.team_member_limit(user)
diff --git a/test/plausible/plugins/api/token_test.exs b/test/plausible/plugins/api/token_test.exs
index 57c848f5d4..47ce9fdabc 100644
--- a/test/plausible/plugins/api/token_test.exs
+++ b/test/plausible/plugins/api/token_test.exs
@@ -3,6 +3,7 @@ defmodule Plausible.Plugins.API.TokenTest do
alias Plausible.Plugins.API.Token
+ @tag :full_build_only
test "basic token properties" do
t1 = Token.generate()
t2 = Token.generate()
@@ -24,20 +25,23 @@ defmodule Plausible.Plugins.API.TokenTest do
end
describe "prefix/0" do
- test "default prefix" do
+ @tag :full_build_only
+ test "default prefix - full build" do
assert Token.prefix() == "plausible-plugin-test"
end
+ @tag :small_build_only
test "selfhosted prefix" do
- patch_env(:is_selfhost, true)
assert Token.prefix() == "plausible-plugin-selfhost"
end
+ @tag :full_build_only
test "prod prefix" do
patch_env(:environment, "prod")
assert Token.prefix() == "plausible-plugin"
end
+ @tag :full_build_only
test "staging prefix" do
patch_env(:environment, "staging")
assert Token.prefix() == "plausible-plugin-staging"
diff --git a/test/plausible/plugins/api/tokens_test.exs b/test/plausible/plugins/api/tokens_test.exs
index 43538f7f67..223e92ddb3 100644
--- a/test/plausible/plugins/api/tokens_test.exs
+++ b/test/plausible/plugins/api/tokens_test.exs
@@ -9,7 +9,6 @@ defmodule Plausible.Plugins.API.TokensTest do
test "generates and stores the token" do
site = insert(:site)
assert {:ok, %Token{} = token, raw} = Tokens.create(site, "My test token")
- assert <<"plausible-plugin-test-", _::binary-size(40)>> = raw
from_db = Repo.get(Token, token.id)
diff --git a/test/plausible/release_test.exs b/test/plausible/release_test.exs
index c1410594e2..07ba568fd0 100644
--- a/test/plausible/release_test.exs
+++ b/test/plausible/release_test.exs
@@ -1,35 +1,43 @@
defmodule Plausible.ReleaseTest do
- use Plausible.DataCase
+ use Plausible.DataCase, async: true
alias Plausible.{Release, Auth}
+ import ExUnit.CaptureIO
describe "should_be_first_launch?/0" do
+ @tag :small_build_only
test "returns true when self-hosted and no users" do
- patch_env(:is_selfhost, true)
refute Repo.exists?(Auth.User)
assert Release.should_be_first_launch?()
end
+ @tag :full_build_only
test "returns false when not self-hosted and has no users" do
- patch_env(:is_selfhost, false)
refute Repo.exists?(Auth.User)
refute Release.should_be_first_launch?()
end
+ @tag :full_build_only
test "returns false when not self-hosted and has users" do
insert(:user)
- patch_env(:is_selfhost, false)
refute Release.should_be_first_launch?()
end
+ @tag :small_build_only
test "returns false when self-hosted and has users" do
insert(:user)
- patch_env(:is_selfhost, true)
refute Release.should_be_first_launch?()
end
end
test "dump_plans/0 inserts plans" do
- Release.dump_plans()
- assert Plausible.Repo.aggregate("plans", :count) == 54
+ stdout =
+ capture_io(fn ->
+ Release.dump_plans()
+ end)
+
+ assert stdout =~ "Loading plausible.."
+ assert stdout =~ "Starting dependencies.."
+ assert stdout =~ "Starting repos.."
+ assert stdout =~ "Inserted 54 plans"
end
end
diff --git a/test/plausible/site/memberships/accept_invitation_test.exs b/test/plausible/site/memberships/accept_invitation_test.exs
index c7fdaa25cf..3098dc2572 100644
--- a/test/plausible/site/memberships/accept_invitation_test.exs
+++ b/test/plausible/site/memberships/accept_invitation_test.exs
@@ -367,6 +367,7 @@ defmodule Plausible.Site.Memberships.AcceptInvitationTest do
refute Repo.reload(invitation)
end
+ @tag :full_build_only
test "locks the site if the new owner has no active subscription or trial" do
existing_owner = insert(:user)
@@ -420,6 +421,7 @@ defmodule Plausible.Site.Memberships.AcceptInvitationTest do
refute Repo.reload!(site).locked
end
+ @tag :full_build_only
test "ends trial of the new owner immediately" do
existing_owner = insert(:user)
@@ -446,6 +448,7 @@ defmodule Plausible.Site.Memberships.AcceptInvitationTest do
assert Repo.reload!(site).locked
end
+ @tag :full_build_only
test "sets user's trial expiry date to yesterday if they don't have one" do
existing_owner = insert(:user)
@@ -472,6 +475,7 @@ defmodule Plausible.Site.Memberships.AcceptInvitationTest do
assert Repo.reload!(site).locked
end
+ @tag :full_build_only
test "ends grace period and sends an email about it if new owner is past grace period" do
existing_owner = insert(:user)
diff --git a/test/plausible/site/memberships/create_invitation_test.exs b/test/plausible/site/memberships/create_invitation_test.exs
index 672fdde1d0..5b8e6f7205 100644
--- a/test/plausible/site/memberships/create_invitation_test.exs
+++ b/test/plausible/site/memberships/create_invitation_test.exs
@@ -67,7 +67,7 @@ defmodule Plausible.Site.Memberships.CreateInvitationTest do
end
test "returns error when owner is over their team member limit" do
- [owner, inviter, invitee] = insert_list(3, :user, inserted_at: ~N[2024-01-01T00:00:00Z])
+ [owner, inviter, invitee] = insert_list(3, :user)
memberships =
[
diff --git a/test/plausible/site/sites_test.exs b/test/plausible/site/sites_test.exs
index 7e5d489b4d..7406d2e857 100644
--- a/test/plausible/site/sites_test.exs
+++ b/test/plausible/site/sites_test.exs
@@ -69,6 +69,7 @@ defmodule Plausible.SitesTest do
end
describe "get_for_user/2" do
+ @tag :full_build_only
test "get site for super_admin" do
user1 = insert(:user)
user2 = insert(:user)
diff --git a/test/plausible/stats/query_test.exs b/test/plausible/stats/query_test.exs
index 415f66e670..49b4033c26 100644
--- a/test/plausible/stats/query_test.exs
+++ b/test/plausible/stats/query_test.exs
@@ -158,11 +158,13 @@ defmodule Plausible.Stats.QueryTest do
assert q.interval == "date"
end
+ @tag :full_build_only
test "adds sample_threshold :infinite to query struct", %{site: site} do
q = Query.from(site, %{"period" => "30d", "sample_threshold" => "infinite"})
assert q.sample_threshold == :infinite
end
+ @tag :full_build_only
test "casts sample_threshold to integer in query struct", %{site: site} do
q = Query.from(site, %{"period" => "30d", "sample_threshold" => "30000000"})
assert q.sample_threshold == 30_000_000
diff --git a/test/plausible_web/components/billing_test.exs b/test/plausible_web/components/billing_test.exs
index 23eaf5cd92..f71a60220c 100644
--- a/test/plausible_web/components/billing_test.exs
+++ b/test/plausible_web/components/billing_test.exs
@@ -87,6 +87,7 @@ defmodule PlausibleWeb.Components.BillingTest do
assert rendered =~ "please reach out to the site owner to upgrade their subscription"
end
+ @tag :full_build_only
test "limit_exceeded_notice/1 when billable user is on trial displays upgrade link" do
me = insert(:user)
diff --git a/test/plausible_web/controllers/admin_auth_controller_test.exs b/test/plausible_web/controllers/admin_auth_controller_test.exs
index e07fb17e57..dc216e126f 100644
--- a/test/plausible_web/controllers/admin_auth_controller_test.exs
+++ b/test/plausible_web/controllers/admin_auth_controller_test.exs
@@ -2,11 +2,10 @@ defmodule PlausibleWeb.AdminAuthControllerTest do
use PlausibleWeb.ConnCase
alias Plausible.Release
- setup_patch_env(:is_selfhost, true)
-
describe "GET /" do
+ @describetag :small_build_only
test "disable registration", %{conn: conn} do
- prevent_first_launch()
+ insert(:user)
patch_config(disable_registration: true)
conn = get(conn, "/register")
assert redirected_to(conn) == "/login"
@@ -26,8 +25,4 @@ defmodule PlausibleWeb.AdminAuthControllerTest do
updated_config = Keyword.merge([disable_registration: false], config)
patch_env(:selfhost, updated_config)
end
-
- defp prevent_first_launch do
- insert(:user)
- end
end
diff --git a/test/plausible_web/controllers/api/external_stats_controller/auth_test.exs b/test/plausible_web/controllers/api/external_stats_controller/auth_test.exs
index a88968e9a8..0a88373106 100644
--- a/test/plausible_web/controllers/api/external_stats_controller/auth_test.exs
+++ b/test/plausible_web/controllers/api/external_stats_controller/auth_test.exs
@@ -67,6 +67,7 @@ defmodule PlausibleWeb.Api.ExternalStatsController.AuthTest do
end
describe "super admin access" do
+ @describetag :full_build_only
setup %{user: user} do
patch_env(:super_admin_user_ids, [user.id])
end
diff --git a/test/plausible_web/controllers/api/internal_controller/sync_test.exs b/test/plausible_web/controllers/api/internal_controller/sync_test.exs
index 6f32589af2..f5d3b883b3 100644
--- a/test/plausible_web/controllers/api/internal_controller/sync_test.exs
+++ b/test/plausible_web/controllers/api/internal_controller/sync_test.exs
@@ -5,6 +5,7 @@ defmodule PlausibleWeb.Api.InternalController.SyncTest do
describe "PUT /api/:domain/disable-feature" do
setup [:create_user, :log_in]
+ @tag :full_build_only
test "when the logged-in user is an super-admin", %{conn: conn, user: user} do
site = insert(:site)
patch_env(:super_admin_user_ids, [user.id])
diff --git a/test/plausible_web/controllers/auth_controller/logs_test.exs b/test/plausible_web/controllers/auth_controller/logs_test.exs
index e2b1bc293b..2babcfb326 100644
--- a/test/plausible_web/controllers/auth_controller/logs_test.exs
+++ b/test/plausible_web/controllers/auth_controller/logs_test.exs
@@ -2,6 +2,8 @@ defmodule PlausibleWeb.AuthController.LogsTest do
use PlausibleWeb.ConnCase
import ExUnit.CaptureLog
+ setup {PlausibleWeb.FirstLaunchPlug.Test, :skip}
+
describe "POST /login" do
setup do
patch_env(:log_failed_login_attempts, true)
diff --git a/test/plausible_web/controllers/auth_controller_test.exs b/test/plausible_web/controllers/auth_controller_test.exs
index cf579e81e6..7c2e0edcc1 100644
--- a/test/plausible_web/controllers/auth_controller_test.exs
+++ b/test/plausible_web/controllers/auth_controller_test.exs
@@ -13,7 +13,8 @@ defmodule PlausibleWeb.AuthControllerTest do
alias Plausible.Auth.User
alias Plausible.Billing.Subscription
- setup :verify_on_exit!
+ setup {PlausibleWeb.FirstLaunchPlug.Test, :skip}
+ setup [:verify_on_exit!]
@v3_plan_id "749355"
@v4_plan_id "857097"
@@ -442,7 +443,8 @@ defmodule PlausibleWeb.AuthControllerTest do
assert location = "/login" = redirected_to(conn, 302)
- conn = get(recycle(conn), location)
+ {:ok, %{conn: conn}} = PlausibleWeb.FirstLaunchPlug.Test.skip(%{conn: recycle(conn)})
+ conn = get(conn, location)
assert html_response(conn, 200) =~ "Password updated successfully"
end
end
@@ -457,6 +459,7 @@ defmodule PlausibleWeb.AuthControllerTest do
assert resp =~ "Change email address"
end
+ @tag :full_build_only
test "shows subscription", %{conn: conn, user: user} do
insert(:subscription, paddle_plan_id: "558018", user: user)
conn = get(conn, "/settings")
@@ -464,6 +467,7 @@ defmodule PlausibleWeb.AuthControllerTest do
assert html_response(conn, 200) =~ "monthly billing"
end
+ @tag :full_build_only
test "shows yearly subscription", %{conn: conn, user: user} do
insert(:subscription, paddle_plan_id: "590752", user: user)
conn = get(conn, "/settings")
@@ -471,6 +475,7 @@ defmodule PlausibleWeb.AuthControllerTest do
assert html_response(conn, 200) =~ "yearly billing"
end
+ @tag :full_build_only
test "shows free subscription", %{conn: conn, user: user} do
insert(:subscription, paddle_plan_id: "free_10k", user: user)
conn = get(conn, "/settings")
@@ -478,6 +483,7 @@ defmodule PlausibleWeb.AuthControllerTest do
assert html_response(conn, 200) =~ "N/A billing"
end
+ @tag :full_build_only
test "shows enterprise plan subscription", %{conn: conn, user: user} do
insert(:subscription, paddle_plan_id: "123", user: user)
@@ -488,6 +494,7 @@ defmodule PlausibleWeb.AuthControllerTest do
assert html_response(conn, 200) =~ "yearly billing"
end
+ @tag :full_build_only
test "shows current enterprise plan subscription when user has a new one to upgrade to", %{
conn: conn,
user: user
@@ -511,6 +518,7 @@ defmodule PlausibleWeb.AuthControllerTest do
assert html_response(conn, 200) =~ "yearly billing"
end
+ @tag :full_build_only
test "renders two links to '/billing/choose-plan` with the text 'Upgrade'", %{conn: conn} do
doc =
get(conn, "/settings")
@@ -526,6 +534,7 @@ defmodule PlausibleWeb.AuthControllerTest do
assert text_of_attr(upgrade_link_2, "href") == Routes.billing_path(conn, :choose_plan)
end
+ @tag :full_build_only
test "renders a link to '/billing/choose-plan' with the text 'Change plan' + cancel link", %{
conn: conn,
user: user
@@ -585,6 +594,7 @@ defmodule PlausibleWeb.AuthControllerTest do
refute element_exists?(doc, "#upgrade-or-change-plan-link")
end
+ @tag :full_build_only
test "renders two links to '/billing/choose-plan' with the text 'Upgrade' for a configured enterprise plan",
%{conn: conn, user: user} do
configure_enterprise_plan(user)
@@ -607,6 +617,7 @@ defmodule PlausibleWeb.AuthControllerTest do
Routes.billing_path(conn, :choose_plan)
end
+ @tag :full_build_only
test "links to '/billing/choose-plan' with the text 'Change plan' for a configured enterprise plan with an existing subscription + renders cancel button",
%{conn: conn, user: user} do
insert(:subscription, paddle_plan_id: @v3_plan_id, user: user)
@@ -628,6 +639,7 @@ defmodule PlausibleWeb.AuthControllerTest do
Routes.billing_path(conn, :choose_plan)
end
+ @tag :full_build_only
test "renders cancelled subscription notice", %{conn: conn, user: user} do
insert(:subscription,
paddle_plan_id: @v4_plan_id,
@@ -645,6 +657,7 @@ defmodule PlausibleWeb.AuthControllerTest do
assert notice_text =~ "Upgrade your subscription to get access to your stats again"
end
+ @tag :full_build_only
test "renders cancelled subscription notice with some subscription days still left", %{
conn: conn,
user: user
@@ -666,6 +679,7 @@ defmodule PlausibleWeb.AuthControllerTest do
assert notice_text =~ "Upgrade your subscription to make sure you don't lose access"
end
+ @tag :full_build_only
test "renders cancelled subscription notice with a warning about losing grandfathering", %{
conn: conn,
user: user
@@ -689,6 +703,7 @@ defmodule PlausibleWeb.AuthControllerTest do
"by letting your subscription expire, you lose access to our grandfathered terms"
end
+ @tag :full_build_only
test "shows invoices for subscribed user", %{conn: conn, user: user} do
insert(:subscription,
paddle_plan_id: "558018",
@@ -703,6 +718,7 @@ defmodule PlausibleWeb.AuthControllerTest do
assert html_response(conn, 200) =~ "$22.00"
end
+ @tag :full_build_only
test "shows 'something went wrong' on failed invoice request'", %{conn: conn, user: user} do
insert(:subscription,
paddle_plan_id: "558018",
diff --git a/test/plausible_web/controllers/avatar_controller_test.exs b/test/plausible_web/controllers/avatar_controller_test.exs
index 9ac531eb9b..7639f7ca1c 100644
--- a/test/plausible_web/controllers/avatar_controller_test.exs
+++ b/test/plausible_web/controllers/avatar_controller_test.exs
@@ -4,6 +4,8 @@ defmodule PlausibleWeb.AvatarControllerTest do
import Mox
setup :verify_on_exit!
+ setup {PlausibleWeb.FirstLaunchPlug.Test, :skip}
+
describe "GET /avatar/:hash" do
test "proxies the request to gravatar", %{conn: conn} do
expect(
diff --git a/test/plausible_web/controllers/error_report_controller_test.exs b/test/plausible_web/controllers/error_report_controller_test.exs
index 3af101c7dc..52eed66135 100644
--- a/test/plausible_web/controllers/error_report_controller_test.exs
+++ b/test/plausible_web/controllers/error_report_controller_test.exs
@@ -1,5 +1,7 @@
defmodule PlausibleWeb.ErrorReportControllerTest do
use PlausibleWeb.ConnCase, async: true
+ @moduletag :full_build_only
+
use Bamboo.Test
import Phoenix.View
diff --git a/test/plausible_web/controllers/page_controller_test.exs b/test/plausible_web/controllers/page_controller_test.exs
index f9246391da..b4c390a0f0 100644
--- a/test/plausible_web/controllers/page_controller_test.exs
+++ b/test/plausible_web/controllers/page_controller_test.exs
@@ -1,6 +1,8 @@
defmodule PlausibleWeb.PageControllerTest do
use PlausibleWeb.ConnCase, async: true
+ setup {PlausibleWeb.FirstLaunchPlug.Test, :skip}
+
describe "GET /" do
test "shows landing page when user not authenticated", %{conn: conn} do
assert conn |> get("/") |> html_response(200) =~ "Welcome to Plausible Analytics!"
diff --git a/test/plausible_web/controllers/site_controller_test.exs b/test/plausible_web/controllers/site_controller_test.exs
index a7601a4290..d8629cb9f3 100644
--- a/test/plausible_web/controllers/site_controller_test.exs
+++ b/test/plausible_web/controllers/site_controller_test.exs
@@ -298,6 +298,7 @@ defmodule PlausibleWeb.SiteControllerTest do
assert_no_emails_delivered()
end
+ @tag :full_build_only
test "does not allow site creation when the user is at their site limit", %{
conn: conn,
user: user
@@ -552,7 +553,6 @@ defmodule PlausibleWeb.SiteControllerTest do
test "deletes the site", %{conn: conn, user: user} do
site = insert(:site, members: [user])
insert(:google_auth, user: user, site: site)
- insert(:custom_domain, site: site)
insert(:spike_notification, site: site)
delete(conn, "/#{site.domain}")
@@ -563,7 +563,6 @@ defmodule PlausibleWeb.SiteControllerTest do
test "fails to delete a site with insufficient permissions", %{conn: conn, user: user} do
site = insert(:site, memberships: [build(:site_membership, user: user, role: :viewer)])
insert(:google_auth, user: user, site: site)
- insert(:custom_domain, site: site)
insert(:spike_notification, site: site)
conn = delete(conn, "/#{site.domain}")
@@ -581,7 +580,6 @@ defmodule PlausibleWeb.SiteControllerTest do
insert(:site, memberships: [build(:site_membership, user: other_user, role: "owner")])
insert(:google_auth, user: other_user, site: other_site)
- insert(:custom_domain, site: other_site)
insert(:spike_notification, site: other_site)
my_conn = delete(my_conn, "/#{other_site.domain}")
@@ -1229,35 +1227,6 @@ defmodule PlausibleWeb.SiteControllerTest do
end
end
- describe "DELETE sites/:website/custom-domains/:id" do
- setup [:create_user, :log_in, :create_site]
-
- test "deletes custom domain", %{conn: conn, site: site} do
- domain = insert(:custom_domain, site: site)
-
- conn = delete(conn, "/sites/#{site.domain}/custom-domains/#{domain.id}")
-
- assert Phoenix.Flash.get(conn.assigns.flash, :success) ==
- "Custom domain deleted successfully"
-
- assert Repo.aggregate(Plausible.Site.CustomDomain, :count, :id) == 0
- end
-
- test "fails to delete custom domain not owning it", %{conn: conn, site: site} do
- _og_domain = insert(:custom_domain, site: site)
-
- foreign_site = insert(:site)
- foreign_domain = insert(:custom_domain, site: foreign_site)
-
- assert Repo.aggregate(Plausible.Site.CustomDomain, :count, :id) == 2
-
- conn = delete(conn, "/sites/#{site.domain}/custom-domains/#{foreign_domain.id}")
- assert Phoenix.Flash.get(conn.assigns.flash, :error) == "Failed to delete custom domain"
-
- assert Repo.aggregate(Plausible.Site.CustomDomain, :count, :id) == 2
- end
- end
-
describe "GET /:website/import/google-analytics/view-id" do
setup [:create_user, :log_in, :create_new_site]
diff --git a/test/plausible_web/controllers/stats_controller_test.exs b/test/plausible_web/controllers/stats_controller_test.exs
index cf3ef23820..721749ae04 100644
--- a/test/plausible_web/controllers/stats_controller_test.exs
+++ b/test/plausible_web/controllers/stats_controller_test.exs
@@ -3,6 +3,8 @@ defmodule PlausibleWeb.StatsControllerTest do
use Plausible.Repo
import Plausible.Test.Support.HTML
+ @react_container "div#stats-react-container"
+
describe "GET /:website - anonymous user" do
test "public site - shows site stats", %{conn: conn} do
site = insert(:site, public: true)
@@ -10,7 +12,10 @@ defmodule PlausibleWeb.StatsControllerTest do
conn = get(conn, "/#{site.domain}")
resp = html_response(conn, 200)
- assert element_exists?(resp, "div#stats-react-container")
+ assert element_exists?(resp, @react_container)
+
+ assert text_of_attr(resp, @react_container, "data-domain") == site.domain
+ assert text_of_attr(resp, @react_container, "data-is-dbip") == "false"
assert ["noindex, nofollow"] ==
resp
@@ -26,7 +31,7 @@ defmodule PlausibleWeb.StatsControllerTest do
conn = get(conn, "/#{site.domain}")
resp = html_response(conn, 200)
- assert element_exists?(resp, "div#stats-react-container")
+ assert element_exists?(resp, @react_container)
assert ["index, nofollow"] ==
resp
@@ -44,6 +49,7 @@ defmodule PlausibleWeb.StatsControllerTest do
end
test "can not view stats of a private website", %{conn: conn} do
+ _ = insert(:user)
conn = get(conn, "/test-site.com")
assert html_response(conn, 404) =~ "There's nothing here"
end
@@ -72,6 +78,7 @@ defmodule PlausibleWeb.StatsControllerTest do
end
describe "GET /:website - as a super admin" do
+ @describetag :full_build_only
setup [:create_user, :make_user_super_admin, :log_in]
test "can view a private dashboard with stats", %{conn: conn} do
diff --git a/test/plausible_web/controllers/unsubscribe_controller_test.exs b/test/plausible_web/controllers/unsubscribe_controller_test.exs
index d955270646..4d398e7b20 100644
--- a/test/plausible_web/controllers/unsubscribe_controller_test.exs
+++ b/test/plausible_web/controllers/unsubscribe_controller_test.exs
@@ -2,6 +2,8 @@ defmodule PlausibleWeb.UnsubscribeControllerTest do
use PlausibleWeb.ConnCase, async: true
use Plausible.Repo
+ setup {PlausibleWeb.FirstLaunchPlug.Test, :skip}
+
describe "GET /sites/:website/weekly-report/unsubscribe" do
test "removes a recipient from the weekly report without them having to log in", %{conn: conn} do
site = insert(:site)
diff --git a/test/plausible_web/plugs/first_launch_plug_test.exs b/test/plausible_web/plugs/first_launch_plug_test.exs
index 7048a8fe97..6f33f99b13 100644
--- a/test/plausible_web/plugs/first_launch_plug_test.exs
+++ b/test/plausible_web/plugs/first_launch_plug_test.exs
@@ -1,5 +1,6 @@
defmodule PlausibleWeb.FirstLaunchPlugTest do
use PlausibleWeb.ConnCase
+ @moduletag :small_build_only
import Plug.Test
alias PlausibleWeb.FirstLaunchPlug
@@ -25,7 +26,6 @@ defmodule PlausibleWeb.FirstLaunchPlugTest do
refute conn.halted
# even when it's the first launch
- patch_env(:is_selfhost, true)
assert Release.should_be_first_launch?()
conn = conn("GET", "/register")
@@ -34,6 +34,7 @@ defmodule PlausibleWeb.FirstLaunchPlugTest do
end
test "no-op when not first launch" do
+ insert(:user)
refute Release.should_be_first_launch?()
conn = conn("GET", "/sites")
conn = FirstLaunchPlug.call(conn, @opts)
@@ -41,7 +42,6 @@ defmodule PlausibleWeb.FirstLaunchPlugTest do
end
test "redirects to :redirect_to when first launch" do
- patch_env(:is_selfhost, true)
assert Release.should_be_first_launch?()
conn = conn("GET", "/sites")
@@ -53,21 +53,10 @@ defmodule PlausibleWeb.FirstLaunchPlugTest do
describe "first launch plug in :browser pipeline" do
test "redirects to /register on first launch", %{conn: conn} do
- patch_env(:is_selfhost, true)
assert Release.should_be_first_launch?()
conn = get(conn, "/")
assert redirected_to(conn) == "/register"
end
-
- test "no-op when not first launch", %{conn: conn} do
- patch_env(:is_selfhost, false)
- refute Release.should_be_first_launch?()
-
- # gets redirected to login by auth plugs
- # "first launch" doesn't interfere
- conn = get(conn, "/sites")
- assert redirected_to(conn) == "/login"
- end
end
end
diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex
index 60c0d82004..a09926d59f 100644
--- a/test/support/conn_case.ex
+++ b/test/support/conn_case.ex
@@ -19,6 +19,7 @@ defmodule PlausibleWeb.ConnCase do
quote do
# Import conveniences for testing with connections
use Plausible.TestUtils
+ use Plausible
import Plug.Conn
import Phoenix.ConnTest
alias PlausibleWeb.Router.Helpers, as: Routes
diff --git a/test/support/factory.ex b/test/support/factory.ex
index 6ee76a287c..4b3606ee89 100644
--- a/test/support/factory.ex
+++ b/test/support/factory.ex
@@ -135,12 +135,6 @@ defmodule Plausible.Factory do
}
end
- def custom_domain_factory do
- %Plausible.Site.CustomDomain{
- domain: sequence(:custom_domain, &"domain-#{&1}.com")
- }
- end
-
def weekly_report_factory do
%Plausible.Site.WeeklyReport{}
end
diff --git a/test/support/test_utils.ex b/test/support/test_utils.ex
index 078b958c10..b0987a860f 100644
--- a/test/support/test_utils.ex
+++ b/test/support/test_utils.ex
@@ -35,12 +35,7 @@ defmodule Plausible.TestUtils do
end
def create_user(_) do
- {:ok,
- user:
- Factory.insert(:user,
- inserted_at: ~U[2024-01-01T00:00:00Z],
- trial_expiry_date: ~D[2024-02-01]
- )}
+ {:ok, user: Factory.insert(:user)}
end
def create_site(%{user: user}) do
diff --git a/test/test_helper.exs b/test/test_helper.exs
index 68ecf5e1c3..ed8c804287 100644
--- a/test/test_helper.exs
+++ b/test/test_helper.exs
@@ -6,7 +6,9 @@ FunWithFlags.enable(:window_time_on_page)
Ecto.Adapters.SQL.Sandbox.mode(Plausible.Repo, :manual)
if Mix.env() == :small_test do
+ IO.puts("Test mode: SMALL")
ExUnit.configure(exclude: [:slow, :full_build_only])
else
+ IO.puts("Test mode: FULL")
ExUnit.configure(exclude: [:slow, :small_build_only])
end