mirror of
https://github.com/plausible/analytics.git
synced 2024-11-22 02:27:57 +03:00
Stop suggesting pageleave as a custom event goal name (#4829)
* stop suggestions pageleave as a custom event goal name * add missing test
This commit is contained in:
parent
c2a95a142d
commit
916c2bb4c5
@ -44,7 +44,7 @@ defmodule Plausible.Stats.GoalSuggestions do
|
||||
native_q =
|
||||
from(e in base_event_query(site, query),
|
||||
where: fragment("? ilike ?", e.name, ^matches),
|
||||
where: e.name != "pageview",
|
||||
where: e.name not in ["pageview", "pageleave"],
|
||||
where: fragment("trim(?)", e.name) != "",
|
||||
where: e.name == fragment("trim(?)", e.name),
|
||||
where: e.name not in ^excluded,
|
||||
|
@ -56,10 +56,14 @@ defmodule Plausible.Stats.GoalSuggestionsTest do
|
||||
]
|
||||
end
|
||||
|
||||
test "ignores the 'pageview' event name", %{site: site} do
|
||||
test "ignores 'pageview' and 'pageleave' event names", %{site: site} do
|
||||
populate_stats(site, [
|
||||
build(:event, name: "Signup"),
|
||||
build(:pageview)
|
||||
build(:pageview,
|
||||
user_id: 1,
|
||||
timestamp: NaiveDateTime.utc_now() |> NaiveDateTime.add(-1, :minute)
|
||||
),
|
||||
build(:event, name: "pageleave", user_id: 1, timestamp: NaiveDateTime.utc_now())
|
||||
])
|
||||
|
||||
assert GoalSuggestions.suggest_event_names(site, "") == ["Signup"]
|
||||
|
@ -50,11 +50,28 @@ defmodule PlausibleWeb.Api.StatsController.SuggestionsTest do
|
||||
end
|
||||
|
||||
test "returns suggestions for goals", %{conn: conn, site: site} do
|
||||
conn = get(conn, "/api/stats/#{site.domain}/suggestions/goal?period=month&date=2019-01-01")
|
||||
conn =
|
||||
get(conn, "/api/stats/#{site.domain}/suggestions/goal?period=month&date=2019-01-01&q=")
|
||||
|
||||
assert json_response(conn, 200) == []
|
||||
end
|
||||
|
||||
test "returns suggestions for configured site goals but not all event names", %{
|
||||
conn: conn,
|
||||
site: site
|
||||
} do
|
||||
insert(:goal, site: site, event_name: "Signup")
|
||||
|
||||
populate_stats(site, [
|
||||
build(:event, name: "Signup", timestamp: ~N[2019-01-01 00:00:00]),
|
||||
build(:event, name: "another", timestamp: ~N[2019-01-01 00:00:00])
|
||||
])
|
||||
|
||||
conn = get(conn, "/api/stats/#{site.domain}/suggestions/goal?period=day&date=2019-01-01&q=")
|
||||
|
||||
assert json_response(conn, 200) == [%{"label" => "Signup", "value" => "Signup"}]
|
||||
end
|
||||
|
||||
test "returns suggestions for sources", %{conn: conn, site: site} do
|
||||
populate_stats(site, [
|
||||
build(:pageview, timestamp: ~N[2019-01-01 23:00:00], referrer_source: "Bing"),
|
||||
|
Loading…
Reference in New Issue
Block a user