: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(dashboards): enforce NOT NULL team_id and expose via HogQL (3/3) (#60013)
Thomas Obermüller832f6e1c8e0a
diff --git a/posthog/hogql/database/schema/system.py b/posthog/hogql/database/schema/system.pyindex e4f479172ce9..8c770e822b4b 100644--- a/posthog/hogql/database/schema/system.py+++ b/posthog/hogql/database/schema/system.py@@ -192,6 +192,30 @@ dashboards: PostgresTable = PostgresTable(},)+dashboard_tiles: PostgresTable = PostgresTable(+ name="dashboard_tiles",+ postgres_table_name="posthog_dashboardtile",+ access_scope="dashboard",+ fields={+ "id": IntegerDatabaseField(name="id"),+ "team_id": IntegerDatabaseField(name="team_id"),+ "dashboard_id": IntegerDatabaseField(name="dashboard_id"),+ "insight_id": IntegerDatabaseField(name="insight_id", nullable=True),+ "text_id": IntegerDatabaseField(name="text_id", nullable=True),+ "button_tile_id": StringDatabaseField(name="button_tile_id", nullable=True),+ "layouts": StringJSONDatabaseField(name="layouts"),+ "color": StringDatabaseField(name="color", nullable=True),+ "show_description": BooleanDatabaseField(name="show_description", nullable=True),+ "transparent_background": BooleanDatabaseField(name="transparent_background", nullable=True),+ "filters_overrides": StringJSONDatabaseField(name="filters_overrides", nullable=True),+ "_deleted": BooleanDatabaseField(name="deleted", hidden=True, nullable=True),+ "deleted": ExpressionField(+ name="deleted",+ expr=ast.Call(name="ifNull", args=[ast.Field(chain=["_deleted"]), ast.Constant(value=False)]),+ ),+ },+)+insights: PostgresTable = PostgresTable(name="insights",postgres_table_name="posthog_dashboarditem",@@ -1131,6 +1155,7 @@ class SystemTables(TableNode):"cohort_calculation_history": TableNode(name="cohort_calculation_history", table=cohort_calculation_history),"cohorts": TableNode(name="cohorts", table=cohorts),"dashboards": TableNode(name="dashboards", table=dashboards),+ "dashboard_tiles": TableNode(name="dashboard_tiles", table=dashboard_tiles),"data_modeling_jobs": TableNode(name="data_modeling_jobs", table=data_modeling_jobs),"data_modeling_views": TableNode(name="data_modeling_views", table=data_modeling_views),"data_modeling_endpoint_versions": TableNode(name="data_modeling_endpoint_versions", table=endpoint_versions),diff --git a/posthog/hogql/database/schema/test/test_system_tables.py b/posthog/hogql/database/schema/test/test_system_tables.pyindex ff2ce9d5431d..e98e6c70efba 100644--- a/posthog/hogql/database/schema/test/test_system_tables.py+++ b/posthog/hogql/database/schema/test/test_system_tables.py@@ -34,6 +34,7 @@ from products.alerts.backend.models.alert import AlertConfigurationfrom products.conversations.backend.models import Ticketfrom products.customer_analytics.backend.models.account import Accountfrom products.dashboards.backend.models.dashboard import Dashboard+from products.dashboards.backend.models.dashboard_tile import DashboardTilefrom products.data_modeling.backend.models.data_modeling_job import DataModelingJobfrom products.data_modeling.backend.models.datawarehouse_saved_query import DataWarehouseSavedQueryfrom products.early_access_features.backend.models import EarlyAccessFeature@@ -153,6 +154,12 @@ def _create_dashboard(team: Team, label: str) -> Dashboard:return Dashboard.objects.create(team=team, name=f"dashboard_{label}")+def _create_dashboard_tile(team: Team, label: str) -> DashboardTile:+ dashboard = Dashboard.objects.create(team=team, name=f"dashboard_for_tile_{label}")+ insight = Insight.objects.create(team=team, short_id=f"tile_{label}"[:12], name=f"insight_{label}")+ return DashboardTile.objects.create(dashboard=dashboard, insight=insight)++def _create_data_modeling_job(team: Team, label: str) -> DataModelingJob:saved_query = DataWarehouseSavedQuery.objects.create(team=team, name=f"query_{label}", query={"kind": "HogQLQuery", "query": "SELECT 1"}@@ -526,6 +533,7 @@ SYSTEM_TABLE_FACTORIES = [("cohorts", _create_cohort),("cohort_calculation_history", _create_cohort_calculation_history),("dashboards", _create_dashboard),+ ("dashboard_tiles", _create_dashboard_tile),("data_modeling_jobs", _create_data_modeling_job),("data_modeling_views", _create_data_warehouse_saved_query),("data_warehouse_sources", _create_data_warehouse_source),diff --git a/posthog/hogql/database/test/__snapshots__/test_database.ambr b/posthog/hogql/database/test/__snapshots__/test_database.ambrindex ca1da6e5e62f..12be53758e69 100644--- a/posthog/hogql/database/test/__snapshots__/test_database.ambr+++ b/posthog/hogql/database/test/__snapshots__/test_database.ambr@@ -3407,6 +3407,124 @@"row_count": null,"type": "system"},+ "system.dashboard_tiles": {+ "fields": {+ "id": {+ "chain": null,+ "fields": null,+ "hogql_value": "id",+ "id": null,+ "name": "id",+ "schema_valid": true,+ "table": null,+ "type": "integer"+ },+ "dashboard_id": {+ "chain": null,+ "fields": null,+ "hogql_value": "dashboard_id",+ "id": null,+ "name": "dashboard_id",+ "schema_valid": true,+ "table": null,+ "type": "integer"+ },+ "insight_id": {+ "chain": null,+ "fields": null,+ "hogql_value": "insight_id",+ "id": null,+ "name": "insight_id",+ "schema_valid": true,+ "table": null,+ "type": "integer"+ },+ "text_id": {+ "chain": null,+ "fields": null,+ "hogql_value": "text_id",+ "id": null,+ "name": "text_id",+ "schema_valid": true,+ "table": null,+ "type": "integer"+ },+ "button_tile_id": {+ "chain": null,+ "fields": null,+ "hogql_value": "button_tile_id",+ "id": null,+ "name": "button_tile_id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "layouts": {+ "chain": null,+ "fields": null,+ "hogql_value": "layouts",+ "id": null,+ "name": "layouts",+ "schema_valid": true,+ "table": null,+ "type": "json"+ },+ "color": {+ "chain": null,+ "fields": null,+ "hogql_value": "color",+ "id": null,+ "name": "color",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "show_description": {+ "chain": null,+ "fields": null,+ "hogql_value": "show_description",+ "id": null,+ "name": "show_description",+ "schema_valid": true,+ "table": null,+ "type": "boolean"+ },+ "transparent_background": {+ "chain": null,+ "fields": null,+ "hogql_value": "transparent_background",+ "id": null,+ "name": "transparent_background",+ "schema_valid": true,+ "table": null,+ "type": "boolean"+ },+ "filters_overrides": {+ "chain": null,+ "fields": null,+ "hogql_value": "filters_overrides",+ "id": null,+ "name": "filters_overrides",+ "schema_valid": true,+ "table": null,+ "type": "json"+ },+ "deleted": {+ "chain": null,+ "fields": null,+ "hogql_value": "deleted",+ "id": null,+ "name": "deleted",+ "schema_valid": true,+ "table": null,+ "type": "expression"+ }+ },+ "id": "system.dashboard_tiles",+ "name": "system.dashboard_tiles",+ "row_count": null,+ "type": "system"+ },"system.data_modeling_jobs": {"fields": {"id": {@@ -10798,6 +10916,124 @@"row_count": null,"type": "system"},+ "system.dashboard_tiles": {+ "fields": {+ "id": {+ "chain": null,+ "fields": null,+ "hogql_value": "id",+ "id": null,+ "name": "id",+ "schema_valid": true,+ "table": null,+ "type": "integer"+ },+ "dashboard_id": {+ "chain": null,+ "fields": null,+ "hogql_value": "dashboard_id",+ "id": null,+ "name": "dashboard_id",+ "schema_valid": true,+ "table": null,+ "type": "integer"+ },+ "insight_id": {+ "chain": null,+ "fields": null,+ "hogql_value": "insight_id",+ "id": null,+ "name": "insight_id",+ "schema_valid": true,+ "table": null,+ "type": "integer"+ },+ "text_id": {+ "chain": null,+ "fields": null,+ "hogql_value": "text_id",+ "id": null,+ "name": "text_id",+ "schema_valid": true,+ "table": null,+ "type": "integer"+ },+ "button_tile_id": {+ "chain": null,+ "fields": null,+ "hogql_value": "button_tile_id",+ "id": null,+ "name": "button_tile_id",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "layouts": {+ "chain": null,+ "fields": null,+ "hogql_value": "layouts",+ "id": null,+ "name": "layouts",+ "schema_valid": true,+ "table": null,+ "type": "json"+ },+ "color": {+ "chain": null,+ "fields": null,+ "hogql_value": "color",+ "id": null,+ "name": "color",+ "schema_valid": true,+ "table": null,+ "type": "string"+ },+ "show_description": {+ "chain": null,+ "fields": null,+ "hogql_value": "show_description",+ "id": null,+ "name": "show_description",+ "schema_valid": true,+ "table": null,+ "type": "boolean"+ },+ "transparent_background": {+ "chain": null,+ "fields": null,+ "hogql_value": "transparent_background",+ "id": null,+ "name": "transparent_background",+ "schema_valid": true,+ "table": null,+ "type": "boolean"+ },+ "filters_overrides": {+ "chain": null,+ "fields": null,+ "hogql_value": "filters_overrides",+ "id": null,+ "name": "filters_overrides",+ "schema_valid": true,+ "table": null,+ "type": "json"+ },+ "deleted": {+ "chain": null,+ "fields": null,+ "hogql_value": "deleted",+ "id": null,+ "name": "deleted",+ "schema_valid": true,+ "table": null,+ "type": "expression"+ }+ },+ "id": "system.dashboard_tiles",+ "name": "system.dashboard_tiles",+ "row_count": null,+ "type": "system"+ },"system.data_modeling_jobs": {"fields": {"id": {diff --git a/products/dashboards/backend/management/commands/backfill_dashboardtile_team_id.py b/products/dashboards/backend/management/commands/backfill_dashboardtile_team_id.pydeleted file mode 100644index 9c7a2093dbeb..000000000000--- a/products/dashboards/backend/management/commands/backfill_dashboardtile_team_id.py+++ /dev/null@@ -1,47 +0,0 @@-import time-from typing import Any--from django.core.management.base import BaseCommand-from django.db import connection, transaction--BATCH_SIZE = 5000-SLEEP_INTERVAL_SECONDS = 0.1--UPDATE_BATCH_SQL = """-UPDATE posthog_dashboardtile AS t-SET team_id = d.team_id-FROM posthog_dashboard AS d-WHERE t.dashboard_id = d.id- AND t.team_id IS NULL- AND t.id IN (- SELECT id- FROM posthog_dashboardtile- WHERE team_id IS NULL- ORDER BY id- LIMIT %s- )-"""---class Command(BaseCommand):- help = "Backfill DashboardTile.team_id from the parent dashboard's team_id."-- def handle(self, *args: Any, **options: Any) -> None:- total_updated = 0- batch_index = 0-- while True:- with transaction.atomic():- with connection.cursor() as cursor:- cursor.execute(UPDATE_BATCH_SQL, [BATCH_SIZE])- updated = cursor.rowcount-- if updated == 0:- break-- total_updated += updated- batch_index += 1- self.stdout.write(f"Batch {batch_index}: updated {updated} tile(s) (running total: {total_updated}).")- time.sleep(SLEEP_INTERVAL_SECONDS)-- self.stdout.write(self.style.SUCCESS(f"Done. Updated {total_updated} tile(s) in {batch_index} batch(es)."))diff --git a/products/dashboards/backend/management/commands/test/test_backfill_dashboardtile_team_id.py b/products/dashboards/backend/management/commands/test/test_backfill_dashboardtile_team_id.pydeleted file mode 100644index 46357e0021d0..000000000000--- a/products/dashboards/backend/management/commands/test/test_backfill_dashboardtile_team_id.py+++ /dev/null@@ -1,73 +0,0 @@-from io import StringIO--from posthog.test.base import BaseTest--from django.core.management import call_command-from django.db import connection--from posthog.models.organization import Organization-from posthog.models.team.team import Team--from products.dashboards.backend.models.dashboard import Dashboard-from products.dashboards.backend.models.dashboard_tile import DashboardTile, Text---def _null_out_team_ids(tile_ids: list[int]) -> None:- with connection.cursor() as cursor:- cursor.execute(- "UPDATE posthog_dashboardtile SET team_id = NULL WHERE id = ANY(%s)",- [tile_ids],- )---def _team_id_for(tile_id: int) -> int | None:- with connection.cursor() as cursor:- cursor.execute("SELECT team_id FROM posthog_dashboardtile WHERE id = %s", [tile_id])- row = cursor.fetchone()- assert row is not None- return row[0]---class TestBackfillDashboardTileTeamId(BaseTest):- def setUp(self) -> None:- super().setUp()- self.stdout = StringIO()-- self.other_organization = Organization.objects.create(name="other org")- self.other_team = Team.objects.create(organization=self.other_organization, name="other team")-- self.dashboard_a = Dashboard.objects.create(team=self.team, name="A")- self.dashboard_b = Dashboard.objects.create(team=self.other_team, name="B")-- text_a = Text.objects.create(team=self.team, body="hi A")- text_b = Text.objects.create(team=self.other_team, body="hi B")- self.tile_a = DashboardTile.objects.create(dashboard=self.dashboard_a, text=text_a)- self.tile_b = DashboardTile.objects.create(dashboard=self.dashboard_b, text=text_b)-- def test_backfills_team_id_from_dashboard(self) -> None:- _null_out_team_ids([self.tile_a.id, self.tile_b.id])- self.assertIsNone(_team_id_for(self.tile_a.id))- self.assertIsNone(_team_id_for(self.tile_b.id))-- call_command("backfill_dashboardtile_team_id", stdout=self.stdout)-- self.assertEqual(_team_id_for(self.tile_a.id), self.team.id)- self.assertEqual(_team_id_for(self.tile_b.id), self.other_team.id)-- def test_second_run_is_a_noop(self) -> None:- _null_out_team_ids([self.tile_a.id, self.tile_b.id])-- call_command("backfill_dashboardtile_team_id", stdout=self.stdout)-- second_stdout = StringIO()- call_command("backfill_dashboardtile_team_id", stdout=second_stdout)- self.assertIn("Updated 0 tile(s) in 0 batch(es)", second_stdout.getvalue())-- def test_skips_tiles_that_already_have_team_id(self) -> None:- _null_out_team_ids([self.tile_a.id])-- call_command("backfill_dashboardtile_team_id", stdout=self.stdout)-- self.tile_b.refresh_from_db(fields=["team_id"])- self.assertEqual(self.tile_b.team_id, self.other_team.id)- self.assertEqual(_team_id_for(self.tile_a.id), self.team.id)diff --git a/products/dashboards/backend/migrations/0004_add_dashboardtile_team_id_index.py b/products/dashboards/backend/migrations/0004_add_dashboardtile_team_id_index.pynew file mode 100644index 000000000000..39e263bd09e5--- /dev/null+++ b/products/dashboards/backend/migrations/0004_add_dashboardtile_team_id_index.py@@ -0,0 +1,33 @@+from django.db import migrations+++class Migration(migrations.Migration):+ """+ Add a btree index on DashboardTile.team_id concurrently.++ HogQL queries against system.dashboard_tiles inject `WHERE team_id = X`,+ so the index is required for acceptable query latency on a fully-populated+ table. CREATE INDEX CONCURRENTLY needs atomic=False.++ The model carries db_index=False on the FK so Django's state has no+ matching index entry — this RunSQL is intentionally outside Django's+ state tracking (it lives only on the database side). Future makemigrations+ runs won't see drift because the field declares no index.+ """++ atomic = False++ dependencies = [+ ("dashboards", "0003_backfill_dashboardtile_team_id"),+ ]++ operations = [+ migrations.RunSQL(+ sql=(+ "CREATE INDEX CONCURRENTLY IF NOT EXISTS "+ '"posthog_dashboardtile_team_id_idx" '+ 'ON "posthog_dashboardtile" ("team_id")'+ ),+ reverse_sql='DROP INDEX CONCURRENTLY IF EXISTS "posthog_dashboardtile_team_id_idx"',+ ),+ ]diff --git a/products/dashboards/backend/migrations/0005_enforce_dashboardtile_team_id_not_null.py b/products/dashboards/backend/migrations/0005_enforce_dashboardtile_team_id_not_null.pynew file mode 100644index 000000000000..32a1881d0313--- /dev/null+++ b/products/dashboards/backend/migrations/0005_enforce_dashboardtile_team_id_not_null.py@@ -0,0 +1,48 @@+import django.db.models.deletion+from django.db import migrations, models+++class Migration(migrations.Migration):+ """+ Enforce NOT NULL on DashboardTile.team_id.++ Step 3 of three. The column was added nullable in 0002 and backfilled in+ 0003. The backfill is idempotent on team_id IS NULL — verify in production+ before merging this migration that no rows remain unpopulated:++ SELECT COUNT(*) FROM posthog_dashboardtile WHERE team_id IS NULL;++ SeparateDatabaseAndState keeps Django's state in sync with the field flip+ on the model. `not-null-ignore` annotation tells the migration analyzer+ that the rewrite-the-table risk does not apply: there are no NULL rows by+ construction, so SET NOT NULL only adds the catalog flag.+ """++ dependencies = [+ ("dashboards", "0004_add_dashboardtile_team_id_index"),+ ]++ operations = [+ migrations.SeparateDatabaseAndState(+ state_operations=[+ migrations.AlterField(+ model_name="dashboardtile",+ name="team",+ field=models.ForeignKey(+ db_index=False,+ on_delete=django.db.models.deletion.CASCADE,+ to="posthog.team",+ ),+ ),+ ],+ database_operations=[+ migrations.RunSQL(+ sql=(+ "-- not-null-ignore: team_id backfilled in 0003_backfill_dashboardtile_team_id\n"+ 'ALTER TABLE "posthog_dashboardtile" ALTER COLUMN "team_id" SET NOT NULL'+ ),+ reverse_sql='ALTER TABLE "posthog_dashboardtile" ALTER COLUMN "team_id" DROP NOT NULL',+ ),+ ],+ ),+ ]diff --git a/products/dashboards/backend/migrations/max_migration.txt b/products/dashboards/backend/migrations/max_migration.txtindex 9a9b84dfa157..2d070391bceb 100644--- a/products/dashboards/backend/migrations/max_migration.txt+++ b/products/dashboards/backend/migrations/max_migration.txt@@ -1 +1 @@-0003_backfill_dashboardtile_team_id+0005_enforce_dashboardtile_team_id_not_nulldiff --git a/products/dashboards/backend/models/dashboard_tile.py b/products/dashboards/backend/models/dashboard_tile.pyindex 73177fb5246c..0c76fcc82b07 100644--- a/products/dashboards/backend/models/dashboard_tile.py+++ b/products/dashboards/backend/models/dashboard_tile.py@@ -79,9 +79,10 @@ class DashboardTile(models.Model):)# Denormalized from `dashboard.team_id` so this table can be exposed via HogQL,# whose printer injects `WHERE team_id = <ctx.team_id>` against every PostgresTable.- # Auto-populated in save() when omitted. Nullable here only because the rollout- # backfills before flipping NOT NULL in a later migration.- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, null=True, db_index=False)+ # Auto-populated in save() when omitted. The index is created concurrently+ # outside Django state (migration 0004) and not declared here, so db_index=False+ # keeps state and DB in sync.+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_index=False)# Tile layout and stylelayouts = models.JSONField(default=dict)@@ -135,7 +136,11 @@ class DashboardTile(models.Model):update_fields = list(update_fields)kwargs["update_fields"] = update_fields- if self.team_id is None and self.dashboard_id is not None:+ # The field is non-nullable in the DB, but unsaved instances start out with+ # team_id unset — pull it off the dashboard so callers can construct a tile+ # with just a dashboard reference. `getattr` keeps mypy from flagging the+ # None branch as unreachable under the non-Optional FK type.+ if getattr(self, "team_id", None) is None and self.dashboard_id is not None:self.team_id = self.dashboard.team_idif update_fields is not None:update_fields.append("team_id")diff --git a/products/data_warehouse/backend/test/__snapshots__/test_hogql_fixer_ai.ambr b/products/data_warehouse/backend/test/__snapshots__/test_hogql_fixer_ai.ambrindex 99e13384864d..27dc3aaeac81 100644--- a/products/data_warehouse/backend/test/__snapshots__/test_hogql_fixer_ai.ambr+++ b/products/data_warehouse/backend/test/__snapshots__/test_hogql_fixer_ai.ambr@@ -110,7 +110,7 @@This is a list of all the available tables in the database:```- ['events', 'groups', 'persons', 'sessions', 'logs', 'query_log', 'system.accounts', 'system.activity_logs', 'system.actions', 'system.alerts', 'system.annotations', 'system.batch_export_backfills', 'system.batch_exports', 'system.cohort_calculation_history', 'system.cohorts', 'system.dashboards', 'system.data_modeling_jobs', 'system.data_modeling_views', 'system.data_modeling_endpoint_versions', 'system.data_modeling_endpoints', 'system.data_warehouse_sources', 'system.data_warehouse_tables', 'system.error_tracking_assignment_rules', 'system.error_tracking_issue_assignments', 'system.error_tracking_issue_fingerprints', 'system.error_tracking_issues', 'system.error_tracking_releases', 'system.error_tracking_symbol_sets', 'system.error_tracking_suppression_rules', 'system.early_access_features', 'system.experiments', 'system.exports', 'system.feature_flags', 'system.groups', 'system.group_type_mappings', 'system.hog_flows', 'system.hog_functions', 'system.ingestion_warnings', 'system.integrations', 'system.integration_repository_cache', 'system.insight_variables', 'system.logs_alerts', 'system.logs_views', 'system.insights', 'system.notebooks', 'system.sandbox_environments', 'system.review_queue_items', 'system.review_queues', 'system.score_definitions', 'system.session_recording_playlists', 'system.session_recordings', 'system.source_schemas', 'system.source_sync_jobs', 'system.support_tickets', 'system.surveys', 'system.task_runs', 'system.tasks', 'system.teams', 'system.trace_review_scores', 'system.trace_reviews', 'system.usage_metrics']+ ['events', 'groups', 'persons', 'sessions', 'logs', 'query_log', 'system.accounts', 'system.activity_logs', 'system.actions', 'system.alerts', 'system.annotations', 'system.batch_export_backfills', 'system.batch_exports', 'system.cohort_calculation_history', 'system.cohorts', 'system.dashboards', 'system.dashboard_tiles', 'system.data_modeling_jobs', 'system.data_modeling_views', 'system.data_modeling_endpoint_versions', 'system.data_modeling_endpoints', 'system.data_warehouse_sources', 'system.data_warehouse_tables', 'system.error_tracking_assignment_rules', 'system.error_tracking_issue_assignments', 'system.error_tracking_issue_fingerprints', 'system.error_tracking_issues', 'system.error_tracking_releases', 'system.error_tracking_symbol_sets', 'system.error_tracking_suppression_rules', 'system.early_access_features', 'system.experiments', 'system.exports', 'system.feature_flags', 'system.groups', 'system.group_type_mappings', 'system.hog_flows', 'system.hog_functions', 'system.ingestion_warnings', 'system.integrations', 'system.integration_repository_cache', 'system.insight_variables', 'system.logs_alerts', 'system.logs_views', 'system.insights', 'system.notebooks', 'system.sandbox_environments', 'system.review_queue_items', 'system.review_queues', 'system.score_definitions', 'system.session_recording_playlists', 'system.session_recordings', 'system.source_schemas', 'system.source_sync_jobs', 'system.support_tickets', 'system.surveys', 'system.task_runs', 'system.tasks', 'system.teams', 'system.trace_review_scores', 'system.trace_reviews', 'system.usage_metrics']````person` or `event` metadata unspecified above (emails, names, etc.) is stored in `properties` fields, accessed like: `properties.foo.bar`.