Skip to content

: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.

fix(insights): identify dashboards in limit events (#87141)

Vasco de Krijgerd7b5ee05a331
diff --git a/posthog/resource_limits/evaluator.py b/posthog/resource_limits/evaluator.py
index ae99c0b4abde..b4ef5d454c5b 100644
--- a/posthog/resource_limits/evaluator.py
+++ b/posthog/resource_limits/evaluator.py
@@ -1,3 +1,4 @@
+from collections.abc import Mapping
from typing import TYPE_CHECKING
from posthog.event_usage import report_user_action
@@ -33,6 +34,7 @@ def check_count_limit(
key: str,
current_count: int,
user: "User | None" = None,
+ resource_properties: Mapping[str, str | int] | None = None,
) -> None:
"""Emit a ``resource limit hit`` PostHog event when a team's next create
would put them at or above the catalog threshold for ``key``.
@@ -52,17 +54,21 @@ def check_count_limit(
return
if user is not None:
+ properties: dict[str, str | int | bool] = {
+ "limit_key": key,
+ "limit": limit,
+ "current_count": current_count,
+ "crossing_threshold": current_count + 1 == limit,
+ "team_id": team.id,
+ "organization_id": str(team.organization_id),
+ }
+ if resource_properties:
+ properties.update(resource_properties)
+
report_user_action(
user,
"resource limit hit",
- {
- "limit_key": key,
- "limit": limit,
- "current_count": current_count,
- "crossing_threshold": current_count + 1 == limit,
- "team_id": team.id,
- "organization_id": str(team.organization_id),
- },
+ properties,
team=team,
organization=team.organization,
)
diff --git a/posthog/resource_limits/test/test_evaluator.py b/posthog/resource_limits/test/test_evaluator.py
index b8dd8b4d92a4..748752899633 100644
--- a/posthog/resource_limits/test/test_evaluator.py
+++ b/posthog/resource_limits/test/test_evaluator.py
@@ -16,10 +16,10 @@ class TestGetLimit(BaseTest):
class TestCheckCountLimit(BaseTest):
@parameterized.expand(
[
- ("below_threshold", 10, False, None),
- ("one_below_threshold", 4999, True, True),
- ("at_threshold", 5000, True, False),
- ("far_above_threshold", 10_000, True, False),
+ ("below_threshold", 10, False, None, None),
+ ("one_below_threshold", 4999, True, True, {"dashboard_id": 42, "dashboard_name": "Dashboard"}),
+ ("at_threshold", 5000, True, False, None),
+ ("far_above_threshold", 10_000, True, False, None),
]
)
def test_emit_at_boundary(
@@ -28,6 +28,7 @@ class TestCheckCountLimit(BaseTest):
current_count: int,
expect_emit: bool,
expect_crossing: bool | None,
+ resource_properties: dict[str, str | int] | None,
) -> None:
with patch("posthog.resource_limits.evaluator.report_user_action") as report:
check_count_limit(
@@ -35,6 +36,7 @@ class TestCheckCountLimit(BaseTest):
key=LimitKey.MAX_DASHBOARDS_PER_TEAM,
current_count=current_count,
user=self.user,
+ resource_properties=resource_properties,
)
if not expect_emit:
report.assert_not_called()
@@ -50,6 +52,8 @@ class TestCheckCountLimit(BaseTest):
assert properties["crossing_threshold"] is expect_crossing
assert properties["team_id"] == self.team.id
assert properties["organization_id"] == str(self.team.organization_id)
+ if resource_properties:
+ assert {key: properties[key] for key in resource_properties} == resource_properties
def test_no_user_no_emit(self) -> None:
with patch("posthog.resource_limits.evaluator.report_user_action") as report:
diff --git a/products/dashboards/backend/facade/api.py b/products/dashboards/backend/facade/api.py
index ee6960e585cc..b93e54c55935 100644
--- a/products/dashboards/backend/facade/api.py
+++ b/products/dashboards/backend/facade/api.py
@@ -89,6 +89,11 @@ def _refs_in_given_order(dashboard_ids: Sequence[int]) -> tuple[DashboardRef, ..
)
+def dashboard_refs(dashboard_ids: Sequence[int]) -> tuple[DashboardRef, ...]:
+ """Dashboard IDs and names for callers that already validated the dashboard IDs."""
+ return _refs_in_given_order(dashboard_ids)
+
+
def unknown_dashboard_ids(dashboard_ids: Collection[int], *, team_id: int) -> list[int]:
"""Which of these ids are not a live dashboard of this team, in the order they were given.
@@ -316,6 +321,7 @@ __all__ = [
"InsightTilePlacement",
"MembershipChange",
"active_tile_count",
+ "dashboard_refs",
"hide_tiles_for_insights",
"insight_has_listed_tile",
"insight_ids_on_dashboard",
diff --git a/products/product_analytics/backend/presentation/insight.py b/products/product_analytics/backend/presentation/insight.py
index 674446b041d3..bf7512278844 100644
--- a/products/product_analytics/backend/presentation/insight.py
+++ b/products/product_analytics/backend/presentation/insight.py
@@ -152,6 +152,7 @@ from products.dashboards.backend.facade.api import (
DashboardTileBasicSerializer,
InsightTilePlacement,
active_tile_count,
+ dashboard_refs,
hide_tiles_for_insights,
insight_has_listed_tile,
insight_ids_on_dashboard,
@@ -726,6 +727,7 @@ class InsightSerializer(InsightBasicSerializer):
new_dashboard_ids = attrs.get("dashboards")
if new_dashboard_ids is not None:
team = self.context["get_team"]()
+ dashboard_names = {dashboard.id: dashboard.name for dashboard in dashboard_refs(new_dashboard_ids)}
existing_dashboard_ids: set[int] = set()
if self.instance is not None:
existing_dashboard_ids = set(
@@ -739,6 +741,10 @@ class InsightSerializer(InsightBasicSerializer):
key=LimitKey.MAX_INSIGHTS_PER_DASHBOARD,
current_count=active_tile_count(dashboard_id),
user=self.context["request"].user,
+ resource_properties={
+ "dashboard_id": dashboard_id,
+ "dashboard_name": dashboard_names.get(dashboard_id) or "",
+ },
)
return super().validate(attrs)
diff --git a/products/product_analytics/backend/tests/api/__snapshots__/test_insight.ambr b/products/product_analytics/backend/tests/api/__snapshots__/test_insight.ambr
index cb6350f2e098..56e4d75f5945 100644
--- a/products/product_analytics/backend/tests/api/__snapshots__/test_insight.ambr
+++ b/products/product_analytics/backend/tests/api/__snapshots__/test_insight.ambr
@@ -501,6 +501,108 @@
'''
# ---
# name: TestInsight.test_listing_insights_does_not_nplus1.10
+ '''
+ SELECT "posthog_team"."id",
+ "posthog_team"."uuid",
+ "posthog_team"."organization_id",
+ "posthog_team"."parent_team_id",
+ "posthog_team"."project_id",
+ "posthog_team"."api_token",
+ "posthog_team"."app_urls",
+ "posthog_team"."name",
+ "posthog_team"."slack_incoming_webhook",
+ "posthog_team"."created_at",
+ "posthog_team"."updated_at",
+ "posthog_team"."anonymize_ips",
+ "posthog_team"."completed_snippet_onboarding",
+ "posthog_team"."has_completed_onboarding_for",
+ "posthog_team"."onboarding_tasks",
+ "posthog_team"."ingested_event",
+ "posthog_team"."ingested_production_event",
+ "posthog_team"."ingested_production_event_last_checked_at",
+ "posthog_team"."person_processing_opt_out",
+ "posthog_team"."secret_api_token",
+ "posthog_team"."secret_api_token_backup",
+ "posthog_team"."session_recording_opt_in",
+ "posthog_team"."session_recording_sample_rate",
+ "posthog_team"."session_recording_minimum_duration_milliseconds",
+ "posthog_team"."session_recording_linked_flag",
+ "posthog_team"."session_recording_network_payload_capture_config",
+ "posthog_team"."session_recording_masking_config",
+ "posthog_team"."session_recording_url_trigger_config",
+ "posthog_team"."session_recording_url_blocklist_config",
+ "posthog_team"."session_recording_event_trigger_config",
+ "posthog_team"."session_recording_trigger_match_type_config",
+ "posthog_team"."session_recording_trigger_groups",
+ "posthog_team"."session_replay_config",
+ "posthog_team"."session_recording_retention_period",
+ "posthog_team"."event_retention_months",
+ "posthog_team"."conversations_enabled",
+ "posthog_team"."conversations_settings",
+ "posthog_team"."proactive_tasks_enabled",
+ "posthog_team"."survey_config",
+ "posthog_team"."surveys_opt_in",
+ "posthog_team"."product_tours_opt_in",
+ "posthog_team"."capture_console_log_opt_in",
+ "posthog_team"."capture_performance_opt_in",
+ "posthog_team"."capture_dead_clicks",
+ "posthog_team"."autocapture_opt_out",
+ "posthog_team"."autocapture_web_vitals_opt_in",
+ "posthog_team"."autocapture_web_vitals_allowed_metrics",
+ "posthog_team"."autocapture_exceptions_opt_in",
+ "posthog_team"."autocapture_exceptions_errors_to_ignore",
+ "posthog_team"."logs_settings",
+ "posthog_team"."llm_gateway_enabled_at",
+ "posthog_team"."llm_gateway_revoked_at",
+ "posthog_team"."llm_gateway_overspend_allowance_usd",
+ "posthog_team"."heatmaps_opt_in",
+ "posthog_team"."receive_org_level_activity_logs",
+ "posthog_team"."web_analytics_pre_aggregated_tables_enabled",
+ "posthog_team"."web_analytics_pre_aggregated_tables_version",
+ "posthog_team"."flags_persistence_default",
+ "posthog_team"."feature_flag_confirmation_enabled",
+ "posthog_team"."feature_flag_confirmation_message",
+ "posthog_team"."default_evaluation_environments_enabled",
+ "posthog_team"."require_evaluation_environment_tags",
+ "posthog_team"."default_evaluation_contexts_enabled",
+ "posthog_team"."require_evaluation_contexts",
+ "posthog_team"."session_recording_version",
+ "posthog_team"."signup_token",
+ "posthog_team"."is_demo",
+ "posthog_team"."access_control",
+ "posthog_team"."week_start_day",
+ "posthog_team"."inject_web_apps",
+ "posthog_team"."test_account_filters",
+ "posthog_team"."test_account_filters_default_checked",
+ "posthog_team"."path_cleaning_filters",
+ "posthog_team"."timezone",
+ "posthog_team"."data_attributes",
+ "posthog_team"."person_display_name_properties",
+ "posthog_team"."live_events_columns",
+ "posthog_team"."recording_domains",
+ "posthog_team"."human_friendly_comparison_periods",
+ "posthog_team"."cookieless_server_hash_mode",
+ "posthog_team"."primary_dashboard_id",
+ "posthog_team"."default_data_theme",
+ "posthog_team"."extra_settings",
+ "posthog_team"."modifiers",
+ "posthog_team"."correlation_config",
+ "posthog_team"."session_recording_retention_period_days",
+ "posthog_team"."external_data_workspace_id",
+ "posthog_team"."external_data_workspace_last_synced_at",
+ "posthog_team"."api_query_rate_limit",
+ "posthog_team"."drop_events_older_than",
+ "posthog_team"."base_currency",
+ "posthog_team"."experiment_recalculation_time",
+ "posthog_team"."default_experiment_confidence_level",
+ "posthog_team"."default_experiment_stats_method",
+ "posthog_team"."business_model"
+ FROM "posthog_team"
+ WHERE "posthog_team"."id" = 99999
+ LIMIT 21
+ '''
+# ---
+# name: TestInsight.test_listing_insights_does_not_nplus1.11
'''
SELECT "posthog_filesystem"."team_id",
"posthog_filesystem"."id",
@@ -525,7 +627,7 @@
AND "posthog_filesystem"."shortcut" IS NOT NULL))
'''
# ---
-# name: TestInsight.test_listing_insights_does_not_nplus1.11
+# name: TestInsight.test_listing_insights_does_not_nplus1.12
'''
SELECT "posthog_dashboardtile"."id",
"posthog_dashboardtile"."dashboard_id",
@@ -552,7 +654,7 @@
AND "posthog_dashboardtile"."insight_id" = 99999)
'''
# ---
-# name: TestInsight.test_listing_insights_does_not_nplus1.12
+# name: TestInsight.test_listing_insights_does_not_nplus1.13
'''
SELECT "posthog_dashboardtile"."id",
"posthog_dashboardtile"."dashboard_id",
@@ -579,7 +681,7 @@
AND "posthog_dashboardtile"."insight_id" = 99999)
'''
# ---
-# name: TestInsight.test_listing_insights_does_not_nplus1.13
+# name: TestInsight.test_listing_insights_does_not_nplus1.14
'''
SELECT "posthog_insightvariable"."created_by_id",
"posthog_insightvariable"."created_at",
@@ -598,7 +700,7 @@
WHERE "posthog_insightvariable"."team_id" = 99999
'''
# ---
-# name: TestInsight.test_listing_insights_does_not_nplus1.14
+# name: TestInsight.test_listing_insights_does_not_nplus1.15
'''
SELECT "posthog_dashboardtile"."dashboard_id" AS "dashboard_id"
FROM "posthog_dashboardtile"
@@ -609,7 +711,7 @@
AND "posthog_dashboardtile"."insight_id" = 99999)
'''
# ---
-# name: TestInsight.test_listing_insights_does_not_nplus1.15
+# name: TestInsight.test_listing_insights_does_not_nplus1.16
'''
SELECT "posthog_dashboard"."id",
"posthog_dashboard"."name",
@@ -642,7 +744,7 @@
5 /* ... */))
'''
# ---
-# name: TestInsight.test_listing_insights_does_not_nplus1.16
+# name: TestInsight.test_listing_insights_does_not_nplus1.17
'''
SELECT "posthog_tag"."name" AS "tag__name"
FROM "posthog_taggeditem"
@@ -650,14 +752,14 @@
WHERE "posthog_taggeditem"."insight_id" = 99999
'''
# ---
-# name: TestInsight.test_listing_insights_does_not_nplus1.17
+# name: TestInsight.test_listing_insights_does_not_nplus1.18
'''
SELECT COUNT(*) AS "__count"
FROM "posthog_dashboarditem"
WHERE NOT ("posthog_dashboarditem"."deleted")
'''
# ---
-# name: TestInsight.test_listing_insights_does_not_nplus1.18
+# name: TestInsight.test_listing_insights_does_not_nplus1.19
'''
SELECT "posthog_user"."id",
"posthog_user"."password",
@@ -703,51 +805,6 @@
AND "posthog_user"."id" = 99999)
'''
# ---
-# name: TestInsight.test_listing_insights_does_not_nplus1.19
- '''
- SELECT "posthog_organization"."id",
- "posthog_organization"."name",
- "posthog_organization"."slug",
- "posthog_organization"."logo_media_id",
- "posthog_organization"."created_at",
- "posthog_organization"."updated_at",
- "posthog_organization"."is_active",
- "posthog_organization"."is_not_active_reason",
- "posthog_organization"."session_cookie_age",
- "posthog_organization"."is_member_join_email_enabled",
- "posthog_organization"."is_ai_data_processing_approved",
- "posthog_organization"."is_ai_training_opted_in",
- "posthog_organization"."is_ai_training_locked",
- "posthog_organization"."is_ai_training_cta_shown",
- "posthog_organization"."enforce_2fa",
- "posthog_organization"."enforce_verified_domains",
- "posthog_organization"."members_can_invite",
- "posthog_organization"."members_can_create_projects",
- "posthog_organization"."members_can_use_personal_api_keys",
- "posthog_organization"."members_can_see_org_members",
- "posthog_organization"."allow_publicly_shared_resources",
- "posthog_organization"."default_role_id",
- "posthog_organization"."plugins_access_level",
- "posthog_organization"."for_internal_metrics",
- "posthog_organization"."default_experiment_stats_method",
- "posthog_organization"."default_anonymize_ips",
- "posthog_organization"."is_hipaa",
- "posthog_organization"."is_pending_deletion",
- "posthog_organization"."customer_id",
- "posthog_organization"."available_product_features",
- "posthog_organization"."usage",
- "posthog_organization"."never_drop_data",
- "posthog_organization"."customer_trust_scores",
- "posthog_organization"."has_active_subscription",
- "posthog_organization"."setup_section_2_completed",
- "posthog_organization"."personalization",
- "posthog_organization"."domain_whitelist",
- "posthog_organization"."is_platform"
- FROM "posthog_organization"
- WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid
- LIMIT 21
- '''
-# ---
# name: TestInsight.test_listing_insights_does_not_nplus1.2
'''
SELECT "posthog_team"."id",
@@ -890,6 +947,51 @@
'''
# ---
# name: TestInsight.test_listing_insights_does_not_nplus1.20
+ '''
+ SELECT "posthog_organization"."id",
+ "posthog_organization"."name",
+ "posthog_organization"."slug",
+ "posthog_organization"."logo_media_id",
+ "posthog_organization"."created_at",
+ "posthog_organization"."updated_at",
+ "posthog_organization"."is_active",
+ "posthog_organization"."is_not_active_reason",
+ "posthog_organization"."session_cookie_age",
+ "posthog_organization"."is_member_join_email_enabled",
+ "posthog_organization"."is_ai_data_processing_approved",
+ "posthog_organization"."is_ai_training_opted_in",
+ "posthog_organization"."is_ai_training_locked",
+ "posthog_organization"."is_ai_training_cta_shown",
+ "posthog_organization"."enforce_2fa",
+ "posthog_organization"."enforce_verified_domains",
+ "posthog_organization"."members_can_invite",
+ "posthog_organization"."members_can_create_projects",
+ "posthog_organization"."members_can_use_personal_api_keys",
+ "posthog_organization"."members_can_see_org_members",
+ "posthog_organization"."allow_publicly_shared_resources",
+ "posthog_organization"."default_role_id",
+ "posthog_organization"."plugins_access_level",
+ "posthog_organization"."for_internal_metrics",
+ "posthog_organization"."default_experiment_stats_method",
+ "posthog_organization"."default_anonymize_ips",
+ "posthog_organization"."is_hipaa",
+ "posthog_organization"."is_pending_deletion",
+ "posthog_organization"."customer_id",
+ "posthog_organization"."available_product_features",
+ "posthog_organization"."usage",
+ "posthog_organization"."never_drop_data",
+ "posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
+ "posthog_organization"."setup_section_2_completed",
+ "posthog_organization"."personalization",
+ "posthog_organization"."domain_whitelist",
+ "posthog_organization"."is_platform"
+ FROM "posthog_organization"
+ WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid
+ LIMIT 21
+ '''
+# ---
+# name: TestInsight.test_listing_insights_does_not_nplus1.21
'''
SELECT "posthog_team"."id",
"posthog_team"."uuid",
@@ -1030,7 +1132,7 @@
LIMIT 21
'''
# ---
-# name: TestInsight.test_listing_insights_does_not_nplus1.21
+# name: TestInsight.test_listing_insights_does_not_nplus1.22
'''
SELECT "posthog_organizationmembership"."id",
"posthog_organizationmembership"."organization_id",
@@ -1084,7 +1186,7 @@
LIMIT 21
'''
# ---
-# name: TestInsight.test_listing_insights_does_not_nplus1.22
+# name: TestInsight.test_listing_insights_does_not_nplus1.23
'''
SELECT "ee_accesscontrol"."id",
"ee_accesscontrol"."team_id",
@@ -1109,7 +1211,7 @@
AND "ee_accesscontrol"."team_id" = 99999))
'''
# ---
-# name: TestInsight.test_listing_insights_does_not_nplus1.23
+# name: TestInsight.test_listing_insights_does_not_nplus1.24
'''
SELECT "posthog_organizationmembership"."id",
"posthog_organizationmembership"."organization_id",
@@ -1161,7 +1263,7 @@
WHERE "posthog_organizationmembership"."user_id" = 99999
'''
# ---
-# name: TestInsight.test_listing_insights_does_not_nplus1.24
+# name: TestInsight.test_listing_insights_does_not_nplus1.25
'''
SELECT COUNT(*) AS "__count"
FROM "posthog_dashboarditem"
@@ -1170,7 +1272,7 @@
AND NOT ("posthog_dashboarditem"."deleted"))
'''
# ---
-# name: TestInsight.test_listing_insights_does_not_nplus1.25
+# name: TestInsight.test_listing_insights_does_not_nplus1.26
'''
SELECT "posthog_dashboarditem"."id",
"posthog_dashboarditem"."name",
@@ -1359,7 +1461,7 @@
LIMIT 100
'''
# ---
-# name: TestInsight.test_listing_insights_does_not_nplus1.26
+# name: TestInsight.test_listing_insights_does_not_nplus1.27
'''
SELECT "posthog_dashboardtile"."id",
"posthog_dashboardtile"."dashboard_id",
@@ -1377,7 +1479,7 @@
5 /* ... */))
'''
# ---
-# name: TestInsight.test_listing_insights_does_not_nplus1.27
+# name: TestInsight.test_listing_insights_does_not_nplus1.28
'''
SELECT "posthog_taggeditem"."id",
"posthog_taggeditem"."tag_id",
@@ -1400,7 +1502,7 @@
5 /* ... */)
'''
# ---
-# name: TestInsight.test_listing_insights_does_not_nplus1.28
+# name: TestInsight.test_listing_insights_does_not_nplus1.29
'''
SELECT "posthog_taggeditem"."id",
"posthog_taggeditem"."tag_id",
@@ -1579,6 +1681,19 @@
'''
# ---
# name: TestInsight.test_listing_insights_does_not_nplus1.7
+ '''
+ SELECT "posthog_dashboard"."id" AS "id",
+ "posthog_dashboard"."name" AS "name"
+ FROM "posthog_dashboard"
+ WHERE (NOT ("posthog_dashboard"."deleted")
+ AND "posthog_dashboard"."id" IN (1,
+ 2,
+ 3,
+ 4,
+ 5 /* ... */))
+ '''
+# ---
+# name: TestInsight.test_listing_insights_does_not_nplus1.8
'''
SELECT COUNT(*) AS "__count"
FROM "posthog_dashboardtile"
@@ -1591,7 +1706,7 @@
AND "posthog_dashboardtile"."deleted" IS NOT NULL))
'''
# ---
-# name: TestInsight.test_listing_insights_does_not_nplus1.8
+# name: TestInsight.test_listing_insights_does_not_nplus1.9
'''
SELECT "posthog_dashboard"."id",
"posthog_dashboard"."name",
@@ -1624,105 +1739,3 @@
5 /* ... */))
'''
# ---
-# name: TestInsight.test_listing_insights_does_not_nplus1.9
- '''
- SELECT "posthog_team"."id",
- "posthog_team"."uuid",
- "posthog_team"."organization_id",
- "posthog_team"."parent_team_id",
- "posthog_team"."project_id",
- "posthog_team"."api_token",
- "posthog_team"."app_urls",
- "posthog_team"."name",
- "posthog_team"."slack_incoming_webhook",
- "posthog_team"."created_at",
- "posthog_team"."updated_at",
- "posthog_team"."anonymize_ips",
- "posthog_team"."completed_snippet_onboarding",
- "posthog_team"."has_completed_onboarding_for",
- "posthog_team"."onboarding_tasks",
- "posthog_team"."ingested_event",
- "posthog_team"."ingested_production_event",
- "posthog_team"."ingested_production_event_last_checked_at",
- "posthog_team"."person_processing_opt_out",
- "posthog_team"."secret_api_token",
- "posthog_team"."secret_api_token_backup",
- "posthog_team"."session_recording_opt_in",
- "posthog_team"."session_recording_sample_rate",
- "posthog_team"."session_recording_minimum_duration_milliseconds",
- "posthog_team"."session_recording_linked_flag",
- "posthog_team"."session_recording_network_payload_capture_config",
- "posthog_team"."session_recording_masking_config",
- "posthog_team"."session_recording_url_trigger_config",
- "posthog_team"."session_recording_url_blocklist_config",
- "posthog_team"."session_recording_event_trigger_config",
- "posthog_team"."session_recording_trigger_match_type_config",
- "posthog_team"."session_recording_trigger_groups",
- "posthog_team"."session_replay_config",
- "posthog_team"."session_recording_retention_period",
- "posthog_team"."event_retention_months",
- "posthog_team"."conversations_enabled",
- "posthog_team"."conversations_settings",
- "posthog_team"."proactive_tasks_enabled",
- "posthog_team"."survey_config",
- "posthog_team"."surveys_opt_in",
- "posthog_team"."product_tours_opt_in",
- "posthog_team"."capture_console_log_opt_in",
- "posthog_team"."capture_performance_opt_in",
- "posthog_team"."capture_dead_clicks",
- "posthog_team"."autocapture_opt_out",
- "posthog_team"."autocapture_web_vitals_opt_in",
- "posthog_team"."autocapture_web_vitals_allowed_metrics",
- "posthog_team"."autocapture_exceptions_opt_in",
- "posthog_team"."autocapture_exceptions_errors_to_ignore",
- "posthog_team"."logs_settings",
- "posthog_team"."llm_gateway_enabled_at",
- "posthog_team"."llm_gateway_revoked_at",
- "posthog_team"."llm_gateway_overspend_allowance_usd",
- "posthog_team"."heatmaps_opt_in",
- "posthog_team"."receive_org_level_activity_logs",
- "posthog_team"."web_analytics_pre_aggregated_tables_enabled",
- "posthog_team"."web_analytics_pre_aggregated_tables_version",
- "posthog_team"."flags_persistence_default",
- "posthog_team"."feature_flag_confirmation_enabled",
- "posthog_team"."feature_flag_confirmation_message",
- "posthog_team"."default_evaluation_environments_enabled",
- "posthog_team"."require_evaluation_environment_tags",
- "posthog_team"."default_evaluation_contexts_enabled",
- "posthog_team"."require_evaluation_contexts",
- "posthog_team"."session_recording_version",
- "posthog_team"."signup_token",
- "posthog_team"."is_demo",
- "posthog_team"."access_control",
- "posthog_team"."week_start_day",
- "posthog_team"."inject_web_apps",
- "posthog_team"."test_account_filters",
- "posthog_team"."test_account_filters_default_checked",
- "posthog_team"."path_cleaning_filters",
- "posthog_team"."timezone",
- "posthog_team"."data_attributes",
- "posthog_team"."person_display_name_properties",
- "posthog_team"."live_events_columns",
- "posthog_team"."recording_domains",
- "posthog_team"."human_friendly_comparison_periods",
- "posthog_team"."cookieless_server_hash_mode",
- "posthog_team"."primary_dashboard_id",
- "posthog_team"."default_data_theme",
- "posthog_team"."extra_settings",
- "posthog_team"."modifiers",
- "posthog_team"."correlation_config",
- "posthog_team"."session_recording_retention_period_days",
- "posthog_team"."external_data_workspace_id",
- "posthog_team"."external_data_workspace_last_synced_at",
- "posthog_team"."api_query_rate_limit",
- "posthog_team"."drop_events_older_than",
- "posthog_team"."base_currency",
- "posthog_team"."experiment_recalculation_time",
- "posthog_team"."default_experiment_confidence_level",
- "posthog_team"."default_experiment_stats_method",
- "posthog_team"."business_model"
- FROM "posthog_team"
- WHERE "posthog_team"."id" = 99999
- LIMIT 21
- '''
-# ---
diff --git a/products/product_analytics/backend/tests/api/test_insight.py b/products/product_analytics/backend/tests/api/test_insight.py
index 4e9e76530d4a..4ba1f413061d 100644
--- a/products/product_analytics/backend/tests/api/test_insight.py
+++ b/products/product_analytics/backend/tests/api/test_insight.py
@@ -1624,6 +1624,21 @@ class TestInsight(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):
request=ANY,
)
+ @patch("posthog.resource_limits.evaluator.report_user_action")
+ @patch("products.product_analytics.backend.presentation.insight.active_tile_count", return_value=99)
+ def test_insight_dashboard_limit_includes_dashboard_context(
+ self, _mock_active_tile_count: mock.Mock, mock_report_user_action: mock.Mock
+ ) -> None:
+ dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "Important dashboard"})
+
+ self.dashboard_api.create_insight({"filters": {"insight": "TRENDS"}, "dashboards": [dashboard_id]})
+
+ limit_call = next(
+ call for call in mock_report_user_action.call_args_list if call.args[1] == "resource limit hit"
+ )
+ assert limit_call.args[2]["dashboard_id"] == dashboard_id
+ assert limit_call.args[2]["dashboard_name"] == "Important dashboard"
+
@patch("products.product_analytics.backend.presentation.insight.report_user_action")
def test_adding_insight_to_dashboard_fires_tile_added_event(self, mock_report_user_action: mock.Mock) -> None:
dashboard_id, _ = self.dashboard_api.create_dashboard({"name": "test"})