: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
feat(hogql): apply custom mcp harness names to $virt_mcp_harness (#125824)
Paul D'Ambra10e82b09303c
diff --git a/.agents/skills/debugging-mcp-analytics/references/event-vocabulary.md b/.agents/skills/debugging-mcp-analytics/references/event-vocabulary.mdindex 5256629f87df..fccf340a96ef 100644--- a/.agents/skills/debugging-mcp-analytics/references/event-vocabulary.md+++ b/.agents/skills/debugging-mcp-analytics/references/event-vocabulary.md@@ -254,7 +254,7 @@ intentionally omitted, matching TS `instrument()`.- Take failures from `$mcp_is_error` (with `$mcp_error_type` / `$mcp_error_status` for thereason), never from `$exception`, which can be absent by design and so returns nothingrather than erroring.-- Group clients by the resolved **harness** label, not raw `$mcp_client_name`.+- Group clients by the resolved **harness** label, not raw `$mcp_client_name`. In SQL, select `properties.$virt_mcp_harness`: it is that label, including the team's custom harness names.- Zombie tools = `arrayJoin($mcp_listed_tool_names)` from `$mcp_tools_list`, minus the distincteffective tool names seen on `$mcp_tool_call`. `$mcp_exec_inner_tool_names` is the intendedsingle-exec equivalent but is unemitted today, so a query resting on it returns nothing.diff --git a/docs/published/docs/mcp-analytics/harness-share.mdx b/docs/published/docs/mcp-analytics/harness-share.mdxindex 7888676181f6..06b2ed2048b1 100644--- a/docs/published/docs/mcp-analytics/harness-share.mdx+++ b/docs/published/docs/mcp-analytics/harness-share.mdx@@ -32,7 +32,8 @@ PostHog assigns each call a harness from the client identity captured with it: tTo name an in-house harness, go to **Settings > Environment > MCP analytics > Custom harnesses**. Add a name and the text to look for in the client name or User-Agent product that the harness reports. Matching ignores case and finds the text anywhere in the name. Your custom names are checked before the built-in ones. When the text of two custom harnesses matches, the longer text wins, so `acme-agent` takes priority over `acme`. Each project can have up to 20.-The custom name shows wherever harness names show, including the harness share card and the activity views. Harness names are cached, so a change can take a few minutes to appear.+The custom name shows wherever harness names show, including the harness share card, the activity views, and `properties.$virt_mcp_harness` in SQL. Harness names are cached, so a change can take a few minutes to appear.+A SQL query or insight that already has cached results keeps the old name until those results refresh.## Harness labels in SQLdiff --git a/posthog/api/test/__snapshots__/test_element.ambr b/posthog/api/test/__snapshots__/test_element.ambrindex 3692a2e12d7b..1aab9135b270 100644--- a/posthog/api/test/__snapshots__/test_element.ambr+++ b/posthog/api/test/__snapshots__/test_element.ambr@@ -184,6 +184,45 @@'''# ---# name: TestElement.test_element_stats_postgres_queries_are_as_expected.10+ '''+ SELECT "posthog_externaldatasource"."created_by_id",+ "posthog_externaldatasource"."created_at",+ "posthog_externaldatasource"."updated_at",+ "posthog_externaldatasource"."deleted",+ "posthog_externaldatasource"."deleted_at",+ "posthog_externaldatasource"."id",+ "posthog_externaldatasource"."source_id",+ "posthog_externaldatasource"."connection_id",+ "posthog_externaldatasource"."destination_id",+ "posthog_externaldatasource"."team_id",+ "posthog_externaldatasource"."sync_frequency",+ "posthog_externaldatasource"."status",+ "posthog_externaldatasource"."source_type",+ "posthog_externaldatasource"."api_version",+ "posthog_externaldatasource"."job_inputs",+ "posthog_externaldatasource"."credentials_integration_id",+ "posthog_externaldatasource"."connection_metadata",+ "posthog_externaldatasource"."are_tables_created",+ "posthog_externaldatasource"."prefix",+ "posthog_externaldatasource"."description",+ "posthog_externaldatasource"."created_via",+ "posthog_externaldatasource"."access_method",+ "posthog_externaldatasource"."direct_query_enabled",+ "posthog_externaldatasource"."auto_sync_new_schemas",+ "posthog_externaldatasource"."auto_sync_schema_patterns",+ "posthog_externaldatasource"."revenue_analytics_enabled",+ "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",+ "posthog_externaldatasourcerevenueanalyticsconfig"."enabled",+ "posthog_externaldatasourcerevenueanalyticsconfig"."include_invoiceless_charges"+ FROM "posthog_externaldatasource"+ LEFT OUTER JOIN "posthog_externaldatasourcerevenueanalyticsconfig" ON ("posthog_externaldatasource"."id" = "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id")+ WHERE ("posthog_externaldatasource"."team_id" = 99999+ AND NOT ("posthog_externaldatasource"."deleted"+ AND "posthog_externaldatasource"."deleted" IS NOT NULL)+ AND "posthog_externaldatasource"."source_type" IN ('Stripe'))+ '''+# ---+# name: TestElement.test_element_stats_postgres_queries_are_as_expected.11'''SELECT "posthog_datawarehousejoin"."created_by_id","posthog_datawarehousejoin"."created_at",@@ -203,7 +242,7 @@AND "posthog_datawarehousejoin"."deleted" IS NOT NULL))'''# ----# name: TestElement.test_element_stats_postgres_queries_are_as_expected.11+# name: TestElement.test_element_stats_postgres_queries_are_as_expected.12'''SELECT "data_tools_datawarehouseexpression"."deleted","data_tools_datawarehouseexpression"."deleted_at",@@ -222,39 +261,6 @@AND "data_tools_datawarehouseexpression"."connection_id" IS NULL)'''# ----# name: TestElement.test_element_stats_postgres_queries_are_as_expected.12- '''- SELECT "posthog_datawarehousetable"."created_by_id",- "posthog_datawarehousetable"."created_at",- "posthog_datawarehousetable"."updated_at",- "posthog_datawarehousetable"."deleted",- "posthog_datawarehousetable"."deleted_at",- "posthog_datawarehousetable"."id",- "posthog_datawarehousetable"."name",- "posthog_datawarehousetable"."format",- "posthog_datawarehousetable"."team_id",- "posthog_datawarehousetable"."url_pattern",- "posthog_datawarehousetable"."queryable_folder",- "posthog_datawarehousetable"."credential_id",- "posthog_datawarehousetable"."external_data_source_id",- "posthog_datawarehousetable"."created_via",- "posthog_datawarehousetable"."columns",- "posthog_datawarehousetable"."column_order",- "posthog_datawarehousetable"."options",- "posthog_datawarehousetable"."row_count",- "posthog_datawarehousetable"."size_in_s3_mib"- FROM "posthog_datawarehousetable"- LEFT OUTER JOIN "posthog_externaldatasource" ON ("posthog_datawarehousetable"."external_data_source_id" = "posthog_externaldatasource"."id")- WHERE ("posthog_datawarehousetable"."team_id" = 99999- AND NOT ("posthog_datawarehousetable"."deleted"- AND "posthog_datawarehousetable"."deleted" IS NOT NULL)- AND NOT ("posthog_externaldatasource"."deleted"- AND "posthog_externaldatasource"."deleted" IS NOT NULL)- AND NOT ("posthog_externaldatasource"."access_method" = 'direct'- AND "posthog_externaldatasource"."access_method" IS NOT NULL))- ORDER BY "posthog_datawarehousetable"."created_at" DESC- '''-# ---# name: TestElement.test_element_stats_postgres_queries_are_as_expected.13'''SELECT "posthog_datawarehousetable"."created_by_id",@@ -475,6 +481,15 @@'''# ---# name: TestElement.test_element_stats_postgres_queries_are_as_expected.7+ '''+ SELECT "posthog_mcp_custom_harness"."name" AS "name",+ "posthog_mcp_custom_harness"."match_pattern" AS "match_pattern"+ FROM "posthog_mcp_custom_harness"+ WHERE "posthog_mcp_custom_harness"."team_id" = 99999+ ORDER BY LENGTH("posthog_mcp_custom_harness"."match_pattern") DESC, "posthog_mcp_custom_harness"."created_at" ASC+ '''+# ---+# name: TestElement.test_element_stats_postgres_queries_are_as_expected.8'''SELECT "posthog_datawarehousesavedquery"."created_by_id","posthog_datawarehousesavedquery"."created_at",@@ -539,7 +554,7 @@ORDER BY "posthog_datawarehousesavedquery"."name" ASC'''# ----# name: TestElement.test_element_stats_postgres_queries_are_as_expected.8+# name: TestElement.test_element_stats_postgres_queries_are_as_expected.9'''SELECT "posthog_teamrevenueanalyticsconfig"."team_id","posthog_teamrevenueanalyticsconfig"."filter_test_accounts",@@ -552,42 +567,3 @@LIMIT 21'''# ----# name: TestElement.test_element_stats_postgres_queries_are_as_expected.9- '''- SELECT "posthog_externaldatasource"."created_by_id",- "posthog_externaldatasource"."created_at",- "posthog_externaldatasource"."updated_at",- "posthog_externaldatasource"."deleted",- "posthog_externaldatasource"."deleted_at",- "posthog_externaldatasource"."id",- "posthog_externaldatasource"."source_id",- "posthog_externaldatasource"."connection_id",- "posthog_externaldatasource"."destination_id",- "posthog_externaldatasource"."team_id",- "posthog_externaldatasource"."sync_frequency",- "posthog_externaldatasource"."status",- "posthog_externaldatasource"."source_type",- "posthog_externaldatasource"."api_version",- "posthog_externaldatasource"."job_inputs",- "posthog_externaldatasource"."credentials_integration_id",- "posthog_externaldatasource"."connection_metadata",- "posthog_externaldatasource"."are_tables_created",- "posthog_externaldatasource"."prefix",- "posthog_externaldatasource"."description",- "posthog_externaldatasource"."created_via",- "posthog_externaldatasource"."access_method",- "posthog_externaldatasource"."direct_query_enabled",- "posthog_externaldatasource"."auto_sync_new_schemas",- "posthog_externaldatasource"."auto_sync_schema_patterns",- "posthog_externaldatasource"."revenue_analytics_enabled",- "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",- "posthog_externaldatasourcerevenueanalyticsconfig"."enabled",- "posthog_externaldatasourcerevenueanalyticsconfig"."include_invoiceless_charges"- FROM "posthog_externaldatasource"- LEFT OUTER JOIN "posthog_externaldatasourcerevenueanalyticsconfig" ON ("posthog_externaldatasource"."id" = "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id")- WHERE ("posthog_externaldatasource"."team_id" = 99999- AND NOT ("posthog_externaldatasource"."deleted"- AND "posthog_externaldatasource"."deleted" IS NOT NULL)- AND "posthog_externaldatasource"."source_type" IN ('Stripe'))- '''-# ---diff --git a/posthog/api/test/test_event.py b/posthog/api/test/test_event.pyindex 83393602578b..1d29087748be 100644--- a/posthog/api/test/test_event.py+++ b/posthog/api/test/test_event.py@@ -116,8 +116,9 @@ class TestEvents(ClickhouseTestMixin, APIBaseTest):# skip its per-call Team+organization lookup. +1 for the saved-expressions fetch in the# HogQL database build. +1 each for the flag-cache TTL, projection kill-switch and# properties-narrowing instance settings, cold-cache here but TTL-cached per worker in production. +1 for the- # organization's flag_evaluations mode lookup in the HogQL database build.- with self.assertNumQueries(18):+ # organization's flag_evaluations mode lookup in the HogQL database build. +1 for the MCP custom harness fetch in+ # the HogQL database build.+ with self.assertNumQueries(19):response = self.client.get(f"/api/projects/{self.team.id}/events/?event=event_name").json()assert response["results"][0]["event"] == "event_name"@@ -155,7 +156,8 @@ class TestEvents(ClickhouseTestMixin, APIBaseTest):# +1 for the saved-expressions fetch in the HogQL database build. +1 each for the flag-cache# TTL, projection kill-switch and properties-narrowing instance settings, cold-cache here but# TTL-cached per worker in production. +1 for the organization's flag_evaluations mode lookup in the HogQL database build.- expected_queries = 24 if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA else 25+ # +1 for the MCP custom harness fetch in the HogQL database build.+ expected_queries = 25 if settings.CLICKHOUSE_HOGQL_USE_NEW_EVENTS_SCHEMA else 26with self.assertNumQueries(expected_queries):response = self.client.get(diff --git a/posthog/api/test/test_person.py b/posthog/api/test/test_person.pyindex e5049cd95680..7a09f7b37e73 100644--- a/posthog/api/test/test_person.py+++ b/posthog/api/test/test_person.py@@ -2266,8 +2266,9 @@ class TestPerson(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):# saved-expressions fetch in the HogQL database build. +1 each for the shared-database# kill-switch, projection kill-switch, properties-narrowing and flag-cache TTL instance# settings, cold-cache here but TTL-cached per worker in production. +1 for the organization's flag_evaluations mode- # lookup in the HogQL database build.- with self.assertNumQueries(19):+ # lookup in the HogQL database build. +1 for the MCP custom harness fetch in the HogQL database build, which later+ # requests read from Redis.+ with self.assertNumQueries(20):response = self.client.get("/api/person/?limit=10").json()self.assertEqual(len(response["results"]), 9)returned_ids += [x["distinct_ids"][0] for x in response["results"]]diff --git a/posthog/hogql/database/database.py b/posthog/hogql/database/database.pyindex 5c84e1313988..ffbee42bd855 100644--- a/posthog/hogql/database/database.py+++ b/posthog/hogql/database/database.py@@ -213,6 +213,7 @@ if TYPE_CHECKING:from products.data_modeling.backend.facade.models import DataWarehouseSavedQueryfrom products.data_tools.backend.models.expression import DataWarehouseExpressionfrom products.data_tools.backend.models.join import DataWarehouseJoin+ from products.mcp_analytics.backend.facade.contracts import CustomHarnessRulefrom products.revenue_analytics.backend.views import RevenueAnalyticsBaseViewfrom products.revenue_analytics.backend.views.core import SourceHandlefrom products.warehouse_sources.backend.facade.models import (@@ -265,6 +266,7 @@ class HogQLDatabaseSources:user_access_control: Optional[UserAccessControl]denied_system_table_names: set[str] # node names under the "system" node to remove during buildgroup_types: list[dict[str, Any]]+ mcp_custom_harness_rules: Sequence[CustomHarnessRule]saved_queries: list[DataWarehouseSavedQuery]endpoint_saved_queries: list[DataWarehouseSavedQuery]revenue_views: list[RevenueAnalyticsBaseView]@@ -307,6 +309,7 @@ class HogQLDatabaseSources:dict(self.direct_connection_metadata) if self.direct_connection_metadata is not None else None),group_types=list(self.group_types),+ mcp_custom_harness_rules=tuple(self.mcp_custom_harness_rules),saved_queries=list(self.saved_queries),endpoint_saved_queries=list(self.endpoint_saved_queries),revenue_views=[view.model_copy(deep=True) for view in self.revenue_views],@@ -2018,6 +2021,7 @@ class Database(BaseModel):flag_calls_only_in_flag_evaluations=False,read_flag_calls_with_union=False,group_types=[],+ mcp_custom_harness_rules=(),saved_queries=[],endpoint_saved_queries=[],revenue_views=[],@@ -2059,6 +2063,7 @@ class Database(BaseModel):from products.data_modeling.backend.facade.models import DataWarehouseSavedQuery # noqa: PLC0415from products.data_tools.backend.models.expression import DataWarehouseExpression # noqa: PLC0415from products.data_tools.backend.models.join import DataWarehouseJoin # noqa: PLC0415+ from products.mcp_analytics.backend.facade.api import custom_harness_rules # noqa: PLC0415from products.warehouse_sources.backend.facade.models import ( # noqa: PLC0415DataWarehouseTable,ExternalDataSource,@@ -2201,6 +2206,9 @@ class Database(BaseModel):[] if is_direct_query else list(get_group_types_for_project(team.project_id)))+ with timings.measure("mcp_custom_harnesses", emit_span=True):+ mcp_custom_harness_rules = () if is_direct_query else custom_harness_rules(team)+with timings.measure("data_warehouse_saved_query", emit_span=True):saved_queries: list[DataWarehouseSavedQuery] = []all_saved_queries: list[DataWarehouseSavedQuery] = []@@ -2411,6 +2419,7 @@ class Database(BaseModel):user_access_control=user_access_control,denied_system_table_names=denied_system_table_names,group_types=group_types,+ mcp_custom_harness_rules=mcp_custom_harness_rules,saved_queries=saved_queries,endpoint_saved_queries=endpoint_saved_queries,revenue_views=revenue_views,@@ -2587,7 +2596,7 @@ class Database(BaseModel):with timings.measure("virtual_fields", emit_span=True):if not database._is_direct_query():- _use_virtual_fields(database, modifiers, timings)+ _use_virtual_fields(database, modifiers, timings, sources.mcp_custom_harness_rules)with timings.measure("group_type_mapping", emit_span=True):if not database._is_direct_query():@@ -3325,7 +3334,12 @@ def _setup_group_key_fields(database: Database, group_types: list[dict[str, Any])-def _use_virtual_fields(database: Database, modifiers: HogQLQueryModifiers, timings: HogQLTimings) -> None:+def _use_virtual_fields(+ database: Database,+ modifiers: HogQLQueryModifiers,+ timings: HogQLTimings,+ mcp_custom_harness_rules: Sequence[CustomHarnessRule],+) -> None:events_table = database.get_table("events")persons_table = database.get_table("persons")groups_table = database.get_table("groups")@@ -3389,7 +3403,7 @@ def _use_virtual_fields(database: Database, modifiers: HogQLQueryModifiers, timievents_table.fields["$virt_mcp_harness"] = ExpressionField(name="$virt_mcp_harness",- expr=mcp_harness_virtual_field_expr(),+ expr=mcp_harness_virtual_field_expr(mcp_custom_harness_rules),isolate_scope=True,description="MCP client label computed from this event's client identity signals.",)diff --git a/posthog/hogql/database/test/test_database.py b/posthog/hogql/database/test/test_database.pyindex 2297fb02eca9..62c42169247d 100644--- a/posthog/hogql/database/test/test_database.py+++ b/posthog/hogql/database/test/test_database.py@@ -1162,7 +1162,7 @@ class TestDatabase(BaseTest, QueryMatchingTest):# +1 vs the pre-bulk-credential baseline: one bulk credential fetch replaces the per-row# credential joins (decrypt once per credential, not per table/view). +1 more for the# organization's flag_evaluations mode, which is_flag_evaluations_table_enabled reads once per build.- max_queries = FuzzyInt(7, 9)+ max_queries = FuzzyInt(7, 10)credential = DataWarehouseCredential.objects.create(team=self.team, access_key="_accesskey", access_secret="_secret")@@ -1220,7 +1220,8 @@ class TestDatabase(BaseTest, QueryMatchingTest):# initialization team query doesn't run; the extra query is the single bulk credential fetch# (credentials are decrypted once each here instead of re-decrypted per table/view row),- # plus the saved-expressions fetch and the organization's flag_evaluations mode+ # plus the saved-expressions fetch and the organization's flag_evaluations mode.+ # The custom MCP harness rules come from Redis, which the first build filled.with self.assertNumQueries(7):modifiers = create_default_modifiers_for_team(self.team, modifiers=HogQLQueryModifiers(useMaterializedViews=True)@@ -2549,7 +2550,8 @@ class TestDatabase(BaseTest, QueryMatchingTest):# +1 vs the pre-bulk-credential baseline: one bulk credential fetch replaces the per-row# credential joins (decrypt once per credential, not per table/view).- with self.assertNumQueries(FuzzyInt(6, 9)):+ # Upper bound +1 for the custom MCP harness lookup.+ with self.assertNumQueries(FuzzyInt(6, 10)):Database.create_for(team=self.team)# We keep adding sources, credentials and tables, number of queries should be stablediff --git a/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr b/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambrindex 0ed396915157..fe1ff9497e59 100644--- a/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr+++ b/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr@@ -798,6 +798,15 @@'''# ---# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.27+ '''+ SELECT "posthog_mcp_custom_harness"."name" AS "name",+ "posthog_mcp_custom_harness"."match_pattern" AS "match_pattern"+ FROM "posthog_mcp_custom_harness"+ WHERE "posthog_mcp_custom_harness"."team_id" = 99999+ ORDER BY LENGTH("posthog_mcp_custom_harness"."match_pattern") DESC, "posthog_mcp_custom_harness"."created_at" ASC+ '''+# ---+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.28'''SELECT "posthog_datawarehousesavedquery"."created_by_id","posthog_datawarehousesavedquery"."created_at",@@ -862,7 +871,7 @@ORDER BY "posthog_datawarehousesavedquery"."name" ASC'''# ----# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.28+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.29'''SELECT "posthog_teamrevenueanalyticsconfig"."team_id","posthog_teamrevenueanalyticsconfig"."filter_test_accounts",@@ -875,45 +884,6 @@LIMIT 21'''# ----# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.29- '''- SELECT "posthog_externaldatasource"."created_by_id",- "posthog_externaldatasource"."created_at",- "posthog_externaldatasource"."updated_at",- "posthog_externaldatasource"."deleted",- "posthog_externaldatasource"."deleted_at",- "posthog_externaldatasource"."id",- "posthog_externaldatasource"."source_id",- "posthog_externaldatasource"."connection_id",- "posthog_externaldatasource"."destination_id",- "posthog_externaldatasource"."team_id",- "posthog_externaldatasource"."sync_frequency",- "posthog_externaldatasource"."status",- "posthog_externaldatasource"."source_type",- "posthog_externaldatasource"."api_version",- "posthog_externaldatasource"."job_inputs",- "posthog_externaldatasource"."credentials_integration_id",- "posthog_externaldatasource"."connection_metadata",- "posthog_externaldatasource"."are_tables_created",- "posthog_externaldatasource"."prefix",- "posthog_externaldatasource"."description",- "posthog_externaldatasource"."created_via",- "posthog_externaldatasource"."access_method",- "posthog_externaldatasource"."direct_query_enabled",- "posthog_externaldatasource"."auto_sync_new_schemas",- "posthog_externaldatasource"."auto_sync_schema_patterns",- "posthog_externaldatasource"."revenue_analytics_enabled",- "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",- "posthog_externaldatasourcerevenueanalyticsconfig"."enabled",- "posthog_externaldatasourcerevenueanalyticsconfig"."include_invoiceless_charges"- FROM "posthog_externaldatasource"- LEFT OUTER JOIN "posthog_externaldatasourcerevenueanalyticsconfig" ON ("posthog_externaldatasource"."id" = "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id")- WHERE ("posthog_externaldatasource"."team_id" = 99999- AND NOT ("posthog_externaldatasource"."deleted"- AND "posthog_externaldatasource"."deleted" IS NOT NULL)- AND "posthog_externaldatasource"."source_type" IN ('Stripe'))- '''-# ---# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.3'''SELECT "posthog_user"."id",@@ -1001,6 +971,45 @@'''# ---# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.30+ '''+ SELECT "posthog_externaldatasource"."created_by_id",+ "posthog_externaldatasource"."created_at",+ "posthog_externaldatasource"."updated_at",+ "posthog_externaldatasource"."deleted",+ "posthog_externaldatasource"."deleted_at",+ "posthog_externaldatasource"."id",+ "posthog_externaldatasource"."source_id",+ "posthog_externaldatasource"."connection_id",+ "posthog_externaldatasource"."destination_id",+ "posthog_externaldatasource"."team_id",+ "posthog_externaldatasource"."sync_frequency",+ "posthog_externaldatasource"."status",+ "posthog_externaldatasource"."source_type",+ "posthog_externaldatasource"."api_version",+ "posthog_externaldatasource"."job_inputs",+ "posthog_externaldatasource"."credentials_integration_id",+ "posthog_externaldatasource"."connection_metadata",+ "posthog_externaldatasource"."are_tables_created",+ "posthog_externaldatasource"."prefix",+ "posthog_externaldatasource"."description",+ "posthog_externaldatasource"."created_via",+ "posthog_externaldatasource"."access_method",+ "posthog_externaldatasource"."direct_query_enabled",+ "posthog_externaldatasource"."auto_sync_new_schemas",+ "posthog_externaldatasource"."auto_sync_schema_patterns",+ "posthog_externaldatasource"."revenue_analytics_enabled",+ "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",+ "posthog_externaldatasourcerevenueanalyticsconfig"."enabled",+ "posthog_externaldatasourcerevenueanalyticsconfig"."include_invoiceless_charges"+ FROM "posthog_externaldatasource"+ LEFT OUTER JOIN "posthog_externaldatasourcerevenueanalyticsconfig" ON ("posthog_externaldatasource"."id" = "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id")+ WHERE ("posthog_externaldatasource"."team_id" = 99999+ AND NOT ("posthog_externaldatasource"."deleted"+ AND "posthog_externaldatasource"."deleted" IS NOT NULL)+ AND "posthog_externaldatasource"."source_type" IN ('Stripe'))+ '''+# ---+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.31'''SELECT "posthog_datawarehousejoin"."created_by_id","posthog_datawarehousejoin"."created_at",@@ -1020,7 +1029,7 @@AND "posthog_datawarehousejoin"."deleted" IS NOT NULL))'''# ----# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.31+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.32'''SELECT "data_tools_datawarehouseexpression"."deleted","data_tools_datawarehouseexpression"."deleted_at",@@ -1039,7 +1048,7 @@AND "data_tools_datawarehouseexpression"."connection_id" IS NULL)'''# ----# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.32+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.33'''SELECT "posthog_datawarehousetable"."created_by_id","posthog_datawarehousetable"."created_at",@@ -1072,7 +1081,7 @@ORDER BY "posthog_datawarehousetable"."created_at" DESC'''# ----# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.33+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.34'''SELECT "posthog_propertydefinition"."id","posthog_propertydefinition"."team_id",@@ -1096,7 +1105,7 @@5 /* ... */))'''# ----# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.34+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.35'''SELECT "posthog_user"."id","posthog_user"."password",@@ -1182,7 +1191,7 @@AND "posthog_user"."id" = 99999)'''# ----# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.35+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.36'''SELECT "posthog_team"."id","posthog_team"."uuid",@@ -1320,7 +1329,7 @@LIMIT 21'''# ----# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.36+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.37'''SELECT "posthog_organizationmembership"."id","posthog_organizationmembership"."organization_id",@@ -1375,7 +1384,7 @@LIMIT 21'''# ----# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.37+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.38'''SELECT "ee_accesscontrol"."id","ee_accesscontrol"."team_id",@@ -1398,7 +1407,7 @@AND "ee_accesscontrol"."team_id" = 99999))'''# ----# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.38+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.39'''SELECT "posthog_organizationmembership"."id","posthog_organizationmembership"."organization_id",@@ -1451,17 +1460,6 @@WHERE "posthog_organizationmembership"."user_id" = 99999'''# ----# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.39- '''- SELECT COUNT(*) AS "__count"- FROM "posthog_sessionrecordingplaylist"- WHERE (NOT "posthog_sessionrecordingplaylist"."deleted"- AND NOT "posthog_sessionrecordingplaylist"."deleted"- AND "posthog_sessionrecordingplaylist"."team_id" = 99999- AND NOT "posthog_sessionrecordingplaylist"."deleted"- AND NOT "posthog_sessionrecordingplaylist"."deleted")- '''-# ---# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.4'''SELECT "posthog_team"."id",@@ -1601,6 +1599,17 @@'''# ---# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.40+ '''+ SELECT COUNT(*) AS "__count"+ FROM "posthog_sessionrecordingplaylist"+ WHERE (NOT "posthog_sessionrecordingplaylist"."deleted"+ AND NOT "posthog_sessionrecordingplaylist"."deleted"+ AND "posthog_sessionrecordingplaylist"."team_id" = 99999+ AND NOT "posthog_sessionrecordingplaylist"."deleted"+ AND NOT "posthog_sessionrecordingplaylist"."deleted")+ '''+# ---+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.41'''SELECT "posthog_sessionrecordingplaylist"."id","posthog_sessionrecordingplaylist"."short_id",@@ -1811,7 +1820,7 @@LIMIT 94'''# ----# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.41+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.42'''SELECT "posthog_sessionrecordingplaylistitem"."playlist_id" AS "playlist_id",COUNT("posthog_sessionrecordingplaylistitem"."id") AS "c"@@ -1831,7 +1840,7 @@GROUP BY 1'''# ----# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.42+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.43'''SELECT "posthog_sessionrecordingplaylistitem"."playlist_id" AS "playlist_id","posthog_sessionrecordingplaylistitem"."recording_id" AS "recording_id"@@ -1850,7 +1859,7 @@AND "posthog_sessionrecording"."start_time" IS NOT NULL))'''# ----# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.43+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.44'''SELECT "posthog_sessionrecordingviewed"."session_id" AS "session_id"FROM "posthog_sessionrecordingviewed"@@ -1859,7 +1868,7 @@AND "posthog_sessionrecordingviewed"."session_id" IN ('00000000-0000-0000-0000-000000000000'))'''# ----# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.44+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.45'''SELECT COUNT(*) AS "__count"FROM "posthog_sessionrecordingviewed"@@ -1867,7 +1876,7 @@AND "posthog_sessionrecordingviewed"."user_id" = 99999)'''# ----# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.45+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.46'''SELECT COUNT(*)FROM@@ -1879,7 +1888,7 @@AND NOT ("posthog_comment"."item_id" IS NULL))) subquery'''# ----# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.46+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.47'''SELECT COUNT(*)FROM@@ -1890,7 +1899,7 @@AND NOT ("posthog_sharingconfiguration"."recording_id" IS NULL))) subquery'''# ----# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.47+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.48'''SELECT COUNT(*)FROM@@ -1905,18 +1914,6 @@AND "posthog_exportedasset"."export_context" IS NOT NULL))) subquery'''# ----# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.48- '''- SELECT COUNT(*)- FROM- (SELECT DISTINCT "posthog_comment"."item_id" AS "item_id"- FROM "posthog_comment"- WHERE (NOT "posthog_comment"."deleted"- AND "posthog_comment"."scope" = 'Replay'- AND "posthog_comment"."team_id" = 99999- AND NOT ("posthog_comment"."item_id" IS NULL))) subquery- '''-# ---# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.49'''SELECT COUNT(*)diff --git a/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr b/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambrindex c13827f8fce7..7197bac1e40e 100644--- a/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr+++ b/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr@@ -232,6 +232,45 @@'''# ---# name: TestSessionRecordings.test_get_session_recordings_returns_newest_first.10+ '''+ SELECT "posthog_externaldatasource"."created_by_id",+ "posthog_externaldatasource"."created_at",+ "posthog_externaldatasource"."updated_at",+ "posthog_externaldatasource"."deleted",+ "posthog_externaldatasource"."deleted_at",+ "posthog_externaldatasource"."id",+ "posthog_externaldatasource"."source_id",+ "posthog_externaldatasource"."connection_id",+ "posthog_externaldatasource"."destination_id",+ "posthog_externaldatasource"."team_id",+ "posthog_externaldatasource"."sync_frequency",+ "posthog_externaldatasource"."status",+ "posthog_externaldatasource"."source_type",+ "posthog_externaldatasource"."api_version",+ "posthog_externaldatasource"."job_inputs",+ "posthog_externaldatasource"."credentials_integration_id",+ "posthog_externaldatasource"."connection_metadata",+ "posthog_externaldatasource"."are_tables_created",+ "posthog_externaldatasource"."prefix",+ "posthog_externaldatasource"."description",+ "posthog_externaldatasource"."created_via",+ "posthog_externaldatasource"."access_method",+ "posthog_externaldatasource"."direct_query_enabled",+ "posthog_externaldatasource"."auto_sync_new_schemas",+ "posthog_externaldatasource"."auto_sync_schema_patterns",+ "posthog_externaldatasource"."revenue_analytics_enabled",+ "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",+ "posthog_externaldatasourcerevenueanalyticsconfig"."enabled",+ "posthog_externaldatasourcerevenueanalyticsconfig"."include_invoiceless_charges"+ FROM "posthog_externaldatasource"+ LEFT OUTER JOIN "posthog_externaldatasourcerevenueanalyticsconfig" ON ("posthog_externaldatasource"."id" = "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id")+ WHERE ("posthog_externaldatasource"."team_id" = 99999+ AND NOT ("posthog_externaldatasource"."deleted"+ AND "posthog_externaldatasource"."deleted" IS NOT NULL)+ AND "posthog_externaldatasource"."source_type" IN ('Stripe'))+ '''+# ---+# name: TestSessionRecordings.test_get_session_recordings_returns_newest_first.11'''SELECT "posthog_datawarehousejoin"."created_by_id","posthog_datawarehousejoin"."created_at",@@ -251,7 +290,7 @@AND "posthog_datawarehousejoin"."deleted" IS NOT NULL))'''# ----# name: TestSessionRecordings.test_get_session_recordings_returns_newest_first.11+# name: TestSessionRecordings.test_get_session_recordings_returns_newest_first.12'''SELECT "data_tools_datawarehouseexpression"."deleted","data_tools_datawarehouseexpression"."deleted_at",@@ -270,7 +309,7 @@AND "data_tools_datawarehouseexpression"."connection_id" IS NULL)'''# ----# name: TestSessionRecordings.test_get_session_recordings_returns_newest_first.12+# name: TestSessionRecordings.test_get_session_recordings_returns_newest_first.13'''SELECT "posthog_datawarehousetable"."created_by_id","posthog_datawarehousetable"."created_at",@@ -303,7 +342,7 @@ORDER BY "posthog_datawarehousetable"."created_at" DESC'''# ----# name: TestSessionRecordings.test_get_session_recordings_returns_newest_first.13+# name: TestSessionRecordings.test_get_session_recordings_returns_newest_first.14'''SELECT "posthog_sessionrecording"."id","posthog_sessionrecording"."session_id",@@ -331,7 +370,7 @@AND "posthog_sessionrecording"."team_id" = 99999)'''# ----# name: TestSessionRecordings.test_get_session_recordings_returns_newest_first.14+# name: TestSessionRecordings.test_get_session_recordings_returns_newest_first.15'''SELECT "posthog_sessionrecordingviewed"."session_id" AS "session_id"FROM "posthog_sessionrecordingviewed"@@ -342,19 +381,6 @@'old_session'))'''# ----# name: TestSessionRecordings.test_get_session_recordings_returns_newest_first.15- '''- SELECT "posthog_sessionrecordingviewed"."session_id" AS "session_id",- "posthog_user"."email" AS "user__email"- FROM "posthog_sessionrecordingviewed"- INNER JOIN "posthog_user" ON ("posthog_sessionrecordingviewed"."user_id" = "posthog_user"."id")- WHERE ("posthog_sessionrecordingviewed"."session_id" IN ('new_session',- 'middle_session',- 'old_session')- AND "posthog_sessionrecordingviewed"."team_id" = 99999- AND NOT ("posthog_sessionrecordingviewed"."user_id" = 99999))- '''-# ---# name: TestSessionRecordings.test_get_session_recordings_returns_newest_first.16'''SELECT "posthog_sessionrecordingviewed"."session_id" AS "session_id",@@ -564,6 +590,15 @@'''# ---# name: TestSessionRecordings.test_get_session_recordings_returns_newest_first.7+ '''+ SELECT "posthog_mcp_custom_harness"."name" AS "name",+ "posthog_mcp_custom_harness"."match_pattern" AS "match_pattern"+ FROM "posthog_mcp_custom_harness"+ WHERE "posthog_mcp_custom_harness"."team_id" = 99999+ ORDER BY LENGTH("posthog_mcp_custom_harness"."match_pattern") DESC, "posthog_mcp_custom_harness"."created_at" ASC+ '''+# ---+# name: TestSessionRecordings.test_get_session_recordings_returns_newest_first.8'''SELECT "posthog_datawarehousesavedquery"."created_by_id","posthog_datawarehousesavedquery"."created_at",@@ -628,7 +663,7 @@ORDER BY "posthog_datawarehousesavedquery"."name" ASC'''# ----# name: TestSessionRecordings.test_get_session_recordings_returns_newest_first.8+# name: TestSessionRecordings.test_get_session_recordings_returns_newest_first.9'''SELECT "posthog_teamrevenueanalyticsconfig"."team_id","posthog_teamrevenueanalyticsconfig"."filter_test_accounts",@@ -641,45 +676,6 @@LIMIT 21'''# ----# name: TestSessionRecordings.test_get_session_recordings_returns_newest_first.9- '''- SELECT "posthog_externaldatasource"."created_by_id",- "posthog_externaldatasource"."created_at",- "posthog_externaldatasource"."updated_at",- "posthog_externaldatasource"."deleted",- "posthog_externaldatasource"."deleted_at",- "posthog_externaldatasource"."id",- "posthog_externaldatasource"."source_id",- "posthog_externaldatasource"."connection_id",- "posthog_externaldatasource"."destination_id",- "posthog_externaldatasource"."team_id",- "posthog_externaldatasource"."sync_frequency",- "posthog_externaldatasource"."status",- "posthog_externaldatasource"."source_type",- "posthog_externaldatasource"."api_version",- "posthog_externaldatasource"."job_inputs",- "posthog_externaldatasource"."credentials_integration_id",- "posthog_externaldatasource"."connection_metadata",- "posthog_externaldatasource"."are_tables_created",- "posthog_externaldatasource"."prefix",- "posthog_externaldatasource"."description",- "posthog_externaldatasource"."created_via",- "posthog_externaldatasource"."access_method",- "posthog_externaldatasource"."direct_query_enabled",- "posthog_externaldatasource"."auto_sync_new_schemas",- "posthog_externaldatasource"."auto_sync_schema_patterns",- "posthog_externaldatasource"."revenue_analytics_enabled",- "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",- "posthog_externaldatasourcerevenueanalyticsconfig"."enabled",- "posthog_externaldatasourcerevenueanalyticsconfig"."include_invoiceless_charges"- FROM "posthog_externaldatasource"- LEFT OUTER JOIN "posthog_externaldatasourcerevenueanalyticsconfig" ON ("posthog_externaldatasource"."id" = "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id")- WHERE ("posthog_externaldatasource"."team_id" = 99999- AND NOT ("posthog_externaldatasource"."deleted"- AND "posthog_externaldatasource"."deleted" IS NOT NULL)- AND "posthog_externaldatasource"."source_type" IN ('Stripe'))- '''-# ---# name: TestSessionRecordings.test_get_session_recordings_scenarios_0_basic_listing'''SELECT "posthog_user"."id",@@ -905,6 +901,45 @@'''# ---# name: TestSessionRecordings.test_get_session_recordings_scenarios_0_basic_listing.10+ '''+ SELECT "posthog_externaldatasource"."created_by_id",+ "posthog_externaldatasource"."created_at",+ "posthog_externaldatasource"."updated_at",+ "posthog_externaldatasource"."deleted",+ "posthog_externaldatasource"."deleted_at",+ "posthog_externaldatasource"."id",+ "posthog_externaldatasource"."source_id",+ "posthog_externaldatasource"."connection_id",+ "posthog_externaldatasource"."destination_id",+ "posthog_externaldatasource"."team_id",+ "posthog_externaldatasource"."sync_frequency",+ "posthog_externaldatasource"."status",+ "posthog_externaldatasource"."source_type",+ "posthog_externaldatasource"."api_version",+ "posthog_externaldatasource"."job_inputs",+ "posthog_externaldatasource"."credentials_integration_id",+ "posthog_externaldatasource"."connection_metadata",+ "posthog_externaldatasource"."are_tables_created",+ "posthog_externaldatasource"."prefix",+ "posthog_externaldatasource"."description",+ "posthog_externaldatasource"."created_via",+ "posthog_externaldatasource"."access_method",+ "posthog_externaldatasource"."direct_query_enabled",+ "posthog_externaldatasource"."auto_sync_new_schemas",+ "posthog_externaldatasource"."auto_sync_schema_patterns",+ "posthog_externaldatasource"."revenue_analytics_enabled",+ "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",+ "posthog_externaldatasourcerevenueanalyticsconfig"."enabled",+ "posthog_externaldatasourcerevenueanalyticsconfig"."include_invoiceless_charges"+ FROM "posthog_externaldatasource"+ LEFT OUTER JOIN "posthog_externaldatasourcerevenueanalyticsconfig" ON ("posthog_externaldatasource"."id" = "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id")+ WHERE ("posthog_externaldatasource"."team_id" = 99999+ AND NOT ("posthog_externaldatasource"."deleted"+ AND "posthog_externaldatasource"."deleted" IS NOT NULL)+ AND "posthog_externaldatasource"."source_type" IN ('Stripe'))+ '''+# ---+# name: TestSessionRecordings.test_get_session_recordings_scenarios_0_basic_listing.11'''SELECT "posthog_datawarehousejoin"."created_by_id","posthog_datawarehousejoin"."created_at",@@ -924,7 +959,7 @@AND "posthog_datawarehousejoin"."deleted" IS NOT NULL))'''# ----# name: TestSessionRecordings.test_get_session_recordings_scenarios_0_basic_listing.11+# name: TestSessionRecordings.test_get_session_recordings_scenarios_0_basic_listing.12'''SELECT "data_tools_datawarehouseexpression"."deleted","data_tools_datawarehouseexpression"."deleted_at",@@ -943,7 +978,7 @@AND "data_tools_datawarehouseexpression"."connection_id" IS NULL)'''# ----# name: TestSessionRecordings.test_get_session_recordings_scenarios_0_basic_listing.12+# name: TestSessionRecordings.test_get_session_recordings_scenarios_0_basic_listing.13'''SELECT "posthog_datawarehousetable"."created_by_id","posthog_datawarehousetable"."created_at",@@ -976,7 +1011,7 @@ORDER BY "posthog_datawarehousetable"."created_at" DESC'''# ----# name: TestSessionRecordings.test_get_session_recordings_scenarios_0_basic_listing.13+# name: TestSessionRecordings.test_get_session_recordings_scenarios_0_basic_listing.14'''SELECT "posthog_sessionrecording"."id","posthog_sessionrecording"."session_id",@@ -1003,7 +1038,7 @@AND "posthog_sessionrecording"."team_id" = 99999)'''# ----# name: TestSessionRecordings.test_get_session_recordings_scenarios_0_basic_listing.14+# name: TestSessionRecordings.test_get_session_recordings_scenarios_0_basic_listing.15'''SELECT "posthog_sessionrecordingviewed"."session_id" AS "session_id"FROM "posthog_sessionrecordingviewed"@@ -1013,18 +1048,6 @@'session1'))'''# ----# name: TestSessionRecordings.test_get_session_recordings_scenarios_0_basic_listing.15- '''- SELECT "posthog_sessionrecordingviewed"."session_id" AS "session_id",- "posthog_user"."email" AS "user__email"- FROM "posthog_sessionrecordingviewed"- INNER JOIN "posthog_user" ON ("posthog_sessionrecordingviewed"."user_id" = "posthog_user"."id")- WHERE ("posthog_sessionrecordingviewed"."session_id" IN ('session2',- 'session1')- AND "posthog_sessionrecordingviewed"."team_id" = 99999- AND NOT ("posthog_sessionrecordingviewed"."user_id" = 99999))- '''-# ---# name: TestSessionRecordings.test_get_session_recordings_scenarios_0_basic_listing.16'''SELECT "posthog_sessionrecordingviewed"."session_id" AS "session_id",@@ -1233,6 +1256,15 @@'''# ---# name: TestSessionRecordings.test_get_session_recordings_scenarios_0_basic_listing.7+ '''+ SELECT "posthog_mcp_custom_harness"."name" AS "name",+ "posthog_mcp_custom_harness"."match_pattern" AS "match_pattern"+ FROM "posthog_mcp_custom_harness"+ WHERE "posthog_mcp_custom_harness"."team_id" = 99999+ ORDER BY LENGTH("posthog_mcp_custom_harness"."match_pattern") DESC, "posthog_mcp_custom_harness"."created_at" ASC+ '''+# ---+# name: TestSessionRecordings.test_get_session_recordings_scenarios_0_basic_listing.8'''SELECT "posthog_datawarehousesavedquery"."created_by_id","posthog_datawarehousesavedquery"."created_at",@@ -1297,7 +1329,7 @@ORDER BY "posthog_datawarehousesavedquery"."name" ASC'''# ----# name: TestSessionRecordings.test_get_session_recordings_scenarios_0_basic_listing.8+# name: TestSessionRecordings.test_get_session_recordings_scenarios_0_basic_listing.9'''SELECT "posthog_teamrevenueanalyticsconfig"."team_id","posthog_teamrevenueanalyticsconfig"."filter_test_accounts",@@ -1310,45 +1342,6 @@LIMIT 21'''# ----# name: TestSessionRecordings.test_get_session_recordings_scenarios_0_basic_listing.9- '''- SELECT "posthog_externaldatasource"."created_by_id",- "posthog_externaldatasource"."created_at",- "posthog_externaldatasource"."updated_at",- "posthog_externaldatasource"."deleted",- "posthog_externaldatasource"."deleted_at",- "posthog_externaldatasource"."id",- "posthog_externaldatasource"."source_id",- "posthog_externaldatasource"."connection_id",- "posthog_externaldatasource"."destination_id",- "posthog_externaldatasource"."team_id",- "posthog_externaldatasource"."sync_frequency",- "posthog_externaldatasource"."status",- "posthog_externaldatasource"."source_type",- "posthog_externaldatasource"."api_version",- "posthog_externaldatasource"."job_inputs",- "posthog_externaldatasource"."credentials_integration_id",- "posthog_externaldatasource"."connection_metadata",- "posthog_externaldatasource"."are_tables_created",- "posthog_externaldatasource"."prefix",- "posthog_externaldatasource"."description",- "posthog_externaldatasource"."created_via",- "posthog_externaldatasource"."access_method",- "posthog_externaldatasource"."direct_query_enabled",- "posthog_externaldatasource"."auto_sync_new_schemas",- "posthog_externaldatasource"."auto_sync_schema_patterns",- "posthog_externaldatasource"."revenue_analytics_enabled",- "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",- "posthog_externaldatasourcerevenueanalyticsconfig"."enabled",- "posthog_externaldatasourcerevenueanalyticsconfig"."include_invoiceless_charges"- FROM "posthog_externaldatasource"- LEFT OUTER JOIN "posthog_externaldatasourcerevenueanalyticsconfig" ON ("posthog_externaldatasource"."id" = "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id")- WHERE ("posthog_externaldatasource"."team_id" = 99999- AND NOT ("posthog_externaldatasource"."deleted"- AND "posthog_externaldatasource"."deleted" IS NOT NULL)- AND "posthog_externaldatasource"."source_type" IN ('Stripe'))- '''-# ---# name: TestSessionRecordings.test_get_session_recordings_scenarios_1_multiple_snapshots'''SELECT "posthog_user"."id",@@ -1574,6 +1567,45 @@'''# ---# name: TestSessionRecordings.test_get_session_recordings_scenarios_1_multiple_snapshots.10+ '''+ SELECT "posthog_externaldatasource"."created_by_id",+ "posthog_externaldatasource"."created_at",+ "posthog_externaldatasource"."updated_at",+ "posthog_externaldatasource"."deleted",+ "posthog_externaldatasource"."deleted_at",+ "posthog_externaldatasource"."id",+ "posthog_externaldatasource"."source_id",+ "posthog_externaldatasource"."connection_id",+ "posthog_externaldatasource"."destination_id",+ "posthog_externaldatasource"."team_id",+ "posthog_externaldatasource"."sync_frequency",+ "posthog_externaldatasource"."status",+ "posthog_externaldatasource"."source_type",+ "posthog_externaldatasource"."api_version",+ "posthog_externaldatasource"."job_inputs",+ "posthog_externaldatasource"."credentials_integration_id",+ "posthog_externaldatasource"."connection_metadata",+ "posthog_externaldatasource"."are_tables_created",+ "posthog_externaldatasource"."prefix",+ "posthog_externaldatasource"."description",+ "posthog_externaldatasource"."created_via",+ "posthog_externaldatasource"."access_method",+ "posthog_externaldatasource"."direct_query_enabled",+ "posthog_externaldatasource"."auto_sync_new_schemas",+ "posthog_externaldatasource"."auto_sync_schema_patterns",+ "posthog_externaldatasource"."revenue_analytics_enabled",+ "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",+ "posthog_externaldatasourcerevenueanalyticsconfig"."enabled",+ "posthog_externaldatasourcerevenueanalyticsconfig"."include_invoiceless_charges"+ FROM "posthog_externaldatasource"+ LEFT OUTER JOIN "posthog_externaldatasourcerevenueanalyticsconfig" ON ("posthog_externaldatasource"."id" = "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id")+ WHERE ("posthog_externaldatasource"."team_id" = 99999+ AND NOT ("posthog_externaldatasource"."deleted"+ AND "posthog_externaldatasource"."deleted" IS NOT NULL)+ AND "posthog_externaldatasource"."source_type" IN ('Stripe'))+ '''+# ---+# name: TestSessionRecordings.test_get_session_recordings_scenarios_1_multiple_snapshots.11'''SELECT "posthog_datawarehousejoin"."created_by_id","posthog_datawarehousejoin"."created_at",@@ -1593,7 +1625,7 @@AND "posthog_datawarehousejoin"."deleted" IS NOT NULL))'''# ----# name: TestSessionRecordings.test_get_session_recordings_scenarios_1_multiple_snapshots.11+# name: TestSessionRecordings.test_get_session_recordings_scenarios_1_multiple_snapshots.12'''SELECT "data_tools_datawarehouseexpression"."deleted","data_tools_datawarehouseexpression"."deleted_at",@@ -1612,7 +1644,7 @@AND "data_tools_datawarehouseexpression"."connection_id" IS NULL)'''# ----# name: TestSessionRecordings.test_get_session_recordings_scenarios_1_multiple_snapshots.12+# name: TestSessionRecordings.test_get_session_recordings_scenarios_1_multiple_snapshots.13'''SELECT "posthog_datawarehousetable"."created_by_id","posthog_datawarehousetable"."created_at",@@ -1645,7 +1677,7 @@ORDER BY "posthog_datawarehousetable"."created_at" DESC'''# ----# name: TestSessionRecordings.test_get_session_recordings_scenarios_1_multiple_snapshots.13+# name: TestSessionRecordings.test_get_session_recordings_scenarios_1_multiple_snapshots.14'''SELECT "posthog_sessionrecording"."id","posthog_sessionrecording"."session_id",@@ -1671,7 +1703,7 @@AND "posthog_sessionrecording"."team_id" = 99999)'''# ----# name: TestSessionRecordings.test_get_session_recordings_scenarios_1_multiple_snapshots.14+# name: TestSessionRecordings.test_get_session_recordings_scenarios_1_multiple_snapshots.15'''SELECT "posthog_sessionrecordingviewed"."session_id" AS "session_id"FROM "posthog_sessionrecordingviewed"@@ -1680,17 +1712,6 @@AND "posthog_sessionrecordingviewed"."session_id" IN ('session_with_duration'))'''# ----# name: TestSessionRecordings.test_get_session_recordings_scenarios_1_multiple_snapshots.15- '''- SELECT "posthog_sessionrecordingviewed"."session_id" AS "session_id",- "posthog_user"."email" AS "user__email"- FROM "posthog_sessionrecordingviewed"- INNER JOIN "posthog_user" ON ("posthog_sessionrecordingviewed"."user_id" = "posthog_user"."id")- WHERE ("posthog_sessionrecordingviewed"."session_id" IN ('session_with_duration')- AND "posthog_sessionrecordingviewed"."team_id" = 99999- AND NOT ("posthog_sessionrecordingviewed"."user_id" = 99999))- '''-# ---# name: TestSessionRecordings.test_get_session_recordings_scenarios_1_multiple_snapshots.16'''SELECT "posthog_sessionrecordingviewed"."session_id" AS "session_id",@@ -1898,6 +1919,15 @@'''# ---# name: TestSessionRecordings.test_get_session_recordings_scenarios_1_multiple_snapshots.7+ '''+ SELECT "posthog_mcp_custom_harness"."name" AS "name",+ "posthog_mcp_custom_harness"."match_pattern" AS "match_pattern"+ FROM "posthog_mcp_custom_harness"+ WHERE "posthog_mcp_custom_harness"."team_id" = 99999+ ORDER BY LENGTH("posthog_mcp_custom_harness"."match_pattern") DESC, "posthog_mcp_custom_harness"."created_at" ASC+ '''+# ---+# name: TestSessionRecordings.test_get_session_recordings_scenarios_1_multiple_snapshots.8'''SELECT "posthog_datawarehousesavedquery"."created_by_id","posthog_datawarehousesavedquery"."created_at",@@ -1962,7 +1992,7 @@ORDER BY "posthog_datawarehousesavedquery"."name" ASC'''# ----# name: TestSessionRecordings.test_get_session_recordings_scenarios_1_multiple_snapshots.8+# name: TestSessionRecordings.test_get_session_recordings_scenarios_1_multiple_snapshots.9'''SELECT "posthog_teamrevenueanalyticsconfig"."team_id","posthog_teamrevenueanalyticsconfig"."filter_test_accounts",@@ -1975,45 +2005,6 @@LIMIT 21'''# ----# name: TestSessionRecordings.test_get_session_recordings_scenarios_1_multiple_snapshots.9- '''- SELECT "posthog_externaldatasource"."created_by_id",- "posthog_externaldatasource"."created_at",- "posthog_externaldatasource"."updated_at",- "posthog_externaldatasource"."deleted",- "posthog_externaldatasource"."deleted_at",- "posthog_externaldatasource"."id",- "posthog_externaldatasource"."source_id",- "posthog_externaldatasource"."connection_id",- "posthog_externaldatasource"."destination_id",- "posthog_externaldatasource"."team_id",- "posthog_externaldatasource"."sync_frequency",- "posthog_externaldatasource"."status",- "posthog_externaldatasource"."source_type",- "posthog_externaldatasource"."api_version",- "posthog_externaldatasource"."job_inputs",- "posthog_externaldatasource"."credentials_integration_id",- "posthog_externaldatasource"."connection_metadata",- "posthog_externaldatasource"."are_tables_created",- "posthog_externaldatasource"."prefix",- "posthog_externaldatasource"."description",- "posthog_externaldatasource"."created_via",- "posthog_externaldatasource"."access_method",- "posthog_externaldatasource"."direct_query_enabled",- "posthog_externaldatasource"."auto_sync_new_schemas",- "posthog_externaldatasource"."auto_sync_schema_patterns",- "posthog_externaldatasource"."revenue_analytics_enabled",- "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",- "posthog_externaldatasourcerevenueanalyticsconfig"."enabled",- "posthog_externaldatasourcerevenueanalyticsconfig"."include_invoiceless_charges"- FROM "posthog_externaldatasource"- LEFT OUTER JOIN "posthog_externaldatasourcerevenueanalyticsconfig" ON ("posthog_externaldatasource"."id" = "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id")- WHERE ("posthog_externaldatasource"."team_id" = 99999- AND NOT ("posthog_externaldatasource"."deleted"- AND "posthog_externaldatasource"."deleted" IS NOT NULL)- AND "posthog_externaldatasource"."source_type" IN ('Stripe'))- '''-# ---# name: TestSessionRecordings.test_get_session_recordings_scenarios_2_many_distinct_ids'''SELECT "posthog_user"."id",@@ -2239,6 +2230,45 @@'''# ---# name: TestSessionRecordings.test_get_session_recordings_scenarios_2_many_distinct_ids.10+ '''+ SELECT "posthog_externaldatasource"."created_by_id",+ "posthog_externaldatasource"."created_at",+ "posthog_externaldatasource"."updated_at",+ "posthog_externaldatasource"."deleted",+ "posthog_externaldatasource"."deleted_at",+ "posthog_externaldatasource"."id",+ "posthog_externaldatasource"."source_id",+ "posthog_externaldatasource"."connection_id",+ "posthog_externaldatasource"."destination_id",+ "posthog_externaldatasource"."team_id",+ "posthog_externaldatasource"."sync_frequency",+ "posthog_externaldatasource"."status",+ "posthog_externaldatasource"."source_type",+ "posthog_externaldatasource"."api_version",+ "posthog_externaldatasource"."job_inputs",+ "posthog_externaldatasource"."credentials_integration_id",+ "posthog_externaldatasource"."connection_metadata",+ "posthog_externaldatasource"."are_tables_created",+ "posthog_externaldatasource"."prefix",+ "posthog_externaldatasource"."description",+ "posthog_externaldatasource"."created_via",+ "posthog_externaldatasource"."access_method",+ "posthog_externaldatasource"."direct_query_enabled",+ "posthog_externaldatasource"."auto_sync_new_schemas",+ "posthog_externaldatasource"."auto_sync_schema_patterns",+ "posthog_externaldatasource"."revenue_analytics_enabled",+ "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",+ "posthog_externaldatasourcerevenueanalyticsconfig"."enabled",+ "posthog_externaldatasourcerevenueanalyticsconfig"."include_invoiceless_charges"+ FROM "posthog_externaldatasource"+ LEFT OUTER JOIN "posthog_externaldatasourcerevenueanalyticsconfig" ON ("posthog_externaldatasource"."id" = "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id")+ WHERE ("posthog_externaldatasource"."team_id" = 99999+ AND NOT ("posthog_externaldatasource"."deleted"+ AND "posthog_externaldatasource"."deleted" IS NOT NULL)+ AND "posthog_externaldatasource"."source_type" IN ('Stripe'))+ '''+# ---+# name: TestSessionRecordings.test_get_session_recordings_scenarios_2_many_distinct_ids.11'''SELECT "posthog_datawarehousejoin"."created_by_id","posthog_datawarehousejoin"."created_at",@@ -2258,7 +2288,7 @@AND "posthog_datawarehousejoin"."deleted" IS NOT NULL))'''# ----# name: TestSessionRecordings.test_get_session_recordings_scenarios_2_many_distinct_ids.11+# name: TestSessionRecordings.test_get_session_recordings_scenarios_2_many_distinct_ids.12'''SELECT "data_tools_datawarehouseexpression"."deleted","data_tools_datawarehouseexpression"."deleted_at",@@ -2277,7 +2307,7 @@AND "data_tools_datawarehouseexpression"."connection_id" IS NULL)'''# ----# name: TestSessionRecordings.test_get_session_recordings_scenarios_2_many_distinct_ids.12+# name: TestSessionRecordings.test_get_session_recordings_scenarios_2_many_distinct_ids.13'''SELECT "posthog_datawarehousetable"."created_by_id","posthog_datawarehousetable"."created_at",@@ -2310,7 +2340,7 @@ORDER BY "posthog_datawarehousetable"."created_at" DESC'''# ----# name: TestSessionRecordings.test_get_session_recordings_scenarios_2_many_distinct_ids.13+# name: TestSessionRecordings.test_get_session_recordings_scenarios_2_many_distinct_ids.14'''SELECT "posthog_sessionrecording"."id","posthog_sessionrecording"."session_id",@@ -2336,7 +2366,7 @@AND "posthog_sessionrecording"."team_id" = 99999)'''# ----# name: TestSessionRecordings.test_get_session_recordings_scenarios_2_many_distinct_ids.14+# name: TestSessionRecordings.test_get_session_recordings_scenarios_2_many_distinct_ids.15'''SELECT "posthog_sessionrecordingviewed"."session_id" AS "session_id"FROM "posthog_sessionrecordingviewed"@@ -2345,17 +2375,6 @@AND "posthog_sessionrecordingviewed"."session_id" IN ('session_many_ids'))'''# ----# name: TestSessionRecordings.test_get_session_recordings_scenarios_2_many_distinct_ids.15- '''- SELECT "posthog_sessionrecordingviewed"."session_id" AS "session_id",- "posthog_user"."email" AS "user__email"- FROM "posthog_sessionrecordingviewed"- INNER JOIN "posthog_user" ON ("posthog_sessionrecordingviewed"."user_id" = "posthog_user"."id")- WHERE ("posthog_sessionrecordingviewed"."session_id" IN ('session_many_ids')- AND "posthog_sessionrecordingviewed"."team_id" = 99999- AND NOT ("posthog_sessionrecordingviewed"."user_id" = 99999))- '''-# ---# name: TestSessionRecordings.test_get_session_recordings_scenarios_2_many_distinct_ids.16'''SELECT "posthog_sessionrecordingviewed"."session_id" AS "session_id",@@ -2563,6 +2582,15 @@'''# ---# name: TestSessionRecordings.test_get_session_recordings_scenarios_2_many_distinct_ids.7+ '''+ SELECT "posthog_mcp_custom_harness"."name" AS "name",+ "posthog_mcp_custom_harness"."match_pattern" AS "match_pattern"+ FROM "posthog_mcp_custom_harness"+ WHERE "posthog_mcp_custom_harness"."team_id" = 99999+ ORDER BY LENGTH("posthog_mcp_custom_harness"."match_pattern") DESC, "posthog_mcp_custom_harness"."created_at" ASC+ '''+# ---+# name: TestSessionRecordings.test_get_session_recordings_scenarios_2_many_distinct_ids.8'''SELECT "posthog_datawarehousesavedquery"."created_by_id","posthog_datawarehousesavedquery"."created_at",@@ -2627,7 +2655,7 @@ORDER BY "posthog_datawarehousesavedquery"."name" ASC'''# ----# name: TestSessionRecordings.test_get_session_recordings_scenarios_2_many_distinct_ids.8+# name: TestSessionRecordings.test_get_session_recordings_scenarios_2_many_distinct_ids.9'''SELECT "posthog_teamrevenueanalyticsconfig"."team_id","posthog_teamrevenueanalyticsconfig"."filter_test_accounts",@@ -2640,45 +2668,6 @@LIMIT 21'''# ----# name: TestSessionRecordings.test_get_session_recordings_scenarios_2_many_distinct_ids.9- '''- SELECT "posthog_externaldatasource"."created_by_id",- "posthog_externaldatasource"."created_at",- "posthog_externaldatasource"."updated_at",- "posthog_externaldatasource"."deleted",- "posthog_externaldatasource"."deleted_at",- "posthog_externaldatasource"."id",- "posthog_externaldatasource"."source_id",- "posthog_externaldatasource"."connection_id",- "posthog_externaldatasource"."destination_id",- "posthog_externaldatasource"."team_id",- "posthog_externaldatasource"."sync_frequency",- "posthog_externaldatasource"."status",- "posthog_externaldatasource"."source_type",- "posthog_externaldatasource"."api_version",- "posthog_externaldatasource"."job_inputs",- "posthog_externaldatasource"."credentials_integration_id",- "posthog_externaldatasource"."connection_metadata",- "posthog_externaldatasource"."are_tables_created",- "posthog_externaldatasource"."prefix",- "posthog_externaldatasource"."description",- "posthog_externaldatasource"."created_via",- "posthog_externaldatasource"."access_method",- "posthog_externaldatasource"."direct_query_enabled",- "posthog_externaldatasource"."auto_sync_new_schemas",- "posthog_externaldatasource"."auto_sync_schema_patterns",- "posthog_externaldatasource"."revenue_analytics_enabled",- "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",- "posthog_externaldatasourcerevenueanalyticsconfig"."enabled",- "posthog_externaldatasourcerevenueanalyticsconfig"."include_invoiceless_charges"- FROM "posthog_externaldatasource"- LEFT OUTER JOIN "posthog_externaldatasourcerevenueanalyticsconfig" ON ("posthog_externaldatasource"."id" = "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id")- WHERE ("posthog_externaldatasource"."team_id" = 99999- AND NOT ("posthog_externaldatasource"."deleted"- AND "posthog_externaldatasource"."deleted" IS NOT NULL)- AND "posthog_externaldatasource"."source_type" IN ('Stripe'))- '''-# ---# name: TestSessionRecordings.test_get_session_recordings_sorted_0_descending_original_'''SELECT "posthog_user"."id",@@ -2904,6 +2893,45 @@'''# ---# name: TestSessionRecordings.test_get_session_recordings_sorted_0_descending_original_.10+ '''+ SELECT "posthog_externaldatasource"."created_by_id",+ "posthog_externaldatasource"."created_at",+ "posthog_externaldatasource"."updated_at",+ "posthog_externaldatasource"."deleted",+ "posthog_externaldatasource"."deleted_at",+ "posthog_externaldatasource"."id",+ "posthog_externaldatasource"."source_id",+ "posthog_externaldatasource"."connection_id",+ "posthog_externaldatasource"."destination_id",+ "posthog_externaldatasource"."team_id",+ "posthog_externaldatasource"."sync_frequency",+ "posthog_externaldatasource"."status",+ "posthog_externaldatasource"."source_type",+ "posthog_externaldatasource"."api_version",+ "posthog_externaldatasource"."job_inputs",+ "posthog_externaldatasource"."credentials_integration_id",+ "posthog_externaldatasource"."connection_metadata",+ "posthog_externaldatasource"."are_tables_created",+ "posthog_externaldatasource"."prefix",+ "posthog_externaldatasource"."description",+ "posthog_externaldatasource"."created_via",+ "posthog_externaldatasource"."access_method",+ "posthog_externaldatasource"."direct_query_enabled",+ "posthog_externaldatasource"."auto_sync_new_schemas",+ "posthog_externaldatasource"."auto_sync_schema_patterns",+ "posthog_externaldatasource"."revenue_analytics_enabled",+ "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",+ "posthog_externaldatasourcerevenueanalyticsconfig"."enabled",+ "posthog_externaldatasourcerevenueanalyticsconfig"."include_invoiceless_charges"+ FROM "posthog_externaldatasource"+ LEFT OUTER JOIN "posthog_externaldatasourcerevenueanalyticsconfig" ON ("posthog_externaldatasource"."id" = "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id")+ WHERE ("posthog_externaldatasource"."team_id" = 99999+ AND NOT ("posthog_externaldatasource"."deleted"+ AND "posthog_externaldatasource"."deleted" IS NOT NULL)+ AND "posthog_externaldatasource"."source_type" IN ('Stripe'))+ '''+# ---+# name: TestSessionRecordings.test_get_session_recordings_sorted_0_descending_original_.11'''SELECT "posthog_datawarehousejoin"."created_by_id","posthog_datawarehousejoin"."created_at",@@ -2923,7 +2951,7 @@AND "posthog_datawarehousejoin"."deleted" IS NOT NULL))'''# ----# name: TestSessionRecordings.test_get_session_recordings_sorted_0_descending_original_.11+# name: TestSessionRecordings.test_get_session_recordings_sorted_0_descending_original_.12'''SELECT "data_tools_datawarehouseexpression"."deleted","data_tools_datawarehouseexpression"."deleted_at",@@ -2942,7 +2970,7 @@AND "data_tools_datawarehouseexpression"."connection_id" IS NULL)'''# ----# name: TestSessionRecordings.test_get_session_recordings_sorted_0_descending_original_.12+# name: TestSessionRecordings.test_get_session_recordings_sorted_0_descending_original_.13'''SELECT "posthog_datawarehousetable"."created_by_id","posthog_datawarehousetable"."created_at",@@ -2975,7 +3003,7 @@ORDER BY "posthog_datawarehousetable"."created_at" DESC'''# ----# name: TestSessionRecordings.test_get_session_recordings_sorted_0_descending_original_.13+# name: TestSessionRecordings.test_get_session_recordings_sorted_0_descending_original_.14'''SELECT "posthog_sessionrecording"."id","posthog_sessionrecording"."session_id",@@ -3002,26 +3030,14 @@AND "posthog_sessionrecording"."team_id" = 99999)'''# ----# name: TestSessionRecordings.test_get_session_recordings_sorted_0_descending_original_.14+# name: TestSessionRecordings.test_get_session_recordings_sorted_0_descending_original_.15'''SELECT "posthog_sessionrecordingviewed"."session_id" AS "session_id"FROM "posthog_sessionrecordingviewed"WHERE ("posthog_sessionrecordingviewed"."team_id" = 99999- AND "posthog_sessionrecordingviewed"."user_id" = 99999- AND "posthog_sessionrecordingviewed"."session_id" IN ('at_base_time_plus_20',- 'at_base_time'))- '''-# ----# name: TestSessionRecordings.test_get_session_recordings_sorted_0_descending_original_.15- '''- SELECT "posthog_sessionrecordingviewed"."session_id" AS "session_id",- "posthog_user"."email" AS "user__email"- FROM "posthog_sessionrecordingviewed"- INNER JOIN "posthog_user" ON ("posthog_sessionrecordingviewed"."user_id" = "posthog_user"."id")- WHERE ("posthog_sessionrecordingviewed"."session_id" IN ('at_base_time_plus_20',- 'at_base_time')- AND "posthog_sessionrecordingviewed"."team_id" = 99999- AND NOT ("posthog_sessionrecordingviewed"."user_id" = 99999))+ AND "posthog_sessionrecordingviewed"."user_id" = 99999+ AND "posthog_sessionrecordingviewed"."session_id" IN ('at_base_time_plus_20',+ 'at_base_time'))'''# ---# name: TestSessionRecordings.test_get_session_recordings_sorted_0_descending_original_.16@@ -3232,6 +3248,15 @@'''# ---# name: TestSessionRecordings.test_get_session_recordings_sorted_0_descending_original_.7+ '''+ SELECT "posthog_mcp_custom_harness"."name" AS "name",+ "posthog_mcp_custom_harness"."match_pattern" AS "match_pattern"+ FROM "posthog_mcp_custom_harness"+ WHERE "posthog_mcp_custom_harness"."team_id" = 99999+ ORDER BY LENGTH("posthog_mcp_custom_harness"."match_pattern") DESC, "posthog_mcp_custom_harness"."created_at" ASC+ '''+# ---+# name: TestSessionRecordings.test_get_session_recordings_sorted_0_descending_original_.8'''SELECT "posthog_datawarehousesavedquery"."created_by_id","posthog_datawarehousesavedquery"."created_at",@@ -3296,7 +3321,7 @@ORDER BY "posthog_datawarehousesavedquery"."name" ASC'''# ----# name: TestSessionRecordings.test_get_session_recordings_sorted_0_descending_original_.8+# name: TestSessionRecordings.test_get_session_recordings_sorted_0_descending_original_.9'''SELECT "posthog_teamrevenueanalyticsconfig"."team_id","posthog_teamrevenueanalyticsconfig"."filter_test_accounts",@@ -3309,45 +3334,6 @@LIMIT 21'''# ----# name: TestSessionRecordings.test_get_session_recordings_sorted_0_descending_original_.9- '''- SELECT "posthog_externaldatasource"."created_by_id",- "posthog_externaldatasource"."created_at",- "posthog_externaldatasource"."updated_at",- "posthog_externaldatasource"."deleted",- "posthog_externaldatasource"."deleted_at",- "posthog_externaldatasource"."id",- "posthog_externaldatasource"."source_id",- "posthog_externaldatasource"."connection_id",- "posthog_externaldatasource"."destination_id",- "posthog_externaldatasource"."team_id",- "posthog_externaldatasource"."sync_frequency",- "posthog_externaldatasource"."status",- "posthog_externaldatasource"."source_type",- "posthog_externaldatasource"."api_version",- "posthog_externaldatasource"."job_inputs",- "posthog_externaldatasource"."credentials_integration_id",- "posthog_externaldatasource"."connection_metadata",- "posthog_externaldatasource"."are_tables_created",- "posthog_externaldatasource"."prefix",- "posthog_externaldatasource"."description",- "posthog_externaldatasource"."created_via",- "posthog_externaldatasource"."access_method",- "posthog_externaldatasource"."direct_query_enabled",- "posthog_externaldatasource"."auto_sync_new_schemas",- "posthog_externaldatasource"."auto_sync_schema_patterns",- "posthog_externaldatasource"."revenue_analytics_enabled",- "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",- "posthog_externaldatasourcerevenueanalyticsconfig"."enabled",- "posthog_externaldatasourcerevenueanalyticsconfig"."include_invoiceless_charges"- FROM "posthog_externaldatasource"- LEFT OUTER JOIN "posthog_externaldatasourcerevenueanalyticsconfig" ON ("posthog_externaldatasource"."id" = "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id")- WHERE ("posthog_externaldatasource"."team_id" = 99999- AND NOT ("posthog_externaldatasource"."deleted"- AND "posthog_externaldatasource"."deleted" IS NOT NULL)- AND "posthog_externaldatasource"."source_type" IN ('Stripe'))- '''-# ---# name: TestSessionRecordings.test_get_session_recordings_sorted_1_descending'''SELECT "posthog_user"."id",@@ -3573,6 +3559,45 @@'''# ---# name: TestSessionRecordings.test_get_session_recordings_sorted_1_descending.10+ '''+ SELECT "posthog_externaldatasource"."created_by_id",+ "posthog_externaldatasource"."created_at",+ "posthog_externaldatasource"."updated_at",+ "posthog_externaldatasource"."deleted",+ "posthog_externaldatasource"."deleted_at",+ "posthog_externaldatasource"."id",+ "posthog_externaldatasource"."source_id",+ "posthog_externaldatasource"."connection_id",+ "posthog_externaldatasource"."destination_id",+ "posthog_externaldatasource"."team_id",+ "posthog_externaldatasource"."sync_frequency",+ "posthog_externaldatasource"."status",+ "posthog_externaldatasource"."source_type",+ "posthog_externaldatasource"."api_version",+ "posthog_externaldatasource"."job_inputs",+ "posthog_externaldatasource"."credentials_integration_id",+ "posthog_externaldatasource"."connection_metadata",+ "posthog_externaldatasource"."are_tables_created",+ "posthog_externaldatasource"."prefix",+ "posthog_externaldatasource"."description",+ "posthog_externaldatasource"."created_via",+ "posthog_externaldatasource"."access_method",+ "posthog_externaldatasource"."direct_query_enabled",+ "posthog_externaldatasource"."auto_sync_new_schemas",+ "posthog_externaldatasource"."auto_sync_schema_patterns",+ "posthog_externaldatasource"."revenue_analytics_enabled",+ "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",+ "posthog_externaldatasourcerevenueanalyticsconfig"."enabled",+ "posthog_externaldatasourcerevenueanalyticsconfig"."include_invoiceless_charges"+ FROM "posthog_externaldatasource"+ LEFT OUTER JOIN "posthog_externaldatasourcerevenueanalyticsconfig" ON ("posthog_externaldatasource"."id" = "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id")+ WHERE ("posthog_externaldatasource"."team_id" = 99999+ AND NOT ("posthog_externaldatasource"."deleted"+ AND "posthog_externaldatasource"."deleted" IS NOT NULL)+ AND "posthog_externaldatasource"."source_type" IN ('Stripe'))+ '''+# ---+# name: TestSessionRecordings.test_get_session_recordings_sorted_1_descending.11'''SELECT "posthog_datawarehousejoin"."created_by_id","posthog_datawarehousejoin"."created_at",@@ -3592,7 +3617,7 @@AND "posthog_datawarehousejoin"."deleted" IS NOT NULL))'''# ----# name: TestSessionRecordings.test_get_session_recordings_sorted_1_descending.11+# name: TestSessionRecordings.test_get_session_recordings_sorted_1_descending.12'''SELECT "data_tools_datawarehouseexpression"."deleted","data_tools_datawarehouseexpression"."deleted_at",@@ -3611,7 +3636,7 @@AND "data_tools_datawarehouseexpression"."connection_id" IS NULL)'''# ----# name: TestSessionRecordings.test_get_session_recordings_sorted_1_descending.12+# name: TestSessionRecordings.test_get_session_recordings_sorted_1_descending.13'''SELECT "posthog_datawarehousetable"."created_by_id","posthog_datawarehousetable"."created_at",@@ -3644,7 +3669,7 @@ORDER BY "posthog_datawarehousetable"."created_at" DESC'''# ----# name: TestSessionRecordings.test_get_session_recordings_sorted_1_descending.13+# name: TestSessionRecordings.test_get_session_recordings_sorted_1_descending.14'''SELECT "posthog_sessionrecording"."id","posthog_sessionrecording"."session_id",@@ -3671,7 +3696,7 @@AND "posthog_sessionrecording"."team_id" = 99999)'''# ----# name: TestSessionRecordings.test_get_session_recordings_sorted_1_descending.14+# name: TestSessionRecordings.test_get_session_recordings_sorted_1_descending.15'''SELECT "posthog_sessionrecordingviewed"."session_id" AS "session_id"FROM "posthog_sessionrecordingviewed"@@ -3681,18 +3706,6 @@'at_base_time'))'''# ----# name: TestSessionRecordings.test_get_session_recordings_sorted_1_descending.15- '''- SELECT "posthog_sessionrecordingviewed"."session_id" AS "session_id",- "posthog_user"."email" AS "user__email"- FROM "posthog_sessionrecordingviewed"- INNER JOIN "posthog_user" ON ("posthog_sessionrecordingviewed"."user_id" = "posthog_user"."id")- WHERE ("posthog_sessionrecordingviewed"."session_id" IN ('at_base_time_plus_20',- 'at_base_time')- AND "posthog_sessionrecordingviewed"."team_id" = 99999- AND NOT ("posthog_sessionrecordingviewed"."user_id" = 99999))- '''-# ---# name: TestSessionRecordings.test_get_session_recordings_sorted_1_descending.16'''SELECT "posthog_sessionrecordingviewed"."session_id" AS "session_id",@@ -3901,6 +3914,15 @@'''# ---# name: TestSessionRecordings.test_get_session_recordings_sorted_1_descending.7+ '''+ SELECT "posthog_mcp_custom_harness"."name" AS "name",+ "posthog_mcp_custom_harness"."match_pattern" AS "match_pattern"+ FROM "posthog_mcp_custom_harness"+ WHERE "posthog_mcp_custom_harness"."team_id" = 99999+ ORDER BY LENGTH("posthog_mcp_custom_harness"."match_pattern") DESC, "posthog_mcp_custom_harness"."created_at" ASC+ '''+# ---+# name: TestSessionRecordings.test_get_session_recordings_sorted_1_descending.8'''SELECT "posthog_datawarehousesavedquery"."created_by_id","posthog_datawarehousesavedquery"."created_at",@@ -3965,7 +3987,7 @@ORDER BY "posthog_datawarehousesavedquery"."name" ASC'''# ----# name: TestSessionRecordings.test_get_session_recordings_sorted_1_descending.8+# name: TestSessionRecordings.test_get_session_recordings_sorted_1_descending.9'''SELECT "posthog_teamrevenueanalyticsconfig"."team_id","posthog_teamrevenueanalyticsconfig"."filter_test_accounts",@@ -3978,45 +4000,6 @@LIMIT 21'''# ----# name: TestSessionRecordings.test_get_session_recordings_sorted_1_descending.9- '''- SELECT "posthog_externaldatasource"."created_by_id",- "posthog_externaldatasource"."created_at",- "posthog_externaldatasource"."updated_at",- "posthog_externaldatasource"."deleted",- "posthog_externaldatasource"."deleted_at",- "posthog_externaldatasource"."id",- "posthog_externaldatasource"."source_id",- "posthog_externaldatasource"."connection_id",- "posthog_externaldatasource"."destination_id",- "posthog_externaldatasource"."team_id",- "posthog_externaldatasource"."sync_frequency",- "posthog_externaldatasource"."status",- "posthog_externaldatasource"."source_type",- "posthog_externaldatasource"."api_version",- "posthog_externaldatasource"."job_inputs",- "posthog_externaldatasource"."credentials_integration_id",- "posthog_externaldatasource"."connection_metadata",- "posthog_externaldatasource"."are_tables_created",- "posthog_externaldatasource"."prefix",- "posthog_externaldatasource"."description",- "posthog_externaldatasource"."created_via",- "posthog_externaldatasource"."access_method",- "posthog_externaldatasource"."direct_query_enabled",- "posthog_externaldatasource"."auto_sync_new_schemas",- "posthog_externaldatasource"."auto_sync_schema_patterns",- "posthog_externaldatasource"."revenue_analytics_enabled",- "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",- "posthog_externaldatasourcerevenueanalyticsconfig"."enabled",- "posthog_externaldatasourcerevenueanalyticsconfig"."include_invoiceless_charges"- FROM "posthog_externaldatasource"- LEFT OUTER JOIN "posthog_externaldatasourcerevenueanalyticsconfig" ON ("posthog_externaldatasource"."id" = "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id")- WHERE ("posthog_externaldatasource"."team_id" = 99999- AND NOT ("posthog_externaldatasource"."deleted"- AND "posthog_externaldatasource"."deleted" IS NOT NULL)- AND "posthog_externaldatasource"."source_type" IN ('Stripe'))- '''-# ---# name: TestSessionRecordings.test_get_session_recordings_sorted_2_ascending'''SELECT "posthog_user"."id",@@ -4242,6 +4225,45 @@'''# ---# name: TestSessionRecordings.test_get_session_recordings_sorted_2_ascending.10+ '''+ SELECT "posthog_externaldatasource"."created_by_id",+ "posthog_externaldatasource"."created_at",+ "posthog_externaldatasource"."updated_at",+ "posthog_externaldatasource"."deleted",+ "posthog_externaldatasource"."deleted_at",+ "posthog_externaldatasource"."id",+ "posthog_externaldatasource"."source_id",+ "posthog_externaldatasource"."connection_id",+ "posthog_externaldatasource"."destination_id",+ "posthog_externaldatasource"."team_id",+ "posthog_externaldatasource"."sync_frequency",+ "posthog_externaldatasource"."status",+ "posthog_externaldatasource"."source_type",+ "posthog_externaldatasource"."api_version",+ "posthog_externaldatasource"."job_inputs",+ "posthog_externaldatasource"."credentials_integration_id",+ "posthog_externaldatasource"."connection_metadata",+ "posthog_externaldatasource"."are_tables_created",+ "posthog_externaldatasource"."prefix",+ "posthog_externaldatasource"."description",+ "posthog_externaldatasource"."created_via",+ "posthog_externaldatasource"."access_method",+ "posthog_externaldatasource"."direct_query_enabled",+ "posthog_externaldatasource"."auto_sync_new_schemas",+ "posthog_externaldatasource"."auto_sync_schema_patterns",+ "posthog_externaldatasource"."revenue_analytics_enabled",+ "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",+ "posthog_externaldatasourcerevenueanalyticsconfig"."enabled",+ "posthog_externaldatasourcerevenueanalyticsconfig"."include_invoiceless_charges"+ FROM "posthog_externaldatasource"+ LEFT OUTER JOIN "posthog_externaldatasourcerevenueanalyticsconfig" ON ("posthog_externaldatasource"."id" = "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id")+ WHERE ("posthog_externaldatasource"."team_id" = 99999+ AND NOT ("posthog_externaldatasource"."deleted"+ AND "posthog_externaldatasource"."deleted" IS NOT NULL)+ AND "posthog_externaldatasource"."source_type" IN ('Stripe'))+ '''+# ---+# name: TestSessionRecordings.test_get_session_recordings_sorted_2_ascending.11'''SELECT "posthog_datawarehousejoin"."created_by_id","posthog_datawarehousejoin"."created_at",@@ -4261,7 +4283,7 @@AND "posthog_datawarehousejoin"."deleted" IS NOT NULL))'''# ----# name: TestSessionRecordings.test_get_session_recordings_sorted_2_ascending.11+# name: TestSessionRecordings.test_get_session_recordings_sorted_2_ascending.12'''SELECT "data_tools_datawarehouseexpression"."deleted","data_tools_datawarehouseexpression"."deleted_at",@@ -4280,7 +4302,7 @@AND "data_tools_datawarehouseexpression"."connection_id" IS NULL)'''# ----# name: TestSessionRecordings.test_get_session_recordings_sorted_2_ascending.12+# name: TestSessionRecordings.test_get_session_recordings_sorted_2_ascending.13'''SELECT "posthog_datawarehousetable"."created_by_id","posthog_datawarehousetable"."created_at",@@ -4313,7 +4335,7 @@ORDER BY "posthog_datawarehousetable"."created_at" DESC'''# ----# name: TestSessionRecordings.test_get_session_recordings_sorted_2_ascending.13+# name: TestSessionRecordings.test_get_session_recordings_sorted_2_ascending.14'''SELECT "posthog_sessionrecording"."id","posthog_sessionrecording"."session_id",@@ -4340,7 +4362,7 @@AND "posthog_sessionrecording"."team_id" = 99999)'''# ----# name: TestSessionRecordings.test_get_session_recordings_sorted_2_ascending.14+# name: TestSessionRecordings.test_get_session_recordings_sorted_2_ascending.15'''SELECT "posthog_sessionrecordingviewed"."session_id" AS "session_id"FROM "posthog_sessionrecordingviewed"@@ -4350,18 +4372,6 @@'at_base_time_plus_20'))'''# ----# name: TestSessionRecordings.test_get_session_recordings_sorted_2_ascending.15- '''- SELECT "posthog_sessionrecordingviewed"."session_id" AS "session_id",- "posthog_user"."email" AS "user__email"- FROM "posthog_sessionrecordingviewed"- INNER JOIN "posthog_user" ON ("posthog_sessionrecordingviewed"."user_id" = "posthog_user"."id")- WHERE ("posthog_sessionrecordingviewed"."session_id" IN ('at_base_time',- 'at_base_time_plus_20')- AND "posthog_sessionrecordingviewed"."team_id" = 99999- AND NOT ("posthog_sessionrecordingviewed"."user_id" = 99999))- '''-# ---# name: TestSessionRecordings.test_get_session_recordings_sorted_2_ascending.16'''SELECT "posthog_sessionrecordingviewed"."session_id" AS "session_id",@@ -4570,6 +4580,15 @@'''# ---# name: TestSessionRecordings.test_get_session_recordings_sorted_2_ascending.7+ '''+ SELECT "posthog_mcp_custom_harness"."name" AS "name",+ "posthog_mcp_custom_harness"."match_pattern" AS "match_pattern"+ FROM "posthog_mcp_custom_harness"+ WHERE "posthog_mcp_custom_harness"."team_id" = 99999+ ORDER BY LENGTH("posthog_mcp_custom_harness"."match_pattern") DESC, "posthog_mcp_custom_harness"."created_at" ASC+ '''+# ---+# name: TestSessionRecordings.test_get_session_recordings_sorted_2_ascending.8'''SELECT "posthog_datawarehousesavedquery"."created_by_id","posthog_datawarehousesavedquery"."created_at",@@ -4634,7 +4653,7 @@ORDER BY "posthog_datawarehousesavedquery"."name" ASC'''# ----# name: TestSessionRecordings.test_get_session_recordings_sorted_2_ascending.8+# name: TestSessionRecordings.test_get_session_recordings_sorted_2_ascending.9'''SELECT "posthog_teamrevenueanalyticsconfig"."team_id","posthog_teamrevenueanalyticsconfig"."filter_test_accounts",@@ -4647,45 +4666,6 @@LIMIT 21'''# ----# name: TestSessionRecordings.test_get_session_recordings_sorted_2_ascending.9- '''- SELECT "posthog_externaldatasource"."created_by_id",- "posthog_externaldatasource"."created_at",- "posthog_externaldatasource"."updated_at",- "posthog_externaldatasource"."deleted",- "posthog_externaldatasource"."deleted_at",- "posthog_externaldatasource"."id",- "posthog_externaldatasource"."source_id",- "posthog_externaldatasource"."connection_id",- "posthog_externaldatasource"."destination_id",- "posthog_externaldatasource"."team_id",- "posthog_externaldatasource"."sync_frequency",- "posthog_externaldatasource"."status",- "posthog_externaldatasource"."source_type",- "posthog_externaldatasource"."api_version",- "posthog_externaldatasource"."job_inputs",- "posthog_externaldatasource"."credentials_integration_id",- "posthog_externaldatasource"."connection_metadata",- "posthog_externaldatasource"."are_tables_created",- "posthog_externaldatasource"."prefix",- "posthog_externaldatasource"."description",- "posthog_externaldatasource"."created_via",- "posthog_externaldatasource"."access_method",- "posthog_externaldatasource"."direct_query_enabled",- "posthog_externaldatasource"."auto_sync_new_schemas",- "posthog_externaldatasource"."auto_sync_schema_patterns",- "posthog_externaldatasource"."revenue_analytics_enabled",- "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id",- "posthog_externaldatasourcerevenueanalyticsconfig"."enabled",- "posthog_externaldatasourcerevenueanalyticsconfig"."include_invoiceless_charges"- FROM "posthog_externaldatasource"- LEFT OUTER JOIN "posthog_externaldatasourcerevenueanalyticsconfig" ON ("posthog_externaldatasource"."id" = "posthog_externaldatasourcerevenueanalyticsconfig"."external_data_source_id")- WHERE ("posthog_externaldatasource"."team_id" = 99999- AND NOT ("posthog_externaldatasource"."deleted"- AND "posthog_externaldatasource"."deleted" IS NOT NULL)- AND "posthog_externaldatasource"."source_type" IN ('Stripe'))- '''-# ---# name: TestSessionRecordings.test_listing_recordings_is_not_nplus1_for_persons'''SELECT "posthog_user"."id",diff --git a/products/data_warehouse/backend/tests/api/test_view_link.py b/products/data_warehouse/backend/tests/api/test_view_link.pyindex e2c522e0e257..aa27f934b871 100644--- a/products/data_warehouse/backend/tests/api/test_view_link.py+++ b/products/data_warehouse/backend/tests/api/test_view_link.py@@ -364,7 +364,8 @@ class TestViewLinkQuery(APIBaseTest):# Test that listing joins uses efficient querying- with self.assertNumQueries(FuzzyInt(20, 21)): # depends when the instance-setting caches are hit in a test+ # +1 for the MCP custom harness fetch in the HogQL database build, which later requests read from Redis.+ with self.assertNumQueries(FuzzyInt(21, 22)): # depends when the instance-setting caches are hit in a testresponse = self.client.get(f"/api/environments/{self.team.id}/warehouse_view_links/")self.assertEqual(response.status_code, 200)diff --git a/products/mcp_analytics/backend/tests/test_harness_breakdown.py b/products/mcp_analytics/backend/tests/test_harness_breakdown.pyindex bf9660a1c25e..45911c3d677e 100644--- a/products/mcp_analytics/backend/tests/test_harness_breakdown.py+++ b/products/mcp_analytics/backend/tests/test_harness_breakdown.py@@ -139,7 +139,7 @@ class TestMCPHarnessBreakdownQueryRunner(_MCPAnalyticsTeamScopedTestMixin, Clickself.assertEqual(response.column_formats, ["mcp_harness", None])self.assertEqual(response.results, [("OpenAI Codex", 2), ("Claude Code", 1)])- def test_custom_harness_names_calls_in_the_breakdown(self) -> None:+ def test_custom_harness_names_calls_everywhere_the_label_shows(self) -> None:MCPCustomHarness.objects.create(team=self.team, name="Acme Agent", match_pattern="acme-agent")MCPCustomHarness.objects.create(team=self.team, name="Our Cursor", match_pattern="cursor-internal")self._emit(properties={"$mcp_client_name": "Acme-Agent/1.2"})@@ -148,6 +148,13 @@ class TestMCPHarnessBreakdownQueryRunner(_MCPAnalyticsTeamScopedTestMixin, Clickself._emit(properties={"$mcp_client_name": "something-else"}, distinct_id="d4")flush_persons_and_events()+ virtual = execute_hogql_query(+ "SELECT properties.$virt_mcp_harness AS client, count() AS calls "+ "FROM events WHERE event = '$mcp_tool_call' GROUP BY client ORDER BY calls DESC, client",+ team=self.team,+ )++ self.assertEqual(virtual.results, [("Acme Agent", 2), ("Other", 1), ("Our Cursor", 1)])self.assertEqual(set(self._breakdown()), {"Acme Agent", "Other", "Our Cursor"})def test_virtual_harness_property_is_empty_on_other_events(self) -> None:diff --git a/products/posthog_ai/skills/querying-posthog-data/references/models-mcp.md b/products/posthog_ai/skills/querying-posthog-data/references/models-mcp.mdindex 7ebc271e6c8f..4fd9653a7f8f 100644--- a/products/posthog_ai/skills/querying-posthog-data/references/models-mcp.md+++ b/products/posthog_ai/skills/querying-posthog-data/references/models-mcp.md@@ -156,6 +156,8 @@ A "harness" is the friendly product label for the MCP client that made a call**Prefer the typed tool.** For "which harnesses use our MCP, and how reliably?", call the `posthog:query-mcp-harness-breakdown` tool. It returns calls / errors / error-rate / sessions per harness and accepts the same `dateRange` / `properties` / `filterTestAccounts` filters as the dashboard, so results match the UI exactly — no hand-written bucketing needed. It also accepts an optional `toolName` to scope the breakdown to one effective tool — but note that scoping **also restricts the result to new-SDK events** (`$mcp_source = 'posthog_mcp_analytics'`), so old-SDK and third-party calls for that tool are excluded and a harness can be undercounted. For a one-tool harness cut across all SDK sources, use `execute-sql`. Anything the typed tools don't express drops to `execute-sql` below.+**For custom cuts in `execute-sql`, select `properties.$virt_mcp_harness`.** It returns the same label as the dashboard, as a string on `$mcp_*` events and `NULL` on other events. It also applies the custom harness names a team sets in Settings > MCP analytics. The hand-written SQL below does not know those names, so use it only when you need the token or the bucketing steps themselves.+**Use `execute-sql` for custom cuts** the typed tool doesn't cover (share-of-users, latency percentiles, per-tool, a trends breakdown). Resolution is two steps: resolve a normalized token from the strongest signal available, then bucket it. An event carries only raw signals, over exactly three properties — the `x-anthropic-client` header (`$mcp_vendor_client`, with the legacy `mcp_vendor_client` coalesced for historical rows) is the only thing separating Anthropic's pooled surfaces (Cowork / Claude.ai / Claude Design); Claude Code's build (cli / sdk / vscode / desktop) rides in the User-Agent (`$mcp_client_user_agent`, also the generic last fallback); and `clientInfo.name` arrives as `$mcp_client_name`. The SQL below mirrors `harness_label_sql` / `HARNESS_TOKEN_SQL` in `mcp_harness.py`; keep them in step until a materialized `$mcp_harness` property exists. (HogQL has no `WITH <expr> AS alias`, so the normalized name `h` is computed in a subquery, not a CTE.)**Share of users by harness** (answers "what % of my users are on Claude Code"):