Skip to content

Commit

Permalink
Remove funnels feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
aerosol committed Sep 5, 2023
1 parent abbfdf5 commit 6ec8fd5
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 36 deletions.
53 changes: 28 additions & 25 deletions lib/plausible_web/controllers/site_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@ defmodule PlausibleWeb.SiteController do
use Plausible.Repo
alias Plausible.{Sites, Goals}

plug PlausibleWeb.RequireAccountPlug
plug(PlausibleWeb.RequireAccountPlug)

plug PlausibleWeb.AuthorizeSiteAccess,
[:owner, :admin, :super_admin] when action not in [:index, :new, :create_site]
plug(
PlausibleWeb.AuthorizeSiteAccess,
[:owner, :admin, :super_admin] when action not in [:index, :new, :create_site]
)

def index(conn, params) do
user = conn.assigns[:current_user]

invitations =
Repo.all(
from i in Plausible.Auth.Invitation,
from(i in Plausible.Auth.Invitation,
where: i.email == ^user.email
)
)
|> Repo.preload(:site)

Expand Down Expand Up @@ -106,10 +109,11 @@ defmodule PlausibleWeb.SiteController do

is_first_site =
!Repo.exists?(
from sm in Plausible.Site.Membership,
from(sm in Plausible.Site.Membership,
where:
sm.user_id == ^user.id and
sm.site_id != ^site.id
)
)

conn
Expand Down Expand Up @@ -203,7 +207,7 @@ defmodule PlausibleWeb.SiteController do

def settings_visibility(conn, _params) do
site = conn.assigns[:site] |> Repo.preload(:custom_domain)
shared_links = Repo.all(from l in Plausible.Site.SharedLink, where: l.site_id == ^site.id)
shared_links = Repo.all(from(l in Plausible.Site.SharedLink, where: l.site_id == ^site.id))

conn
|> assign(:skip_plausible_tracking, true)
Expand All @@ -227,19 +231,15 @@ defmodule PlausibleWeb.SiteController do
end

def settings_funnels(conn, _params) do
if Plausible.Funnels.enabled_for?(conn.assigns[:current_user]) do
site = conn.assigns[:site] |> Repo.preload(:custom_domain)

conn
|> assign(:skip_plausible_tracking, true)
|> render("settings_funnels.html",
site: site,
connect_live_socket: true,
layout: {PlausibleWeb.LayoutView, "site_settings.html"}
)
else
conn |> Plug.Conn.put_status(401) |> Plug.Conn.halt()
end
site = conn.assigns[:site] |> Repo.preload(:custom_domain)

conn
|> assign(:skip_plausible_tracking, true)
|> render("settings_funnels.html",
site: site,
connect_live_socket: true,
layout: {PlausibleWeb.LayoutView, "site_settings.html"}
)
end

def settings_props(conn, _params) do
Expand Down Expand Up @@ -428,7 +428,7 @@ defmodule PlausibleWeb.SiteController do

def disable_weekly_report(conn, _params) do
site = conn.assigns[:site]
Repo.delete_all(from wr in Plausible.Site.WeeklyReport, where: wr.site_id == ^site.id)
Repo.delete_all(from(wr in Plausible.Site.WeeklyReport, where: wr.site_id == ^site.id))

conn
|> put_flash(:success, "You will not receive weekly email reports going forward")
Expand Down Expand Up @@ -482,7 +482,7 @@ defmodule PlausibleWeb.SiteController do

def disable_monthly_report(conn, _params) do
site = conn.assigns[:site]
Repo.delete_all(from mr in Plausible.Site.MonthlyReport, where: mr.site_id == ^site.id)
Repo.delete_all(from(mr in Plausible.Site.MonthlyReport, where: mr.site_id == ^site.id))

conn
|> put_flash(:success, "You will not receive monthly email reports going forward")
Expand Down Expand Up @@ -542,7 +542,7 @@ defmodule PlausibleWeb.SiteController do

def disable_spike_notification(conn, _params) do
site = conn.assigns[:site]
Repo.delete_all(from mr in Plausible.Site.SpikeNotification, where: mr.site_id == ^site.id)
Repo.delete_all(from(mr in Plausible.Site.SpikeNotification, where: mr.site_id == ^site.id))

conn
|> put_flash(:success, "Spike notification disabled")
Expand Down Expand Up @@ -658,9 +658,10 @@ defmodule PlausibleWeb.SiteController do
site_id = site.id

case Repo.delete_all(
from l in Plausible.Site.SharedLink,
from(l in Plausible.Site.SharedLink,
where: l.slug == ^slug,
where: l.site_id == ^site_id
)
) do
{1, _} ->
conn
Expand All @@ -679,9 +680,10 @@ defmodule PlausibleWeb.SiteController do
site_id = site.id

case Repo.delete_all(
from d in Plausible.Site.CustomDomain,
from(d in Plausible.Site.CustomDomain,
where: d.site_id == ^site_id,
where: d.id == ^domain_id
)
) do
{1, _} ->
conn
Expand Down Expand Up @@ -872,10 +874,11 @@ defmodule PlausibleWeb.SiteController do
cond do
site.imported_data ->
Oban.cancel_all_jobs(
from j in Oban.Job,
from(j in Oban.Job,
where:
j.queue == "google_analytics_imports" and
fragment("(? ->> 'site_id')::int", j.args) == ^site.id
)
)

Plausible.Imported.forget(site)
Expand Down
6 changes: 2 additions & 4 deletions lib/plausible_web/controllers/stats_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,8 @@ defmodule PlausibleWeb.StatsController do

defp shared_link_cookie_name(slug), do: "shared-link-" <> slug

defp get_flags(user) do
%{
funnels: Plausible.Funnels.enabled_for?(user)
}
defp get_flags(_user) do
%{}
end

defp is_dbip() do
Expand Down
2 changes: 0 additions & 2 deletions lib/plausible_web/live/funnel_settings.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ defmodule PlausibleWeb.Live.FunnelSettings do
%{"site_id" => site_id, "domain" => domain, "current_user_id" => user_id},
socket
) do
true = Plausible.Funnels.enabled_for?("user:#{user_id}")

socket =
socket
|> assign_new(:site, fn ->
Expand Down
4 changes: 1 addition & 3 deletions lib/plausible_web/views/layout_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ defmodule PlausibleWeb.LayoutView do
[key: "People", value: "people"],
[key: "Visibility", value: "visibility"],
[key: "Goals", value: "goals"],
if Plausible.Funnels.enabled_for?(conn.assigns[:current_user]) do
[key: "Funnels", value: "funnels"]
end,
[key: "Funnels", value: "funnels"],
[key: "Custom Properties", value: "properties"],
[key: "Search Console", value: "search-console"],
[key: "Email Reports", value: "email-reports"],
Expand Down
2 changes: 0 additions & 2 deletions priv/repo/seeds.exs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

user = Plausible.Factory.insert(:user, email: "user@plausible.test", password: "plausible")

FunWithFlags.enable(:funnels)

native_stats_range =
Date.range(
Date.add(Date.utc_today(), -720),
Expand Down

0 comments on commit 6ec8fd5

Please sign in to comment.