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(experiments): keep error-loop sessions off watch card highlights (#83406)

Marcel Poelkere87e55ae6331
diff --git a/frontend/src/lib/utils/eventUsageLogic.ts b/frontend/src/lib/utils/eventUsageLogic.ts
index 85e9e3f586db..91e8414eb5aa 100644
--- a/frontend/src/lib/utils/eventUsageLogic.ts
+++ b/frontend/src/lib/utils/eventUsageLogic.ts
@@ -159,6 +159,8 @@ export interface ExperimentWatchShelfContext {
friction_cards: number
variant_only_cards: number
metric_cards: number
+ /** Cards removed for restating another card's recordings; what the dedupe threshold is tuned from. */
+ dropped_duplicate_cards: number
}
/**
diff --git a/frontend/src/scenes/experiments/ExperimentView/experimentReplayTabLogic.test.ts b/frontend/src/scenes/experiments/ExperimentView/experimentReplayTabLogic.test.ts
index 48645881f3aa..440e3ed1a417 100644
--- a/frontend/src/scenes/experiments/ExperimentView/experimentReplayTabLogic.test.ts
+++ b/frontend/src/scenes/experiments/ExperimentView/experimentReplayTabLogic.test.ts
@@ -71,6 +71,7 @@ const DELTA_RESPONSE = {
events_truncated: false,
min_arm_persons: 50,
max_card_recordings: 20,
+ dropped_duplicate_cards: 0,
too_early: false,
}
diff --git a/frontend/src/scenes/experiments/ExperimentView/experimentReplayTabLogic.ts b/frontend/src/scenes/experiments/ExperimentView/experimentReplayTabLogic.ts
index e5f100799b36..838d798076fa 100644
--- a/frontend/src/scenes/experiments/ExperimentView/experimentReplayTabLogic.ts
+++ b/frontend/src/scenes/experiments/ExperimentView/experimentReplayTabLogic.ts
@@ -938,6 +938,7 @@ export const experimentReplayTabLogic = kea<experimentReplayTabLogicType>([
friction_cards: kindCount(ExperimentWatchCardKindEnumApi.Friction),
variant_only_cards: kindCount(ExperimentWatchCardKindEnumApi.VariantOnly),
metric_cards: kindCount(ExperimentWatchCardKindEnumApi.Metric),
+ dropped_duplicate_cards: sessionEventDeltas.dropped_duplicate_cards,
})
},
selectWatchCard: ({ card }) => {
diff --git a/products/experiments/backend/presentation/serializers.py b/products/experiments/backend/presentation/serializers.py
index 11fecf0b57c0..99e0905cceeb 100644
--- a/products/experiments/backend/presentation/serializers.py
+++ b/products/experiments/backend/presentation/serializers.py
@@ -2085,6 +2085,12 @@ class ExperimentSessionEventDeltaResponseSerializer(serializers.Serializer):
"so report it as 'at least this many' rather than as a count."
)
)
+ dropped_duplicate_cards = serializers.IntegerField(
+ help_text=(
+ "How many cards were removed because their recordings were already another card's on the same "
+ "shelf. Nothing was lost: the recordings are all reachable through the cards that stayed."
+ )
+ )
too_early = serializers.BooleanField(
help_text=(
"True when fewer than two variants have min_arm_persons exposed people, so no comparison exists and "
diff --git a/products/experiments/backend/session_event_deltas.py b/products/experiments/backend/session_event_deltas.py
index d531522ac0a4..6f18d66dfa31 100644
--- a/products/experiments/backend/session_event_deltas.py
+++ b/products/experiments/backend/session_event_deltas.py
@@ -162,6 +162,13 @@ DUPLICATE_CARD_OVERLAP = 0.8
# measures how long the session is rather than what it shows, and raw totals hand every card the
# same longest session. Only the ranking is bounded; the reason still prints the true count.
HIGHLIGHT_COUNT_DAMPING = 3
+# A session at or past this many of one friction signal, without a single rage click, is a client
+# stuck in an error loop or automation, not a person to watch, so it is never offered as a
+# highlight. It stays on its cards' playlists. A rage click exempts the session because it is the
+# one signal only a person produces: as of August 2026, production sessions past this bound with a
+# rage click show a median 23 active minutes across several distinct errors (a person suffering
+# through them), while those without show under a minute of activity and one error repeating.
+MAX_HIGHLIGHT_SIGNAL_COUNT = 100
# Recording candidates fetched per card before replay existence is checked, and how many survive
# onto the card. The margin absorbs sessions that were never recorded without a second round trip.
MAX_CARD_RECORDING_CANDIDATES = 60
@@ -395,6 +402,11 @@ class ExperimentWatchResult:
# into the ceiling. A count sitting on the cap is a floor, and printed as a plain number beside
# an event name it reads as a measurement of that event.
max_card_recordings: int
+ # How many cards the duplicate-recording-set rule removed from this viewer's shelf, reported
+ # so the shelf-loaded telemetry can say how often DUPLICATE_CARD_OVERLAP fires on real shelves
+ # before anyone tunes it. Set in `finalize_watch_cards` rather than here, because the shelf is
+ # cached across viewers and the duplicate cut runs on the shelf a viewer actually gets.
+ dropped_duplicate_cards: int
too_early: bool
@@ -415,6 +427,10 @@ def finalize_watch_cards(result: ExperimentWatchResult, accessible_session_ids:
recorded, since either way there is nothing to watch behind it. `recording_count` is recomputed
so it keeps meaning "recordings this card can show you".
+ The cut is silent, as it is on the bucket and batch-context reads: the response must not say
+ whether this filter removed anything, because that would tell the viewer recordings denied to
+ them ran through this experiment, which is the fact the object-level control withholds.
+
The duplicate cut and the highlight assignment run here rather than in the scan because both
are statements about the shelf a viewer sees. Cutting a duplicate against recordings this
viewer can't open would drop a card whose remaining recordings they can, and could leave two
@@ -430,7 +446,8 @@ def finalize_watch_cards(result: ExperimentWatchResult, accessible_session_ids:
cards.append(
replace(card, recording_count=len(session_ids), session_ids=session_ids, highlights=highlights)
)
- return replace(result, cards=_assign_highlights(_drop_duplicate_recording_sets(cards)))
+ deduped = _drop_duplicate_recording_sets(cards)
+ return replace(result, cards=_assign_highlights(deduped), dropped_duplicate_cards=len(cards) - len(deduped))
def get_experiment_session_event_deltas(team: Team, user: User, experiment: Experiment) -> ExperimentWatchResult:
@@ -598,6 +615,8 @@ def get_experiment_session_event_deltas(team: Team, user: User, experiment: Expe
events_truncated=scan.events_truncated,
min_arm_persons=MIN_ARM_PERSONS,
max_card_recordings=MAX_CARD_RECORDINGS,
+ # Settled per viewer in `finalize_watch_cards`; the cached shelf carries a placeholder.
+ dropped_duplicate_cards=0,
too_early=too_early,
)
safe_cache_set(cache_key, result, timeout=DELTA_CACHE_TTL)
@@ -741,7 +760,7 @@ def _cache_key(
# applied on read. One viewer's scan then serves every viewer whose restrictions match, which
# on the heaviest read in this family is the difference between paying it once per team per
# TTL and once per viewer.
- return f"experiment_session_event_deltas_v7_{team.pk}_{experiment.pk}_{digest}"
+ return f"experiment_session_event_deltas_v8_{team.pk}_{experiment.pk}_{digest}"
def _metric_event_names(metrics: list[MetricEventSource]) -> set[str]:
@@ -1580,6 +1599,14 @@ def _rank_highlights(
for event, singular in HIGHLIGHT_SIGNALS
if recording.signals[event] > 0
]
+ # A broken session tops every card it backs: damping caps what its counts are worth, but it
+ # still wins ties on carrying every kind of signal, so it is kept off the highlights
+ # entirely rather than merely held back. A rage click vouches for the session: loops don't
+ # rage click, and a person grinding through this much friction is worth featuring.
+ if recording.signals["$rageclick"] == 0 and any(
+ count >= MAX_HIGHLIGHT_SIGNAL_COUNT for count, _singular in present
+ ):
+ continue
# Every signal the session carries, in the shelf's own priority order rather than by size,
# so two recordings' reasons stay comparable at a glance.
phrases = [pluralize(count, singular) for count, singular in present]
diff --git a/products/experiments/backend/test/test_session_event_deltas_api.py b/products/experiments/backend/test/test_session_event_deltas_api.py
index 575046811dc3..44631c2bd0d5 100644
--- a/products/experiments/backend/test/test_session_event_deltas_api.py
+++ b/products/experiments/backend/test/test_session_event_deltas_api.py
@@ -196,6 +196,49 @@ class TestExperimentSessionEventDeltas(ClickhouseTestMixin, APILicensedTest):
def _cards(self, data: dict[str, Any], kind: Optional[str] = None) -> list[dict[str, Any]]:
return [card for card in data["cards"] if kind is None or card["kind"] == kind]
+ @patch.object(session_event_deltas, "MIN_ARM_PERSONS", 20)
+ def test_arms_that_behave_the_same_earn_no_finding_cards(self) -> None:
+ # The A/A case, under the real evidence floors: arms doing the same things with a person
+ # or two of sampling jitter must leave every finding shelf empty. This is the tripwire for
+ # threshold work — a change that lets jitter card fails here, on whichever shelf it leaks
+ # onto, before it ships noise as findings.
+ experiment = self._create_experiment(metrics=[PURCHASE_METRIC])
+ self._arm(
+ "control",
+ [["pricing_faq", "purchase"]] * 10
+ + [["pricing_faq"]] * 8
+ + [["checkout_start", "$exception"]] * 5
+ + [["$rageclick"]] * 3
+ + [[]] * 4,
+ )
+ self._arm(
+ "test",
+ [["pricing_faq", "purchase"]] * 11
+ + [["pricing_faq"]] * 7
+ + [["checkout_start", "$exception"]] * 6
+ + [["$rageclick"]] * 2
+ + [[]] * 4,
+ )
+ flush_persons_and_events()
+
+ data = self._post_deltas(experiment).json()
+
+ assert self._cards(data, "behavior") == []
+ assert self._cards(data, "friction") == []
+ assert self._cards(data, "variant_only") == []
+ # Shortcuts survive an empty shelf: they offer to show a metric event happening rather
+ # than claiming a difference, so "nothing to find" must not take them down too.
+ assert [(card["event"], card["variant"]) for card in self._cards(data, "metric")] == [
+ ("purchase", "control"),
+ ("purchase", "test"),
+ ]
+ # Not the too-early empty state: both arms are populated, there is genuinely nothing to
+ # find, and the frontend words those two cases differently.
+ assert data["too_early"] is False
+ assert [(arm["key"], arm["persons"]) for arm in data["arms"]] == [("control", 30), ("test", 30)]
+ # A clean shelf reports a clean caveat: no card was deduped away.
+ assert data["dropped_duplicate_cards"] == 0
+
@patch.object(session_event_deltas, "MIN_ARM_PERSONS", 20)
def test_cards_rank_by_separation_and_leave_out_what_the_arms_share(self) -> None:
experiment = self._create_experiment(metrics=[PURCHASE_METRIC])
@@ -478,6 +521,9 @@ class TestExperimentSessionEventDeltas(ClickhouseTestMixin, APILicensedTest):
("purchase", "control"),
("purchase", "test"),
]
+ # The drop is counted, so the telemetry the threshold is tuned from can see how often the
+ # rule fires on real shelves.
+ assert data["dropped_duplicate_cards"] == 1
@rank_anything
def test_a_cards_highlights_name_which_of_its_recordings_to_open_first(self) -> None:
@@ -535,6 +581,27 @@ class TestExperimentSessionEventDeltas(ClickhouseTestMixin, APILicensedTest):
(noisy, "1 rage click, 6 errors, 1 dead click, did this 2 times"),
]
+ @rank_anything
+ def test_a_broken_session_is_not_offered_as_a_highlight(self) -> None:
+ experiment = self._create_experiment(metrics=[PURCHASE_METRIC])
+ self._arm("control", [[]] * 2)
+ # A hundred errors without a single rage click is a client stuck in a loop, not a person
+ # hitting a hundred problems. Damping keeps it from winning on volume, but it still wins
+ # ties on signal kinds, so without an exclusion it fronts every card its session backs.
+ broken = self._session(variants=["test"], events=["pricing_faq", "pricing_faq"] + ["$exception"] * 100)
+ # The same error volume with a rage click is a person suffering through it, which is what a
+ # friction highlight exists to show: the rage click is the act no loop performs.
+ frustrated = self._session(variants=["test"], events=["pricing_faq", "$rageclick"] + ["$exception"] * 100)
+ on_point = self._session(variants=["test"], events=["pricing_faq", "$rageclick"])
+ flush_persons_and_events()
+
+ data = self._post_deltas(experiment).json()
+
+ card = next(card for card in self._cards(data, "behavior") if card["event"] == "pricing_faq")
+ assert [highlight["session_id"] for highlight in card["highlights"]] == [frustrated, on_point]
+ # Excluded from the highlights only: the recording still belongs to the card's playlist.
+ assert broken in card["session_ids"]
+
@rank_anything
def test_the_same_recording_does_not_lead_every_card(self) -> None:
experiment = self._create_experiment(metrics=[PURCHASE_METRIC])
@@ -791,6 +858,9 @@ class TestExperimentSessionEventDeltas(ClickhouseTestMixin, APILicensedTest):
card = next(card for card in self._cards(data, "behavior") if card["event"] == "pricing_faq")
assert card["session_ids"] == [allowed]
assert card["recording_count"] == 1
+ # The cut leaves no trace: acknowledging it would tell the viewer that recordings denied
+ # to them ran through this experiment.
+ assert "recordings_excluded_by_access" not in data
@rank_anything
def test_a_card_the_viewer_can_still_watch_survives_its_duplicate_being_cut(self) -> None:
diff --git a/products/experiments/frontend/generated/api.schemas.ts b/products/experiments/frontend/generated/api.schemas.ts
index 17b4272e6073..ec5f6cd9a108 100644
--- a/products/experiments/frontend/generated/api.schemas.ts
+++ b/products/experiments/frontend/generated/api.schemas.ts
@@ -2396,6 +2396,8 @@ export interface ExperimentSessionEventDeltaResponseApi {
min_arm_persons: number
/** The most recordings one card can carry. A card whose recording_count equals this hit the ceiling, so report it as 'at least this many' rather than as a count. */
max_card_recordings: number
+ /** How many cards were removed because their recordings were already another card's on the same shelf. Nothing was lost: the recordings are all reachable through the cards that stayed. */
+ dropped_duplicate_cards: number
/** True when fewer than two variants have min_arm_persons exposed people, so no comparison exists and cards is empty. Say 'too early to compare' and show the arms' counts; an empty shelf presented without this would read as 'the variants behaved identically'. */
too_early: boolean
}
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index cf715962b29d..dbedd187968d 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -32201,6 +32201,8 @@ export namespace Schemas {
min_arm_persons: number;
/** The most recordings one card can carry. A card whose recording_count equals this hit the ceiling, so report it as 'at least this many' rather than as a count. */
max_card_recordings: number;
+ /** How many cards were removed because their recordings were already another card's on the same shelf. Nothing was lost: the recordings are all reachable through the cards that stayed. */
+ dropped_duplicate_cards: number;
/** True when fewer than two variants have min_arm_persons exposed people, so no comparison exists and cards is empty. Say 'too early to compare' and show the arms' counts; an empty shelf presented without this would read as 'the variants behaved identically'. */
too_early: boolean;
}