Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Bump funnel max size to 8 steps (#3094)
hq101fba1f34bd2
diff --git a/assets/js/dashboard/stats/behaviours/funnel.js b/assets/js/dashboard/stats/behaviours/funnel.jsindex 30b2ad1ed4..e044422f3d 100644--- a/assets/js/dashboard/stats/behaviours/funnel.js+++ b/assets/js/dashboard/stats/behaviours/funnel.js@@ -51,7 +51,7 @@ export default function Funnel(props) {}, [funnel, visible])useEffect(() => {- const mediaQuery = window.matchMedia('(max-width: 600px)')+ const mediaQuery = window.matchMedia('(max-width: 768px)')setSmallScreen(mediaQuery.matches)const handleScreenChange = (e) => {setSmallScreen(e.matches);@@ -164,6 +164,14 @@ export default function Funnel(props) {const dropOffData = funnel.steps.map((step) => step.dropoff)const ctx = canvasRef.current.getContext("2d")+ const calcBarThickness = (ctx) => {+ if (ctx.dataset.data.length <= 3) {+ return 160+ } else {+ return Math.floor(650 / ctx.dataset.data.length)+ }+ }+// passing those verbatim to make sure canvas rendering picks them upvar fontFamily = 'ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"'@@ -199,7 +207,7 @@ export default function Funnel(props) {data: data,options: {responsive: true,- barThickness: 120,+ barThickness: calcBarThickness,plugins: {legend: {display: false,diff --git a/lib/plausible/funnel.ex b/lib/plausible/funnel.exindex 4d8e24c8b2..208fec2afe 100644--- a/lib/plausible/funnel.ex+++ b/lib/plausible/funnel.ex@@ -1,6 +1,6 @@defmodule Plausible.Funnel do@min_steps 2- @max_steps 5+ @max_steps 8@moduledoc """A funnel is a marketing term used to capture and describe the journeydiff --git a/test/plausible/funnels_test.exs b/test/plausible/funnels_test.exsindex c600791f86..dbb0e0c763 100644--- a/test/plausible/funnels_test.exs+++ b/test/plausible/funnels_test.exs@@ -14,12 +14,15 @@ defmodule Plausible.FunnelsTest do{:ok, g4} = Goals.create(site, %{"event_name" => "Leave feedback"}){:ok, g5} = Goals.create(site, %{"page_path" => "/recommend"}){:ok, g6} = Goals.create(site, %{"event_name" => "Extra event"})+ {:ok, g7} = Goals.create(site, %{"event_name" => "Extra event 2"})+ {:ok, g8} = Goals.create(site, %{"event_name" => "Extra event 3"})+ {:ok, g9} = Goals.create(site, %{"event_name" => "Extra event 4"}){:ok,%{site: site,goals: [g1, g2, g3],- steps: [g1, g2, g3, g4, g5, g6] |> Enum.map(&%{"goal_id" => &1.id})+ steps: [g1, g2, g3, g4, g5, g6, g7, g8, g9] |> Enum.map(&%{"goal_id" => &1.id})}}end@@ -84,7 +87,14 @@ defmodule Plausible.FunnelsTest do)end- test "a funnel can be made of 5 steps maximum", %{site: site, steps: too_many_steps} do+ test "a funnel can be made of 8 steps maximum", %{site: site, steps: too_many_steps} do+ assert {:ok, _} =+ Funnels.create(+ site,+ "Lorem ipsum",+ Enum.take(too_many_steps, 8)+ )+assert {:error, :invalid_funnel_size} =Funnels.create(site,