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(replay-vision): collect what to watch ranking telemetry and add not useful (#118064)

Tue Haulund70413b4a3f80
diff --git a/.semgrep/rules/security/idor-team-scoped-models.yaml b/.semgrep/rules/security/idor-team-scoped-models.yaml
index ca41629ef73d..fc2a66d7562d 100644
--- a/.semgrep/rules/security/idor-team-scoped-models.yaml
+++ b/.semgrep/rules/security/idor-team-scoped-models.yaml
@@ -344,6 +344,7 @@ rules:
|QuickFilter
|QuickFilterContext
|ReplayObservation
+ |ReplayObservationFeedDismissal
|ReplayObservationLabel
|ReplayObservationMedia
|ReplayObservationRequest
@@ -805,6 +806,7 @@ rules:
|QuickFilter
|QuickFilterContext
|ReplayObservation
+ |ReplayObservationFeedDismissal
|ReplayObservationLabel
|ReplayObservationMedia
|ReplayObservationRequest
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index b16bb9ee1599..8a3bd66bf6bd 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -4553,9 +4553,9 @@ snapshots:
lemon-ui-icons1--shelf-a--light:
hash: v1.k794b7964.5ac03ce003c333375b716362f03c7692bca611adffe6be6ef9be3b007e3b2595.YDFXw5WBfM-Nw2sTc3wVkST_yw3Ov7ZZshM8qFYuf-M
lemon-ui-icons1--shelf-b--dark:
- hash: v1.k794b7964.c7547d871ddbf17a4f99d32c466878c8757d27cf0f22ec6bc8e43ef87c399182.L89ECBrJOTmw8Exi6IL6Hr8id1ix59nzKurtIQ7KHRw
+ hash: v1.k794b7964.442b513ecaaba24065426e17cea6f5b3e549b46f0a4adec3431c34bda36a6d32.nxKhi1ZQ3TZmrOBs-kMq4Zj4BReQjniC9EMHj9aPJZs
lemon-ui-icons1--shelf-b--light:
- hash: v1.k794b7964.8b727af713dae6ff6e31145bdc8366e139ee55c4d714edb1116a3dce8a76c320.RRDoV57noSzwfHYAdS7_PREQ_Vq_mj8htal3TSvLZ1E
+ hash: v1.k794b7964.9aa09f6d478d55cbde5837aa1b603508ae5788d88505310f3ea76bed1c54334d.2j1WtJgL-T1h4nY_3IbzUSQnPL4T_ycdfHfF_mjgDII
lemon-ui-icons1--shelf-c--dark:
hash: v1.k794b7964.fa38008cc14dfc8829a27ae05a420e0330024a81d22e8cf6c0955c0cd720d06d.0v0ZiDwGLHBsy_I3t3yYKrc-3iWi75dosJJEVP3dldo
lemon-ui-icons1--shelf-c--light:
@@ -14047,21 +14047,21 @@ snapshots:
scenes-app-replay-vision--experiment-variants-waiting-for-observations--light:
hash: v1.k794b7964.a1555dab4c0006028e8c240451c56c6aed5e31c8a8e68c893e3d6a07b562bba6.VYeYPsjZ_p0Rt4cbZzF7lbxjxurMjLXff9kJRsy49gU
scenes-app-replay-vision--home-watch-feed--dark:
- hash: v1.k794b7964.1781f0b3640482554b64106cfa5d2151143e1301d329a78bd6d053ec284cd50a.7JkhgjlkBl6Dl9j6uI2_ZHR3Uq9xT5qWrCaBBHJKLQo
+ hash: v1.k794b7964.1bc04b4cde8e64b1d5cdda96a05a9d3d68d9cbae39769050f0f387e2901c47ab.3FG3l4i4q6N9cWaR_NPUjnHGlQjpssZxvo931grrsHg
scenes-app-replay-vision--home-watch-feed--light:
- hash: v1.k794b7964.7119fa5e588c2763bbeee5e5bdb76b621f8d8609291dba0d9c065e8860a3ee6d.TDf10qFfSYUJohljt-AGKzhlPBv6e8q-fXq30frva5c
+ hash: v1.k794b7964.7ed4a80840e067b94ff620d3ef55afd606053ae800e4ac1c3787c80f8f8cdc53.R9_xhoaxtKXNftQZpmRSYuk-lSbjy3T74WZxh-Y3m0A
scenes-app-replay-vision--home-watch-feed-empty--dark:
hash: v1.k794b7964.326052a0a0811e06149d4ce16661c1079dd4c3ea3989b9fc380f6ea6ad332964.fbb9IzE045MNm7rezEvrawyQy0D8MHwTfxwNVlpKKMI
scenes-app-replay-vision--home-watch-feed-empty--light:
hash: v1.k794b7964.12fbcb5782edcde470bc066c7679270b5dad44ce31fc70197a61d2bf259eabc5.ODXEus08mjP34GTt0Ji95tYjEz-wxAkK_T1dpDdCHK8
scenes-app-replay-vision--home-watch-feed-jev-arm--dark:
- hash: v1.k794b7964.62f35a459a0eeb91322af2777799392cb516ef90c4e27b53e9747fe092507e23.wEoRu_mVlBExqdXk6mhTEvm56V33CPJBhAqfGfXLQi4
+ hash: v1.k794b7964.58d069d6b41d360ebd150a40595171799dccbdd444a1ca7b7b6df3ee74eef294.VPOJP280lRjX5bFhsDcrHpjq_rg89Ubkn9Yi-jePeW4
scenes-app-replay-vision--home-watch-feed-jev-arm--light:
- hash: v1.k794b7964.fa346ffdf211a49a261d381d5837163eb6d1af35cba25ae22ca29b43bbfc6078.WYM_DL1M4g_78GRE16pWL9LP2Dzf3fdOB6HVrwDjGV0
+ hash: v1.k794b7964.0a95ee1663618b9c42010e4f3b0d18eb2393923705b591a08855ec27c452f18a.GLxpWw94CW8eIriaFhzKpmsRLM_FcaciW6i_Lrj0pwc
scenes-app-replay-vision--home-watch-feed-only-newest--dark:
- hash: v1.k794b7964.25c40d1f0700190ce2401de7d59db7305084f379bf6a2d3947e9e852c583c819.APZ4PoLYFBmtgKX2EIcqHVpAz9euVvIk40vd3LHRlGg
+ hash: v1.k794b7964.533cd0046a467efdde98e7fafbca443063e9e8c0d121ccbdd78498752c82b1c3.nqFHvXS6R_txqJQVyBN91v4Qv84wgsRGkxna7cLlygE
scenes-app-replay-vision--home-watch-feed-only-newest--light:
- hash: v1.k794b7964.c4ca67c86a3a5efc11c123b656e82878052f4e2c348237403a975cc2649524fd.PX6UtkIMGc0gr7LHmrCUgwPPP2Xo0J2hJDOyV7RlOl8
+ hash: v1.k794b7964.a343dad6782b2f5b266fb43fda4edc0168409d77ec79d434888f0d5cff86c810.uUwWWBB-GUQmXWcBJxyVispCUjS4qjG5vsnjssoYiU0
scenes-app-replay-vision--monitor-observations--dark:
hash: v1.k794b7964.9ec7ef6c17074e9547647fe71aa2613100208fa0c7ba87a3d97897b4f183a5c8.-UKB-w06mWDRH2yNgzIBhn3Qhn2MYlFTNXjhMce1hh4
scenes-app-replay-vision--monitor-observations--light:
diff --git a/frontend/src/lib/lemon-ui/icons/icons.tsx b/frontend/src/lib/lemon-ui/icons/icons.tsx
index 82b45d1dc19f..bff7fdb9d205 100644
--- a/frontend/src/lib/lemon-ui/icons/icons.tsx
+++ b/frontend/src/lib/lemon-ui/icons/icons.tsx
@@ -890,6 +890,18 @@ export function IconCancel(props: LemonIconProps): JSX.Element {
)
}
+/** Material Design Block icon. */
+export function IconBlock(props: LemonIconProps): JSX.Element {
+ return (
+ <LemonIconBase {...props}>
+ <path
+ d="m12 2c-5.52 0-10 4.48-10 10s4.48 10 10 10 10-4.48 10-10-4.48-10-10-10zm-8 10c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69l-11.21 11.21c-1.06-1.35-1.69-3.05-1.69-4.9zm8 8c-1.85 0-3.55-.63-4.9-1.69l11.21-11.21c1.06 1.35 1.69 3.05 1.69 4.9 0 4.42-3.58 8-8 8z"
+ fill="currentColor"
+ />
+ </LemonIconBase>
+ )
+}
+
/** Material Design Workspace Premium icon. */
export function IconPremium(props: LemonIconProps): JSX.Element {
return (
diff --git a/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.test.ts b/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.test.ts
index 0b00d31d782b..9a7509bbe1d3 100644
--- a/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.test.ts
+++ b/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.test.ts
@@ -1618,6 +1618,7 @@ describe('sessionRecordingPlayerLogic', () => {
expect(mockCapture).toHaveBeenCalledWith(
'recording viewed summary',
expect.objectContaining({
+ recording_id: '2',
viewed_time_ms: expect.any(Number),
play_time_ms: expect.any(Number),
buffer_time_ms: expect.any(Number),
diff --git a/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts b/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts
index b842b2847fc5..725195c8898e 100644
--- a/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts
+++ b/frontend/src/scenes/session-recordings/player/sessionRecordingPlayerLogic.ts
@@ -137,6 +137,7 @@ export interface PlayerTimeTracking {
}
export interface RecordingViewedSummaryAnalytics {
+ recording_id?: string
// how long was the player session mounted for
viewed_time_ms?: number
// how long was the video playing for
@@ -4010,6 +4011,7 @@ export const sessionRecordingPlayerLogic = kea<sessionRecordingPlayerLogicType>(
const playTimeMs = values.playingTimeTracking.watchTime || 0
const summaryAnalytics: RecordingViewedSummaryAnalytics = {
+ recording_id: props.sessionRecordingId,
viewed_time_ms: cache.openTime !== undefined ? performance.now() - cache.openTime : undefined,
play_time_ms: playTimeMs,
buffer_time_ms: values.playingTimeTracking.bufferTime || 0,
diff --git a/products/replay_vision/backend/api/observations.py b/products/replay_vision/backend/api/observations.py
index b54a8c5e86e2..60ab5fe4b495 100644
--- a/products/replay_vision/backend/api/observations.py
+++ b/products/replay_vision/backend/api/observations.py
@@ -60,6 +60,10 @@ from products.replay_vision.backend.models.replay_observation import (
hydrate_for_serialization,
jsonb_typeof,
)
+from products.replay_vision.backend.models.replay_observation_feed_dismissal import (
+ FeedDismissalReason,
+ ReplayObservationFeedDismissal,
+)
from products.replay_vision.backend.models.replay_observation_label import ReplayObservationLabel
from products.replay_vision.backend.models.replay_observation_media import ReplayObservationMedia
from products.replay_vision.backend.models.replay_observation_view import ReplayObservationView
@@ -196,6 +200,18 @@ class ReplayObservationLabelSerializer(serializers.Serializer):
)
+class ObservationFeedDismissalSerializer(serializers.Serializer):
+ """Why the calling user marked an observation not useful in What to watch."""
+
+ reason = serializers.ChoiceField(
+ choices=FeedDismissalReason.choices,
+ required=False,
+ allow_null=True,
+ default=None,
+ help_text="Optional reason the observation was not useful. Omit or send null when the user gave none.",
+ )
+
+
class ReplayObservationMediaSerializer(serializers.Serializer):
"""One frame illustrating an observation."""
@@ -1200,6 +1216,46 @@ class ReplayObservationViewSet(
)
return Response(status=status.HTTP_204_NO_CONTENT)
+ @extend_schema(
+ methods=["POST"],
+ request=ObservationFeedDismissalSerializer,
+ responses={204: None},
+ description=(
+ "Mark this observation not useful for the calling user, with an optional reason. What to watch stops "
+ "showing it to that user. Sending it again replaces the reason."
+ ),
+ )
+ @extend_schema(
+ methods=["DELETE"],
+ request=None,
+ responses={204: None},
+ description="Undo the calling user's not-useful mark, so What to watch can show the observation again.",
+ )
+ @action(
+ detail=True,
+ methods=["post", "delete"],
+ url_path="feed_dismissal",
+ # Per-user state, like `viewed`, so read scope is enough.
+ required_scopes=["replay_scanner:read", "session_recording:read"],
+ )
+ def feed_dismissal(self, request: Request, **kwargs: Any) -> Response:
+ observation = self.get_object()
+ user = cast(User, request.user)
+ if request.method == "DELETE":
+ ReplayObservationFeedDismissal.objects.filter(
+ team_id=observation.team_id, observation=observation, user=user
+ ).delete()
+ return Response(status=status.HTTP_204_NO_CONTENT)
+ input_serializer = ObservationFeedDismissalSerializer(data=request.data)
+ input_serializer.is_valid(raise_exception=True)
+ ReplayObservationFeedDismissal.objects.update_or_create(
+ team_id=observation.team_id,
+ observation=observation,
+ user=user,
+ defaults={"reason": input_serializer.validated_data["reason"]},
+ )
+ return Response(status=status.HTTP_204_NO_CONTENT)
+
@extend_schema(
request=None,
parameters=[ObservationThumbnailQuerySerializer],
diff --git a/products/replay_vision/backend/api/scanners.py b/products/replay_vision/backend/api/scanners.py
index 8c5dd9385401..1e190e4098fc 100644
--- a/products/replay_vision/backend/api/scanners.py
+++ b/products/replay_vision/backend/api/scanners.py
@@ -110,6 +110,7 @@ from products.replay_vision.backend.models.replay_observation import (
ReplayObservation,
hydrate_for_serialization,
)
+from products.replay_vision.backend.models.replay_observation_feed_dismissal import ReplayObservationFeedDismissal
from products.replay_vision.backend.models.replay_observation_view import ReplayObservationView
from products.replay_vision.backend.models.replay_scanner import (
ReplayScanner,
@@ -2596,6 +2597,10 @@ class ReplayScannerViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixin, vi
# Row-gate on each row's snapshot experiment before ranking, so a restricted row can't take a slot.
candidates = accessible_observations(self.user_access_control, self.team_id, candidates)
viewer_id = cast(User, request.user).id
+ # Before ranking, so a row the viewer marked not useful neither takes a slot nor shifts the window baselines.
+ candidates = candidates.exclude(
+ Exists(ReplayObservationFeedDismissal.objects.filter(observation_id=OuterRef("id"), user_id=viewer_id))
+ )
viewed = Exists(ReplayObservationView.objects.filter(observation_id=OuterRef("id"), user_id=viewer_id))
candidate_rows = list(
candidates.annotate(
diff --git a/products/replay_vision/backend/migrations/0125_replayobservationfeeddismissal.py b/products/replay_vision/backend/migrations/0125_replayobservationfeeddismissal.py
new file mode 100644
index 000000000000..62c4ee2ea58f
--- /dev/null
+++ b/products/replay_vision/backend/migrations/0125_replayobservationfeeddismissal.py
@@ -0,0 +1,82 @@
+# Generated by Django 5.2.18 on 2026-10-15 19:07
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.uuidt
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("posthog", "1397_uploaded_media_dimensions_and_archive"),
+ ("replay_vision", "0124_replayscanner_free_only"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="ReplayObservationFeedDismissal",
+ fields=[
+ (
+ "id",
+ models.UUIDField(
+ default=posthog.uuidt.uuid7,
+ editable=False,
+ primary_key=True,
+ serialize=False,
+ ),
+ ),
+ (
+ "reason",
+ models.CharField(
+ blank=True,
+ choices=[
+ ("not_a_real_problem", "Not a real problem"),
+ ("already_known", "Already known"),
+ ("not_my_area", "Not my area"),
+ ("other", "Other"),
+ ],
+ max_length=32,
+ null=True,
+ ),
+ ),
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "observation",
+ models.ForeignKey(
+ db_index=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="feed_dismissals",
+ to="replay_vision.replayobservation",
+ ),
+ ),
+ (
+ "team",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ (
+ "user",
+ models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ],
+ options={
+ "constraints": [
+ models.UniqueConstraint(
+ fields=("observation", "user"),
+ name="unique_replay_observation_feed_dismissal_per_user",
+ )
+ ],
+ },
+ ),
+ ]
diff --git a/products/replay_vision/backend/migrations/max_migration.txt b/products/replay_vision/backend/migrations/max_migration.txt
index 3f448009d002..094e746900bc 100644
--- a/products/replay_vision/backend/migrations/max_migration.txt
+++ b/products/replay_vision/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0124_replayscanner_free_only
+0125_replayobservationfeeddismissal
diff --git a/products/replay_vision/backend/models/__init__.py b/products/replay_vision/backend/models/__init__.py
index c15c5d99fda3..ed4e1fb2e961 100644
--- a/products/replay_vision/backend/models/__init__.py
+++ b/products/replay_vision/backend/models/__init__.py
@@ -1,4 +1,5 @@
from products.replay_vision.backend.models.replay_observation import ReplayObservation
+from products.replay_vision.backend.models.replay_observation_feed_dismissal import ReplayObservationFeedDismissal
from products.replay_vision.backend.models.replay_observation_label import ReplayObservationLabel
from products.replay_vision.backend.models.replay_observation_media import ReplayObservationMedia
from products.replay_vision.backend.models.replay_observation_request import ReplayObservationRequest
@@ -17,6 +18,7 @@ from products.replay_vision.backend.models.vision_alert import (
__all__ = [
"ReplayObservation",
+ "ReplayObservationFeedDismissal",
"ReplayObservationLabel",
"ReplayObservationMedia",
"ReplayObservationRequest",
diff --git a/products/replay_vision/backend/models/replay_observation_feed_dismissal.py b/products/replay_vision/backend/models/replay_observation_feed_dismissal.py
new file mode 100644
index 000000000000..6e5462e903aa
--- /dev/null
+++ b/products/replay_vision/backend/models/replay_observation_feed_dismissal.py
@@ -0,0 +1,31 @@
+from django.db import models
+
+from posthog.models.scoping.root_mixin import TeamScopedRootMixin
+from posthog.models.utils import UUIDModel
+
+
+class FeedDismissalReason(models.TextChoices):
+ NOT_A_REAL_PROBLEM = "not_a_real_problem", "Not a real problem"
+ ALREADY_KNOWN = "already_known", "Already known"
+ NOT_MY_AREA = "not_my_area", "Not my area"
+ OTHER = "other", "Other"
+
+
+class ReplayObservationFeedDismissal(TeamScopedRootMixin, UUIDModel):
+ """One user marked this observation not useful in What to watch. Per user, like `ReplayObservationView`."""
+
+ # The unique constraint leads with observation_id, so a separate index on it would only slow writes.
+ observation = models.ForeignKey(
+ "replay_vision.ReplayObservation", on_delete=models.CASCADE, related_name="feed_dismissals", db_index=False
+ )
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+", db_constraint=False)
+ user = models.ForeignKey("posthog.User", on_delete=models.CASCADE, related_name="+", db_constraint=False)
+ reason = models.CharField(max_length=32, choices=FeedDismissalReason.choices, null=True, blank=True)
+ created_at = models.DateTimeField(auto_now_add=True)
+
+ class Meta:
+ constraints = [
+ models.UniqueConstraint(
+ fields=["observation", "user"], name="unique_replay_observation_feed_dismissal_per_user"
+ ),
+ ]
diff --git a/products/replay_vision/backend/tests/test_api.py b/products/replay_vision/backend/tests/test_api.py
index 1e60159cba47..ce4856834a8e 100644
--- a/products/replay_vision/backend/tests/test_api.py
+++ b/products/replay_vision/backend/tests/test_api.py
@@ -5620,6 +5620,27 @@ class TestWatchFeedAPI(_VisionAPITestCase):
resp = self.client.get(self.feed_url)
self.assertEqual([item["observation"]["session_id"] for item in resp.json()["results"]], ["open-sess"])
+ def test_not_useful_hides_a_row_for_that_user_only_until_undone(self) -> None:
+ scanner = self._create_scanner(name="m")
+ dismissed = self._succeeded_observation(scanner, "dismissed-sess", 1, self._monitor_result("yes"))
+ self._succeeded_observation(scanner, "kept-sess", 2, self._monitor_result("yes"))
+ dismissal_url = f"/api/projects/{self.team.id}/vision/observations/{dismissed.id}/feed_dismissal/"
+
+ def feed_sessions() -> list[str]:
+ return [item["observation"]["session_id"] for item in self.client.get(self.feed_url).json()["results"]]
+
+ self.assertEqual(self.client.post(dismissal_url, {"reason": "nonsense"}).status_code, 400)
+ self.assertEqual(self.client.post(dismissal_url, {"reason": "already_known"}).status_code, 204)
+ self.assertEqual(feed_sessions(), ["kept-sess"])
+
+ other = User.objects.create_and_join(self.organization, "[email protected]", None)
+ self.client.force_login(other)
+ self.assertEqual(sorted(feed_sessions()), ["dismissed-sess", "kept-sess"])
+
+ self.client.force_login(self.user)
+ self.assertEqual(self.client.delete(dismissal_url).status_code, 204)
+ self.assertEqual(sorted(feed_sessions()), ["dismissed-sess", "kept-sess"])
+
def test_requires_session_recording_read(self) -> None:
with patch(
"products.access_control.backend.facade.user_access_control.UserAccessControl.check_access_level_for_resource",
diff --git a/products/replay_vision/frontend/generated/api.schemas.ts b/products/replay_vision/frontend/generated/api.schemas.ts
index a49c2079b53d..6c45e500a08d 100644
--- a/products/replay_vision/frontend/generated/api.schemas.ts
+++ b/products/replay_vision/frontend/generated/api.schemas.ts
@@ -855,6 +855,34 @@ export interface CreateTaskFromObservationResponseApi {
task_id: string
}
+/**
+ * * `not_a_real_problem` - Not a real problem
+ * * `already_known` - Already known
+ * * `not_my_area` - Not my area
+ * * `other` - Other
+ */
+export type FeedDismissalReasonEnumApi = (typeof FeedDismissalReasonEnumApi)[keyof typeof FeedDismissalReasonEnumApi]
+
+export const FeedDismissalReasonEnumApi = {
+ NotARealProblem: 'not_a_real_problem',
+ AlreadyKnown: 'already_known',
+ NotMyArea: 'not_my_area',
+ Other: 'other',
+} as const
+
+/**
+ * Why the calling user marked an observation not useful in What to watch.
+ */
+export interface ObservationFeedDismissalApi {
+ /** Optional reason the observation was not useful. Omit or send null when the user gave none.
+ *
+ * * `not_a_real_problem` - Not a real problem
+ * * `already_known` - Already known
+ * * `not_my_area` - Not my area
+ * * `other` - Other */
+ reason?: FeedDismissalReasonEnumApi | null
+}
+
/**
* Async-accepted response for POST /vision/scanners/{id}/observations/{id}/retry/.
*/
diff --git a/products/replay_vision/frontend/generated/api.ts b/products/replay_vision/frontend/generated/api.ts
index 657f8988828a..b998096ee3dc 100644
--- a/products/replay_vision/frontend/generated/api.ts
+++ b/products/replay_vision/frontend/generated/api.ts
@@ -25,6 +25,7 @@ import type {
ExperimentVariantsReadoutApi,
InlineScanRequestApi,
InlineScanResponseApi,
+ ObservationFeedDismissalApi,
ObservationRequestApi,
ObservationSearchResponseApi,
ObservationSignalReportApi,
@@ -380,6 +381,45 @@ export const visionObservationsCreateTaskCreate = async (
})
}
+export const getVisionObservationsFeedDismissalCreateUrl = (projectId: string, id: string) => {
+ return `/api/projects/${projectId}/vision/observations/${id}/feed_dismissal/`
+}
+
+/**
+ * Mark this observation not useful for the calling user, with an optional reason. What to watch stops showing it to that user. Sending it again replaces the reason.
+ */
+export const visionObservationsFeedDismissalCreate = async (
+ projectId: string,
+ id: string,
+ observationFeedDismissalApi?: ObservationFeedDismissalApi,
+ options?: RequestInit
+): Promise<void> => {
+ return apiMutator<void>(getVisionObservationsFeedDismissalCreateUrl(projectId, id), {
+ ...options,
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
+ body: JSON.stringify(observationFeedDismissalApi),
+ })
+}
+
+export const getVisionObservationsFeedDismissalDestroyUrl = (projectId: string, id: string) => {
+ return `/api/projects/${projectId}/vision/observations/${id}/feed_dismissal/`
+}
+
+/**
+ * Undo the calling user's not-useful mark, so What to watch can show the observation again.
+ */
+export const visionObservationsFeedDismissalDestroy = async (
+ projectId: string,
+ id: string,
+ options?: RequestInit
+): Promise<void> => {
+ return apiMutator<void>(getVisionObservationsFeedDismissalDestroyUrl(projectId, id), {
+ ...options,
+ method: 'DELETE',
+ })
+}
+
export const getVisionObservationsLabelCreateUrl = (projectId: string, id: string) => {
return `/api/projects/${projectId}/vision/observations/${id}/label/`
}
@@ -1178,6 +1218,55 @@ export const visionScannersObservationsCreateTaskCreate = async (
)
}
+export const getVisionScannersObservationsFeedDismissalCreateUrl = (
+ projectId: string,
+ scannerId: string,
+ id: string
+) => {
+ return `/api/projects/${projectId}/vision/scanners/${scannerId}/observations/${id}/feed_dismissal/`
+}
+
+/**
+ * Mark this observation not useful for the calling user, with an optional reason. What to watch stops showing it to that user. Sending it again replaces the reason.
+ */
+export const visionScannersObservationsFeedDismissalCreate = async (
+ projectId: string,
+ scannerId: string,
+ id: string,
+ observationFeedDismissalApi?: ObservationFeedDismissalApi,
+ options?: RequestInit
+): Promise<void> => {
+ return apiMutator<void>(getVisionScannersObservationsFeedDismissalCreateUrl(projectId, scannerId, id), {
+ ...options,
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
+ body: JSON.stringify(observationFeedDismissalApi),
+ })
+}
+
+export const getVisionScannersObservationsFeedDismissalDestroyUrl = (
+ projectId: string,
+ scannerId: string,
+ id: string
+) => {
+ return `/api/projects/${projectId}/vision/scanners/${scannerId}/observations/${id}/feed_dismissal/`
+}
+
+/**
+ * Undo the calling user's not-useful mark, so What to watch can show the observation again.
+ */
+export const visionScannersObservationsFeedDismissalDestroy = async (
+ projectId: string,
+ scannerId: string,
+ id: string,
+ options?: RequestInit
+): Promise<void> => {
+ return apiMutator<void>(getVisionScannersObservationsFeedDismissalDestroyUrl(projectId, scannerId, id), {
+ ...options,
+ method: 'DELETE',
+ })
+}
+
export const getVisionScannersObservationsLabelCreateUrl = (projectId: string, scannerId: string, id: string) => {
return `/api/projects/${projectId}/vision/scanners/${scannerId}/observations/${id}/label/`
}
diff --git a/products/replay_vision/frontend/generated/api.zod.ts b/products/replay_vision/frontend/generated/api.zod.ts
index f1cab844762a..e6da789d35ef 100644
--- a/products/replay_vision/frontend/generated/api.zod.ts
+++ b/products/replay_vision/frontend/generated/api.zod.ts
@@ -445,6 +445,27 @@ export const VisionAlertsDestinationsDeleteCreateBody = /* @__PURE__ */ zod.obje
.describe('HogFunction IDs to delete as one atomic destination group.'),
})
+/**
+ * Mark this observation not useful for the calling user, with an optional reason. What to watch stops showing it to that user. Sending it again replaces the reason.
+ */
+export const VisionObservationsFeedDismissalCreateBody = /* @__PURE__ */ zod
+ .object({
+ reason: zod
+ .union([
+ zod
+ .enum(['not_a_real_problem', 'already_known', 'not_my_area', 'other'])
+ .describe(
+ '\* `not_a_real_problem` - Not a real problem\n\* `already_known` - Already known\n\* `not_my_area` - Not my area\n\* `other` - Other'
+ ),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ 'Optional reason the observation was not useful. Omit or send null when the user gave none.\n\n\* `not_a_real_problem` - Not a real problem\n\* `already_known` - Already known\n\* `not_my_area` - Not my area\n\* `other` - Other'
+ ),
+ })
+ .describe('Why the calling user marked an observation not useful in What to watch.')
+
/**
* Set or update the observation's shared label: whether the scanner scored the session correctly, plus optional feedback on what it got wrong. One label per observation, shared across the team; these labels feed prompt improvement. Requires editor access to the scanner.
*/
@@ -1008,6 +1029,27 @@ export const VisionScannersBackfillsEstimateCreateBody = /* @__PURE__ */ zod.obj
),
})
+/**
+ * Mark this observation not useful for the calling user, with an optional reason. What to watch stops showing it to that user. Sending it again replaces the reason.
+ */
+export const VisionScannersObservationsFeedDismissalCreateBody = /* @__PURE__ */ zod
+ .object({
+ reason: zod
+ .union([
+ zod
+ .enum(['not_a_real_problem', 'already_known', 'not_my_area', 'other'])
+ .describe(
+ '\* `not_a_real_problem` - Not a real problem\n\* `already_known` - Already known\n\* `not_my_area` - Not my area\n\* `other` - Other'
+ ),
+ zod.null(),
+ ])
+ .optional()
+ .describe(
+ 'Optional reason the observation was not useful. Omit or send null when the user gave none.\n\n\* `not_a_real_problem` - Not a real problem\n\* `already_known` - Already known\n\* `not_my_area` - Not my area\n\* `other` - Other'
+ ),
+ })
+ .describe('Why the calling user marked an observation not useful in What to watch.')
+
/**
* Set or update the observation's shared label: whether the scanner scored the session correctly, plus optional feedback on what it got wrong. One label per observation, shared across the team; these labels feed prompt improvement. Requires editor access to the scanner.
*/
diff --git a/products/replay_vision/frontend/observations/ObservationShareButton.tsx b/products/replay_vision/frontend/observations/ObservationShareButton.tsx
index aba9fe122eb7..fa99d300da94 100644
--- a/products/replay_vision/frontend/observations/ObservationShareButton.tsx
+++ b/products/replay_vision/frontend/observations/ObservationShareButton.tsx
@@ -28,7 +28,10 @@ function ObservationShareDialogContent(props: ObservationShareLogicProps): JSX.E
center
sideIcon={<IconCopy />}
onClick={() => {
- posthog.capture('replay_vision_observation_link_copied', { with_timestamp: includeTime })
+ posthog.capture('replay_vision_observation_link_copied', {
+ observation_id: props.observationId,
+ with_timestamp: includeTime,
+ })
void copyToClipboard(shareUrl, 'observation link').catch((e) => posthog.captureException(e))
}}
title={shareUrl}
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx
index a5604d57388f..5330af3699c3 100644
--- a/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx
@@ -1,9 +1,10 @@
-import { useActions } from 'kea'
+import { useActions, useValues } from 'kea'
import { combineUrl } from 'kea-router'
import { IconFlag } from '@posthog/icons'
import { LemonDivider, LemonTag, Link, Tooltip } from '@posthog/lemon-ui'
+import { useAutoMarkRead } from 'lib/components/NotificationsMenu/useAutoMarkRead'
import { TZLabel } from 'lib/components/TZLabel'
import posthog from 'lib/posthog-typed'
import { colonDelimitedDuration } from 'lib/utils/durations'
@@ -23,6 +24,8 @@ import { OBSERVATION_ORIGIN_PARAM, WATCH_FEED_ORIGIN } from '../../utils/breadcr
import { citedTextToPlainText } from '../../utils/citations'
import { SCANNER_TYPE_TAG_TYPE, ScannerType } from '../types'
import { watchFeedLogic } from '../watchFeedLogic'
+import { CARD_SEEN_DWELL_MS, cardProperties } from '../watchFeedTelemetry'
+import { WatchFeedDismissButton } from './WatchFeedDismissButton'
/** Reason kinds that say nothing about the session. The backend returns these only to pad a near-empty
* feed, so a feed made up entirely of them means the window turned up no findings at all. */
@@ -207,9 +210,11 @@ interface WatchFeedRowProps {
function WatchCardPerson({
observation,
person,
+ children,
}: {
observation: ReplayObservationApi
person: string | null | undefined
+ children?: React.ReactNode
}): JSX.Element {
return (
<div className="flex flex-wrap items-center gap-1 text-xs text-muted">
@@ -227,6 +232,8 @@ function WatchCardPerson({
))}
{person && <span aria-hidden>·</span>}
<TZLabel time={observation.created_at} className="shrink-0" />
+ {children && <span aria-hidden>·</span>}
+ {children}
</div>
)
}
@@ -339,6 +346,9 @@ export function watchFeedRowTitle(observation: ReplayObservationApi, reason: Wat
*/
export function WatchFeedRow({ item, position }: WatchFeedRowProps): JSX.Element {
const { observation, reason } = item
+ const { feedLoad } = useValues(watchFeedLogic)
+ const { cardSeen, dismissItem } = useActions(watchFeedLogic)
+ const rowRef = useAutoMarkRead(true, () => cardSeen(item, position), CARD_SEEN_DWELL_MS)
const result = readResult(observation)
// Fall back to the result's own scanner_type when the snapshot is absent, like watchCardHeadline.
const scannerType =
@@ -357,17 +367,14 @@ export function WatchFeedRow({ item, position }: WatchFeedRowProps): JSX.Element
const filler = FILLER_REASON_KINDS.has(reason.kind)
const captureOpened = (): void => {
posthog.capture('replay_vision_watch_clip_clicked', {
- scanner_id: observation.scanner_id,
+ ...cardProperties(feedLoad, item, position, 'feed_tab'),
scanner_type: scannerType,
- observation_id: observation.id,
- position,
- reason_kind: reason.kind,
has_key_moment: keyMomentMs !== null,
target: 'observation',
})
}
return (
- <article className="group relative flex min-w-0 gap-4" data-attr="vision-watch-feed-row">
+ <article ref={rowRef} className="group relative flex min-w-0 gap-4" data-attr="vision-watch-feed-row">
<div className="relative w-36 shrink-0 self-start overflow-hidden rounded-lg border group-hover:border-accent group-focus-within:border-accent @xl:w-80">
{!observation.viewed && <span className="absolute inset-x-0 top-0 z-20 h-1 bg-accent" aria-hidden />}
<ObservationThumbnail observation={observation} className="rounded-none border-0" />
@@ -396,7 +403,12 @@ export function WatchFeedRow({ item, position }: WatchFeedRowProps): JSX.Element
</h3>
</Link>
<WatchFeedScannerLink observation={observation} scannerName={scannerName} scannerType={scannerType} />
- <WatchCardPerson observation={observation} person={person} />
+ <WatchCardPerson observation={observation} person={person}>
+ <WatchFeedDismissButton
+ className="relative z-10 -my-1"
+ onDismiss={(dismissalReason) => dismissItem(item, position, dismissalReason)}
+ />
+ </WatchCardPerson>
{/* A short rule rather than a full-width line: rows carry no card, so a full line reads as
the border between two rows. */}
<div className="mt-1 flex flex-col gap-2" data-attr="vision-watch-feed-why">
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchFeedDismissButton.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchFeedDismissButton.tsx
new file mode 100644
index 000000000000..0caf5e4d1d9b
--- /dev/null
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchFeedDismissButton.tsx
@@ -0,0 +1,26 @@
+import { LemonButton, LemonMenu } from '@posthog/lemon-ui'
+
+import { IconBlock } from 'lib/lemon-ui/icons'
+
+import type { FeedDismissalReasonEnumApi } from '../../generated/api.schemas'
+import { feedDismissalMenuItems } from '../watchFeedDismissal'
+
+interface WatchFeedDismissButtonProps {
+ onDismiss: (reason: FeedDismissalReasonEnumApi | null) => void
+ className?: string
+}
+
+export function WatchFeedDismissButton({ onDismiss, className }: WatchFeedDismissButtonProps): JSX.Element {
+ return (
+ <LemonMenu placement="bottom-end" items={feedDismissalMenuItems(onDismiss)}>
+ <LemonButton
+ size="xsmall"
+ icon={<IconBlock />}
+ tooltip="Not useful"
+ aria-label="Not useful"
+ className={className}
+ data-attr="vision-watch-feed-dismiss"
+ />
+ </LemonMenu>
+ )
+}
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchFeedTab.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchFeedTab.tsx
index 9f8a359308f6..42c18f307e25 100644
--- a/products/replay_vision/frontend/replay_scanners/components/WatchFeedTab.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchFeedTab.tsx
@@ -46,6 +46,7 @@ export function WatchFeedTab(): JSX.Element {
const {
feedItems,
feedItemsLoading,
+ feedLoad,
feedFailed,
dateFrom,
dateTo,
@@ -183,7 +184,11 @@ export function WatchFeedTab(): JSX.Element {
)}
{items.length > 0 ? (
items.map((item, index) => (
- <WatchFeedRow key={item.observation.id} item={item} position={index} />
+ <WatchFeedRow
+ key={`${feedLoad?.feedLoadId}-${item.observation.id}`}
+ item={item}
+ position={index}
+ />
))
) : feedFailed ? null : emptyReason ? (
<WatchFeedEmptyState reason={emptyReason} />
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchPickRow.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchPickRow.tsx
index fb2a73cfcfe1..3a0dd4ed8deb 100644
--- a/products/replay_vision/frontend/replay_scanners/components/WatchPickRow.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchPickRow.tsx
@@ -2,12 +2,14 @@ import { useActions } from 'kea'
import { LemonButton } from '@posthog/lemon-ui'
+import { useAutoMarkRead } from 'lib/components/NotificationsMenu/useAutoMarkRead'
import { TZLabel } from 'lib/components/TZLabel'
import { cn } from 'lib/utils/css-classes'
import { ObservationThumbnail } from '../../components/ObservationThumbnail'
import type { WatchFeedItemApi } from '../../generated/api.schemas'
import { citedTextToPlainText } from '../../utils/citations'
+import { CARD_SEEN_DWELL_MS } from '../watchFeedTelemetry'
import { watchPicksLogic } from '../watchPicksLogic'
import { watchPickSummary } from '../watchPickSummary'
import { watchFeedRowWhy } from './WatchFeedCard'
@@ -22,12 +24,14 @@ interface WatchPickRowProps {
}
export function WatchPickRow({ item, position, isActive, rank }: WatchPickRowProps): JSX.Element {
- const { watchPick } = useActions(watchPicksLogic)
+ const { watchPick, cardSeen } = useActions(watchPicksLogic)
const { observation, reason } = item
const { title, scannerName } = watchPickSummary(observation)
+ const rowRef = useAutoMarkRead(true, () => cardSeen(item, position), CARD_SEEN_DWELL_MS)
return (
<LemonButton
+ ref={rowRef}
fullWidth
size="small"
active={isActive}
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchPicksList.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchPicksList.tsx
index a1369c7ceb48..6e20c4ef3f73 100644
--- a/products/replay_vision/frontend/replay_scanners/components/WatchPicksList.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchPicksList.tsx
@@ -14,7 +14,7 @@ const LIST_TOP_COUNT = 5
export function WatchPicksList(): JSX.Element {
const picksLogic = useMountedLogic(watchPicksLogic)
- const { picks, picksLoading, picksFailed, activeSessionId } = useValues(picksLogic)
+ const { picks, picksLoad, picksLoading, picksFailed, activeSessionId } = useValues(picksLogic)
const { loadPicks } = useActions(picksLogic)
const { startedScanner, burstDone, burstStalled } = useValues(watchPicksStarterLogic(picksLogic.props))
const burstActive = startedScanner !== null && (!burstDone || burstStalled)
@@ -64,7 +64,7 @@ export function WatchPicksList(): JSX.Element {
<div className="flex flex-col gap-0.5 p-1">
{picks.map((item, index) => (
<WatchPickRow
- key={item.observation.id}
+ key={`${picksLoad?.feedLoadId}-${item.observation.id}`}
item={item}
position={index}
rank={index < LIST_TOP_COUNT ? index + 1 : undefined}
diff --git a/products/replay_vision/frontend/replay_scanners/watchFeedDismissal.ts b/products/replay_vision/frontend/replay_scanners/watchFeedDismissal.ts
new file mode 100644
index 000000000000..8ad5b8bbfb95
--- /dev/null
+++ b/products/replay_vision/frontend/replay_scanners/watchFeedDismissal.ts
@@ -0,0 +1,98 @@
+import type { LemonMenuItems } from 'lib/lemon-ui/LemonMenu/LemonMenu'
+import { lemonToast } from 'lib/lemon-ui/LemonToast'
+import posthog from 'lib/posthog-typed'
+
+import { visionObservationsFeedDismissalCreate, visionObservationsFeedDismissalDestroy } from '../generated/api'
+import type { FeedDismissalReasonEnumApi, WatchFeedItemApi } from '../generated/api.schemas'
+
+export const FEED_DISMISSAL_REASON_LABELS: Record<FeedDismissalReasonEnumApi, string> = {
+ not_a_real_problem: 'Not a real problem',
+ already_known: 'Already known',
+ not_my_area: 'Not my area',
+ other: 'Other reason',
+}
+
+export function feedDismissalMenuItems(onDismiss: (reason: FeedDismissalReasonEnumApi | null) => void): LemonMenuItems {
+ const reasons = Object.entries(FEED_DISMISSAL_REASON_LABELS) as [FeedDismissalReasonEnumApi, string][]
+ return [
+ {
+ title: 'Why is this not useful?',
+ items: reasons.map(([reason, label]) => ({
+ label,
+ onClick: () => onDismiss(reason),
+ 'data-attr': `vision-watch-feed-dismiss-${reason}`,
+ })),
+ },
+ {
+ items: [
+ {
+ label: 'Hide without a reason',
+ onClick: () => onDismiss(null),
+ 'data-attr': 'vision-watch-feed-dismiss-no-reason',
+ },
+ ],
+ },
+ ]
+}
+
+export function withoutFeedItem(items: WatchFeedItemApi[] | null, observationId: string): WatchFeedItemApi[] | null {
+ return items?.filter((item) => item.observation.id !== observationId) ?? null
+}
+
+/** Puts an item back where it was, or at the end when the list has since shrunk below that place. */
+export function withFeedItemRestored(
+ items: WatchFeedItemApi[] | null,
+ item: WatchFeedItemApi,
+ position: number
+): WatchFeedItemApi[] | null {
+ if (!items || items.some((existing) => existing.observation.id === item.observation.id)) {
+ return items
+ }
+ const next = [...items]
+ next.splice(Math.min(position, next.length), 0, item)
+ return next
+}
+
+interface DismissFeedItemArgs {
+ teamId: number
+ item: WatchFeedItemApi
+ reason: FeedDismissalReasonEnumApi | null
+ properties: Record<string, unknown>
+ restore: () => void
+}
+
+export async function dismissFeedItem({
+ teamId,
+ item,
+ reason,
+ properties,
+ restore,
+}: DismissFeedItemArgs): Promise<void> {
+ const observationId = item.observation.id
+ try {
+ await visionObservationsFeedDismissalCreate(String(teamId), observationId, { reason })
+ } catch {
+ restore()
+ lemonToast.error("Couldn't hide this session. Try again.")
+ return
+ }
+ posthog.capture('replay_vision_watch_clip_dismissed', { ...properties, dismissal_reason: reason })
+ const undo = async (): Promise<void> => {
+ try {
+ await visionObservationsFeedDismissalDestroy(String(teamId), observationId)
+ } catch {
+ lemonToast.error("Couldn't bring this session back.", {
+ toastId: `vision-watch-feed-undo-failed-${observationId}`,
+ button: { label: 'Try again', dataAttr: 'vision-watch-feed-dismiss-undo-retry', action: undo },
+ })
+ return
+ }
+ posthog.capture('replay_vision_watch_clip_dismiss_undone', properties)
+ restore()
+ }
+ // Keyed per observation, so a second dismissal gets its own toast instead of merging into the first.
+ lemonToast.success('Hidden from your feed', {
+ toastId: `vision-watch-feed-dismissed-${observationId}`,
+ button: { label: 'Undo', dataAttr: 'vision-watch-feed-dismiss-undo', action: undo },
+ })
+}
diff --git a/products/replay_vision/frontend/replay_scanners/watchFeedLogic.test.ts b/products/replay_vision/frontend/replay_scanners/watchFeedLogic.test.ts
index 969e704256b0..d323f1f54846 100644
--- a/products/replay_vision/frontend/replay_scanners/watchFeedLogic.test.ts
+++ b/products/replay_vision/frontend/replay_scanners/watchFeedLogic.test.ts
@@ -2,11 +2,15 @@ import { router } from 'kea-router'
import { expectLogic } from 'kea-test-utils'
import posthog from 'posthog-js'
+import { lemonToast } from 'lib/lemon-ui/LemonToast'
+
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
import { watchFeedLogic } from './watchFeedLogic'
+jest.mock('lib/lemon-ui/LemonToast', () => ({ lemonToast: { success: jest.fn(), error: jest.fn() } }))
+
describe('watchFeedLogic', () => {
let logic: ReturnType<typeof watchFeedLogic.build>
let feedSpy: jest.Mock
@@ -179,6 +183,32 @@ describe('watchFeedLogic', () => {
expect(logic.values.emptyReason).toBe('all-disabled')
})
+ it('puts a card back when hiding fails, and leaves a reloaded feed alone on a late restore', async () => {
+ let dismissStatus = 500
+ useMocks({
+ post: { '/api/projects/:team/vision/observations/:id/feed_dismissal/': () => [dismissStatus] },
+ delete: { '/api/projects/:team/vision/observations/:id/feed_dismissal/': () => [204] },
+ })
+ logic.mount()
+ await expectLogic(logic).toDispatchActions(['loadFeedSuccess']).toFinishAllListeners()
+ const [first] = logic.values.feedItems ?? []
+
+ await expectLogic(logic, () => logic.actions.dismissItem(first, 0, null)).toFinishAllListeners()
+ expect(logic.values.feedItems?.map((i) => i.observation.id)).toEqual(['o1', 'o2'])
+
+ dismissStatus = 204
+ await expectLogic(logic, () => logic.actions.dismissItem(first, 0, 'already_known')).toFinishAllListeners()
+ expect(logic.values.feedItems?.map((i) => i.observation.id)).toEqual(['o2'])
+
+ feedSpy.mockImplementation(() => [200, { results: [item('o3', 'recent')] }])
+ await expectLogic(logic, () => logic.actions.setScannerTypeFilter('monitor')).toFinishAllListeners()
+ const undo = jest.mocked(lemonToast.success).mock.calls.at(-1)?.[1]?.button?.action
+ expect(undo).toBeTruthy()
+ await undo?.()
+ expect(jest.mocked(lemonToast.error)).toHaveBeenCalledTimes(1)
+ expect(logic.values.feedItems?.map((i) => i.observation.id)).toEqual(['o3'])
+ })
+
it('flags a failed load and clears the flag on retry', async () => {
feedSpy.mockImplementation(() => [500, { detail: 'nope' }])
logic.mount()
diff --git a/products/replay_vision/frontend/replay_scanners/watchFeedLogic.ts b/products/replay_vision/frontend/replay_scanners/watchFeedLogic.ts
index 7e456905b411..986eee0ce243 100644
--- a/products/replay_vision/frontend/replay_scanners/watchFeedLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/watchFeedLogic.ts
@@ -16,11 +16,20 @@ import type { ReplayScannerApi, VisionQuotaApi, WatchFeedResponseApi } from '../
import type { VisionScannersWatchFeedRetrieveParams, WatchFeedItemApi } from '../generated/api.schemas'
import type { ScannerTypeEnumApi } from '../generated/api.schemas'
import type { RankerEnumApi } from '../generated/api.schemas'
+import type { FeedDismissalReasonEnumApi } from '../generated/api.schemas'
import { visionQuotaLogic } from '../logics/visionQuotaLogic'
import { visionScannersListLogic } from '../logics/visionScannersListLogic'
import { csvParam, parseCsvParam } from '../utils/urlParams'
import { ScannerType } from './types'
+import { dismissFeedItem, withFeedItemRestored, withoutFeedItem } from './watchFeedDismissal'
import { type WatchFeedEmptyReason, resolveWatchFeedEmptyReason } from './watchFeedEmptyState'
+import {
+ type WatchFeedLoad,
+ WatchFeedImpressions,
+ cardProperties,
+ newWatchFeedLoad,
+ servedListProperties,
+} from './watchFeedTelemetry'
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface watchFeedLogicValues {
@@ -36,6 +45,7 @@ export interface watchFeedLogicValues {
feedFailed: boolean
feedItems: WatchFeedItemApi[] | null
feedItemsLoading: boolean
+ feedLoad: WatchFeedLoad | null
feedRanker: WatchFeedRanker
feedRankerVariant: string | null
hasFeedFilters: boolean
@@ -54,9 +64,25 @@ export interface watchFeedLogicActions {
loadTags: () => {
value: true
} // tagsModel
+ cardSeen: (
+ item: WatchFeedItemApi,
+ position: number
+ ) => {
+ item: WatchFeedItemApi
+ position: number
+ }
clearFeedFilters: () => {
value: true
}
+ dismissItem: (
+ item: WatchFeedItemApi,
+ position: number,
+ reason: FeedDismissalReasonEnumApi | null
+ ) => {
+ item: WatchFeedItemApi
+ position: number
+ reason: FeedDismissalReasonEnumApi | null
+ }
loadFeed: () => {
value: true
}
@@ -89,6 +115,13 @@ export interface watchFeedLogicActions {
search: string
tags: string[]
}
+ restoreItem: (
+ item: WatchFeedItemApi,
+ position: number
+ ) => {
+ item: WatchFeedItemApi
+ position: number
+ }
setCreatedByFilter: (userIds: string[]) => {
userIds: string[]
}
@@ -99,6 +132,9 @@ export interface watchFeedLogicActions {
dateFrom: string | null
dateTo: string | null
}
+ setFeedLoad: (load: WatchFeedLoad) => {
+ load: WatchFeedLoad
+ }
setFeedRanker: (
ranker: WatchFeedRanker,
variant: string | null
@@ -212,6 +248,14 @@ export const watchFeedLogic = kea<watchFeedLogicType>([
clearFeedFilters: true,
loadFeed: true,
setFeedRanker: (ranker: WatchFeedRanker, variant: string | null) => ({ ranker, variant }),
+ setFeedLoad: (load: WatchFeedLoad) => ({ load }),
+ cardSeen: (item: WatchFeedItemApi, position: number) => ({ item, position }),
+ dismissItem: (item: WatchFeedItemApi, position: number, reason: FeedDismissalReasonEnumApi | null) => ({
+ item,
+ position,
+ reason,
+ }),
+ restoreItem: (item: WatchFeedItemApi, position: number) => ({ item, position }),
}),
loaders(({ values, actions }) => ({
@@ -249,6 +293,7 @@ export const watchFeedLogic = kea<watchFeedLogicType>([
// Drop out-of-order responses — the most recent filter change owns the feed.
breakpoint()
actions.setFeedRanker(response.ranker ?? 'weighted-score', response.ranker_variant ?? null)
+ actions.setFeedLoad(newWatchFeedLoad(response.ranker, response.results))
return response.results
},
},
@@ -256,6 +301,16 @@ export const watchFeedLogic = kea<watchFeedLogicType>([
})),
reducers({
+ feedItems: {
+ dismissItem: (state, { item }) => withoutFeedItem(state, item.observation.id),
+ restoreItem: (state, { item, position }) => withFeedItemRestored(state, item, position),
+ },
+ feedLoad: [
+ null as WatchFeedLoad | null,
+ {
+ setFeedLoad: (_, { load }) => load,
+ },
+ ],
dateFrom: [
DEFAULT_FEED_DATE_FROM,
{
@@ -336,7 +391,27 @@ export const watchFeedLogic = kea<watchFeedLogicType>([
],
}),
- listeners(({ actions, values }) => ({
+ listeners(({ actions, values, cache }) => ({
+ setFeedLoad: ({ load }) => {
+ cache.impressions.start(load)
+ },
+ cardSeen: ({ item, position }) => {
+ cache.impressions.add(item, position)
+ },
+ dismissItem: async ({ item, position, reason }) => {
+ const teamId = teamLogic.values.currentTeamId
+ if (!teamId) {
+ return
+ }
+ const loadId = values.feedLoad?.feedLoadId
+ await dismissFeedItem({
+ teamId,
+ item,
+ reason,
+ properties: cardProperties(values.feedLoad, item, position, 'feed_tab'),
+ restore: () => values.feedLoad?.feedLoadId === loadId && actions.restoreItem(item, position),
+ })
+ },
setDateRange: () => {
reportFiltered(values)
actions.loadFeed()
@@ -380,6 +455,7 @@ export const watchFeedLogic = kea<watchFeedLogicType>([
countByReasonKind[item.reason.kind] = (countByReasonKind[item.reason.kind] ?? 0) + 1
}
posthog.capture('replay_vision_watch_feed_viewed', {
+ ...servedListProperties(values.feedLoad, items),
clip_count: items.length,
scanner_count: new Set(items.map((item) => item.observation.scanner_id)).size,
reason_kind_counts: countByReasonKind,
@@ -489,7 +565,10 @@ export const watchFeedLogic = kea<watchFeedLogicType>([
})),
// The tab content mounts only while the tab is active, so mount is the fetch signal.
- afterMount(({ actions }) => {
+ afterMount(({ actions, cache }) => {
+ cache.impressions = new WatchFeedImpressions('feed_tab')
+ // Not paused on hide: hiding is when the batch must go out.
+ cache.disposables.add(cache.impressions.flushOnHideAndUnmount, 'impressionsFlush', { pauseOnPageHidden: false })
actions.loadFeed()
// tagsModel is lazy; load it so the tag filter isn't empty on a direct visit.
actions.loadTags()
diff --git a/products/replay_vision/frontend/replay_scanners/watchFeedTelemetry.ts b/products/replay_vision/frontend/replay_scanners/watchFeedTelemetry.ts
new file mode 100644
index 000000000000..d92f0b502aba
--- /dev/null
+++ b/products/replay_vision/frontend/replay_scanners/watchFeedTelemetry.ts
@@ -0,0 +1,113 @@
+import posthog from 'lib/posthog-typed'
+import { uuid } from 'lib/utils/dom'
+
+import type { WatchFeedItemApi } from '../generated/api.schemas'
+
+// A second on screen, enough to read the title, so a card scrolled past at speed does not count as shown.
+export const CARD_SEEN_DWELL_MS = 1000
+
+/** One feed fetch. Every card event carries its id, so a click, dismissal, or impression joins back to the ranked list it came from. */
+export interface WatchFeedLoad {
+ feedLoadId: string
+ ranker: string
+ // Each card's place as served, so a dismissal that shortens the list does not shift later cards' positions.
+ positions: Record<string, number>
+}
+
+export function newWatchFeedLoad(ranker: string | null | undefined, items: WatchFeedItemApi[]): WatchFeedLoad {
+ return {
+ feedLoadId: uuid(),
+ ranker: ranker ?? 'weighted-score',
+ positions: Object.fromEntries(items.map((item, index) => [item.observation.id, index])),
+ }
+}
+
+function servedPosition(load: WatchFeedLoad | null, item: WatchFeedItemApi, position: number): number {
+ return load?.positions[item.observation.id] ?? position
+}
+
+export function servedListProperties(load: WatchFeedLoad | null, items: WatchFeedItemApi[]): Record<string, unknown> {
+ return {
+ feed_load_id: load?.feedLoadId ?? null,
+ ranker: load?.ranker ?? null,
+ observation_ids: items.map((item) => item.observation.id),
+ reason_kinds: items.map((item) => item.reason.kind),
+ }
+}
+
+export function cardProperties(
+ load: WatchFeedLoad | null,
+ item: WatchFeedItemApi,
+ position: number,
+ surface: string
+): Record<string, unknown> {
+ const { observation, reason } = item
+ const createdAt = Date.parse(observation.created_at)
+ return {
+ feed_load_id: load?.feedLoadId ?? null,
+ ranker: load?.ranker ?? null,
+ surface,
+ observation_id: observation.id,
+ scanner_id: observation.scanner_id,
+ // Joins to the player's `recording viewed summary` event.
+ session_id: observation.session_id,
+ position: servedPosition(load, item, position),
+ reason_kind: reason.kind,
+ observation_age_ms: Number.isFinite(createdAt) ? Math.max(0, Date.now() - createdAt) : null,
+ }
+}
+
+/** Batches one load's seen cards into a single event. Flushes on tab hide too, since a closed tab sends nothing later. */
+export class WatchFeedImpressions {
+ private seen = new Map<string, { position: number; reason_kind: string }>()
+ // A tab hidden and shown again flushes twice in one load; a card is reported once per load.
+ private reported = new Set<string>()
+ private load: WatchFeedLoad | null = null
+
+ constructor(private readonly surface: string) {}
+
+ start(load: WatchFeedLoad | null): void {
+ this.flush()
+ this.reported.clear()
+ this.load = load
+ }
+
+ add(item: WatchFeedItemApi, position: number): void {
+ if (!this.seen.has(item.observation.id) && !this.reported.has(item.observation.id)) {
+ this.seen.set(item.observation.id, {
+ position: servedPosition(this.load, item, position),
+ reason_kind: item.reason.kind,
+ })
+ }
+ }
+
+ flush(): void {
+ if (this.seen.size === 0) {
+ return
+ }
+ posthog.capture('replay_vision_watch_feed_impressions', {
+ feed_load_id: this.load?.feedLoadId ?? null,
+ ranker: this.load?.ranker ?? null,
+ surface: this.surface,
+ count: this.seen.size,
+ impressions: Array.from(this.seen, ([observation_id, card]) => ({ observation_id, ...card })),
+ })
+ for (const observationId of this.seen.keys()) {
+ this.reported.add(observationId)
+ }
+ this.seen.clear()
+ }
+
+ flushOnHideAndUnmount = (): (() => void) => {
+ const flushWhenHidden = (): void => {
+ if (document.visibilityState === 'hidden') {
+ this.flush()
+ }
+ }
+ document.addEventListener('visibilitychange', flushWhenHidden)
+ return () => {
+ document.removeEventListener('visibilitychange', flushWhenHidden)
+ this.flush()
+ }
+ }
+}
diff --git a/products/replay_vision/frontend/replay_scanners/watchPicksLogic.test.ts b/products/replay_vision/frontend/replay_scanners/watchPicksLogic.test.ts
index 3bee442f9ce3..4b5a62524fe3 100644
--- a/products/replay_vision/frontend/replay_scanners/watchPicksLogic.test.ts
+++ b/products/replay_vision/frontend/replay_scanners/watchPicksLogic.test.ts
@@ -89,7 +89,28 @@ describe('watchPicksLogic', () => {
it('opens on the picks and reports the impression with its count', () => {
expect(logic.values.effectiveListMode).toBe('picks')
- expect(shownEvents()).toEqual([{ view: 'list', count: 3, unwatched_count: 3, shown_count: 1 }])
+ expect(shownEvents()).toEqual([
+ expect.objectContaining({
+ view: 'list',
+ count: 3,
+ unwatched_count: 3,
+ shown_count: 1,
+ feed_load_id: logic.values.picksLoad?.feedLoadId,
+ observation_ids: ['o1', 'o2', 'o3'],
+ }),
+ ])
+ })
+
+ it('reports impressions of served picks only, not of the unranked fallback rows', () => {
+ const [served] = logic.values.picks ?? []
+ logic.actions.cardSeen(served as any, 0)
+ logic.actions.cardSeen(item('fallback', 'session-c') as any, 0)
+ logic.unmount()
+ const batches = captureSpy.mock.calls
+ .filter(([name]) => name === 'replay_vision_watch_feed_impressions')
+ .map(([, props]) => props.impressions.map((i: { observation_id: string }) => i.observation_id))
+ expect(batches).toEqual([['o1']])
+ logic.mount()
})
it.each([
diff --git a/products/replay_vision/frontend/replay_scanners/watchPicksLogic.ts b/products/replay_vision/frontend/replay_scanners/watchPicksLogic.ts
index da176b9255c0..34d8aaa2b479 100644
--- a/products/replay_vision/frontend/replay_scanners/watchPicksLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/watchPicksLogic.ts
@@ -31,6 +31,13 @@ import { SessionRecordingSidebarTab } from '~/types'
import { visionObservationsViewedCreate, visionScannersWatchFeedRetrieve } from '../generated/api'
import type { WatchFeedItemApi } from '../generated/api.schemas'
import { observationKeyMomentMs, watchStartSeconds } from './components/WatchFeedCard'
+import {
+ type WatchFeedLoad,
+ WatchFeedImpressions,
+ cardProperties,
+ newWatchFeedLoad,
+ servedListProperties,
+} from './watchFeedTelemetry'
export type WatchPicksListMode = 'recordings' | 'picks'
@@ -65,6 +72,7 @@ export interface watchPicksLogicValues {
openedOnDeepLink: boolean
picks: WatchFeedItemApi[] | null
picksFailed: boolean
+ picksLoad: WatchFeedLoad | null
picksLoading: boolean
unwatchedCount: number
}
@@ -74,6 +82,13 @@ export interface watchPicksLogicActions {
adoptPicksMode: () => {
value: true
}
+ cardSeen: (
+ item: WatchFeedItemApi,
+ position: number
+ ) => {
+ item: WatchFeedItemApi
+ position: number
+ }
loadPicks: () => {
value: true
}
@@ -104,6 +119,9 @@ export interface watchPicksLogicActions {
setListMode: (mode: WatchPicksListMode) => {
mode: WatchPicksListMode
}
+ setPicksLoad: (load: WatchFeedLoad) => {
+ load: WatchFeedLoad
+ }
watchPick: (
item: WatchFeedItemApi,
position: number
@@ -150,9 +168,11 @@ export const watchPicksLogic: LogicWrapper<watchPicksLogicType> = kea<watchPicks
watchPick: (item: WatchFeedItemApi, position: number) => ({ item, position }),
setActiveSessionId: (sessionId: string | null) => ({ sessionId }),
markPickViewed: (observationId: string) => ({ observationId }),
+ setPicksLoad: (load: WatchFeedLoad) => ({ load }),
+ cardSeen: (item: WatchFeedItemApi, position: number) => ({ item, position }),
}),
- loaders(({ values }) => ({
+ loaders(({ values, actions }) => ({
picks: [
null as WatchFeedItemApi[] | null,
{
@@ -165,6 +185,7 @@ export const watchPicksLogic: LogicWrapper<watchPicksLogicType> = kea<watchPicks
limit: PICKS_LIMIT,
})
breakpoint()
+ actions.setPicksLoad(newWatchFeedLoad(response.ranker, response.results))
return response.results
},
},
@@ -180,6 +201,12 @@ export const watchPicksLogic: LogicWrapper<watchPicksLogicType> = kea<watchPicks
: pick
) ?? null,
},
+ picksLoad: [
+ null as WatchFeedLoad | null,
+ {
+ setPicksLoad: (_, { load }) => load,
+ },
+ ],
listMode: [
null as WatchPicksListMode | null,
{ persist: true, storageKey: 'replay-vision.watch-picks-list-mode' },
@@ -241,6 +268,7 @@ export const watchPicksLogic: LogicWrapper<watchPicksLogicType> = kea<watchPicks
const shownCount = (picksShownCount.get() ?? 0) + 1
picksShownCount.set(shownCount)
posthog.capture('replay_vision_watch_picks_shown', {
+ ...servedListProperties(values.picksLoad, values.picks),
view: 'list',
count: values.picks.length,
unwatched_count: values.unwatchedCount,
@@ -258,6 +286,15 @@ export const watchPicksLogic: LogicWrapper<watchPicksLogicType> = kea<watchPicks
adoptPicksMode: () => {
emptyImpressions.set(0)
},
+ setPicksLoad: ({ load }) => {
+ cache.impressions.start(load)
+ },
+ cardSeen: ({ item, position }) => {
+ // Fallback rows below the picks were not served by the ranker, so they are not impressions of this load.
+ if (values.picksLoad?.positions[item.observation.id] !== undefined) {
+ cache.impressions.add(item, position)
+ }
+ },
setListMode: ({ mode }) => {
posthog.capture('replay_vision_watch_picks_list_mode_changed', { mode })
if (mode === 'picks') {
@@ -265,14 +302,16 @@ export const watchPicksLogic: LogicWrapper<watchPicksLogicType> = kea<watchPicks
}
},
watchPick: async ({ item, position }) => {
- const { observation, reason } = item
+ const { observation } = item
const keyMomentMs = observationKeyMomentMs(observation)
posthog.capture('replay_vision_watch_clip_clicked', {
- scanner_id: observation.scanner_id,
+ ...cardProperties(
+ values.picksLoad?.positions[observation.id] !== undefined ? values.picksLoad : null,
+ item,
+ position,
+ 'list'
+ ),
scanner_type: observation.scanner_snapshot?.scanner_type,
- observation_id: observation.id,
- position,
- reason_kind: reason.kind,
has_key_moment: keyMomentMs !== null,
target: 'replay_page',
view: 'list',
@@ -316,6 +355,9 @@ export const watchPicksLogic: LogicWrapper<watchPicksLogicType> = kea<watchPicks
}),
afterMount(({ actions, cache }) => {
+ cache.impressions = new WatchFeedImpressions('list')
+ // Not paused on hide: hiding is when the batch must go out.
+ cache.disposables.add(cache.impressions.flushOnHideAndUnmount, 'impressionsFlush', { pauseOnPageHidden: false })
actions.loadPicks()
cache.disposables.add(() => {
const onFocus = (): void => {
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 0cd41a07d5a9..b6ab6db3ea47 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -52985,6 +52985,22 @@ export namespace Schemas {
created_at: string | null;
}
+ /**
+ * * `not_a_real_problem` - Not a real problem
+ * * `already_known` - Already known
+ * * `not_my_area` - Not my area
+ * * `other` - Other
+ */
+ export type FeedDismissalReasonEnum = typeof FeedDismissalReasonEnum[keyof typeof FeedDismissalReasonEnum];
+
+
+ export const FeedDismissalReasonEnum = {
+ NotARealProblem: 'not_a_real_problem',
+ AlreadyKnown: 'already_known',
+ NotMyArea: 'not_my_area',
+ Other: 'other',
+ } as const;
+
/**
* Structured element metadata (inferred selectors, attributes, component hints).
*/
@@ -69471,6 +69487,19 @@ export namespace Schemas {
event_definition_id?: string | null;
}
+ /**
+ * Why the calling user marked an observation not useful in What to watch.
+ */
+ export interface ObservationFeedDismissal {
+ /** Optional reason the observation was not useful. Omit or send null when the user gave none.
+ *
+ * * `not_a_real_problem` - Not a real problem
+ * * `already_known` - Already known
+ * * `not_my_area` - Not my area
+ * * `other` - Other */
+ reason?: FeedDismissalReasonEnum | null;
+ }
+
export interface ObservationLabelDayCount {
/** Day (UTC) the observed sessions were scanned. */
date: string;