:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(demo): mark simulated persons that fired $identify as identified (#88675)
Andrew Maguiree84cc08c76fc
diff --git a/products/demo/backend/logic/matrix/manager.py b/products/demo/backend/logic/matrix/manager.pyindex 75b0565f3d37..2825e65d6976 100644--- a/products/demo/backend/logic/matrix/manager.py+++ b/products/demo/backend/logic/matrix/manager.py@@ -22,7 +22,7 @@ from products.demo.backend.logic.matrix.persons_db_sync import (from products.demo.backend.logic.matrix.taxonomy_inference import infer_taxonomy_for_teamfrom .matrix import Matrix-from .models import SimEvent, SimPerson+from .models import EVENT_IDENTIFY, SimEvent, SimPersonclass MatrixManager:@@ -263,10 +263,15 @@ class MatrixManager:if not hasattr(subject, "properties_at_now"):subject.take_snapshot_at_now()+ # A person that fired an $identify event during the simulation is identified,+ # matching real ingestion, which flips is_identified on $identify. Without this the+ # demo generator leaves every person anonymous (is_identified=False).+ is_identified = any(event.event == EVENT_IDENTIFY for event in subject.past_events)create_person(uuid=str(subject.in_posthog_id),team_id=team.pk,properties=subject.properties_at_now,+ is_identified=is_identified,version=0,)self._persons_created += 1diff --git a/products/demo/backend/test/test_matrix_manager.py b/products/demo/backend/test/test_matrix_manager.pyindex d1a87ef2313a..7a737e531766 100644--- a/products/demo/backend/test/test_matrix_manager.py+++ b/products/demo/backend/test/test_matrix_manager.py@@ -103,6 +103,19 @@ class TestMatrixManager(ClickhouseDestroyTablesMixin):)assert self.team.name == DummyMatrix.PRODUCT_NAME+ def test_run_on_team_marks_persons_that_identified(self):+ manager = MatrixManager(self.matrix)++ manager.run_on_team(self.team, self.user)++ assert (+ sync_execute(+ "SELECT countIf(is_identified = 1) FROM person WHERE team_id = %(team_id)s",+ {"team_id": self.team.pk},+ )[0][0]+ >= 3+ )+def test_run_on_team_using_pre_save(self):manager = MatrixManager(self.matrix, use_pre_save=True)