+ )
+}
\ No newline at end of file
diff --git a/assets/js/dashboard/historical.js b/assets/js/dashboard/historical.js
index 524bcbab5..8f6dcdb90 100644
--- a/assets/js/dashboard/historical.js
+++ b/assets/js/dashboard/historical.js
@@ -9,25 +9,13 @@ import Sources from './stats/sources'
import Pages from './stats/pages'
import Locations from './stats/locations';
import Devices from './stats/devices'
-import Conversions from './stats/conversions'
+import Behaviours from './stats/behaviours'
import ComparisonInput from './comparison-input'
import { withPinnedHeader } from './pinned-header-hoc';
function Historical(props) {
const tooltipBoundary = React.useRef(null)
- function renderConversions() {
- if (props.site.hasGoals) {
- return (
-
-
-
- )
- }
-
- return null
- }
-
return (
@@ -51,7 +39,7 @@ function Historical(props) {
- { renderConversions() }
+
)
}
diff --git a/assets/js/dashboard/mount.js b/assets/js/dashboard/mount.js
index 9c923a88b..2f867b563 100644
--- a/assets/js/dashboard/mount.js
+++ b/assets/js/dashboard/mount.js
@@ -16,6 +16,10 @@ if (container) {
domain: container.dataset.domain,
offset: container.dataset.offset,
hasGoals: container.dataset.hasGoals === 'true',
+ conversionsEnabled: container.dataset.conversionsEnabled === 'true',
+ funnelsEnabled: container.dataset.funnelsEnabled === 'true',
+ propsEnabled: container.dataset.propsEnabled === 'true',
+ funnels: JSON.parse(container.dataset.funnels),
statsBegin: container.dataset.statsBegin,
nativeStatsBegin: container.dataset.nativeStatsBegin,
embedded: container.dataset.embedded,
diff --git a/assets/js/dashboard/realtime.js b/assets/js/dashboard/realtime.js
index 1c85f8b8c..ea1a283ef 100644
--- a/assets/js/dashboard/realtime.js
+++ b/assets/js/dashboard/realtime.js
@@ -8,22 +8,10 @@ import Sources from './stats/sources'
import Pages from './stats/pages'
import Locations from './stats/locations'
import Devices from './stats/devices'
-import Conversions from './stats/conversions'
+import Behaviours from './stats/behaviours'
import { withPinnedHeader } from './pinned-header-hoc';
class Realtime extends React.Component {
- renderConversions() {
- if (this.props.site.hasGoals) {
- return (
-
-
-
- )
- }
-
- return null
- }
-
render() {
const navClass = this.props.site.embedded ? 'relative' : 'sticky'
@@ -48,8 +36,7 @@ class Realtime extends React.Component {
-
- { this.renderConversions() }
+
)
}
diff --git a/assets/js/dashboard/stats/conversions/index.js b/assets/js/dashboard/stats/behaviours/conversions.js
similarity index 93%
rename from assets/js/dashboard/stats/conversions/index.js
rename to assets/js/dashboard/stats/behaviours/conversions.js
index 4b0976803..36a843b8b 100644
--- a/assets/js/dashboard/stats/conversions/index.js
+++ b/assets/js/dashboard/stats/behaviours/conversions.js
@@ -2,7 +2,6 @@ import React from 'react';
import { Link } from 'react-router-dom'
import FlipMove from 'react-flip-move'
-
import Bar from '../bar'
import PropBreakdown from './prop-breakdown'
import numberFormatter from '../../util/number-formatter'
@@ -100,7 +99,6 @@ export default class Conversions extends React.Component {
} else if (this.state.goals) {
return (
-
+ )
+ } else {
+ return null
+ }
+}
diff --git a/assets/js/dashboard/stats/conversions/prop-breakdown.js b/assets/js/dashboard/stats/behaviours/prop-breakdown.js
similarity index 100%
rename from assets/js/dashboard/stats/conversions/prop-breakdown.js
rename to assets/js/dashboard/stats/behaviours/prop-breakdown.js
diff --git a/lib/plausible/site.ex b/lib/plausible/site.ex
index 513a20fd8..d51d7e19d 100644
--- a/lib/plausible/site.ex
+++ b/lib/plausible/site.ex
@@ -18,6 +18,9 @@ defmodule Plausible.Site do
field :stats_start_date, :date
field :native_stats_start_at, :naive_datetime
field :allowed_event_props, {:array, :string}
+ field :conversions_enabled, :boolean
+ field :props_enabled, :boolean
+ field :funnels_enabled, :boolean
field :ingest_rate_limit_scale_seconds, :integer, default: 60
# default is set via changeset/2
@@ -166,6 +169,14 @@ defmodule Plausible.Site do
change(site, allowed_event_props: list)
end
+ def disable_feature(site, "conversions"), do: change(site, conversions_enabled: false)
+ def disable_feature(site, "funnels"), do: change(site, funnels_enabled: false)
+ def disable_feature(site, "props"), do: change(site, props_enabled: false)
+
+ def enable_feature(site, "conversions"), do: change(site, conversions_enabled: true)
+ def enable_feature(site, "funnels"), do: change(site, funnels_enabled: true)
+ def enable_feature(site, "props"), do: change(site, props_enabled: true)
+
def remove_imported_data(site) do
change(site, imported_data: nil)
end
diff --git a/lib/plausible_web/controllers/api/internal_controller.ex b/lib/plausible_web/controllers/api/internal_controller.ex
index 40ea59b92..751fcb6fc 100644
--- a/lib/plausible_web/controllers/api/internal_controller.ex
+++ b/lib/plausible_web/controllers/api/internal_controller.ex
@@ -2,9 +2,11 @@ defmodule PlausibleWeb.Api.InternalController do
use PlausibleWeb, :controller
use Plausible.Repo
alias Plausible.Stats.Clickhouse, as: Stats
+ alias Plausible.{Sites, Site, Auth}
+ alias Plausible.Auth.User
def domain_status(conn, %{"domain" => domain}) do
- site = Plausible.Sites.get_by_domain(domain)
+ site = Sites.get_by_domain(domain)
if Stats.has_pageviews?(site) do
json(conn, "READY")
@@ -30,11 +32,28 @@ defmodule PlausibleWeb.Api.InternalController do
end
end
+ def disable_feature(conn, %{"domain" => domain, "feature" => feature}) do
+ with %User{id: user_id} <- conn.assigns[:current_user],
+ site <- Sites.get_by_domain(domain),
+ true <- Sites.has_admin_access?(user_id, site) || Auth.is_super_admin?(user_id) do
+ Site.disable_feature(site, feature)
+ |> Repo.update()
+
+ json(conn, "ok")
+ else
+ _ ->
+ PlausibleWeb.Api.Helpers.unauthorized(
+ conn,
+ "You need to be logged in as the owner or admin account of this site"
+ )
+ end
+ end
+
defp sites_for(user, params) do
Repo.paginate(
from(
- s in Plausible.Site,
- join: sm in Plausible.Site.Membership,
+ s in Site,
+ join: sm in Site.Membership,
on: sm.site_id == s.id,
where: sm.user_id == ^user.id,
order_by: s.domain
diff --git a/lib/plausible_web/controllers/site_controller.ex b/lib/plausible_web/controllers/site_controller.ex
index 6de9010ec..2ee92f949 100644
--- a/lib/plausible_web/controllers/site_controller.ex
+++ b/lib/plausible_web/controllers/site_controller.ex
@@ -171,6 +171,34 @@ defmodule PlausibleWeb.SiteController do
end
end
+ def set_feature_status(conn, %{"action" => action, "feature" => feature}) do
+ site = conn.assigns[:site]
+
+ report_title =
+ case feature do
+ "conversions" -> "Goals"
+ "funnels" -> "Funnels"
+ "props" -> "Properties"
+ end
+
+ {change, flash_msg} =
+ case action do
+ "enable" ->
+ {Plausible.Site.enable_feature(site, feature),
+ "#{report_title} are now visible again on your dashboard"}
+
+ "disable" ->
+ {Plausible.Site.disable_feature(site, feature),
+ "#{report_title} are now hidden from your dashboard"}
+ end
+
+ Repo.update(change)
+
+ conn
+ |> put_flash(:success, flash_msg)
+ |> redirect(to: Routes.site_path(conn, :settings_goals, conn.assigns[:site].domain))
+ end
+
def settings(conn, %{"website" => website}) do
redirect(conn, to: Routes.site_path(conn, :settings_general, website))
end
diff --git a/lib/plausible_web/controllers/stats_controller.ex b/lib/plausible_web/controllers/stats_controller.ex
index ad93738fb..b32d8c8d3 100644
--- a/lib/plausible_web/controllers/stats_controller.ex
+++ b/lib/plausible_web/controllers/stats_controller.ex
@@ -64,6 +64,7 @@ defmodule PlausibleWeb.StatsController do
|> render("stats.html",
site: site,
has_goals: Plausible.Sites.has_goals?(site),
+ funnels: [],
stats_start_date: stats_start_date,
native_stats_start_date: NaiveDateTime.to_date(site.native_stats_start_at),
title: "Plausible · " <> site.domain,
@@ -291,6 +292,7 @@ defmodule PlausibleWeb.StatsController do
|> render("stats.html",
site: shared_link.site,
has_goals: Sites.has_goals?(shared_link.site),
+ funnels: [],
stats_start_date: shared_link.site.stats_start_date,
native_stats_start_date: NaiveDateTime.to_date(shared_link.site.native_stats_start_at),
title: "Plausible · " <> shared_link.site.domain,
@@ -324,8 +326,11 @@ defmodule PlausibleWeb.StatsController do
defp shared_link_cookie_name(slug), do: "shared-link-" <> slug
- defp get_flags(_user) do
- %{}
+ defp get_flags(user) do
+ %{
+ funnels: FunWithFlags.enabled?(:funnels, for: user),
+ props: FunWithFlags.enabled?(:props, for: user)
+ }
end
defp is_dbip() do
diff --git a/lib/plausible_web/router.ex b/lib/plausible_web/router.ex
index cd93e5fde..7ef5d2352 100644
--- a/lib/plausible_web/router.ex
+++ b/lib/plausible_web/router.ex
@@ -117,6 +117,8 @@ defmodule PlausibleWeb.Router do
post "/paddle/webhook", Api.PaddleController, :webhook
get "/:domain/status", Api.InternalController, :domain_status
+ put "/:domain/disable-feature", Api.InternalController, :disable_feature
+
get "/sites", Api.InternalController, :sites
end
@@ -251,6 +253,7 @@ defmodule PlausibleWeb.Router do
get "/:website/goals/new", SiteController, :new_goal
post "/:website/goals", SiteController, :create_goal
delete "/:website/goals/:id", SiteController, :delete_goal
+ put "/:website/settings/features/:action/:feature", SiteController, :set_feature_status
put "/:website/settings", SiteController, :update_settings
put "/:website/settings/google", SiteController, :update_google_auth
delete "/:website/settings/google-search", SiteController, :delete_google_auth
diff --git a/lib/plausible_web/templates/site/new_goal.html.eex b/lib/plausible_web/templates/site/new_goal.html.eex
index 0417c5a30..0dae3ce57 100644
--- a/lib/plausible_web/templates/site/new_goal.html.eex
+++ b/lib/plausible_web/templates/site/new_goal.html.eex
@@ -7,6 +7,11 @@
+
+ Custom events are not tracked by default - you have to configure them on your site to be sent to Plausible. See examples and learn more in
+ our docs.
+