Skip to content

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

Hook up flags to the custom prop filter

Uku Taht428ee747c3c5
diff --git a/assets/js/dashboard/filters.js b/assets/js/dashboard/filters.js
index 68e80edf69..950744e8a1 100644
--- a/assets/js/dashboard/filters.js
+++ b/assets/js/dashboard/filters.js
@@ -127,7 +127,9 @@ function DropdownContent({history, site, query, wrapped}) {
const [addingFilter, setAddingFilter] = useState(false);
if (wrapped === 0 || addingFilter) {
- return Object.keys(FILTER_GROUPS).map((option) => filterDropdownOption(site, option))
+ return Object.keys(FILTER_GROUPS)
+ .filter((option) => option === 'props' ? site.flags.custom_dimension_filter : true)
+ .map((option) => filterDropdownOption(site, option))
}
return (
diff --git a/assets/js/dashboard/mount.js b/assets/js/dashboard/mount.js
index 38cc914a3a..4490c98b71 100644
--- a/assets/js/dashboard/mount.js
+++ b/assets/js/dashboard/mount.js
@@ -16,7 +16,8 @@ if (container) {
statsBegin: container.dataset.statsBegin,
embedded: container.dataset.embedded,
background: container.dataset.background,
- selfhosted: container.dataset.selfhosted === 'true'
+ selfhosted: container.dataset.selfhosted === 'true',
+ flags: JSON.parse(container.dataset.flags)
}
const loggedIn = container.dataset.loggedIn === 'true'
diff --git a/lib/plausible_web/router.ex b/lib/plausible_web/router.ex
index 7687dcf7c2..a66abf7b2d 100644
--- a/lib/plausible_web/router.ex
+++ b/lib/plausible_web/router.ex
@@ -41,9 +41,11 @@ defmodule PlausibleWeb.Router do
plug PlausibleWeb.Firewall
end
- pipeline :mounted_apps do
+ pipeline :flags do
plug :accepts, ["html"]
plug :put_secure_browser_headers
+ plug :fetch_session
+ plug PlausibleWeb.CRMAuthPlug
end
if Mix.env() == :dev do
@@ -52,9 +54,9 @@ defmodule PlausibleWeb.Router do
use Kaffy.Routes, scope: "/crm", pipe_through: [PlausibleWeb.CRMAuthPlug]
- scope path: "/feature-flags" do
- pipe_through :mounted_apps
- forward "/", FunWithFlags.UI.Router, namespace: "feature-flags"
+ scope path: "/flags" do
+ pipe_through :flags
+ forward "/", FunWithFlags.UI.Router, namespace: "flags"
end
scope "/api/stats", PlausibleWeb.Api do