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.

feat(error-tracking): replace recommendations tab with stacked banners (#120160)

Aleksander Błaszkiewiczdb28cdf9b031
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 1d243be43729..7ee8ad9e8a56 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -10630,18 +10630,30 @@ snapshots:
hash: v1.k794b7964.f0a877f43f21e22df68b7079fa79359bcd1774421569c912846e650b18739123.p_jatMQIVuHSCFR26V2kjNi5joMBE6cDMJIJ8X661UY
scenes-app-errortracking--list-page--light:
hash: v1.k794b7964.94a21a8bc2d65f2d2b07441d37154ef969dd4f9dc70eda4bd1391c2646976418.GIbgBEioBAUKocOZXziZzBfy7Dcai-26atGC7-e65t4
+ scenes-app-errortracking--list-page-with-alerts-banner--dark:
+ hash: v1.k794b7964.7bd3555bbb7ef93006430a1b1f59aa322efa142754eb8989bc4dc25fe9dfd1f6.o9HM8v53WWx7r3XlR76Em9ZmZ99b5Un5XAI5KQeE5zo
+ scenes-app-errortracking--list-page-with-alerts-banner--light:
+ hash: v1.k794b7964.647a774457544d17f025b0950e81ec0d8e51abdfc46f3745940fd9b49f42cdc7.L1kGKem8OGMt76wxDexkz2IFN8IvQWU4-rjiDSX5PzU
scenes-app-errortracking--list-page-with-ingestion-warning--dark:
hash: v1.k794b7964.f0a877f43f21e22df68b7079fa79359bcd1774421569c912846e650b18739123.wjLlwTCMltB2T4H0my67O8JvucglL-7nDiO-XF_OswU
scenes-app-errortracking--list-page-with-ingestion-warning--light:
hash: v1.k794b7964.bb5f04d2503f96fb01f04997d5399856d76e594dc7c9cfa58bbabb657bfc3def.XfpDiPEHxnS0I6-YWW72tibVGlsaUtQftzns99r2VPk
+ scenes-app-errortracking--list-page-with-rate-limits-banner--dark:
+ hash: v1.k794b7964.5399aeec1bb86cc8a629f0bfec5ae24cdb0005ff294ed6cea944dcb60058719b.mWKrKQRrs1aErDUvY8LuzXIgLEYgZhZMwCiDzIIcgDc
+ scenes-app-errortracking--list-page-with-rate-limits-banner--light:
+ hash: v1.k794b7964.5601fa6fc8daacb5c7bcee039783618bc412b4e9b99ac0e87b724ba74a1ca24b.4x2ftv3DN_y7bWtcrLCdxc_zN9m7q898vWL4JcEnyw0
scenes-app-errortracking--list-page-with-source-maps-banner--dark:
- hash: v1.k794b7964.ccc05c5077ab603e03162368e1ea86bfb2d435fcc4a595964a14d4885d43977b.0a5IoAWliacEzLoFqQnd4dHkiempLwJ-8EUwsvHJYNw
+ hash: v1.k794b7964.5c1f7558f79a3d4c7d075ecd4fd84bf060917e13629c0df26fa133f64bfdfab8.65JnjJ09bh15yzqFjeUHEIxMBWGJ0Z8OfmBzFCQMsKM
scenes-app-errortracking--list-page-with-source-maps-banner--light:
- hash: v1.k794b7964.aa9baa124bfa1588fd2314af7e14fe508415cb41c3f33b0ac37fb7fba69679af.g0rhpUievSc6awbRpxB38Mr2yEvlLwNaeXe_zHlm3jM
+ hash: v1.k794b7964.b24ffe1fee7932dfaa60f7e33c45d47292175915d4d6808e8b14ad385c79a4ab.HmCwMfIGY7bB3-m_Qm7qMUMw6weAb3YaB0DsmG8g4jw
scenes-app-errortracking--list-page-with-source-maps-banner-narrow--dark:
- hash: v1.k794b7964.996bb2e1fe84e212085369239bda51926db8afa9c82a9970785a524a422f61ec.sx19coyKsxgrjq7Qq6cIW052JhDkEdVS8fWSmaCyOEU
+ hash: v1.k794b7964.25fc21ca53021e7713863dbfced91bf8ffca3dbf971b43e4829a720af0dca39d.qV3HWzyRoqwXBPStErs7a6kOAS_nVtpsWf_l2hr3BGY
scenes-app-errortracking--list-page-with-source-maps-banner-narrow--light:
- hash: v1.k794b7964.0d639b3d461515345aa1ba3249353326dd0becf88f2994cb9c1044d6071c040f.QkMsikIvv8a3_9azW-uqFPxjsHJe8ze4VGD6Qfrky0U
+ hash: v1.k794b7964.c60191ccfaa5f77b9d3691f63a83e908e0344a64a9a91ca35ccfe0ab560ca943.1EYQMH1U8EtHyKqW9f5JAPgdno3UEGP_LycNCelaqjU
+ scenes-app-errortracking--list-page-with-stacked-banners--dark:
+ hash: v1.k794b7964.aff3898ea14ab795c09e66d34c11e4b968fb1694d5825107ccc6d804636b09c5.FD3T-3N8kACVT6lTwvI6zI5uK5eFvorATmyyoPA8IjY
+ scenes-app-errortracking--list-page-with-stacked-banners--light:
+ hash: v1.k794b7964.c9b1b9e1cbd1f222b720bfa49136df00605cc402ac231399392643f72b17e0cf.py6UFtlSm-v_ev6kF1NcOlVo7nMjm6de2ulS61Fh_8U
scenes-app-errortracking-linkedreports--fix-proposed--dark:
hash: v1.k794b7964.1b50022f8fafb4684dacd255b966bd2969f79e84d5c7c7daeb68291772a1e36d.9uyjrwufsjMCFx9c7cjsoIyabB3A4ZBnPSVUouM0RZE
scenes-app-errortracking-linkedreports--fix-proposed--light:
diff --git a/frontend/src/lib/api-ratchet-baseline.txt b/frontend/src/lib/api-ratchet-baseline.txt
index 077d2ffd9f80..cf207f4164cc 100644
--- a/frontend/src/lib/api-ratchet-baseline.txt
+++ b/frontend/src/lib/api-ratchet-baseline.txt
@@ -89,7 +89,6 @@ errorTrackingIssueMerge projects/{}/error_tracking/issues/{}/merge
errorTrackingIssueSplit projects/{}/error_tracking/issues/{}/split
errorTrackingIssues projects/{}/error_tracking/issues
errorTrackingIssuesExists projects/{}/error_tracking/issues/exists
-errorTrackingRecommendations projects/{}/error_tracking/recommendations
errorTrackingRelease projects/{}/error_tracking/releases/{}
errorTrackingReleases projects/{}/error_tracking/releases
errorTrackingSpikeDetectionConfig projects/{}/error_tracking/spike_detection_config
diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts
index 4945fbf67ad3..8640c6d9abb4 100644
--- a/frontend/src/lib/api.ts
+++ b/frontend/src/lib/api.ts
@@ -215,7 +215,6 @@ import type {
ErrorTrackingRuleType,
} from 'products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rules/types'
import type { SymbolSetOrder } from 'products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/symbol_sets/symbolSetLogic'
-import type { ErrorTrackingRecommendation } from 'products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/types'
import type { CopyFlagsResponseApi } from 'products/feature_flags/frontend/generated/api.schemas'
import type {
GitHubBranchesResponseApi,
@@ -1350,14 +1349,6 @@ export class ApiRequest {
return this.errorTracking(teamId).addPathComponent('spike_events')
}
- public errorTrackingRecommendations(teamId?: TeamType['id']): ApiRequest {
- return this.errorTracking(teamId).addPathComponent('recommendations')
- }
-
- public errorTrackingRecommendation(id: string, teamId?: TeamType['id']): ApiRequest {
- return this.errorTrackingRecommendations(teamId).addPathComponent(id)
- }
-
public quickFilters(teamId?: TeamType['id']): ApiRequest {
return this.teamProjectDetail(teamId).addPathComponent('quick_filters')
}
@@ -4142,31 +4133,6 @@ const api = {
return await new ApiRequest().errorTrackingRules(ruleType).get()
},
- async listRecommendations({ poll = false }: { poll?: boolean } = {}): Promise<{
- results: ErrorTrackingRecommendation[]
- }> {
- return await new ApiRequest().errorTrackingRecommendations().withQueryString({ poll }).get()
- },
-
- async dismissRecommendation(id: string): Promise<ErrorTrackingRecommendation> {
- return await new ApiRequest().errorTrackingRecommendation(id).withAction('dismiss').create()
- },
-
- async restoreRecommendation(id: string): Promise<ErrorTrackingRecommendation> {
- return await new ApiRequest().errorTrackingRecommendation(id).withAction('restore').create()
- },
-
- async refreshRecommendation(
- id: string,
- { force = true }: { force?: boolean } = {}
- ): Promise<ErrorTrackingRecommendation> {
- return await new ApiRequest()
- .errorTrackingRecommendation(id)
- .withAction('refresh')
- .withQueryString({ force })
- .create()
- },
-
async createRule(
ruleType: ErrorTrackingRuleType,
{ id: _, ...data }: ErrorTrackingRule
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index d6f3f3b06a5d..9b071a97f644 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -316,7 +316,6 @@ export const FEATURE_FLAGS = {
ERROR_TRACKING_RATE_LIMITING: 'error-tracking-rate-limiting', // owner: @ablaszkiewicz #team-error-tracking
ERROR_TRACKING_RATE_LIMITING_BYPASS: 'error-tracking-rate-limiting-bypass', // owner: @ablaszkiewicz #team-error-tracking
ERROR_TRACKING_RATE_LIMITING_PER_ISSUE: 'error-tracking-rate-limiting-per-issue', // owner: @ablaszkiewicz #team-error-tracking
- ERROR_TRACKING_RECOMMENDATIONS: 'error-tracking-recommendations', // owner: @ablaszkiewicz #team-error-tracking
ERROR_TRACKING_RELATED_ISSUES: 'error-tracking-related-issues', // owner: #team-error-tracking
ERROR_TRACKING_WEEKLY_DIGEST: 'error-tracking-weekly-digest', // owner: #team-error-tracking
EXPERIMENT_BEHAVIOR_COMPARISON: 'experiment-behavior-comparison', // owner: @mp-hog #team-experiments
diff --git a/frontend/src/products.tsx b/frontend/src/products.tsx
index f1f495b120fa..3deffe97df13 100644
--- a/frontend/src/products.tsx
+++ b/frontend/src/products.tsx
@@ -2716,14 +2716,7 @@ export const getTreeItemsProducts = (): FileSystemImport[] => [
] as FileSystemIconColor,
href: urls.errorTracking(),
searchKeywords: ['exceptions', 'crashes', 'bugs', 'stack traces'],
- searchTabs: [
- { name: 'Insights', href: urls.errorTracking({ activeTab: 'insights' }) },
- {
- name: 'Recommendations',
- href: urls.errorTracking({ activeTab: 'recommendations' }),
- flag: FEATURE_FLAGS.ERROR_TRACKING_RECOMMENDATIONS,
- },
- ],
+ searchTabs: [{ name: 'Insights', href: urls.errorTracking({ activeTab: 'insights' }) }],
sceneKey: 'ErrorTracking',
sceneKeys: ['ErrorTracking', 'ErrorTrackingIssue', 'ErrorTrackingFingerprint'],
},
diff --git a/frontend/src/scenes/health/categoryDetail/categoryDetailConfig.ts b/frontend/src/scenes/health/categoryDetail/categoryDetailConfig.ts
index 1dfc69de91e3..2ed7ea4df02d 100644
--- a/frontend/src/scenes/health/categoryDetail/categoryDetailConfig.ts
+++ b/frontend/src/scenes/health/categoryDetail/categoryDetailConfig.ts
@@ -58,7 +58,7 @@ export const CATEGORY_DETAIL_CONFIG: Partial<Record<HealthIssueCategory, Categor
error_tracking: {
docsUrl: 'https://posthog.com/docs/error-tracking',
guidance: 'These checks ensure your error tracking setup captures exceptions with readable stack traces.',
- redirectUrl: urls.errorTracking({ activeTab: 'recommendations' }),
+ redirectUrl: urls.errorTracking(),
tableComponent: ErrorTrackingHealthTable,
},
}
diff --git a/products/error_tracking/backend/facade/contracts.py b/products/error_tracking/backend/facade/contracts.py
index 2dd8aa09b0a6..b194fa09816e 100644
--- a/products/error_tracking/backend/facade/contracts.py
+++ b/products/error_tracking/backend/facade/contracts.py
@@ -18,7 +18,7 @@ from pydantic.dataclasses import dataclass
ERROR_TRACKING_ISSUE_SEVERITIES = ("low", "medium", "high", "critical")
-# Keep in sync with products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/sourceMapsFixWizardLogic.ts.
+# Keep in sync with products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/sourceMapsFixWizardLogic.ts.
SOURCE_MAPS_DOCS_URL = "https://posthog.com/docs/error-tracking/upload-source-maps"
diff --git a/products/error_tracking/backend/logic/recommendations/__init__.py b/products/error_tracking/backend/logic/recommendations/__init__.py
index 8afe5fb43f3f..75a8d562e807 100644
--- a/products/error_tracking/backend/logic/recommendations/__init__.py
+++ b/products/error_tracking/backend/logic/recommendations/__init__.py
@@ -1,6 +1,5 @@
from .alerts import AlertsRecommendation
from .base import Recommendation
-from .long_running_issues import LongRunningIssuesRecommendation
from .rate_limits import RateLimitsRecommendation
from .source_maps import SourceMapsRecommendation
@@ -8,7 +7,6 @@ from .source_maps import SourceMapsRecommendation
# products/error_tracking/mcp/prompts/error-tracking-recommendations-list.md — keep it in sync when adding/changing a type.
RECOMMENDATIONS: list[Recommendation] = [
AlertsRecommendation(),
- LongRunningIssuesRecommendation(),
RateLimitsRecommendation(),
SourceMapsRecommendation(),
]
diff --git a/products/error_tracking/backend/logic/recommendations/long_running_issues.py b/products/error_tracking/backend/logic/recommendations/long_running_issues.py
deleted file mode 100644
index aad238ee30d0..000000000000
--- a/products/error_tracking/backend/logic/recommendations/long_running_issues.py
+++ /dev/null
@@ -1,126 +0,0 @@
-from datetime import timedelta
-from typing import Any
-
-from posthog.schema import ProductKey
-
-from posthog.clickhouse.client import sync_execute
-from posthog.clickhouse.materialized_columns import get_materialized_column_for_property
-from posthog.clickhouse.query_tagging import Feature, tag_queries
-from posthog.clickhouse.workload import Workload
-from posthog.models.team.team import Team
-
-from products.error_tracking.backend.models import ErrorTrackingIssue
-
-from .base import Recommendation
-
-ISSUE_LIMIT = 5
-
-BATCH_QUERY = """
- SELECT
- events.team_id AS team_id,
- issue_state.issue_id AS issue_id,
- any(issue_state.first_seen) AS first_seen,
- count() AS occurrences
- FROM events
- INNER JOIN (
- SELECT
- team_id,
- fp_hash,
- tupleElement(state, 1) AS issue_id,
- tupleElement(state, 2) AS first_seen,
- tupleElement(state, 3) AS issue_status
- FROM (
- SELECT
- team_id,
- cityHash64(fingerprint) AS fp_hash,
- argMax((issue_id, first_seen, issue_status), version) AS state
- FROM error_tracking_fingerprint_issue_state
- WHERE team_id IN %(team_ids)s
- GROUP BY team_id, fp_hash
- HAVING argMax(is_deleted, version) = 0
- SETTINGS optimize_aggregation_in_order=1
- )
- ) AS issue_state
- ON events.team_id = issue_state.team_id
- AND cityHash64({fingerprint_expr}) = issue_state.fp_hash
- WHERE events.team_id IN %(team_ids)s
- AND events.event = '$exception'
- AND events.timestamp >= now() - INTERVAL 7 DAY
- AND issue_state.issue_status = 'active'
- AND issue_state.first_seen < now() - INTERVAL 7 DAY
- GROUP BY team_id, issue_id
- ORDER BY team_id ASC, first_seen ASC
- LIMIT %(issue_limit)s BY team_id
-"""
-
-
-def _fingerprint_expr() -> str:
- column = get_materialized_column_for_property("events", "properties", "$exception_fingerprint")
- if column is None:
- return "JSONExtractString(events.properties, '$exception_fingerprint')"
- if column.is_nullable:
- return f"ifNull(events.`{column.name}`, '')"
- return f"events.`{column.name}`"
-
-
-class LongRunningIssuesRecommendation(Recommendation):
- type = "long_running_issues"
- refresh_interval = timedelta(hours=6)
-
- def compute_batch(self, team_ids: list[int]) -> dict[int, dict[str, Any]]:
- tag_queries(
- product=ProductKey.ERROR_TRACKING,
- feature=Feature.ENRICHMENT,
- name="recommendations:long_running_issues",
- )
-
- rows = sync_execute(
- BATCH_QUERY.format(fingerprint_expr=_fingerprint_expr()),
- {"team_ids": team_ids, "issue_limit": ISSUE_LIMIT},
- workload=Workload.OFFLINE,
- )
-
- issues_by_id = {
- issue.id: issue
- # nosemgrep: idor-lookup-without-team (team_id__in scopes the lookup; background sweep, not user input)
- for issue in ErrorTrackingIssue.objects.filter(
- team_id__in=team_ids, id__in=[issue_id for _, issue_id, _, _ in rows]
- ).only("id", "name", "description", "status")
- }
-
- metas: dict[int, dict[str, Any]] = {team_id: {"issues": []} for team_id in team_ids}
- for team_id, issue_id, first_seen, occurrences in rows:
- issue = issues_by_id.get(issue_id)
- # Stale state rows can reference issues deleted from Postgres — skip them.
- if issue is None or first_seen is None:
- continue
- metas[team_id]["issues"].append(
- {
- "id": str(issue_id),
- "name": issue.name or "Untitled issue",
- "description": issue.description,
- "created_at": first_seen.isoformat(),
- "occurrences": occurrences,
- "status": issue.status,
- }
- )
- return metas
-
- def is_completed(self, meta: dict[str, Any]) -> bool:
- return not meta.get("issues")
-
- def enrich(self, team: Team, meta: dict[str, Any]) -> dict[str, Any]:
- issues = meta.get("issues") or []
- if not issues:
- return meta
-
- statuses = {
- str(row_id): row_status
- for row_id, row_status in ErrorTrackingIssue.objects.filter(
- team=team, id__in=[i["id"] for i in issues]
- ).values_list("id", "status")
- }
- return {
- **meta,
- "issues": [{**issue, "status": statuses.get(issue["id"], issue.get("status"))} for issue in issues],
- }
diff --git a/products/error_tracking/backend/logic/recommendations/refresh.py b/products/error_tracking/backend/logic/recommendations/refresh.py
index c86ff348d18b..30d8193af7b4 100644
--- a/products/error_tracking/backend/logic/recommendations/refresh.py
+++ b/products/error_tracking/backend/logic/recommendations/refresh.py
@@ -122,8 +122,7 @@ def refresh_team_recommendations(team_id: int) -> int:
Staleness is governed by each recommendation's ``refresh_interval``, so an hourly
caller only recomputes the types that have actually gone stale (e.g. source_maps
- and long_running_issues every 6h). Used by the on-demand API path, which
- must not block on compute.
+ every 6h). Used by the on-demand API path, which must not block on compute.
Returns the number of recommendations kicked.
"""
diff --git a/products/error_tracking/backend/logic/recommendations/store.py b/products/error_tracking/backend/logic/recommendations/store.py
index ca4c3db3a3ce..ddbbd34502e3 100644
--- a/products/error_tracking/backend/logic/recommendations/store.py
+++ b/products/error_tracking/backend/logic/recommendations/store.py
@@ -18,7 +18,13 @@ class UnknownRecommendationTypeError(Exception):
def list_recommendations(team_id: int) -> list[ErrorTrackingRecommendation]:
- return list(ErrorTrackingRecommendation.objects.filter(team_id=team_id).select_related("team").order_by("type"))
+ # Rows of a removed recommendation type stay in Postgres. Filter on the registry so that
+ # the API does not return a type that has no implementation to compute or enrich it.
+ return list(
+ ErrorTrackingRecommendation.objects.filter(team_id=team_id, type__in=list(RECOMMENDATIONS_BY_TYPE))
+ .select_related("team")
+ .order_by("type")
+ )
def _get(team_id: int, recommendation_id: UUID) -> ErrorTrackingRecommendation:
diff --git a/products/error_tracking/backend/temporal/recommendations_refresh/test/test_recommendations_refresh.py b/products/error_tracking/backend/temporal/recommendations_refresh/test/test_recommendations_refresh.py
index 9d368713bfcd..678448f881f7 100644
--- a/products/error_tracking/backend/temporal/recommendations_refresh/test/test_recommendations_refresh.py
+++ b/products/error_tracking/backend/temporal/recommendations_refresh/test/test_recommendations_refresh.py
@@ -14,14 +14,7 @@ from temporalio.worker import UnsandboxedWorkflowRunner, Worker
from posthog.models import Team
-from products.error_tracking.backend.logic.recommendations.long_running_issues import LongRunningIssuesRecommendation
-from products.error_tracking.backend.models import (
- ErrorTrackingIssue,
- ErrorTrackingIssueFingerprintV2,
- ErrorTrackingRecommendation,
- sync_issues_to_clickhouse,
-)
-from products.error_tracking.backend.sql import TRUNCATE_ERROR_TRACKING_FINGERPRINT_ISSUE_STATE_TABLE_SQL
+from products.error_tracking.backend.models import ErrorTrackingRecommendation
from products.error_tracking.backend.temporal.recommendations_refresh.activities import (
get_team_batches_activity,
pack_team_batches,
@@ -40,7 +33,6 @@ from products.error_tracking.backend.temporal.recommendations_refresh.workflow i
_ALERTS_COMPUTE_BATCH = (
"products.error_tracking.backend.logic.recommendations.alerts.AlertsRecommendation.compute_batch"
)
-_LONG_RUNNING_COMPUTE_BATCH = "products.error_tracking.backend.logic.recommendations.long_running_issues.LongRunningIssuesRecommendation.compute_batch"
_SOURCE_MAPS_COMPUTE_BATCH = (
"products.error_tracking.backend.logic.recommendations.source_maps.SourceMapsRecommendation.compute_batch"
)
@@ -49,7 +41,6 @@ _RATE_LIMITS_COMPUTE_BATCH = (
)
_ALERTS_META = {"alerts": [{"key": "error-tracking-issue-created", "enabled": False}]}
-_LONG_RUNNING_META: dict = {"issues": []}
_SOURCE_MAPS_META = {"total_frames": 0, "unresolved_frames": 0, "unresolved_pct": 0.0}
_RATE_LIMITS_META = {"rate_limits": [{"key": "project", "enabled": False}, {"key": "per_issue", "enabled": False}]}
@@ -104,48 +95,45 @@ class TestPackTeamBatches:
class TestRefreshRecommendationsBatchActivity(APIBaseTest):
@patch(_RATE_LIMITS_COMPUTE_BATCH, side_effect=_batch_meta(_RATE_LIMITS_META))
@patch(_SOURCE_MAPS_COMPUTE_BATCH, side_effect=_batch_meta(_SOURCE_MAPS_META))
- @patch(_LONG_RUNNING_COMPUTE_BATCH, side_effect=_batch_meta(_LONG_RUNNING_META))
@patch(_ALERTS_COMPUTE_BATCH, side_effect=_batch_meta(_ALERTS_META))
- def test_computes_recommendations_for_all_teams(self, _alerts, _long, _source, _rate_limits):
+ def test_computes_recommendations_for_all_teams(self, _alerts, _source, _rate_limits):
team_b = Team.objects.create(organization=self.organization, name="Team B")
result = _run_batch_activity(RefreshBatchInputs(team_ids=[self.team.id, team_b.id]))
assert result.teams_processed == 2
- assert result.recommendations_kicked == 8
+ assert result.recommendations_kicked == 6
for team_id in (self.team.id, team_b.id):
recs = ErrorTrackingRecommendation.objects.filter(team_id=team_id)
- assert recs.count() == 4
+ assert recs.count() == 3
for rec in recs:
assert rec.status == ErrorTrackingRecommendation.Status.READY
assert rec.computed_at is not None
@patch(_RATE_LIMITS_COMPUTE_BATCH, side_effect=_batch_meta(_RATE_LIMITS_META))
@patch(_SOURCE_MAPS_COMPUTE_BATCH, side_effect=_batch_meta(_SOURCE_MAPS_META))
- @patch(_LONG_RUNNING_COMPUTE_BATCH, side_effect=_batch_meta(_LONG_RUNNING_META))
@patch(_ALERTS_COMPUTE_BATCH, side_effect=_batch_meta(_ALERTS_META))
- def test_rerun_only_recomputes_stale_recommendations(self, _alerts, _long, _source, _rate_limits):
+ def test_rerun_only_recomputes_stale_recommendations(self, _alerts, _source, _rate_limits):
team_b = Team.objects.create(organization=self.organization, name="Team B")
batch = RefreshBatchInputs(team_ids=[self.team.id, team_b.id])
first = _run_batch_activity(batch)
- assert first.recommendations_kicked == 8
+ assert first.recommendations_kicked == 6
second = _run_batch_activity(batch)
# `alerts` and `rate_limits` have no refresh_interval, so they recompute for both teams;
- # long_running_issues and source_maps (both 6h) are still fresh and are skipped.
+ # source_maps (6h) is still fresh and is skipped.
assert second.recommendations_kicked == 4
@patch(_RATE_LIMITS_COMPUTE_BATCH, side_effect=_batch_meta(_RATE_LIMITS_META))
@patch(_SOURCE_MAPS_COMPUTE_BATCH, side_effect=_batch_meta(_SOURCE_MAPS_META))
- @patch(_LONG_RUNNING_COMPUTE_BATCH, side_effect=_batch_meta(_LONG_RUNNING_META))
@patch(_ALERTS_COMPUTE_BATCH, side_effect=Exception("boom"))
- def test_failing_recommendation_reverts_claims_and_spares_others(self, _alerts, _long, _source, _rate_limits):
+ def test_failing_recommendation_reverts_claims_and_spares_others(self, _alerts, _source, _rate_limits):
team_b = Team.objects.create(organization=self.organization, name="Team B")
result = _run_batch_activity(RefreshBatchInputs(team_ids=[self.team.id, team_b.id]))
- assert result.recommendations_kicked == 6
+ assert result.recommendations_kicked == 4
alerts_rows = ErrorTrackingRecommendation.objects.filter(type="alerts")
assert alerts_rows.count() == 2
for row in alerts_rows:
@@ -154,9 +142,8 @@ class TestRefreshRecommendationsBatchActivity(APIBaseTest):
@patch(_RATE_LIMITS_COMPUTE_BATCH, side_effect=_batch_meta(_RATE_LIMITS_META))
@patch(_SOURCE_MAPS_COMPUTE_BATCH, side_effect=_batch_meta(_SOURCE_MAPS_META))
- @patch(_LONG_RUNNING_COMPUTE_BATCH, side_effect=_batch_meta(_LONG_RUNNING_META))
@patch(_ALERTS_COMPUTE_BATCH, side_effect=_batch_meta(_ALERTS_META))
- def test_skips_deleted_teams_without_failing_batch(self, _alerts, _long, _source, _rate_limits):
+ def test_skips_deleted_teams_without_failing_batch(self, _alerts, _source, _rate_limits):
# ClickHouse retains events for teams later deleted from Postgres; the batch must
# process surviving teams and not blow up on the missing team_id foreign key.
deleted_team = Team.objects.create(organization=self.organization, name="Doomed")
@@ -167,15 +154,14 @@ class TestRefreshRecommendationsBatchActivity(APIBaseTest):
# teams_processed reflects only the surviving team, not the raw input count.
assert result.teams_processed == 1
- assert result.recommendations_kicked == 4
- assert ErrorTrackingRecommendation.objects.filter(team_id=self.team.id).count() == 4
+ assert result.recommendations_kicked == 3
+ assert ErrorTrackingRecommendation.objects.filter(team_id=self.team.id).count() == 3
assert ErrorTrackingRecommendation.objects.filter(team_id=deleted_team_id).count() == 0
@patch(_RATE_LIMITS_COMPUTE_BATCH, side_effect=_batch_meta(_RATE_LIMITS_META))
@patch(_SOURCE_MAPS_COMPUTE_BATCH, side_effect=_batch_meta(_SOURCE_MAPS_META))
- @patch(_LONG_RUNNING_COMPUTE_BATCH, side_effect=_batch_meta(_LONG_RUNNING_META))
@patch(_ALERTS_COMPUTE_BATCH, side_effect=_batch_meta(_ALERTS_META))
- def test_all_teams_deleted_kicks_nothing(self, _alerts, _long, _source, _rate_limits):
+ def test_all_teams_deleted_kicks_nothing(self, _alerts, _source, _rate_limits):
deleted_team = Team.objects.create(organization=self.organization, name="Doomed")
deleted_team_id = deleted_team.id
deleted_team.delete()
@@ -188,82 +174,16 @@ class TestRefreshRecommendationsBatchActivity(APIBaseTest):
@patch(_RATE_LIMITS_COMPUTE_BATCH, side_effect=_batch_meta(_RATE_LIMITS_META))
@patch(_SOURCE_MAPS_COMPUTE_BATCH, side_effect=_batch_meta(_SOURCE_MAPS_META))
- @patch(_LONG_RUNNING_COMPUTE_BATCH, side_effect=_batch_meta(_LONG_RUNNING_META))
@patch(_ALERTS_COMPUTE_BATCH, side_effect=lambda team_ids: {})
- def test_missing_meta_reverts_claim(self, _alerts, _long, _source, _rate_limits):
+ def test_missing_meta_reverts_claim(self, _alerts, _source, _rate_limits):
result = _run_batch_activity(RefreshBatchInputs(team_ids=[self.team.id]))
- assert result.recommendations_kicked == 3
+ assert result.recommendations_kicked == 2
alerts_row = ErrorTrackingRecommendation.objects.get(team_id=self.team.id, type="alerts")
assert alerts_row.status == ErrorTrackingRecommendation.Status.READY
assert alerts_row.computed_at is None
-class TestLongRunningIssuesComputeBatch(ClickhouseTestMixin, APIBaseTest):
- def setUp(self):
- super().setUp()
- from posthog.clickhouse.client import sync_execute
-
- sync_execute(TRUNCATE_ERROR_TRACKING_FINGERPRINT_ISSUE_STATE_TABLE_SQL())
-
- def _create_issue_with_events(
- self, team: Team, fingerprint: str, first_seen, event_count: int, **issue_kwargs
- ) -> ErrorTrackingIssue:
- issue = ErrorTrackingIssue.objects.create(team=team, **issue_kwargs)
- ErrorTrackingIssueFingerprintV2.objects.create(team=team, issue=issue, fingerprint=fingerprint)
- ErrorTrackingIssueFingerprintV2.objects.filter(issue=issue).update(first_seen=first_seen)
- sync_issues_to_clickhouse(issue_ids=[issue.id], team_id=team.id)
-
- for i in range(event_count):
- _create_event(
- distinct_id=f"u{i}",
- event="$exception",
- team=team,
- timestamp=timezone.now().isoformat(),
- properties={"$exception_fingerprint": fingerprint},
- )
- return issue
-
- def test_returns_long_running_issues_per_team(self):
- team_b = Team.objects.create(organization=self.organization, name="Team B")
- team_quiet = Team.objects.create(organization=self.organization, name="Quiet")
-
- old = timezone.now() - timedelta(days=30)
- long_running = self._create_issue_with_events(
- self.team, "fp_old", old, event_count=3, name="Old issue", description="Still firing"
- )
- # Recent issue: first_seen inside the 7 day window, so not long-running.
- self._create_issue_with_events(self.team, "fp_new", timezone.now(), event_count=2, name="New issue")
- # Resolved long-running issue on another team: excluded by status.
- self._create_issue_with_events(
- team_b, "fp_resolved", old, event_count=2, name="Done", status=ErrorTrackingIssue.Status.RESOLVED
- )
- flush_persons_and_events()
-
- metas = LongRunningIssuesRecommendation().compute_batch([self.team.id, team_b.id, team_quiet.id])
-
- assert set(metas.keys()) == {self.team.id, team_b.id, team_quiet.id}
- assert metas[team_b.id] == {"issues": []}
- assert metas[team_quiet.id] == {"issues": []}
-
- issues = metas[self.team.id]["issues"]
- assert len(issues) == 1
- assert issues[0]["id"] == str(long_running.id)
- assert issues[0]["name"] == "Old issue"
- assert issues[0]["description"] == "Still firing"
- assert issues[0]["occurrences"] == 3
- assert issues[0]["status"] == ErrorTrackingIssue.Status.ACTIVE
-
- def test_compute_delegates_to_batch(self):
- old = timezone.now() - timedelta(days=30)
- issue = self._create_issue_with_events(self.team, "fp_old", old, event_count=1, name="Old issue")
- flush_persons_and_events()
-
- meta = LongRunningIssuesRecommendation().compute(self.team)
-
- assert [i["id"] for i in meta["issues"]] == [str(issue.id)]
-
-
async def _run_refresh_workflow(
inputs: RecommendationsRefreshInputs | None, team_batches: list[list[int]]
) -> tuple[RecommendationsRefreshResult, list[list[int]]]:
diff --git a/products/error_tracking/backend/tests/api/test_recommendations.py b/products/error_tracking/backend/tests/api/test_recommendations.py
index 91e3f8ec942c..023b1651bc09 100644
--- a/products/error_tracking/backend/tests/api/test_recommendations.py
+++ b/products/error_tracking/backend/tests/api/test_recommendations.py
@@ -2,31 +2,23 @@ from datetime import timedelta
from uuid import uuid4
import time_machine
-from posthog.test.base import APIBaseTest, ClickhouseTestMixin, _create_event, flush_persons_and_events
+from posthog.test.base import APIBaseTest
from unittest.mock import patch
from django.utils import timezone
from rest_framework import status
-from posthog.models.utils import uuid7
-
from products.cdp.backend.facade.models import HogFunction
from products.error_tracking.backend.logic.recommendations.alerts import AlertsRecommendation
-from products.error_tracking.backend.logic.recommendations.long_running_issues import LongRunningIssuesRecommendation
from products.error_tracking.backend.logic.recommendations.rate_limits import RateLimitsRecommendation
from products.error_tracking.backend.logic.recommendations.source_maps import SourceMapsRecommendation
from products.error_tracking.backend.models import (
- ErrorTrackingIssue,
- ErrorTrackingIssueFingerprintV2,
ErrorTrackingRecommendation,
ErrorTrackingSettings,
ErrorTrackingStackFrame,
- sync_issues_to_clickhouse,
)
-from ee.clickhouse.materialized_columns.columns import materialize
-
MOCK_ALERTS_META = {
"alerts": [
{"key": "error-tracking-issue-created", "enabled": False},
@@ -41,18 +33,10 @@ MOCK_ALERTS_META_UPDATED = {
{"key": "error-tracking-issue-spiking", "enabled": True},
]
}
+MOCK_SOURCE_MAPS_META = {"total_frames": 0, "unresolved_frames": 0, "unresolved_pct": 0.0}
-def _days_ago(n: int) -> str:
- return (timezone.now() - timedelta(days=n)).isoformat()
-
-
-class TestRecommendationsAPI(ClickhouseTestMixin, APIBaseTest):
- @classmethod
- def setUpTestData(cls):
- super().setUpTestData()
- materialize("events", "$exception_issue_id", is_nullable=True)
-
+class TestRecommendationsAPI(APIBaseTest):
def _list(self):
return self.client.get(f"/api/environments/{self.team.id}/error_tracking/recommendations/")
@@ -65,32 +49,26 @@ class TestRecommendationsAPI(ClickhouseTestMixin, APIBaseTest):
def _refresh(self, rec_id):
return self.client.post(f"/api/environments/{self.team.id}/error_tracking/recommendations/{rec_id}/refresh/")
- @patch(
- "products.error_tracking.backend.logic.recommendations.long_running_issues.LongRunningIssuesRecommendation.compute",
- return_value={"issues": []},
- )
@patch(
"products.error_tracking.backend.logic.recommendations.alerts.AlertsRecommendation.compute",
return_value=MOCK_ALERTS_META,
)
- def test_first_list_creates_all_recommendations(self, mock_alerts, mock_long_running):
- self.assertEqual(ErrorTrackingRecommendation.objects.filter(team=self.team).count(), 0)
+ def test_first_list_creates_registered_recommendations_and_hides_unregistered_types(self, mock_alerts):
+ ErrorTrackingRecommendation.objects.create(team=self.team, type="long_running_issues")
response = self._list()
self.assertEqual(response.status_code, status.HTTP_200_OK)
- self.assertEqual(ErrorTrackingRecommendation.objects.filter(team=self.team).count(), 4)
+ self.assertEqual(
+ ErrorTrackingRecommendation.objects.filter(team=self.team).exclude(type="long_running_issues").count(), 3
+ )
types = {r["type"] for r in response.json()["results"]}
- self.assertEqual(types, {"alerts", "long_running_issues", "rate_limits", "source_maps"})
+ self.assertEqual(types, {"alerts", "rate_limits", "source_maps"})
- @patch(
- "products.error_tracking.backend.logic.recommendations.long_running_issues.LongRunningIssuesRecommendation.compute",
- return_value={"issues": []},
- )
@patch(
"products.error_tracking.backend.logic.recommendations.alerts.AlertsRecommendation.compute",
)
- def test_alerts_recomputes_on_every_list(self, mock_alerts, mock_long_running):
+ def test_alerts_recomputes_on_every_list(self, mock_alerts):
mock_alerts.return_value = MOCK_ALERTS_META
self._list()
@@ -102,36 +80,32 @@ class TestRecommendationsAPI(ClickhouseTestMixin, APIBaseTest):
self.assertEqual(alerts["meta"], MOCK_ALERTS_META_UPDATED)
@patch(
- "products.error_tracking.backend.logic.recommendations.long_running_issues.LongRunningIssuesRecommendation.compute",
+ "products.error_tracking.backend.logic.recommendations.source_maps.SourceMapsRecommendation.compute",
+ return_value=MOCK_SOURCE_MAPS_META,
)
@patch(
"products.error_tracking.backend.logic.recommendations.alerts.AlertsRecommendation.compute",
return_value=MOCK_ALERTS_META,
)
- def test_long_running_is_cached_until_interval_elapses(self, mock_alerts, mock_long_running):
+ def test_source_maps_is_cached_until_interval_elapses(self, mock_alerts, mock_source_maps):
with time_machine.travel("2026-01-01T00:00:00Z", tick=False) as frozen_time:
- mock_long_running.return_value = {"issues": []}
self._list()
- self.assertEqual(mock_long_running.call_count, 1)
+ self.assertEqual(mock_source_maps.call_count, 1)
# Re-listing within the same refresh window doesn't recompute.
self._list()
- self.assertEqual(mock_long_running.call_count, 1)
+ self.assertEqual(mock_source_maps.call_count, 1)
# A full refresh_interval always crosses into the next window — recompute, regardless of phase.
- frozen_time.shift(LongRunningIssuesRecommendation.refresh_interval)
+ frozen_time.shift(SourceMapsRecommendation.refresh_interval)
self._list()
- self.assertEqual(mock_long_running.call_count, 2)
+ self.assertEqual(mock_source_maps.call_count, 2)
- @patch(
- "products.error_tracking.backend.logic.recommendations.long_running_issues.LongRunningIssuesRecommendation.compute",
- return_value={"issues": []},
- )
@patch(
"products.error_tracking.backend.logic.recommendations.alerts.AlertsRecommendation.compute",
return_value=MOCK_ALERTS_META,
)
- def test_dismiss_persists_across_requests(self, mock_alerts, mock_long_running):
+ def test_dismiss_persists_across_requests(self, mock_alerts):
response = self._list()
alerts_id = next(r["id"] for r in response.json()["results"] if r["type"] == "alerts")
@@ -166,127 +140,6 @@ class TestRecommendationsAPI(ClickhouseTestMixin, APIBaseTest):
by_key = {a["key"]: a["enabled"] for a in meta["alerts"]}
self.assertFalse(by_key["error-tracking-issue-created"])
- def _create_issue(self, created_at, status=ErrorTrackingIssue.Status.ACTIVE, name="TestError"):
- issue = ErrorTrackingIssue.objects.create(
- id=uuid7(),
- team=self.team,
- status=status,
- name=name,
- description="boom",
- )
- ErrorTrackingIssue.objects.filter(id=issue.id).update(created_at=created_at)
- issue.refresh_from_db()
- fingerprint = f"fp::{issue.id}"
- ErrorTrackingIssueFingerprintV2.objects.create(team=self.team, issue=issue, fingerprint=fingerprint)
- ErrorTrackingIssueFingerprintV2.objects.filter(team=self.team, fingerprint=fingerprint).update(
- first_seen=created_at
- )
- sync_issues_to_clickhouse(issue_ids=[issue.id], team_id=self.team.pk)
- return issue
-
- def _create_exception(self, issue_id, timestamp, fingerprint=None):
- _create_event(
- distinct_id="user_1",
- event="$exception",
- team=self.team,
- properties={
- "$exception_issue_id": str(issue_id),
- "$exception_fingerprint": fingerprint or f"fp::{issue_id}",
- },
- timestamp=timestamp,
- )
-
- def test_long_running_returns_oldest_active_issues_with_recent_occurrences(self):
- old_active = self._create_issue(created_at=timezone.now() - timedelta(days=60), name="Oldest")
- mid_active = self._create_issue(created_at=timezone.now() - timedelta(days=20), name="MidAged")
- recent_active = self._create_issue(created_at=timezone.now() - timedelta(days=3), name="Recent")
- self._create_exception(old_active.id, _days_ago(1))
- self._create_exception(mid_active.id, _days_ago(1))
- # Recent issue still has activity but was first seen <7d ago, so it shouldn't qualify as long-running.
- self._create_exception(recent_active.id, _days_ago(1))
- flush_persons_and_events()
-
- meta = LongRunningIssuesRecommendation().compute(self.team)
-
- names = [i["name"] for i in meta["issues"]]
- self.assertEqual(names, ["Oldest", "MidAged"])
-
- def test_long_running_ignores_issues_without_recent_occurrences(self):
- stale = self._create_issue(created_at=timezone.now() - timedelta(days=60), name="Stale")
- self._create_exception(stale.id, _days_ago(30))
- flush_persons_and_events()
-
- meta = LongRunningIssuesRecommendation().compute(self.team)
-
- self.assertEqual(meta["issues"], [])
-
- def test_long_running_excludes_non_active_issues(self):
- resolved = self._create_issue(
- created_at=timezone.now() - timedelta(days=60),
- status=ErrorTrackingIssue.Status.RESOLVED,
- name="Resolved",
- )
- self._create_exception(resolved.id, _days_ago(1))
- flush_persons_and_events()
-
- meta = LongRunningIssuesRecommendation().compute(self.team)
-
- self.assertEqual(meta["issues"], [])
-
- def test_long_running_limits_to_five(self):
- for i in range(15):
- issue = self._create_issue(
- created_at=timezone.now() - timedelta(days=60 - i),
- name=f"Issue {i:02d}",
- )
- self._create_exception(issue.id, _days_ago(1))
- flush_persons_and_events()
-
- meta = LongRunningIssuesRecommendation().compute(self.team)
-
- self.assertEqual(len(meta["issues"]), 5)
- self.assertEqual(meta["issues"][0]["name"], "Issue 00")
- self.assertEqual(meta["issues"][4]["name"], "Issue 04")
-
- def test_long_running_ignores_other_teams_issues(self):
- other_issue_id = str(uuid4())
- self._create_exception(other_issue_id, _days_ago(1))
- flush_persons_and_events()
-
- meta = LongRunningIssuesRecommendation().compute(self.team)
-
- self.assertEqual(meta["issues"], [])
-
- def test_long_running_enrich_overrides_status_with_live_value(self):
- issue = self._create_issue(created_at=timezone.now() - timedelta(days=60), name="Boom")
- meta = {"issues": [{"id": str(issue.id), "name": "Boom", "status": ErrorTrackingIssue.Status.ACTIVE}]}
- ErrorTrackingIssue.objects.filter(id=issue.id).update(status=ErrorTrackingIssue.Status.SUPPRESSED)
-
- enriched = LongRunningIssuesRecommendation().enrich(self.team, meta)
-
- self.assertEqual(enriched["issues"][0]["status"], ErrorTrackingIssue.Status.SUPPRESSED)
-
- def test_long_running_enrich_with_empty_issues_returns_unchanged(self):
- meta: dict = {"issues": []}
-
- enriched = LongRunningIssuesRecommendation().enrich(self.team, meta)
-
- self.assertEqual(enriched, {"issues": []})
-
- def test_long_running_enrich_keeps_cached_status_when_issue_missing(self):
- meta = {"issues": [{"id": str(uuid4()), "name": "Gone", "status": ErrorTrackingIssue.Status.ACTIVE}]}
-
- enriched = LongRunningIssuesRecommendation().enrich(self.team, meta)
-
- self.assertEqual(enriched["issues"][0]["status"], ErrorTrackingIssue.Status.ACTIVE)
-
- def test_long_running_is_completed_when_no_issues(self):
- self.assertTrue(LongRunningIssuesRecommendation().is_completed({"issues": []}))
-
- def test_long_running_is_completed_false_when_issues_present(self):
- meta = {"issues": [{"id": "x"}]}
- self.assertFalse(LongRunningIssuesRecommendation().is_completed(meta))
-
def test_alerts_is_completed_when_all_enabled(self):
self.assertTrue(AlertsRecommendation().is_completed(MOCK_ALERTS_META_UPDATED))
@@ -339,82 +192,73 @@ class TestRecommendationsAPI(ClickhouseTestMixin, APIBaseTest):
self.assertFalse(RateLimitsRecommendation().is_completed({"rate_limits": []}))
@patch(
- "products.error_tracking.backend.logic.recommendations.long_running_issues.LongRunningIssuesRecommendation.compute",
- return_value={"issues": []},
+ "products.error_tracking.backend.logic.recommendations.source_maps.SourceMapsRecommendation.compute",
+ return_value=MOCK_SOURCE_MAPS_META,
)
@patch(
"products.error_tracking.backend.logic.recommendations.alerts.AlertsRecommendation.compute",
return_value=MOCK_ALERTS_META,
)
- def test_refresh_with_force_false_does_not_recompute(self, mock_alerts, mock_long_running):
+ def test_refresh_with_force_false_does_not_recompute(self, mock_alerts, mock_source_maps):
response = self._list()
- rec_id = next(r["id"] for r in response.json()["results"] if r["type"] == "long_running_issues")
- mock_long_running.reset_mock()
+ rec_id = next(r["id"] for r in response.json()["results"] if r["type"] == "source_maps")
+ mock_source_maps.reset_mock()
response = self.client.post(
f"/api/environments/{self.team.id}/error_tracking/recommendations/{rec_id}/refresh/?force=false"
)
self.assertEqual(response.status_code, status.HTTP_200_OK)
- mock_long_running.assert_not_called()
+ mock_source_maps.assert_not_called()
@patch(
- "products.error_tracking.backend.logic.recommendations.long_running_issues.LongRunningIssuesRecommendation.compute",
- return_value={"issues": []},
+ "products.error_tracking.backend.logic.recommendations.source_maps.SourceMapsRecommendation.compute",
+ return_value=MOCK_SOURCE_MAPS_META,
)
@patch(
"products.error_tracking.backend.logic.recommendations.alerts.AlertsRecommendation.compute",
return_value=MOCK_ALERTS_META,
)
- def test_refresh_with_force_true_recomputes(self, mock_alerts, mock_long_running):
+ def test_refresh_with_force_true_recomputes(self, mock_alerts, mock_source_maps):
response = self._list()
- rec_id = next(r["id"] for r in response.json()["results"] if r["type"] == "long_running_issues")
- mock_long_running.reset_mock()
+ rec_id = next(r["id"] for r in response.json()["results"] if r["type"] == "source_maps")
+ mock_source_maps.reset_mock()
response = self._refresh(rec_id)
self.assertEqual(response.status_code, status.HTTP_200_OK)
- mock_long_running.assert_called_once()
+ mock_source_maps.assert_called_once()
@patch(
- "products.error_tracking.backend.logic.recommendations.long_running_issues.LongRunningIssuesRecommendation.compute",
- return_value={"issues": []},
+ "products.error_tracking.backend.logic.recommendations.source_maps.SourceMapsRecommendation.compute",
+ return_value=MOCK_SOURCE_MAPS_META,
)
@patch(
"products.error_tracking.backend.logic.recommendations.alerts.AlertsRecommendation.compute",
return_value=MOCK_ALERTS_META,
)
- def test_list_marks_recommendations_ready_after_compute(self, mock_alerts, mock_long_running):
+ def test_list_marks_recommendations_ready_after_compute(self, mock_alerts, mock_source_maps):
response = self._list()
self.assertEqual(response.status_code, status.HTTP_200_OK)
statuses = {r["type"]: r["status"] for r in response.json()["results"]}
- self.assertEqual(
- statuses,
- {"alerts": "ready", "long_running_issues": "ready", "rate_limits": "ready", "source_maps": "ready"},
- )
+ self.assertEqual(statuses, {"alerts": "ready", "rate_limits": "ready", "source_maps": "ready"})
# Each recommendation row should have been computed exactly once via the celery task path.
self.assertEqual(mock_alerts.call_count, 1)
- self.assertEqual(mock_long_running.call_count, 1)
+ self.assertEqual(mock_source_maps.call_count, 1)
- @patch(
- "products.error_tracking.backend.logic.recommendations.long_running_issues.LongRunningIssuesRecommendation.compute",
- return_value={"issues": []},
- )
@patch(
"products.error_tracking.backend.logic.recommendations.alerts.AlertsRecommendation.compute",
return_value=MOCK_ALERTS_META,
)
- def test_poll_does_not_kick_off_new_computations(self, mock_alerts, mock_long_running):
+ def test_poll_does_not_kick_off_new_computations(self, mock_alerts):
self._list()
mock_alerts.reset_mock()
- mock_long_running.reset_mock()
response = self._poll()
self.assertEqual(response.status_code, status.HTTP_200_OK)
mock_alerts.assert_not_called()
- mock_long_running.assert_not_called()
def _make_frame(self, lang: str, resolved: bool, created_hours_ago: int = 1) -> ErrorTrackingStackFrame:
frame = ErrorTrackingStackFrame.objects.create(
@@ -512,25 +356,25 @@ class TestRecommendationsAPI(ClickhouseTestMixin, APIBaseTest):
self.assertTrue(SourceMapsRecommendation().is_completed(meta))
@patch(
- "products.error_tracking.backend.logic.recommendations.long_running_issues.LongRunningIssuesRecommendation.compute",
- return_value={"issues": []},
+ "products.error_tracking.backend.logic.recommendations.source_maps.SourceMapsRecommendation.compute",
+ return_value=MOCK_SOURCE_MAPS_META,
)
@patch(
"products.error_tracking.backend.logic.recommendations.alerts.AlertsRecommendation.compute",
return_value=MOCK_ALERTS_META,
)
- def test_stuck_computing_rows_are_re_kicked(self, mock_alerts, mock_long_running):
- # Simulate a worker that died mid-compute for long_running: row stays in
+ def test_stuck_computing_rows_are_re_kicked(self, mock_alerts, mock_source_maps):
+ # Simulate a worker that died mid-compute for source_maps: row stays in
# "computing" with a stale status_changed_at and never reaches "ready".
- long_running = ErrorTrackingRecommendation.objects.create(
+ source_maps = ErrorTrackingRecommendation.objects.create(
team=self.team,
- type="long_running_issues",
+ type="source_maps",
status=ErrorTrackingRecommendation.Status.COMPUTING,
status_changed_at=timezone.now() - timedelta(minutes=10),
)
self._list()
- long_running.refresh_from_db()
- self.assertEqual(long_running.status, ErrorTrackingRecommendation.Status.READY)
- mock_long_running.assert_called_once()
+ source_maps.refresh_from_db()
+ self.assertEqual(source_maps.status, ErrorTrackingRecommendation.Status.READY)
+ mock_source_maps.assert_called_once()
diff --git a/products/error_tracking/frontend/ErrorTracking.stories.tsx b/products/error_tracking/frontend/ErrorTracking.stories.tsx
index 00af3ce82621..8a38656d6684 100644
--- a/products/error_tracking/frontend/ErrorTracking.stories.tsx
+++ b/products/error_tracking/frontend/ErrorTracking.stories.tsx
@@ -677,7 +677,7 @@ export const ListPageWithSourceMapsBanner: Story = {
decorators: [
mswDecorator({
get: {
- 'api/environments/:team_id/error_tracking/recommendations': () => [
+ 'api/projects/:team_id/error_tracking/recommendations': () => [
200,
{
results: [
@@ -713,6 +713,160 @@ export const ListPageWithSourceMapsBannerNarrow: Story = {
parameters: { testOptions: { viewport: { width: 760, height: 1000 } } },
}
+// With source maps fine, the alerts banner takes the single banner slot and names
+// only the alert types that are still missing
+export const ListPageWithAlertsBanner: Story = {
+ decorators: [
+ mswDecorator({
+ get: {
+ 'api/projects/:team_id/error_tracking/recommendations': () => [
+ 200,
+ {
+ results: [
+ {
+ id: 'alerts-recommendation',
+ type: 'alerts',
+ completed: false,
+ status: 'ready',
+ computed_at: '2024-07-08T00:00:00Z',
+ dismissed_at: null,
+ created_at: '2024-07-08T00:00:00Z',
+ updated_at: '2024-07-08T00:00:00Z',
+ meta: {
+ alerts: [
+ { key: 'error-tracking-issue-created', enabled: true },
+ { key: 'error-tracking-issue-reopened', enabled: false },
+ { key: 'error-tracking-issue-spiking', enabled: false },
+ ],
+ },
+ },
+ {
+ id: 'source-maps-recommendation',
+ type: 'source_maps',
+ completed: true,
+ status: 'ready',
+ computed_at: '2024-07-08T00:00:00Z',
+ dismissed_at: null,
+ created_at: '2024-07-08T00:00:00Z',
+ updated_at: '2024-07-08T00:00:00Z',
+ meta: {
+ total_frames: 100,
+ unresolved_frames: 3,
+ unresolved_pct: 0.03,
+ threshold_pct: 0.25,
+ min_sample_frames: 50,
+ lookback_hours: 24,
+ },
+ },
+ ],
+ },
+ ],
+ },
+ }),
+ ],
+}
+
+// With source maps and alerts covered, the rate limit banner takes the single banner slot
+export const ListPageWithRateLimitsBanner: Story = {
+ decorators: [
+ mswDecorator({
+ get: {
+ 'api/projects/:team_id/error_tracking/recommendations': () => [
+ 200,
+ {
+ results: [
+ {
+ id: 'rate-limits-recommendation',
+ type: 'rate_limits',
+ completed: false,
+ status: 'ready',
+ computed_at: '2024-07-08T00:00:00Z',
+ dismissed_at: null,
+ created_at: '2024-07-08T00:00:00Z',
+ updated_at: '2024-07-08T00:00:00Z',
+ meta: {
+ rate_limits: [
+ { key: 'project', enabled: false },
+ { key: 'per_issue', enabled: false },
+ ],
+ },
+ },
+ ],
+ },
+ ],
+ },
+ }),
+ ],
+}
+
+// With every check failing, the banners stack: source maps on top, the other two peeking out below
+export const ListPageWithStackedBanners: Story = {
+ decorators: [
+ mswDecorator({
+ get: {
+ 'api/projects/:team_id/error_tracking/recommendations': () => [
+ 200,
+ {
+ results: [
+ {
+ id: 'source-maps-recommendation',
+ type: 'source_maps',
+ completed: false,
+ status: 'ready',
+ computed_at: '2024-07-08T00:00:00Z',
+ dismissed_at: null,
+ created_at: '2024-07-08T00:00:00Z',
+ updated_at: '2024-07-08T00:00:00Z',
+ meta: {
+ total_frames: 100,
+ unresolved_frames: 62,
+ unresolved_pct: 0.62,
+ threshold_pct: 0.25,
+ min_sample_frames: 50,
+ lookback_hours: 24,
+ },
+ },
+ {
+ id: 'alerts-recommendation',
+ type: 'alerts',
+ completed: false,
+ status: 'ready',
+ computed_at: '2024-07-08T00:00:00Z',
+ dismissed_at: null,
+ created_at: '2024-07-08T00:00:00Z',
+ updated_at: '2024-07-08T00:00:00Z',
+ meta: {
+ alerts: [
+ { key: 'error-tracking-issue-created', enabled: false },
+ { key: 'error-tracking-issue-reopened', enabled: false },
+ { key: 'error-tracking-issue-spiking', enabled: false },
+ ],
+ },
+ },
+ {
+ id: 'rate-limits-recommendation',
+ type: 'rate_limits',
+ completed: false,
+ status: 'ready',
+ computed_at: '2024-07-08T00:00:00Z',
+ dismissed_at: null,
+ created_at: '2024-07-08T00:00:00Z',
+ updated_at: '2024-07-08T00:00:00Z',
+ meta: {
+ rate_limits: [
+ { key: 'project', enabled: false },
+ { key: 'per_issue', enabled: false },
+ ],
+ },
+ },
+ ],
+ },
+ ],
+ },
+ }),
+ ],
+}
+
// Autocapture must be on for the issue list to render instead of the full setup prompt,
// and it comes from the bootstrap app context, so an msw override isn't enough
function IssueScenePreviewStory({
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/ErrorTrackingScene.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/ErrorTrackingScene.tsx
index 3404be842356..d678f92d6245 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingScene/ErrorTrackingScene.tsx
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/ErrorTrackingScene.tsx
@@ -1,7 +1,7 @@
import { BindLogic, useActions, useValues } from 'kea'
import posthog from 'posthog-js'
-import { LemonBadge, LemonButton, LemonTab, LemonTabs, Spinner } from '@posthog/lemon-ui'
+import { LemonButton, LemonTab, LemonTabs } from '@posthog/lemon-ui'
import { Button } from '@posthog/quill'
import api from 'lib/api'
@@ -28,6 +28,7 @@ import { issueQueryOptionsLogic } from '../../components/IssueQueryOptions/issue
import { StyleVariables } from '../../components/StyleVariables'
import { errorTrackingEmptyState } from '../../emptyState/errorTrackingEmptyState'
import { ERROR_TRACKING_LOGIC_KEY } from '../../utils'
+import { ErrorTrackingBanners } from './banners/ErrorTrackingBanners'
import {
ERROR_TRACKING_SCENE_LOGIC_KEY,
ErrorTrackingSceneActiveTab,
@@ -35,9 +36,6 @@ import {
} from './errorTrackingSceneLogic'
import { ErrorTrackingInsights } from './tabs/insights/ErrorTrackingInsights'
import { IssuesList } from './tabs/issues/IssuesList'
-import { SourceMapsBanner } from './tabs/issues/SourceMapsBanner'
-import { RecommendationsTab } from './tabs/recommendations/RecommendationsTab'
-import { recommendationsTabLogic } from './tabs/recommendations/recommendationsTabLogic'
const ERROR_TRACKING_ALERT_FILTER_GROUPS: CyclotronJobFiltersType[] = [
{ events: [{ id: '$error_tracking_issue_created', type: 'events' }] },
@@ -55,7 +53,6 @@ export const scene: SceneExport = {
export function ErrorTrackingScene(): JSX.Element {
const { activeTab } = useValues(errorTrackingSceneLogic)
const { setActiveTab } = useActions(errorTrackingSceneLogic)
- const hasRecommendations = useFeatureFlag('ERROR_TRACKING_RECOMMENDATIONS')
// Same gate as the settings section: configuration endpoints require error tracking viewer access.
const configurationAccessDeniedReason = getAccessControlDisabledReason(
AccessControlResourceType.ErrorTracking,
@@ -84,7 +81,7 @@ export function ErrorTrackingScene(): JSX.Element {
label: 'Issues',
content: (
<>
- <SourceMapsBanner />
+ <ErrorTrackingBanners />
<IssuesList />
{/* Renders a hidden div — keep it after IssuesList so the sticky bar's
first:-mt-4 can detect whether a banner renders above it */}
@@ -97,15 +94,6 @@ export function ErrorTrackingScene(): JSX.Element {
label: 'Insights',
content: <ErrorTrackingInsights />,
},
- ...(hasRecommendations
- ? [
- {
- key: 'recommendations' as const,
- label: <RecommendationsTabLabel />,
- content: <RecommendationsTab />,
- },
- ]
- : []),
{
key: 'configuration',
label: 'Configuration',
@@ -142,21 +130,6 @@ export function ErrorTrackingScene(): JSX.Element {
)
}
-const RecommendationsTabLabel = (): JSX.Element => {
- const { activeRecommendations, recommendationsLoading } = useValues(recommendationsTabLogic)
-
- return (
- <span className="flex items-center gap-1.5">
- Recommendations
- {recommendationsLoading ? (
- <LemonBadge size="small" content={<Spinner textColored />} />
- ) : (
- <LemonBadge.Number count={activeRecommendations.length} size="small" showZero />
- )}
- </span>
- )
-}
-
const Header = (): JSX.Element => {
const { isDev } = useValues(preflightLogic)
const todayRailNav = useFeatureFlag('TODAY_RAIL_NAV')
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/AlertSetupModal.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/AlertSetupModal.tsx
new file mode 100644
index 000000000000..8e967528154e
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/AlertSetupModal.tsx
@@ -0,0 +1,81 @@
+import { BindLogic, useActions } from 'kea'
+import { router } from 'kea-router'
+import posthog from 'posthog-js'
+
+import { LemonModal } from '@posthog/lemon-ui'
+
+import { AlertWizard } from 'lib/components/Alerting/AlertWizard/AlertWizard'
+import {
+ AlertCreationView,
+ AlertWizardLogicProps,
+ alertWizardLogic,
+} from 'lib/components/Alerting/AlertWizard/alertWizardLogic'
+
+import { HogFunctionSubTemplateIdType } from '~/types'
+
+import {
+ ERROR_TRACKING_DESTINATIONS,
+ ERROR_TRACKING_SUB_TEMPLATE_IDS,
+ ERROR_TRACKING_TRIGGERS,
+} from '../../ErrorTrackingConfigurationScene/alerting/alertWizardConfig'
+import { errorTrackingConfigurationSettingUrl } from './configurationSettingUrl'
+
+export function AlertSetupModal({
+ triggerKey,
+ onClose,
+}: {
+ /** `null` shows the trigger step so the user picks which alert to set up. */
+ triggerKey: HogFunctionSubTemplateIdType | null
+ onClose: () => void
+}): JSX.Element {
+ const wizardProps: AlertWizardLogicProps = {
+ logicKey: `error-tracking-alerts-banner-${triggerKey ?? 'any'}`,
+ subTemplateIds: ERROR_TRACKING_SUB_TEMPLATE_IDS,
+ triggers: ERROR_TRACKING_TRIGGERS,
+ destinations: ERROR_TRACKING_DESTINATIONS,
+ disableUrlSync: true,
+ presetTriggerKey: triggerKey ?? undefined,
+ contextId: 'error-tracking',
+ onAlertCreated: onClose,
+ }
+
+ return (
+ <LemonModal isOpen onClose={onClose} width={560} simple>
+ <BindLogic logic={alertWizardLogic} props={wizardProps}>
+ <AlertSetupWizard hideTriggerStep={triggerKey !== null} onClose={onClose} />
+ </BindLogic>
+ </LemonModal>
+ )
+}
+
+function AlertSetupWizard({
+ hideTriggerStep,
+ onClose,
+}: {
+ hideTriggerStep: boolean
+ onClose: () => void
+}): JSX.Element {
+ const { setAlertCreationView, resetWizard } = useActions(alertWizardLogic)
+
+ return (
+ <div className="p-4">
+ <AlertWizard
+ hideTriggerStep={hideTriggerStep}
+ hideCloseButton
+ onCancel={() => {
+ setAlertCreationView(AlertCreationView.None)
+ resetWizard()
+ onClose()
+ }}
+ onSwitchToTraditional={() => {
+ posthog.capture('error_tracking_alert_creation_switched_to_traditional', {
+ ui_source: 'alerts_banner',
+ })
+ resetWizard()
+ onClose()
+ router.actions.push(errorTrackingConfigurationSettingUrl('error-tracking-alerting'))
+ }}
+ />
+ </div>
+ )
+}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/AlertsBanner.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/AlertsBanner.tsx
new file mode 100644
index 000000000000..427c651507c0
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/AlertsBanner.tsx
@@ -0,0 +1,61 @@
+import { useActions, useValues } from 'kea'
+import posthog from 'posthog-js'
+import { ReactNode } from 'react'
+
+import { IconBell } from '@posthog/icons'
+
+import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'
+
+import { AlertSetupModal } from './AlertSetupModal'
+import { BannerCallout } from './BannerCallout'
+import { errorTrackingConfigurationSettingUrl } from './configurationSettingUrl'
+import { errorTrackingBannersLogic } from './errorTrackingBannersLogic'
+import { TownCrierHog } from './townCrierHog'
+import { ALERT_TRIGGER_ADJECTIVES, type AlertsRecommendation } from './types'
+
+const ALERT_SETTINGS_URL = errorTrackingConfigurationSettingUrl('error-tracking-alerting')
+const LIST_FORMAT = new Intl.ListFormat('en', { style: 'long', type: 'disjunction' })
+
+// Mounts only while the banner is visible, so the "shown" event fires exactly when it was seen.
+export function AlertsBanner({
+ recommendation,
+ navigation,
+}: {
+ recommendation: AlertsRecommendation
+ navigation?: ReactNode
+}): JSX.Element {
+ const { isAlertSetupOpen, alertSetupTriggerKey } = useValues(errorTrackingBannersLogic)
+ const { dismissBanner, openAlertSetup, closeAlertSetup } = useActions(errorTrackingBannersLogic)
+ const missing = (recommendation.meta.alerts ?? []).filter((alert) => !alert.enabled)
+ const missingAdjectives = missing.map((alert) => ALERT_TRIGGER_ADJECTIVES[alert.key] ?? alert.key)
+
+ useOnMountEffect(() => {
+ posthog.capture('error_tracking_alerts_banner_shown', { missing_alert_count: missing.length })
+ })
+
+ return (
+ <>
+ <BannerCallout
+ illustration={TownCrierHog}
+ title={`You don't get alerts for ${LIST_FORMAT.format(missingAdjectives)} issues`}
+ description="Send them to Slack, Teams, PagerDuty, or another destination."
+ primaryAction={{
+ label: missing.length === 1 ? 'Set up alert' : 'Set up alerts',
+ icon: <IconBell />,
+ // With one alert left, skip the trigger step and set up that one.
+ onClick: () => openAlertSetup(missing.length === 1 ? missing[0].key : null),
+ dataAttr: 'error-tracking-alerts-banner-set-up',
+ }}
+ secondaryAction={{
+ label: 'Alert settings',
+ to: ALERT_SETTINGS_URL,
+ onClick: () => posthog.capture('error_tracking_alerts_banner_settings_clicked'),
+ dataAttr: 'error-tracking-alerts-banner-settings',
+ }}
+ navigation={navigation}
+ onDismiss={() => dismissBanner('alerts')}
+ />
+ {isAlertSetupOpen && <AlertSetupModal triggerKey={alertSetupTriggerKey} onClose={closeAlertSetup} />}
+ </>
+ )
+}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/BannerActionButton.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/BannerActionButton.tsx
new file mode 100644
index 000000000000..664171d95c21
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/BannerActionButton.tsx
@@ -0,0 +1,35 @@
+import { LinkPrimitive } from 'lib/lemon-ui/Link'
+import { Button } from 'lib/ui/quill'
+
+export interface BannerAction {
+ label: string
+ icon?: JSX.Element
+ onClick?: () => void
+ to?: string
+ targetBlank?: boolean
+ dataAttr: string
+}
+
+export function BannerActionButton({
+ action,
+ variant,
+}: {
+ action: BannerAction
+ variant: 'primary' | 'default'
+}): JSX.Element {
+ return (
+ <Button
+ variant={variant}
+ onClick={action.onClick}
+ data-attr={action.dataAttr}
+ render={
+ action.to ? (
+ <LinkPrimitive to={action.to} target={action.targetBlank ? '_blank' : undefined} />
+ ) : undefined
+ }
+ >
+ {action.icon}
+ {action.label}
+ </Button>
+ )
+}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/BannerCallout.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/BannerCallout.tsx
new file mode 100644
index 000000000000..bbe3771bdb2a
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/BannerCallout.tsx
@@ -0,0 +1,50 @@
+import { ComponentType, ReactNode } from 'react'
+
+import { Item, ItemActions, ItemContent, ItemDescription, ItemMedia, ItemTitle } from 'lib/ui/quill'
+
+import { BannerAction, BannerActionButton } from './BannerActionButton'
+import { BannerDismissButton } from './BannerDismissButton'
+
+export interface BannerCalloutProps {
+ illustration: ComponentType<{ className?: string; loading?: 'lazy' | 'eager' }>
+ title: string
+ description: ReactNode
+ primaryAction: BannerAction
+ secondaryAction?: BannerAction
+ /** Previous and next controls, when several banners are queued. */
+ navigation?: ReactNode
+ onDismiss: () => void
+}
+
+export function BannerCallout({
+ illustration: Illustration,
+ title,
+ description,
+ primaryAction,
+ secondaryAction,
+ navigation,
+ onDismiss,
+}: BannerCalloutProps): JSX.Element {
+ return (
+ // The shell uses the issues table's surface tokens, so the banner reads as a card in both themes.
+ // Inside quill's scope these tokens resolve to the page background, so the shell stays outside it.
+ <div className="@container rounded border border-primary bg-surface-primary">
+ <Item className="flex-wrap border-transparent">
+ {/* `eager` because a lazy image hidden by a container query never loads. */}
+ <ItemMedia className="hidden @2xl:flex">
+ <Illustration className="size-12" loading="eager" />
+ </ItemMedia>
+ <ItemContent className="basis-72">
+ <ItemTitle>{title}</ItemTitle>
+ <ItemDescription>{description}</ItemDescription>
+ </ItemContent>
+ <ItemActions className="ml-auto flex-wrap">
+ {secondaryAction && <BannerActionButton action={secondaryAction} variant="default" />}
+ <BannerActionButton action={primaryAction} variant="primary" />
+ {navigation}
+ <BannerDismissButton onDismiss={onDismiss} />
+ </ItemActions>
+ </Item>
+ </div>
+ )
+}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/BannerDeck.test.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/BannerDeck.test.tsx
new file mode 100644
index 000000000000..054bd9f45367
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/BannerDeck.test.tsx
@@ -0,0 +1,36 @@
+import { cleanup, render } from '@testing-library/react'
+import { useEffect } from 'react'
+
+import { BannerDeck } from './BannerDeck'
+import type { ErrorTrackingBannerKey } from './bannerQueue'
+
+describe('BannerDeck', () => {
+ afterEach(() => {
+ cleanup()
+ })
+
+ test.each<[string, ErrorTrackingBannerKey[], ErrorTrackingBannerKey[]]>([
+ ['grows', ['source_maps'], ['source_maps', 'alerts', 'rate_limits']],
+ ['shrinks', ['source_maps', 'alerts'], ['source_maps']],
+ ])('keeps the current banner mounted when the deck %s', (_, before, after) => {
+ const onMount = jest.fn()
+ function Banner(): JSX.Element {
+ useEffect(() => onMount(), [])
+ return <div>banner</div>
+ }
+ const deck = (banners: ErrorTrackingBannerKey[]): JSX.Element => (
+ <BannerDeck
+ banners={banners}
+ current="source_maps"
+ onPrevious={jest.fn()}
+ onNext={jest.fn()}
+ renderCurrent={() => <Banner />}
+ />
+ )
+
+ const { rerender } = render(deck(before))
+ rerender(deck(after))
+
+ expect(onMount).toHaveBeenCalledTimes(1)
+ })
+})
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/BannerDeck.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/BannerDeck.tsx
new file mode 100644
index 000000000000..843127f917f3
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/BannerDeck.tsx
@@ -0,0 +1,58 @@
+import { ReactNode } from 'react'
+
+import { cn } from 'lib/utils/css-classes'
+
+import type { ErrorTrackingBannerKey } from './bannerQueue'
+import { BannerStackControls } from './BannerStackControls'
+
+export function BannerDeck({
+ banners,
+ current,
+ onPrevious,
+ onNext,
+ renderCurrent,
+}: {
+ banners: ErrorTrackingBannerKey[]
+ current: ErrorTrackingBannerKey
+ onPrevious: () => void
+ onNext: () => void
+ /** Renders the current banner, with the stack controls to place inside it. */
+ renderCurrent: (navigation?: ReactNode) => ReactNode
+}): JSX.Element {
+ const cardsBehind = Math.min(banners.length - 1, 2)
+
+ // The current banner keeps the same place in the tree for any deck size. A different wrapper
+ // for a single banner would remount it when the queue grows or shrinks, which closes an open
+ // setup modal and loses what the user typed in it.
+ return (
+ <div className={cn('relative', cardsBehind === 2 ? 'pb-4' : cardsBehind === 1 ? 'pb-2' : null)}>
+ {cardsBehind === 2 && (
+ <div
+ aria-hidden
+ className="absolute inset-x-6 bottom-0 h-8 rounded border border-primary bg-surface-primary"
+ />
+ )}
+ {cardsBehind >= 1 && (
+ <div
+ aria-hidden
+ className={cn(
+ 'absolute inset-x-3 h-8 rounded border border-primary bg-surface-primary',
+ cardsBehind === 2 ? 'bottom-2' : 'bottom-0'
+ )}
+ />
+ )}
+ <div className="relative">
+ {renderCurrent(
+ cardsBehind >= 1 ? (
+ <BannerStackControls
+ index={banners.indexOf(current)}
+ total={banners.length}
+ onPrevious={onPrevious}
+ onNext={onNext}
+ />
+ ) : undefined
+ )}
+ </div>
+ </div>
+ )
+}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/BannerDismissButton.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/BannerDismissButton.tsx
new file mode 100644
index 000000000000..51b43a57669a
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/BannerDismissButton.tsx
@@ -0,0 +1,11 @@
+import { IconX } from '@posthog/icons'
+
+import { Button } from 'lib/ui/quill'
+
+export function BannerDismissButton({ onDismiss }: { onDismiss: () => void }): JSX.Element {
+ return (
+ <Button variant="default" size="icon-sm" aria-label="Dismiss" tooltip="Dismiss" onClick={onDismiss}>
+ <IconX />
+ </Button>
+ )
+}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/BannerStackControls.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/BannerStackControls.tsx
new file mode 100644
index 000000000000..6a4ce308eeae
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/BannerStackControls.tsx
@@ -0,0 +1,42 @@
+import { IconChevronLeft, IconChevronRight } from '@posthog/icons'
+
+import { Button, Text } from 'lib/ui/quill'
+
+export function BannerStackControls({
+ index,
+ total,
+ onPrevious,
+ onNext,
+}: {
+ index: number
+ total: number
+ onPrevious: () => void
+ onNext: () => void
+}): JSX.Element {
+ return (
+ <div className="flex items-center gap-1">
+ <Button
+ variant="default"
+ size="icon-sm"
+ aria-label="Previous recommendation"
+ disabled={index <= 0}
+ onClick={onPrevious}
+ data-attr="error-tracking-banners-previous"
+ >
+ <IconChevronLeft />
+ </Button>
+ <Text size="xs" variant="muted" className="tabular-nums">
+ {`${index + 1} of ${total}`}
+ </Text>
+ <Button
+ variant="default"
+ size="icon-sm"
+ aria-label="Next recommendation"
+ onClick={onNext}
+ data-attr="error-tracking-banners-next"
+ >
+ <IconChevronRight />
+ </Button>
+ </div>
+ )
+}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/ErrorTrackingBanners.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/ErrorTrackingBanners.tsx
new file mode 100644
index 000000000000..146f00219927
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/ErrorTrackingBanners.tsx
@@ -0,0 +1,47 @@
+import { useActions, useValues } from 'kea'
+import { ReactNode } from 'react'
+
+import { AlertsBanner } from './AlertsBanner'
+import { BannerDeck } from './BannerDeck'
+import { ErrorTrackingBannerKey } from './bannerQueue'
+import { errorTrackingBannersLogic } from './errorTrackingBannersLogic'
+import { RateLimitsBanner } from './RateLimitsBanner'
+import { SourceMapsBanner } from './SourceMapsBanner'
+
+/** Shows one setup banner at a time, stacked so the user can see and step through the others. */
+export function ErrorTrackingBanners(): JSX.Element | null {
+ const { activeBanners, currentBanner, sourceMapsRecommendation, alertsRecommendation, rateLimitsRecommendation } =
+ useValues(errorTrackingBannersLogic)
+ const { showPreviousBanner, showNextBanner } = useActions(errorTrackingBannersLogic)
+
+ if (!currentBanner) {
+ return null
+ }
+
+ // Keyed by banner so each one mounts fresh and fires its own "shown" event.
+ const renderBanner = (banner: ErrorTrackingBannerKey, navigation?: ReactNode): ReactNode => {
+ if (banner === 'source_maps' && sourceMapsRecommendation) {
+ return <SourceMapsBanner key={banner} recommendation={sourceMapsRecommendation} navigation={navigation} />
+ }
+ if (banner === 'alerts' && alertsRecommendation) {
+ return <AlertsBanner key={banner} recommendation={alertsRecommendation} navigation={navigation} />
+ }
+ if (banner === 'rate_limits' && rateLimitsRecommendation) {
+ return <RateLimitsBanner key={banner} navigation={navigation} />
+ }
+ return null
+ }
+
+ // The sticky filters bar below uses `first:` to detect whether a banner renders above it.
+ return (
+ <div className="mt-2 mb-2">
+ <BannerDeck
+ banners={activeBanners}
+ current={currentBanner}
+ onPrevious={showPreviousBanner}
+ onNext={showNextBanner}
+ renderCurrent={(navigation) => renderBanner(currentBanner, navigation)}
+ />
+ </div>
+ )
+}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/RateLimitsBanner.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/RateLimitsBanner.tsx
new file mode 100644
index 000000000000..bc59de65ca41
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/RateLimitsBanner.tsx
@@ -0,0 +1,41 @@
+import { useActions } from 'kea'
+import posthog from 'posthog-js'
+import { ReactNode } from 'react'
+
+import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'
+
+import { BannerCallout } from './BannerCallout'
+import { errorTrackingConfigurationSettingUrl } from './configurationSettingUrl'
+import { errorTrackingBannersLogic } from './errorTrackingBannersLogic'
+import { TrafficControllerHog } from './trafficControllerHog'
+
+const RATE_LIMIT_SETTINGS_URL = errorTrackingConfigurationSettingUrl('error-tracking-rate-limits')
+
+// Mounts only while the banner is visible, so the "shown" event fires exactly when it was seen.
+export function RateLimitsBanner({ navigation }: { navigation?: ReactNode }): JSX.Element {
+ const { dismissBanner } = useActions(errorTrackingBannersLogic)
+
+ useOnMountEffect(() => {
+ posthog.capture('error_tracking_rate_limits_banner_shown')
+ })
+
+ return (
+ <BannerCallout
+ illustration={TrafficControllerHog}
+ title="Your project has no rate limit"
+ description="Set one to drop exceptions above a rate you choose, so a runaway error loop can't flood the project."
+ primaryAction={{
+ label: 'Set rate limit',
+ to: RATE_LIMIT_SETTINGS_URL,
+ onClick: () =>
+ posthog.capture('error_tracking_rate_limit_setup_started', {
+ ui_source: 'rate_limits_banner',
+ rate_limit_key: 'project',
+ }),
+ dataAttr: 'error-tracking-rate-limits-banner-set-up',
+ }}
+ navigation={navigation}
+ onDismiss={() => dismissBanner('rate_limits')}
+ />
+ )
+}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/SourceMapsBanner.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/SourceMapsBanner.tsx
new file mode 100644
index 000000000000..928d3f20420b
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/SourceMapsBanner.tsx
@@ -0,0 +1,61 @@
+import { useActions } from 'kea'
+import posthog from 'posthog-js'
+import { ReactNode } from 'react'
+
+import { IconMagicWand } from '@posthog/icons'
+
+import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'
+import { WizardHog } from 'scenes/onboarding/shared/wizardHog'
+
+import { BannerCallout } from './BannerCallout'
+import { errorTrackingBannersLogic } from './errorTrackingBannersLogic'
+import { SourceMapsFixModal } from './SourceMapsFixModal'
+import { SOURCE_MAPS_DOCS_URL, sourceMapsFixWizardLogic } from './sourceMapsFixWizardLogic'
+import type { SourceMapsRecommendation } from './types'
+
+// Mounts only while the banner is visible, so the "shown" event fires exactly when it was seen.
+export function SourceMapsBanner({
+ recommendation,
+ navigation,
+}: {
+ recommendation: SourceMapsRecommendation
+ navigation?: ReactNode
+}): JSX.Element {
+ const { openModal } = useActions(sourceMapsFixWizardLogic)
+ const { dismissBanner } = useActions(errorTrackingBannersLogic)
+ const percent = Math.round((recommendation.meta.unresolved_pct ?? 0) * 100)
+
+ useOnMountEffect(() => {
+ posthog.capture('error_tracking_source_maps_banner_shown', {
+ unresolved_pct: percent,
+ lookback_hours: recommendation.meta.lookback_hours,
+ })
+ })
+
+ return (
+ <>
+ <BannerCallout
+ illustration={WizardHog}
+ title={`${percent}% of your stack traces aren't readable`}
+ description="Upload source maps to see your original code. Wizard's setup agent can add the uploads to your build."
+ primaryAction={{
+ label: 'Fix with Wizard',
+ icon: <IconMagicWand />,
+ onClick: () => openModal('issues_list'),
+ dataAttr: 'error-tracking-source-maps-banner-wizard',
+ }}
+ secondaryAction={{
+ label: 'Read docs',
+ to: SOURCE_MAPS_DOCS_URL,
+ targetBlank: true,
+ onClick: () =>
+ posthog.capture('error_tracking_source_maps_docs_clicked', { ui_source: 'issues_list' }),
+ dataAttr: 'error-tracking-source-maps-banner-docs',
+ }}
+ navigation={navigation}
+ onDismiss={() => dismissBanner('source_maps')}
+ />
+ <SourceMapsFixModal />
+ </>
+ )
+}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/SourceMapsFixModal.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/SourceMapsFixModal.tsx
similarity index 100%
rename from products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/SourceMapsFixModal.tsx
rename to products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/SourceMapsFixModal.tsx
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/bannerQueue.test.ts b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/bannerQueue.test.ts
new file mode 100644
index 000000000000..ff4d3b0a727f
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/bannerQueue.test.ts
@@ -0,0 +1,114 @@
+import type { ErrorTrackingRecommendationApi } from '../../../generated/api.schemas'
+import {
+ activeBanners,
+ bannerAfterDismiss,
+ BannerCandidateState,
+ candidateState,
+ ErrorTrackingBannerKey,
+ stepBanner,
+} from './bannerQueue'
+
+const recommendation = (overrides: Partial<ErrorTrackingRecommendationApi> = {}): ErrorTrackingRecommendationApi => ({
+ id: 'recommendation',
+ type: 'source_maps',
+ meta: {},
+ completed: false,
+ status: 'ready',
+ computed_at: '2024-07-08T00:00:00Z',
+ dismissed_at: null,
+ created_at: '2024-07-08T00:00:00Z',
+ updated_at: '2024-07-08T00:00:00Z',
+ ...overrides,
+})
+
+describe('banner queue', () => {
+ test.each<[string, ErrorTrackingRecommendationApi | null, BannerCandidateState]>([
+ ['missing row', null, 'not_needed'],
+ ['first compute running', recommendation({ computed_at: null, status: 'computing' }), 'pending'],
+ ['first compute failed', recommendation({ computed_at: null, status: 'ready' }), 'not_needed'],
+ ['recompute running over an old result', recommendation({ status: 'computing' }), 'needed'],
+ ['completed', recommendation({ completed: true }), 'not_needed'],
+ ])('candidate state: %s', (_, input, expected) => {
+ expect(candidateState(input, (r) => !r.completed)).toEqual(expected)
+ })
+
+ const KEYS: ErrorTrackingBannerKey[] = ['source_maps', 'alerts', 'rate_limits']
+
+ test.each<[string, [BannerCandidateState, boolean][], ErrorTrackingBannerKey[]]>([
+ [
+ 'keeps priority order',
+ [
+ ['needed', false],
+ ['needed', false],
+ ['needed', false],
+ ],
+ KEYS,
+ ],
+ [
+ 'skips dismissed',
+ [
+ ['needed', true],
+ ['needed', false],
+ ['needed', false],
+ ],
+ ['alerts', 'rate_limits'],
+ ],
+ [
+ 'skips fixed',
+ [
+ ['needed', false],
+ ['not_needed', false],
+ ['needed', false],
+ ],
+ ['source_maps', 'rate_limits'],
+ ],
+ [
+ 'pending cuts the list there',
+ [
+ ['needed', false],
+ ['pending', false],
+ ['needed', false],
+ ],
+ ['source_maps'],
+ ],
+ [
+ 'dismissed while pending does not cut',
+ [
+ ['pending', true],
+ ['needed', false],
+ ['needed', false],
+ ],
+ ['alerts', 'rate_limits'],
+ ],
+ [
+ 'all dismissed is empty',
+ [
+ ['needed', true],
+ ['needed', true],
+ ['needed', true],
+ ],
+ [],
+ ],
+ ])('active banners: %s', (_, candidates, expected) => {
+ expect(
+ activeBanners(candidates.map(([state, dismissed], index) => ({ key: KEYS[index], state, dismissed })))
+ ).toEqual(expected)
+ })
+
+ test.each<[string, ErrorTrackingBannerKey, 'previous' | 'next', ErrorTrackingBannerKey]>([
+ ['next from the middle', 'alerts', 'next', 'rate_limits'],
+ ['previous from the middle', 'alerts', 'previous', 'source_maps'],
+ ['next from the last wraps to the first', 'rate_limits', 'next', 'source_maps'],
+ ['previous stops at the start', 'source_maps', 'previous', 'source_maps'],
+ ])('step: %s', (_, current, direction, expected) => {
+ expect(stepBanner(KEYS, current, direction)).toEqual(expected)
+ })
+
+ test.each<[string, ErrorTrackingBannerKey[], ErrorTrackingBannerKey, ErrorTrackingBannerKey | null]>([
+ ['moves to the next one', KEYS, 'alerts', 'rate_limits'],
+ ['falls back to the previous one at the end', KEYS, 'rate_limits', 'alerts'],
+ ['empties when the last one goes', ['alerts'], 'alerts', null],
+ ])('after dismiss: %s', (_, active, dismissed, expected) => {
+ expect(bannerAfterDismiss(active, dismissed)).toEqual(expected)
+ })
+})
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/bannerQueue.ts b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/bannerQueue.ts
new file mode 100644
index 000000000000..719e6fbfc8bb
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/bannerQueue.ts
@@ -0,0 +1,74 @@
+import type { ErrorTrackingRecommendationApi } from '../../../generated/api.schemas'
+
+export type ErrorTrackingBannerKey = 'source_maps' | 'alerts' | 'rate_limits'
+
+/** `pending` means the first compute for this banner's check is still running. */
+export type BannerCandidateState = 'pending' | 'needed' | 'not_needed'
+
+export interface BannerCandidate {
+ key: ErrorTrackingBannerKey
+ state: BannerCandidateState
+ dismissed: boolean
+}
+
+export function candidateState<T extends ErrorTrackingRecommendationApi>(
+ recommendation: T | null,
+ isNeeded: (recommendation: T) => boolean
+): BannerCandidateState {
+ if (!recommendation) {
+ return 'not_needed'
+ }
+ if (recommendation.computed_at === null) {
+ // A failed first compute reverts to ready with no result. Skip it so it can't hold back the queue.
+ return recommendation.status === 'computing' ? 'pending' : 'not_needed'
+ }
+ return isNeeded(recommendation) ? 'needed' : 'not_needed'
+}
+
+/**
+ * Candidates arrive in priority order. Returns every banner that applies, in that order. A pending
+ * candidate cuts the list there, so a lower banner never shows and then gets pushed down when the
+ * higher one resolves.
+ */
+export function activeBanners(candidates: BannerCandidate[]): ErrorTrackingBannerKey[] {
+ const active: ErrorTrackingBannerKey[] = []
+ for (const candidate of candidates) {
+ if (candidate.dismissed) {
+ continue
+ }
+ if (candidate.state === 'pending') {
+ return active
+ }
+ if (candidate.state === 'needed') {
+ active.push(candidate.key)
+ }
+ }
+ return active
+}
+
+export function currentBanner(
+ active: ErrorTrackingBannerKey[],
+ selected: ErrorTrackingBannerKey | null
+): ErrorTrackingBannerKey | null {
+ return selected && active.includes(selected) ? selected : (active[0] ?? null)
+}
+
+export function stepBanner(
+ active: ErrorTrackingBannerKey[],
+ current: ErrorTrackingBannerKey | null,
+ direction: 'previous' | 'next'
+): ErrorTrackingBannerKey | null {
+ const index = current ? active.indexOf(current) : -1
+ if (direction === 'next') {
+ return active[(index + 1) % active.length] ?? null
+ }
+ return active[Math.max(index - 1, 0)] ?? null
+}
+
+export function bannerAfterDismiss(
+ active: ErrorTrackingBannerKey[],
+ dismissed: ErrorTrackingBannerKey
+): ErrorTrackingBannerKey | null {
+ const index = active.indexOf(dismissed)
+ return active[index + 1] ?? active[index - 1] ?? null
+}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/configurationSettingUrl.ts b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/configurationSettingUrl.ts
similarity index 100%
rename from products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/configurationSettingUrl.ts
rename to products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/configurationSettingUrl.ts
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/errorTrackingBannersLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/errorTrackingBannersLogic.ts
new file mode 100644
index 000000000000..42476c986df8
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/errorTrackingBannersLogic.ts
@@ -0,0 +1,292 @@
+import { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'
+import posthog from 'posthog-js'
+
+import { lemonBannerLogic } from 'lib/lemon-ui/LemonBanner/lemonBannerLogic'
+
+import { HogFunctionSubTemplateIdType } from '~/types'
+
+import type { ErrorTrackingRecommendationApi } from '../../../generated/api.schemas'
+import {
+ ErrorTrackingBannerKey,
+ activeBanners,
+ bannerAfterDismiss,
+ candidateState,
+ currentBanner,
+ stepBanner,
+} from './bannerQueue'
+import { recommendationsLogic } from './recommendationsLogic'
+import type { AlertsRecommendation, RateLimitsRecommendation, SourceMapsRecommendation } from './types'
+
+// pinned: localStorage keys. Renaming one resets every user's dismissal.
+export const SOURCE_MAPS_BANNER_DISMISS_KEY = 'error-tracking-source-maps-banner'
+export const ALERTS_BANNER_DISMISS_KEY = 'error-tracking-alerts-banner'
+export const RATE_LIMITS_BANNER_DISMISS_KEY = 'error-tracking-rate-limits-banner'
+
+const isSourceMapsRecommendation = (r: ErrorTrackingRecommendationApi): r is SourceMapsRecommendation =>
+ r.type === 'source_maps'
+
+const isAlertsRecommendation = (r: ErrorTrackingRecommendationApi): r is AlertsRecommendation => r.type === 'alerts'
+
+const isRateLimitsRecommendation = (r: ErrorTrackingRecommendationApi): r is RateLimitsRecommendation =>
+ r.type === 'rate_limits'
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface errorTrackingBannersLogicValues {
+ alertsBannerDismissed: boolean // lemonBannerLogic
+ rateLimitsBannerDismissed: boolean // lemonBannerLogic
+ sourceMapsBannerDismissed: boolean // lemonBannerLogic
+ recommendations: ErrorTrackingRecommendationApi[] // recommendationsLogic
+ activeBanners: ErrorTrackingBannerKey[]
+ alertSetupTriggerKey: HogFunctionSubTemplateIdType | null
+ alertsRecommendation: AlertsRecommendation | null
+ currentBanner: ErrorTrackingBannerKey | null
+ currentBannerIndex: number
+ isAlertSetupOpen: boolean
+ rateLimitsRecommendation: RateLimitsRecommendation | null
+ selectedBanner: ErrorTrackingBannerKey | null
+ sourceMapsRecommendation: SourceMapsRecommendation | null
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface errorTrackingBannersLogicActions {
+ dismissAlertsBanner: () => {
+ value: true
+ } // lemonBannerLogic
+ dismissRateLimitsBanner: () => {
+ value: true
+ } // lemonBannerLogic
+ dismissSourceMapsBanner: () => {
+ value: true
+ } // lemonBannerLogic
+ refreshRecommendation: (id: string) => {
+ id: string
+ } // recommendationsLogic
+ closeAlertSetup: () => {
+ value: true
+ }
+ dismissBanner: (banner: ErrorTrackingBannerKey) => {
+ banner: ErrorTrackingBannerKey
+ }
+ openAlertSetup: (triggerKey: HogFunctionSubTemplateIdType | null) => {
+ triggerKey: HogFunctionSubTemplateIdType | null
+ }
+ setSelectedBanner: (banner: ErrorTrackingBannerKey | null) => {
+ banner: ErrorTrackingBannerKey | null
+ }
+ showNextBanner: () => {
+ value: true
+ }
+ showPreviousBanner: () => {
+ value: true
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface errorTrackingBannersLogicMeta {
+ __keaTypeGenInternalSelectorTypes: {
+ sourceMapsRecommendation: (recommendations: ErrorTrackingRecommendationApi[]) => SourceMapsRecommendation | null
+ alertsRecommendation: (recommendations: ErrorTrackingRecommendationApi[]) => AlertsRecommendation | null
+ rateLimitsRecommendation: (recommendations: ErrorTrackingRecommendationApi[]) => RateLimitsRecommendation | null
+ activeBanners: (
+ sourceMapsRecommendation: SourceMapsRecommendation | null,
+ alertsRecommendation: AlertsRecommendation | null,
+ rateLimitsRecommendation: RateLimitsRecommendation | null,
+ sourceMapsBannerDismissed: boolean,
+ alertsBannerDismissed: boolean,
+ rateLimitsBannerDismissed: boolean
+ ) => ErrorTrackingBannerKey[]
+ currentBanner: (
+ activeBanners: ErrorTrackingBannerKey[],
+ selectedBanner: ErrorTrackingBannerKey | null
+ ) => ErrorTrackingBannerKey | null
+ currentBannerIndex: (
+ activeBanners: ErrorTrackingBannerKey[],
+ currentBanner: ErrorTrackingBannerKey | null
+ ) => number
+ }
+}
+
+export type errorTrackingBannersLogicType = MakeLogicType<
+ errorTrackingBannersLogicValues,
+ errorTrackingBannersLogicActions,
+ Record<string, any>,
+ errorTrackingBannersLogicMeta
+>
+
+export const errorTrackingBannersLogic = kea<errorTrackingBannersLogicType>([
+ path(['products', 'error_tracking', 'scenes', 'ErrorTrackingScene', 'banners', 'errorTrackingBannersLogic']),
+
+ connect(() => ({
+ values: [
+ recommendationsLogic,
+ ['recommendations'],
+ lemonBannerLogic({ dismissKey: SOURCE_MAPS_BANNER_DISMISS_KEY }),
+ ['isDismissed as sourceMapsBannerDismissed'],
+ lemonBannerLogic({ dismissKey: ALERTS_BANNER_DISMISS_KEY }),
+ ['isDismissed as alertsBannerDismissed'],
+ lemonBannerLogic({ dismissKey: RATE_LIMITS_BANNER_DISMISS_KEY }),
+ ['isDismissed as rateLimitsBannerDismissed'],
+ ],
+ actions: [
+ recommendationsLogic,
+ ['refreshRecommendation'],
+ lemonBannerLogic({ dismissKey: SOURCE_MAPS_BANNER_DISMISS_KEY }),
+ ['dismiss as dismissSourceMapsBanner'],
+ lemonBannerLogic({ dismissKey: ALERTS_BANNER_DISMISS_KEY }),
+ ['dismiss as dismissAlertsBanner'],
+ lemonBannerLogic({ dismissKey: RATE_LIMITS_BANNER_DISMISS_KEY }),
+ ['dismiss as dismissRateLimitsBanner'],
+ ],
+ })),
+
+ actions({
+ dismissBanner: (banner: ErrorTrackingBannerKey) => ({ banner }),
+ showPreviousBanner: true,
+ showNextBanner: true,
+ setSelectedBanner: (banner: ErrorTrackingBannerKey | null) => ({ banner }),
+ openAlertSetup: (triggerKey: HogFunctionSubTemplateIdType | null) => ({ triggerKey }),
+ closeAlertSetup: true,
+ }),
+
+ reducers({
+ isAlertSetupOpen: [
+ false,
+ {
+ openAlertSetup: () => true,
+ closeAlertSetup: () => false,
+ },
+ ],
+ alertSetupTriggerKey: [
+ null as HogFunctionSubTemplateIdType | null,
+ {
+ openAlertSetup: (_, { triggerKey }) => triggerKey,
+ },
+ ],
+ selectedBanner: [
+ null as ErrorTrackingBannerKey | null,
+ {
+ setSelectedBanner: (_, { banner }) => banner,
+ },
+ ],
+ }),
+
+ selectors({
+ sourceMapsRecommendation: [
+ (s) => [s.recommendations],
+ (recommendations: ErrorTrackingRecommendationApi[]): SourceMapsRecommendation | null =>
+ recommendations.find(isSourceMapsRecommendation) ?? null,
+ ],
+ alertsRecommendation: [
+ (s) => [s.recommendations],
+ (recommendations: ErrorTrackingRecommendationApi[]): AlertsRecommendation | null =>
+ recommendations.find(isAlertsRecommendation) ?? null,
+ ],
+ rateLimitsRecommendation: [
+ (s) => [s.recommendations],
+ (recommendations: ErrorTrackingRecommendationApi[]): RateLimitsRecommendation | null =>
+ recommendations.find(isRateLimitsRecommendation) ?? null,
+ ],
+ activeBanners: [
+ (s) => [
+ s.sourceMapsRecommendation,
+ s.alertsRecommendation,
+ s.rateLimitsRecommendation,
+ s.sourceMapsBannerDismissed,
+ s.alertsBannerDismissed,
+ s.rateLimitsBannerDismissed,
+ ],
+ (
+ sourceMapsRecommendation: SourceMapsRecommendation | null,
+ alertsRecommendation: AlertsRecommendation | null,
+ rateLimitsRecommendation: RateLimitsRecommendation | null,
+ sourceMapsBannerDismissed: boolean,
+ alertsBannerDismissed: boolean,
+ rateLimitsBannerDismissed: boolean
+ ): ErrorTrackingBannerKey[] =>
+ // Unreadable stack traces block triage, so that banner goes first.
+ activeBanners([
+ {
+ key: 'source_maps',
+ state: candidateState(sourceMapsRecommendation, (r) => !r.completed),
+ dismissed: sourceMapsBannerDismissed,
+ },
+ {
+ key: 'alerts',
+ state: candidateState(
+ alertsRecommendation,
+ (r) => !r.completed && (r.meta.alerts ?? []).length > 0
+ ),
+ dismissed: alertsBannerDismissed,
+ },
+ {
+ key: 'rate_limits',
+ // Only the project-wide limit gets a banner. The per-issue limit is optional tuning.
+ state: candidateState(rateLimitsRecommendation, (r) =>
+ (r.meta.rate_limits ?? []).some((limit) => limit.key === 'project' && !limit.enabled)
+ ),
+ dismissed: rateLimitsBannerDismissed,
+ },
+ ]),
+ ],
+ currentBanner: [
+ (s) => [s.activeBanners, s.selectedBanner],
+ (
+ active: ErrorTrackingBannerKey[],
+ selected: ErrorTrackingBannerKey | null
+ ): ErrorTrackingBannerKey | null => currentBanner(active, selected),
+ ],
+ currentBannerIndex: [
+ (s) => [s.activeBanners, s.currentBanner],
+ (active: ErrorTrackingBannerKey[], current: ErrorTrackingBannerKey | null): number =>
+ current ? active.indexOf(current) : -1,
+ ],
+ }),
+
+ listeners(({ actions, values }) => {
+ const navigateTo = (direction: 'previous' | 'next'): void => {
+ const target = stepBanner(values.activeBanners, values.currentBanner, direction)
+ if (!target || target === values.currentBanner) {
+ return
+ }
+ actions.setSelectedBanner(target)
+ posthog.capture('error_tracking_banner_navigated', {
+ banner: target,
+ direction,
+ position: values.activeBanners.indexOf(target) + 1,
+ total: values.activeBanners.length,
+ })
+ }
+
+ return {
+ dismissBanner: ({ banner }) => {
+ // Keep the user at the same spot in the stack rather than jumping back to the top.
+ if (banner === values.currentBanner) {
+ actions.setSelectedBanner(bannerAfterDismiss(values.activeBanners, banner))
+ }
+ if (banner === 'source_maps') {
+ actions.dismissSourceMapsBanner()
+ } else if (banner === 'alerts') {
+ actions.dismissAlertsBanner()
+ } else {
+ actions.dismissRateLimitsBanner()
+ }
+ // pinned: analytics event names. Renaming them breaks dashboards.
+ posthog.capture(`error_tracking_${banner}_banner_dismissed`)
+ },
+ showPreviousBanner: () => navigateTo('previous'),
+ showNextBanner: () => navigateTo('next'),
+ openAlertSetup: ({ triggerKey }) => {
+ posthog.capture('error_tracking_alert_creation_started', {
+ ui_source: 'alerts_banner',
+ trigger_key: triggerKey,
+ })
+ },
+ closeAlertSetup: () => {
+ // Recompute right away so the banner hides, or narrows to the alerts still missing.
+ if (values.alertsRecommendation) {
+ actions.refreshRecommendation(values.alertsRecommendation.id)
+ }
+ },
+ }
+ }),
+])
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/recommendationsLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/recommendationsLogic.ts
new file mode 100644
index 000000000000..2f5283107863
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/recommendationsLogic.ts
@@ -0,0 +1,148 @@
+import { MakeLogicType, actions, afterMount, kea, listeners, path, reducers } from 'kea'
+import posthog from 'posthog-js'
+
+import { lemonToast } from '@posthog/lemon-ui'
+
+import { teamLogic } from 'scenes/teamLogic'
+
+import { errorTrackingRecommendationsList, errorTrackingRecommendationsRefreshCreate } from '../../../generated/api'
+import type { ErrorTrackingRecommendationApi } from '../../../generated/api.schemas'
+
+const POLL_INTERVAL_MS = 500
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface recommendationsLogicValues {
+ recommendations: ErrorTrackingRecommendationApi[]
+ recommendationsLoading: boolean
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface recommendationsLogicActions {
+ ensurePollingScheduled: () => {
+ value: true
+ }
+ loadRecommendations: () => {
+ value: true
+ }
+ markRecommendationComputing: (id: string) => {
+ id: string
+ }
+ pollRecommendations: () => {
+ value: true
+ }
+ refreshRecommendation: (id: string) => {
+ id: string
+ }
+ setRecommendations: (recommendations: ErrorTrackingRecommendationApi[]) => {
+ recommendations: ErrorTrackingRecommendationApi[]
+ }
+ setRecommendationsLoading: (loading: boolean) => {
+ loading: boolean
+ }
+ upsertRecommendation: (recommendation: ErrorTrackingRecommendationApi) => {
+ recommendation: ErrorTrackingRecommendationApi
+ }
+}
+
+export type recommendationsLogicType = MakeLogicType<recommendationsLogicValues, recommendationsLogicActions>
+
+// The backend `status` field is the single source of truth for "is this recommendation
+// being computed". The frontend optimistically flips status to 'computing' before issuing
+// a refresh HTTP call, and polls until no recommendation is computing. The optimistic value
+// converges with the server response since both arrive at status='computing'.
+export const recommendationsLogic = kea<recommendationsLogicType>([
+ path(['products', 'error_tracking', 'scenes', 'ErrorTrackingScene', 'banners', 'recommendationsLogic']),
+
+ actions({
+ loadRecommendations: true,
+ pollRecommendations: true,
+ refreshRecommendation: (id: string) => ({ id }),
+
+ setRecommendations: (recommendations: ErrorTrackingRecommendationApi[]) => ({ recommendations }),
+ upsertRecommendation: (recommendation: ErrorTrackingRecommendationApi) => ({ recommendation }),
+ markRecommendationComputing: (id: string) => ({ id }),
+ setRecommendationsLoading: (loading: boolean) => ({ loading }),
+
+ ensurePollingScheduled: true,
+ }),
+
+ reducers({
+ recommendations: [
+ [] as ErrorTrackingRecommendationApi[],
+ {
+ setRecommendations: (_, { recommendations }) => recommendations,
+ upsertRecommendation: (state, { recommendation }) =>
+ state.map((r) => (r.id === recommendation.id ? recommendation : r)),
+ markRecommendationComputing: (state, { id }) =>
+ state.map((r) => (r.id === id ? { ...r, status: 'computing' } : r)),
+ },
+ ],
+ recommendationsLoading: [
+ true,
+ {
+ setRecommendationsLoading: (_, { loading }) => loading,
+ },
+ ],
+ }),
+
+ listeners(({ actions, values, cache }) => ({
+ loadRecommendations: async () => {
+ actions.setRecommendationsLoading(true)
+ try {
+ const response = await errorTrackingRecommendationsList(String(teamLogic.values.currentTeamId))
+ actions.setRecommendations(response.results)
+ posthog.capture('error_tracking_recommendations_loaded', {
+ open_count: response.results.filter((r) => !r.dismissed_at && !r.completed).length,
+ completed_count: response.results.filter((r) => !r.dismissed_at && r.completed).length,
+ dismissed_count: response.results.filter((r) => !!r.dismissed_at).length,
+ total_count: response.results.length,
+ })
+ } finally {
+ actions.setRecommendationsLoading(false)
+ }
+ },
+ pollRecommendations: async () => {
+ try {
+ const response = await errorTrackingRecommendationsList(String(teamLogic.values.currentTeamId), {
+ poll: true,
+ })
+ actions.setRecommendations(response.results)
+ } catch {
+ actions.ensurePollingScheduled()
+ }
+ },
+ refreshRecommendation: async ({ id }) => {
+ actions.markRecommendationComputing(id)
+ try {
+ const updated = await errorTrackingRecommendationsRefreshCreate(
+ String(teamLogic.values.currentTeamId),
+ id
+ )
+ actions.upsertRecommendation(updated)
+ } catch {
+ lemonToast.error("Couldn't refresh your error tracking setup. Reload the page to try again.")
+ // Polling will reconcile state regardless of which side errored.
+ }
+ },
+
+ // Polling lifecycle: any time the recommendations state changes, re-evaluate
+ // whether we still need to poll. The shared key keeps one timer at a time.
+ setRecommendations: () => actions.ensurePollingScheduled(),
+ upsertRecommendation: () => actions.ensurePollingScheduled(),
+ markRecommendationComputing: () => actions.ensurePollingScheduled(),
+ ensurePollingScheduled: () => {
+ if (!values.recommendations.some((r) => r.status === 'computing')) {
+ cache.disposables.dispose('poll')
+ return
+ }
+ cache.disposables.add(() => {
+ const timeoutId = window.setTimeout(() => actions.pollRecommendations(), POLL_INTERVAL_MS)
+ return () => window.clearTimeout(timeoutId)
+ }, 'poll')
+ },
+ })),
+
+ afterMount(({ actions }) => {
+ actions.loadRecommendations()
+ }),
+])
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/sourceMapsFixWizardLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/sourceMapsFixWizardLogic.ts
similarity index 94%
rename from products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/sourceMapsFixWizardLogic.ts
rename to products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/sourceMapsFixWizardLogic.ts
index 31243682cedd..98defcb76e9c 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/sourceMapsFixWizardLogic.ts
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/sourceMapsFixWizardLogic.ts
@@ -7,10 +7,10 @@ import { getSurveyIdBasedResponseKey, getSurveyResponseKey } from 'scenes/survey
import { SurveyEventName, SurveyEventProperties } from '~/types'
-import type { FeatureFlagsSet } from '../../../../../../../frontend/src/lib/logic/featureFlagLogic'
+import type { FeatureFlagsSet } from '../../../../../../frontend/src/lib/logic/featureFlagLogic'
export type WizardRating = 'good' | 'bad'
-export type WizardOpenSource = 'issues_list' | 'recommendations'
+export type WizardOpenSource = 'issues_list'
export const SOURCE_MAPS_DOCS_URL = 'https://posthog.com/docs/error-tracking/upload-source-maps'
@@ -49,7 +49,7 @@ export interface sourceMapsFixWizardLogicActions {
value: true
}
openModal: (source: WizardOpenSource) => {
- source: WizardOpenSource
+ source: 'issues_list'
}
rateWizard: (rating: WizardRating) => {
rating: WizardRating
@@ -83,15 +83,7 @@ export type sourceMapsFixWizardLogicType = MakeLogicType<
>
export const sourceMapsFixWizardLogic = kea<sourceMapsFixWizardLogicType>([
- path([
- 'products',
- 'error_tracking',
- 'scenes',
- 'ErrorTrackingScene',
- 'tabs',
- 'recommendations',
- 'sourceMapsFixWizardLogic',
- ]),
+ path(['products', 'error_tracking', 'scenes', 'ErrorTrackingScene', 'banners', 'sourceMapsFixWizardLogic']),
connect(() => ({
values: [featureFlagLogic, ['featureFlags']],
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/sourceMapsWizardVisuals.scss b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/sourceMapsWizardVisuals.scss
similarity index 100%
rename from products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/sourceMapsWizardVisuals.scss
rename to products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/sourceMapsWizardVisuals.scss
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/sourceMapsWizardVisuals.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/sourceMapsWizardVisuals.tsx
similarity index 100%
rename from products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/sourceMapsWizardVisuals.tsx
rename to products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/sourceMapsWizardVisuals.tsx
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/townCrierHog.ts b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/townCrierHog.ts
new file mode 100644
index 000000000000..c11a85aa3cfa
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/townCrierHog.ts
@@ -0,0 +1,5 @@
+import * as townCrierPng from '@posthog/brand/hoggies/png/town-crier'
+
+import { pngHoggie } from 'lib/brand/hoggies'
+
+export const TownCrierHog = pngHoggie(townCrierPng)
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/trafficControllerHog.ts b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/trafficControllerHog.ts
new file mode 100644
index 000000000000..2587d3d25807
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/trafficControllerHog.ts
@@ -0,0 +1,5 @@
+import * as trafficControllerPng from '@posthog/brand/hoggies/png/traffic-controller'
+
+import { pngHoggie } from 'lib/brand/hoggies'
+
+export const TrafficControllerHog = pngHoggie(trafficControllerPng)
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/types.ts b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/types.ts
new file mode 100644
index 000000000000..c0e8e1c549ea
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/banners/types.ts
@@ -0,0 +1,51 @@
+import { HogFunctionSubTemplateIdType } from '~/types'
+
+import type { ErrorTrackingRecommendationApi } from '../../../generated/api.schemas'
+
+// The serializer types `meta` as an untyped JSON field, so each banner narrows it here.
+export type RecommendationWithMeta<TType extends string, TMeta> = Omit<ErrorTrackingRecommendationApi, 'meta'> & {
+ type: TType
+ meta: TMeta
+}
+
+export interface AlertRecommendationItem {
+ key: HogFunctionSubTemplateIdType
+ enabled: boolean
+}
+
+export interface AlertsRecommendationMeta {
+ alerts: AlertRecommendationItem[]
+}
+
+export type AlertsRecommendation = RecommendationWithMeta<'alerts', AlertsRecommendationMeta>
+
+export interface SourceMapsRecommendationMeta {
+ total_frames: number
+ unresolved_frames: number
+ unresolved_pct: number
+ threshold_pct: number
+ min_sample_frames: number
+ lookback_hours: number
+}
+
+export type SourceMapsRecommendation = RecommendationWithMeta<'source_maps', SourceMapsRecommendationMeta>
+
+export type RateLimitKey = 'project' | 'per_issue'
+
+export interface RateLimitRecommendationItem {
+ key: RateLimitKey
+ enabled: boolean
+}
+
+export interface RateLimitsRecommendationMeta {
+ rate_limits: RateLimitRecommendationItem[]
+}
+
+export type RateLimitsRecommendation = RecommendationWithMeta<'rate_limits', RateLimitsRecommendationMeta>
+
+/** Fills "alerts for ___ issues" in the alerts banner title. */
+export const ALERT_TRIGGER_ADJECTIVES: Partial<Record<HogFunctionSubTemplateIdType, string>> = {
+ 'error-tracking-issue-created': 'new',
+ 'error-tracking-issue-reopened': 'reopened',
+ 'error-tracking-issue-spiking': 'spiking',
+}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/errorTrackingSceneLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingScene/errorTrackingSceneLogic.ts
index ce26017f19e8..f044cce4ef94 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingScene/errorTrackingSceneLogic.ts
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/errorTrackingSceneLogic.ts
@@ -44,7 +44,12 @@ export const ERROR_TRACKING_SCENE_LOGIC_KEY = 'ErrorTrackingScene'
const DEFAULT_ACTIVE_TAB = 'issues'
-export type ErrorTrackingSceneActiveTab = 'issues' | 'insights' | 'recommendations' | 'configuration'
+const ACTIVE_TABS = ['issues', 'insights', 'configuration'] as const
+
+export type ErrorTrackingSceneActiveTab = (typeof ACTIVE_TABS)[number]
+
+const isActiveTab = (value: unknown): value is ErrorTrackingSceneActiveTab =>
+ ACTIVE_TABS.includes(value as ErrorTrackingSceneActiveTab)
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface errorTrackingSceneLogicValues {
@@ -111,7 +116,7 @@ export interface errorTrackingSceneLogicActions {
setting: SettingId
} // settingsLogic
setActiveTab: (activeTab: ErrorTrackingSceneActiveTab) => {
- activeTab: ErrorTrackingSceneActiveTab
+ activeTab: 'configuration' | 'insights' | 'issues'
}
}
@@ -268,7 +273,8 @@ export const errorTrackingSceneLogic = kea<errorTrackingSceneLogicType>([
urlToAction(({ actions, values }) => {
return {
'**/error-tracking': (_, params, hashParams) => {
- if (params.activeTab && !equal(params.activeTab, values.activeTab)) {
+ // Old links can name a tab that no longer exists, such as `recommendations`.
+ if (isActiveTab(params.activeTab) && !equal(params.activeTab, values.activeTab)) {
actions.setActiveTab(params.activeTab)
}
if (hashParams.selectedSetting && hashParams.selectedSetting !== values.selectedSettingId) {
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/issues/SourceMapsBanner.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/issues/SourceMapsBanner.tsx
deleted file mode 100644
index 92dfa51cf82b..000000000000
--- a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/issues/SourceMapsBanner.tsx
+++ /dev/null
@@ -1,89 +0,0 @@
-import { useActions, useValues } from 'kea'
-import posthog from 'posthog-js'
-
-import { IconMagicWand, IconX } from '@posthog/icons'
-import { LemonButton } from '@posthog/lemon-ui'
-
-import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'
-import { lemonBannerLogic } from 'lib/lemon-ui/LemonBanner/lemonBannerLogic'
-
-import { isSourceMapsRecommendation, recommendationsTabLogic } from '../recommendations/recommendationsTabLogic'
-import { SourceMapsFixModal } from '../recommendations/SourceMapsFixModal'
-import { SOURCE_MAPS_DOCS_URL, sourceMapsFixWizardLogic } from '../recommendations/sourceMapsFixWizardLogic'
-import { WizardHog } from '../recommendations/sourceMapsWizardVisuals'
-
-// Dismissal is independent of the source maps recommendation's own dismissed_at —
-// dismissing here only hides this banner, via the standard localStorage-backed pattern.
-const DISMISS_KEY = 'error-tracking-source-maps-banner'
-
-export function SourceMapsBanner(): JSX.Element | null {
- const { recommendations } = useValues(recommendationsTabLogic)
- const { isDismissed } = useValues(lemonBannerLogic({ dismissKey: DISMISS_KEY }))
-
- const sourceMaps = recommendations.find(isSourceMapsRecommendation)
- // Show only once computed and while there's an actual problem (not completed),
- // regardless of whether the recommendation itself was dismissed.
- if (!sourceMaps || sourceMaps.computed_at === null || sourceMaps.completed || isDismissed) {
- return null
- }
-
- const percent = Math.round((sourceMaps.meta.unresolved_pct ?? 0) * 100)
- const lookbackHours = sourceMaps.meta.lookback_hours
-
- return <SourceMapsBannerContent percent={percent} lookbackHours={lookbackHours} />
-}
-
-// Inner component so the "shown" event fires exactly when the banner becomes visible —
-// the outer guards (including dismissal) gate the mount, so mounting here means it was seen.
-function SourceMapsBannerContent({ percent, lookbackHours }: { percent: number; lookbackHours: number }): JSX.Element {
- const { openModal } = useActions(sourceMapsFixWizardLogic)
- const { dismiss } = useActions(lemonBannerLogic({ dismissKey: DISMISS_KEY }))
-
- useOnMountEffect(() => {
- posthog.capture('error_tracking_source_maps_banner_shown', {
- unresolved_pct: percent,
- lookback_hours: lookbackHours,
- })
- })
-
- return (
- <>
- <div className="mb-2">
- <div className="@container rounded-lg border border-border bg-bg-light pl-3 pr-4 py-3 mt-2">
- <div className="flex flex-wrap items-center gap-x-4 gap-y-2">
- {/* The hog is absolutely positioned so it doesn't drive the card height —
- it overflows the card edges slightly by design. */}
- <div className="relative hidden @2xl:block shrink-0 self-stretch w-20">
- <div className="absolute inset-x-0 top-1/2 -translate-y-1/2 pointer-events-none">
- <div className="absolute -inset-2 bg-[radial-gradient(circle,rgba(43,111,244,0.18),transparent_70%)]" />
- <WizardHog className="relative w-20 h-20 -rotate-3" />
- </div>
- </div>
- <div className="flex-1 basis-80 min-w-0">
- <div className="font-semibold">{percent}% of your stack traces aren't readable</div>
- <div className="text-sm text-secondary">
- Let the wizard set up automatic uploads in your project.
- </div>
- </div>
- <div className="flex min-w-0 max-w-full flex-wrap items-center justify-end gap-4 ml-auto">
- <LemonButton type="tertiary" size="small" to={SOURCE_MAPS_DOCS_URL} targetBlank>
- Read docs
- </LemonButton>
- <LemonButton
- type="secondary"
- icon={<IconMagicWand />}
- onClick={() => openModal('issues_list')}
- >
- <span className="rainbow-text rainbow-text-animating font-semibold">
- Fix with AI wizard
- </span>
- </LemonButton>
- <LemonButton size="xsmall" icon={<IconX />} onClick={dismiss} aria-label="Dismiss banner" />
- </div>
- </div>
- </div>
- </div>
- <SourceMapsFixModal />
- </>
- )
-}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/AlertsRecommendationCard.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/AlertsRecommendationCard.tsx
deleted file mode 100644
index 843961de097a..000000000000
--- a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/AlertsRecommendationCard.tsx
+++ /dev/null
@@ -1,157 +0,0 @@
-import { BindLogic, useActions, useValues } from 'kea'
-import { router } from 'kea-router'
-import posthog from 'posthog-js'
-
-import { LemonButton, LemonModal } from '@posthog/lemon-ui'
-
-import { AlertWizard } from 'lib/components/Alerting/AlertWizard/AlertWizard'
-import {
- AlertCreationView,
- AlertWizardLogicProps,
- alertWizardLogic,
-} from 'lib/components/Alerting/AlertWizard/alertWizardLogic'
-
-import { HogFunctionSubTemplateIdType } from '~/types'
-
-import {
- ERROR_TRACKING_DESTINATIONS,
- ERROR_TRACKING_SUB_TEMPLATE_IDS,
- ERROR_TRACKING_TRIGGERS,
-} from '../../../ErrorTrackingConfigurationScene/alerting/alertWizardConfig'
-import { errorTrackingConfigurationSettingUrl } from './configurationSettingUrl'
-import { ListRecommendationCard } from './ListRecommendationCard'
-import { recommendationsTabLogic } from './recommendationsTabLogic'
-import { ALERT_RECOMMENDATION_INFO, AlertsRecommendation } from './types'
-
-export function AlertsRecommendationCard({
- recommendation,
- dismissed,
-}: {
- recommendation: AlertsRecommendation
- dismissed?: boolean
-}): JSX.Element | null {
- const { refreshRecommendation, setOpenAlertTriggerKey } = useActions(recommendationsTabLogic)
- const { openAlertTriggerKey } = useValues(recommendationsTabLogic)
- const alerts = recommendation.meta.alerts ?? []
-
- if (alerts.length === 0) {
- if (recommendation.computed_at === null) {
- return (
- <ListRecommendationCard
- recommendationId={recommendation.id}
- title="Alert coverage"
- description="Stay ahead of new and resurfacing issues."
- dismissed={dismissed}
- items={[]}
- progressLabel="configured"
- />
- )
- }
- return null
- }
-
- const items = alerts
- .map((alert) => {
- const info = ALERT_RECOMMENDATION_INFO[alert.key]
- if (!info) {
- return null
- }
- return {
- key: alert.key,
- enabled: alert.enabled,
- name: info.name,
- reason: info.reason,
- action: (
- <LemonButton
- size="xsmall"
- type="secondary"
- onClick={() => {
- posthog.capture('error_tracking_alert_creation_started', {
- ui_source: 'recommendation_modal',
- trigger_key: alert.key,
- })
- setOpenAlertTriggerKey(alert.key)
- }}
- >
- Create alert
- </LemonButton>
- ),
- }
- })
- .filter((i): i is NonNullable<typeof i> => i !== null)
-
- return (
- <>
- <ListRecommendationCard
- recommendationId={recommendation.id}
- title="Alert coverage"
- description="Stay ahead of new and resurfacing issues."
- dismissed={dismissed}
- items={items}
- progressLabel="configured"
- />
- {openAlertTriggerKey && (
- <AlertsRecommendationWizardModal
- triggerKey={openAlertTriggerKey}
- onClose={() => {
- setOpenAlertTriggerKey(null)
- refreshRecommendation(recommendation.id)
- }}
- />
- )}
- </>
- )
-}
-
-function AlertsRecommendationWizardModal({
- triggerKey,
- onClose,
-}: {
- triggerKey: HogFunctionSubTemplateIdType
- onClose: () => void
-}): JSX.Element {
- const wizardProps: AlertWizardLogicProps = {
- logicKey: `error-tracking-recommendation-${triggerKey}`,
- subTemplateIds: ERROR_TRACKING_SUB_TEMPLATE_IDS,
- triggers: ERROR_TRACKING_TRIGGERS,
- destinations: ERROR_TRACKING_DESTINATIONS,
- disableUrlSync: true,
- presetTriggerKey: triggerKey,
- contextId: 'error-tracking',
- onAlertCreated: onClose,
- }
-
- return (
- <LemonModal isOpen onClose={onClose} width={560} simple>
- <BindLogic logic={alertWizardLogic} props={wizardProps}>
- <AlertsRecommendationWizardContent onClose={onClose} />
- </BindLogic>
- </LemonModal>
- )
-}
-
-function AlertsRecommendationWizardContent({ onClose }: { onClose: () => void }): JSX.Element {
- const { setAlertCreationView, resetWizard } = useActions(alertWizardLogic)
-
- return (
- <div className="p-4">
- <AlertWizard
- hideTriggerStep
- hideCloseButton
- onCancel={() => {
- setAlertCreationView(AlertCreationView.None)
- resetWizard()
- onClose()
- }}
- onSwitchToTraditional={() => {
- posthog.capture('error_tracking_alert_creation_switched_to_traditional', {
- ui_source: 'recommendation_modal',
- })
- resetWizard()
- onClose()
- router.actions.push(errorTrackingConfigurationSettingUrl('error-tracking-alerting'))
- }}
- />
- </div>
- )
-}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/ListRecommendationCard.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/ListRecommendationCard.tsx
deleted file mode 100644
index 317bb5d8fae8..000000000000
--- a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/ListRecommendationCard.tsx
+++ /dev/null
@@ -1,53 +0,0 @@
-import { ReactNode } from 'react'
-
-import { RecommendationCard, RecommendationCardProps } from './RecommendationCard'
-
-export interface ListRecommendationItem {
- key: string
- enabled: boolean
- name: string
- reason?: string
- action?: ReactNode
-}
-
-export interface ListRecommendationCardProps extends Omit<
- RecommendationCardProps,
- 'progress' | 'children' | 'description'
-> {
- description?: string
- items: ListRecommendationItem[]
- progressLabel: string
-}
-
-export function ListRecommendationCard({
- items,
- progressLabel,
- ...cardProps
-}: ListRecommendationCardProps): JSX.Element {
- const enabledCount = items.filter((i) => i.enabled).length
-
- return (
- <RecommendationCard
- {...cardProps}
- progress={{ current: enabledCount, total: items.length, label: progressLabel }}
- >
- <div className="flex flex-col gap-0">
- {items.map((item) => (
- <div
- key={item.key}
- className={`flex items-center gap-3 py-2 border-b last:border-b-0 ${item.enabled ? 'opacity-60' : ''}`}
- >
- <div
- className={`w-1.5 h-1.5 rounded-full shrink-0 ${item.enabled ? 'bg-success' : 'bg-muted'}`}
- />
- <div className="flex-1">
- <span className="text-sm font-medium">{item.name}</span>
- {item.reason && <p className="text-xs text-muted m-0">{item.reason}</p>}
- </div>
- {!item.enabled && item.action}
- </div>
- ))}
- </div>
- </RecommendationCard>
- )
-}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/LongRunningIssuesRecommendationCard.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/LongRunningIssuesRecommendationCard.tsx
deleted file mode 100644
index 7b017248de57..000000000000
--- a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/LongRunningIssuesRecommendationCard.tsx
+++ /dev/null
@@ -1,117 +0,0 @@
-import { useActions } from 'kea'
-
-import { LemonButton, LemonTag, Link } from '@posthog/lemon-ui'
-
-import { dayjs } from 'lib/dayjs'
-import { humanFriendlyLargeNumber } from 'lib/utils/numbers'
-import { urls } from 'scenes/urls'
-
-import { RecommendationCard } from './RecommendationCard'
-import { recommendationsTabLogic } from './recommendationsTabLogic'
-import type { LongRunningIssuesRecommendation } from './types'
-
-export function LongRunningIssuesRecommendationCard({
- recommendation,
- dismissed,
-}: {
- recommendation: LongRunningIssuesRecommendation
- dismissed?: boolean
-}): JSX.Element | null {
- const { suppressIssue, activateIssue } = useActions(recommendationsTabLogic)
-
- const issues = recommendation.meta.issues ?? []
- const isFirstLoad = recommendation.computed_at === null
-
- if (isFirstLoad) {
- return (
- <RecommendationCard
- recommendationId={recommendation.id}
- title="Long-running issues"
- description="Your oldest active issues that are still firing this week — worth a second look."
- dismissed={dismissed}
- />
- )
- }
-
- if (issues.length === 0) {
- return (
- <RecommendationCard recommendationId={recommendation.id} title="Long-running issues" dismissed={dismissed}>
- <div className="text-sm text-secondary">No long-running issues right now — nice work!</div>
- </RecommendationCard>
- )
- }
-
- return (
- <RecommendationCard
- recommendationId={recommendation.id}
- title="Long-running issues"
- description="Your oldest active issues that are still firing this week — worth a second look."
- dismissed={dismissed}
- >
- <div className="flex flex-col gap-0">
- {issues.map((issue) => {
- const isActive = issue.status === 'active'
- return (
- <div key={issue.id} className="border-b last:border-b-0">
- <Link
- subtle
- to={urls.errorTrackingIssue(issue.id)}
- className={`group flex items-center gap-3 py-2 no-underline ${
- isActive ? '' : 'opacity-60'
- }`}
- >
- <div
- className={`w-1.5 h-1.5 rounded-full shrink-0 ${
- isActive ? 'bg-warning' : 'bg-muted'
- }`}
- />
- <div className="flex-1 min-w-0">
- <div className="text-sm font-medium truncate flex items-center gap-2">
- <span className="truncate">{issue.name}</span>
- {!isActive && (
- <LemonTag size="small" type="muted">
- {issue.status}
- </LemonTag>
- )}
- </div>
- <div className="text-xs text-secondary">
- {dayjs(issue.created_at).fromNow(true)} old ·{' '}
- {humanFriendlyLargeNumber(issue.occurrences)} occurrences in last 7 days
- </div>
- </div>
- <div className="opacity-0 group-hover:opacity-100 transition-opacity">
- {isActive ? (
- <LemonButton
- size="xsmall"
- type="secondary"
- status="danger"
- onClick={(e) => {
- e.preventDefault()
- e.stopPropagation()
- suppressIssue(issue.id)
- }}
- >
- Suppress
- </LemonButton>
- ) : (
- <LemonButton
- size="xsmall"
- type="secondary"
- onClick={(e) => {
- e.preventDefault()
- e.stopPropagation()
- activateIssue(issue.id)
- }}
- >
- Undo
- </LemonButton>
- )}
- </div>
- </Link>
- </div>
- )
- })}
- </div>
- </RecommendationCard>
- )
-}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/RateLimitsRecommendationCard.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/RateLimitsRecommendationCard.tsx
deleted file mode 100644
index 24bd4a3303cf..000000000000
--- a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/RateLimitsRecommendationCard.tsx
+++ /dev/null
@@ -1,71 +0,0 @@
-import posthog from 'posthog-js'
-
-import { LemonButton } from '@posthog/lemon-ui'
-
-import { errorTrackingConfigurationSettingUrl } from './configurationSettingUrl'
-import { ListRecommendationCard } from './ListRecommendationCard'
-import { RATE_LIMIT_RECOMMENDATION_INFO, RateLimitsRecommendation } from './types'
-
-const RATE_LIMITS_SETTINGS_URL = errorTrackingConfigurationSettingUrl('error-tracking-rate-limits')
-
-export function RateLimitsRecommendationCard({
- recommendation,
- dismissed,
-}: {
- recommendation: RateLimitsRecommendation
- dismissed?: boolean
-}): JSX.Element | null {
- const rateLimits = recommendation.meta.rate_limits ?? []
-
- if (rateLimits.length === 0) {
- if (recommendation.computed_at === null) {
- return (
- <ListRecommendationCard
- recommendationId={recommendation.id}
- title="Rate limits"
- description="Protect ingestion from runaway exception volume."
- dismissed={dismissed}
- items={[]}
- progressLabel="configured"
- />
- )
- }
- return null
- }
-
- const items = rateLimits.map((rateLimit) => {
- const info = RATE_LIMIT_RECOMMENDATION_INFO[rateLimit.key]
- return {
- key: rateLimit.key,
- enabled: rateLimit.enabled,
- name: info.name,
- reason: info.reason,
- action: (
- <LemonButton
- size="xsmall"
- type="secondary"
- to={RATE_LIMITS_SETTINGS_URL}
- onClick={() => {
- posthog.capture('error_tracking_rate_limit_setup_started', {
- ui_source: 'recommendation_card',
- rate_limit_key: rateLimit.key,
- })
- }}
- >
- Set limit
- </LemonButton>
- ),
- }
- })
-
- return (
- <ListRecommendationCard
- recommendationId={recommendation.id}
- title="Rate limits"
- description="Protect ingestion from runaway exception volume."
- dismissed={dismissed}
- items={items}
- progressLabel="configured"
- />
- )
-}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/RecommendationCard.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/RecommendationCard.tsx
deleted file mode 100644
index 792099dfce44..000000000000
--- a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/RecommendationCard.tsx
+++ /dev/null
@@ -1,82 +0,0 @@
-import { useActions, useValues } from 'kea'
-import { ReactNode } from 'react'
-
-import { IconRefresh, IconX } from '@posthog/icons'
-import { LemonButton, Spinner } from '@posthog/lemon-ui'
-
-import { recommendationsTabLogic } from './recommendationsTabLogic'
-
-export interface RecommendationCardProps {
- recommendationId: string
- title: string
- description?: string
- progress?: { current: number; total: number; label: string }
- dismissed?: boolean
- children?: ReactNode
-}
-
-export function RecommendationCard({
- recommendationId,
- title,
- description,
- progress,
- dismissed,
- children,
-}: RecommendationCardProps): JSX.Element {
- const { dismissRecommendation, restoreRecommendation, refreshRecommendation } = useActions(recommendationsTabLogic)
- const { computingIds } = useValues(recommendationsTabLogic)
- const isComputing = computingIds.has(recommendationId)
-
- return (
- <div className="border rounded-lg bg-surface-primary p-4" aria-busy={isComputing}>
- <div className="flex items-center justify-between mb-1">
- <h3 className="font-semibold text-sm m-0">{title}</h3>
- <div className="flex items-center gap-2">
- {progress && (
- <>
- <span className="text-xs text-muted">
- {progress.current} / {progress.total} {progress.label}
- </span>
- <div className="w-20 h-1.5 bg-border rounded-full">
- <div
- className="h-1.5 bg-success rounded-full"
- // eslint-disable-next-line react/forbid-dom-props
- style={{
- width: `${progress.total === 0 ? 0 : (progress.current / progress.total) * 100}%`,
- }}
- />
- </div>
- </>
- )}
- <LemonButton
- size="xsmall"
- type="tertiary"
- icon={isComputing ? <Spinner /> : <IconRefresh />}
- disabled={isComputing}
- onClick={() => refreshRecommendation(recommendationId)}
- tooltip="Refresh this recommendation"
- />
- {dismissed ? (
- <LemonButton
- size="xsmall"
- type="tertiary"
- onClick={() => restoreRecommendation(recommendationId)}
- >
- Restore
- </LemonButton>
- ) : (
- <LemonButton
- size="xsmall"
- type="tertiary"
- icon={<IconX />}
- onClick={() => dismissRecommendation(recommendationId)}
- tooltip="Dismiss this recommendation"
- />
- )}
- </div>
- </div>
- {description && <p className="text-xs text-secondary mt-1 mb-3">{description}</p>}
- {children}
- </div>
- )
-}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/RecommendationsTab.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/RecommendationsTab.tsx
deleted file mode 100644
index 9a2640292db8..000000000000
--- a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/RecommendationsTab.tsx
+++ /dev/null
@@ -1,135 +0,0 @@
-import { useActions, useValues } from 'kea'
-
-import { IconChevronRight } from '@posthog/icons'
-import { Spinner } from '@posthog/lemon-ui'
-
-import { AlertsRecommendationCard } from './AlertsRecommendationCard'
-import { LongRunningIssuesRecommendationCard } from './LongRunningIssuesRecommendationCard'
-import { RateLimitsRecommendationCard } from './RateLimitsRecommendationCard'
-import {
- isAlertsRecommendation,
- isLongRunningIssuesRecommendation,
- isRateLimitsRecommendation,
- isSourceMapsRecommendation,
- recommendationsTabLogic,
-} from './recommendationsTabLogic'
-import { SourceMapsRecommendationCard } from './SourceMapsRecommendationCard'
-import type { ErrorTrackingRecommendation } from './types'
-
-function RecommendationCardForType({
- recommendation,
- dismissed,
-}: {
- recommendation: ErrorTrackingRecommendation
- dismissed?: boolean
-}): JSX.Element | null {
- if (isAlertsRecommendation(recommendation)) {
- return <AlertsRecommendationCard recommendation={recommendation} dismissed={dismissed} />
- }
- if (isLongRunningIssuesRecommendation(recommendation)) {
- return <LongRunningIssuesRecommendationCard recommendation={recommendation} dismissed={dismissed} />
- }
- if (isRateLimitsRecommendation(recommendation)) {
- return <RateLimitsRecommendationCard recommendation={recommendation} dismissed={dismissed} />
- }
- if (isSourceMapsRecommendation(recommendation)) {
- return <SourceMapsRecommendationCard recommendation={recommendation} dismissed={dismissed} />
- }
- return null
-}
-
-export function RecommendationsTab(): JSX.Element {
- const {
- recommendations,
- recommendationsLoading,
- activeRecommendations,
- completedRecommendations,
- ignoredRecommendations,
- dismissedExpanded,
- completedExpanded,
- } = useValues(recommendationsTabLogic)
- const { toggleDismissedExpanded, toggleCompletedExpanded } = useActions(recommendationsTabLogic)
-
- if (recommendationsLoading && recommendations.length === 0) {
- return (
- <div className="flex justify-center py-8">
- <Spinner />
- </div>
- )
- }
-
- if (recommendations.length === 0) {
- return (
- <div className="border rounded-lg bg-surface-primary p-4 text-secondary text-sm">
- No recommendations right now — everything's looking good!
- </div>
- )
- }
-
- return (
- <div className="flex flex-col gap-4">
- {activeRecommendations.length > 0 && (
- <div className="columns-1 md:columns-2 xl:columns-3 gap-4">
- {activeRecommendations.map((recommendation) => (
- <div key={recommendation.id} className="break-inside-avoid mb-4">
- <RecommendationCardForType recommendation={recommendation} />
- </div>
- ))}
- </div>
- )}
-
- {activeRecommendations.length === 0 &&
- (completedRecommendations.length > 0 || ignoredRecommendations.length > 0) && (
- <div className="border rounded-lg bg-surface-primary p-4 text-secondary text-sm">
- No active recommendations — everything's looking good!
- </div>
- )}
-
- {completedRecommendations.length > 0 && (
- <div>
- <button
- type="button"
- className="flex items-center gap-1 text-xs text-muted hover:text-primary cursor-pointer bg-transparent border-0 p-0"
- onClick={toggleCompletedExpanded}
- aria-expanded={completedExpanded}
- >
- <IconChevronRight className={`text-sm ${completedExpanded ? 'rotate-90' : ''}`} />
- {completedRecommendations.length} completed
- </button>
- {completedExpanded && (
- <div className="columns-1 md:columns-2 xl:columns-3 gap-4 mt-2 opacity-60">
- {completedRecommendations.map((recommendation) => (
- <div key={recommendation.id} className="break-inside-avoid mb-4">
- <RecommendationCardForType recommendation={recommendation} />
- </div>
- ))}
- </div>
- )}
- </div>
- )}
-
- {ignoredRecommendations.length > 0 && (
- <div>
- <button
- type="button"
- className="flex items-center gap-1 text-xs text-muted hover:text-primary cursor-pointer bg-transparent border-0 p-0"
- onClick={toggleDismissedExpanded}
- aria-expanded={dismissedExpanded}
- >
- <IconChevronRight className={`text-sm ${dismissedExpanded ? 'rotate-90' : ''}`} />
- {ignoredRecommendations.length} dismissed
- </button>
- {dismissedExpanded && (
- <div className="columns-1 md:columns-2 xl:columns-3 gap-4 mt-2 opacity-60">
- {ignoredRecommendations.map((recommendation) => (
- <div key={recommendation.id} className="break-inside-avoid mb-4">
- <RecommendationCardForType recommendation={recommendation} dismissed />
- </div>
- ))}
- </div>
- )}
- </div>
- )}
- </div>
- )
-}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/SourceMapsRecommendationCard.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/SourceMapsRecommendationCard.tsx
deleted file mode 100644
index 44a9f53c0914..000000000000
--- a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/SourceMapsRecommendationCard.tsx
+++ /dev/null
@@ -1,64 +0,0 @@
-import { useActions } from 'kea'
-import posthog from 'posthog-js'
-
-import { IconMagicWand } from '@posthog/icons'
-import { LemonButton } from '@posthog/lemon-ui'
-
-import { RecommendationCard } from './RecommendationCard'
-import { SourceMapsFixModal } from './SourceMapsFixModal'
-import { SOURCE_MAPS_DOCS_URL, sourceMapsFixWizardLogic } from './sourceMapsFixWizardLogic'
-import type { SourceMapsRecommendation } from './types'
-
-export function SourceMapsRecommendationCard({
- recommendation,
- dismissed,
-}: {
- recommendation: SourceMapsRecommendation
- dismissed?: boolean
-}): JSX.Element | null {
- const { unresolved_pct, lookback_hours } = recommendation.meta
- const { openModal } = useActions(sourceMapsFixWizardLogic)
- const isFirstLoad = recommendation.computed_at === null
-
- if (isFirstLoad) {
- return (
- <RecommendationCard
- recommendationId={recommendation.id}
- title="Missing source maps"
- description="Upload source maps so JavaScript stack traces show your original source code."
- dismissed={dismissed}
- />
- )
- }
-
- const percent = Math.round((unresolved_pct ?? 0) * 100)
-
- return (
- <RecommendationCard recommendationId={recommendation.id} title="Missing source maps" dismissed={dismissed}>
- <div className="flex flex-col items-center gap-1 py-2">
- <div className="text-5xl font-bold leading-none">{percent}%</div>
- <div className="text-xs text-secondary">
- of frames were unresolved in the last {lookback_hours} hours
- </div>
- </div>
- <div className="flex flex-wrap justify-center gap-2 mt-2">
- <LemonButton
- type="tertiary"
- to={SOURCE_MAPS_DOCS_URL}
- targetBlank
- onClick={() => {
- posthog.capture('error_tracking_source_maps_docs_clicked', {
- ui_source: 'recommendation_card',
- })
- }}
- >
- Read docs
- </LemonButton>
- <LemonButton type="secondary" icon={<IconMagicWand />} onClick={() => openModal('recommendations')}>
- <span className="rainbow-text rainbow-text-animating font-semibold">Fix with AI wizard</span>
- </LemonButton>
- </div>
- <SourceMapsFixModal />
- </RecommendationCard>
- )
-}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/recommendationsTabLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/recommendationsTabLogic.ts
deleted file mode 100644
index 1b488b80915e..000000000000
--- a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/recommendationsTabLogic.ts
+++ /dev/null
@@ -1,328 +0,0 @@
-import { MakeLogicType, actions, afterMount, beforeUnmount, kea, listeners, path, reducers, selectors } from 'kea'
-import posthog from 'posthog-js'
-
-import { lemonToast } from '@posthog/lemon-ui'
-
-import api from 'lib/api'
-
-import { HogFunctionSubTemplateIdType } from '~/types'
-
-import type {
- AlertsRecommendation,
- ErrorTrackingRecommendation,
- LongRunningIssuesRecommendation,
- RateLimitsRecommendation,
- SourceMapsRecommendation,
-} from './types'
-
-export const isAlertsRecommendation = (
- recommendation: ErrorTrackingRecommendation
-): recommendation is AlertsRecommendation => recommendation.type === 'alerts'
-
-export const isLongRunningIssuesRecommendation = (
- recommendation: ErrorTrackingRecommendation
-): recommendation is LongRunningIssuesRecommendation => recommendation.type === 'long_running_issues'
-
-export const isRateLimitsRecommendation = (
- recommendation: ErrorTrackingRecommendation
-): recommendation is RateLimitsRecommendation => recommendation.type === 'rate_limits'
-
-export const isSourceMapsRecommendation = (
- recommendation: ErrorTrackingRecommendation
-): recommendation is SourceMapsRecommendation => recommendation.type === 'source_maps'
-
-const POLL_INTERVAL_MS = 500
-
-// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
-export interface recommendationsTabLogicValues {
- activeRecommendations: ErrorTrackingRecommendation[]
- completedExpanded: boolean
- completedRecommendations: ErrorTrackingRecommendation[]
- computingIds: Set<string>
- dismissedExpanded: boolean
- ignoredRecommendations: ErrorTrackingRecommendation[]
- openAlertTriggerKey: HogFunctionSubTemplateIdType | null
- recommendations: ErrorTrackingRecommendation[]
- recommendationsLoading: boolean
-}
-
-// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
-export interface recommendationsTabLogicActions {
- activateIssue: (issueId: string) => {
- issueId: string
- }
- clearPolling: () => {
- value: true
- }
- dismissRecommendation: (id: string) => {
- id: string
- }
- ensurePollingScheduled: () => {
- value: true
- }
- loadRecommendations: () => {
- value: true
- }
- markRecommendationComputing: (id: string) => {
- id: string
- }
- pollRecommendations: () => {
- value: true
- }
- refreshRecommendation: (id: string) => {
- id: string
- }
- restoreRecommendation: (id: string) => {
- id: string
- }
- setOpenAlertTriggerKey: (triggerKey: HogFunctionSubTemplateIdType | null) => {
- triggerKey: HogFunctionSubTemplateIdType | null
- }
- setRecommendations: (recommendations: ErrorTrackingRecommendation[]) => {
- recommendations: ErrorTrackingRecommendation<Record<string, unknown>>[]
- }
- setRecommendationsLoading: (loading: boolean) => {
- loading: boolean
- }
- suppressIssue: (issueId: string) => {
- issueId: string
- }
- toggleCompletedExpanded: () => {
- value: true
- }
- toggleDismissedExpanded: () => {
- value: true
- }
- upsertRecommendation: (recommendation: ErrorTrackingRecommendation) => {
- recommendation: ErrorTrackingRecommendation<Record<string, unknown>>
- }
-}
-
-// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
-export interface recommendationsTabLogicMeta {
- __keaTypeGenInternalSelectorTypes: {
- activeRecommendations: (
- recommendations: ErrorTrackingRecommendation<Record<string, unknown>>[]
- ) => ErrorTrackingRecommendation[]
- completedRecommendations: (
- recommendations: ErrorTrackingRecommendation<Record<string, unknown>>[]
- ) => ErrorTrackingRecommendation[]
- ignoredRecommendations: (
- recommendations: ErrorTrackingRecommendation<Record<string, unknown>>[]
- ) => ErrorTrackingRecommendation[]
- computingIds: (recommendations: ErrorTrackingRecommendation<Record<string, unknown>>[]) => Set<string>
- }
-}
-
-export type recommendationsTabLogicType = MakeLogicType<
- recommendationsTabLogicValues,
- recommendationsTabLogicActions,
- Record<string, any>,
- recommendationsTabLogicMeta
->
-
-// The backend `status` field is the single source of truth for "is this recommendation
-// being computed". The frontend shows a spinner whenever status === 'computing', and
-// optimistically flips status to 'computing' before issuing a refresh HTTP call so the
-// spinner appears instantly (without waiting for the roundtrip). The optimistic value
-// converges with the server response since both arrive at status='computing'.
-export const recommendationsTabLogic = kea<recommendationsTabLogicType>([
- path(['products', 'error_tracking', 'scenes', 'ErrorTrackingScene', 'tabs', 'recommendations', 'logic']),
-
- actions({
- loadRecommendations: true,
- pollRecommendations: true,
- refreshRecommendation: (id: string) => ({ id }),
- dismissRecommendation: (id: string) => ({ id }),
- restoreRecommendation: (id: string) => ({ id }),
- suppressIssue: (issueId: string) => ({ issueId }),
- activateIssue: (issueId: string) => ({ issueId }),
-
- setRecommendations: (recommendations: ErrorTrackingRecommendation[]) => ({ recommendations }),
- upsertRecommendation: (recommendation: ErrorTrackingRecommendation) => ({ recommendation }),
- markRecommendationComputing: (id: string) => ({ id }),
- setRecommendationsLoading: (loading: boolean) => ({ loading }),
-
- ensurePollingScheduled: true,
- clearPolling: true,
-
- toggleDismissedExpanded: true,
- toggleCompletedExpanded: true,
- setOpenAlertTriggerKey: (triggerKey: HogFunctionSubTemplateIdType | null) => ({ triggerKey }),
- }),
-
- reducers({
- recommendations: [
- [] as ErrorTrackingRecommendation[],
- {
- setRecommendations: (_, { recommendations }) => recommendations,
- upsertRecommendation: (state, { recommendation }) =>
- state.map((r) => (r.id === recommendation.id ? recommendation : r)),
- markRecommendationComputing: (state, { id }) =>
- state.map((r) => (r.id === id ? { ...r, status: 'computing' as const } : r)),
- },
- ],
- recommendationsLoading: [
- true,
- {
- setRecommendationsLoading: (_, { loading }) => loading,
- },
- ],
- dismissedExpanded: [
- false,
- {
- toggleDismissedExpanded: (state) => !state,
- },
- ],
- completedExpanded: [
- false,
- {
- toggleCompletedExpanded: (state) => !state,
- },
- ],
- openAlertTriggerKey: [
- null as HogFunctionSubTemplateIdType | null,
- {
- setOpenAlertTriggerKey: (_, { triggerKey }) => triggerKey,
- },
- ],
- }),
-
- listeners(({ actions, values, cache }) => ({
- loadRecommendations: async () => {
- actions.setRecommendationsLoading(true)
- try {
- const response = await api.errorTracking.listRecommendations()
- actions.setRecommendations(response.results)
- posthog.capture('error_tracking_recommendations_loaded', {
- open_count: response.results.filter((r) => !r.dismissed_at && !r.completed).length,
- completed_count: response.results.filter((r) => !r.dismissed_at && r.completed).length,
- dismissed_count: response.results.filter((r) => !!r.dismissed_at).length,
- total_count: response.results.length,
- })
- } finally {
- actions.setRecommendationsLoading(false)
- }
- },
- pollRecommendations: async () => {
- try {
- const response = await api.errorTracking.listRecommendations({ poll: true })
- actions.setRecommendations(response.results)
- } catch {
- actions.ensurePollingScheduled()
- }
- },
- refreshRecommendation: async ({ id }) => {
- // Optimistic flip — the spinner appears instantly. The server response will
- // confirm the same status, so there's no flicker when it arrives.
- actions.markRecommendationComputing(id)
- try {
- const updated = await api.errorTracking.refreshRecommendation(id)
- actions.upsertRecommendation(updated)
- } catch {
- lemonToast.error('Failed to refresh recommendation')
- // Polling will reconcile state regardless of which side errored.
- }
- },
- dismissRecommendation: async ({ id }) => {
- const updated = await api.errorTracking.dismissRecommendation(id)
- actions.upsertRecommendation(updated)
- posthog.capture('error_tracking_recommendation_dismissed', {
- recommendation_type: updated.type,
- })
- },
- restoreRecommendation: async ({ id }) => {
- const updated = await api.errorTracking.restoreRecommendation(id)
- actions.upsertRecommendation(updated)
- },
- suppressIssue: async ({ issueId }) => {
- await api.errorTracking.updateIssue(issueId, { status: 'suppressed' })
- posthog.capture('error_tracking_issue_update_status', {
- status: 'suppressed',
- issue_id: issueId,
- ui_source: 'recommendations',
- })
- const longRunning = values.recommendations.find(isLongRunningIssuesRecommendation)
- if (!longRunning) {
- return
- }
- // force=false: just re-pulls enriched meta, no recompute. So we don't mark computing.
- const updated = await api.errorTracking.refreshRecommendation(longRunning.id, { force: false })
- actions.upsertRecommendation(updated)
- },
- activateIssue: async ({ issueId }) => {
- await api.errorTracking.updateIssue(issueId, { status: 'active' })
- posthog.capture('error_tracking_issue_update_status', {
- status: 'active',
- issue_id: issueId,
- ui_source: 'recommendations',
- })
- const longRunning = values.recommendations.find(isLongRunningIssuesRecommendation)
- if (!longRunning) {
- return
- }
- const updated = await api.errorTracking.refreshRecommendation(longRunning.id, { force: false })
- actions.upsertRecommendation(updated)
- },
-
- // Polling lifecycle: any time the recommendations state changes, re-evaluate
- // whether we still need to poll. Schedule one timer at a time.
- setRecommendations: () => actions.ensurePollingScheduled(),
- upsertRecommendation: () => actions.ensurePollingScheduled(),
- markRecommendationComputing: () => actions.ensurePollingScheduled(),
- ensurePollingScheduled: () => {
- const stillComputing = values.recommendations.some((r) => r.status === 'computing')
- if (!stillComputing) {
- actions.clearPolling()
- return
- }
- if (cache.pollTimeoutId !== undefined) {
- return
- }
- cache.pollTimeoutId = window.setTimeout(() => {
- cache.pollTimeoutId = undefined
- actions.pollRecommendations()
- }, POLL_INTERVAL_MS)
- },
- clearPolling: () => {
- if (cache.pollTimeoutId !== undefined) {
- window.clearTimeout(cache.pollTimeoutId)
- cache.pollTimeoutId = undefined
- }
- },
- })),
-
- selectors({
- activeRecommendations: [
- (s) => [s.recommendations],
- (recommendations: ErrorTrackingRecommendation[]): ErrorTrackingRecommendation[] => {
- return recommendations.filter((r) => !r.dismissed_at && !r.completed)
- },
- ],
- completedRecommendations: [
- (s) => [s.recommendations],
- (recommendations: ErrorTrackingRecommendation[]): ErrorTrackingRecommendation[] => {
- return recommendations.filter((r) => !r.dismissed_at && r.completed)
- },
- ],
- ignoredRecommendations: [
- (s) => [s.recommendations],
- (recommendations: ErrorTrackingRecommendation[]): ErrorTrackingRecommendation[] => {
- return recommendations.filter((r) => !!r.dismissed_at)
- },
- ],
- computingIds: [
- (s) => [s.recommendations],
- (recommendations: ErrorTrackingRecommendation[]): Set<string> =>
- new Set(recommendations.filter((r) => r.status === 'computing').map((r) => r.id)),
- ],
- }),
-
- afterMount(({ actions }) => {
- actions.loadRecommendations()
- }),
-
- beforeUnmount(({ actions }) => {
- actions.clearPolling()
- }),
-])
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/types.ts b/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/types.ts
deleted file mode 100644
index e05397602e13..000000000000
--- a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/types.ts
+++ /dev/null
@@ -1,104 +0,0 @@
-import { ErrorTrackingIssue } from '~/queries/schema/schema-general'
-import { HogFunctionSubTemplateIdType } from '~/types'
-
-export type ErrorTrackingRecommendationType = 'alerts' | 'long_running_issues' | 'rate_limits' | 'source_maps'
-
-export type ErrorTrackingRecommendationStatus = 'ready' | 'computing'
-
-export interface ErrorTrackingRecommendation<TMeta extends Record<string, unknown> = Record<string, unknown>> {
- id: string
- type: ErrorTrackingRecommendationType
- meta: TMeta
- completed: boolean
- status: ErrorTrackingRecommendationStatus
- computed_at: string | null
- dismissed_at: string | null
- created_at: string
- updated_at: string
-}
-
-export interface AlertRecommendationItem {
- key: HogFunctionSubTemplateIdType
- enabled: boolean
-}
-
-export interface AlertsRecommendationMeta extends Record<string, unknown> {
- alerts: AlertRecommendationItem[]
-}
-
-export type AlertsRecommendation = ErrorTrackingRecommendation<AlertsRecommendationMeta>
-
-export interface AlertRecommendationInfo {
- name: string
- reason: string
-}
-
-export const ALERT_RECOMMENDATION_INFO: Record<string, AlertRecommendationInfo> = {
- 'error-tracking-issue-created': {
- name: 'Issue created',
- reason: 'Get notified when a new error issue is detected.',
- },
- 'error-tracking-issue-reopened': {
- name: 'Issue reopened',
- reason: 'Get notified when a previously resolved issue comes back.',
- },
- 'error-tracking-issue-spiking': {
- name: 'Issue spiking',
- reason: 'Get notified when an issue starts occurring more frequently than usual.',
- },
-}
-
-export type RateLimitRecommendationKey = 'project' | 'per_issue'
-
-export interface RateLimitRecommendationItem {
- key: RateLimitRecommendationKey
- enabled: boolean
-}
-
-export interface RateLimitsRecommendationMeta extends Record<string, unknown> {
- rate_limits: RateLimitRecommendationItem[]
-}
-
-export type RateLimitsRecommendation = ErrorTrackingRecommendation<RateLimitsRecommendationMeta>
-
-export interface RateLimitRecommendationInfo {
- name: string
- reason: string
-}
-
-export const RATE_LIMIT_RECOMMENDATION_INFO: Record<RateLimitRecommendationKey, RateLimitRecommendationInfo> = {
- project: {
- name: 'Project-wide rate limit',
- reason: 'Cap exception volume across the whole project to control ingestion.',
- },
- per_issue: {
- name: 'Per-issue rate limit',
- reason: 'Stop a single noisy issue from dominating your ingestion.',
- },
-}
-
-export interface LongRunningIssueItem {
- id: string
- name: string
- description: string | null
- created_at: string
- occurrences: number
- status: ErrorTrackingIssue['status']
-}
-
-export interface LongRunningIssuesRecommendationMeta extends Record<string, unknown> {
- issues: LongRunningIssueItem[]
-}
-
-export type LongRunningIssuesRecommendation = ErrorTrackingRecommendation<LongRunningIssuesRecommendationMeta>
-
-export interface SourceMapsRecommendationMeta extends Record<string, unknown> {
- total_frames: number
- unresolved_frames: number
- unresolved_pct: number
- threshold_pct: number
- min_sample_frames: number
- lookback_hours: number
-}
-
-export type SourceMapsRecommendation = ErrorTrackingRecommendation<SourceMapsRecommendationMeta>
diff --git a/products/error_tracking/manifest.tsx b/products/error_tracking/manifest.tsx
index fad23e35216f..47086c62b665 100644
--- a/products/error_tracking/manifest.tsx
+++ b/products/error_tracking/manifest.tsx
@@ -1,6 +1,5 @@
import { combineUrl, router } from 'kea-router'
-import { FEATURE_FLAGS } from 'lib/constants'
import { urls } from 'scenes/urls'
import { DateRange, FileSystemIconType, ProductItemCategory, ProductKey } from '~/queries/schema/schema-general'
@@ -118,14 +117,7 @@ export const manifest: ProductManifest = {
] as FileSystemIconColor,
href: urls.errorTracking(),
searchKeywords: ['exceptions', 'crashes', 'bugs', 'stack traces'],
- searchTabs: [
- { name: 'Insights', href: urls.errorTracking({ activeTab: 'insights' }) },
- {
- name: 'Recommendations',
- href: urls.errorTracking({ activeTab: 'recommendations' }),
- flag: FEATURE_FLAGS.ERROR_TRACKING_RECOMMENDATIONS,
- },
- ],
+ searchTabs: [{ name: 'Insights', href: urls.errorTracking({ activeTab: 'insights' }) }],
sceneKey: 'ErrorTracking',
},
],
diff --git a/products/error_tracking/mcp/prompts/error-tracking-recommendations-list.md b/products/error_tracking/mcp/prompts/error-tracking-recommendations-list.md
index 2f820a4d49fc..4c342803aeb0 100644
--- a/products/error_tracking/mcp/prompts/error-tracking-recommendations-list.md
+++ b/products/error_tracking/mcp/prompts/error-tracking-recommendations-list.md
@@ -6,7 +6,7 @@ Surface only the few recommendations that matter — don't dump every row. Skip
# Response envelope (every recommendation)
-- `type`: one of `alerts`, `rate_limits`, `source_maps`, `long_running_issues`.
+- `type`: one of `alerts`, `rate_limits`, `source_maps`.
- `meta`: type-specific payload — see the per-type sections below.
- `completed`: `true` means the recommended action is already satisfied. Nothing to do — skip it.
- `dismissed_at`: set if the user dismissed this recommendation. Skip dismissed ones unless the user explicitly asks.
@@ -24,5 +24,3 @@ Only act on recommendations that are not `completed` and not dismissed.
```
If frames still don't resolve after uploading, use the `diagnosing-stacktrace-symbolication` skill.
-
-- `long_running_issues` — `meta.issues` lists stale active issues (first seen over a week ago, still recurring). To act, use the `triaging-error-issues` skill to work through them, or `investigating-error-issue` to root-cause one.
diff --git a/products/error_tracking/skills/authoring-error-tracking-alerts/SKILL.md b/products/error_tracking/skills/authoring-error-tracking-alerts/SKILL.md
index 6fc1e0aadbe8..acf7954366ec 100644
--- a/products/error_tracking/skills/authoring-error-tracking-alerts/SKILL.md
+++ b/products/error_tracking/skills/authoring-error-tracking-alerts/SKILL.md
@@ -94,7 +94,7 @@ guess: show the user the matching names and ask whether one of them is the alert
a scoped alert and an all-issues alert to the same channel both fire on the scoped issue.
PostHog's "alerts configured" recommendation only inspects `filters.events` — adding per-issue
-`filters.properties` does not affect the status the recommendations card reports.
+`filters.properties` does not affect the status the alerts banner reports.
### 3. Pick the integration
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 171400545346..63211a10f6e1 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -4829,7 +4829,7 @@
}
},
"error-tracking-recommendations-list": {
- "description": "List error tracking recommendations for the current project. Each row is a server-computed suggestion with a fixed `type` and a type-specific `meta` payload.\n\nUse this when the user asks how to improve their error tracking setup, what they should fix, or wants to act on their recommendations.\n\nSurface only the few recommendations that matter — don't dump every row. Skip ones that are already done or dismissed.\n\n# Response envelope (every recommendation)\n\n- `type`: one of `alerts`, `rate_limits`, `source_maps`, `long_running_issues`.\n- `meta`: type-specific payload — see the per-type sections below.\n- `completed`: `true` means the recommended action is already satisfied. Nothing to do — skip it.\n- `dismissed_at`: set if the user dismissed this recommendation. Skip dismissed ones unless the user explicitly asks.\n\nOnly act on recommendations that are not `completed` and not dismissed.\n\n# Recommendation types\n\n- `alerts` — `meta.alerts` is a list of `{ key, enabled }` for the `issue-created`/`issue-reopened`/`issue-spiking` triggers; `enabled: false` means no alert is wired. To act, use the `authoring-error-tracking-alerts` skill (or the `error-tracking-alerts-create` tool).\n- `rate_limits` — `meta.rate_limits` is a list of `{ key, enabled }` for the `project` and `per_issue` ingestion limits; `enabled: false` means it isn't set. To act, check and set them via `error-tracking-settings-get` / `error-tracking-settings-update`.\n- `source_maps` — `meta` carries frame-resolution stats (`unresolved_pct` vs `threshold_pct` over a sample); a high unresolved share means stack traces aren't symbolicated. The fix is uploading source maps from the build via the setup wizard:\n\n ```sh\n npx -y @posthog/wizard@latest upload-source-maps\n ```\n\n If frames still don't resolve after uploading, use the `diagnosing-stacktrace-symbolication` skill.\n\n- `long_running_issues` — `meta.issues` lists stale active issues (first seen over a week ago, still recurring). To act, use the `triaging-error-issues` skill to work through them, or `investigating-error-issue` to root-cause one.",
+ "description": "List error tracking recommendations for the current project. Each row is a server-computed suggestion with a fixed `type` and a type-specific `meta` payload.\n\nUse this when the user asks how to improve their error tracking setup, what they should fix, or wants to act on their recommendations.\n\nSurface only the few recommendations that matter — don't dump every row. Skip ones that are already done or dismissed.\n\n# Response envelope (every recommendation)\n\n- `type`: one of `alerts`, `rate_limits`, `source_maps`.\n- `meta`: type-specific payload — see the per-type sections below.\n- `completed`: `true` means the recommended action is already satisfied. Nothing to do — skip it.\n- `dismissed_at`: set if the user dismissed this recommendation. Skip dismissed ones unless the user explicitly asks.\n\nOnly act on recommendations that are not `completed` and not dismissed.\n\n# Recommendation types\n\n- `alerts` — `meta.alerts` is a list of `{ key, enabled }` for the `issue-created`/`issue-reopened`/`issue-spiking` triggers; `enabled: false` means no alert is wired. To act, use the `authoring-error-tracking-alerts` skill (or the `error-tracking-alerts-create` tool).\n- `rate_limits` — `meta.rate_limits` is a list of `{ key, enabled }` for the `project` and `per_issue` ingestion limits; `enabled: false` means it isn't set. To act, check and set them via `error-tracking-settings-get` / `error-tracking-settings-update`.\n- `source_maps` — `meta` carries frame-resolution stats (`unresolved_pct` vs `threshold_pct` over a sample); a high unresolved share means stack traces aren't symbolicated. The fix is uploading source maps from the build via the setup wizard:\n\n ```sh\n npx -y @posthog/wizard@latest upload-source-maps\n ```\n\n If frames still don't resolve after uploading, use the `diagnosing-stacktrace-symbolication` skill.",
"category": "Error tracking",
"feature": "error_tracking",
"summary": "List error tracking recommendations",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index 8d2bacaf36b8..e54615c393b0 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -4858,7 +4858,7 @@
}
},
"error-tracking-recommendations-list": {
- "description": "List error tracking recommendations for the current project. Each row is a server-computed suggestion with a fixed `type` and a type-specific `meta` payload.\n\nUse this when the user asks how to improve their error tracking setup, what they should fix, or wants to act on their recommendations.\n\nSurface only the few recommendations that matter — don't dump every row. Skip ones that are already done or dismissed.\n\n# Response envelope (every recommendation)\n\n- `type`: one of `alerts`, `rate_limits`, `source_maps`, `long_running_issues`.\n- `meta`: type-specific payload — see the per-type sections below.\n- `completed`: `true` means the recommended action is already satisfied. Nothing to do — skip it.\n- `dismissed_at`: set if the user dismissed this recommendation. Skip dismissed ones unless the user explicitly asks.\n\nOnly act on recommendations that are not `completed` and not dismissed.\n\n# Recommendation types\n\n- `alerts` — `meta.alerts` is a list of `{ key, enabled }` for the `issue-created`/`issue-reopened`/`issue-spiking` triggers; `enabled: false` means no alert is wired. To act, use the `authoring-error-tracking-alerts` skill (or the `error-tracking-alerts-create` tool).\n- `rate_limits` — `meta.rate_limits` is a list of `{ key, enabled }` for the `project` and `per_issue` ingestion limits; `enabled: false` means it isn't set. To act, check and set them via `error-tracking-settings-get` / `error-tracking-settings-update`.\n- `source_maps` — `meta` carries frame-resolution stats (`unresolved_pct` vs `threshold_pct` over a sample); a high unresolved share means stack traces aren't symbolicated. The fix is uploading source maps from the build via the setup wizard:\n\n ```sh\n npx -y @posthog/wizard@latest upload-source-maps\n ```\n\n If frames still don't resolve after uploading, use the `diagnosing-stacktrace-symbolication` skill.\n\n- `long_running_issues` — `meta.issues` lists stale active issues (first seen over a week ago, still recurring). To act, use the `triaging-error-issues` skill to work through them, or `investigating-error-issue` to root-cause one.",
+ "description": "List error tracking recommendations for the current project. Each row is a server-computed suggestion with a fixed `type` and a type-specific `meta` payload.\n\nUse this when the user asks how to improve their error tracking setup, what they should fix, or wants to act on their recommendations.\n\nSurface only the few recommendations that matter — don't dump every row. Skip ones that are already done or dismissed.\n\n# Response envelope (every recommendation)\n\n- `type`: one of `alerts`, `rate_limits`, `source_maps`.\n- `meta`: type-specific payload — see the per-type sections below.\n- `completed`: `true` means the recommended action is already satisfied. Nothing to do — skip it.\n- `dismissed_at`: set if the user dismissed this recommendation. Skip dismissed ones unless the user explicitly asks.\n\nOnly act on recommendations that are not `completed` and not dismissed.\n\n# Recommendation types\n\n- `alerts` — `meta.alerts` is a list of `{ key, enabled }` for the `issue-created`/`issue-reopened`/`issue-spiking` triggers; `enabled: false` means no alert is wired. To act, use the `authoring-error-tracking-alerts` skill (or the `error-tracking-alerts-create` tool).\n- `rate_limits` — `meta.rate_limits` is a list of `{ key, enabled }` for the `project` and `per_issue` ingestion limits; `enabled: false` means it isn't set. To act, check and set them via `error-tracking-settings-get` / `error-tracking-settings-update`.\n- `source_maps` — `meta` carries frame-resolution stats (`unresolved_pct` vs `threshold_pct` over a sample); a high unresolved share means stack traces aren't symbolicated. The fix is uploading source maps from the build via the setup wizard:\n\n ```sh\n npx -y @posthog/wizard@latest upload-source-maps\n ```\n\n If frames still don't resolve after uploading, use the `diagnosing-stacktrace-symbolication` skill.",
"category": "Error tracking",
"feature": "error_tracking",
"summary": "List error tracking recommendations",