Update session screen_size if unknown (#1610)

This commit is contained in:
ssendev 2022-01-21 21:32:19 +01:00 committed by GitHub
parent 69576aa253
commit 8077671f8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 1 deletions

View File

@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file.
- Subscribed users can see their Paddle invoices from the last 12 months under the user settings
- Allow custom styles to be passed to embedded iframe plausible/analytics#1522
- New UTM Tags `utm_content` and `utm_term` plausible/analytics#515
- If a session was started without a screen_size it is updated if an event with screen_size occurs
### Fixed
- UI fix where multi-line text in pills would not be underlined properly on small screens.

View File

@ -91,6 +91,8 @@ defmodule Plausible.Session.Store do
duration: Timex.diff(event.timestamp, session.start, :second) |> abs,
pageviews:
if(event.name == "pageview", do: session.pageviews + 1, else: session.pageviews),
screen_size:
if(session.screen_size == "", do: event.screen_size, else: session.screen_size),
events: session.events + 1
}
end

View File

@ -70,7 +70,8 @@ defmodule Plausible.Session.StoreTest do
domain: event1.domain,
user_id: event1.user_id,
name: "pageview",
timestamp: timestamp
timestamp: timestamp,
screen_size: "Desktop"
)
Store.on_event(event1, nil, store)
@ -80,6 +81,7 @@ defmodule Plausible.Session.StoreTest do
assert session.duration == 10
assert session.pageviews == 2
assert session.events == 2
assert session.screen_size == "Desktop"
end
test "calculates duration correctly for out-of-order events", %{store: store} do