From 953e8fef235be82472461bd64e97cfe70607e0fe Mon Sep 17 00:00:00 2001 From: Michael Matloka Date: Thu, 5 Sep 2024 19:01:33 +0200 Subject: [PATCH] Update recordings list tests --- posthog/models/event/util.py | 2 +- .../queries/test/session_replay_sql.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/posthog/models/event/util.py b/posthog/models/event/util.py index 609d7974f7cdd..6ef6b024bf0a6 100644 --- a/posthog/models/event/util.py +++ b/posthog/models/event/util.py @@ -173,7 +173,7 @@ def bulk_create_events( ) #  use person properties mapping to populate person properties in given event - team_id = event["team"].pk + team_id = event.get("team_id") or event.get("team").pk person_mode = event.get("person_mode", "full") if person_mapping and person_mapping.get(event["distinct_id"]): person = person_mapping[event["distinct_id"]] diff --git a/posthog/session_recordings/queries/test/session_replay_sql.py b/posthog/session_recordings/queries/test/session_replay_sql.py index 8be7d3b88b1da..289b307a51f2c 100644 --- a/posthog/session_recordings/queries/test/session_replay_sql.py +++ b/posthog/session_recordings/queries/test/session_replay_sql.py @@ -12,6 +12,7 @@ KAFKA_LOG_ENTRIES, ) from posthog.models.event.util import format_clickhouse_timestamp +from posthog.test.base import _create_event from posthog.utils import cast_timestamp_or_now INSERT_SINGLE_SESSION_REPLAY = """ @@ -146,6 +147,14 @@ def produce_replay_summary( sql=INSERT_SINGLE_SESSION_REPLAY, data=data, ) + # We also need to create a random analytics event, since sessions querying joins with events in + # any person-ID-on-events mode - sessions without an analytics event are excluded + _create_event( + distinct_id=data["distinct_id"], + event="foobarino", + properties={"$session_id": data["session_id"]}, + team_id=team_id, + ) for level, messages in log_messages.items(): for message in messages: