Include imported page paths in pageview goal suggestions (#4193)

This commit is contained in:
Adrian Gruntkowski 2024-06-06 10:40:48 +02:00 committed by GitHub
parent b096057eef
commit fd81ef2105
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 2 deletions

View File

@ -16,7 +16,9 @@ defmodule PlausibleWeb.Live.GoalSettings do
socket =
socket
|> assign_new(:site, fn ->
Sites.get_for_user!(user_id, domain, [:owner, :admin, :super_admin])
user_id
|> Sites.get_for_user!(domain, [:owner, :admin, :super_admin])
|> Plausible.Imported.load_import_data()
end)
|> assign_new(:all_goals, fn %{site: site} ->
Goals.for_site(site, preload_funnels?: true)

View File

@ -319,7 +319,7 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do
end
def suggest_page_paths(input, _options, site) do
query = Plausible.Stats.Query.from(site, %{})
query = Plausible.Stats.Query.from(site, %{"with_imported" => "true", "period" => "all"})
site
|> Plausible.Stats.filter_suggestions(query, "page", input)

View File

@ -162,6 +162,30 @@ defmodule PlausibleWeb.Live.GoalSettings.FormTest do
assert html =~ "/go/home"
refute html =~ "/go/to/page/1"
end
test "pageview combo considers imported pageviews as well", %{conn: conn, site: site} do
site_import = insert(:site_import, site: site)
populate_stats(site, site_import.id, [
build(:imported_pages, page: "/go/to/page/1", pageviews: 2),
build(:imported_pages, page: "/go/home", pageviews: 1)
])
lv = get_liveview(conn, site)
lv |> element(~s/a#pageview-tab/) |> render_click()
type_into_combo(lv, "page_path_input", "/go/to/p")
html = render(lv)
assert html =~ "Create "/go/to/p""
assert html =~ "/go/to/page/1"
refute html =~ "/go/home"
type_into_combo(lv, "page_path_input", "/go/h")
html = render(lv)
assert html =~ "/go/home"
refute html =~ "/go/to/page/1"
end
end
defp type_into_combo(lv, id, text) do