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
Stop counting engagement events into current visitors (#5163)
Karl-Aksel Puulmann4078e762d361
diff --git a/lib/plausible/stats/current_visitors.ex b/lib/plausible/stats/current_visitors.exindex 35a3491e08..90b516d6dc 100644--- a/lib/plausible/stats/current_visitors.ex+++ b/lib/plausible/stats/current_visitors.ex@@ -13,6 +13,7 @@ defmodule Plausible.Stats.CurrentVisitors dofrom e in "events_v2",where: e.site_id == ^site.id,where: e.timestamp >= ^first_datetime,+ where: e.name != "engagement",select: uniq(e.user_id))enddiff --git a/test/plausible_web/controllers/api/stats_controller/current_visitors_test.exs b/test/plausible_web/controllers/api/stats_controller/current_visitors_test.exsindex 1bf1a7286a..f68b19ce1b 100644--- a/test/plausible_web/controllers/api/stats_controller/current_visitors_test.exs+++ b/test/plausible_web/controllers/api/stats_controller/current_visitors_test.exs@@ -5,9 +5,14 @@ defmodule PlausibleWeb.Api.StatsController.CurrentVisitorsTest dosetup [:create_user, :log_in, :create_site]test "returns unique users in the last 5 minutes", %{conn: conn, site: site} do+ now = DateTime.utc_now()+populate_stats(site, [- build(:pageview, user_id: 123),- build(:pageview, user_id: 456)+ build(:pageview, user_id: 123, timestamp: now |> DateTime.shift(minute: -3)),+ build(:pageview, user_id: 456, timestamp: now |> DateTime.shift(minute: -3)),+ build(:pageview, user_id: 123, timestamp: now |> DateTime.shift(minute: -1)),+ build(:pageview, user_id: 789, timestamp: now |> DateTime.shift(minute: -7)),+ build(:engagement, user_id: 789, timestamp: now |> DateTime.shift(minute: -3))])conn = get(conn, "/api/stats/#{site.domain}/current-visitors")