Bump funnel max size to 8 steps (#3094)

* Bump max funnel size to 8 steps

* Improve chart rendering for small screens/large funnels
pull/3109/head r2023.07.04-139
hq1 3 years ago committed by GitHub
parent ade437c085
commit 01fba1f34b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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 up
var 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,

@ -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 journey

@ -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,

Loading…
Cancel
Save