Fix mismatch between session and event user_ids after salts are rotated (#5065)

* Refactor test suite to allow seeking multiple sessions

* Fix mismatch between session and event user_ids after salts are rotated

Consider the following scenario
1. We receive a pageview from a user A
2. Salts are rotated after day end
3. We receive another pageview

Previously, this would result in:
- 2 different sessions with mismatching user_ids
- 2 events where each would have different user_ids

This fixes the problem by removing the previous faulty session updating
and forcing the event.user_id to be updated after we found a session
with the previous salt.

* Remove an assertion
This commit is contained in:
Karl-Aksel Puulmann 2025-02-12 12:07:55 +02:00 committed by GitHub
parent a7ff6faf00
commit 40926686f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 150 additions and 133 deletions

View File

@ -29,6 +29,7 @@ All notable changes to this project will be documented in this file.
- Fix Direct / None details modal not opening
- Fix year over year comparisons being offset by a day for leap years
- Breakdown modals now display correct comparison values instead of 0 after pagination
- Fix database mismatch between event and session user_ids after rotating salts
## v2.1.5-rc.1 - 2025-01-17

View File

@ -73,6 +73,7 @@ defmodule Plausible.ClickhouseEventV2 do
@session_properties [
:session_id,
:user_id,
:referrer,
:referrer_source,
:click_id_param,

View File

@ -78,8 +78,7 @@ defmodule Plausible.Session.CacheStore do
defp update_session(session, event) do
%{
session
| user_id: event.user_id,
timestamp: event.timestamp,
| timestamp: event.timestamp,
entry_page:
if(session.entry_page == "" and event.name == "pageview",
do: event.pathname,