chore(product-analytics): move insight models to product app#60001
Conversation
Move 4 Django models (Insight, InsightViewed, InsightCachingState,
InsightVariable) out of posthog/models/ into products/product_analytics/
backend/models/ as part of the ongoing product isolation effort.
State-only migrations with SeparateDatabaseAndState — no DB changes,
tables keep their posthog_ prefix via explicit db_table. ContentType
rows updated via RunPython. Cross-app FKs (Dashboard.insights,
DashboardTile.insight, Alert.insight, Survey.linked_insight,
TaggedItem.insight, SharingConfiguration.insight, Subscription.insight,
ExportedAsset.insight, Annotation.dashboard_item, CustomerJourney.insight)
re-pointed to the new app label.
Adjacent product-specific files moved alongside the models:
- API: insight.py, insight_metadata.py, insight_serializers.py,
insight_suggestions.py, insight_variable.py (+ their tests)
- Model tests, activity-logging test
insight_admin.py stays in posthog/admin/admins/ — DashboardTileInline's
autocomplete_fields requires it to be registered eagerly, which only
the central admin registry guarantees during migrate's system checks.
Owner-confirmed by Product Analytics team.
…analytics-models # Conflicts: # posthog/migrations/max_migration.txt
|
🎭 Playwright didn't run on this PR — your changes touch code that could affect E2E behavior, but Playwright is opt-in via label now to keep CI cost down. Add the Most PRs don't need this. Real regressions still get caught on master and fix-forward. |
…imports - product_analytics 0001 dependency: 1177 → 1179 (renamed during master merge to avoid collision with 1178_datadeletionrequest_person_properties) - tach.toml: remove duplicate customer_analytics + marketing_analytics entries left over from the master merge (kept the union of deps) - three test files added on master while this branch was open still imported Insight from posthog.models — repoint to products.product_analytics.backend
Migration SQL ChangesHey 👋, we've detected some migrations on this PR. Here's the SQL output for each migration, make sure they make sense:
|
🔍 Migration Risk AnalysisWe've analyzed your migrations for potential risks. Summary: 2 Safe | 5 Needs Review | 0 Blocked
|
posthog/caching/test/test_insight_caching_state.py and the moved products/product_analytics/backend/models/test/test_insight_caching_state.py share a basename — pytest needs __init__.py in the new dirs so it can treat them as packages and disambiguate.
MCP UI Apps size report
|
|
⏭️ Skipped snapshot commit because branch advanced to The new commit will trigger its own snapshot update workflow. If you expected this workflow to succeed: This can happen due to concurrent commits. To get a fresh workflow run, either:
|
- ci-backend.yml hardcoded ./posthog/api/test/test_insight* — now points at products/product_analytics/backend/api/test/ - moved test_insight.ambr + test_insight_funnels.ambr alongside the tests they belong to
…pshot The Insight model move shifts where RootTeamManager team-resolution queries fire during feature-flag-copy setup — net result is fewer queries against posthog_dashboarditem in the copy path. Snapshot regenerated with --snapshot-update against the new app layout.
There was a problem hiding this comment.
Pull request overview
This PR continues the product isolation effort by moving Product Analytics insight-related Django models (and the corresponding API + tests) out of posthog/models into the products.product_analytics app, while keeping existing Postgres tables in place via state-only migrations and updating cross-app FK targets/import paths throughout the codebase.
Changes:
- Moved
Insight,InsightViewed,InsightCachingState, andInsightVariable(plus Product Analytics API/tests) intoproducts/product_analytics/backend/, and registeredProductAnalyticsConfig. - Repointed cross-app model relations (
ForeignKey/ManyToManyField) and updated imports across dashboards, surveys, alerts, subscriptions, sharing, exports, HogQL variables, etc. - Added state-only migrations (including ContentType relabeling) and updated tooling/config (tach dependencies, ruff config, CI test selection, MCP tools config).
Reviewed changes
Copilot reviewed 186 out of 196 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tach.toml | Add products.product_analytics dependencies across impacted modules and define product_analytics module deps. |
| products/surveys/backend/test_max_tools.py | Update Insight import to new product_analytics location. |
| products/surveys/backend/models.py | Repoint Survey.linked_insight FK to product_analytics.Insight. |
| products/surveys/backend/migrations/max_migration.txt | Bump surveys migration pointer for the model move. |
| products/surveys/backend/migrations/0004_migrate_product_analytics_models.py | State migration updating Survey.linked_insight FK target. |
| products/surveys/backend/api/test/test_survey.py | Update Insight import to product_analytics model. |
| products/surveys/backend/api/survey.py | Update Insight import to product_analytics model. |
| products/slack_app/backend/tests/test_link_unfurl.py | Update Insight import to product_analytics model. |
| products/slack_app/backend/slack_link_unfurl.py | Update Insight import to product_analytics model. |
| products/ruff.toml | Exempt product_analytics backend from ANN rules (matching other product apps). |
| products/product_analytics/mcp/tools.yaml | Add (disabled) insight-variable MCP tool entries. |
| products/product_analytics/backend/test/test_insight_activity_logging.py | Update Insight import to product_analytics model. |
| products/product_analytics/backend/models/test/test_insight_model.py | Update Insight/hash import paths to new model module. |
| products/product_analytics/backend/models/test/test_insight_caching_state.py | Update Insight/InsightCachingState imports to product_analytics modules. |
| products/product_analytics/backend/models/insight.py | Move Insight/InsightViewed model definitions under product_analytics with explicit db_table and updated FK refs. |
| products/product_analytics/backend/models/insight_variable.py | Move InsightVariable model under product_analytics with explicit db_table and updated FK refs. |
| products/product_analytics/backend/models/insight_caching_state.py | Move InsightCachingState model under product_analytics with explicit db_table and updated FK refs. |
| products/product_analytics/backend/models/init.py | Expose product_analytics insight-related models via package exports. |
| products/product_analytics/backend/migrations/max_migration.txt | Establish product_analytics migration pointer. |
| products/product_analytics/backend/migrations/0001_migrate_product_analytics_models.py | Initial state-only migration creating new app’s model state mapped to existing tables. |
| products/product_analytics/backend/api/test/test_insight.py | Update test imports and patch paths to product_analytics insight API module. |
| products/product_analytics/backend/api/test/test_insight_variable.py | Update imports to product_analytics insight-variable API/model. |
| products/product_analytics/backend/api/test/test_insight_query.py | Update Insight import to product_analytics model. |
| products/product_analytics/backend/api/test/test_insight_metadata.py | Update mock patch path for relocated insight_metadata module. |
| products/product_analytics/backend/api/test/test_insight_funnels.py | Add funnel API tests under product_analytics test suite. |
| products/product_analytics/backend/api/test/snapshots/test_insight_funnels.ambr | Add ClickHouse query snapshots for new funnel tests. |
| products/product_analytics/backend/api/insight.py | Relocate Insight API implementation into product_analytics app and update imports. |
| products/product_analytics/backend/api/insight_variable.py | Relocate InsightVariable API/viewset into product_analytics app and update model import. |
| products/product_analytics/backend/api/insight_suggestions.py | Relocate insight suggestion/analysis helpers into product_analytics app. |
| products/product_analytics/backend/api/insight_serializers.py | Introduce product_analytics-specific insight serializers for endpoints/docs. |
| products/product_analytics/backend/api/insight_metadata.py | Relocate insight metadata (LLM naming/description) generator into product_analytics app. |
| products/product_analytics/backend/api/init.py | Export product_analytics insight viewsets. |
| products/notebooks/backend/test/test_sharing.py | Update Insight import to product_analytics model. |
| products/endpoints/backend/tests/test_openapi_spec.py | Update InsightVariable import to product_analytics model. |
| products/endpoints/backend/tests/test_endpoint.py | Update InsightVariable imports to product_analytics model. |
| products/endpoints/backend/tests/test_endpoint_execution.py | Update InsightVariable import to product_analytics model. |
| products/endpoints/backend/openapi.py | Update InsightVariable import to product_analytics model. |
| products/endpoints/backend/api.py | Update InsightVariable import to product_analytics model. |
| products/dashboards/backend/models/dashboard.py | Repoint dashboards’ M2M insights relation to product_analytics.Insight. |
| products/dashboards/backend/models/dashboard_tile.py | Repoint DashboardTile.insight FK and update filters hash import path. |
| products/dashboards/backend/migrations/max_migration.txt | Bump dashboards migration pointer for the model move. |
| products/dashboards/backend/migrations/0004_migrate_product_analytics_models.py | State migration updating dashboard insight relations to new app label. |
| products/dashboards/backend/api/test/test_run_insights.py | Update Insight/InsightVariable imports to product_analytics models. |
| products/dashboards/backend/api/dashboard.py | Update Insight API/serializer imports to product_analytics modules. |
| products/customer_analytics/backend/models/customer_journey.py | Repoint CustomerJourney.insight FK to product_analytics.Insight. |
| products/customer_analytics/backend/migrations/max_migration.txt | Bump customer_analytics migration pointer for the model move. |
| products/customer_analytics/backend/migrations/0006_migrate_product_analytics_models.py | State migration updating CustomerJourney.insight FK target. |
| products/customer_analytics/backend/api/test_views.py | Update Insight import to product_analytics model. |
| products/alerts/backend/test_max_tools.py | Update Insight import to product_analytics model. |
| products/alerts/backend/models/alert.py | Repoint alert/threshold/config FKs to product_analytics.Insight. |
| products/alerts/backend/migrations/max_migration.txt | Bump alerts migration pointer for the model move. |
| products/alerts/backend/migrations/0002_migrate_product_analytics_models.py | State migration updating alerts’ Insight FK targets. |
| products/alerts/backend/max_tools.py | Update Insight import to product_analytics model. |
| products/alerts/backend/api/alert.py | Update Insight + InsightBasicSerializer imports to product_analytics API. |
| products/actions/backend/api/test/test_action.py | Update Insight import to product_analytics model. |
| products/actions/backend/api/action.py | Update Insight import to product_analytics model. |
| posthog/utils.py | Update TYPE_CHECKING and variables override helper import paths for insight variables. |
| posthog/user_permissions.py | Update Insight import to product_analytics model. |
| posthog/test/test_utils.py | Update patch path for relocated map_stale_to_latest. |
| posthog/test/test_user_permissions.py | Update Insight import to product_analytics model. |
| posthog/test/test_middleware.py | Update Insight import to product_analytics model. |
| posthog/test/playwright_setup_functions.py | Update Insight/InsightVariable imports to product_analytics models. |
| posthog/test/base.py | Update Insight import to product_analytics model. |
| posthog/test/activity_logging/test_annotation_activity_logging.py | Update Insight import to product_analytics model. |
| posthog/temporal/tests/test_subscriptions_workflows.py | Update Insight import to product_analytics model. |
| posthog/temporal/tests/test_alerts_workflows.py | Update Insight import to product_analytics model. |
| posthog/temporal/tests/test_alerts_investigation.py | Update Insight import to product_analytics model. |
| posthog/temporal/tests/test_alerts_activities.py | Update Insight import to product_analytics model. |
| posthog/temporal/tests/product_analytics/test_upgrade_queries_workflow.py | Update Insight import to product_analytics model. |
| posthog/temporal/tests/ai/test_anomaly_investigation_verdict.py | Update Insight import to product_analytics model. |
| posthog/temporal/tests/ai/test_anomaly_investigation_notebook.py | Update Insight import to product_analytics model. |
| posthog/temporal/subscriptions/test_snapshot_image_loading.py | Update Insight import to product_analytics model. |
| posthog/temporal/subscriptions/test_snapshot_annotations.py | Update Insight import to product_analytics model. |
| posthog/temporal/subscriptions/test_snapshot_ai_consent.py | Update Insight import to product_analytics model. |
| posthog/temporal/subscriptions/snapshot_activities.py | Update Insight import to product_analytics model. |
| posthog/temporal/subscriptions/llm_change_summary.py | Update import path for relocated query-instructions helper. |
| posthog/temporal/subscriptions/insight_snapshot.py | Update Insight import to product_analytics model. |
| posthog/temporal/subscriptions/activities.py | Update Insight import to product_analytics model. |
| posthog/temporal/product_analytics/upgrade_queries_activities.py | Update Insight import to product_analytics model. |
| posthog/temporal/ai/anomaly_investigation/notebook.py | Update Insight import to product_analytics model. |
| posthog/tasks/exports/test/test_image_exporter.py | Update Insight/InsightVariable/map_stale_to_latest imports to product_analytics modules. |
| posthog/tasks/exports/image_exporter.py | Update InsightVariable/map_stale_to_latest imports to product_analytics modules. |
| posthog/tasks/alerts/trends.py | Update Insight import to product_analytics model. |
| posthog/tasks/alerts/test/test_investigation_notifications.py | Update Insight import to product_analytics model. |
| posthog/tasks/alerts/test/test_detector_breakdowns.py | Update Insight import to product_analytics model. |
| posthog/tasks/alerts/detector.py | Update Insight import to product_analytics model. |
| posthog/settings/web.py | Register ProductAnalyticsConfig in product apps list. |
| posthog/schema_migrations/upgrade_manager.py | Update TYPE_CHECKING import path for Insight. |
| posthog/rbac/test/test_user_access_control.py | Update Insight import to product_analytics model. |
| posthog/models/test/test_tagged_item_model.py | Update Insight import to product_analytics model. |
| posthog/models/test/test_subscription_model.py | Update Insight import to product_analytics model. |
| posthog/models/test/test_product_intent.py | Update Insight import to product_analytics model. |
| posthog/models/test/test_dashboard_tile_model.py | Update Insight import to product_analytics model. |
| posthog/models/team/util.py | Update InsightCachingState import path to product_analytics model. |
| posthog/models/tagged_item.py | Repoint TaggedItem.insight FK to product_analytics.Insight. |
| posthog/models/subscription.py | Repoint subscription insight relations to product_analytics.Insight. |
| posthog/models/sharing_configuration.py | Repoint SharingConfiguration.insight FK and update Insight import path. |
| posthog/models/resource_transfer/visitors/insight.py | Update Insight import to product_analytics model for transfer visitor. |
| posthog/models/resource_transfer/test/test_inter_project_transferer.py | Update Insight import to product_analytics model. |
| posthog/models/product_intent/product_intent.py | Update Insight import to product_analytics model. |
| posthog/models/file_system/unfiled_file_saver.py | Update Insight import to product_analytics model. |
| posthog/models/file_system/test/test_file_system.py | Update Insight import to product_analytics model. |
| posthog/models/file_system/test/test_file_system_view_log.py | Update Insight import to product_analytics model. |
| posthog/models/file_system/test/test_file_system_mixin.py | Update Insight import to product_analytics model. |
| posthog/models/exported_asset.py | Repoint ExportedAsset.insight FK to product_analytics.Insight. |
| posthog/models/annotation.py | Repoint Annotation.dashboard_item FK to product_analytics.Insight. |
| posthog/models/init.py | Stop re-exporting insight-related models from posthog.models. |
| posthog/migrations/max_migration.txt | Bump posthog migration pointer. |
| posthog/migrations/1180_migrate_product_analytics_models.py | State-only cleanup + ContentType relabeling for moved models. |
| posthog/migrations/1179_migrate_product_analytics_models.py | State-only pre-step removing old Insight fields to avoid state conflicts. |
| posthog/migrations/0156_insight_short_id.py | Fix migration import to explicitly use posthog.utils.generate_short_id. |
| posthog/middleware.py | Update Insight import to product_analytics model. |
| posthog/management/commands/migrate_retention_show_mean.py | Update Insight import to product_analytics model. |
| posthog/management/commands/backfill_insights_query_metadata.py | Update Insight import to product_analytics model. |
| posthog/hogql/variables.py | Update InsightVariable import to product_analytics model. |
| posthog/hogql/test/test_query.py | Update InsightVariable import to product_analytics model. |
| posthog/hogql/test/test_metadata.py | Update InsightVariable import to product_analytics model. |
| posthog/hogql/test/test_autocomplete.py | Update InsightVariable import to product_analytics model. |
| posthog/hogql/database/schema/test/test_system_tables.py | Update Insight/InsightVariable imports to product_analytics models. |
| posthog/hogql/autocomplete.py | Update InsightVariable import to product_analytics model. |
| posthog/hogql_queries/test/test_hogql_query_runner.py | Update InsightVariable import to product_analytics model. |
| posthog/hogql_queries/legacy_compatibility/flagged_conversion_manager.py | Update TYPE_CHECKING import path for Insight. |
| posthog/helpers/dashboard_templates.py | Update Insight import to product_analytics model. |
| posthog/demo/products/hedgebox/matrix.py | Update Insight/InsightViewed imports to product_analytics models. |
| posthog/demo/legacy/web_data_generator.py | Update Insight import to product_analytics model. |
| posthog/demo/legacy/revenue_data_generator.py | Update Insight import to product_analytics model. |
| posthog/demo/legacy/insight_variables_data_generator.py | Update Insight/InsightVariable imports to product_analytics models. |
| posthog/demo/legacy/app_data_generator.py | Update Insight import to product_analytics model. |
| posthog/caching/warming.py | Update Insight import to product_analytics model. |
| posthog/caching/test/test_warming.py | Update Insight/InsightViewed imports to product_analytics models. |
| posthog/caching/test/test_insight_caching_state.py | Update Insight/InsightViewed/InsightCachingState imports to product_analytics models. |
| posthog/caching/test/test_insight_cache.py | Update InsightCachingState import to product_analytics model. |
| posthog/caching/insight_caching_state.py | Update Insight/InsightViewed/InsightCachingState imports to product_analytics models. |
| posthog/caching/insight_cache.py | Update Insight/InsightCachingState imports to product_analytics models. |
| posthog/caching/calculate_results.py | Update Insight + hash helper import to product_analytics model module. |
| posthog/api/test/test_tagged_item.py | Update Insight import to product_analytics model. |
| posthog/api/test/test_sharing.py | Update Insight import and patch paths to product_analytics insight API module. |
| posthog/api/test/test_sharing_access_token_security.py | Update Insight/InsightVariable imports to product_analytics models. |
| posthog/api/test/test_search.py | Update Insight import to product_analytics model. |
| posthog/api/test/test_resource_transfer.py | Update Insight import to product_analytics model. |
| posthog/api/test/test_query.py | Update InsightVariable import to product_analytics model. |
| posthog/api/test/test_personal_api_keys.py | Update Insight import to product_analytics model. |
| posthog/api/test/test_file_system.py | Update Insight import to product_analytics model. |
| posthog/api/test/test_feature_flag.py | Update Insight import to product_analytics model. |
| posthog/api/test/test_exports.py | Update Insight/InsightSerializer imports to product_analytics modules. |
| posthog/api/test/test_cohort.py | Update Insight import to product_analytics model. |
| posthog/api/test/test_annotation.py | Update Insight import to product_analytics model. |
| posthog/api/test/test_annotation_context.py | Update Insight import to product_analytics model. |
| posthog/api/test/dashboards/test_dashboard.py | Update Insight/InsightVariable imports to product_analytics models. |
| posthog/api/test/snapshots/test_organization_feature_flag.ambr | Update stored SQL snapshot ordering affected by model/app label changes. |
| posthog/api/sharing.py | Update sharing to use product_analytics Insight API/model types. |
| posthog/api/search.py | Update Insight import to product_analytics model. |
| posthog/api/person.py | Update import for capture_legacy_api_call to relocated insight API module. |
| posthog/api/my_notifications.py | Update Insight import to product_analytics model. |
| posthog/api/file_system/test/test_file_system.py | Update Insight import to product_analytics model. |
| posthog/api/file_system/registrations.py | Update file-system registration app label for Insight to product_analytics. |
| posthog/api/exports.py | Update Insight import to product_analytics model. |
| posthog/api/cohort.py | Update Insight import to product_analytics model. |
| posthog/api/annotation.py | Update Insight import to product_analytics model. |
| posthog/api/init.py | Route Insight/InsightVariable viewsets from product_analytics and update nested registration. |
| posthog/admin/admins/organization_admin.py | Update model path for InsightCachingState references in admin. |
| posthog/admin/admins/insight_admin.py | Keep central admin registration but import Insight from product_analytics. |
| ee/tasks/test/test_slack.py | Update Insight import to product_analytics model. |
| ee/tasks/test/subscriptions/test_subscriptions_utils.py | Update Insight import to product_analytics model. |
| ee/tasks/test/subscriptions/test_slack_subscriptions.py | Update Insight import to product_analytics model. |
| ee/tasks/test/subscriptions/test_email_subscriptions.py | Update Insight import to product_analytics model. |
| ee/tasks/subscriptions/subscription_utils.py | Update Insight import to product_analytics model. |
| ee/hogai/tools/upsert_dashboard/tool.py | Update Insight import to product_analytics model. |
| ee/hogai/tools/upsert_dashboard/test/test_tool.py | Update Insight import to product_analytics model. |
| ee/hogai/tools/read_data/test/test_tool.py | Update Insight import to product_analytics model. |
| ee/hogai/tools/execute_sql/test/test_tool.py | Update Insight import to product_analytics model. |
| ee/hogai/tools/execute_sql/test/test_mcp_tool.py | Update Insight import to product_analytics model. |
| ee/hogai/eval/sandboxed/seeders/insight.py | Update Insight import to product_analytics model. |
| ee/hogai/eval/data_setup.py | Update Insight import to product_analytics model. |
| ee/hogai/eval/ci/max_tools/eval_upsert_dashboard.py | Update Insight import to product_analytics model. |
| ee/hogai/context/insight/context.py | Update Insight import to product_analytics model. |
| ee/hogai/context/entity_search/test/test_context.py | Update Insight/InsightViewed imports to product_analytics models. |
| ee/hogai/context/entity_search/context.py | Update Insight import to product_analytics model. |
| ee/hogai/chat_agent/insights/test/test_nodes.py | Update Insight/InsightViewed imports to product_analytics models. |
| ee/hogai/chat_agent/insights/nodes.py | Update Insight import to product_analytics model. |
| ee/hogai/artifacts/types.py | Update Insight import to product_analytics model. |
| ee/hogai/artifacts/test/test_manager.py | Update Insight import to product_analytics model. |
| ee/hogai/artifacts/handlers/visualization.py | Update Insight import to product_analytics model. |
| ee/clickhouse/views/person.py | Update capture_legacy_api_call import to relocated insight API module. |
| ee/clickhouse/views/insights.py | Update InsightViewSet/capture helper and Insight import to product_analytics modules. |
| ee/api/test/test_tagged_item.py | Update Insight import to product_analytics model. |
| ee/api/test/test_subscription.py | Update Insight import to product_analytics model. |
| ee/api/test/test_insight.py | Update Insight import to product_analytics model. |
| ee/api/subscription.py | Update Insight import to product_analytics model. |
| .semgrep/rules/idor-team-scoped-models.py | Update Insight import to product_analytics model for rule test fixture/example. |
| .github/workflows/ci-backend.yml | Update pytest target selection to include new product_analytics test path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…analytics-models # Conflicts: # products/dashboards/backend/migrations/max_migration.txt
PR #51923 (feature flag move) appended duplicate `[[modules]]` blocks at the bottom of the file. Union them with the existing top entries and drop the trailing block. Also add `products.product_analytics` to feature_flags' depends_on for the test import added by master.
Master added FeatureFlag imports next to this branch's Insight ones, producing duplicate `from posthog.models import (...)` blocks and stale unused names after the moves. `ruff check --select F401,F811` collapses them.
Query snapshots: Backend query snapshots updatedChanges: 1 snapshots (1 modified, 0 added, 0 deleted) What this means:
Next steps:
|
Problem
Insight,InsightViewed,InsightCachingState,InsightVariablestill live inposthog/models/even though Product analytics has its own app. Moving them is the next step in the ongoing product isolation effort. Insights are referenced widely (dashboards, surveys, alerts, exports, sharing, annotations, tagging…), so this is the riskier end of the migration series.Changes
Models, API, tests, and activity-logging tests moved into
products/product_analytics/backend/. Cross-app FKs (Dashboard, DashboardTile, Alert, AlertConfiguration, Threshold, Survey.linked_insight, TaggedItem.insight, SharingConfiguration.insight, Subscription.insight, ExportedAsset.insight, Annotation.dashboard_item, CustomerJourney.insight) re-pointed toproduct_analytics.Insight.State-only migrations with
SeparateDatabaseAndState— tables keep theirposthog_prefix via explicitdb_table.ContentTyperows updated viaRunPythonusing the same idempotent merge-permissions-then-delete pattern as web_analytics (#59223). Same shape as the alerts/actions (#59224) and web_analytics (#59223) moves.insight_admin.pystays inposthog/admin/admins/— central registration is required becauseDashboardTileInline.autocomplete_fields = ("insight", ...)runs as a Django system check duringmigrate, and PostHog's lazy admin loader is disabled duringmigrate. Matches what alert_admin.py / dashboard_admin.py do.tach.tomlgetsproducts.product_analyticsadded to the depends_on lists ofee,actions,alerts,customer_analytics,dashboards,endpoints,notebooks,slack_app,surveys. Product itself gainsee,dashboards,alerts.How did you test this code?
I am an agent (Claude Code). I ran:
python manage.py migrate --plan— full plan resolves, all state-onlypython manage.py check— cleantach check --dependencies --interfaces— passesruff check/ruff format— cleanbin/hogli product:lint product_analytics— passesNo manual testing, no apply against the local DB.
Publish to changelog?
no
Docs update
n/a
🤖 Agent context
Built with Claude Code via the
product-model-migrationskill. Phase-by-phase workflow:move_scanner.py(cherry-pick mode with--files),migrate_phased.py(phases 1–6), manual cleanup of the trailing-comma artifacts the import rewriter leaves behind, cross-app FK string-ref updates, tach wiring.Notable decisions made along the way:
insight_admin.pyinto the product.migrate --planthen failed withadmin.E039because the lazy admin registry is bypassed duringmigrate(seeposthog/apps.py:198), soregister_all_admin()never ran, so the autodiscovered product admin never registered, so DashboardTileInline's autocomplete check saw an unregistered model. Moved it back toposthog/admin/admins/, only the imports inside it now point at the new model location. Same pattern as alert_admin/dashboard_admin.posthog/caching/insight_caching_state.py,posthog/hogql_queries/insights/*,posthog/queries/insight.py,posthog/demo/legacy/insight_variables_data_generator.py,posthog/management/commands/backfill_insights_query_metadata.py,posthog/temporal/subscriptions/insight_snapshot.pyin place — they're either cross-cutting infra or large surfaces that deserve their own PR. Same scope choice as alerts/actions and web_analytics.posthog/helpers/dashboard_templates.pyandposthog.models.team.team(viainsight_caching_state.py→from posthog.models.team import Team). Removed the unusedTeamimport and moved theDashboardtype-only import ininsight.pyunderTYPE_CHECKING.0156_insight_short_idhad a pre-existing latent bug — referencedposthog.utils.generate_short_idwhile only importingposthog.models.insight, relying on the package-traversal side effect. Replaced with an explicitimport posthog.utils.