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(ingestion): let event restrictions target the heatmaps pipeline (#106853)

Paweł Ledwoń374927af176d
diff --git a/frontend/src/generated/core/api.schemas.ts b/frontend/src/generated/core/api.schemas.ts
index 28233a1423d7..a095cfcbce78 100644
--- a/frontend/src/generated/core/api.schemas.ts
+++ b/frontend/src/generated/core/api.schemas.ts
@@ -3659,6 +3659,7 @@ export const RestrictionTypeEnumApi = {
* * `session_recordings` - Session Recordings
* * `errortracking` - Errortracking
* * `clientwarnings` - Clientwarnings
+ * * `heatmaps` - Heatmaps
* * `ai` - Ai
*/
export type IngestionPipelineEnumApi = (typeof IngestionPipelineEnumApi)[keyof typeof IngestionPipelineEnumApi]
@@ -3668,6 +3669,7 @@ export const IngestionPipelineEnumApi = {
SessionRecordings: 'session_recordings',
Errortracking: 'errortracking',
Clientwarnings: 'clientwarnings',
+ Heatmaps: 'heatmaps',
Ai: 'ai',
} as const
diff --git a/frontend/src/layout/navigation/EventIngestionRestrictionDetails.tsx b/frontend/src/layout/navigation/EventIngestionRestrictionDetails.tsx
index aab67f9ce435..ce5d532ffd34 100644
--- a/frontend/src/layout/navigation/EventIngestionRestrictionDetails.tsx
+++ b/frontend/src/layout/navigation/EventIngestionRestrictionDetails.tsx
@@ -43,6 +43,7 @@ const PIPELINE_LABELS: Record<IngestionPipelineEnumApi, string> = {
session_recordings: 'session recordings',
errortracking: 'error tracking',
clientwarnings: 'client warnings',
+ heatmaps: 'heatmaps',
ai: 'AI',
}
diff --git a/posthog/admin/admins/tophog_admin.py b/posthog/admin/admins/tophog_admin.py
index a7b901d65472..bb3bbe71a393 100644
--- a/posthog/admin/admins/tophog_admin.py
+++ b/posthog/admin/admins/tophog_admin.py
@@ -31,6 +31,8 @@ TOPHOG_TO_RESTRICTION_PIPELINE = {
"sessionreplay": "session_recordings",
"errortracking": "errortracking",
"clientwarnings": "clientwarnings",
+ "heatmaps": "heatmaps",
+ "ai": "ai",
}
PRESETS = OrderedDict(
@@ -125,8 +127,8 @@ def _restriction_matches(
Key fields absent from the tophog entry don't disqualify a restriction.
Pipelines require full coverage: every one of the entry's pipelines must map to a
- restriction pipeline the restriction applies to. Unmapped pipelines (e.g. ai, heatmaps)
- can't be restricted at all, so an entry that includes one is never covered.
+ restriction pipeline the restriction applies to. Unmapped pipelines can't be
+ restricted at all, so an entry that includes one is never covered.
"""
if _extendable_fields(restriction, key):
return False
diff --git a/posthog/admin/test_tophog_admin.py b/posthog/admin/test_tophog_admin.py
index fbabb9928eec..9540686830d8 100644
--- a/posthog/admin/test_tophog_admin.py
+++ b/posthog/admin/test_tophog_admin.py
@@ -93,7 +93,8 @@ class TestTopHogAdminHelpers(BaseTest):
@parameterized.expand(
[
("known_names_mapped", ["sessionreplay", "analytics"], ["analytics", "session_recordings"]),
- ("unknown_names_dropped", ["heatmaps", "ai"], []),
+ ("heatmaps_and_ai_mapped", ["heatmaps", "ai"], ["ai", "heatmaps"]),
+ ("unknown_names_dropped", ["unknown"], []),
]
)
def test_map_pipelines(self, _name, tophog_pipelines, expected):
@@ -113,8 +114,8 @@ class TestTopHogAdminHelpers(BaseTest):
),
("pipeline_covered", {}, {}, ["analytics"], True),
("pipeline_disjoint", {"pipelines": ["errortracking"]}, {}, ["analytics"], False),
- ("unmapped_pipeline_never_covered", {}, {}, ["ai"], False),
- ("partially_unmapped_never_covered", {}, {}, ["analytics", "ai"], False),
+ ("unmapped_pipeline_never_covered", {}, {}, ["unknown"], False),
+ ("partially_unmapped_never_covered", {}, {}, ["analytics", "unknown"], False),
("partial_pipeline_coverage_not_covered", {}, {}, ["analytics", "sessionreplay"], False),
(
"full_pipeline_coverage",
diff --git a/posthog/models/event_ingestion_restriction_config.py b/posthog/models/event_ingestion_restriction_config.py
index c6957f37a84b..867963144311 100644
--- a/posthog/models/event_ingestion_restriction_config.py
+++ b/posthog/models/event_ingestion_restriction_config.py
@@ -17,6 +17,7 @@ INGESTION_PIPELINES = [
{"value": "session_recordings", "label": "Session Recordings Pipeline"},
{"value": "errortracking", "label": "Error Tracking Pipeline"},
{"value": "clientwarnings", "label": "Client Warnings Pipeline"},
+ {"value": "heatmaps", "label": "Heatmaps Pipeline"},
{"value": "ai", "label": "AI Pipeline"},
]
@@ -38,6 +39,7 @@ class IngestionPipeline(models.TextChoices):
SESSION_RECORDINGS = "session_recordings"
ERRORTRACKING = "errortracking"
CLIENTWARNINGS = "clientwarnings"
+ HEATMAPS = "heatmaps"
AI = "ai"
diff --git a/posthog/models/test/test_event_ingestion_restriction_config.py b/posthog/models/test/test_event_ingestion_restriction_config.py
index 72a2432700dc..32d7fc75f747 100644
--- a/posthog/models/test/test_event_ingestion_restriction_config.py
+++ b/posthog/models/test/test_event_ingestion_restriction_config.py
@@ -2,6 +2,8 @@ import json
from posthog.test.base import BaseTest
+from django.core.exceptions import ValidationError
+
from parameterized import parameterized
from posthog.models.event_ingestion_restriction_config import (
@@ -293,19 +295,33 @@ class TestEventIngestionRestrictionConfig(BaseTest):
],
)
- def test_pipeline_fields_in_redis(self):
+ @parameterized.expand(
+ [
+ ("session_recordings", "session_recordings"),
+ ("heatmaps", "heatmaps"),
+ ]
+ )
+ def test_pipeline_fields_in_redis(self, _name, pipeline):
"""Test that pipelines field is correctly stored in Redis"""
config = EventIngestionRestrictionConfig.objects.create(
token="test_token",
restriction_type=RestrictionType.SKIP_PERSON_PROCESSING,
- pipelines=["session_recordings"],
+ pipelines=[pipeline],
)
redis_key = config.get_redis_key()
redis_data = self.redis_client.get(redis_key)
data = json.loads(redis_data if redis_data is not None else b"[]")
- self.assertEqual(data[0]["pipelines"], ["session_recordings"])
+ self.assertEqual(data[0]["pipelines"], [pipeline])
+
+ def test_unknown_pipeline_is_rejected(self):
+ with self.assertRaises(ValidationError):
+ EventIngestionRestrictionConfig.objects.create(
+ token="test_token",
+ restriction_type=RestrictionType.DROP_EVENT_FROM_INGESTION,
+ pipelines=["not_a_pipeline"],
+ )
def test_update_pipeline_fields(self):
"""Test that updating pipelines field correctly updates Redis"""
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 2b01c134f393..f276d860d0ce 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -39393,6 +39393,7 @@ export namespace Schemas {
* * `session_recordings` - Session Recordings
* * `errortracking` - Errortracking
* * `clientwarnings` - Clientwarnings
+ * * `heatmaps` - Heatmaps
* * `ai` - Ai
*/
export type IngestionPipelineEnum = typeof IngestionPipelineEnum[keyof typeof IngestionPipelineEnum];
@@ -39403,6 +39404,7 @@ export namespace Schemas {
SessionRecordings: 'session_recordings',
Errortracking: 'errortracking',
Clientwarnings: 'clientwarnings',
+ Heatmaps: 'heatmaps',
Ai: 'ai',
} as const;