mirror of
https://github.com/plausible/analytics.git
synced 2024-12-22 17:11:36 +03:00
Revert entry props
This commit is contained in:
parent
428ee747c3
commit
8fb4f3f886
@ -18,8 +18,8 @@ defmodule Plausible.ClickhouseSession do
|
||||
field :events, :integer
|
||||
field :sign, :integer
|
||||
|
||||
field :"entry.meta.key", {:array, :string}, default: []
|
||||
field :"entry.meta.value", {:array, :string}, default: []
|
||||
# field :"entry.meta.key", {:array, :string}, default: []
|
||||
# field :"entry.meta.value", {:array, :string}, default: []
|
||||
|
||||
field :utm_medium, :string
|
||||
field :utm_source, :string
|
||||
|
@ -160,9 +160,9 @@ defmodule Plausible.Session.Store do
|
||||
browser: event.browser,
|
||||
browser_version: event.browser_version,
|
||||
timestamp: event.timestamp,
|
||||
start: event.timestamp,
|
||||
"entry.meta.key": Map.get(event, :"meta.key"),
|
||||
"entry.meta.value": Map.get(event, :"meta.value")
|
||||
start: event.timestamp
|
||||
# "entry.meta.key": Map.get(event, :"meta.key"),
|
||||
# "entry.meta.value": Map.get(event, :"meta.value")
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -0,0 +1,9 @@
|
||||
defmodule Plausible.ClickhouseRepo.Migrations.RemoveEntryProps do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
alter table(:sessions) do
|
||||
remove(:"entry.meta")
|
||||
end
|
||||
end
|
||||
end
|
@ -61,8 +61,8 @@ defmodule Plausible.Session.StoreTest do
|
||||
assert session.browser_version == event.browser_version
|
||||
assert session.timestamp == event.timestamp
|
||||
assert session.start === event.timestamp
|
||||
assert Map.get(session, :"entry.meta.key") == ["logged_in", "darkmode"]
|
||||
assert Map.get(session, :"entry.meta.value") == ["true", "false"]
|
||||
# assert Map.get(session, :"entry.meta.key") == ["logged_in", "darkmode"]
|
||||
# assert Map.get(session, :"entry.meta.value") == ["true", "false"]
|
||||
end
|
||||
|
||||
test "updates a session", %{store: store} do
|
||||
|
@ -66,7 +66,7 @@ defmodule Plausible.SiteAdminTest do
|
||||
actual = SiteAdmin.session_transfer_query("from.com", "to.com")
|
||||
|
||||
expected =
|
||||
"INSERT INTO sessions (browser, browser_version, city_geoname_id, country_code, domain, duration, entry.meta.key, entry.meta.value, entry_page, events, exit_page, hostname, is_bounce, operating_system, operating_system_version, pageviews, referrer, referrer_source, screen_size, session_id, sign, start, subdivision1_code, subdivision2_code, timestamp, transferred_from, user_id, utm_campaign, utm_content, utm_medium, utm_source, utm_term) SELECT browser, browser_version, city_geoname_id, country_code, 'to.com' as domain, duration, entry.meta.key, entry.meta.value, entry_page, events, exit_page, hostname, is_bounce, operating_system, operating_system_version, pageviews, referrer, referrer_source, screen_size, session_id, sign, start, subdivision1_code, subdivision2_code, timestamp, 'from.com' as transferred_from, user_id, utm_campaign, utm_content, utm_medium, utm_source, utm_term FROM (SELECT * FROM sessions WHERE domain='from.com')"
|
||||
"INSERT INTO sessions (browser, browser_version, city_geoname_id, country_code, domain, duration, entry_page, events, exit_page, hostname, is_bounce, operating_system, operating_system_version, pageviews, referrer, referrer_source, screen_size, session_id, sign, start, subdivision1_code, subdivision2_code, timestamp, transferred_from, user_id, utm_campaign, utm_content, utm_medium, utm_source, utm_term) SELECT browser, browser_version, city_geoname_id, country_code, 'to.com' as domain, duration, entry_page, events, exit_page, hostname, is_bounce, operating_system, operating_system_version, pageviews, referrer, referrer_source, screen_size, session_id, sign, start, subdivision1_code, subdivision2_code, timestamp, 'from.com' as transferred_from, user_id, utm_campaign, utm_content, utm_medium, utm_source, utm_term FROM (SELECT * FROM sessions WHERE domain='from.com')"
|
||||
|
||||
assert actual == expected
|
||||
end
|
||||
|
@ -30,183 +30,183 @@ defmodule PlausibleWeb.Api.StatsController.SourcesTest do
|
||||
]
|
||||
end
|
||||
|
||||
test "returns top sources with :is filter on custom pageview props", %{conn: conn, site: site} do
|
||||
populate_stats(site, [
|
||||
build(:pageview,
|
||||
referrer_source: "DuckDuckGo",
|
||||
referrer: "duckduckgo.com",
|
||||
user_id: 123,
|
||||
timestamp: ~N[2021-01-01 00:00:00]
|
||||
),
|
||||
build(:pageview,
|
||||
"meta.key": ["author"],
|
||||
"meta.value": ["John Doe"],
|
||||
user_id: 123,
|
||||
timestamp: ~N[2021-01-01 00:01:00]
|
||||
),
|
||||
build(:pageview,
|
||||
referrer_source: "Google",
|
||||
referrer: "google.com",
|
||||
"meta.key": ["author"],
|
||||
"meta.value": ["John Doe"],
|
||||
timestamp: ~N[2021-01-01 00:00:00]
|
||||
),
|
||||
build(:pageview,
|
||||
referrer_source: "Facebook",
|
||||
referrer: "facebook.com",
|
||||
timestamp: ~N[2021-01-01 00:00:00]
|
||||
)
|
||||
])
|
||||
# test "returns top sources with :is filter on custom pageview props", %{conn: conn, site: site} do
|
||||
# populate_stats(site, [
|
||||
# build(:pageview,
|
||||
# referrer_source: "DuckDuckGo",
|
||||
# referrer: "duckduckgo.com",
|
||||
# user_id: 123,
|
||||
# timestamp: ~N[2021-01-01 00:00:00]
|
||||
# ),
|
||||
# build(:pageview,
|
||||
# "meta.key": ["author"],
|
||||
# "meta.value": ["John Doe"],
|
||||
# user_id: 123,
|
||||
# timestamp: ~N[2021-01-01 00:01:00]
|
||||
# ),
|
||||
# build(:pageview,
|
||||
# referrer_source: "Google",
|
||||
# referrer: "google.com",
|
||||
# "meta.key": ["author"],
|
||||
# "meta.value": ["John Doe"],
|
||||
# timestamp: ~N[2021-01-01 00:00:00]
|
||||
# ),
|
||||
# build(:pageview,
|
||||
# referrer_source: "Facebook",
|
||||
# referrer: "facebook.com",
|
||||
# timestamp: ~N[2021-01-01 00:00:00]
|
||||
# )
|
||||
# ])
|
||||
|
||||
filters = Jason.encode!(%{props: %{"author" => "John Doe"}})
|
||||
# filters = Jason.encode!(%{props: %{"author" => "John Doe"}})
|
||||
|
||||
conn =
|
||||
get(
|
||||
conn,
|
||||
"/api/stats/#{site.domain}/sources?period=day&date=2021-01-01&filters=#{filters}"
|
||||
)
|
||||
# conn =
|
||||
# get(
|
||||
# conn,
|
||||
# "/api/stats/#{site.domain}/sources?period=day&date=2021-01-01&filters=#{filters}"
|
||||
# )
|
||||
|
||||
assert json_response(conn, 200) == [
|
||||
%{"name" => "Google", "visitors" => 1}
|
||||
]
|
||||
end
|
||||
# assert json_response(conn, 200) == [
|
||||
# %{"name" => "Google", "visitors" => 1}
|
||||
# ]
|
||||
# end
|
||||
|
||||
test "returns top sources with :is_not filter on custom pageview props", %{
|
||||
conn: conn,
|
||||
site: site
|
||||
} do
|
||||
populate_stats(site, [
|
||||
build(:pageview,
|
||||
referrer_source: "DuckDuckGo",
|
||||
referrer: "duckduckgo.com",
|
||||
"meta.key": ["author"],
|
||||
"meta.value": ["John Doe"],
|
||||
user_id: 123,
|
||||
timestamp: ~N[2021-01-01 00:00:00]
|
||||
),
|
||||
build(:pageview,
|
||||
"meta.key": ["author"],
|
||||
"meta.value": ["other"],
|
||||
user_id: 123,
|
||||
timestamp: ~N[2021-01-01 00:01:00]
|
||||
),
|
||||
build(:pageview,
|
||||
referrer_source: "Google",
|
||||
referrer: "google.com",
|
||||
"meta.key": ["author"],
|
||||
"meta.value": ["other"],
|
||||
timestamp: ~N[2021-01-01 00:00:00]
|
||||
),
|
||||
build(:pageview,
|
||||
referrer_source: "Facebook",
|
||||
referrer: "facebook.com",
|
||||
timestamp: ~N[2021-01-01 00:00:00]
|
||||
)
|
||||
])
|
||||
# test "returns top sources with :is_not filter on custom pageview props", %{
|
||||
# conn: conn,
|
||||
# site: site
|
||||
# } do
|
||||
# populate_stats(site, [
|
||||
# build(:pageview,
|
||||
# referrer_source: "DuckDuckGo",
|
||||
# referrer: "duckduckgo.com",
|
||||
# "meta.key": ["author"],
|
||||
# "meta.value": ["John Doe"],
|
||||
# user_id: 123,
|
||||
# timestamp: ~N[2021-01-01 00:00:00]
|
||||
# ),
|
||||
# build(:pageview,
|
||||
# "meta.key": ["author"],
|
||||
# "meta.value": ["other"],
|
||||
# user_id: 123,
|
||||
# timestamp: ~N[2021-01-01 00:01:00]
|
||||
# ),
|
||||
# build(:pageview,
|
||||
# referrer_source: "Google",
|
||||
# referrer: "google.com",
|
||||
# "meta.key": ["author"],
|
||||
# "meta.value": ["other"],
|
||||
# timestamp: ~N[2021-01-01 00:00:00]
|
||||
# ),
|
||||
# build(:pageview,
|
||||
# referrer_source: "Facebook",
|
||||
# referrer: "facebook.com",
|
||||
# timestamp: ~N[2021-01-01 00:00:00]
|
||||
# )
|
||||
# ])
|
||||
|
||||
filters = Jason.encode!(%{props: %{"author" => "!John Doe"}})
|
||||
# filters = Jason.encode!(%{props: %{"author" => "!John Doe"}})
|
||||
|
||||
conn =
|
||||
get(
|
||||
conn,
|
||||
"/api/stats/#{site.domain}/sources?period=day&date=2021-01-01&filters=#{filters}"
|
||||
)
|
||||
# conn =
|
||||
# get(
|
||||
# conn,
|
||||
# "/api/stats/#{site.domain}/sources?period=day&date=2021-01-01&filters=#{filters}"
|
||||
# )
|
||||
|
||||
assert json_response(conn, 200) == [
|
||||
%{"name" => "Facebook", "visitors" => 1},
|
||||
%{"name" => "Google", "visitors" => 1}
|
||||
]
|
||||
end
|
||||
# assert json_response(conn, 200) == [
|
||||
# %{"name" => "Facebook", "visitors" => 1},
|
||||
# %{"name" => "Google", "visitors" => 1}
|
||||
# ]
|
||||
# end
|
||||
|
||||
test "returns top sources with :is (none) filter on custom pageview props", %{
|
||||
conn: conn,
|
||||
site: site
|
||||
} do
|
||||
populate_stats(site, [
|
||||
build(:pageview,
|
||||
referrer_source: "DuckDuckGo",
|
||||
referrer: "duckduckgo.com",
|
||||
"meta.key": ["author"],
|
||||
"meta.value": ["John Doe"],
|
||||
user_id: 123,
|
||||
timestamp: ~N[2021-01-01 00:00:00]
|
||||
),
|
||||
build(:pageview,
|
||||
user_id: 123,
|
||||
timestamp: ~N[2021-01-01 00:01:00]
|
||||
),
|
||||
build(:pageview,
|
||||
referrer_source: "Google",
|
||||
referrer: "google.com",
|
||||
"meta.key": ["author"],
|
||||
"meta.value": ["other"],
|
||||
timestamp: ~N[2021-01-01 00:00:00]
|
||||
),
|
||||
build(:pageview,
|
||||
referrer_source: "Facebook",
|
||||
referrer: "facebook.com",
|
||||
timestamp: ~N[2021-01-01 00:00:00]
|
||||
)
|
||||
])
|
||||
# test "returns top sources with :is (none) filter on custom pageview props", %{
|
||||
# conn: conn,
|
||||
# site: site
|
||||
# } do
|
||||
# populate_stats(site, [
|
||||
# build(:pageview,
|
||||
# referrer_source: "DuckDuckGo",
|
||||
# referrer: "duckduckgo.com",
|
||||
# "meta.key": ["author"],
|
||||
# "meta.value": ["John Doe"],
|
||||
# user_id: 123,
|
||||
# timestamp: ~N[2021-01-01 00:00:00]
|
||||
# ),
|
||||
# build(:pageview,
|
||||
# user_id: 123,
|
||||
# timestamp: ~N[2021-01-01 00:01:00]
|
||||
# ),
|
||||
# build(:pageview,
|
||||
# referrer_source: "Google",
|
||||
# referrer: "google.com",
|
||||
# "meta.key": ["author"],
|
||||
# "meta.value": ["other"],
|
||||
# timestamp: ~N[2021-01-01 00:00:00]
|
||||
# ),
|
||||
# build(:pageview,
|
||||
# referrer_source: "Facebook",
|
||||
# referrer: "facebook.com",
|
||||
# timestamp: ~N[2021-01-01 00:00:00]
|
||||
# )
|
||||
# ])
|
||||
|
||||
filters = Jason.encode!(%{props: %{"author" => "(none)"}})
|
||||
# filters = Jason.encode!(%{props: %{"author" => "(none)"}})
|
||||
|
||||
conn =
|
||||
get(
|
||||
conn,
|
||||
"/api/stats/#{site.domain}/sources?period=day&date=2021-01-01&filters=#{filters}"
|
||||
)
|
||||
# conn =
|
||||
# get(
|
||||
# conn,
|
||||
# "/api/stats/#{site.domain}/sources?period=day&date=2021-01-01&filters=#{filters}"
|
||||
# )
|
||||
|
||||
assert json_response(conn, 200) == [
|
||||
%{"name" => "Facebook", "visitors" => 1}
|
||||
]
|
||||
end
|
||||
# assert json_response(conn, 200) == [
|
||||
# %{"name" => "Facebook", "visitors" => 1}
|
||||
# ]
|
||||
# end
|
||||
|
||||
test "returns top sources with :is_not (none) filter on custom pageview props", %{
|
||||
conn: conn,
|
||||
site: site
|
||||
} do
|
||||
populate_stats(site, [
|
||||
build(:pageview,
|
||||
referrer_source: "DuckDuckGo",
|
||||
referrer: "duckduckgo.com",
|
||||
"meta.key": ["logged_in"],
|
||||
"meta.value": ["true"],
|
||||
user_id: 123,
|
||||
timestamp: ~N[2021-01-01 00:00:00]
|
||||
),
|
||||
build(:pageview,
|
||||
"meta.key": ["author"],
|
||||
"meta.value": ["other"],
|
||||
user_id: 123,
|
||||
timestamp: ~N[2021-01-01 00:01:00]
|
||||
),
|
||||
build(:pageview,
|
||||
referrer_source: "Google",
|
||||
referrer: "google.com",
|
||||
"meta.key": ["author"],
|
||||
"meta.value": ["other"],
|
||||
timestamp: ~N[2021-01-01 00:00:00]
|
||||
),
|
||||
build(:pageview,
|
||||
referrer_source: "Facebook",
|
||||
referrer: "facebook.com",
|
||||
timestamp: ~N[2021-01-01 00:00:00]
|
||||
)
|
||||
])
|
||||
# test "returns top sources with :is_not (none) filter on custom pageview props", %{
|
||||
# conn: conn,
|
||||
# site: site
|
||||
# } do
|
||||
# populate_stats(site, [
|
||||
# build(:pageview,
|
||||
# referrer_source: "DuckDuckGo",
|
||||
# referrer: "duckduckgo.com",
|
||||
# "meta.key": ["logged_in"],
|
||||
# "meta.value": ["true"],
|
||||
# user_id: 123,
|
||||
# timestamp: ~N[2021-01-01 00:00:00]
|
||||
# ),
|
||||
# build(:pageview,
|
||||
# "meta.key": ["author"],
|
||||
# "meta.value": ["other"],
|
||||
# user_id: 123,
|
||||
# timestamp: ~N[2021-01-01 00:01:00]
|
||||
# ),
|
||||
# build(:pageview,
|
||||
# referrer_source: "Google",
|
||||
# referrer: "google.com",
|
||||
# "meta.key": ["author"],
|
||||
# "meta.value": ["other"],
|
||||
# timestamp: ~N[2021-01-01 00:00:00]
|
||||
# ),
|
||||
# build(:pageview,
|
||||
# referrer_source: "Facebook",
|
||||
# referrer: "facebook.com",
|
||||
# timestamp: ~N[2021-01-01 00:00:00]
|
||||
# )
|
||||
# ])
|
||||
|
||||
filters = Jason.encode!(%{props: %{"author" => "!(none)"}})
|
||||
# filters = Jason.encode!(%{props: %{"author" => "!(none)"}})
|
||||
|
||||
conn =
|
||||
get(
|
||||
conn,
|
||||
"/api/stats/#{site.domain}/sources?period=day&date=2021-01-01&filters=#{filters}"
|
||||
)
|
||||
# conn =
|
||||
# get(
|
||||
# conn,
|
||||
# "/api/stats/#{site.domain}/sources?period=day&date=2021-01-01&filters=#{filters}"
|
||||
# )
|
||||
|
||||
assert json_response(conn, 200) == [
|
||||
%{"name" => "Google", "visitors" => 1}
|
||||
]
|
||||
end
|
||||
# assert json_response(conn, 200) == [
|
||||
# %{"name" => "Google", "visitors" => 1}
|
||||
# ]
|
||||
# end
|
||||
|
||||
test "returns top sources with imported data", %{conn: conn, site: site} do
|
||||
populate_stats(site, [
|
||||
|
Loading…
Reference in New Issue
Block a user