Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Do not rely on insertion order in tests
Uku Tahtcd8df23e5e82
diff --git a/lib/plausible/stats/imported.ex b/lib/plausible/stats/imported.exindex 52cd586341..c96684e18d 100644--- a/lib/plausible/stats/imported.ex+++ b/lib/plausible/stats/imported.ex@@ -408,7 +408,7 @@ defmodule Plausible.Stats.Imported do|> select_merge([s, i], %{visit_duration:fragment(- "(? + ? * ?) / (? + ?)",+ "round((? + ? * ?) / (? + ?), 1)",i.visit_duration,s.visit_duration,s.visits,diff --git a/test/plausible/imported/imported_test.exs b/test/plausible/imported/imported_test.exsindex 7cbd075864..5bc8bd0c26 100644--- a/test/plausible/imported/imported_test.exs+++ b/test/plausible/imported/imported_test.exs@@ -211,6 +211,7 @@ defmodule Plausible.ImportedTest dotest "UTM terms data imported from Google Analytics", %{conn: conn, site: site} dopopulate_stats(site, [build(:pageview, utm_term: "oat milk", timestamp: ~N[2021-01-01 00:00:00]),+ build(:pageview, utm_term: "Sweden", timestamp: ~N[2021-01-01 00:00:00]),build(:pageview, utm_term: "Sweden", timestamp: ~N[2021-01-01 00:00:00])])@@ -243,9 +244,9 @@ defmodule Plausible.ImportedTest doassert json_response(conn, 200) == [%{"name" => "Sweden",- "visitors" => 2,- "bounce_rate" => 50.0,- "visit_duration" => 50.0+ "visitors" => 3,+ "bounce_rate" => 67.0,+ "visit_duration" => 33.3},%{"name" => "oat milk",diff --git a/test/plausible_web/controllers/api/external_stats_controller/breakdown_test.exs b/test/plausible_web/controllers/api/external_stats_controller/breakdown_test.exsindex 83b722d88a..e6b41b03ea 100644--- a/test/plausible_web/controllers/api/external_stats_controller/breakdown_test.exs+++ b/test/plausible_web/controllers/api/external_stats_controller/breakdown_test.exs@@ -606,7 +606,6 @@ defmodule PlausibleWeb.Api.ExternalStatsController.BreakdownTest dobuild(:pageview,domain: site.domain,pathname: "/non-existing",- user_id: @user_id,timestamp: ~N[2021-01-01 00:00:01]),build(:pageview,@@ -641,7 +640,7 @@ defmodule PlausibleWeb.Api.ExternalStatsController.BreakdownTest doassert json_response(conn, 200) == %{"results" => [- %{"name" => "pageview", "visitors" => 1, "events" => 4},+ %{"name" => "pageview", "visitors" => 2, "events" => 4},%{"name" => "404", "visitors" => 1, "events" => 2}]}@@ -922,6 +921,13 @@ defmodule PlausibleWeb.Api.ExternalStatsController.BreakdownTest dodomain: site.domain,timestamp: ~N[2021-01-01 00:00:00]),+ build(:event,+ name: "Purchase",+ "meta.key": ["cost"],+ "meta.value": ["16"],+ domain: site.domain,+ timestamp: ~N[2021-01-01 00:00:00]+ ),build(:event,name: "Purchase",domain: site.domain,@@ -954,7 +960,7 @@ defmodule PlausibleWeb.Api.ExternalStatsController.BreakdownTest doassert json_response(conn, 200) == %{"results" => [- %{"cost" => "16", "visitors" => 2},+ %{"cost" => "16", "visitors" => 3},%{"cost" => "14", "visitors" => 2},%{"cost" => "(none)", "visitors" => 1}]