+
{this.props.children}
diff --git a/assets/tailwind.config.js b/assets/tailwind.config.js
index a56552449688..4dfba9ebfac7 100644
--- a/assets/tailwind.config.js
+++ b/assets/tailwind.config.js
@@ -14,6 +14,7 @@ module.exports = {
extend: {
colors: {
orange: colors.orange,
+ 'gray-950': 'rgb(13, 18, 30)',
'gray-850': 'rgb(26, 32, 44)',
'gray-825': 'rgb(37, 47, 63)'
},
@@ -30,7 +31,7 @@ module.exports = {
'9': 9,
},
maxWidth: {
- '2xs': '16rem',
+ '2xs': '15rem',
'3xs': '12rem',
}
},
diff --git a/lib/plausible/stats/clickhouse.ex b/lib/plausible/stats/clickhouse.ex
index e636af7cd225..4aa6a899d98b 100644
--- a/lib/plausible/stats/clickhouse.ex
+++ b/lib/plausible/stats/clickhouse.ex
@@ -257,13 +257,7 @@ defmodule Plausible.Stats.Clickhouse do
from(s in referrers, where: s.referrer_source != "")
end
- referrers =
- if query.filters["page"] do
- page = query.filters["page"]
- from(s in referrers, where: s.entry_page == ^page)
- else
- referrers
- end
+ referrers = apply_page_as_entry_page(referrers, site, query)
referrers =
if include_details do
@@ -326,13 +320,7 @@ defmodule Plausible.Stats.Clickhouse do
end
defp apply_page_as_entry_page(db_query, _site, query) do
- page = query.filters["page"]
-
- if is_binary(page) do
- from(s in db_query, where: s.entry_page == ^page)
- else
- db_query
- end
+ include_path_filter_entry(db_query, query.filters["page"])
end
def utm_mediums(site, query, limit \\ 9, page \\ 1, show_noref \\ false) do
@@ -1156,21 +1144,9 @@ defmodule Plausible.Stats.Clickhouse do
sessions_q
end
- sessions_q =
- if query.filters["entry_page"] do
- entry_page = query.filters["entry_page"]
- from(s in sessions_q, where: s.entry_page == ^entry_page)
- else
- sessions_q
- end
+ sessions_q = include_path_filter_entry(sessions_q, query.filters["entry_page"])
- sessions_q =
- if query.filters["exit_page"] do
- exit_page = query.filters["exit_page"]
- from(s in sessions_q, where: s.exit_page == ^exit_page)
- else
- sessions_q
- end
+ sessions_q = include_path_filter_exit(sessions_q, query.filters["exit_page"])
q =
from(e in "events",
@@ -1194,13 +1170,7 @@ defmodule Plausible.Stats.Clickhouse do
q
end
- q =
- if query.filters["page"] do
- page = query.filters["page"]
- from(e in q, where: e.pathname == ^page)
- else
- q
- end
+ q = include_path_filter(q, query.filters["page"])
if query.filters["props"] do
[{key, val}] = query.filters["props"] |> Enum.into([])
@@ -1350,21 +1320,9 @@ defmodule Plausible.Stats.Clickhouse do
q
end
- q =
- if query.filters["entry_page"] do
- entry_page = query.filters["entry_page"]
- from(s in q, where: s.entry_page == ^entry_page)
- else
- q
- end
+ q = include_path_filter_entry(q, query.filters["entry_page"])
- q =
- if query.filters["exit_page"] do
- exit_page = query.filters["exit_page"]
- from(s in q, where: s.exit_page == ^exit_page)
- else
- q
- end
+ q = include_path_filter_exit(q, query.filters["exit_page"])
if query.filters["referrer"] do
ref = query.filters["referrer"]
@@ -1464,13 +1422,7 @@ defmodule Plausible.Stats.Clickhouse do
q
end
- q =
- if query.filters["page"] do
- page = query.filters["page"]
- from(e in q, where: e.pathname == ^page)
- else
- q
- end
+ q = include_path_filter(q, query.filters["page"])
if query.filters["props"] do
[{key, val}] = query.filters["props"] |> Enum.into([])
@@ -1550,12 +1502,9 @@ defmodule Plausible.Stats.Clickhouse do
end
if path do
- if String.match?(path, ~r/\*/) do
- path_regex =
- "^#{path}\/?$"
- |> String.replace(~r/\*\*/, ".*")
- |> String.replace(~r/(? String.replace(~r/\*\*/, ".*")
+ |> String.replace(~r/(? 1,
+ "bounce_rate" => nil,
+ "count" => 2,
+ "pageviews" => 2,
+ "name" => "/register"
+ },
+ %{
+ "time_on_page" => nil,
+ "bounce_rate" => nil,
+ "count" => 1,
+ "pageviews" => 1,
+ "name" => "/irrelevant"
+ }
+ ]
+ end
+
+ test "filters pages based on exclusion", %{conn: conn, site: site} do
+ filters = Jason.encode!(%{page: "!/"})
+
+ conn =
+ get(
+ conn,
+ "/api/stats/#{site.domain}/pages?period=day&date=2019-01-01&detailed=true&filters=#{
+ filters
+ }"
+ )
+
+ assert json_response(conn, 200) == [
+ %{
+ "time_on_page" => 1,
+ "bounce_rate" => nil,
+ "count" => 2,
+ "pageviews" => 2,
+ "name" => "/register"
+ },
+ %{
+ "time_on_page" => nil,
+ "bounce_rate" => nil,
+ "count" => 1,
+ "pageviews" => 1,
+ "name" => "/contact"
+ },
+ %{
+ "time_on_page" => nil,
+ "bounce_rate" => nil,
+ "count" => 1,
+ "pageviews" => 1,
+ "name" => "/irrelevant"
+ }
+ ]
+ end
+
+ test "filters pages based on wildard exclusion", %{conn: conn, site: site} do
+ filters = Jason.encode!(%{page: "!/*re*"})
+
+ conn =
+ get(
+ conn,
+ "/api/stats/#{site.domain}/pages?period=day&date=2019-01-01&detailed=true&filters=#{
+ filters
+ }"
+ )
+
+ assert json_response(conn, 200) == [
+ %{
+ "time_on_page" => 82800,
+ "bounce_rate" => 33.0,
+ "count" => 3,
+ "pageviews" => 3,
+ "name" => "/"
+ },
+ %{
+ "time_on_page" => nil,
+ "bounce_rate" => nil,
+ "count" => 1,
+ "pageviews" => 1,
+ "name" => "/contact"
+ }
+ ]
+ end
+
test "returns top pages in realtime report", %{conn: conn, site: site} do
conn = get(conn, "/api/stats/#{site.domain}/pages?period=realtime")
@@ -97,6 +191,18 @@ defmodule PlausibleWeb.Api.StatsController.PagesTest do
}
]
end
+
+ test "filters based on exclusion for entry pages", %{conn: conn, site: site} do
+ filters = Jason.encode!(%{entry_page: "!/"})
+
+ conn =
+ get(
+ conn,
+ "/api/stats/#{site.domain}/entry-pages?period=day&date=2019-01-01&filters=#{filters}"
+ )
+
+ assert json_response(conn, 200) == []
+ end
end
describe "GET /api/stats/:domain/exit-pages" do
@@ -109,5 +215,17 @@ defmodule PlausibleWeb.Api.StatsController.PagesTest do
%{"count" => 3, "exits" => 3, "name" => "/", "exit_rate" => 100.0}
]
end
+
+ test "filters based on exclusion for entry pages", %{conn: conn, site: site} do
+ filters = Jason.encode!(%{exit_page: "!/"})
+
+ conn =
+ get(
+ conn,
+ "/api/stats/#{site.domain}/exit-pages?period=day&date=2019-01-01&filters=#{filters}"
+ )
+
+ assert json_response(conn, 200) == []
+ end
end
end