: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): emit logged_in when a simulated user logs back in (#127430)
Daniel Parker961ae25ae4f3
diff --git a/products/demo/backend/logic/matrix/models.py b/products/demo/backend/logic/matrix/models.pyindex 40ed1d60955a..3e0244404145 100644--- a/products/demo/backend/logic/matrix/models.py+++ b/products/demo/backend/logic/matrix/models.py@@ -396,7 +396,7 @@ class SimBrowserClient(SimClient):def reset(self):"""Reset active client, for instance when the user logs out. Similar to JS `posthog.reset()`."""self.active_distinct_id = self.device_id- self.is_logged_in = True+ self.is_logged_in = Falsedef register(self, super_properties: Properties):"""Register super properties. Similar to JS `posthog.register()`."""diff --git a/products/demo/backend/test/test_hedgebox_matrix.py b/products/demo/backend/test/test_hedgebox_matrix.pyindex ff246590b9e6..1e8f48f5c669 100644--- a/products/demo/backend/test/test_hedgebox_matrix.py+++ b/products/demo/backend/test/test_hedgebox_matrix.py@@ -13,6 +13,8 @@ from products.demo.backend.logic.matrix.models import SimEventfrom products.demo.backend.logic.products.hedgebox.matrix import HedgeboxMatrixfrom products.demo.backend.logic.products.hedgebox.taxonomy import (EVENT_DOWNGRADED_PLAN,+ EVENT_LOGGED_IN,+ EVENT_LOGGED_OUT,EVENT_PAID_BILL,EVENT_SIGNED_UP,EVENT_UPGRADED_PLAN,@@ -20,6 +22,17 @@ from products.demo.backend.logic.products.hedgebox.taxonomy import ()+class TestHedgeboxMatrixSimulation(SimpleTestCase):+ def test_users_who_log_out_log_back_in(self):+ matrix = HedgeboxMatrix(seed="login-test", n_clusters=10, days_past=60, days_future=0)+ matrix.simulate()++ events = [event.event for person in matrix.people for event in person.past_events]++ assert events.count(EVENT_LOGGED_OUT) > 0+ assert events.count(EVENT_LOGGED_IN) > 0++class TestHedgeboxMatrixDemoWarehouseTables(SimpleTestCase):def test_collect_demo_data_warehouse_rows(self):matrix = HedgeboxMatrix(seed="warehouse-test", n_clusters=0)