mirror of
https://github.com/plausible/analytics.git
synced 2024-11-23 11:12:15 +03:00
Fix entry pages
This commit is contained in:
parent
79f6756ba2
commit
ecbc68f05b
@ -270,10 +270,10 @@ class LineGraph extends React.Component {
|
||||
}
|
||||
|
||||
topStatTooltip(stat) {
|
||||
if (typeof(stat.count) == 'number') {
|
||||
if (typeof(stat.value) == 'number') {
|
||||
let name = stat.name.toLowerCase()
|
||||
name = stat.count === 1 ? name.slice(0, -1) : name
|
||||
return stat.count.toLocaleString() + ' ' + name
|
||||
name = stat.value === 1 ? name.slice(0, -1) : name
|
||||
return stat.value.toLocaleString() + ' ' + name
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,9 +73,6 @@ defmodule Plausible.Stats.Base do
|
||||
|
||||
nil ->
|
||||
q
|
||||
|
||||
_ ->
|
||||
raise "Unknown goal type"
|
||||
end
|
||||
|
||||
Enum.reduce(query.filters, q, fn {filter_key, filter_value}, query ->
|
||||
@ -121,28 +118,6 @@ defmodule Plausible.Stats.Base do
|
||||
where: s.timestamp >= ^first_datetime and s.start < ^last_datetime
|
||||
)
|
||||
|
||||
sessions_q =
|
||||
case query.filters["event:page"] do
|
||||
{:is, page} ->
|
||||
from(e in sessions_q, where: e.entry_page == ^page)
|
||||
|
||||
{:is_not, page} ->
|
||||
from(e in sessions_q, where: e.entry_page != ^page)
|
||||
|
||||
{:matches, glob_expr} ->
|
||||
regex = page_regex(glob_expr)
|
||||
from(s in sessions_q, where: fragment("match(?, ?)", s.entry_page, ^regex))
|
||||
|
||||
{:member, list} ->
|
||||
from(e in sessions_q, where: e.entry_page in ^list)
|
||||
|
||||
nil ->
|
||||
sessions_q
|
||||
|
||||
_ ->
|
||||
raise "Unknown filter type"
|
||||
end
|
||||
|
||||
Enum.reduce(Filters.visit_props(), sessions_q, fn prop_name, sessions_q ->
|
||||
filter = query.filters["visit:" <> prop_name]
|
||||
prop_name = Map.get(@api_prop_name_to_db, prop_name, prop_name)
|
||||
|
@ -158,6 +158,7 @@ defmodule Plausible.Stats.Breakdown do
|
||||
|
||||
defp breakdown_sessions(site, query, property, metrics, {limit, page}) do
|
||||
offset = (page - 1) * limit
|
||||
query = treat_page_filter_as_entry_page(query)
|
||||
|
||||
from(s in query_sessions(site, query),
|
||||
order_by: [desc: fragment("uniq(?)", s.user_id), asc: fragment("min(?)", s.start)],
|
||||
@ -168,9 +169,21 @@ defmodule Plausible.Stats.Breakdown do
|
||||
|> filter_converted_sessions(site, query)
|
||||
|> do_group_by(property)
|
||||
|> select_metrics(metrics)
|
||||
|> IO.inspect()
|
||||
|> ClickhouseRepo.all()
|
||||
end
|
||||
|
||||
defp treat_page_filter_as_entry_page(query) do
|
||||
case query.filters["event:page"] do
|
||||
nil ->
|
||||
query
|
||||
|
||||
filter ->
|
||||
new_filters = Map.put(query.filters, "visit:entry_page", filter)
|
||||
%Query{query | filters: new_filters}
|
||||
end
|
||||
end
|
||||
|
||||
defp filter_converted_sessions(db_query, site, query) do
|
||||
if query.filters["event:name"] || query.filters["event:page"] || query.filters["visit:goal"] do
|
||||
converted_sessions =
|
||||
|
@ -11,7 +11,9 @@ defmodule Plausible.Stats.Filters do
|
||||
"browser_version",
|
||||
"os",
|
||||
"os_version",
|
||||
"country"
|
||||
"country",
|
||||
"entry_page",
|
||||
"exit_page"
|
||||
]
|
||||
|
||||
@event_props [
|
||||
|
@ -334,8 +334,8 @@ defmodule PlausibleWeb.Api.StatsController do
|
||||
metrics = ["visitors", "visits", "visit_duration"]
|
||||
|
||||
entry_pages =
|
||||
Stats.breakdown(site, query, "event:page", metrics, pagination)
|
||||
|> transform_keys(%{"page" => "name", "visits" => "entries", "visitors" => "count"})
|
||||
Stats.breakdown(site, query, "visit:entry_page", metrics, pagination)
|
||||
|> transform_keys(%{"entry_page" => "name", "visits" => "entries", "visitors" => "count"})
|
||||
|
||||
json(conn, entry_pages)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user