From 5cdca6f408f5edd33d1dfed3dd7131897be6e07d Mon Sep 17 00:00:00 2001 From: Karl-Aksel Puulmann Date: Tue, 20 Feb 2024 09:35:12 +0200 Subject: [PATCH] Remove code that updates session browser/geo/OS attributes (#3796) This will makes it impossible to store session attributes on events. Looking at production data also revealed no cases where these updates are effective. --- lib/plausible/session/cache_store.ex | 10 ---------- test/plausible/session/cache_store_test.exs | 22 ++------------------- 2 files changed, 2 insertions(+), 30 deletions(-) diff --git a/lib/plausible/session/cache_store.ex b/lib/plausible/session/cache_store.ex index b2eeffc1b..9329db372 100644 --- a/lib/plausible/session/cache_store.ex +++ b/lib/plausible/session/cache_store.ex @@ -55,16 +55,6 @@ defmodule Plausible.Session.CacheStore do duration: Timex.diff(event.timestamp, session.start, :second) |> abs, pageviews: if(event.name == "pageview", do: session.pageviews + 1, else: session.pageviews), - country_code: session.country_code || event.country_code, - subdivision1_code: session.subdivision1_code || event.subdivision1_code, - subdivision2_code: session.subdivision2_code || event.subdivision2_code, - city_geoname_id: session.city_geoname_id || event.city_geoname_id, - operating_system: session.operating_system || event.operating_system, - operating_system_version: - session.operating_system_version || event.operating_system_version, - browser: session.browser || event.browser, - browser_version: session.browser_version || event.browser_version, - screen_size: session.screen_size || event.screen_size, events: session.events + 1 } end diff --git a/test/plausible/session/cache_store_test.exs b/test/plausible/session/cache_store_test.exs index 555aedd37..a0f4f176d 100644 --- a/test/plausible/session/cache_store_test.exs +++ b/test/plausible/session/cache_store_test.exs @@ -68,22 +68,13 @@ defmodule Plausible.Session.CacheStoreTest do # assert Map.get(session, :"entry.meta.value") == ["true", "false"] end - test "updates a session", %{buffer: buffer} do + test "updates session counters", %{buffer: buffer} do timestamp = Timex.now() event1 = build(:event, name: "pageview", timestamp: timestamp |> Timex.shift(seconds: -10)) event2 = %{ event1 - | timestamp: timestamp, - country_code: "US", - subdivision1_code: "SUB1", - subdivision2_code: "SUB2", - city_geoname_id: 12312, - screen_size: "Desktop", - operating_system: "Mac", - operating_system_version: "11", - browser: "Firefox", - browser_version: "10" + | timestamp: timestamp } CacheStore.on_event(event1, nil, buffer) @@ -93,15 +84,6 @@ defmodule Plausible.Session.CacheStoreTest do assert session.duration == 10 assert session.pageviews == 2 assert session.events == 2 - assert session.country_code == "US" - assert session.subdivision1_code == "SUB1" - assert session.subdivision2_code == "SUB2" - assert session.city_geoname_id == 12312 - assert session.operating_system == "Mac" - assert session.operating_system_version == "11" - assert session.browser == "Firefox" - assert session.browser_version == "10" - assert session.screen_size == "Desktop" end test "calculates duration correctly for out-of-order events", %{buffer: buffer} do