Skip to content

: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.

chore(demo): extract and isolate demo data generation (#66199)

Paul D'Ambra3f6e679b0fe9
diff --git a/ee/hogai/eval/data_setup.py b/ee/hogai/eval/data_setup.py
index a1b6c165aed2..c6cc2d543f98 100644
--- a/ee/hogai/eval/data_setup.py
+++ b/ee/hogai/eval/data_setup.py
@@ -14,9 +14,6 @@ from django.db import transaction
from django.test import override_settings
from posthog.clickhouse.client import sync_execute
-from posthog.demo.matrix.manager import MatrixManager
-from posthog.demo.matrix.taxonomy_inference import infer_taxonomy_for_team
-from posthog.demo.products.hedgebox.matrix import HedgeboxMatrix
from posthog.models import Organization, OrganizationMembership, Team, User
from posthog.models.event.sql import COPY_EVENTS_BETWEEN_TEAMS
from posthog.models.group.sql import COPY_GROUPS_BETWEEN_TEAMS
@@ -24,6 +21,7 @@ from posthog.models.person.sql import COPY_PERSON_DISTINCT_ID2S_BETWEEN_TEAMS, C
from posthog.persons_db import persons_db_connection
from products.dashboards.backend.models import Dashboard, DashboardTile
+from products.demo.backend.facade.api import HedgeboxMatrix, MatrixManager, infer_taxonomy_for_team
from products.posthog_ai.backend.models.assistant import CoreMemory
from products.product_analytics.backend.models.insight import Insight
diff --git a/ee/hogai/eval/sandboxed/AGENTS.md b/ee/hogai/eval/sandboxed/AGENTS.md
index bdeb556d3b4f..6bac4d960645 100644
--- a/ee/hogai/eval/sandboxed/AGENTS.md
+++ b/ee/hogai/eval/sandboxed/AGENTS.md
@@ -4,9 +4,9 @@ Every eval in this tree (and in `ee/hogai/eval/ci`) runs against a **single, det
Source of truth (read these if anything below looks stale):
-- Simulation logic: `posthog/demo/products/hedgebox/models.py` (per-person session state machine + events)
-- Project setup (actions/cohorts/dashboards/insights/flags/experiments): `posthog/demo/products/hedgebox/matrix.py` → `HedgeboxMatrix.set_project_up`
-- Taxonomy constants (event/flag/group names): `posthog/demo/products/hedgebox/taxonomy.py`
+- Simulation logic: `products/demo/backend/logic/products/hedgebox/models.py` (per-person session state machine + events)
+- Project setup (actions/cohorts/dashboards/insights/flags/experiments): `products/demo/backend/logic/products/hedgebox/matrix.py` → `HedgeboxMatrix.set_project_up`
+- Taxonomy constants (event/flag/group names): `products/demo/backend/logic/products/hedgebox/taxonomy.py`
- How evals seed it: `ee/hogai/eval/data_setup.py`
## How the data is seeded for evals
@@ -104,4 +104,4 @@ After simulation, the team is populated with named artifacts. Agents doing retri
- Prefer relative date ranges (`-30d`, `-8w`, `-6m`) and shape-based assertions over absolute counts.
- Set `filterTestAccounts=True` in expected queries when mirroring the seeded insights/dashboards.
- For group/account-level math use the `account` group type (index 0).
-- The whole dataset is deterministic under `EVAL_SEED`; if you change the simulation in `posthog/demo/products/hedgebox/`, expected fixtures across `ci/` and `sandboxed/` may need re-baselining.
+- The whole dataset is deterministic under `EVAL_SEED`; if you change the simulation in `products/demo/backend/logic/products/hedgebox/`, expected fixtures across `ci/` and `sandboxed/` may need re-baselining.
diff --git a/ee/hogai/eval/sandboxed/error_tracking/seeders.py b/ee/hogai/eval/sandboxed/error_tracking/seeders.py
index ba6e2e1779ff..cd8d95b507cf 100644
--- a/ee/hogai/eval/sandboxed/error_tracking/seeders.py
+++ b/ee/hogai/eval/sandboxed/error_tracking/seeders.py
@@ -163,7 +163,7 @@ def _build_exception_properties(spec: dict[str, Any], issue_id: str, session_id:
"""Construct the ``$exception`` event payload for one occurrence.
Mirrors the shape Hedgebox's demo seed writes (see
- ``posthog/demo/products/hedgebox/matrix.py:_set_up_error_tracking_demo_data``)
+ ``products/demo/backend/logic/products/hedgebox/matrix.py:_set_up_error_tracking_demo_data``)
so the query runner's frame-extraction (``innermost_frame_attribute``)
and the events tool's ``$exception_list`` rendering both work. Stack
frames are inlined as ``resolved=True``; we deliberately skip the
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index e652e2056a8f..ad5528df5540 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -3009,6 +3009,8 @@ importers:
specifier: 18.3.1
version: 18.3.1
+ products/demo: {}
+
products/early_access_features:
dependencies:
'@posthog/icons':
diff --git a/posthog/api/signup.py b/posthog/api/signup.py
index 99ec31cfb4dd..49ec1bc8d1e5 100644
--- a/posthog/api/signup.py
+++ b/posthog/api/signup.py
@@ -29,8 +29,6 @@ from posthog.api.webauthn import (
WEBAUTHN_SIGNUP_EMAIL_KEY,
WEBAUTHN_SIGNUP_USER_UUID_KEY,
)
-from posthog.demo.matrix import MatrixManager
-from posthog.demo.products.hedgebox import HedgeboxMatrix
from posthog.email import is_email_available
from posthog.event_usage import alias_invite_id, report_user_joined_organization, report_user_signed_up
from posthog.exceptions_capture import capture_exception
@@ -43,6 +41,8 @@ from posthog.rate_limit import SignupEmailPrecheckThrottle, SignupIPThrottle, Si
from posthog.utils import get_can_create_org, is_relative_url
from posthog.workos_radar import RadarAction, RadarAuthMethod, evaluate_auth_attempt
+from products.demo.backend.facade.api import HedgeboxMatrix, MatrixManager
+
logger = structlog.get_logger(__name__)
diff --git a/posthog/api/test/__snapshots__/test_persons_trends.ambr b/posthog/api/test/__snapshots__/test_persons_trends.ambr
index 011b48a1e185..588c2e60e624 100644
--- a/posthog/api/test/__snapshots__/test_persons_trends.ambr
+++ b/posthog/api/test/__snapshots__/test_persons_trends.ambr
@@ -108,73 +108,6 @@
use_hive_partitioning=0
'''
# ---
-# name: TestPersonTrends.test_trends_people_endpoint_filters_search.2
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT person_id AS actor_id,
- count() AS actor_value ,
- groupUniqArray(100)((timestamp, uuid,
- $session_id,
- $window_id)) as matching_events
- FROM
- (SELECT e.timestamp as timestamp,
- e."properties" as "properties",
- e."$window_id" as $window_id,
- e."$session_id" as $session_id,
- if(notEmpty(pdi.distinct_id), pdi.person_id, e.person_id) as person_id,
- e.distinct_id as distinct_id,
- e.team_id as team_id,
- e.uuid as uuid
- FROM events e
- LEFT OUTER JOIN
- (SELECT distinct_id,
- argMax(person_id, version) as person_id
- FROM person_distinct_id2
- WHERE team_id = 99999
- AND distinct_id IN
- (SELECT distinct_id
- FROM events
- WHERE team_id = 99999
- AND event = '$pageview'
- AND toTimeZone(timestamp, 'UTC') >= toDateTime(toStartOfDay(toDateTime('2020-01-08 00:00:00', 'UTC')), 'UTC')
- AND toTimeZone(timestamp, 'UTC') <= toDateTime('2020-01-12 23:59:59', 'UTC'))
- GROUP BY distinct_id
- HAVING argMax(is_deleted, version) = 0) AS pdi ON e.distinct_id = pdi.distinct_id
- INNER JOIN
- (SELECT id,
- argMax(properties, version) as person_props
- FROM person
- WHERE team_id = 99999
- GROUP BY id
- HAVING max(is_deleted) = 0 SETTINGS optimize_aggregation_in_order = 1) person ON person.id = pdi.person_id
- WHERE team_id = 99999
- AND event = '$pageview'
- AND toTimeZone(timestamp, 'UTC') >= toDateTime(toStartOfDay(toDateTime('2020-01-08 00:00:00', 'UTC')), 'UTC')
- AND toTimeZone(timestamp, 'UTC') <= toDateTime('2020-01-12 23:59:59', 'UTC')
- AND ((replaceRegexpAll(JSONExtractRaw(person_props, 'email'), '^"|"$', '') ILIKE '%ben%'
- OR replaceRegexpAll(JSONExtractRaw(person_props, 'name'), '^"|"$', '') ILIKE '%ben%'
- OR replaceRegexpAll(JSONExtractRaw(e.properties, 'distinct_id'), '^"|"$', '') ILIKE '%ben%')
- AND (has([''], replaceRegexpAll(JSONExtractRaw(e.properties, 'key'), '^"|"$', '')))))
- GROUP BY actor_id
- ORDER BY actor_value DESC,
- actor_id DESC
- LIMIT 100
- OFFSET 0
- '''
-# ---
-# name: TestPersonTrends.test_trends_people_endpoint_filters_search.3
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT session_id
- FROM session_replay_events
- WHERE team_id = 99999
- and session_id in []
- AND min_first_timestamp >= '2020-01-07 00:00:00'
- AND max_last_timestamp <= '2020-01-13 23:59:59'
- GROUP BY session_id
- HAVING max(is_deleted) = 0
- '''
-# ---
# name: TestPersonTrends.test_trends_people_endpoint_includes_recordings
'''
/* user_id:0 request:_snapshot_ */
diff --git a/posthog/api/test/__snapshots__/test_properties_timeline.ambr b/posthog/api/test/__snapshots__/test_properties_timeline.ambr
index dedc6e682ce8..142ab3d9c555 100644
--- a/posthog/api/test/__snapshots__/test_properties_timeline.ambr
+++ b/posthog/api/test/__snapshots__/test_properties_timeline.ambr
@@ -359,44 +359,6 @@
use_hive_partitioning=0
'''
# ---
-# name: TestPersonPropertiesTimeline.test_timeline_for_new_actor_with_one_event_before_range_materialized
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT timestamp, properties,
- end_event_number - start_event_number AS relevant_event_count
- FROM
- (SELECT timestamp, properties,
- start_event_number,
- leadInFrame(start_event_number) OVER (
- ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
- FROM
- (SELECT timestamp, person_properties AS properties,
- array("mat_pp_bar") AS relevant_property_values,
- lagInFrame(relevant_property_values) OVER (
- ORDER BY timestamp ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
- row_number() OVER (
- ORDER BY timestamp ASC) AS start_event_number
- FROM (
- (SELECT e.timestamp AS timestamp,
- e."mat_pp_bar" AS "mat_pp_bar",
- e."person_properties" AS "person_properties"
- FROM events e
- WHERE team_id = 99999
- AND person_id = '00000000-0000-0000-0000-000000000000'
- AND event = '$pageview'
- AND toTimeZone(timestamp, 'UTC') >= toDateTime(toStartOfDay(toDateTime('2020-01-01 00:00:00', 'UTC')), 'UTC')
- AND toTimeZone(timestamp, 'UTC') <= toDateTime('2020-01-05 23:59:59', 'UTC')
- ORDER BY timestamp ASC)
- UNION ALL
- (SELECT NULL AS timestamp,
- '' AS "mat_pp_bar",
- '' AS "person_properties")))
- WHERE start_event_number = 1
- OR relevant_property_values != previous_relevant_property_values
- OR timestamp IS NULL)
- WHERE timestamp IS NOT NULL
- '''
-# ---
# name: TestPersonPropertiesTimeline.test_timeline_for_new_actor_with_one_event_in_range
'''
/* user_id:0 request:_snapshot_ */
@@ -437,44 +399,6 @@
use_hive_partitioning=0
'''
# ---
-# name: TestPersonPropertiesTimeline.test_timeline_for_new_actor_with_one_event_in_range_materialized
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT timestamp, properties,
- end_event_number - start_event_number AS relevant_event_count
- FROM
- (SELECT timestamp, properties,
- start_event_number,
- leadInFrame(start_event_number) OVER (
- ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
- FROM
- (SELECT timestamp, person_properties AS properties,
- array("mat_pp_bar") AS relevant_property_values,
- lagInFrame(relevant_property_values) OVER (
- ORDER BY timestamp ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
- row_number() OVER (
- ORDER BY timestamp ASC) AS start_event_number
- FROM (
- (SELECT e.timestamp AS timestamp,
- e."mat_pp_bar" AS "mat_pp_bar",
- e."person_properties" AS "person_properties"
- FROM events e
- WHERE team_id = 99999
- AND person_id = '00000000-0000-0000-0000-000000000000'
- AND event = '$pageview'
- AND toTimeZone(timestamp, 'UTC') >= toDateTime(toStartOfDay(toDateTime('2020-01-01 00:00:00', 'UTC')), 'UTC')
- AND toTimeZone(timestamp, 'UTC') <= toDateTime('2020-01-05 23:59:59', 'UTC')
- ORDER BY timestamp ASC)
- UNION ALL
- (SELECT NULL AS timestamp,
- '' AS "mat_pp_bar",
- '' AS "person_properties")))
- WHERE start_event_number = 1
- OR relevant_property_values != previous_relevant_property_values
- OR timestamp IS NULL)
- WHERE timestamp IS NOT NULL
- '''
-# ---
# name: TestPersonPropertiesTimeline.test_timeline_with_two_events_in_range_using_breakdown
'''
/* user_id:0 request:_snapshot_ */
@@ -515,46 +439,6 @@
use_hive_partitioning=0
'''
# ---
-# name: TestPersonPropertiesTimeline.test_timeline_with_two_events_in_range_using_breakdown_materialized
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT timestamp, properties,
- end_event_number - start_event_number AS relevant_event_count
- FROM
- (SELECT timestamp, properties,
- start_event_number,
- leadInFrame(start_event_number) OVER (
- ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
- FROM
- (SELECT timestamp, person_properties AS properties,
- array("mat_pp_bar", "mat_pp_foo") AS relevant_property_values,
- lagInFrame(relevant_property_values) OVER (
- ORDER BY timestamp ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
- row_number() OVER (
- ORDER BY timestamp ASC) AS start_event_number
- FROM (
- (SELECT e.timestamp AS timestamp,
- e."mat_pp_bar" AS "mat_pp_bar",
- e."mat_pp_foo" AS "mat_pp_foo",
- e."person_properties" AS "person_properties"
- FROM events e
- WHERE team_id = 99999
- AND person_id = '00000000-0000-0000-0000-000000000000'
- AND event = '$pageview'
- AND toTimeZone(timestamp, 'UTC') >= toDateTime(toStartOfDay(toDateTime('2020-01-01 00:00:00', 'UTC')), 'UTC')
- AND toTimeZone(timestamp, 'UTC') <= toDateTime('2020-01-05 23:59:59', 'UTC')
- ORDER BY timestamp ASC)
- UNION ALL
- (SELECT NULL AS timestamp,
- '' AS "mat_pp_bar",
- '' AS "mat_pp_foo",
- '' AS "person_properties")))
- WHERE start_event_number = 1
- OR relevant_property_values != previous_relevant_property_values
- OR timestamp IS NULL)
- WHERE timestamp IS NOT NULL
- '''
-# ---
# name: TestPersonPropertiesTimeline.test_timeline_with_two_events_in_range_using_filter_on_series
'''
/* user_id:0 request:_snapshot_ */
@@ -595,43 +479,3 @@
use_hive_partitioning=0
'''
# ---
-# name: TestPersonPropertiesTimeline.test_timeline_with_two_events_in_range_using_filter_on_series_materialized
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT timestamp, properties,
- end_event_number - start_event_number AS relevant_event_count
- FROM
- (SELECT timestamp, properties,
- start_event_number,
- leadInFrame(start_event_number) OVER (
- ORDER BY timestamp ASC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) AS end_event_number
- FROM
- (SELECT timestamp, person_properties AS properties,
- array("mat_pp_bar", "mat_pp_foo") AS relevant_property_values,
- lagInFrame(relevant_property_values) OVER (
- ORDER BY timestamp ASC ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS previous_relevant_property_values,
- row_number() OVER (
- ORDER BY timestamp ASC) AS start_event_number
- FROM (
- (SELECT e.timestamp AS timestamp,
- e."mat_pp_bar" AS "mat_pp_bar",
- e."mat_pp_foo" AS "mat_pp_foo",
- e."person_properties" AS "person_properties"
- FROM events e
- WHERE team_id = 99999
- AND person_id = '00000000-0000-0000-0000-000000000000'
- AND event = '$pageview'
- AND toTimeZone(timestamp, 'UTC') >= toDateTime(toStartOfDay(toDateTime('2020-01-01 00:00:00', 'UTC')), 'UTC')
- AND toTimeZone(timestamp, 'UTC') <= toDateTime('2020-01-05 23:59:59', 'UTC')
- ORDER BY timestamp ASC)
- UNION ALL
- (SELECT NULL AS timestamp,
- '' AS "mat_pp_bar",
- '' AS "mat_pp_foo",
- '' AS "person_properties")))
- WHERE start_event_number = 1
- OR relevant_property_values != previous_relevant_property_values
- OR timestamp IS NULL)
- WHERE timestamp IS NOT NULL
- '''
-# ---
diff --git a/posthog/api/test/__snapshots__/test_query.ambr b/posthog/api/test/__snapshots__/test_query.ambr
index 3b226a40dccf..ba10d36a80b4 100644
--- a/posthog/api/test/__snapshots__/test_query.ambr
+++ b/posthog/api/test/__snapshots__/test_query.ambr
@@ -92,93 +92,6 @@
use_hive_partitioning=0
'''
# ---
-# name: TestQuery.test_event_property_filter_materialized
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT events.event AS event,
- events.distinct_id AS distinct_id,
- nullIf(nullIf(events.mat_key, ''), 'null') AS key,
- 'a%sd',
- concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(nullIf(nullIf(events.mat_key, ''), 'null')), '')) AS `concat(event, ' ', properties.key)`
- FROM events
- WHERE and(equals(events.team_id, 99999), in(events.uuid,
- (SELECT events.uuid AS uuid
- FROM events
- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))
- ORDER BY events.event ASC
- LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))
- ORDER BY events.event ASC
- LIMIT 101
- OFFSET 0 SETTINGS readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=0,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
-# name: TestQuery.test_event_property_filter_materialized.1
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT events.event AS event,
- events.distinct_id AS distinct_id,
- nullIf(nullIf(events.mat_key, ''), 'null') AS key,
- 'a%sd',
- concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(nullIf(nullIf(events.mat_key, ''), 'null')), '')) AS `concat(event, ' ', properties.key)`
- FROM events
- WHERE and(equals(events.team_id, 99999), in(events.uuid,
- (SELECT events.uuid AS uuid
- FROM events
- WHERE and(equals(events.team_id, 99999), equals(events.mat_key, 'test_val3'), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))
- ORDER BY events.event ASC
- LIMIT 101)), and(equals(events.mat_key, 'test_val3'), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))
- ORDER BY events.event ASC
- LIMIT 101
- OFFSET 0 SETTINGS readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=0,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
-# name: TestQuery.test_event_property_filter_materialized.2
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT events.event AS event,
- events.distinct_id AS distinct_id,
- nullIf(nullIf(events.mat_key, ''), 'null') AS key,
- 'a%sd',
- concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(nullIf(nullIf(events.mat_key, ''), 'null')), '')) AS `concat(event, ' ', properties.key)`
- FROM events
- WHERE and(equals(events.team_id, 99999), in(events.uuid,
- (SELECT events.uuid AS uuid
- FROM events
- WHERE and(equals(events.team_id, 99999), ilike(events.mat_path, '%/%'), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))
- ORDER BY events.event ASC
- LIMIT 101)), and(ilike(events.mat_path, '%/%'), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))
- ORDER BY events.event ASC
- LIMIT 101
- OFFSET 0 SETTINGS readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=0,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
# name: TestQuery.test_events_query_all_time_date
'''
/* user_id:0 request:_snapshot_ */
@@ -284,29 +197,6 @@
use_hive_partitioning=0
'''
# ---
-# name: TestQuery.test_full_hogql_query_materialized
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT events.event AS event,
- events.distinct_id AS distinct_id,
- nullIf(nullIf(events.mat_key, ''), 'null') AS key
- FROM events
- WHERE equals(events.team_id, 99999)
- ORDER BY toTimeZone(events.timestamp, 'UTC') ASC
- LIMIT 101
- OFFSET 0 SETTINGS readonly=2,
- max_execution_time=600,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=0,
- enable_analyzer=1,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
# name: TestQuery.test_full_hogql_query_view
'''
/* user_id:0 request:_snapshot_ */
@@ -478,117 +368,6 @@
use_hive_partitioning=0
'''
# ---
-# name: TestQuery.test_hogql_property_filter_materialized
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT events.event AS event,
- events.distinct_id AS distinct_id,
- nullIf(nullIf(events.mat_key, ''), 'null') AS key,
- 'a%sd',
- concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(nullIf(nullIf(events.mat_key, ''), 'null')), '')) AS `concat(event, ' ', properties.key)`
- FROM events
- WHERE and(equals(events.team_id, 99999), in(events.uuid,
- (SELECT events.uuid AS uuid
- FROM events
- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))
- ORDER BY events.event ASC
- LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))
- ORDER BY events.event ASC
- LIMIT 101
- OFFSET 0 SETTINGS readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=0,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
-# name: TestQuery.test_hogql_property_filter_materialized.1
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT events.event AS event,
- events.distinct_id AS distinct_id,
- nullIf(nullIf(events.mat_key, ''), 'null') AS key,
- 'a%sd',
- concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(nullIf(nullIf(events.mat_key, ''), 'null')), '')) AS `concat(event, ' ', properties.key)`
- FROM events
- WHERE 0
- ORDER BY events.event ASC
- LIMIT 101
- OFFSET 0 SETTINGS readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=0,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
-# name: TestQuery.test_hogql_property_filter_materialized.2
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT events.event AS event,
- events.distinct_id AS distinct_id,
- nullIf(nullIf(events.mat_key, ''), 'null') AS key,
- 'a%sd',
- concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(nullIf(nullIf(events.mat_key, ''), 'null')), '')) AS `concat(event, ' ', properties.key)`
- FROM events
- WHERE and(equals(events.team_id, 99999), in(events.uuid,
- (SELECT events.uuid AS uuid
- FROM events
- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))
- ORDER BY events.event ASC
- LIMIT 101)), and(less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))
- ORDER BY events.event ASC
- LIMIT 101
- OFFSET 0 SETTINGS readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=0,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
-# name: TestQuery.test_hogql_property_filter_materialized.3
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT events.event AS event,
- events.distinct_id AS distinct_id,
- nullIf(nullIf(events.mat_key, ''), 'null') AS key,
- 'a%sd',
- concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(nullIf(nullIf(events.mat_key, ''), 'null')), '')) AS `concat(event, ' ', properties.key)`
- FROM events
- WHERE and(equals(events.team_id, 99999), in(events.uuid,
- (SELECT events.uuid AS uuid
- FROM events
- WHERE and(equals(events.team_id, 99999), equals(events.mat_key, 'test_val2'), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))
- ORDER BY events.event ASC
- LIMIT 101)), and(equals(events.mat_key, 'test_val2'), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC'))))
- ORDER BY events.event ASC
- LIMIT 101
- OFFSET 0 SETTINGS readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=0,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
# name: TestQuery.test_person_property_filter
'''
/* user_id:0 request:_snapshot_ */
@@ -652,67 +431,6 @@
use_hive_partitioning=0
'''
# ---
-# name: TestQuery.test_person_property_filter_materialized
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT events.event AS event,
- events.distinct_id AS distinct_id,
- nullIf(nullIf(events.mat_key, ''), 'null') AS key,
- 'a%sd',
- concat(ifNull(toString(events.event), ''), ' ', ifNull(toString(nullIf(nullIf(events.mat_key, ''), 'null')), '')) AS `concat(event, ' ', properties.key)`
- FROM events
- LEFT OUTER JOIN
- (SELECT tupleElement(argMax(tuple(person_distinct_id_overrides.person_id), person_distinct_id_overrides.version), 1) AS person_id,
- person_distinct_id_overrides.distinct_id AS distinct_id
- FROM person_distinct_id_overrides
- WHERE equals(person_distinct_id_overrides.team_id, 99999)
- GROUP BY person_distinct_id_overrides.distinct_id
- HAVING ifNull(equals(tupleElement(argMax(tuple(person_distinct_id_overrides.is_deleted), person_distinct_id_overrides.version), 1), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)
- LEFT JOIN
- (SELECT person.id AS id,
- nullIf(nullIf(person.pmat_email, ''), 'null') AS properties___email
- FROM person
- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),
- (SELECT person.id AS id, max(person.version) AS version
- FROM person
- WHERE equals(person.team_id, 99999)
- GROUP BY person.id
- HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)
- WHERE and(equals(events.team_id, 99999), in(events.uuid,
- (SELECT events.uuid AS uuid
- FROM events
- LEFT OUTER JOIN
- (SELECT tupleElement(argMax(tuple(person_distinct_id_overrides.person_id), person_distinct_id_overrides.version), 1) AS person_id, person_distinct_id_overrides.distinct_id AS distinct_id
- FROM person_distinct_id_overrides
- WHERE equals(person_distinct_id_overrides.team_id, 99999)
- GROUP BY person_distinct_id_overrides.distinct_id
- HAVING ifNull(equals(tupleElement(argMax(tuple(person_distinct_id_overrides.is_deleted), person_distinct_id_overrides.version), 1), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)
- LEFT JOIN
- (SELECT person.id AS id, nullIf(nullIf(person.pmat_email, ''), 'null') AS properties___email
- FROM person
- WHERE and(equals(person.team_id, 99999), in(tuple(person.id, person.version),
- (SELECT person.id AS id, max(person.version) AS version
- FROM person
- WHERE equals(person.team_id, 99999)
- GROUP BY person.id
- HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0))))) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id)
- WHERE and(equals(events.team_id, 99999), ifNull(equals(events__person.properties___email, '[email protected]'), 0), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), greater(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))
- ORDER BY events.event ASC
- LIMIT 101)), and(ifNull(equals(events__person.properties___email, '[email protected]'), 0), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC')), greater(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))
- ORDER BY events.event ASC
- LIMIT 101
- OFFSET 0 SETTINGS readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=0,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
# name: TestQuery.test_property_filter_aggregations
'''
/* user_id:0 request:_snapshot_ */
@@ -762,51 +480,6 @@
use_hive_partitioning=0
'''
# ---
-# name: TestQuery.test_property_filter_aggregations_materialized
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT nullIf(nullIf(events.mat_key, ''), 'null') AS key,
- count() AS `count()`
- FROM events
- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))
- GROUP BY nullIf(nullIf(events.mat_key, ''), 'null')
- ORDER BY count() DESC
- LIMIT 101
- OFFSET 0 SETTINGS readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=0,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
-# name: TestQuery.test_property_filter_aggregations_materialized.1
- '''
- /* user_id:0 request:_snapshot_ */
- SELECT nullIf(nullIf(events.mat_key, ''), 'null') AS key,
- count() AS `count()`
- FROM events
- WHERE and(equals(events.team_id, 99999), less(events.timestamp, toDateTime64('2020-01-10 12:14:05.000000', 6, 'UTC')), greater(events.timestamp, toDateTime64('2020-01-09 12:14:00.000000', 6, 'UTC')))
- GROUP BY nullIf(nullIf(events.mat_key, ''), 'null')
- HAVING ifNull(greater(count(), 1), 0)
- ORDER BY count() DESC
- LIMIT 101
- OFFSET 0 SETTINGS readonly=2,
- max_execution_time=60,
- allow_experimental_object_type=1,
- max_ast_elements=4000000,
- max_expanded_ast_elements=4000000,
- max_bytes_before_external_group_by=0,
- transform_null_in=1,
- optimize_min_equality_disjunction_chain_length=4294967295,
- allow_experimental_join_condition=1,
- use_hive_partitioning=0
- '''
-# ---
# name: TestQuery.test_select_event_person
'''
/* user_id:0 request:_snapshot_ */
diff --git a/posthog/management/commands/ensure_migration_defaults.py b/posthog/management/commands/ensure_migration_defaults.py
index 41816d4cef3b..d0178f0d6d54 100644
--- a/posthog/management/commands/ensure_migration_defaults.py
+++ b/posthog/management/commands/ensure_migration_defaults.py
@@ -6,10 +6,10 @@ from typing import Any
from django.apps import apps
from django.core.management.base import BaseCommand
-from posthog.demo.dashboard_template_seeds import seed_dev_dashboard_templates
from posthog.models.data_color_theme import DataColorTheme
from products.dashboards.backend.models.dashboard_templates import DashboardTemplate
+from products.demo.backend.facade.api import seed_dev_dashboard_templates
# 0537 still references posthog.DataColorTheme which hasn't moved
_migration_0537 = importlib.import_module("posthog.migrations.0537_data_color_themes")
diff --git a/posthog/management/commands/generate_bot_demo_data.py b/posthog/management/commands/generate_bot_demo_data.py
index ad69fdfae2c0..10fcfab89599 100644
--- a/posthog/management/commands/generate_bot_demo_data.py
+++ b/posthog/management/commands/generate_bot_demo_data.py
@@ -5,7 +5,10 @@ from uuid import uuid4
from django.core.management.base import BaseCommand, CommandError
from django.utils import timezone
-from posthog.demo.products.hedgebox.taxonomy import (
+from posthog.models import Team
+from posthog.models.event.util import create_event
+
+from products.demo.backend.facade.api import (
SITE_URL,
URL_FILES,
URL_HOME,
@@ -14,9 +17,6 @@ from posthog.demo.products.hedgebox.taxonomy import (
URL_PRICING,
URL_SIGNUP,
)
-from posthog.models import Team
-from posthog.models.event.util import create_event
-
from products.web_analytics.backend.hogql_queries.bot_ua_fixtures import BOT_USER_AGENTS
# Crawl patterns per bot category - bots visit different pages based on their purpose
diff --git a/posthog/management/commands/generate_demo_data.py b/posthog/management/commands/generate_demo_data.py
index f41648d0541c..b2af86b600b6 100644
--- a/posthog/management/commands/generate_demo_data.py
+++ b/posthog/management/commands/generate_demo_data.py
@@ -14,11 +14,6 @@ from django.core.management.base import BaseCommand, CommandError
from django.db.utils import OperationalError
from posthog.api.person import PERSON_DEFAULT_DISPLAY_NAME_PROPERTIES
-from posthog.demo.dashboard_template_seeds import seed_dev_dashboard_templates
-from posthog.demo.matrix import Matrix, MatrixManager
-from posthog.demo.matrix.persons_db_sync import get_group_type_mapping_count
-from posthog.demo.products.hedgebox import HedgeboxMatrix
-from posthog.demo.products.spikegpt import SpikeGPTMatrix
from posthog.health import get_pending_postgres_migrations
from posthog.management.commands.sync_feature_flags_from_api import sync_feature_flags_from_api
from posthog.models import User
@@ -28,6 +23,15 @@ from posthog.models.team.team import Team
from posthog.products import Products
from posthog.taxonomy.taxonomy import PERSON_PROPERTIES_ADAPTED_FROM_EVENT
+from products.demo.backend.facade.api import (
+ HedgeboxMatrix,
+ Matrix,
+ MatrixManager,
+ SpikeGPTMatrix,
+ get_group_type_mapping_count,
+ seed_dev_dashboard_templates,
+)
+
from ee.clickhouse.materialized_columns.analyze import materialize_properties_task
logging.getLogger("kafka").setLevel(logging.ERROR) # Hide kafka-python's logspam
diff --git a/posthog/management/commands/plugin_server_load_test.py b/posthog/management/commands/plugin_server_load_test.py
index cae4b473dfb0..cf7f48bcece5 100644
--- a/posthog/management/commands/plugin_server_load_test.py
+++ b/posthog/management/commands/plugin_server_load_test.py
@@ -13,10 +13,11 @@ import structlog
from kafka import KafkaAdminClient, KafkaConsumer, TopicPartition
from posthog.api.capture import capture_batch_internal
-from posthog.demo.products.hedgebox import HedgeboxMatrix
from posthog.kafka_client.topics import KAFKA_EVENTS_PLUGIN_INGESTION
from posthog.models import Team
+from products.demo.backend.facade.api import HedgeboxMatrix
+
logging.getLogger("kafka").setLevel(logging.WARNING) # Hide kafka-python's logspam
logger = structlog.get_logger(__name__)
diff --git a/posthog/management/commands/setup_dev.py b/posthog/management/commands/setup_dev.py
index c4f2a19da7c5..d932717840f9 100644
--- a/posthog/management/commands/setup_dev.py
+++ b/posthog/management/commands/setup_dev.py
@@ -2,11 +2,11 @@ from django.core.management.base import BaseCommand
from django.db import transaction
from django.utils import timezone
-from posthog.demo.legacy import ORGANIZATION_NAME, TEAM_NAME, create_demo_data
from posthog.models import EventProperty, PersonalAPIKey, Team, User
from posthog.models.utils import hash_key_value
from products.cdp.backend.models.plugin import Plugin, PluginConfig, PluginSourceFile
+from products.demo.backend.facade.api import ORGANIZATION_NAME, TEAM_NAME, create_demo_data
from products.event_definitions.backend.models.event_definition import EventDefinition
from products.event_definitions.backend.models.property_definition import PropertyDefinition
diff --git a/posthog/management/commands/stream_live_events.py b/posthog/management/commands/stream_live_events.py
index 440646e85848..48f5078155b7 100644
--- a/posthog/management/commands/stream_live_events.py
+++ b/posthog/management/commands/stream_live_events.py
@@ -17,9 +17,10 @@ import datetime as dt
from django.core.management.base import BaseCommand
from posthog.api.capture import capture_internal
-from posthog.demo.products.hedgebox import HedgeboxMatrix
from posthog.models.team import Team
+from products.demo.backend.facade.api import HedgeboxMatrix
+
class Command(BaseCommand):
help = "Stream live demo events continuously for local development"
diff --git a/posthog/tasks/demo_create_data.py b/posthog/tasks/demo_create_data.py
index 99a57a688be4..6b4a384df571 100644
--- a/posthog/tasks/demo_create_data.py
+++ b/posthog/tasks/demo_create_data.py
@@ -13,11 +13,10 @@ def create_data_for_demo_team(team_id: int, user_id: int, cache_key: str) -> Non
# Deferred: the demo matrix pulls mimesis (a fake-data generator). This task module is
# eager-imported by posthog/tasks/__init__, so a module-level import drags mimesis onto
# every process's startup path. Only needed when actually generating demo data.
- from posthog.demo.matrix import manager # noqa: PLC0415
- from posthog.demo.products.hedgebox.matrix import HedgeboxMatrix # noqa: PLC0415
+ from products.demo.backend.facade.api import HedgeboxMatrix, MatrixManager # noqa: PLC0415
team = Team.objects.get(pk=team_id)
user = User.objects.get(pk=user_id)
if team and user:
- manager.MatrixManager(HedgeboxMatrix(), use_pre_save=True).run_on_team(team, user)
+ MatrixManager(HedgeboxMatrix(), use_pre_save=True).run_on_team(team, user)
cache.delete(cache_key)
diff --git a/posthog/tasks/demo_reset_master_team.py b/posthog/tasks/demo_reset_master_team.py
index ca62908e7733..96f88679d36b 100644
--- a/posthog/tasks/demo_reset_master_team.py
+++ b/posthog/tasks/demo_reset_master_team.py
@@ -4,8 +4,7 @@ from django.db import transaction
def demo_reset_master_team() -> None:
# Deferred: the demo matrix pulls mimesis (fake-data generator); this module is
# eager-imported by posthog/tasks/__init__, so a module-level import drags it onto startup.
- from posthog.demo.matrix import MatrixManager # noqa: PLC0415
- from posthog.demo.products import HedgeboxMatrix # noqa: PLC0415
+ from products.demo.backend.facade.api import HedgeboxMatrix, MatrixManager # noqa: PLC0415
matrix = HedgeboxMatrix()
manager = MatrixManager(matrix)
diff --git a/posthog/test/playwright_setup_functions.py b/posthog/test/playwright_setup_functions.py
index 9ad0352dc67c..aa01642af691 100644
--- a/posthog/test/playwright_setup_functions.py
+++ b/posthog/test/playwright_setup_functions.py
@@ -505,7 +505,7 @@ def _create_events_and_persons(data: PlaywrightWorkspaceSetupData, team: Team) -
_wait_for_events_in_clickhouse(team.pk, baseline_count + len(data.events))
# Populate event/property definitions so the taxonomic filter works
- from posthog.demo.matrix.taxonomy_inference import infer_taxonomy_for_team
+ from products.demo.backend.facade.api import infer_taxonomy_for_team
with tags_context(product=Product.INTERNAL, feature=Feature.MANAGEMENT_COMMAND):
infer_taxonomy_for_team(team.pk)
diff --git a/posthog/urls.py b/posthog/urls.py
index f6757d6da9b2..c155049ab258 100644
--- a/posthog/urls.py
+++ b/posthog/urls.py
@@ -40,7 +40,6 @@ from posthog.api.utils import hostname_in_allowed_url_list
from posthog.api.web_experiment import web_experiments
from posthog.api.zendesk_orgcheck import ensure_zendesk_organization
from posthog.constants import PERMITTED_FORUM_DOMAINS
-from posthog.demo.legacy import demo_route
from posthog.models import User
from posthog.models.instance_setting import get_instance_setting
from posthog.oauth2_urls import urlpatterns as oauth2_urls
@@ -49,6 +48,7 @@ from posthog.temporal.codec_server import decode_payloads
from products.ai_observability.backend.api.personal_spend import personal_spend_eu_redirect
from products.cdp.backend.api import hog_function_template
from products.data_warehouse.backend.presentation.views.public_source_configs import PublicSourceConfigViewSet
+from products.demo.backend.facade.api import demo_route
from products.early_access_features.backend.api import early_access_features
from products.legal_documents.backend.presentation.webhook import legal_document_pandadoc_webhook
from products.messaging.backend.api.customerio_webhook import CustomerIOWebhookView
diff --git a/posthog/demo/__init__.py b/products/demo/__init__.py
similarity index 100%
rename from posthog/demo/__init__.py
rename to products/demo/__init__.py
diff --git a/products/demo/backend/__init__.py b/products/demo/backend/__init__.py
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/products/demo/backend/facade/__init__.py b/products/demo/backend/facade/__init__.py
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/products/demo/backend/facade/api.py b/products/demo/backend/facade/api.py
new file mode 100644
index 000000000000..83a7fca62b83
--- /dev/null
+++ b/products/demo/backend/facade/api.py
@@ -0,0 +1,78 @@
+"""Public facade for the demo product.
+
+Core (`posthog/`, `ee/`) generates demo/simulation data only through the surface exposed
+here — signup, the demo celery tasks, the `generate_demo_data`/`setup_dev`/eval tooling,
+and the `demo_route` view. The matrix scenario classes cross the boundary as objects core
+instantiates; the data-generation helpers are thin functions over the product's logic.
+"""
+
+from __future__ import annotations
+
+from typing import TYPE_CHECKING
+
+from products.demo.backend.logic.dashboard_template_seeds import (
+ seed_dev_dashboard_templates as _seed_dev_dashboard_templates,
+)
+from products.demo.backend.logic.legacy import (
+ ORGANIZATION_NAME,
+ TEAM_NAME,
+ create_demo_data as _create_demo_data,
+ demo_route,
+)
+from products.demo.backend.logic.matrix import Matrix, MatrixManager
+from products.demo.backend.logic.matrix.persons_db_sync import (
+ get_group_type_mapping_count as _get_group_type_mapping_count,
+)
+from products.demo.backend.logic.matrix.taxonomy_inference import infer_taxonomy_for_team as _infer_taxonomy_for_team
+from products.demo.backend.logic.products.hedgebox import HedgeboxMatrix
+from products.demo.backend.logic.products.hedgebox.taxonomy import (
+ SITE_URL,
+ URL_FILES,
+ URL_HOME,
+ URL_LOGIN,
+ URL_MARIUS_TECH_TIPS,
+ URL_PRICING,
+ URL_SIGNUP,
+)
+from products.demo.backend.logic.products.spikegpt import SpikeGPTMatrix
+
+if TYPE_CHECKING:
+ from posthog.models.team import Team
+
+
+def create_demo_data(team: Team, dashboards: bool = True) -> None:
+ _create_demo_data(team, dashboards=dashboards)
+
+
+def seed_dev_dashboard_templates() -> list[str]:
+ return _seed_dev_dashboard_templates()
+
+
+def infer_taxonomy_for_team(team_id: int) -> tuple[int, int, int]:
+ return _infer_taxonomy_for_team(team_id)
+
+
+def get_group_type_mapping_count(project_id: int) -> int:
+ return _get_group_type_mapping_count(project_id)
+
+
+__all__ = [
+ "ORGANIZATION_NAME",
+ "SITE_URL",
+ "TEAM_NAME",
+ "URL_FILES",
+ "URL_HOME",
+ "URL_LOGIN",
+ "URL_MARIUS_TECH_TIPS",
+ "URL_PRICING",
+ "URL_SIGNUP",
+ "HedgeboxMatrix",
+ "Matrix",
+ "MatrixManager",
+ "SpikeGPTMatrix",
+ "create_demo_data",
+ "demo_route",
+ "get_group_type_mapping_count",
+ "infer_taxonomy_for_team",
+ "seed_dev_dashboard_templates",
+]
diff --git a/products/demo/backend/facade/contracts.py b/products/demo/backend/facade/contracts.py
new file mode 100644
index 000000000000..b51594e430a1
--- /dev/null
+++ b/products/demo/backend/facade/contracts.py
@@ -0,0 +1,9 @@
+"""Public data contracts for the demo product.
+
+The demo facade is behavioral: it exposes the matrix-simulation entry points (the
+`MatrixManager`, the `HedgeboxMatrix`/`SpikeGPTMatrix` scenarios) and data-generation
+helpers, which write into core models and return primitives. The product owns no data
+model of its own, so there are no product-owned contracts to define here — the file
+exists to mark the product as isolated and is the home for any future cross-boundary
+data record.
+"""
diff --git a/products/demo/backend/logic/__init__.py b/products/demo/backend/logic/__init__.py
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/posthog/demo/dashboard_template_seeds/01_website_metrics.json b/products/demo/backend/logic/dashboard_template_seeds/01_website_metrics.json
similarity index 100%
rename from posthog/demo/dashboard_template_seeds/01_website_metrics.json
rename to products/demo/backend/logic/dashboard_template_seeds/01_website_metrics.json
diff --git a/posthog/demo/dashboard_template_seeds/02_aarrr_pirate_metrics.json b/products/demo/backend/logic/dashboard_template_seeds/02_aarrr_pirate_metrics.json
similarity index 100%
rename from posthog/demo/dashboard_template_seeds/02_aarrr_pirate_metrics.json
rename to products/demo/backend/logic/dashboard_template_seeds/02_aarrr_pirate_metrics.json
diff --git a/posthog/demo/dashboard_template_seeds/03_csp_violation_reports.json b/products/demo/backend/logic/dashboard_template_seeds/03_csp_violation_reports.json
similarity index 100%
rename from posthog/demo/dashboard_template_seeds/03_csp_violation_reports.json
rename to products/demo/backend/logic/dashboard_template_seeds/03_csp_violation_reports.json
diff --git a/posthog/demo/dashboard_template_seeds/04_api_usage_metrics.json b/products/demo/backend/logic/dashboard_template_seeds/04_api_usage_metrics.json
similarity index 100%
rename from posthog/demo/dashboard_template_seeds/04_api_usage_metrics.json
rename to products/demo/backend/logic/dashboard_template_seeds/04_api_usage_metrics.json
diff --git a/posthog/demo/dashboard_template_seeds/05_landing_pages_report.json b/products/demo/backend/logic/dashboard_template_seeds/05_landing_pages_report.json
similarity index 100%
rename from posthog/demo/dashboard_template_seeds/05_landing_pages_report.json
rename to products/demo/backend/logic/dashboard_template_seeds/05_landing_pages_report.json
diff --git a/posthog/demo/dashboard_template_seeds/06_mobile_analytics.json b/products/demo/backend/logic/dashboard_template_seeds/06_mobile_analytics.json
similarity index 100%
rename from posthog/demo/dashboard_template_seeds/06_mobile_analytics.json
rename to products/demo/backend/logic/dashboard_template_seeds/06_mobile_analytics.json
diff --git a/posthog/demo/dashboard_template_seeds/07_product_analytics.json b/products/demo/backend/logic/dashboard_template_seeds/07_product_analytics.json
similarity index 100%
rename from posthog/demo/dashboard_template_seeds/07_product_analytics.json
rename to products/demo/backend/logic/dashboard_template_seeds/07_product_analytics.json
diff --git a/posthog/demo/dashboard_template_seeds/08_real_time_analytics.json b/products/demo/backend/logic/dashboard_template_seeds/08_real_time_analytics.json
similarity index 100%
rename from posthog/demo/dashboard_template_seeds/08_real_time_analytics.json
rename to products/demo/backend/logic/dashboard_template_seeds/08_real_time_analytics.json
diff --git a/posthog/demo/dashboard_template_seeds/__init__.py b/products/demo/backend/logic/dashboard_template_seeds/__init__.py
similarity index 100%
rename from posthog/demo/dashboard_template_seeds/__init__.py
rename to products/demo/backend/logic/dashboard_template_seeds/__init__.py
diff --git a/posthog/demo/legacy/__init__.py b/products/demo/backend/logic/legacy/__init__.py
similarity index 100%
rename from posthog/demo/legacy/__init__.py
rename to products/demo/backend/logic/legacy/__init__.py
diff --git a/posthog/demo/legacy/app_data_generator.py b/products/demo/backend/logic/legacy/app_data_generator.py
similarity index 100%
rename from posthog/demo/legacy/app_data_generator.py
rename to products/demo/backend/logic/legacy/app_data_generator.py
diff --git a/posthog/demo/legacy/data_generator.py b/products/demo/backend/logic/legacy/data_generator.py
similarity index 100%
rename from posthog/demo/legacy/data_generator.py
rename to products/demo/backend/logic/legacy/data_generator.py
diff --git a/posthog/demo/legacy/demo_people.json b/products/demo/backend/logic/legacy/demo_people.json
similarity index 100%
rename from posthog/demo/legacy/demo_people.json
rename to products/demo/backend/logic/legacy/demo_people.json
diff --git a/posthog/demo/legacy/hogflix_session_recording.json b/products/demo/backend/logic/legacy/hogflix_session_recording.json
similarity index 100%
rename from posthog/demo/legacy/hogflix_session_recording.json
rename to products/demo/backend/logic/legacy/hogflix_session_recording.json
diff --git a/posthog/demo/legacy/insight_variables_data_generator.py b/products/demo/backend/logic/legacy/insight_variables_data_generator.py
similarity index 100%
rename from posthog/demo/legacy/insight_variables_data_generator.py
rename to products/demo/backend/logic/legacy/insight_variables_data_generator.py
diff --git a/posthog/demo/legacy/revenue_data_generator.py b/products/demo/backend/logic/legacy/revenue_data_generator.py
similarity index 100%
rename from posthog/demo/legacy/revenue_data_generator.py
rename to products/demo/backend/logic/legacy/revenue_data_generator.py
diff --git a/posthog/demo/legacy/web_data_generator.py b/products/demo/backend/logic/legacy/web_data_generator.py
similarity index 96%
rename from posthog/demo/legacy/web_data_generator.py
rename to products/demo/backend/logic/legacy/web_data_generator.py
index 0069318fc47a..63784958ed39 100644
--- a/posthog/demo/legacy/web_data_generator.py
+++ b/products/demo/backend/logic/legacy/web_data_generator.py
@@ -1,6 +1,7 @@
import json
import random
from datetime import timedelta
+from pathlib import Path
from typing import Any
from django.utils.timezone import now
@@ -11,7 +12,6 @@ from posthog.constants import TREND_FILTER_TYPE_ACTIONS
from posthog.models import Person, PropertyDefinition
from posthog.models.filters.mixins.utils import cached_property
from posthog.models.utils import UUIDT
-from posthog.utils import get_absolute_path
from products.actions.backend.models.action import Action
from products.dashboards.backend.models.dashboard import Dashboard
@@ -20,6 +20,9 @@ from products.product_analytics.backend.models.insight import Insight
from .data_generator import DataGenerator
+# JSON fixtures live in this directory, beside this module.
+_LEGACY_DATA_DIR = Path(__file__).resolve().parent
+
SCREEN_OPTIONS = ("settings", "profile", "movies", "downloads")
@@ -210,10 +213,10 @@ class WebDataGenerator(DataGenerator):
@cached_property
def demo_data(self) -> list[dict[str, Any]]:
- with open(get_absolute_path("demo/legacy/demo_people.json")) as demo_data_file:
+ with open(_LEGACY_DATA_DIR / "demo_people.json") as demo_data_file:
return json.load(demo_data_file)
@cached_property
def demo_recording(self) -> dict[str, Any]:
- with open(get_absolute_path("demo/legacy/hogflix_session_recording.json")) as demo_session_file:
+ with open(_LEGACY_DATA_DIR / "hogflix_session_recording.json") as demo_session_file:
return json.load(demo_session_file)
diff --git a/posthog/demo/matrix/__init__.py b/products/demo/backend/logic/matrix/__init__.py
similarity index 100%
rename from posthog/demo/matrix/__init__.py
rename to products/demo/backend/logic/matrix/__init__.py
diff --git a/posthog/demo/matrix/manager.py b/products/demo/backend/logic/matrix/manager.py
similarity index 99%
rename from posthog/demo/matrix/manager.py
rename to products/demo/backend/logic/matrix/manager.py
index a99864c8a8d3..d90a23e2133c 100644
--- a/posthog/demo/matrix/manager.py
+++ b/products/demo/backend/logic/matrix/manager.py
@@ -9,17 +9,17 @@ from django.core import exceptions
from django.db import transaction
from posthog.clickhouse.client import sync_execute
-from posthog.demo.matrix.persons_db_sync import (
+from posthog.models import Organization, OrganizationMembership, Team, User
+from posthog.models.utils import UUIDT, generate_random_token_project
+
+from products.cohorts.backend.models.cohort import Cohort
+from products.demo.backend.logic.matrix.persons_db_sync import (
bulk_create_group_type_mappings,
copy_group_type_mappings,
delete_group_type_mappings,
sync_persons_to_postgres,
)
-from posthog.demo.matrix.taxonomy_inference import infer_taxonomy_for_team
-from posthog.models import Organization, OrganizationMembership, Team, User
-from posthog.models.utils import UUIDT, generate_random_token_project
-
-from products.cohorts.backend.models.cohort import Cohort
+from products.demo.backend.logic.matrix.taxonomy_inference import infer_taxonomy_for_team
from .matrix import Matrix
from .models import SimEvent, SimPerson
diff --git a/posthog/demo/matrix/matrix.py b/products/demo/backend/logic/matrix/matrix.py
similarity index 99%
rename from posthog/demo/matrix/matrix.py
rename to products/demo/backend/logic/matrix/matrix.py
index f639859030a2..31fd7aa7207b 100644
--- a/posthog/demo/matrix/matrix.py
+++ b/products/demo/backend/logic/matrix/matrix.py
@@ -12,11 +12,11 @@ import tiktoken
import mimesis.random
from posthog.constants import GROUP_TYPES_LIMIT
-from posthog.demo.matrix.randomization import PropertiesProvider
from posthog.helpers.tiktoken_encoding import LLM_TOKEN_COUNT_PROXY_MODEL, get_tiktoken_encoding_for_model
from posthog.models import Team, User
from posthog.models.utils import UUIDT, uuid7
+from products.demo.backend.logic.matrix.randomization import PropertiesProvider
from products.feature_flags.backend.models.feature_flag import FeatureFlag
from .models import Effect, SimPerson, SimServerClient
diff --git a/posthog/demo/matrix/models.py b/products/demo/backend/logic/matrix/models.py
similarity index 99%
rename from posthog/demo/matrix/models.py
rename to products/demo/backend/logic/matrix/models.py
index 2c84b904ce1f..40ed1d60955a 100644
--- a/posthog/demo/matrix/models.py
+++ b/products/demo/backend/logic/matrix/models.py
@@ -13,7 +13,7 @@ from uuid import UUID, uuid4
from zoneinfo import ZoneInfo
if TYPE_CHECKING:
- from posthog.demo.matrix.matrix import Cluster, Matrix
+ from products.demo.backend.logic.matrix.matrix import Cluster, Matrix
# Refer to https://github.com/PostHog/posthog-ai-costs-app/tree/main/src/ai-cost-data for missing models
LLM_COSTS_BY_MODEL = {
diff --git a/posthog/demo/matrix/persons_db_sync.py b/products/demo/backend/logic/matrix/persons_db_sync.py
similarity index 100%
rename from posthog/demo/matrix/persons_db_sync.py
rename to products/demo/backend/logic/matrix/persons_db_sync.py
diff --git a/posthog/demo/matrix/randomization.py b/products/demo/backend/logic/matrix/randomization.py
similarity index 100%
rename from posthog/demo/matrix/randomization.py
rename to products/demo/backend/logic/matrix/randomization.py
diff --git a/posthog/demo/matrix/taxonomy_inference.py b/products/demo/backend/logic/matrix/taxonomy_inference.py
similarity index 100%
rename from posthog/demo/matrix/taxonomy_inference.py
rename to products/demo/backend/logic/matrix/taxonomy_inference.py
diff --git a/posthog/demo/products/__init__.py b/products/demo/backend/logic/products/__init__.py
similarity index 100%
rename from posthog/demo/products/__init__.py
rename to products/demo/backend/logic/products/__init__.py
diff --git a/posthog/demo/products/hedgebox/__init__.py b/products/demo/backend/logic/products/hedgebox/__init__.py
similarity index 100%
rename from posthog/demo/products/hedgebox/__init__.py
rename to products/demo/backend/logic/products/hedgebox/__init__.py
diff --git a/posthog/demo/products/hedgebox/matrix.py b/products/demo/backend/logic/products/hedgebox/matrix.py
similarity index 99%
rename from posthog/demo/products/hedgebox/matrix.py
rename to products/demo/backend/logic/products/hedgebox/matrix.py
index 54c863a37e15..de2150b9bf4f 100644
--- a/posthog/demo/products/hedgebox/matrix.py
+++ b/products/demo/backend/logic/products/hedgebox/matrix.py
@@ -47,9 +47,6 @@ from posthog.schema import (
from posthog.cloud_utils import is_cloud
from posthog.constants import PAGEVIEW_EVENT
-from posthog.demo.matrix.matrix import Cluster, Matrix
-from posthog.demo.matrix.models import SimEvent
-from posthog.demo.matrix.randomization import Industry
from posthog.exceptions_capture import capture_exception
from posthog.models.event.util import create_event
from posthog.models.oauth import OAuthApplication
@@ -61,6 +58,9 @@ from products.cohorts.backend.models.cohort import Cohort
from products.dashboards.backend.models.dashboard import Dashboard
from products.dashboards.backend.models.dashboard_tile import DashboardTile
from products.data_tools.backend.models.join import DataWarehouseJoin
+from products.demo.backend.logic.matrix.matrix import Cluster, Matrix
+from products.demo.backend.logic.matrix.models import SimEvent
+from products.demo.backend.logic.matrix.randomization import Industry
from products.endpoints.backend.facade.models import Endpoint, EndpointVersion
from products.error_tracking.backend.models import (
ErrorTrackingIssue,
diff --git a/posthog/demo/products/hedgebox/models.py b/products/demo/backend/logic/products/hedgebox/models.py
similarity index 99%
rename from posthog/demo/products/hedgebox/models.py
rename to products/demo/backend/logic/products/hedgebox/models.py
index 51783fbe658e..3d08fcab557d 100644
--- a/posthog/demo/products/hedgebox/models.py
+++ b/products/demo/backend/logic/products/hedgebox/models.py
@@ -9,7 +9,7 @@ from zoneinfo import ZoneInfo
import pytz
-from posthog.demo.matrix.models import EVENT_AUTOCAPTURE, Effect, SimPerson, SimSessionIntent
+from products.demo.backend.logic.matrix.models import EVENT_AUTOCAPTURE, Effect, SimPerson, SimSessionIntent
from .taxonomy import (
BIAS_WARNING_FLIP_PROBABILITY,
@@ -58,7 +58,7 @@ from .taxonomy import (
)
if TYPE_CHECKING:
- from posthog.demo.products.hedgebox.matrix import HedgeboxCluster
+ from products.demo.backend.logic.products.hedgebox.matrix import HedgeboxCluster
class HedgeboxSessionIntent(SimSessionIntent):
diff --git a/posthog/demo/products/hedgebox/taxonomy.py b/products/demo/backend/logic/products/hedgebox/taxonomy.py
similarity index 100%
rename from posthog/demo/products/hedgebox/taxonomy.py
rename to products/demo/backend/logic/products/hedgebox/taxonomy.py
diff --git a/posthog/demo/products/spikegpt/__init__.py b/products/demo/backend/logic/products/spikegpt/__init__.py
similarity index 100%
rename from posthog/demo/products/spikegpt/__init__.py
rename to products/demo/backend/logic/products/spikegpt/__init__.py
diff --git a/posthog/demo/products/spikegpt/data.py b/products/demo/backend/logic/products/spikegpt/data.py
similarity index 100%
rename from posthog/demo/products/spikegpt/data.py
rename to products/demo/backend/logic/products/spikegpt/data.py
diff --git a/posthog/demo/products/spikegpt/matrix.py b/products/demo/backend/logic/products/spikegpt/matrix.py
similarity index 95%
rename from posthog/demo/products/spikegpt/matrix.py
rename to products/demo/backend/logic/products/spikegpt/matrix.py
index b598b210904a..ff1ccbc224df 100644
--- a/posthog/demo/products/spikegpt/matrix.py
+++ b/products/demo/backend/logic/products/spikegpt/matrix.py
@@ -1,6 +1,5 @@
-from posthog.demo.matrix.matrix import Cluster, Matrix
-
from products.cohorts.backend.models.cohort import Cohort
+from products.demo.backend.logic.matrix.matrix import Cluster, Matrix
from .models import SpikeGPTPerson
diff --git a/posthog/demo/products/spikegpt/models.py b/products/demo/backend/logic/products/spikegpt/models.py
similarity index 98%
rename from posthog/demo/products/spikegpt/models.py
rename to products/demo/backend/logic/products/spikegpt/models.py
index 0a27ecb6697e..bd04d6f34aee 100644
--- a/posthog/demo/products/spikegpt/models.py
+++ b/products/demo/backend/logic/products/spikegpt/models.py
@@ -5,8 +5,8 @@ from urllib.parse import urlencode, urlparse, urlunparse
import pytz
-from posthog.demo.matrix.models import EVENT_PAGELEAVE, SimPerson, SimSessionIntent
-from posthog.demo.products.spikegpt.data import FAKE_CHATS
+from products.demo.backend.logic.matrix.models import EVENT_PAGELEAVE, SimPerson, SimSessionIntent
+from products.demo.backend.logic.products.spikegpt.data import FAKE_CHATS
from .taxonomy import URL_HOME
diff --git a/posthog/demo/products/spikegpt/taxonomy.py b/products/demo/backend/logic/products/spikegpt/taxonomy.py
similarity index 100%
rename from posthog/demo/products/spikegpt/taxonomy.py
rename to products/demo/backend/logic/products/spikegpt/taxonomy.py
diff --git a/posthog/demo/test/test_hedgebox_matrix.py b/products/demo/backend/test/test_hedgebox_matrix.py
similarity index 92%
rename from posthog/demo/test/test_hedgebox_matrix.py
rename to products/demo/backend/test/test_hedgebox_matrix.py
index 0b66f0ea716e..771a108ada8e 100644
--- a/posthog/demo/test/test_hedgebox_matrix.py
+++ b/products/demo/backend/test/test_hedgebox_matrix.py
@@ -9,9 +9,9 @@ from django.test import SimpleTestCase, override_settings
from parameterized import parameterized
-from posthog.demo.matrix.models import SimEvent
-from posthog.demo.products.hedgebox.matrix import HedgeboxMatrix
-from posthog.demo.products.hedgebox.taxonomy import (
+from products.demo.backend.logic.matrix.models import SimEvent
+from products.demo.backend.logic.products.hedgebox.matrix import HedgeboxMatrix
+from products.demo.backend.logic.products.hedgebox.taxonomy import (
EVENT_DOWNGRADED_PLAN,
EVENT_PAID_BILL,
EVENT_SIGNED_UP,
@@ -181,9 +181,9 @@ class TestHedgeboxMatrixDemoWarehouseTables(SimpleTestCase):
),
]
- @patch("posthog.demo.products.hedgebox.matrix.object_storage.write")
- @patch("posthog.demo.products.hedgebox.matrix.DataWarehouseTable.objects.create")
- @patch("posthog.demo.products.hedgebox.matrix.DataWarehouseTable.objects.filter")
+ @patch("products.demo.backend.logic.products.hedgebox.matrix.object_storage.write")
+ @patch("products.demo.backend.logic.products.hedgebox.matrix.DataWarehouseTable.objects.create")
+ @patch("products.demo.backend.logic.products.hedgebox.matrix.DataWarehouseTable.objects.filter")
def test_upsert_demo_data_warehouse_table_sets_csv_double_quotes_on_create(
self, mock_filter, mock_create, _mock_write
):
@@ -206,8 +206,8 @@ class TestHedgeboxMatrixDemoWarehouseTables(SimpleTestCase):
mock_create.assert_called_once()
assert mock_create.call_args.kwargs["options"] == {"csv_allow_double_quotes": True}
- @patch("posthog.demo.products.hedgebox.matrix.object_storage.write")
- @patch("posthog.demo.products.hedgebox.matrix.DataWarehouseTable.objects.filter")
+ @patch("products.demo.backend.logic.products.hedgebox.matrix.object_storage.write")
+ @patch("products.demo.backend.logic.products.hedgebox.matrix.DataWarehouseTable.objects.filter")
def test_upsert_demo_data_warehouse_table_sets_csv_double_quotes_on_update(self, mock_filter, _mock_write):
matrix = HedgeboxMatrix(seed="warehouse-test", n_clusters=0)
team = cast(Any, SimpleNamespace(pk=1))
@@ -257,7 +257,7 @@ class TestHedgeboxMatrixDemoOAuthApplication(SimpleTestCase):
("no_oidc_key", "", True, False, True),
]
)
- @patch("posthog.demo.products.hedgebox.matrix.OAuthApplication.objects.create")
+ @patch("products.demo.backend.logic.products.hedgebox.matrix.OAuthApplication.objects.create")
def test_demo_oauth_app_only_created_in_local_dev(
self,
_name: str,
@@ -272,7 +272,7 @@ class TestHedgeboxMatrixDemoOAuthApplication(SimpleTestCase):
user = cast(Any, SimpleNamespace())
with override_settings(OIDC_RSA_PRIVATE_KEY=oidc_key, DEBUG=debug):
- with patch("posthog.demo.products.hedgebox.matrix.is_cloud", return_value=cloud):
+ with patch("products.demo.backend.logic.products.hedgebox.matrix.is_cloud", return_value=cloud):
matrix._set_up_demo_oauth_application(team, user)
if should_skip:
diff --git a/posthog/demo/test/test_matrix_manager.py b/products/demo/backend/test/test_matrix_manager.py
similarity index 93%
rename from posthog/demo/test/test_matrix_manager.py
rename to products/demo/backend/test/test_matrix_manager.py
index 7acf43ffeb74..7ffae60ce95c 100644
--- a/posthog/demo/test/test_matrix_manager.py
+++ b/products/demo/backend/test/test_matrix_manager.py
@@ -6,9 +6,10 @@ from zoneinfo import ZoneInfo
from posthog.test.base import ClickhouseDestroyTablesMixin
from posthog.clickhouse.client import sync_execute
-from posthog.demo.matrix.manager import MatrixManager
-from posthog.demo.matrix.matrix import Cluster, Matrix
-from posthog.demo.matrix.models import SimPerson, SimSessionIntent
+
+from products.demo.backend.logic.matrix.manager import MatrixManager
+from products.demo.backend.logic.matrix.matrix import Cluster, Matrix
+from products.demo.backend.logic.matrix.models import SimPerson, SimSessionIntent
class DummySessionIntent(SimSessionIntent):
diff --git a/posthog/demo/test/test_persons_db_sync.py b/products/demo/backend/test/test_persons_db_sync.py
similarity index 99%
rename from posthog/demo/test/test_persons_db_sync.py
rename to products/demo/backend/test/test_persons_db_sync.py
index 028f10318e97..a6f68d0aa8bd 100644
--- a/posthog/demo/test/test_persons_db_sync.py
+++ b/products/demo/backend/test/test_persons_db_sync.py
@@ -6,7 +6,9 @@ from django.conf import settings
import psycopg
-from posthog.demo.matrix.persons_db_sync import (
+from posthog.persons_db import persons_db_connection
+
+from products.demo.backend.logic.matrix.persons_db_sync import (
_insert_groups,
_insert_person_distinct_ids,
_insert_persons,
@@ -15,7 +17,6 @@ from posthog.demo.matrix.persons_db_sync import (
delete_group_type_mappings,
get_group_type_mapping_count,
)
-from posthog.persons_db import persons_db_connection
SYNC_TEST_TEAM_ID = 2_000_000_010
SYNC_TEST_PROJECT_ID = 2_000_000_010
diff --git a/products/demo/manifest.tsx b/products/demo/manifest.tsx
new file mode 100644
index 000000000000..e2824d93d487
--- /dev/null
+++ b/products/demo/manifest.tsx
@@ -0,0 +1,7 @@
+import { ProductManifest } from '~/types'
+
+export const manifest: ProductManifest = {
+ name: 'Demo data',
+ treeItemsNew: [],
+ treeItemsProducts: [],
+}
diff --git a/products/demo/package.json b/products/demo/package.json
new file mode 100644
index 000000000000..f08610b153e5
--- /dev/null
+++ b/products/demo/package.json
@@ -0,0 +1,8 @@
+{
+ "name": "@posthog/products-demo",
+ "scripts": {
+ "backend:test": "pytest -c ../../pytest.ini --rootdir ../.. backend/test -v --tb=short",
+ "backend:lint": "ruff check --config ../../pyproject.toml backend && ruff format --config ../../pyproject.toml --check backend",
+ "backend:contract-check": "echo 'Contract files unchanged'"
+ }
+}
diff --git a/products/demo/product.yaml b/products/demo/product.yaml
new file mode 100644
index 000000000000..3f80404ceeef
--- /dev/null
+++ b/products/demo/product.yaml
@@ -0,0 +1,3 @@
+name: Demo data
+owners:
+ - team-growth
diff --git a/products/demo/tsconfig.json b/products/demo/tsconfig.json
new file mode 100644
index 000000000000..fe425d6fcba8
--- /dev/null
+++ b/products/demo/tsconfig.json
@@ -0,0 +1,6 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "composite": true
+ }
+}
diff --git a/products/demo/turbo.json b/products/demo/turbo.json
new file mode 100644
index 000000000000..34a16b3d30ce
--- /dev/null
+++ b/products/demo/turbo.json
@@ -0,0 +1,10 @@
+{
+ "extends": ["//"],
+ "tasks": {
+ "backend:contract-check": {
+ "inputs": ["backend/facade/**", "backend/presentation/**"],
+ "outputs": [],
+ "cache": true
+ }
+ }
+}
diff --git a/products/ruff.toml b/products/ruff.toml
index a69d9e67471c..6f55978e592b 100644
--- a/products/ruff.toml
+++ b/products/ruff.toml
@@ -31,6 +31,7 @@ extend-select = ["ANN001", "ANN201", "ANN202", "ANN204"]
"data_modeling/backend/**" = ["ANN"]
"data_tools/backend/**" = ["ANN"]
"data_warehouse/backend/**" = ["ANN"]
+"demo/backend/**" = ["ANN"]
"early_access_features/backend/**" = ["ANN"]
"endpoints/backend/**" = ["ANN"]
"error_tracking/backend/**" = ["ANN"]
@@ -72,6 +73,7 @@ extend-select = ["ANN001", "ANN201", "ANN202", "ANN204"]
"data_modeling/**" = ["PLC0415"]
"data_tools/**" = ["PLC0415"]
"data_warehouse/**" = ["PLC0415"]
+"demo/**" = ["PLC0415"]
"deployments/**" = ["PLC0415"]
"early_access_features/**" = ["PLC0415"]
"endpoints/**" = ["PLC0415"]
diff --git a/products/tasks/backend/management/commands/setup_background_agents.py b/products/tasks/backend/management/commands/setup_background_agents.py
index d65f7541ce53..4261c78e33a8 100644
--- a/products/tasks/backend/management/commands/setup_background_agents.py
+++ b/products/tasks/backend/management/commands/setup_background_agents.py
@@ -23,7 +23,7 @@ AUTO_FILL_KEYS = [
]
GITHUB_APP_KEYS = ["GITHUB_APP_CLIENT_ID", "GITHUB_APP_CLIENT_SECRET", "GITHUB_APP_SLUG", "GITHUB_APP_PRIVATE_KEY"]
# Canonical local-dev redirect URIs for the Array OAuth app (matches
-# posthog/demo/products/hedgebox/matrix.py and docs/published/handbook/engineering/oauth-development-guide.md).
+# products/demo/backend/logic/products/hedgebox/matrix.py and docs/published/handbook/engineering/oauth-development-guide.md).
EXPECTED_REDIRECT_URIS = (
"http://localhost:3000/callback "
"https://example.com/callback "
diff --git a/tach.toml b/tach.toml
index 34ab1a4ba52a..4086301b62b7 100644
--- a/tach.toml
+++ b/tach.toml
@@ -43,6 +43,7 @@ depends_on = [
"products.dashboards",
"products.data_modeling",
"products.data_tools",
+ "products.demo",
"products.error_tracking",
"products.event_definitions",
"products.experiments",
@@ -81,6 +82,7 @@ depends_on = [
"products.dashboards",
"products.data_modeling",
"products.data_warehouse",
+ "products.demo",
"products.early_access_features",
"products.endpoints",
"products.engineering_analytics",
@@ -266,6 +268,24 @@ depends_on = [
]
layer = "modules"
+[[modules]]
+path = "products.demo"
+depends_on = [
+ "posthog",
+ "products.actions",
+ "products.cohorts",
+ "products.dashboards",
+ "products.data_tools",
+ "products.endpoints",
+ "products.error_tracking",
+ "products.event_definitions",
+ "products.experiments",
+ "products.feature_flags",
+ "products.product_analytics",
+ "products.warehouse_sources",
+]
+layer = "modules"
+
[[modules]]
path = "products.early_access_features"
depends_on = [
@@ -720,7 +740,7 @@ expose = [
"backend\\.routes.*",
]
from = [
- "products\\.(customer_analytics|data_modeling|data_warehouse|endpoints|error_tracking|experiments|mcp_analytics|mcp_store|metrics|notebooks|notifications|streamlit_apps|tasks|tracing|user_interviews|visual_review|warehouse_sources)",
+ "products\\.(customer_analytics|data_modeling|data_warehouse|demo|endpoints|error_tracking|experiments|mcp_analytics|mcp_store|metrics|notebooks|notifications|streamlit_apps|tasks|tracing|user_interviews|visual_review|warehouse_sources)",
]
# TODO: Experiments-specific temporary interface
diff --git a/tools/hedgebox-dummy/README.md b/tools/hedgebox-dummy/README.md
index 33ebd74b1350..b5d7aa611d46 100644
--- a/tools/hedgebox-dummy/README.md
+++ b/tools/hedgebox-dummy/README.md
@@ -4,7 +4,7 @@ This app represents our Hedgebox product simulation for demo data purposes.
## Background
-We've had a [demo data generator](../../posthog/demo/products/hedgebox/) simulating a product called Hedgebox (like Dropbox for hedgehogs) for a while now. It creates realistic event data with user profiles, behaviors, timezones, even includes features like a Marius Tech Tips sponsorship landing page and an A/B test on the signup flow.
+We've had a [demo data generator](../../products/demo/backend/logic/products/hedgebox/) simulating a product called Hedgebox (like Dropbox for hedgehogs) for a while now. It creates realistic event data with user profiles, behaviors, timezones, even includes features like a Marius Tech Tips sponsorship landing page and an A/B test on the signup flow.
However, the generator hasn't been able to create session recording data, as that's a hard nut to ~~crack~~ store. Session recordings need an actual app with actual user interactions to capture. Hedgebox never had one - until now.