: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
fix(resource-transfer): exclude subscription export m2m from insight traversal (#83773)
Alin Ciciuc942d65a8194
diff --git a/posthog/models/resource_transfer/test/__snapshots__/test_visitor_field_snapshots.ambr b/posthog/models/resource_transfer/test/__snapshots__/test_visitor_field_snapshots.ambrindex c787bb4d812a..46442c84b22f 100644--- a/posthog/models/resource_transfer/test/__snapshots__/test_visitor_field_snapshots.ambr+++ b/posthog/models/resource_transfer/test/__snapshots__/test_visitor_field_snapshots.ambr@@ -115,6 +115,7 @@'refresh_attempt','refreshing','short_id',+ 'subscriptions_dashboard_export',])# ---# name: TestVisitorFieldSnapshots.test_excluded_fields_Survey@@ -417,7 +418,6 @@list(['created_by','last_modified_by',- 'subscriptions_dashboard_export','team',])# ---@@ -932,6 +932,7 @@'short_id','show_legend','subscription_set',+ 'subscriptions_dashboard_export','surveys_linked_insight','tagged_items','team_id',diff --git a/posthog/models/resource_transfer/test/test_inter_project_transferer.py b/posthog/models/resource_transfer/test/test_inter_project_transferer.pyindex 1e8d3143a36c..18aee9ea724c 100644--- a/posthog/models/resource_transfer/test/test_inter_project_transferer.py+++ b/posthog/models/resource_transfer/test/test_inter_project_transferer.py@@ -136,6 +136,33 @@ class TestBuildResourceDuplicationGraph(BaseTest):with self.assertRaises(TypeError):list(build_resource_duplication_graph(annotation, set()))+ def test_insight_with_dashboard_export_subscription_does_not_traverse_through_table(self) -> None:+ from datetime import datetime+ from zoneinfo import ZoneInfo++ from products.exports.backend.models.subscription import Subscription++ insight = Insight.objects.create(team=self.team, name="Exported insight")+ dashboard = Dashboard.objects.create(team=self.team, name="Subscribed dashboard")+ subscription = Subscription.objects.create(+ team=self.team,+ title="Weekly digest",+ dashboard=dashboard,+ target_type="email",+ target_value="[email protected]",+ frequency="weekly",+ interval=1,+ start_date=datetime(2022, 1, 1, 0, 0, 0, 0, tzinfo=ZoneInfo("UTC")),+ )+ subscription.dashboard_export_insights.add(insight)++ graph = list(build_resource_duplication_graph(insight, set()))+ model_names = {v.model.__name__ for v in graph}++ assert "Insight" in model_names+ assert "Subscription" not in model_names+ assert "Subscription_dashboard_export_insights" not in model_names+class TestDagSortDuplicationGraph(BaseTest):def test_dag_sorts_vertices_so_dependencies_come_first(self) -> None:diff --git a/posthog/models/resource_transfer/visitors/insight.py b/posthog/models/resource_transfer/visitors/insight.pyindex d8c915c62d57..d96ccd1c957f 100644--- a/posthog/models/resource_transfer/visitors/insight.py+++ b/posthog/models/resource_transfer/visitors/insight.py@@ -21,6 +21,7 @@ class InsightVisitor("dive_dashboard","dashboard","dashboards",+ "subscriptions_dashboard_export","short_id","filters_hash","refreshing",