Skip to content

chore(product-analytics): move insight models to product app#60001

Merged
webjunkie merged 17 commits into
masterfrom
chore/move-product-analytics-models
May 27, 2026
Merged

chore(product-analytics): move insight models to product app#60001
webjunkie merged 17 commits into
masterfrom
chore/move-product-analytics-models

Conversation

@webjunkie
Copy link
Copy Markdown
Contributor

Problem

Insight, InsightViewed, InsightCachingState, InsightVariable still live in posthog/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 to product_analytics.Insight.

State-only migrations with SeparateDatabaseAndState — tables keep their posthog_ prefix via explicit db_table. ContentType rows updated via RunPython using 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.py stays in posthog/admin/admins/ — central registration is required because DashboardTileInline.autocomplete_fields = ("insight", ...) runs as a Django system check during migrate, and PostHog's lazy admin loader is disabled during migrate. Matches what alert_admin.py / dashboard_admin.py do.

tach.toml gets products.product_analytics added to the depends_on lists of ee, actions, alerts, customer_analytics, dashboards, endpoints, notebooks, slack_app, surveys. Product itself gains ee, 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-only
  • python manage.py check — clean
  • tach check --dependencies --interfaces — passes
  • ruff check / ruff format — clean
  • bin/hogli product:lint product_analytics — passes

No 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-migration skill. 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:

  • Admin file stays central. Initially moved insight_admin.py into the product. migrate --plan then failed with admin.E039 because the lazy admin registry is bypassed during migrate (see posthog/apps.py:198), so register_all_admin() never ran, so the autodiscovered product admin never registered, so DashboardTileInline's autocomplete check saw an unregistered model. Moved it back to posthog/admin/admins/, only the imports inside it now point at the new model location. Same pattern as alert_admin/dashboard_admin.
  • Adjacent files: models + API + tests + admin, nothing else. Left 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.py in place — they're either cross-cutting infra or large surfaces that deserve their own PR. Same scope choice as alerts/actions and web_analytics.
  • Circular import between posthog/helpers/dashboard_templates.py and posthog.models.team.team (via insight_caching_state.pyfrom posthog.models.team import Team). Removed the unused Team import and moved the Dashboard type-only import in insight.py under TYPE_CHECKING.
  • Legacy migration 0156_insight_short_id had a pre-existing latent bug — referenced posthog.utils.generate_short_id while only importing posthog.models.insight, relying on the package-traversal side effect. Replaced with an explicit import posthog.utils.

webjunkie added 2 commits May 26, 2026 07:51
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
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

🎭 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 run-playwright label if you want an E2E sweep before merging — CI will pick it up automatically.

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
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

Migration SQL Changes

Hey 👋, we've detected some migrations on this PR. Here's the SQL output for each migration, make sure they make sense:

posthog/migrations/1183_migrate_product_analytics_models_state.py

BEGIN;
--
-- Custom state/database change combination
--
-- (no-op)
COMMIT;

posthog/migrations/1184_migrate_product_analytics_models.py

BEGIN;
--
-- Custom state/database change combination
--
-- (no-op)
--
-- Raw Python operation
--
-- THIS OPERATION CANNOT BE WRITTEN AS SQL
COMMIT;

products/alerts/backend/migrations/0002_migrate_product_analytics_models.py

BEGIN;
--
-- Alter field insight on alert
--
-- (no-op)
--
-- Alter field insight on alertconfiguration
--
-- (no-op)
--
-- Alter field insight on threshold
--
-- (no-op)
COMMIT;

products/customer_analytics/backend/migrations/0006_migrate_product_analytics_models.py

BEGIN;
--
-- Alter field insight on customerjourney
--
-- (no-op)
COMMIT;

products/dashboards/backend/migrations/0006_migrate_product_analytics_models.py

BEGIN;
--
-- Alter field insights on dashboard
--
-- (no-op)
--
-- Alter field insight on dashboardtile
--
-- (no-op)
COMMIT;

products/product_analytics/backend/migrations/0001_migrate_product_analytics_models.py

BEGIN;
--
-- Custom state/database change combination
--
-- (no-op)
COMMIT;

products/surveys/backend/migrations/0005_migrate_product_analytics_models.py

BEGIN;
--
-- Alter field linked_insight on survey
--
-- (no-op)
COMMIT;

Last updated: 2026-05-27 08:46 UTC (4821ff8)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

🔍 Migration Risk Analysis

We've analyzed your migrations for potential risks.

Summary: 2 Safe | 5 Needs Review | 0 Blocked

⚠️ Needs Review

May have performance impact

alerts.0002_migrate_product_analytics_models
  └─ #1 ⚠️ AlterField
     Field alteration may cause table locks or data loss (check if changing type or constraints)
     model: alert, field: insight, field_type: ForeignKey
  └─ #2 ⚠️ AlterField
     Field alteration may cause table locks or data loss (check if changing type or constraints)
     model: alertconfiguration, field: insight, field_type: ForeignKey
  └─ #3 ⚠️ AlterField
     Field alteration may cause table locks or data loss (check if changing type or constraints)
     model: threshold, field: insight, field_type: ForeignKey
customer_analytics.0006_migrate_product_analytics_models
  └─ #1 ⚠️ AlterField
     Field alteration may cause table locks or data loss (check if changing type or constraints)
     model: customerjourney, field: insight, field_type: ForeignKey
dashboards.0006_migrate_product_analytics_models
  └─ #1 ⚠️ AlterField
     Field alteration may cause table locks or data loss (check if changing type or constraints)
     model: dashboard, field: insights, field_type: ManyToManyField
  └─ #2 ⚠️ AlterField
     Field alteration may cause table locks or data loss (check if changing type or constraints)
     model: dashboardtile, field: insight, field_type: ForeignKey
surveys.0005_migrate_product_analytics_models
  └─ #1 ⚠️ AlterField
     Field alteration may cause table locks or data loss (check if changing type or constraints)
     model: survey, field: linked_insight, field_type: ForeignKey
posthog.1184_migrate_product_analytics_models
  └─ #1 ✅ SeparateDatabaseAndState: Only state operations (no database changes)
  └─ #2 ⚠️ RunPython: RunPython data migration needs review for performance

✅ Safe

Brief or no lock, backwards compatible

posthog.1183_migrate_product_analytics_models_state
  └─ #1 ✅ SeparateDatabaseAndState: Only state operations (no database changes)
product_analytics.0001_migrate_product_analytics_models
  └─ #1 ✅ SeparateDatabaseAndState: Only state operations (no database changes)

📚 How to Deploy These Changes Safely

RunPython:

Use batching for large data migrations:

  • Use .iterator() to avoid loading all rows into memory
  • Use .bulk_update() instead of saving individual objects
  • Batch size: 1,000-10,000 rows per batch
  • Add pauses between batches
  • Consider background jobs for very large updates (millions of rows)

See the migration safety guide

Last updated: 2026-05-27 08:46 UTC (4821ff8)

tests-posthog Bot and others added 3 commits May 26, 2026 06:47
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.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

MCP UI Apps size report

App JS CSS
debug 474.9 KB 139.9 KB
action 349.4 KB 139.9 KB
action-list 357.2 KB 139.9 KB
cohort 348.5 KB 139.9 KB
cohort-list 356.2 KB 139.9 KB
error-details 369.9 KB 139.9 KB
error-issue 349.2 KB 139.9 KB
error-issue-list 357.2 KB 139.9 KB
experiment 353.7 KB 139.9 KB
experiment-list 358.0 KB 139.9 KB
experiment-results 355.8 KB 139.9 KB
feature-flag 434.3 KB 139.9 KB
feature-flag-list 438.8 KB 139.9 KB
feature-flag-testing 427.2 KB 139.9 KB
insight-actors 352.3 KB 139.9 KB
llm-costs 351.9 KB 139.9 KB
session-recording 350.2 KB 139.9 KB
session-summary 356.2 KB 139.9 KB
survey 350.0 KB 139.9 KB
survey-global-stats 354.8 KB 139.9 KB
survey-list 357.9 KB 139.9 KB
survey-stats 354.8 KB 139.9 KB
trace-span 348.8 KB 139.9 KB
trace-span-list 357.1 KB 139.9 KB
workflow 348.8 KB 139.9 KB
workflow-list 356.6 KB 139.9 KB
query-results 370.6 KB 139.9 KB
visual-review-snapshots 353.5 KB 139.9 KB

@tests-posthog
Copy link
Copy Markdown
Contributor

tests-posthog Bot commented May 26, 2026

⏭️ Skipped snapshot commit because branch advanced to 538613f while workflow was testing ec74251.

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:

  • Merge master into your branch, or
  • Push an empty commit: git commit --allow-empty -m 'trigger CI' && git push

webjunkie added 3 commits May 26, 2026 09:15
- 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.
@webjunkie webjunkie marked this pull request as ready for review May 26, 2026 08:12
Copilot AI review requested due to automatic review settings May 26, 2026 08:12
@webjunkie webjunkie requested a review from a team as a code owner May 26, 2026 08:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and InsightVariable (plus Product Analytics API/tests) into products/product_analytics/backend/, and registered ProductAnalyticsConfig.
  • 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.

Comment thread posthog/api/sharing.py
Copy link
Copy Markdown
Collaborator

@thmsobrmlr thmsobrmlr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤞

@webjunkie webjunkie requested a review from mariusandra May 26, 2026 10:54
…analytics-models

# Conflicts:
#	products/dashboards/backend/migrations/max_migration.txt
webjunkie and others added 5 commits May 27, 2026 09:51
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.
@tests-posthog
Copy link
Copy Markdown
Contributor

tests-posthog Bot commented May 27, 2026

Query snapshots: Backend query snapshots updated

Changes: 1 snapshots (1 modified, 0 added, 0 deleted)

What this means:

  • Query snapshots have been automatically updated to match current output
  • These changes reflect modifications to database queries or schema

Next steps:

  • Review the query changes to ensure they're intentional
  • If unexpected, investigate what caused the query to change

Review snapshot changes →

@webjunkie webjunkie merged commit 3fbcbbd into master May 27, 2026
314 of 320 checks passed
@webjunkie webjunkie deleted the chore/move-product-analytics-models branch May 27, 2026 09:29
@deployment-status-posthog
Copy link
Copy Markdown

deployment-status-posthog Bot commented May 27, 2026

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-05-27 09:57 UTC Run
prod-us ✅ Deployed 2026-05-27 10:20 UTC Run
prod-eu ✅ Deployed 2026-05-27 10:24 UTC Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants