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): add automatic suppression rules (#123278)

Aleksander Błaszkiewiczb5a20516bfb7
diff --git a/.github/workflows/container-images-cd.yml b/.github/workflows/container-images-cd.yml
index f54386c88e4e..c3b089410fff 100644
--- a/.github/workflows/container-images-cd.yml
+++ b/.github/workflows/container-images-cd.yml
@@ -562,6 +562,10 @@ jobs:
errorTracking:
- 'products/error_tracking/backend/temporal/**'
- 'products/error_tracking/backend/logic/**'
+ # The automatic suppression rules hash the bot list, so the worker
+ # must redeploy with web analytics when that list changes.
+ - 'products/web_analytics/backend/facade/bot_definitions.py'
+ - 'products/web_analytics/backend/hogql_queries/bot_definitions.py'
- 'products/error_tracking/backend/models.py'
- 'products/error_tracking/backend/weekly_digest.py'
- 'products/error_tracking/backend/weekly_digest_delivery.py'
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index d6da4673670f..c68eac1f0349 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -3136,6 +3136,10 @@ snapshots:
hash: v1.k794b7964.dfeaf97789a0f52c2cb9f41f1dc4c430c8f1f8c4d26b450886b8fe1bf009a565.g5h8M4sn6ctmHk9PSgvmHWj4LQm_L5wCwYUDIEz7TPs
errortracking-assigneedisplay--user-displays--light:
hash: v1.k794b7964.5e5ff02390ffcbf925829bc3cb5be1d12eeae84cbfd4a5d0fb52511d448b1405.LJ4jfnPIbSE2F6dWW90mnaD_cEkywysIZEHPl7RXAls
+ errortracking-builtinfilterrow--some-rules-on--dark:
+ hash: v1.k794b7964.b3079597cf042fef576f7a3b95ed60f9e8414c5a042b97c2022f22861da5164f.2-KTykPV9V9wu2Nw1BMI5Q01qWfvsBHuLUlF51O9-5A
+ errortracking-builtinfilterrow--some-rules-on--light:
+ hash: v1.k794b7964.2bedaf9f4861ad95fc592898de2d754227a930a3e8e6c0c06a01409ef5abc890.BNT8SHV1WLgDPuYnfG1o0XqSc52E6YeTblBLre3x2mE
errortracking-contextdisplay--context-display-empty--dark:
hash: v1.k794b7964.3516484d01487339ed46bb0e58427cdc5e90c39309321ecbb7f50460a9231f52.9a39dHevx4udYZ6fNqvmvAyi-dzSt1m5brQ5l0vBuzg
errortracking-contextdisplay--context-display-empty--light:
@@ -15255,9 +15259,9 @@ snapshots:
scenes-app-settings-environment--settings-environment-error-tracking--light:
hash: v1.k794b7964.adb6fd411ffdc03ea8e1b9a29f01536d41a5af4b6224c37881d7ad6b06630f84.WGucFxYafyt1RqQ5e0M6MzvBxP4nGZseNtgVciGxRWc
scenes-app-settings-environment--settings-environment-error-tracking-configuration--dark:
- hash: v1.k794b7964.ec06b32dd20c57ad9a82e1f94711678b9ccc586027958cb583102fa06bda94e5.R0Xah_fVqbKt8GSnJzj6Mb4HWqCK0VLaYPvmC-it9hQ
+ hash: v1.k794b7964.fefec3bbacd088c88914a8fcb41ecb8cb2ab327cca2d73788d27450e592c35f9.S75BhNkh_Gx5uOCqbImr0kf0CYnsY3BDW_EnFvIuZ8k
scenes-app-settings-environment--settings-environment-error-tracking-configuration--light:
- hash: v1.k794b7964.fe0b9b2717829dbcadc4b61a3366c48a9141440fc907ed6a12d5d171f231c2df.vJ-9wkHdToz9HblFJRGAvWp8-hVVmxNp-zPPlni1vHA
+ hash: v1.k794b7964.d203e510b1d56262b3ba6e0a19195c9e9ebefb79c6771f7d2748133d5c03a5fc.emVO0_18WGnSz9JoyR0RBg6aWOqHM40ssA-tRKisOSI
scenes-app-settings-environment--settings-environment-experiments--dark:
hash: v1.k794b7964.97267477544077ef369227235fde9b1c9380237167be329954cf2f4ce360283e.NgTCKnQHKhLyLWyje5QLi6KyJlx3k5fnuF9ODDZ9BFY
scenes-app-settings-environment--settings-environment-experiments--light:
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index f7a49718a3a8..ac91f22b915b 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -315,6 +315,7 @@ export const FEATURE_FLAGS = {
EMAIL_TEMPLATES_AI_FIRST_NEW: 'email-templates-ai-first-new', // owner: @mayteio #team-workflows
EMOJI_RELATED_SEARCH: 'emoji-related-search', // owner: @pauldambra, gates the model search in `emojiSuggestionsLogic.ts` when the emoji picker finds no match
ENGINEERING_ANALYTICS: 'engineering-analytics', // owner: #team-devex
+ ERROR_TRACKING_BUILT_IN_FILTERS: 'error-tracking-built-in-filters', // owner: @ablaszkiewicz #team-error-tracking
ERROR_TRACKING_ISSUE_CORRELATION: 'error-tracking-issue-correlation', // owner: @david #team-error-tracking
ERROR_TRACKING_ISSUE_SPLITTING: 'error-tracking-issue-splitting', // owner: @david #team-error-tracking
ERROR_TRACKING_NEW_WIZARD: 'error-tracking-new-wizard', // owner: @ablaszkiewicz #team-error-tracking
diff --git a/frontend/src/scenes/settings/SettingsMap.tsx b/frontend/src/scenes/settings/SettingsMap.tsx
index 8653cd4f7e4f..7609080b7f14 100644
--- a/frontend/src/scenes/settings/SettingsMap.tsx
+++ b/frontend/src/scenes/settings/SettingsMap.tsx
@@ -947,7 +947,21 @@ export const SETTINGS_MAP: SettingSection[] = [
title: 'Suppression rules',
description: 'Filter out exceptions that match the given filters.',
component: <SuppressionRules />,
- keywords: ['filter', 'ignore', 'suppress', 'exception', 'type', 'message'],
+ keywords: [
+ 'filter',
+ 'ignore',
+ 'suppress',
+ 'exception',
+ 'type',
+ 'message',
+ 'automatic',
+ 'bot',
+ 'crawler',
+ 'localhost',
+ 'browser',
+ 'hydration',
+ 'chunk',
+ ],
},
{
id: 'error-tracking-symbol-sets',
diff --git a/posthog/models/remote_config.py b/posthog/models/remote_config.py
index 48fc5d00ae8f..72343f38fa56 100644
--- a/posthog/models/remote_config.py
+++ b/posthog/models/remote_config.py
@@ -698,7 +698,8 @@ def product_tour_deleted(sender, instance, **kwargs):
@receiver(post_save, sender="error_tracking.ErrorTrackingSuppressionRule")
-def error_tracking_suppression_rule_saved(sender, instance, created, **kwargs):
+@receiver(post_delete, sender="error_tracking.ErrorTrackingSuppressionRule")
+def error_tracking_suppression_rule_changed(sender, instance, **kwargs):
transaction.on_commit(lambda: _update_team_remote_config(instance.team_id))
diff --git a/posthog/temporal/schedule.py b/posthog/temporal/schedule.py
index f37ecfd8acb3..0d13fff4eba7 100644
--- a/posthog/temporal/schedule.py
+++ b/posthog/temporal/schedule.py
@@ -109,6 +109,7 @@ from products.engineering_analytics.backend.facade.temporal import (
)
from products.error_tracking.backend.facade.temporal import (
RecommendationsRefreshInputs,
+ create_error_tracking_built_in_filters_refresh_schedule,
create_error_tracking_spike_event_cleanup_schedule,
create_error_tracking_symbol_set_cleanup_schedule,
create_error_tracking_weekly_digest_schedule,
@@ -990,6 +991,7 @@ schedules = [
create_error_tracking_symbol_set_cleanup_schedule,
create_error_tracking_spike_event_cleanup_schedule,
create_error_tracking_weekly_digest_schedule,
+ create_error_tracking_built_in_filters_refresh_schedule,
create_wa_weekly_digest_schedule,
create_wa_digest_notification_schedule,
create_heatmap_page_history_schedule,
diff --git a/posthog/test/repo_invariants/setup_receivers_baseline.txt b/posthog/test/repo_invariants/setup_receivers_baseline.txt
index 3d82026dafcc..bb99aa7fac7e 100644
--- a/posthog/test/repo_invariants/setup_receivers_baseline.txt
+++ b/posthog/test/repo_invariants/setup_receivers_baseline.txt
@@ -74,6 +74,7 @@ post_delete:posthog.models.organization.clean_up_alert_subscriptions_on_membersh
post_delete:posthog.models.organization.clean_up_event_streams_on_membership_removal
post_delete:posthog.models.organization.sync_billing_on_membership_removal
post_delete:posthog.models.product_intent.product_intent._invalidate_product_intents_on_delete
+post_delete:posthog.models.remote_config.error_tracking_suppression_rule_changed
post_delete:posthog.models.remote_config.product_tour_deleted
post_delete:posthog.models.remote_config.push_integration_changed
post_delete:posthog.models.remote_config.site_function_changed
@@ -148,7 +149,7 @@ post_save:posthog.models.organization.invalidate_llm_gateway_quota_cache_on_acti
post_save:posthog.models.organization.sync_active_state_to_billing_on_change
post_save:posthog.models.organization.sync_billing_on_membership_save
post_save:posthog.models.product_intent.product_intent._invalidate_product_intents_on_save
-post_save:posthog.models.remote_config.error_tracking_suppression_rule_saved
+post_save:posthog.models.remote_config.error_tracking_suppression_rule_changed
post_save:posthog.models.remote_config.feature_flag_saved
post_save:posthog.models.remote_config.heatmap_config_saved
post_save:posthog.models.remote_config.js_snippet_config_saved
diff --git a/posthog/test/repo_invariants/test_pagination_contract.py b/posthog/test/repo_invariants/test_pagination_contract.py
index 2456f3ff77ed..322913cc3835 100644
--- a/posthog/test/repo_invariants/test_pagination_contract.py
+++ b/posthog/test/repo_invariants/test_pagination_contract.py
@@ -169,6 +169,8 @@ EXISTING_CUSTOM_LIST_VIEWSETS = {
"products.endpoints.backend.presentation.views.api.EndpointViewSet",
"products.error_tracking.backend.presentation.views.alerts.ErrorTrackingAlertViewSet",
"products.error_tracking.backend.presentation.views.assignment_rules.ErrorTrackingAssignmentRuleViewSet",
+ # Returns the fixed set of built-in filter definitions, one entry each, not a page of rows.
+ "products.error_tracking.backend.presentation.views.built_in_filters.ErrorTrackingBuiltInFilterViewSet",
"products.error_tracking.backend.presentation.views.bypass_rules.ErrorTrackingBypassRuleViewSet",
"products.error_tracking.backend.presentation.views.external_references.ErrorTrackingExternalReferenceViewSet",
"products.error_tracking.backend.presentation.views.fingerprints.ErrorTrackingFingerprintViewSet",
diff --git a/products/error_tracking/backend/facade/api.py b/products/error_tracking/backend/facade/api.py
index 590bf8f34ce4..14c12b9eba43 100644
--- a/products/error_tracking/backend/facade/api.py
+++ b/products/error_tracking/backend/facade/api.py
@@ -18,7 +18,7 @@ from products.access_control.backend.facade.api import valid_role_member_user_id
from .. import logic, weekly_digest, weekly_digest_delivery
from ..indexed_embedding import DOCUMENT_EMBEDDINGS_BUFFER_SHARDED_TABLE, EMBEDDING_TABLES
-from ..logic import external_references, github_external_references, rules
+from ..logic import built_in_filters, external_references, github_external_references, rules
from ..models import (
ErrorTrackingIssue,
override_error_tracking_issue_fingerprint as override_error_tracking_issue_fingerprint,
@@ -38,6 +38,7 @@ ExternalReferenceValidationError = external_references.ErrorTrackingExternalRefe
ReleaseHashInUseError = logic.ErrorTrackingReleaseHashInUseError
InvalidBytecodeError = rules.ErrorTrackingInvalidBytecodeError
SeverityRuleLimitError = rules.ErrorTrackingSeverityRuleLimitError
+UnknownBuiltInFilterError = built_in_filters.UnknownBuiltInFilterError
SOURCE_MAPS_DOCS_URL = contracts.SOURCE_MAPS_DOCS_URL
@@ -575,6 +576,25 @@ def get_client_safe_suppression_rules(team_id: int) -> list[dict]:
return rules.get_client_safe_suppression_rules(team_id)
+def _to_built_in_filter(state: built_in_filters.BuiltInFilterState) -> contracts.ErrorTrackingBuiltInFilter:
+ return contracts.ErrorTrackingBuiltInFilter(
+ key=state.definition.key,
+ name=state.definition.name,
+ description=state.definition.description,
+ evaluation=contracts.BuiltInFilterEvaluation(built_in_filters.built_in_filter_evaluation(state.definition)),
+ enabled=state.enabled,
+ disabled_reason=state.disabled_reason,
+ )
+
+
+def list_built_in_filters(team_id: int) -> list[contracts.ErrorTrackingBuiltInFilter]:
+ return [_to_built_in_filter(state) for state in built_in_filters.list_built_in_filters(team_id)]
+
+
+def set_built_in_filter_enabled(team_id: int, key: str, *, enabled: bool) -> contracts.ErrorTrackingBuiltInFilter:
+ return _to_built_in_filter(built_in_filters.set_built_in_filter_enabled(team_id, key, enabled=enabled))
+
+
def _to_bypass_rule(rule) -> contracts.ErrorTrackingBypassRule:
return contracts.ErrorTrackingBypassRule(
id=rule.id,
diff --git a/products/error_tracking/backend/facade/contracts.py b/products/error_tracking/backend/facade/contracts.py
index 01b6f505b313..f7e54c308cbe 100644
--- a/products/error_tracking/backend/facade/contracts.py
+++ b/products/error_tracking/backend/facade/contracts.py
@@ -21,6 +21,11 @@ from posthog.enums import LabeledStrEnum
ERROR_TRACKING_ISSUE_SEVERITIES = ("low", "medium", "high", "critical")
+class BuiltInFilterEvaluation(LabeledStrEnum):
+ CLIENT = "client"
+ SERVER = "server"
+
+
class IssueTrendDirection(LabeledStrEnum):
NEW = "new"
INCREASING = "increasing"
@@ -296,6 +301,16 @@ class ErrorTrackingSuppressionRule:
updated_at: datetime
+@dataclass(frozen=True)
+class ErrorTrackingBuiltInFilter:
+ key: str
+ name: str
+ description: str
+ evaluation: BuiltInFilterEvaluation
+ enabled: bool
+ disabled_reason: str | None
+
+
@dataclass(frozen=True)
class ErrorTrackingBypassRule:
id: UUID
diff --git a/products/error_tracking/backend/facade/temporal.py b/products/error_tracking/backend/facade/temporal.py
index e85d51521654..72d728883b24 100644
--- a/products/error_tracking/backend/facade/temporal.py
+++ b/products/error_tracking/backend/facade/temporal.py
@@ -7,6 +7,9 @@ objects, not data, so they live in their own facade submodule — keeping the
"""
from products.error_tracking.backend.temporal import ACTIVITIES, LIFECYCLE_ACTIVITIES, LIFECYCLE_WORKFLOWS, WORKFLOWS
+from products.error_tracking.backend.temporal.built_in_filters_refresh.schedule import (
+ create_error_tracking_built_in_filters_refresh_schedule,
+)
from products.error_tracking.backend.temporal.recommendations_refresh.types import RecommendationsRefreshInputs
from products.error_tracking.backend.temporal.spike_event_cleanup.schedule import (
create_error_tracking_spike_event_cleanup_schedule,
@@ -22,6 +25,7 @@ __all__ = [
"LIFECYCLE_WORKFLOWS",
"WORKFLOWS",
"RecommendationsRefreshInputs",
+ "create_error_tracking_built_in_filters_refresh_schedule",
"create_error_tracking_spike_event_cleanup_schedule",
"create_error_tracking_symbol_set_cleanup_schedule",
"create_error_tracking_weekly_digest_schedule",
diff --git a/products/error_tracking/backend/logic/built_in_filter_definitions.py b/products/error_tracking/backend/logic/built_in_filter_definitions.py
new file mode 100644
index 000000000000..622b0faec1dd
--- /dev/null
+++ b/products/error_tracking/backend/logic/built_in_filter_definitions.py
@@ -0,0 +1,174 @@
+"""Definitions of the built-in suppression filters.
+
+A team that turns a filter on gets one `ErrorTrackingSuppressionRule` row with the filter's key
+and a hash of the filters it was built from.
+The refresh workflow rewrites every row whose hash differs from the current definition,
+so a change here, including a change to the bot list it reads, reaches every team without a manual step.
+The error tracking Temporal worker redeploys only when a file in its path filter changes,
+so the errorTracking filter in .github/workflows/container-images-cd.yml must list every file
+outside this product that the definitions read.
+
+Every pattern here comes from PostHog's own data or from public facts:
+React's error decoder pages, bundler and browser error text, and browser release history.
+"""
+
+import json
+import hashlib
+from typing import Any
+
+from posthog.dataclasses import frozen
+
+from products.web_analytics.backend.facade.bot_definitions import bot_user_agent_patterns
+
+# The Rust HogVM caches a compiled regex only up to this length and compiles a longer one on every event.
+# Keep in sync with MAX_CACHEABLE_PATTERN_LEN in rust/common/hogvm/src/util.rs.
+MAX_CACHED_REGEX_LENGTH = 1024
+
+# AI assistants fetch pages for a person, and generic HTTP libraries also send requests from real apps and SDKs.
+_EXCLUDED_BOT_CATEGORIES = frozenset({"ai_assistant", "http_client"})
+
+# React's decoder codes for hydration mismatches: https://react.dev/errors
+_REACT_HYDRATION_ERROR_CODES = (418, 419, 421, 422, 423, 425)
+
+# The browsers that bundlers such as Vite targeted by default for ES2020 output, plus Internet Explorer.
+# Each pattern matches a major version below the cutoff, whether the SDK sends the version as a number or a string.
+_LEGACY_BROWSER_VERSION_PATTERNS = {
+ "Chrome": r"^(?:[0-9]|[1-7][0-9]|8[0-6])(?:\.|$)",
+ "Microsoft Edge": r"^(?:[0-9]|[1-7][0-9]|8[0-7])(?:\.|$)",
+ "Firefox": r"^(?:[0-9]|[1-6][0-9]|7[0-7])(?:\.|$)",
+ "Safari": r"^(?:[0-9]|1[0-3])(?:\.|$)",
+ "Mobile Safari": r"^(?:[0-9]|1[0-3])(?:\.|$)",
+ "Opera": r"^(?:[0-9]|[1-6][0-9]|7[0-2])(?:\.|$)",
+}
+_ALWAYS_LEGACY_BROWSERS = ("Internet Explorer", "Internet Explorer Mobile")
+
+_LOCAL_URL_PATTERN = r"(?i)^(?:file:|https?://(?:localhost|[^/?#]*\.localhost|127(?:\.[0-9]{1,3}){3}|0\.0\.0\.0|\[::1\])(?::[0-9]+)?(?:[/?#]|$))"
+
+
+@frozen
+class BuiltInFilter:
+ key: str
+ name: str
+ description: str
+ filters: dict[str, Any]
+
+ @property
+ def filters_hash(self) -> str:
+ return hashlib.sha256(json.dumps(self.filters, sort_keys=True).encode()).hexdigest()
+
+
+def _leaf(key: str, operator: str, value: str | list[str]) -> dict[str, Any]:
+ return {"key": key, "type": "event", "operator": operator, "value": value}
+
+
+def chunk_alternation(patterns: list[str], max_length: int = MAX_CACHED_REGEX_LENGTH) -> list[str]:
+ """Join patterns into as few `(?:a)|(?:b)` alternations as fit within `max_length` each."""
+ chunks: list[str] = []
+ current: list[str] = []
+ current_length = 0
+ for pattern in patterns:
+ group = f"(?:{pattern})"
+ if len(group) > max_length:
+ raise ValueError(f"Pattern is longer than {max_length} characters: {pattern}")
+ added_length = len(group) + (1 if current else 0)
+ if current and current_length + added_length > max_length:
+ chunks.append("|".join(current))
+ current = []
+ current_length = 0
+ added_length = len(group)
+ current.append(group)
+ current_length += added_length
+ if current:
+ chunks.append("|".join(current))
+ return chunks
+
+
+def _web_crawler_filters() -> dict[str, Any]:
+ patterns = bot_user_agent_patterns(exclude_categories=_EXCLUDED_BOT_CATEGORIES)
+ return {
+ "type": "OR",
+ "values": [_leaf("$raw_user_agent", "regex", chunk) for chunk in chunk_alternation(patterns)],
+ }
+
+
+def _legacy_browser_filters() -> dict[str, Any]:
+ groups: list[dict[str, Any]] = [
+ {"type": "AND", "values": [_leaf("$browser", "exact", list(_ALWAYS_LEGACY_BROWSERS))]},
+ ]
+ groups.extend(
+ {
+ "type": "AND",
+ "values": [_leaf("$browser", "exact", [browser]), _leaf("$browser_version", "regex", version_pattern)],
+ }
+ for browser, version_pattern in _LEGACY_BROWSER_VERSION_PATTERNS.items()
+ )
+ return {"type": "OR", "values": groups}
+
+
+def _react_hydration_filters() -> dict[str, Any]:
+ needles = [
+ needle
+ for code in _REACT_HYDRATION_ERROR_CODES
+ for needle in (f"react.dev/errors/{code}", f"reactjs.org/docs/error-decoder.html?invariant={code}")
+ ]
+ return {"type": "OR", "values": [_leaf("$exception_values", "icontains", needles)]}
+
+
+BUILT_IN_FILTERS: tuple[BuiltInFilter, ...] = (
+ BuiltInFilter(
+ key="web_crawlers",
+ name="Web crawlers and bots",
+ description="Drop exceptions from search engines, AI crawlers, uptime monitors and headless browsers.",
+ filters=_web_crawler_filters(),
+ ),
+ BuiltInFilter(
+ key="localhost",
+ name="Local development",
+ description="Drop exceptions from pages on localhost, a loopback address or a file: URL.",
+ filters={"type": "OR", "values": [_leaf("$current_url", "regex", _LOCAL_URL_PATTERN)]},
+ ),
+ BuiltInFilter(
+ key="legacy_browsers",
+ name="Legacy browsers",
+ description=(
+ "Drop exceptions from Internet Explorer, Chrome before 87, Edge before 88, Firefox before 78, "
+ "Safari before 14 and Opera before 73."
+ ),
+ filters=_legacy_browser_filters(),
+ ),
+ BuiltInFilter(
+ key="react_hydration_errors",
+ name="React hydration errors",
+ description="Drop React errors about server-rendered HTML that doesn't match the page in the browser.",
+ filters=_react_hydration_filters(),
+ ),
+ BuiltInFilter(
+ key="chunk_load_errors",
+ name="Chunk load errors",
+ description="Drop errors from lazy-loaded scripts that fail to load, which often happens after a deploy.",
+ filters={
+ "type": "OR",
+ "values": [
+ _leaf("$exception_types", "exact", ["ChunkLoadError"]),
+ _leaf(
+ "$exception_values",
+ "icontains",
+ [
+ # Chromium, Firefox and Safari word a failed dynamic import differently.
+ "Failed to fetch dynamically imported module",
+ "error loading dynamically imported module",
+ "Importing a module script failed",
+ ],
+ ),
+ ],
+ },
+ ),
+ BuiltInFilter(
+ key="resize_observer_loop",
+ name="ResizeObserver loop errors",
+ description="Drop the ResizeObserver loop warning that browsers report as an error.",
+ filters={"type": "OR", "values": [_leaf("$exception_values", "icontains", ["ResizeObserver loop"])]},
+ ),
+)
+
+BUILT_IN_FILTERS_BY_KEY: dict[str, BuiltInFilter] = {f.key: f for f in BUILT_IN_FILTERS}
diff --git a/products/error_tracking/backend/logic/built_in_filters.py b/products/error_tracking/backend/logic/built_in_filters.py
new file mode 100644
index 000000000000..902a3638b90a
--- /dev/null
+++ b/products/error_tracking/backend/logic/built_in_filters.py
@@ -0,0 +1,161 @@
+from collections.abc import Callable
+from typing import Literal
+
+from django.db import IntegrityError, transaction
+from django.db.models import Q
+
+import structlog
+from temporalio.exceptions import CancelledError
+
+from posthog.dataclasses import frozen
+
+from products.error_tracking.backend.logic.built_in_filter_definitions import (
+ BUILT_IN_FILTERS,
+ BUILT_IN_FILTERS_BY_KEY,
+ BuiltInFilter,
+)
+from products.error_tracking.backend.logic.rules import (
+ compile_filter_bytecode,
+ create_suppression_rule,
+ get_client_safe_filters,
+)
+from products.error_tracking.backend.models import ErrorTrackingSuppressionRule
+
+logger = structlog.get_logger(__name__)
+
+BuiltInFilterEvaluation = Literal["client", "server"]
+
+
+class UnknownBuiltInFilterError(Exception):
+ pass
+
+
+@frozen
+class BuiltInFilterState:
+ definition: BuiltInFilter
+ enabled: bool
+ # Set when ingestion turned the rule off because it failed on an event.
+ disabled_reason: str | None
+
+
+@frozen
+class BuiltInFilterRefreshResult:
+ rules_refreshed: int
+ rules_failed: int
+
+
+def built_in_filter_evaluation(definition: BuiltInFilter) -> BuiltInFilterEvaluation:
+ return "client" if get_client_safe_filters(definition.filters) is not None else "server"
+
+
+def _disabled_reason(rule: ErrorTrackingSuppressionRule | None) -> str | None:
+ if rule is None or rule.disabled_data is None:
+ return None
+ message = rule.disabled_data.get("message") if isinstance(rule.disabled_data, dict) else None
+ return message if isinstance(message, str) and message else "Unknown error"
+
+
+def _state(definition: BuiltInFilter, rule: ErrorTrackingSuppressionRule | None) -> BuiltInFilterState:
+ return BuiltInFilterState(definition=definition, enabled=rule is not None, disabled_reason=_disabled_reason(rule))
+
+
+def _refresh_rule(rule: ErrorTrackingSuppressionRule, definition: BuiltInFilter) -> None:
+ rule.filters = definition.filters
+ rule.bytecode = compile_filter_bytecode(rule.team_id, definition.filters)
+ rule.built_in_hash = definition.filters_hash
+ # A rewritten rule gets a fresh start, so a rule that ingestion turned off runs again.
+ rule.disabled_data = None
+ # update_fields makes the save fail rather than recreate a row that a user deleted in the meantime.
+ rule.save(update_fields=["filters", "bytecode", "built_in_hash", "disabled_data", "updated_at"])
+
+
+def list_built_in_filters(team_id: int) -> list[BuiltInFilterState]:
+ rules = {
+ rule.built_in_key: rule
+ for rule in ErrorTrackingSuppressionRule.objects.filter(team_id=team_id, built_in_key__isnull=False)
+ }
+ return [_state(definition, rules.get(definition.key)) for definition in BUILT_IN_FILTERS]
+
+
+def set_built_in_filter_enabled(team_id: int, key: str, *, enabled: bool) -> BuiltInFilterState:
+ definition = BUILT_IN_FILTERS_BY_KEY.get(key)
+ if definition is None:
+ raise UnknownBuiltInFilterError(key)
+
+ existing = ErrorTrackingSuppressionRule.objects.filter(team_id=team_id, built_in_key=key).first()
+ if not enabled:
+ if existing is not None:
+ existing.delete()
+ return _state(definition, None)
+
+ if existing is not None:
+ if existing.built_in_hash != definition.filters_hash:
+ _refresh_rule(existing, definition)
+ elif existing.disabled_data is not None:
+ existing.disabled_data = None
+ existing.save(update_fields=["disabled_data", "updated_at"])
+ return _state(definition, existing)
+
+ try:
+ with transaction.atomic():
+ rule = create_suppression_rule(
+ team_id,
+ filters=definition.filters,
+ sampling_rate=1.0,
+ built_in_key=definition.key,
+ built_in_hash=definition.filters_hash,
+ )
+ except IntegrityError:
+ # A concurrent request turned the same filter on first.
+ rule = ErrorTrackingSuppressionRule.objects.get(team_id=team_id, built_in_key=key)
+ return _state(definition, rule)
+
+
+def _stale_rules_filter() -> Q:
+ stale = Q()
+ for definition in BUILT_IN_FILTERS:
+ stale |= Q(built_in_key=definition.key) & (
+ Q(built_in_hash__isnull=True) | ~Q(built_in_hash=definition.filters_hash)
+ )
+ return stale
+
+
+def refresh_stale_built_in_filter_rules(
+ *, batch_size: int, on_progress: Callable[[], None] | None = None
+) -> BuiltInFilterRefreshResult:
+ """Rewrite every built-in rule whose hash differs from its definition's hash.
+
+ During a deploy, a worker that still runs older code can rewrite a row back to the older definition.
+ The next run on new code rewrites it again, and the older rule still works in the meantime.
+ A row whose key this code doesn't know is skipped rather than deleted.
+ """
+ refreshed = 0
+ failed = 0
+ stale = _stale_rules_filter()
+ cursor = None
+ while True:
+ queryset = ErrorTrackingSuppressionRule.objects.filter(stale).order_by("id")
+ if cursor is not None:
+ queryset = queryset.filter(id__gt=cursor)
+ batch = list(queryset[:batch_size])
+ if not batch:
+ break
+ for rule in batch:
+ try:
+ _refresh_rule(rule, BUILT_IN_FILTERS_BY_KEY[str(rule.built_in_key)])
+ refreshed += 1
+ except CancelledError:
+ # Temporal raises this inside the activity thread to cancel it, so the sweep must stop here.
+ raise
+ except Exception:
+ failed += 1
+ logger.exception(
+ "error_tracking.built_in_filters.refresh_failed",
+ rule_id=str(rule.id),
+ team_id=rule.team_id,
+ built_in_key=rule.built_in_key,
+ )
+ cursor = batch[-1].id
+ if on_progress is not None:
+ on_progress()
+ return BuiltInFilterRefreshResult(rules_refreshed=refreshed, rules_failed=failed)
diff --git a/products/error_tracking/backend/logic/rules.py b/products/error_tracking/backend/logic/rules.py
index c2be96f5f8c2..45bc12857e00 100644
--- a/products/error_tracking/backend/logic/rules.py
+++ b/products/error_tracking/backend/logic/rules.py
@@ -80,11 +80,11 @@ _ReorderableRule = TypeVar(
)
-def _reorder_rules(model: type[_ReorderableRule], team_id: int, orders: dict[str, int]) -> None:
- rules = list(model.objects.filter(team_id=team_id, id__in=orders.keys()))
+def _reorder_rules(team_rules: QuerySet[_ReorderableRule], orders: dict[str, int]) -> None:
+ rules = list(team_rules.filter(id__in=orders.keys()))
for rule in rules:
- rule.order_key = orders[str(rule.id)] # ty: ignore[invalid-assignment]
- model.objects.filter(team_id=team_id).bulk_update(rules, ["order_key"])
+ rule.order_key = orders[str(rule.id)]
+ team_rules.bulk_update(rules, ["order_key"])
def has_filter_values(json_filters: dict) -> bool:
@@ -158,7 +158,7 @@ def delete_assignment_rule(team_id: int, rule_id: str) -> bool:
def reorder_assignment_rules(team_id: int, orders: dict[str, int]) -> None:
- _reorder_rules(ErrorTrackingAssignmentRule, team_id, orders)
+ _reorder_rules(ErrorTrackingAssignmentRule.objects.filter(team_id=team_id), orders)
def list_severity_rules(team_id: int) -> QuerySet[ErrorTrackingSeverityRule]:
@@ -228,7 +228,7 @@ def delete_severity_rule(team_id: int, rule_id: str) -> bool:
def reorder_severity_rules(team_id: int, orders: dict[str, int]) -> None:
- _reorder_rules(ErrorTrackingSeverityRule, team_id, orders)
+ _reorder_rules(ErrorTrackingSeverityRule.objects.filter(team_id=team_id), orders)
def list_grouping_rules(team_id: int) -> QuerySet[ErrorTrackingGroupingRule]:
@@ -285,24 +285,38 @@ def delete_grouping_rule(team_id: int, rule_id: str) -> bool:
def reorder_grouping_rules(team_id: int, orders: dict[str, int]) -> None:
- _reorder_rules(ErrorTrackingGroupingRule, team_id, orders)
+ _reorder_rules(ErrorTrackingGroupingRule.objects.filter(team_id=team_id), orders)
+
+
+def _custom_suppression_rules(team_id: int) -> QuerySet[ErrorTrackingSuppressionRule]:
+ # Built-in filter switches own their rows, so the custom rule functions never see or change them.
+ return ErrorTrackingSuppressionRule.objects.filter(team_id=team_id, built_in_key__isnull=True)
def list_suppression_rules(team_id: int) -> QuerySet[ErrorTrackingSuppressionRule]:
- return ErrorTrackingSuppressionRule.objects.filter(team_id=team_id).order_by("order_key")
+ return _custom_suppression_rules(team_id).order_by("order_key")
def get_suppression_rule(team_id: int, rule_id: str) -> ErrorTrackingSuppressionRule | None:
- return ErrorTrackingSuppressionRule.objects.filter(team_id=team_id, id=rule_id).first()
+ return _custom_suppression_rules(team_id).filter(id=rule_id).first()
-def create_suppression_rule(team_id: int, *, filters: dict, sampling_rate: float) -> ErrorTrackingSuppressionRule:
+def create_suppression_rule(
+ team_id: int,
+ *,
+ filters: dict,
+ sampling_rate: float,
+ built_in_key: str | None = None,
+ built_in_hash: str | None = None,
+) -> ErrorTrackingSuppressionRule:
return ErrorTrackingSuppressionRule.objects.create(
team_id=team_id,
filters=filters,
bytecode=_rule_bytecode(team_id, filters),
order_key=0,
sampling_rate=sampling_rate,
+ built_in_key=built_in_key,
+ built_in_hash=built_in_hash,
)
@@ -327,12 +341,12 @@ def update_suppression_rule(
def delete_suppression_rule(team_id: int, rule_id: str) -> bool:
- deleted, _ = ErrorTrackingSuppressionRule.objects.filter(team_id=team_id, id=rule_id).delete()
+ deleted, _ = _custom_suppression_rules(team_id).filter(id=rule_id).delete()
return deleted > 0
def reorder_suppression_rules(team_id: int, orders: dict[str, int]) -> None:
- _reorder_rules(ErrorTrackingSuppressionRule, team_id, orders)
+ _reorder_rules(_custom_suppression_rules(team_id), orders)
def list_bypass_rules(team_id: int) -> QuerySet[ErrorTrackingBypassRule]:
@@ -375,7 +389,7 @@ def delete_bypass_rule(team_id: int, rule_id: str) -> bool:
def reorder_bypass_rules(team_id: int, orders: dict[str, int]) -> None:
- _reorder_rules(ErrorTrackingBypassRule, team_id, orders)
+ _reorder_rules(ErrorTrackingBypassRule.objects.filter(team_id=team_id), orders)
def get_client_safe_filters(filters: object) -> dict | None:
diff --git a/products/error_tracking/backend/migrations/0046_errortrackingsuppressionrule_built_in.py b/products/error_tracking/backend/migrations/0046_errortrackingsuppressionrule_built_in.py
new file mode 100644
index 000000000000..213eb005af0e
--- /dev/null
+++ b/products/error_tracking/backend/migrations/0046_errortrackingsuppressionrule_built_in.py
@@ -0,0 +1,20 @@
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("error_tracking", "0045_errortrackingissuesummary"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="errortrackingsuppressionrule",
+ name="built_in_key",
+ field=models.CharField(blank=True, max_length=64, null=True),
+ ),
+ migrations.AddField(
+ model_name="errortrackingsuppressionrule",
+ name="built_in_hash",
+ field=models.CharField(blank=True, max_length=64, null=True),
+ ),
+ ]
diff --git a/products/error_tracking/backend/migrations/0047_errortrackingsuppressionrule_built_in_key_uniq.py b/products/error_tracking/backend/migrations/0047_errortrackingsuppressionrule_built_in_key_uniq.py
new file mode 100644
index 000000000000..ab433a9bc722
--- /dev/null
+++ b/products/error_tracking/backend/migrations/0047_errortrackingsuppressionrule_built_in_key_uniq.py
@@ -0,0 +1,34 @@
+from django.db import migrations, models
+
+from posthog.migration_helpers import CreateIndexConcurrently
+
+
+class Migration(migrations.Migration):
+ atomic = False
+
+ dependencies = [
+ ("error_tracking", "0046_errortrackingsuppressionrule_built_in"),
+ ]
+
+ operations = [
+ migrations.SeparateDatabaseAndState(
+ state_operations=[
+ migrations.AddConstraint(
+ model_name="errortrackingsuppressionrule",
+ constraint=models.UniqueConstraint(
+ condition=models.Q(built_in_key__isnull=False),
+ fields=("built_in_key", "team"),
+ name="et_supp_rule_built_in_key_uniq",
+ ),
+ )
+ ],
+ database_operations=[
+ CreateIndexConcurrently(
+ index_name="et_supp_rule_built_in_key_uniq",
+ table_name="posthog_errortrackingsuppressionrule",
+ columns="(built_in_key, team_id) WHERE built_in_key IS NOT NULL",
+ unique=True,
+ )
+ ],
+ )
+ ]
diff --git a/products/error_tracking/backend/migrations/max_migration.txt b/products/error_tracking/backend/migrations/max_migration.txt
index 7490ac5a9c2a..9e89e8f07d18 100644
--- a/products/error_tracking/backend/migrations/max_migration.txt
+++ b/products/error_tracking/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0045_errortrackingissuesummary
+0047_errortrackingsuppressionrule_built_in_key_uniq
diff --git a/products/error_tracking/backend/models.py b/products/error_tracking/backend/models.py
index 0409abbf8079..93dc38586f86 100644
--- a/products/error_tracking/backend/models.py
+++ b/products/error_tracking/backend/models.py
@@ -602,11 +602,23 @@ class ErrorTrackingSuppressionRule(UUIDTModel):
order_key = models.IntegerField(null=False, blank=False)
# Fraction of matching events to suppress (1.0 = all, 0.5 = half, etc.)
sampling_rate = models.FloatField(null=False, default=1.0)
+ # Set only on rows that a built-in filter switch manages. Users cannot edit these rows directly.
+ built_in_key = models.CharField(max_length=64, null=True, blank=True)
+ # Hash of the definition filters behind this row, so the refresh workflow finds rows whose definition changed.
+ built_in_hash = models.CharField(max_length=64, null=True, blank=True)
class Meta:
indexes = [
models.Index(fields=["team_id"]),
]
+ constraints = [
+ # built_in_key leads so the cross-team refresh of stale rows can use this index too.
+ models.UniqueConstraint(
+ fields=["built_in_key", "team"],
+ condition=models.Q(built_in_key__isnull=False),
+ name="et_supp_rule_built_in_key_uniq",
+ ),
+ ]
db_table = "posthog_errortrackingsuppressionrule"
# TODO - I think this is strictly necessary, but I'm not gonna enforce it right now while we're iterating
diff --git a/products/error_tracking/backend/presentation/views/__init__.py b/products/error_tracking/backend/presentation/views/__init__.py
index ed350eec402b..b3ef8c6c23bc 100644
--- a/products/error_tracking/backend/presentation/views/__init__.py
+++ b/products/error_tracking/backend/presentation/views/__init__.py
@@ -1,5 +1,6 @@
from products.error_tracking.backend.presentation.views.alerts import ErrorTrackingAlertViewSet
from products.error_tracking.backend.presentation.views.assignment_rules import ErrorTrackingAssignmentRuleViewSet
+from products.error_tracking.backend.presentation.views.built_in_filters import ErrorTrackingBuiltInFilterViewSet
from products.error_tracking.backend.presentation.views.bypass_rules import ErrorTrackingBypassRuleViewSet
from products.error_tracking.backend.presentation.views.external_references import ErrorTrackingExternalReferenceViewSet
from products.error_tracking.backend.presentation.views.fingerprints import ErrorTrackingFingerprintViewSet
@@ -39,5 +40,6 @@ __all__ = [
"ErrorTrackingSuppressionRuleViewSet",
"ErrorTrackingAssignmentRuleViewSet",
"ErrorTrackingBypassRuleViewSet",
+ "ErrorTrackingBuiltInFilterViewSet",
"GitProviderFileLinksViewSet",
]
diff --git a/products/error_tracking/backend/presentation/views/built_in_filters.py b/products/error_tracking/backend/presentation/views/built_in_filters.py
new file mode 100644
index 000000000000..d3826d92db4f
--- /dev/null
+++ b/products/error_tracking/backend/presentation/views/built_in_filters.py
@@ -0,0 +1,84 @@
+import posthoganalytics
+from drf_spectacular.utils import OpenApiResponse
+from rest_framework import serializers, viewsets
+from rest_framework.exceptions import NotFound
+from rest_framework.response import Response
+
+from posthog.api.mixins import ValidatedRequest, validated_request
+from posthog.api.routing import TeamAndOrgViewSetMixin
+from posthog.event_usage import get_request_analytics_properties, groups
+
+from products.error_tracking.backend.facade import (
+ api as error_tracking_api,
+ contracts,
+)
+
+
+class ErrorTrackingBuiltInFilterSerializer(serializers.Serializer):
+ key = serializers.CharField(
+ read_only=True, help_text="Stable identifier of the built-in filter, for example `web_crawlers`."
+ )
+ name = serializers.CharField(read_only=True, help_text="Display name of the built-in filter.")
+ description = serializers.CharField(read_only=True, help_text="One sentence on which exceptions the filter drops.")
+ evaluation = serializers.ChoiceField(
+ read_only=True,
+ choices=contracts.BuiltInFilterEvaluation.choices,
+ help_text=(
+ "Where the filter runs. `client` filters also run in the web SDK, which drops matching exceptions "
+ "before it sends them. `server` filters run only during ingestion."
+ ),
+ )
+ enabled = serializers.BooleanField(
+ read_only=True, help_text="Whether the filter drops exceptions for this project."
+ )
+ disabled_reason = serializers.CharField(
+ read_only=True,
+ allow_null=True,
+ help_text=(
+ "Set when ingestion turned the filter off because it failed on an event. "
+ "Turning the filter on again resets it."
+ ),
+ )
+
+
+class ErrorTrackingBuiltInFilterUpdateRequestSerializer(serializers.Serializer):
+ enabled = serializers.BooleanField(
+ help_text="`true` drops matching exceptions for this project. `false` stops dropping them."
+ )
+
+
+class ErrorTrackingBuiltInFilterViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):
+ scope_object = "error_tracking"
+ scope_object_read_actions = ["list"]
+ scope_object_write_actions = ["partial_update"]
+ # Each rule drops events for the whole project, so a grant on one error tracking object is not enough.
+ requires_resource_level_access = True
+ lookup_field = "key"
+ lookup_value_regex = "[a-z0-9_]+"
+
+ @validated_request(responses={200: OpenApiResponse(response=ErrorTrackingBuiltInFilterSerializer(many=True))})
+ def list(self, request: ValidatedRequest, *args, **kwargs) -> Response:
+ filters = error_tracking_api.list_built_in_filters(self.team.id)
+ return Response(ErrorTrackingBuiltInFilterSerializer(filters, many=True).data)
+
+ @validated_request(
+ request_serializer=ErrorTrackingBuiltInFilterUpdateRequestSerializer,
+ responses={200: OpenApiResponse(response=ErrorTrackingBuiltInFilterSerializer)},
+ )
+ def partial_update(self, request: ValidatedRequest, *args, key: str, **kwargs) -> Response:
+ enabled: bool = request.validated_data["enabled"]
+ try:
+ built_in_filter = error_tracking_api.set_built_in_filter_enabled(self.team.id, key, enabled=enabled)
+ except error_tracking_api.UnknownBuiltInFilterError as err:
+ raise NotFound() from err
+ posthoganalytics.capture(
+ "error_tracking_built_in_filter_toggled",
+ distinct_id=request.user.pk,
+ properties={
+ **get_request_analytics_properties(request),
+ "built_in_filter_key": key,
+ "enabled": enabled,
+ },
+ groups=groups(self.team.organization, self.team),
+ )
+ return Response(ErrorTrackingBuiltInFilterSerializer(built_in_filter).data)
diff --git a/products/error_tracking/backend/routes.py b/products/error_tracking/backend/routes.py
index 5fcdebb32d46..ce0140ac40d7 100644
--- a/products/error_tracking/backend/routes.py
+++ b/products/error_tracking/backend/routes.py
@@ -3,6 +3,7 @@ from posthog.api.routing import RouterRegistry
from products.error_tracking.backend.presentation.views import (
ErrorTrackingAlertViewSet,
ErrorTrackingAssignmentRuleViewSet,
+ ErrorTrackingBuiltInFilterViewSet,
ErrorTrackingBypassRuleViewSet,
ErrorTrackingExternalReferenceViewSet,
ErrorTrackingFingerprintViewSet,
@@ -62,6 +63,12 @@ def register_routes(routers: RouterRegistry) -> None:
"project_error_tracking_bypass_rule",
["team_id"],
)
+ routers.projects.register(
+ r"error_tracking/built_in_filters",
+ ErrorTrackingBuiltInFilterViewSet,
+ "project_error_tracking_built_in_filter",
+ ["team_id"],
+ )
routers.projects.register(
r"error_tracking/recommendations",
ErrorTrackingRecommendationViewSet,
diff --git a/products/error_tracking/backend/temporal/__init__.py b/products/error_tracking/backend/temporal/__init__.py
index f1f276586d7b..6d0d563c7563 100644
--- a/products/error_tracking/backend/temporal/__init__.py
+++ b/products/error_tracking/backend/temporal/__init__.py
@@ -3,6 +3,12 @@ from products.error_tracking.backend.temporal.alerts import (
WORKFLOWS as ALERT_WORKFLOWS,
ErrorTrackingAlertDeliveryWorkflow,
)
+from products.error_tracking.backend.temporal.built_in_filters_refresh import (
+ ACTIVITIES as BUILT_IN_FILTERS_REFRESH_ACTIVITIES,
+ WORKFLOWS as BUILT_IN_FILTERS_REFRESH_WORKFLOWS,
+ ErrorTrackingBuiltInFiltersRefreshWorkflow,
+ refresh_built_in_filter_rules_activity,
+)
from products.error_tracking.backend.temporal.lifecycle import (
ACTIVITIES as LIFECYCLE_ACTIVITIES,
WORKFLOWS as LIFECYCLE_WORKFLOWS,
@@ -45,6 +51,7 @@ WORKFLOWS = (
+ RECOMMENDATIONS_REFRESH_WORKFLOWS
+ WEEKLY_DIGEST_WORKFLOWS
+ ALERT_WORKFLOWS
+ + BUILT_IN_FILTERS_REFRESH_WORKFLOWS
)
ACTIVITIES = (
SYMBOL_SET_ACTIVITIES
@@ -52,6 +59,7 @@ ACTIVITIES = (
+ RECOMMENDATIONS_REFRESH_ACTIVITIES
+ WEEKLY_DIGEST_ACTIVITIES
+ ALERT_ACTIVITIES
+ + BUILT_IN_FILTERS_REFRESH_ACTIVITIES
)
__all__ = [
@@ -60,6 +68,7 @@ __all__ = [
"LIFECYCLE_WORKFLOWS",
"WORKFLOWS",
"ErrorTrackingAlertDeliveryWorkflow",
+ "ErrorTrackingBuiltInFiltersRefreshWorkflow",
"ErrorTrackingIssueCreatedWorkflow",
"ErrorTrackingIssueReopenedWorkflow",
"ErrorTrackingIssueSpikingWorkflow",
@@ -71,6 +80,7 @@ __all__ = [
"cleanup_symbol_sets_activity",
"get_digest_orgs_activity",
"get_team_batches_activity",
+ "refresh_built_in_filter_rules_activity",
"refresh_recommendations_batch_activity",
"send_org_digest_activity",
]
diff --git a/products/error_tracking/backend/temporal/built_in_filters_refresh/__init__.py b/products/error_tracking/backend/temporal/built_in_filters_refresh/__init__.py
new file mode 100644
index 000000000000..2ee85436d989
--- /dev/null
+++ b/products/error_tracking/backend/temporal/built_in_filters_refresh/__init__.py
@@ -0,0 +1,16 @@
+from products.error_tracking.backend.temporal.built_in_filters_refresh.activities import (
+ refresh_built_in_filter_rules_activity,
+)
+from products.error_tracking.backend.temporal.built_in_filters_refresh.workflow import (
+ ErrorTrackingBuiltInFiltersRefreshWorkflow,
+)
+
+WORKFLOWS = [ErrorTrackingBuiltInFiltersRefreshWorkflow]
+ACTIVITIES = [refresh_built_in_filter_rules_activity]
+
+__all__ = [
+ "ACTIVITIES",
+ "WORKFLOWS",
+ "ErrorTrackingBuiltInFiltersRefreshWorkflow",
+ "refresh_built_in_filter_rules_activity",
+]
diff --git a/products/error_tracking/backend/temporal/built_in_filters_refresh/activities.py b/products/error_tracking/backend/temporal/built_in_filters_refresh/activities.py
new file mode 100644
index 000000000000..0024b021d8ee
--- /dev/null
+++ b/products/error_tracking/backend/temporal/built_in_filters_refresh/activities.py
@@ -0,0 +1,26 @@
+from django.db import close_old_connections
+
+import structlog
+from temporalio import activity
+
+from products.error_tracking.backend.logic.built_in_filters import refresh_stale_built_in_filter_rules
+from products.error_tracking.backend.temporal.built_in_filters_refresh.types import (
+ BuiltInFiltersRefreshInputs,
+ BuiltInFiltersRefreshResult,
+)
+
+logger = structlog.get_logger(__name__)
+
+
+def refresh_built_in_filter_rules_activity(inputs: BuiltInFiltersRefreshInputs) -> BuiltInFiltersRefreshResult:
+ # Temporal workers are long-lived, so refresh any stale Django DB connection before querying.
+ close_old_connections()
+
+ result = refresh_stale_built_in_filter_rules(batch_size=inputs.batch_size, on_progress=activity.heartbeat)
+ logger.info(
+ "error_tracking.built_in_filters_refresh.complete",
+ rules_refreshed=result.rules_refreshed,
+ rules_failed=result.rules_failed,
+ )
+ return BuiltInFiltersRefreshResult(rules_refreshed=result.rules_refreshed, rules_failed=result.rules_failed)
diff --git a/products/error_tracking/backend/temporal/built_in_filters_refresh/schedule.py b/products/error_tracking/backend/temporal/built_in_filters_refresh/schedule.py
new file mode 100644
index 000000000000..27cf40685885
--- /dev/null
+++ b/products/error_tracking/backend/temporal/built_in_filters_refresh/schedule.py
@@ -0,0 +1,47 @@
+from datetime import timedelta
+
+from django.conf import settings
+
+from temporalio.client import (
+ Client,
+ Schedule,
+ ScheduleActionStartWorkflow,
+ ScheduleIntervalSpec,
+ ScheduleOverlapPolicy,
+ SchedulePolicy,
+ ScheduleSpec,
+)
+
+from posthog.scheduling.jitter import deterministic_offset
+from posthog.temporal.common.schedule import a_create_schedule, a_schedule_exists, a_update_schedule
+
+from products.error_tracking.backend.temporal.built_in_filters_refresh.types import BuiltInFiltersRefreshInputs
+from products.error_tracking.backend.temporal.built_in_filters_refresh.workflow import WORKFLOW_NAME
+
+SCHEDULE_ID = "error-tracking-built-in-filters-refresh-schedule"
+# Rows only go stale when a deploy changes a definition, so an hourly sweep picks up a change soon after it ships.
+SCHEDULE_INTERVAL = timedelta(hours=1)
+
+
+async def create_error_tracking_built_in_filters_refresh_schedule(client: Client) -> None:
+ built_in_filters_refresh_schedule = Schedule(
+ action=ScheduleActionStartWorkflow(
+ WORKFLOW_NAME,
+ BuiltInFiltersRefreshInputs(),
+ id=SCHEDULE_ID,
+ task_queue=settings.ERROR_TRACKING_TASK_QUEUE,
+ ),
+ spec=ScheduleSpec(
+ intervals=[
+ ScheduleIntervalSpec(
+ every=SCHEDULE_INTERVAL, offset=deterministic_offset(SCHEDULE_ID, SCHEDULE_INTERVAL)
+ )
+ ]
+ ),
+ policy=SchedulePolicy(overlap=ScheduleOverlapPolicy.SKIP, catchup_window=SCHEDULE_INTERVAL),
+ )
+
+ if await a_schedule_exists(client, SCHEDULE_ID):
+ await a_update_schedule(client, SCHEDULE_ID, built_in_filters_refresh_schedule, keep_paused=True)
+ else:
+ await a_create_schedule(client, SCHEDULE_ID, built_in_filters_refresh_schedule, trigger_immediately=False)
diff --git a/products/error_tracking/backend/temporal/built_in_filters_refresh/types.py b/products/error_tracking/backend/temporal/built_in_filters_refresh/types.py
new file mode 100644
index 000000000000..b77be2395d38
--- /dev/null
+++ b/products/error_tracking/backend/temporal/built_in_filters_refresh/types.py
@@ -0,0 +1,12 @@
+import dataclasses
+
+
[email protected](frozen=True)
+class BuiltInFiltersRefreshInputs:
+ batch_size: int = 500
+
+
[email protected](frozen=True)
+class BuiltInFiltersRefreshResult:
+ rules_refreshed: int
+ rules_failed: int
diff --git a/products/error_tracking/backend/temporal/built_in_filters_refresh/workflow.py b/products/error_tracking/backend/temporal/built_in_filters_refresh/workflow.py
new file mode 100644
index 000000000000..546f06c39bd0
--- /dev/null
+++ b/products/error_tracking/backend/temporal/built_in_filters_refresh/workflow.py
@@ -0,0 +1,42 @@
+from datetime import timedelta
+
+from temporalio import common, workflow
+
+from posthog.temporal.common.base import PostHogWorkflow
+
+with workflow.unsafe.imports_passed_through():
+ from products.error_tracking.backend.temporal.built_in_filters_refresh.activities import (
+ refresh_built_in_filter_rules_activity,
+ )
+ from products.error_tracking.backend.temporal.built_in_filters_refresh.types import (
+ BuiltInFiltersRefreshInputs,
+ BuiltInFiltersRefreshResult,
+ )
+
+WORKFLOW_NAME = "error-tracking-built-in-filters-refresh"
+
+# A refresh only rewrites rows that are still stale, so a retry repeats no work.
+ACTIVITY_RETRY_POLICY = common.RetryPolicy(maximum_attempts=3, initial_interval=timedelta(seconds=30))
+ACTIVITY_START_TO_CLOSE_TIMEOUT = timedelta(hours=1)
+ACTIVITY_HEARTBEAT_TIMEOUT = timedelta(minutes=5)
+
+
[email protected](name=WORKFLOW_NAME)
+class ErrorTrackingBuiltInFiltersRefreshWorkflow(PostHogWorkflow):
+ """Rewrite the built-in filter rules whose definitions changed since a team turned them on."""
+
+ inputs_cls = BuiltInFiltersRefreshInputs
+ inputs_optional = True
+
+ @workflow.run
+ async def run(self, inputs: BuiltInFiltersRefreshInputs | None = None) -> BuiltInFiltersRefreshResult:
+ if inputs is None:
+ inputs = BuiltInFiltersRefreshInputs()
+
+ return await workflow.execute_activity(
+ refresh_built_in_filter_rules_activity,
+ inputs,
+ start_to_close_timeout=ACTIVITY_START_TO_CLOSE_TIMEOUT,
+ heartbeat_timeout=ACTIVITY_HEARTBEAT_TIMEOUT,
+ retry_policy=ACTIVITY_RETRY_POLICY,
+ )
diff --git a/products/error_tracking/backend/tests/api/test_built_in_filters_api.py b/products/error_tracking/backend/tests/api/test_built_in_filters_api.py
new file mode 100644
index 000000000000..63f621c9cfc1
--- /dev/null
+++ b/products/error_tracking/backend/tests/api/test_built_in_filters_api.py
@@ -0,0 +1,212 @@
+import pytest
+from posthog.test.base import APIBaseTest, BaseTest
+from unittest.mock import call, patch
+
+from parameterized import parameterized
+from rest_framework import status
+from temporalio.exceptions import CancelledError
+
+from posthog.constants import AvailableFeature
+from posthog.models.organization import OrganizationMembership
+from posthog.models.user import User
+
+from products.access_control.backend.facade.testing import create_access_control
+from products.error_tracking.backend.logic.built_in_filter_definitions import BUILT_IN_FILTERS_BY_KEY
+from products.error_tracking.backend.logic.built_in_filters import (
+ refresh_stale_built_in_filter_rules,
+ set_built_in_filter_enabled,
+)
+from products.error_tracking.backend.logic.rules import get_client_safe_suppression_rules
+from products.error_tracking.backend.models import ErrorTrackingSuppressionRule
+
+
+class TestBuiltInFiltersAPI(APIBaseTest):
+ def _url(self, key: str | None = None) -> str:
+ base = f"/api/projects/{self.team.id}/error_tracking/built_in_filters/"
+ return f"{base}{key}/" if key else base
+
+ def _set(self, key: str, enabled: bool) -> dict:
+ response = self.client.patch(self._url(key), data={"enabled": enabled}, format="json")
+ assert response.status_code == status.HTTP_200_OK, response.json()
+ return response.json()
+
+ def _enabled_keys(self) -> set[str]:
+ response = self.client.get(self._url())
+ assert response.status_code == status.HTTP_200_OK
+ return {f["key"] for f in response.json() if f["enabled"]}
+
+ def test_toggling_a_filter_creates_and_deletes_one_rule(self) -> None:
+ assert self._enabled_keys() == set()
+
+ self._set("localhost", True)
+ self._set("localhost", True)
+
+ rule = ErrorTrackingSuppressionRule.objects.get(team=self.team)
+ assert rule.built_in_key == "localhost"
+ assert rule.built_in_hash == BUILT_IN_FILTERS_BY_KEY["localhost"].filters_hash
+ assert rule.bytecode
+ assert self._enabled_keys() == {"localhost"}
+
+ self._set("localhost", False)
+ self._set("localhost", False)
+
+ assert not ErrorTrackingSuppressionRule.objects.filter(team=self.team).exists()
+ assert self._enabled_keys() == set()
+
+ def test_only_client_filters_reach_the_sdk_config(self) -> None:
+ for key in BUILT_IN_FILTERS_BY_KEY:
+ self._set(key, True)
+
+ response = self.client.get(self._url())
+ evaluation = {f["key"]: f["evaluation"] for f in response.json()}
+ assert evaluation == {
+ "web_crawlers": "server",
+ "localhost": "server",
+ "legacy_browsers": "server",
+ "react_hydration_errors": "client",
+ "chunk_load_errors": "client",
+ "resize_observer_loop": "client",
+ }
+ sdk_rules = get_client_safe_suppression_rules(self.team.id)
+ client_keys = [key for key, where in evaluation.items() if where == "client"]
+ assert len(sdk_rules) == len(client_keys)
+ assert all(BUILT_IN_FILTERS_BY_KEY[key].filters in sdk_rules for key in client_keys)
+
+ def test_turning_a_filter_off_rebuilds_the_sdk_config(self) -> None:
+ self._set("resize_observer_loop", True)
+
+ with patch("posthog.models.remote_config._update_team_remote_config") as mock_rebuild:
+ with self.captureOnCommitCallbacks(execute=True):
+ self._set("resize_observer_loop", False)
+
+ assert mock_rebuild.call_args_list == [call(self.team.id)]
+
+ def test_custom_rule_endpoints_cannot_see_or_change_built_in_rules(self) -> None:
+ self._set("web_crawlers", True)
+ rule = ErrorTrackingSuppressionRule.objects.get(team=self.team)
+ rules_url = f"/api/projects/{self.team.id}/error_tracking/suppression_rules/"
+
+ assert self.client.get(rules_url).json()["results"] == []
+ assert self.client.get(f"{rules_url}{rule.id}/").status_code == status.HTTP_404_NOT_FOUND
+ assert (
+ self.client.patch(f"{rules_url}{rule.id}/", data={"sampling_rate": 0.5}, format="json").status_code
+ == status.HTTP_404_NOT_FOUND
+ )
+ assert self.client.delete(f"{rules_url}{rule.id}/").status_code == status.HTTP_404_NOT_FOUND
+ self.client.patch(f"{rules_url}reorder/", data={"orders": {str(rule.id): 5}}, format="json")
+
+ rule.refresh_from_db()
+ assert rule.sampling_rate == 1.0
+ assert rule.order_key == 0
+
+ @parameterized.expand([("current_definition", False), ("changed_definition", True)])
+ def test_turning_a_filter_on_again_retries_a_rule_that_ingestion_turned_off(
+ self, _name: str, definition_changed: bool
+ ) -> None:
+ definition = BUILT_IN_FILTERS_BY_KEY["legacy_browsers"]
+ self._set("legacy_browsers", True)
+ ErrorTrackingSuppressionRule.objects.filter(team=self.team).update(
+ disabled_data={"message": "Invalid regex", "props": {}},
+ **({"filters": {"type": "OR", "values": []}, "built_in_hash": "stale"} if definition_changed else {}),
+ )
+
+ listed = {f["key"]: f for f in self.client.get(self._url()).json()}
+ assert listed["legacy_browsers"]["enabled"] is True
+ assert listed["legacy_browsers"]["disabled_reason"] == "Invalid regex"
+
+ assert self._set("legacy_browsers", True)["disabled_reason"] is None
+ rule = ErrorTrackingSuppressionRule.objects.get(team=self.team)
+ assert rule.disabled_data is None
+ assert rule.filters == definition.filters
+ assert rule.built_in_hash == definition.filters_hash
+
+ @pytest.mark.ee
+ def test_toggling_requires_resource_level_access(self) -> None:
+ self.organization.available_product_features = [
+ {"key": AvailableFeature.ACCESS_CONTROL, "name": AvailableFeature.ACCESS_CONTROL}
+ ]
+ self.organization.save()
+ restricted_user = User.objects.create_and_join(self.organization, "[email protected]", "testtest")
+ membership = OrganizationMembership.objects.get(user=restricted_user, organization=self.organization)
+ create_access_control(team_id=self.team.id, resource="error_tracking", access_level="none")
+ create_access_control(
+ team_id=self.team.id,
+ resource="error_tracking",
+ resource_id="00000000-0000-0000-0000-000000000001",
+ access_level="editor",
+ organization_member_id=membership.id,
+ )
+ self.client.force_login(restricted_user)
+
+ response = self.client.patch(self._url("web_crawlers"), data={"enabled": True}, format="json")
+
+ assert response.status_code == status.HTTP_403_FORBIDDEN
+ assert not ErrorTrackingSuppressionRule.objects.filter(team=self.team).exists()
+
+ def test_unknown_filter_returns_404(self) -> None:
+ response = self.client.patch(self._url("not_a_filter"), data={"enabled": True}, format="json")
+
+ assert response.status_code == status.HTTP_404_NOT_FOUND
+
+
+class TestRefreshStaleBuiltInFilterRules(BaseTest):
+ def test_refresh_rewrites_only_rules_whose_definition_changed(self) -> None:
+ definition = BUILT_IN_FILTERS_BY_KEY["localhost"]
+ set_built_in_filter_enabled(self.team.id, "chunk_load_errors", enabled=True)
+ stale = ErrorTrackingSuppressionRule.objects.create(
+ team=self.team,
+ filters={"type": "OR", "values": []},
+ bytecode=[],
+ order_key=0,
+ built_in_key="localhost",
+ built_in_hash="stale",
+ disabled_data={"message": "Invalid regex", "props": {}},
+ )
+ unknown = ErrorTrackingSuppressionRule.objects.create(
+ team=self.team,
+ filters={"type": "OR", "values": []},
+ bytecode=[],
+ order_key=0,
+ built_in_key="retired_filter",
+ built_in_hash="stale",
+ )
+ untouched = {
+ rule.id: rule.updated_at
+ for rule in ErrorTrackingSuppressionRule.objects.filter(team=self.team).exclude(id=stale.id)
+ }
+
+ result = refresh_stale_built_in_filter_rules(batch_size=1)
+
+ assert (result.rules_refreshed, result.rules_failed) == (1, 0)
+ stale.refresh_from_db()
+ assert stale.filters == definition.filters
+ assert stale.bytecode
+ assert stale.built_in_hash == definition.filters_hash
+ assert stale.disabled_data is None
+ assert {
+ rule.id: rule.updated_at
+ for rule in ErrorTrackingSuppressionRule.objects.filter(team=self.team).exclude(id=stale.id)
+ } == untouched
+ assert unknown.id in untouched
+
+ def test_refresh_stops_when_temporal_cancels_it(self) -> None:
+ for key in ("localhost", "legacy_browsers"):
+ ErrorTrackingSuppressionRule.objects.create(
+ team=self.team,
+ filters={"type": "OR", "values": []},
+ bytecode=[],
+ order_key=0,
+ built_in_key=key,
+ built_in_hash="stale",
+ )
+
+ with (
+ patch(
+ "products.error_tracking.backend.logic.built_in_filters.compile_filter_bytecode",
+ side_effect=CancelledError("cancelled"),
+ ) as compile_bytecode,
+ pytest.raises(CancelledError),
+ ):
+ refresh_stale_built_in_filter_rules(batch_size=1)
+
+ assert compile_bytecode.call_count == 1
diff --git a/products/error_tracking/backend/tests/api/test_suppression_rule_server_evaluation.py b/products/error_tracking/backend/tests/api/test_suppression_rule_server_evaluation.py
index 27505d418a84..61a58c345e5c 100644
--- a/products/error_tracking/backend/tests/api/test_suppression_rule_server_evaluation.py
+++ b/products/error_tracking/backend/tests/api/test_suppression_rule_server_evaluation.py
@@ -2,6 +2,7 @@ from posthog.test.base import APIBaseTest
from parameterized import parameterized
+from products.error_tracking.backend.logic.built_in_filter_definitions import BUILT_IN_FILTERS_BY_KEY
from products.error_tracking.backend.logic.rules import compile_filter_bytecode
from common.hogvm.python.execute import execute_bytecode
@@ -84,3 +85,158 @@ class TestServerFilterEvaluation(APIBaseTest):
for event_props, expected in cases:
assert self._eval(bytecode, event_props) == expected, f"Expected {expected} for props {event_props}"
+
+ @parameterized.expand(
+ [
+ (
+ "web_crawlers",
+ [
+ (
+ {"$raw_user_agent": "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"},
+ True,
+ ),
+ (
+ {
+ "$raw_user_agent": "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; GPTBot/1.2; +https://openai.com/gptbot)"
+ },
+ True,
+ ),
+ (
+ {
+ "$raw_user_agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/120.0.0.0 Safari/537.36"
+ },
+ True,
+ ),
+ (
+ {
+ "$raw_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36"
+ },
+ False,
+ ),
+ (
+ {
+ "$raw_user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Mobile/15E148 Safari/604.1"
+ },
+ False,
+ ),
+ (
+ {
+ "$raw_user_agent": "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko); compatible; ChatGPT-User/1.0; +https://openai.com/bot"
+ },
+ False,
+ ),
+ ({"$raw_user_agent": "axios/1.6.0"}, False),
+ ({"$raw_user_agent": ""}, False),
+ ({}, False),
+ ],
+ ),
+ (
+ "localhost",
+ [
+ ({"$current_url": "http://localhost:3000/dashboard"}, True),
+ ({"$current_url": "https://app.localhost/settings"}, True),
+ ({"$current_url": "http://127.0.0.1:8000"}, True),
+ ({"$current_url": "http://[::1]:5173/"}, True),
+ ({"$current_url": "http://0.0.0.0:8080/"}, True),
+ ({"$current_url": "file:///Users/example/index.html"}, True),
+ ({"$current_url": "HTTP://LOCALHOST"}, True),
+ ({"$current_url": "https://localhost.example.com/"}, False),
+ ({"$current_url": "https://example.com/?next=http://localhost:3000"}, False),
+ ({"$current_url": "http://localhostfoo/"}, False),
+ ({}, False),
+ ],
+ ),
+ (
+ "legacy_browsers",
+ [
+ ({"$browser": "Internet Explorer", "$browser_version": 11}, True),
+ ({"$browser": "Internet Explorer"}, True),
+ ({"$browser": "Chrome", "$browser_version": 86}, True),
+ ({"$browser": "Chrome", "$browser_version": "86.0.4240.198"}, True),
+ ({"$browser": "Chrome", "$browser_version": 87}, False),
+ ({"$browser": "Chrome", "$browser_version": 120.0}, False),
+ ({"$browser": "Microsoft Edge", "$browser_version": 18}, True),
+ ({"$browser": "Microsoft Edge", "$browser_version": 88}, False),
+ ({"$browser": "Firefox", "$browser_version": 77}, True),
+ ({"$browser": "Firefox", "$browser_version": 78}, False),
+ ({"$browser": "Safari", "$browser_version": 13.1}, True),
+ ({"$browser": "Safari", "$browser_version": 14}, False),
+ ({"$browser": "Mobile Safari", "$browser_version": 9}, True),
+ ({"$browser": "Opera", "$browser_version": 72}, True),
+ ({"$browser": "Opera", "$browser_version": 73}, False),
+ ({"$browser": "Chrome", "$browser_version": "unknown"}, False),
+ ({"$browser": "Chrome"}, False),
+ ({"$browser_version": 10}, False),
+ ({}, False),
+ ],
+ ),
+ (
+ "react_hydration_errors",
+ [
+ (
+ {
+ "$exception_values": [
+ "Minified React error #418; visit https://react.dev/errors/418?args[]=text for the full message"
+ ]
+ },
+ True,
+ ),
+ (
+ {
+ "$exception_values": [
+ "Minified React error #423; visit https://reactjs.org/docs/error-decoder.html?invariant=423 for the full message"
+ ]
+ },
+ True,
+ ),
+ (
+ {
+ "$exception_values": [
+ "Minified React error #185; visit https://react.dev/errors/185 for the full message"
+ ]
+ },
+ False,
+ ),
+ ({}, False),
+ ],
+ ),
+ (
+ "chunk_load_errors",
+ [
+ (
+ {"$exception_types": ["ChunkLoadError"], "$exception_values": ["Loading chunk 123 failed."]},
+ True,
+ ),
+ (
+ {
+ "$exception_types": ["TypeError"],
+ "$exception_values": [
+ "Failed to fetch dynamically imported module: https://example.com/assets/index-a1b2c3.js"
+ ],
+ },
+ True,
+ ),
+ (
+ {"$exception_types": ["TypeError"], "$exception_values": ["Importing a module script failed."]},
+ True,
+ ),
+ ({"$exception_types": ["TypeError"], "$exception_values": ["Failed to fetch"]}, False),
+ ({}, False),
+ ],
+ ),
+ (
+ "resize_observer_loop",
+ [
+ ({"$exception_values": ["ResizeObserver loop completed with undelivered notifications."]}, True),
+ ({"$exception_values": ["ResizeObserver loop limit exceeded"]}, True),
+ ({"$exception_values": ["ResizeObserver is not defined"]}, False),
+ ({}, False),
+ ],
+ ),
+ ]
+ )
+ def test_built_in_filter_evaluation(self, key: str, cases: list[tuple[dict, bool]]) -> None:
+ bytecode = compile_filter_bytecode(self.team.id, BUILT_IN_FILTERS_BY_KEY[key].filters)
+
+ for event_props, expected in cases:
+ assert self._eval(bytecode, event_props) == expected, f"Expected {expected} for props {event_props}"
diff --git a/products/error_tracking/backend/tests/test_built_in_filter_definitions.py b/products/error_tracking/backend/tests/test_built_in_filter_definitions.py
new file mode 100644
index 000000000000..02fe921fc673
--- /dev/null
+++ b/products/error_tracking/backend/tests/test_built_in_filter_definitions.py
@@ -0,0 +1,35 @@
+from typing import Any
+
+from django.test import SimpleTestCase
+
+from products.error_tracking.backend.logic.built_in_filter_definitions import (
+ BUILT_IN_FILTERS,
+ MAX_CACHED_REGEX_LENGTH,
+ chunk_alternation,
+)
+
+
+def _regex_values(filters: dict[str, Any]) -> list[str]:
+ values: list[str] = []
+ for value in filters.get("values", []):
+ if "values" in value:
+ values.extend(_regex_values(value))
+ elif value.get("operator") == "regex":
+ values.append(value["value"])
+ return values
+
+
+class TestBuiltInFilterDefinitions(SimpleTestCase):
+ def test_every_regex_fits_the_ingestion_regex_cache(self) -> None:
+ for definition in BUILT_IN_FILTERS:
+ for pattern in _regex_values(definition.filters):
+ assert len(pattern) <= MAX_CACHED_REGEX_LENGTH, definition.key
+
+ def test_chunk_alternation_keeps_every_pattern_in_order(self) -> None:
+ patterns = [f"bot{i}" * 20 for i in range(30)]
+
+ chunks = chunk_alternation(patterns, max_length=200)
+
+ assert len(chunks) > 1
+ assert all(len(chunk) <= 200 for chunk in chunks)
+ assert "|".join(chunks) == "|".join(f"(?:{p})" for p in patterns)
diff --git a/products/error_tracking/frontend/generated/api.schemas.ts b/products/error_tracking/frontend/generated/api.schemas.ts
index 115d21589579..dfebb0d53e8d 100644
--- a/products/error_tracking/frontend/generated/api.schemas.ts
+++ b/products/error_tracking/frontend/generated/api.schemas.ts
@@ -645,6 +645,44 @@ export interface PatchedErrorTrackingAssignmentRuleReorderRequestApi {
orders?: PatchedErrorTrackingAssignmentRuleReorderRequestApiOrders
}
+/**
+ * * `client` - Client
+ * * `server` - Server
+ */
+export type BuiltInFilterEvaluationEnumApi =
+ (typeof BuiltInFilterEvaluationEnumApi)[keyof typeof BuiltInFilterEvaluationEnumApi]
+
+export const BuiltInFilterEvaluationEnumApi = {
+ Client: 'client',
+ Server: 'server',
+} as const
+
+export interface ErrorTrackingBuiltInFilterApi {
+ /** Stable identifier of the built-in filter, for example `web_crawlers`. */
+ readonly key: string
+ /** Display name of the built-in filter. */
+ readonly name: string
+ /** One sentence on which exceptions the filter drops. */
+ readonly description: string
+ /** Where the filter runs. `client` filters also run in the web SDK, which drops matching exceptions before it sends them. `server` filters run only during ingestion.
+ *
+ * * `client` - Client
+ * * `server` - Server */
+ readonly evaluation: BuiltInFilterEvaluationEnumApi
+ /** Whether the filter drops exceptions for this project. */
+ readonly enabled: boolean
+ /**
+ * Set when ingestion turned the filter off because it failed on an event. Turning the filter on again resets it.
+ * @nullable
+ */
+ readonly disabled_reason: string | null
+}
+
+export interface PatchedErrorTrackingBuiltInFilterUpdateRequestApi {
+ /** `true` drops matching exceptions for this project. `false` stops dropping them. */
+ enabled?: boolean
+}
+
export interface ErrorTrackingBypassRuleApi {
/** Unique identifier of the bypass rule. */
readonly id: string
diff --git a/products/error_tracking/frontend/generated/api.ts b/products/error_tracking/frontend/generated/api.ts
index dabdfe1b0bf1..6a17ddeea353 100644
--- a/products/error_tracking/frontend/generated/api.ts
+++ b/products/error_tracking/frontend/generated/api.ts
@@ -17,6 +17,7 @@ import type {
ErrorTrackingAssignmentRuleCreateRequestApi,
ErrorTrackingAssignmentRuleUpdateRequestApi,
ErrorTrackingAssignmentRulesListParams,
+ ErrorTrackingBuiltInFilterApi,
ErrorTrackingBypassRuleApi,
ErrorTrackingBypassRuleCreateRequestApi,
ErrorTrackingBypassRuleUpdateRequestApi,
@@ -107,6 +108,7 @@ import type {
PatchedErrorTrackingAlertUpdateRequestApi,
PatchedErrorTrackingAssignmentRuleReorderRequestApi,
PatchedErrorTrackingAssignmentRuleUpdateRequestApi,
+ PatchedErrorTrackingBuiltInFilterUpdateRequestApi,
PatchedErrorTrackingBypassRuleReorderRequestApi,
PatchedErrorTrackingBypassRuleUpdateRequestApi,
PatchedErrorTrackingGroupingRuleReorderRequestApi,
@@ -383,6 +385,38 @@ export const errorTrackingAssignmentRulesReorderPartialUpdate = async (
})
}
+export const getErrorTrackingBuiltInFiltersListUrl = (projectId: string) => {
+ return `/api/projects/${projectId}/error_tracking/built_in_filters/`
+}
+
+export const errorTrackingBuiltInFiltersList = async (
+ projectId: string,
+ options?: RequestInit
+): Promise<ErrorTrackingBuiltInFilterApi[]> => {
+ return apiMutator<ErrorTrackingBuiltInFilterApi[]>(getErrorTrackingBuiltInFiltersListUrl(projectId), {
+ ...options,
+ method: 'GET',
+ })
+}
+
+export const getErrorTrackingBuiltInFiltersPartialUpdateUrl = (projectId: string, key: string) => {
+ return `/api/projects/${projectId}/error_tracking/built_in_filters/${key}/`
+}
+
+export const errorTrackingBuiltInFiltersPartialUpdate = async (
+ projectId: string,
+ key: string,
+ patchedErrorTrackingBuiltInFilterUpdateRequestApi?: PatchedErrorTrackingBuiltInFilterUpdateRequestApi,
+ options?: RequestInit
+): Promise<ErrorTrackingBuiltInFilterApi> => {
+ return apiMutator<ErrorTrackingBuiltInFilterApi>(getErrorTrackingBuiltInFiltersPartialUpdateUrl(projectId, key), {
+ ...options,
+ method: 'PATCH',
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
+ body: JSON.stringify(patchedErrorTrackingBuiltInFilterUpdateRequestApi),
+ })
+}
+
export const getErrorTrackingBypassRulesListUrl = (projectId: string, params?: ErrorTrackingBypassRulesListParams) => {
const normalizedParams = new URLSearchParams()
diff --git a/products/error_tracking/frontend/generated/api.zod.ts b/products/error_tracking/frontend/generated/api.zod.ts
index 8c0942606d5f..1826692d0c5b 100644
--- a/products/error_tracking/frontend/generated/api.zod.ts
+++ b/products/error_tracking/frontend/generated/api.zod.ts
@@ -330,6 +330,13 @@ export const ErrorTrackingAssignmentRulesReorderPartialUpdateBody = /* @__PURE__
.describe('Mapping from assignment rule UUID to its new evaluation order.'),
})
+export const ErrorTrackingBuiltInFiltersPartialUpdateBody = /* @__PURE__ */ zod.object({
+ enabled: zod
+ .boolean()
+ .optional()
+ .describe('`true` drops matching exceptions for this project. `false` stops dropping them.'),
+})
+
export const ErrorTrackingBypassRulesCreateBody = /* @__PURE__ */ zod.object({
filters: zod
.record(zod.string(), zod.unknown())
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/built_in_filters/BuiltInFilterRow.stories.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/built_in_filters/BuiltInFilterRow.stories.tsx
new file mode 100644
index 000000000000..3557ebf8b902
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/built_in_filters/BuiltInFilterRow.stories.tsx
@@ -0,0 +1,85 @@
+import { Meta, StoryObj } from '@storybook/react'
+
+import type { ErrorTrackingBuiltInFilterApi } from '../../../generated/api.schemas'
+import { BuiltInFilterRow } from './BuiltInFilterRow'
+
+const meta: Meta<typeof BuiltInFilterRow> = {
+ title: 'ErrorTracking/BuiltInFilterRow',
+ component: BuiltInFilterRow,
+ parameters: {
+ layout: 'padded',
+ testOptions: { snapshotBrowsers: ['chromium'] },
+ },
+}
+export default meta
+
+type Story = StoryObj<typeof BuiltInFilterRow>
+
+const FILTERS: ErrorTrackingBuiltInFilterApi[] = [
+ {
+ key: 'web_crawlers',
+ name: 'Web crawlers and bots',
+ description: 'Drop exceptions from search engines, AI crawlers, uptime monitors and headless browsers.',
+ evaluation: 'server',
+ enabled: true,
+ disabled_reason: null,
+ },
+ {
+ key: 'localhost',
+ name: 'Local development',
+ description: 'Drop exceptions from pages on localhost, a loopback address or a file: URL.',
+ evaluation: 'server',
+ enabled: false,
+ disabled_reason: null,
+ },
+ {
+ key: 'legacy_browsers',
+ name: 'Legacy browsers',
+ description:
+ 'Drop exceptions from Internet Explorer, Chrome before 87, Edge before 88, Firefox before 78, Safari before 14 and Opera before 73.',
+ evaluation: 'server',
+ enabled: true,
+ disabled_reason: null,
+ },
+ {
+ key: 'react_hydration_errors',
+ name: 'React hydration errors',
+ description: "Drop React errors about server-rendered HTML that doesn't match the page in the browser.",
+ evaluation: 'client',
+ enabled: false,
+ disabled_reason: null,
+ },
+ {
+ key: 'chunk_load_errors',
+ name: 'Chunk load errors',
+ description: 'Drop errors from lazy-loaded scripts that fail to load, which often happens after a deploy.',
+ evaluation: 'client',
+ enabled: true,
+ disabled_reason: null,
+ },
+ {
+ key: 'resize_observer_loop',
+ name: 'ResizeObserver loop errors',
+ description: 'Drop the ResizeObserver loop warning that browsers report as an error.',
+ evaluation: 'client',
+ enabled: false,
+ disabled_reason: null,
+ },
+]
+
+// A narrow container matches a settings scene with the side panel open.
+export const SomeRulesOn: Story = {
+ render: () => (
+ <div className="w-[520px] rounded border bg-surface-primary divide-y">
+ {FILTERS.map((filter) => (
+ <BuiltInFilterRow
+ key={filter.key}
+ filter={filter}
+ saving={false}
+ editDisabledReason={null}
+ onSetEnabled={() => {}}
+ />
+ ))}
+ </div>
+ ),
+}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/built_in_filters/BuiltInFilterRow.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/built_in_filters/BuiltInFilterRow.tsx
new file mode 100644
index 000000000000..a11c2e866c19
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/built_in_filters/BuiltInFilterRow.tsx
@@ -0,0 +1,52 @@
+import { LemonButton, LemonSwitch } from '@posthog/lemon-ui'
+
+import type { ErrorTrackingBuiltInFilterApi } from '../../../generated/api.schemas'
+
+export interface BuiltInFilterRowProps {
+ filter: ErrorTrackingBuiltInFilterApi
+ saving: boolean
+ editDisabledReason: string | null
+ onSetEnabled: (enabled: boolean) => void
+}
+
+export function BuiltInFilterRow({
+ filter,
+ saving,
+ editDisabledReason,
+ onSetEnabled,
+}: BuiltInFilterRowProps): JSX.Element {
+ return (
+ <div className="flex items-center gap-4 p-3">
+ <div className="flex min-w-0 flex-1 flex-col gap-1">
+ <span className="font-semibold">{filter.name}</span>
+ <span className="text-secondary">{filter.description}</span>
+ {filter.disabled_reason ? (
+ <span className="text-danger text-xs">
+ <span>Ingestion turned this rule off after it failed on an event: </span>
+ <span translate="no">{filter.disabled_reason}</span>
+ </span>
+ ) : null}
+ </div>
+ {filter.disabled_reason ? (
+ <LemonButton
+ type="secondary"
+ size="small"
+ loading={saving}
+ disabledReason={editDisabledReason}
+ onClick={() => onSetEnabled(true)}
+ data-attr="error-tracking-built-in-filter-retry"
+ >
+ Retry
+ </LemonButton>
+ ) : null}
+ <LemonSwitch
+ checked={filter.enabled}
+ onChange={onSetEnabled}
+ loading={saving}
+ disabledReason={editDisabledReason}
+ aria-label={filter.name}
+ data-attr={`error-tracking-built-in-filter-${filter.key}`}
+ />
+ </div>
+ )
+}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/built_in_filters/BuiltInFilters.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/built_in_filters/BuiltInFilters.tsx
new file mode 100644
index 000000000000..25c90b0b8a08
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/built_in_filters/BuiltInFilters.tsx
@@ -0,0 +1,39 @@
+import { useActions, useValues } from 'kea'
+
+import { LemonBanner, LemonSkeleton } from '@posthog/lemon-ui'
+
+import { errorTrackingEditAccessDisabledReason } from '../../../utils'
+import { BuiltInFilterRow } from './BuiltInFilterRow'
+import { builtInFiltersLogic } from './builtInFiltersLogic'
+
+export function BuiltInFilters(): JSX.Element {
+ const { builtInFilters, builtInFiltersLoadFailed, pendingKeys } = useValues(builtInFiltersLogic)
+ const { loadBuiltInFilters, setFilterEnabled } = useActions(builtInFiltersLogic)
+ const editDisabledReason = errorTrackingEditAccessDisabledReason()
+
+ if (builtInFiltersLoadFailed) {
+ return (
+ <LemonBanner type="error" action={{ children: 'Try again', onClick: () => loadBuiltInFilters() }}>
+ Couldn't load the automatic suppression rules.
+ </LemonBanner>
+ )
+ }
+
+ if (builtInFilters === null) {
+ return <LemonSkeleton className="h-14" repeat={3} />
+ }
+
+ return (
+ <div className="rounded border bg-surface-primary divide-y">
+ {builtInFilters.map((filter) => (
+ <BuiltInFilterRow
+ key={filter.key}
+ filter={filter}
+ saving={pendingKeys.includes(filter.key)}
+ editDisabledReason={editDisabledReason}
+ onSetEnabled={(enabled) => setFilterEnabled(filter.key, enabled)}
+ />
+ ))}
+ </div>
+ )
+}
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/built_in_filters/builtInFiltersLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/built_in_filters/builtInFiltersLogic.ts
new file mode 100644
index 000000000000..085eed41dc01
--- /dev/null
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/built_in_filters/builtInFiltersLogic.ts
@@ -0,0 +1,120 @@
+import { MakeLogicType, actions, afterMount, kea, listeners, path, reducers } from 'kea'
+import { loaders } from 'kea-loaders'
+
+import { lemonToast } from '@posthog/lemon-ui'
+
+import { teamLogic } from 'scenes/teamLogic'
+
+import { errorTrackingBuiltInFiltersList, errorTrackingBuiltInFiltersPartialUpdate } from '../../../generated/api'
+import type { ErrorTrackingBuiltInFilterApi } from '../../../generated/api.schemas'
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface builtInFiltersLogicValues {
+ builtInFilters: ErrorTrackingBuiltInFilterApi[] | null
+ builtInFiltersLoadFailed: boolean
+ builtInFiltersLoading: boolean
+ pendingKeys: string[]
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface builtInFiltersLogicActions {
+ loadBuiltInFilters: () => any
+ loadBuiltInFiltersFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadBuiltInFiltersSuccess: (
+ builtInFilters: ErrorTrackingBuiltInFilterApi[],
+ payload?: any
+ ) => {
+ builtInFilters: ErrorTrackingBuiltInFilterApi[]
+ payload?: any
+ }
+ setFilterEnabled: (
+ key: string,
+ enabled: boolean
+ ) => {
+ enabled: boolean
+ key: string
+ }
+ setFilterSaveFailed: (key: string) => {
+ key: string
+ }
+ setFilterSaved: (filter: ErrorTrackingBuiltInFilterApi) => {
+ filter: ErrorTrackingBuiltInFilterApi
+ }
+}
+
+export type builtInFiltersLogicType = MakeLogicType<builtInFiltersLogicValues, builtInFiltersLogicActions>
+
+export const builtInFiltersLogic = kea<builtInFiltersLogicType>([
+ path([
+ 'products',
+ 'error_tracking',
+ 'scenes',
+ 'ErrorTrackingConfigurationScene',
+ 'built_in_filters',
+ 'builtInFiltersLogic',
+ ]),
+
+ actions({
+ setFilterEnabled: (key: string, enabled: boolean) => ({ key, enabled }),
+ setFilterSaved: (filter: ErrorTrackingBuiltInFilterApi) => ({ filter }),
+ setFilterSaveFailed: (key: string) => ({ key }),
+ }),
+
+ loaders({
+ builtInFilters: [
+ null as ErrorTrackingBuiltInFilterApi[] | null,
+ {
+ loadBuiltInFilters: async () =>
+ await errorTrackingBuiltInFiltersList(String(teamLogic.values.currentTeamId)),
+ },
+ ],
+ }),
+
+ reducers({
+ builtInFilters: {
+ setFilterSaved: (state, { filter }) => state?.map((f) => (f.key === filter.key ? filter : f)) ?? state,
+ },
+ builtInFiltersLoadFailed: [
+ false,
+ {
+ loadBuiltInFilters: () => false,
+ loadBuiltInFiltersFailure: () => true,
+ },
+ ],
+ // Keys with a request in flight, so each switch blocks a second toggle until its own request settles.
+ pendingKeys: [
+ [] as string[],
+ {
+ setFilterEnabled: (state, { key }) => [...state, key],
+ setFilterSaved: (state, { filter }) => state.filter((k) => k !== filter.key),
+ setFilterSaveFailed: (state, { key }) => state.filter((k) => k !== key),
+ },
+ ],
+ }),
+
+ listeners(({ actions }) => ({
+ setFilterEnabled: async ({ key, enabled }) => {
+ try {
+ const filter = await errorTrackingBuiltInFiltersPartialUpdate(
+ String(teamLogic.values.currentTeamId),
+ key,
+ { enabled }
+ )
+ actions.setFilterSaved(filter)
+ } catch {
+ actions.setFilterSaveFailed(key)
+ lemonToast.error("Couldn't update the rule. Try again, and if it keeps failing, contact support.")
+ }
+ },
+ })),
+
+ afterMount(({ actions }) => {
+ actions.loadBuiltInFilters()
+ }),
+])
diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/suppression_rules/SuppressionRules.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/suppression_rules/SuppressionRules.tsx
index 12243960e15c..7ec98ea15027 100644
--- a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/suppression_rules/SuppressionRules.tsx
+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/suppression_rules/SuppressionRules.tsx
@@ -1,5 +1,7 @@
import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
+import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
+import { BuiltInFilters } from '../built_in_filters/BuiltInFilters'
import { RuleList } from '../rules/RuleList'
import { ErrorTrackingRuleType, ErrorTrackingSuppressionRule } from '../rules/types'
import { EvaluationIndicator, SamplingRateIndicator, getEvalMode } from './EvaluationIndicator'
@@ -7,7 +9,9 @@ import { SuppressionRuleModal } from './SuppressionRuleModal'
import { suppressionRuleModalLogic } from './suppressionRuleModalLogic'
export function SuppressionRules(): JSX.Element {
- return (
+ const hasAutomaticRules = useFeatureFlag('ERROR_TRACKING_BUILT_IN_FILTERS')
+
+ const manualRules = (
<RuleList
ruleType={ErrorTrackingRuleType.Suppression}
modalLogic={suppressionRuleModalLogic}
@@ -31,4 +35,30 @@ export function SuppressionRules(): JSX.Element {
)}
/>
)
+
+ if (!hasAutomaticRules) {
+ return manualRules
+ }
+
+ return (
+ <div className="space-y-8">
+ <div className="space-y-4">
+ <div>
+ <h3 className="font-semibold text-base mb-1">Automatic suppression rules</h3>
+ <p className="text-muted-foreground">
+ PostHog maintains these rules for common exceptions that you usually can't act on, and keeps
+ them up to date.
+ </p>
+ </div>
+ <BuiltInFilters />
+ </div>
+ <div className="space-y-4">
+ <div>
+ <h3 className="font-semibold text-base mb-1">Manual suppression rules</h3>
+ <p className="text-muted-foreground">Rules that you create and edit.</p>
+ </div>
+ {manualRules}
+ </div>
+ </div>
+ )
}
diff --git a/products/web_analytics/backend/facade/bot_definitions.py b/products/web_analytics/backend/facade/bot_definitions.py
new file mode 100644
index 000000000000..cdaca6c6a5bf
--- /dev/null
+++ b/products/web_analytics/backend/facade/bot_definitions.py
@@ -0,0 +1,6 @@
+from products.web_analytics.backend.hogql_queries.bot_definitions import BOT_DEFINITIONS
+
+
+def bot_user_agent_patterns(*, exclude_categories: frozenset[str] = frozenset()) -> list[str]:
+ """Return the case-sensitive RE2 patterns that match the user agent of a known bot, in definition order."""
+ return [pattern for pattern, bot in BOT_DEFINITIONS.items() if bot.category not in exclude_categories]
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 4507f258c2a9..9fd7d64aa2eb 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -20301,6 +20301,18 @@ export namespace Schemas {
Failed: 'failed',
} as const;
+ /**
+ * * `client` - Client
+ * * `server` - Server
+ */
+ export type BuiltInFilterEvaluationEnum = typeof BuiltInFilterEvaluationEnum[keyof typeof BuiltInFilterEvaluationEnum];
+
+
+ export const BuiltInFilterEvaluationEnum = {
+ Client: 'client',
+ Server: 'server',
+ } as const;
+
/**
* * `summarize_recording` - Summarize recording
*/
@@ -43047,6 +43059,27 @@ export namespace Schemas {
version?: number | null;
}
+ export interface ErrorTrackingBuiltInFilter {
+ /** Stable identifier of the built-in filter, for example `web_crawlers`. */
+ readonly key: string;
+ /** Display name of the built-in filter. */
+ readonly name: string;
+ /** One sentence on which exceptions the filter drops. */
+ readonly description: string;
+ /** Where the filter runs. `client` filters also run in the web SDK, which drops matching exceptions before it sends them. `server` filters run only during ingestion.
+ *
+ * * `client` - Client
+ * * `server` - Server */
+ readonly evaluation: BuiltInFilterEvaluationEnum;
+ /** Whether the filter drops exceptions for this project. */
+ readonly enabled: boolean;
+ /**
+ * Set when ingestion turned the filter off because it failed on an event. Turning the filter on again resets it.
+ * @nullable
+ */
+ readonly disabled_reason: string | null;
+ }
+
export interface ErrorTrackingBypassRule {
/** Unique identifier of the bypass rule. */
readonly id: string;
@@ -86299,6 +86332,11 @@ export namespace Schemas {
assignee?: ErrorTrackingAssignmentRuleAssigneeRequest | null;
}
+ export interface PatchedErrorTrackingBuiltInFilterUpdateRequest {
+ /** `true` drops matching exceptions for this project. `false` stops dropping them. */
+ enabled?: boolean;
+ }
+
/**
* Mapping from bypass rule UUID to its new evaluation order.
*/
diff --git a/tach.toml b/tach.toml
index 0e7d1dca350e..f793c13e55e7 100644
--- a/tach.toml
+++ b/tach.toml
@@ -495,6 +495,8 @@ depends_on = [
"products.notifications",
"products.signals",
"products.warehouse_sources", "products.access_control",
+ # Facade-only: the built-in bot filter reads the bot user agent patterns.
+ "products.web_analytics",
]
layer = "modules"