|
|
|
|
@ -12,6 +12,8 @@
|
|
|
|
|
|
|
|
|
|
user = Plausible.Factory.insert(:user, email: "user@plausible.test", password: "plausible")
|
|
|
|
|
|
|
|
|
|
FunWithFlags.enable(:funnels)
|
|
|
|
|
|
|
|
|
|
native_stats_range =
|
|
|
|
|
Date.range(
|
|
|
|
|
Date.add(Date.utc_today(), -720),
|
|
|
|
|
@ -31,6 +33,17 @@ site =
|
|
|
|
|
stats_start_date: NaiveDateTime.new!(imported_stats_range.first, ~T[00:00:00])
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
{:ok, goal1} = Plausible.Goals.create(site, %{"page_path" => "/"})
|
|
|
|
|
{:ok, goal2} = Plausible.Goals.create(site, %{"page_path" => "/register"})
|
|
|
|
|
{:ok, goal3} = Plausible.Goals.create(site, %{"page_path" => "/login"})
|
|
|
|
|
|
|
|
|
|
{:ok, _funnel} =
|
|
|
|
|
Plausible.Funnels.create(site, "From homepage to login", [
|
|
|
|
|
%{"goal_id" => goal1.id},
|
|
|
|
|
%{"goal_id" => goal2.id},
|
|
|
|
|
%{"goal_id" => goal3.id}
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
_membership = Plausible.Factory.insert(:site_membership, user: user, site: site, role: :owner)
|
|
|
|
|
|
|
|
|
|
put_random_time = fn
|
|
|
|
|
@ -94,7 +107,7 @@ geolocations = [
|
|
|
|
|
native_stats_range
|
|
|
|
|
|> Enum.with_index()
|
|
|
|
|
|> Enum.flat_map(fn {date, index} ->
|
|
|
|
|
Enum.map(0..:rand.uniform(500), fn _ ->
|
|
|
|
|
Enum.map(0..Enum.random(1..500), fn _ ->
|
|
|
|
|
geolocation = Enum.random(geolocations)
|
|
|
|
|
|
|
|
|
|
[
|
|
|
|
|
@ -108,7 +121,8 @@ native_stats_range
|
|
|
|
|
operating_system: Enum.random(["Windows", "macOS", "Linux"]),
|
|
|
|
|
operating_system_version: to_string(Enum.random(0..15)),
|
|
|
|
|
pathname:
|
|
|
|
|
Enum.random(["/", "/login", "/settings", "/register", "/docs", "/docs/1", "/docs/2"])
|
|
|
|
|
Enum.random(["/", "/login", "/settings", "/register", "/docs", "/docs/1", "/docs/2"]),
|
|
|
|
|
user_id: Enum.random(1..1200)
|
|
|
|
|
]
|
|
|
|
|
|> Keyword.merge(geolocation)
|
|
|
|
|
|> then(&Plausible.Factory.build(:pageview, &1))
|
|
|
|
|
@ -127,7 +141,7 @@ site =
|
|
|
|
|
|
|
|
|
|
imported_stats_range
|
|
|
|
|
|> Enum.flat_map(fn date ->
|
|
|
|
|
Enum.flat_map(0..:rand.uniform(500), fn _ ->
|
|
|
|
|
Enum.flat_map(0..Enum.random(1..500), fn _ ->
|
|
|
|
|
[
|
|
|
|
|
Plausible.Factory.build(:imported_visitors,
|
|
|
|
|
date: date,
|
|
|
|
|
|