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): lay out what to watch cards as posts (#122779)

Tue Haulund6dd02155521b
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 954ac674d12b..6f30b2d6c2f2 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -14593,21 +14593,25 @@ 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.031ff3d767c9b2d0900e559fbf4a9c78f5066fbcecde5b309bd9b22f2f2db342.vRyLsopnMHAdtwaz8dJ1hkQKMh3wMRmXY3nRRxWmByY
+ hash: v1.k794b7964.7d0e2559c229b41c2dd34bb70bb0b89c2a4c7f2038c2482290e7b8f63b6dd261.znzm1HO_g6PbiSk7IXl6qOsnk9rYY-QEfTg000qIXF0
scenes-app-replay-vision--home-watch-feed--light:
- hash: v1.k794b7964.060f25ab51f3ce69e2e68af90055c134b0f2d7905d9678bda4c300d2e51726c3.gLCeY7ckAsB-jYPVfZrkZS2BadtD4-UOleMGllrOVQU
+ hash: v1.k794b7964.4d1c2d852d5380f72997ca12282df9c5194effa9f908e62b6086dd675e797e6f.9B9NfkA62DYoeVZKKFjbn8Dv9mg1zn7GXPZjGqnhr9Y
+ scenes-app-replay-vision--home-watch-feed-embedding-arm--dark:
+ hash: v1.k794b7964.1a1cbdd6acabea08dd2d68e14fe040eaf902ef8465927578ace8a9f5bbde6ce5.GTgpW1FTkzZrHK7RUxilJPC2AxgeWgp4C8Ga_scR5fo
+ scenes-app-replay-vision--home-watch-feed-embedding-arm--light:
+ hash: v1.k794b7964.7590868e3a7d088106dc18e3e0d2a8d838be86b0acef135e97a45ecc53b67f36.cel6SQmC7MujdHW5o9lkpJ2h42bm3FAyefLD8im6eKM
scenes-app-replay-vision--home-watch-feed-empty--dark:
- hash: v1.k794b7964.508e7537ec9368ae5f9b9df50086f1e552ac7cd292496e8a32d7261b9416a808.vmCvpR4ES-v0zOQJpuaz0l0LJWvzgyDJHZomDXMvfpo
+ hash: v1.k794b7964.614c2f25e846b4b62d453da1f3e8eeea44c57e1139cbd6a9aa93553a457aac17.l7w_nfYdsx17uChOCZUrB1cjbXW6Iif4KBTpTsL08Xk
scenes-app-replay-vision--home-watch-feed-empty--light:
- hash: v1.k794b7964.5b95650e20cbf2fc7515cc99bac499c83bad574858817d0232c095ccf9944b69.t_3o-A2yWVHUKwMsfsgENI4qFMrF4IWp4EQwKOAAnnM
+ hash: v1.k794b7964.9d99877526d83ea7f03feab63d2d0e94fb66e68d585889e6b37e9bae480f68c9.x1Aal2QclDzow3a5Hx6BpkJcnv_l-PhLDjkIqexUTNA
scenes-app-replay-vision--home-watch-feed-jev-arm--dark:
- hash: v1.k794b7964.013fab882504a541802c347ed72ad1f4eaa8cbd966216c89de79fc3ebec352f3.0dfk-dxpMi-aygVKWhCBLGIEXE65qVHpCaggbaNC_Ds
+ hash: v1.k794b7964.a275b0ea478208f97f7198bc67644bedddc12083ebaae9cafe287ebdcbd02faa.cRV7FtQxED_hIn3kObdcUdMPsj8WeUpHmOulEahgTTo
scenes-app-replay-vision--home-watch-feed-jev-arm--light:
- hash: v1.k794b7964.3af0fd2963dc4bbb700bc8305ada330486f9abcaee7945fb25d5e3bcbd4be92c.r9HN72bBYYbgsx_O6VyhI21zejjNCQ-kmfWcp67xbBY
+ hash: v1.k794b7964.e7e598f0ce15c0c82d52af9a0e2030d955e55ab40abfe9cc2052a2acd7c1f6d0.wrabqzKi1LjI6N4dPGG9kCC6UCdDrcq0Hm-l4VLemHs
scenes-app-replay-vision--home-watch-feed-only-newest--dark:
- hash: v1.k794b7964.39af7e6060e2ae5664f6534a6d76af2de997e0f10d3a85e6ad18cd49666c727c.L_KdE8x_W_YZ4tlxxcNwf3qycSGhoP7lGmXW_yNTsHc
+ hash: v1.k794b7964.db86a44f2ccb474abc3fbfc0c16d690ec06099ebec1a13d0006717cc24a8bae9.46YbWyXBGKdeS6wjijnt0Zy3_fPL-zY1DbF3Wkvbvac
scenes-app-replay-vision--home-watch-feed-only-newest--light:
- hash: v1.k794b7964.7f0bce5ea238bcff38e8e8d2339a2dce62e6b135b9bf9fee311eeb92c57f795c.8rgy6-qnerQKdi7LWHqgY4FeRVzeBD6Jr-50w6ZygCI
+ hash: v1.k794b7964.b9ef681e0d7f7cf3dcdfe6b5ea74e6aa6308e301aadeada4819df13fcbaa12f8.ZUNDzzhrBQbzMegH2AdNIwvFOXtfdVyJCwV_P3cv_LY
scenes-app-replay-vision--monitor-observations--dark:
hash: v1.k794b7964.9ec7ef6c17074e9547647fe71aa2613100208fa0c7ba87a3d97897b4f183a5c8.-UKB-w06mWDRH2yNgzIBhn3Qhn2MYlFTNXjhMce1hh4
scenes-app-replay-vision--monitor-observations--light:
@@ -14925,9 +14929,9 @@ snapshots:
scenes-app-replay-vision-watchfeedemptystate--all-disabled--light:
hash: v1.k794b7964.87641562db015731f2de39e04591e3efd4e136db74a726b4e7a8835f6b608be6._VX6C8s2D6xBgXcwhyxW47DDLTNUg90321xZZc0enxE
scenes-app-replay-vision-watchfeedemptystate--filtered--dark:
- hash: v1.k794b7964.417933f4f0dbd89798575f302a173ac5780705a8533c42e7196c8922a5b9d0ec.zAKPjkDiU74sZwyCufk7XKxwAmu-of86YMX-TTIcUSE
+ hash: v1.k794b7964.9c28b22694bf445428e287ffba15a43ba9f8e6096f2975525a0f101c168f9acc.AMzob-d5Se4UV-_lnmynB4K58gbjmwCo6zDyVJmpEUc
scenes-app-replay-vision-watchfeedemptystate--filtered--light:
- hash: v1.k794b7964.b4dbcfa2372545ec4218a5974345864dc01908f4682afe32b05e7cc968747a71.jSaF9RqYy5QMC4Jj0ilFjfNhRm0TEPaCeXIfPg33eSc
+ hash: v1.k794b7964.8d5946497bd09e2b026c061d1455a817ba966af095a88728ea6d29fbb9f52bb9.pE1i1IRnnpYJTGvEFuMWHNYnVKUoGparwVoG0Sx_VHg
scenes-app-replay-vision-watchfeedemptystate--no-scanners--dark:
hash: v1.k794b7964.f2bd16f47816e1a9d2fd314270daa72223c37a8946af17765b3f3c43df966cfe.3wSlppAgHktz_NPXbdFqdb0d4SxmdQ4_lBtKTji20e0
scenes-app-replay-vision-watchfeedemptystate--no-scanners--light:
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 6ac0aeab2b57..44075409db6e 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -566,6 +566,7 @@ export const FEATURE_FLAGS = {
UX_REMOVE_SIDEPANEL: 'ux-remove-sidepanel', // owner: #team-surveys
VISION_ENTRYPOINT_REPLAY_FILTERS: 'vision-entrypoint-replay-filters', // owner: #team-replay, cross-sell entry point from the replay filters panel
VISION_EXPERIMENT_SCANNER: 'experiment-scanner', // owner: #team-replay, experiment scanners overall: the type in the scanner editor, creating one from experiments, and the variants tab
+ VISION_WATCH_FEED_RANKER: 'vision-watch-feed-ranker', // owner: #team-replay multivariate=control,jev-shadow,jev,embedding. Project-aggregated; compare the variant string
VISUAL_REVIEW: 'visual-review', // owner: #team-devex
WAREHOUSE_MULTI_DESTINATION: 'warehouse-multi-destination', // owner: #team-warehouse-sources
WAREHOUSE_PERSON_PROPERTIES: 'warehouse-person-properties', // owner: @tomowers #team-warehouse-sources, gates warehouse -> person properties (person-target custom property sources)
diff --git a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx
index 43c873bc2d32..32b4a5192048 100644
--- a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx
+++ b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx
@@ -1213,6 +1213,69 @@ export const HomeWatchFeedJevArm: StoryObj = {
],
}
+// The embedding ranker arm: each pick names its category, and the first stands for three similar sessions.
+export const HomeWatchFeedEmbeddingArm: StoryObj = {
+ decorators: [
+ mswDecorator({
+ get: {
+ '/api/projects/:team_id/vision/scanners/watch_feed/': {
+ ranker: 'embedding',
+ has_more: false,
+ results: [
+ {
+ observation: observation({
+ id: '00000000-0000-0000-0000-0000000000a1',
+ prompt_question: 'Did the user hesitate at checkout?',
+ scanner_id: scanners.results[0].id,
+ scanner_snapshot: {
+ name: 'Confused checkout',
+ scanner_type: 'monitor',
+ scanner_version: 1,
+ model: 'gemini-3.8-flash',
+ provider: 'google',
+ emits_signals: true,
+ scanner_config: { prompt: 'Did the user hesitate at checkout?' },
+ },
+ scanner_result: {
+ model_output: {
+ scanner_type: 'monitor',
+ verdict: 'yes',
+ confidence: 0.92,
+ reasoning:
+ 'The card form rejected a valid card three times before the user left.',
+ key_moment_ms: 154000,
+ },
+ signals_count: 0,
+ },
+ viewed: false,
+ }),
+ reason: { kind: 'embedding_pick', watch_category: 'failure', similar_count: 3 },
+ },
+ {
+ observation: observation({
+ id: '00000000-0000-0000-0000-0000000000a2',
+ prompt_question: 'What happened in this session?',
+ scanner_result: {
+ model_output: {
+ scanner_type: 'summarizer',
+ confidence: 0.8,
+ title: 'Plan limit blocked an export',
+ summary: 'The export stopped at the plan limit and the user opened billing.',
+ },
+ signals_count: 0,
+ },
+ viewed: true,
+ }),
+ reason: { kind: 'embedding_pick', watch_category: 'revenue', similar_count: 0 },
+ },
+ ],
+ },
+ },
+ }),
+ ],
+ parameters: { featureFlags: { [FEATURE_FLAGS.VISION_WATCH_FEED_RANKER]: 'embedding' } },
+}
+
// A quiet window: nothing scored on any source, so the feed pads to three newest clips and says so
// rather than filling the page with them.
export const HomeWatchFeedOnlyNewest: StoryObj = {
diff --git a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.tsx b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.tsx
index 9a5a0c9fcae6..ee1e21718af5 100644
--- a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.tsx
+++ b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.tsx
@@ -322,7 +322,15 @@ export function ReplayScannersScene(): JSX.Element {
activeKey={activeTab}
onChange={(tab) => push(urls.replayVision(), tab === DEFAULT_TAB ? {} : { tab })}
tabs={[
- { key: 'watch', label: 'What to watch', content: <></> },
+ {
+ key: 'watch',
+ // The new name ships with the embedding ranker, so it stays off the arms it does not describe.
+ label:
+ featureFlags[FEATURE_FLAGS.VISION_WATCH_FEED_RANKER] === 'embedding'
+ ? 'Highlights'
+ : 'What to watch',
+ content: <></>,
+ },
{ key: 'scanners', label: 'Scanners', content: <></> },
{ key: ReplayScannerTab.Search, label: 'Search', content: <></> },
{ key: 'usage', label: 'Usage', content: <></> },
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx
index f04afddb0897..f6834fb14d8b 100644
--- a/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchFeedCard.tsx
@@ -1,8 +1,8 @@
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 { IconFlag, IconPlayFilled } from '@posthog/icons'
+import { LemonButton, LemonTag, Link, Tooltip } from '@posthog/lemon-ui'
import { useAutoMarkRead } from 'lib/components/NotificationsMenu/useAutoMarkRead'
import { TZLabel } from 'lib/components/TZLabel'
@@ -227,11 +227,9 @@ 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">
@@ -249,8 +247,6 @@ function WatchCardPerson({
))}
{person && <span aria-hidden>·</span>}
<TZLabel time={observation.created_at} className="shrink-0" />
- {children && <span aria-hidden>·</span>}
- {children}
</div>
)
}
@@ -269,8 +265,8 @@ export function watchFeedRowSentence(observation: ReplayObservationApi, reason:
}
/**
- * The scanner behind a row: a circle in its type's color, then its name. Clicking it narrows the
- * feed to that scanner. The tooltip carries the scanner's question and verdict.
+ * The scanner behind a row: a circle in its type's color, then its name. Clicking it opens the
+ * scanner. The tooltip carries the scanner's question and verdict.
*/
function WatchFeedScannerLink({
observation,
@@ -281,7 +277,6 @@ function WatchFeedScannerLink({
scannerName: string
scannerType: ScannerType | undefined
}): JSX.Element {
- const { setScannerIdsFilter } = useActions(watchFeedLogic)
const verdict = readResult(observation)?.verdict
return (
<Tooltip
@@ -294,14 +289,14 @@ function WatchFeedScannerLink({
{typeof verdict === 'string' && verdict ? ` Answered ${verdict}.` : ''}
</span>
)}
- <span className="italic">Click to show only this scanner's sessions</span>
+ <span className="italic">Click to open this scanner</span>
</div>
}
>
- <button
- type="button"
- onClick={() => setScannerIdsFilter([observation.scanner_id])}
- className="relative z-10 flex max-w-full min-w-0 cursor-pointer items-center gap-2 self-start text-sm text-secondary hover:text-default"
+ <Link
+ to={urls.replayVision(observation.scanner_id)}
+ subtle
+ className="relative z-10 flex max-w-full min-w-0 items-center gap-2 self-start text-sm text-secondary hover:text-default"
data-attr="vision-watch-feed-scanner-chip"
>
{scannerType && (
@@ -313,7 +308,7 @@ function WatchFeedScannerLink({
</LemonTag>
)}
<span className="truncate font-medium">{scannerName}</span>
- </button>
+ </Link>
</Tooltip>
)
}
@@ -356,10 +351,10 @@ export function watchFeedRowTitle(observation: ReplayObservationApi, reason: Wat
}
/**
- * One feed row, laid out like a video search result: a large key-moment poster, then a title, the
- * reason Jev picked the session when it gave one, the scanner, and the person and time. Both ranker
- * arms render it, so the experiment compares rankings, not layouts. The whole row opens the
- * observation page, which starts the player at the key moment.
+ * One feed row, laid out as a post: who and where on top, then the title and the reason it was
+ * picked, then the key-moment poster and a button that starts the player there. Every ranker arm
+ * renders it, so the experiment compares rankings, not layouts. The whole card opens the
+ * observation page.
*/
export function WatchFeedRow({ item, position }: WatchFeedRowProps): JSX.Element {
const { observation, reason } = item
@@ -391,20 +386,25 @@ export function WatchFeedRow({ item, position }: WatchFeedRowProps): JSX.Element
})
}
return (
- <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" />
- {!observation.viewed && (
- <UnviewedObservationTag className="absolute top-2 left-2 z-10 pointer-events-none" />
- )}
- {keyMomentMs !== null && (
- <span className="absolute bottom-2 right-2 z-10 rounded bg-black/70 px-1.5 text-xs tabular-nums text-white">
- {colonDelimitedDuration(Math.floor(keyMomentMs / 1000), null)}
- </span>
- )}
- </div>
- <div className="flex min-w-0 flex-1 flex-col gap-2 pt-0.5">
+ <article
+ ref={rowRef}
+ className="group relative flex min-w-0 flex-col gap-3 rounded-lg border bg-surface-primary p-4 hover:border-accent focus-within:border-accent"
+ data-attr="vision-watch-feed-row"
+ >
+ <header className="flex min-w-0 items-center gap-2">
+ <WatchFeedScannerLink observation={observation} scannerName={scannerName} scannerType={scannerType} />
+ <span className="text-xs text-muted" aria-hidden>
+ ·
+ </span>
+ <div className="min-w-0 flex-1">
+ <WatchCardPerson observation={observation} person={person} />
+ </div>
+ <WatchFeedDismissButton
+ className="relative z-10 shrink-0"
+ onDismiss={(dismissalReason) => dismissItem(item, position, dismissalReason)}
+ />
+ </header>
+ <div className="flex min-w-0 flex-col gap-1">
<Link
to={observationUrl}
onClick={captureOpened}
@@ -419,30 +419,39 @@ export function WatchFeedRow({ item, position }: WatchFeedRowProps): JSX.Element
{title}
</h3>
</Link>
- <WatchFeedScannerLink observation={observation} scannerName={scannerName} scannerType={scannerType} />
- <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">
- <LemonDivider className="m-0 w-36" />
- <p className="m-0 flex items-start gap-1.5 text-sm text-secondary">
- <Tooltip title="Why this recording">
- <span className="mt-0.5 flex shrink-0">
- <IconFlag className="text-accent" aria-hidden />
- </span>
- </Tooltip>
- <span className="line-clamp-2">
- <span className="sr-only">Why this recording: </span>
- {watchFeedRowWhy(reason)}
+ <p className="m-0 flex items-start gap-1.5 text-sm text-secondary" data-attr="vision-watch-feed-why">
+ <Tooltip title="Why this recording">
+ <span className="mt-0.5 flex shrink-0">
+ <IconFlag className="text-accent" aria-hidden />
</span>
- </p>
- </div>
+ </Tooltip>
+ <span className="line-clamp-3">
+ <span className="sr-only">Why this recording: </span>
+ {watchFeedRowWhy(reason)}
+ </span>
+ </p>
</div>
+ {/* Clicks pass through the poster to the card's link, which sits beneath it. */}
+ <div className="pointer-events-none relative overflow-hidden rounded-md border">
+ {!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" />
+ {!observation.viewed && <UnviewedObservationTag className="absolute top-2 left-2 z-10" />}
+ </div>
+ <footer className="flex items-center gap-2">
+ <LemonButton
+ type="secondary"
+ size="small"
+ icon={<IconPlayFilled />}
+ to={observationUrl}
+ onClick={captureOpened}
+ className="relative z-10"
+ data-attr="vision-watch-feed-row-watch"
+ >
+ {keyMomentMs !== null
+ ? `Watch from ${colonDelimitedDuration(Math.floor(keyMomentMs / 1000), null)}`
+ : 'Watch session'}
+ </LemonButton>
+ </footer>
</article>
)
}
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchFeedEmptyState.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchFeedEmptyState.tsx
index 4f5b79a1a4e6..8e28086233a1 100644
--- a/products/replay_vision/frontend/replay_scanners/components/WatchFeedEmptyState.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchFeedEmptyState.tsx
@@ -23,7 +23,7 @@ function DashedNote({ children }: { children: React.ReactNode }): JSX.Element {
* that would actually fill the feed, so a reader is never told to wait on scanners that cannot run.
*/
export function WatchFeedEmptyState({ reason }: { reason: WatchFeedEmptyReason }): JSX.Element {
- const { clearFeedFilters } = useActions(watchFeedLogic)
+ const { setOnlyMyScanners } = useActions(watchFeedLogic)
const { scanners } = useValues(visionScannersListLogic)
const { push } = useActions(router)
@@ -95,9 +95,9 @@ export function WatchFeedEmptyState({ reason }: { reason: WatchFeedEmptyReason }
if (reason === 'filtered') {
return (
<DashedNote>
- <span>No clips match these filters in this window.</span>
- <LemonButton type="secondary" size="small" onClick={() => clearFeedFilters()}>
- Clear filters
+ <span>Your scanners picked nothing in this window.</span>
+ <LemonButton type="secondary" size="small" onClick={() => setOnlyMyScanners(false)}>
+ Show all scanners
</LemonButton>
</DashedNote>
)
diff --git a/products/replay_vision/frontend/replay_scanners/components/WatchFeedTab.tsx b/products/replay_vision/frontend/replay_scanners/components/WatchFeedTab.tsx
index 61c4febaf26b..b2e582ed974f 100644
--- a/products/replay_vision/frontend/replay_scanners/components/WatchFeedTab.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/WatchFeedTab.tsx
@@ -2,43 +2,25 @@ import { useActions, useValues } from 'kea'
import { useEffect } from 'react'
import { useInView } from 'react-intersection-observer'
-import { IconSearch } from '@posthog/icons'
-import { LemonButton, LemonInput, LemonSkeleton } from '@posthog/lemon-ui'
+import { IconChevronDown } from '@posthog/icons'
+import { LemonButton, LemonMenu, LemonSkeleton, LemonTabs } from '@posthog/lemon-ui'
-import { DateFilter } from 'lib/components/DateFilter/DateFilter'
-import { MemberSelectMultiplePopover } from 'lib/components/MemberSelectMultiplePopover'
-import { dateMapping } from 'lib/utils/dateFilters'
-import { pluralize } from 'lib/utils/strings'
-
-import { FilterPill } from '../../components/FilterPill'
-import { visionScannersListLogic } from '../../logics/visionScannersListLogic'
-import { SCANNER_TYPE_OPTIONS, ScannerType } from '../types'
import { watchFeedLogic } from '../watchFeedLogic'
import { FILLER_REASON_KINDS, WatchFeedRow } from './WatchFeedCard'
import { WatchFeedEmptyState } from './WatchFeedEmptyState'
-const TYPE_OPTIONS: { value: ScannerType; label: string }[] = SCANNER_TYPE_OPTIONS.map(({ value, label }) => ({
- value,
- label,
-}))
-
-// The endpoint caps the window at 90 days and rejects "All time" style bounds, so offer only ranges it accepts.
-const FEED_DATE_OPTION_KEYS = new Set([
- 'Today',
- 'Yesterday',
- 'Last 24 hours',
- 'Last 7 days',
- 'Last 14 days',
- 'Last 30 days',
- 'Last 90 days',
-])
-const FEED_DATE_OPTIONS = dateMapping.filter((option) => FEED_DATE_OPTION_KEYS.has(option.key))
+const FEED_DATE_OPTIONS = [
+ { value: '-24h', label: 'Last 24 hours' },
+ { value: '-7d', label: 'Last 7 days' },
+ { value: '-30d', label: 'Last 30 days' },
+ { value: '-90d', label: 'Last 90 days' },
+]
function FeedSkeleton(): JSX.Element {
return (
- <div className="flex flex-col gap-3" aria-busy>
+ <div className="mx-auto flex w-full max-w-xl flex-col gap-4" aria-busy>
{[0, 1, 2].map((i) => (
- <LemonSkeleton key={i} className="h-32 rounded" />
+ <LemonSkeleton key={i} className="h-80 rounded-lg" />
))}
</div>
)
@@ -70,7 +52,7 @@ function FeedEnd({ itemCount }: { itemCount: number }): JSX.Element | null {
if (feedHasMore) {
return (
<div ref={ref} aria-busy>
- <LemonSkeleton className="h-32 rounded" />
+ <LemonSkeleton className="h-80 rounded-lg" />
</div>
)
}
@@ -82,121 +64,55 @@ function FeedEnd({ itemCount }: { itemCount: number }): JSX.Element | null {
}
export function WatchFeedTab(): JSX.Element {
- const {
- feedItems,
- feedItemsLoading,
- feedLoad,
- feedFailed,
- dateFrom,
- dateTo,
- scannerTypeFilter,
- scannerIdsFilter,
- tagsFilter,
- tagOptions,
- createdByFilter,
- search,
- hasFeedFilters,
- emptyReason,
- } = useValues(watchFeedLogic)
- const {
- setDateRange,
- setScannerTypeFilter,
- setScannerIdsFilter,
- setTagsFilter,
- setCreatedByFilter,
- setSearch,
- clearFeedFilters,
- loadFeed,
- } = useActions(watchFeedLogic)
- const { scanners: allScanners } = useValues(visionScannersListLogic)
- const scannerOptions = allScanners.map((scanner) => ({
- value: scanner.id,
- label: scanner.name || '(untitled)',
- }))
+ const { feedItems, feedItemsLoading, feedLoad, feedFailed, dateFrom, onlyMyScanners, emptyReason } =
+ useValues(watchFeedLogic)
+ const { setDateFrom, setOnlyMyScanners, loadFeed } = useActions(watchFeedLogic)
const items = feedItems ?? []
- // Only the scanner picker narrows *which* scanners are in scope; the others narrow within them.
- const narrowedToScanners =
- scannerIdsFilter.length > 0 && scannerIdsFilter.length < allScanners.length ? scannerIdsFilter.length : 0
- const scannerCount = new Set(items.map((item) => item.observation.scanner_id)).size
// Every card carrying a no-evidence reason means the window produced no findings. A feed that mixes a
// finding with padding needs no explaining, so this stays off unless the whole feed is padding.
const onlyFiller = items.length > 0 && items.every((item) => FILLER_REASON_KINDS.has(item.reason.kind))
return (
<div className="@container flex flex-col gap-4">
- <div className="flex flex-wrap items-end justify-between gap-2">
- <div className="flex flex-col gap-1 flex-1 min-w-[16rem]">
- <h2 className="text-xl font-semibold m-0">What to watch</h2>
- <p className="text-muted text-sm m-0">
- {narrowedToScanners > 0
- ? `Following ${pluralize(narrowedToScanners, 'scanner')} of ${allScanners.length}. `
- : ''}
- {items.length > 0
- ? `Picked from ${pluralize(scannerCount, 'scanner')} in this window. Each session opens at the moment its scan cites.`
- : 'The observations most worth a look, picked across your scanners.'}
- </p>
- </div>
- <div className="flex flex-wrap items-center gap-2">
- <LemonInput
- type="search"
- placeholder="Search sessions..."
- value={search}
- onChange={setSearch}
- prefix={<IconSearch />}
- className="max-w-xs"
- data-attr="vision-watch-feed-search"
- />
- <FilterPill<string>
- label="Scanners"
- dataAttr="vision-watch-feed-scanners-filter"
- searchable
- searchPlaceholder="Search scanners..."
- selectAllLabel="All scanners"
- options={scannerOptions}
- value={scannerIdsFilter}
- onChange={setScannerIdsFilter}
- />
- <span data-attr="vision-watch-feed-created-by-filter">
- <MemberSelectMultiplePopover
- value={createdByFilter.map(Number)}
- onChange={(ids) => setCreatedByFilter(ids.map(String))}
- />
- </span>
- <FilterPill<string>
- label="Tags"
- dataAttr="vision-watch-feed-tags-filter"
- searchable
- options={tagOptions}
- value={tagsFilter}
- onChange={setTagsFilter}
- />
- <FilterPill<ScannerType>
- label="Type"
- dataAttr="vision-watch-feed-type-filter"
- options={TYPE_OPTIONS}
- value={scannerTypeFilter ? [scannerTypeFilter] : []}
- onChange={(values) => setScannerTypeFilter(values[values.length - 1] ?? null)}
- />
- <DateFilter
- dateFrom={dateFrom}
- dateTo={dateTo}
- dateOptions={FEED_DATE_OPTIONS}
- showRollingRangePicker={false}
- onChange={(from, to) => setDateRange(from ?? null, to ?? null)}
- />
- {hasFeedFilters && (
- <LemonButton type="tertiary" size="small" onClick={() => clearFeedFilters()}>
- Clear filters
+ <p className="mx-auto w-full max-w-xl text-sm text-secondary m-0 -mb-2">
+ Sessions that stand out in your scanner results.
+ </p>
+ <LemonTabs
+ size="small"
+ // The small size packs tabs two units apart below md, too tight for two labels this long.
+ className="mx-auto w-full max-w-xl -mb-2 [&_ul>div]:gap-x-6"
+ activeKey={onlyMyScanners ? 'mine' : 'all'}
+ onChange={(key) => setOnlyMyScanners(key === 'mine')}
+ data-attr="vision-watch-feed-scope"
+ tabs={[
+ { key: 'all', label: 'All scanners', 'data-attr': 'vision-watch-feed-scope-all' },
+ { key: 'mine', label: 'My scanners', 'data-attr': 'vision-watch-feed-scope-mine' },
+ ]}
+ rightSlotClassName="bg-transparent pr-0"
+ rightSlot={
+ <LemonMenu
+ items={FEED_DATE_OPTIONS.map((option) => ({
+ label: option.label,
+ active: option.value === dateFrom,
+ onClick: () => setDateFrom(option.value),
+ }))}
+ >
+ <LemonButton
+ size="small"
+ type="tertiary"
+ sideIcon={<IconChevronDown />}
+ data-attr="vision-watch-feed-range"
+ >
+ {FEED_DATE_OPTIONS.find((option) => option.value === dateFrom)?.label ?? dateFrom}
</LemonButton>
- )}
- </div>
- </div>
-
+ </LemonMenu>
+ }
+ />
{feedItemsLoading && feedItems === null ? (
<FeedSkeleton />
) : (
- <div className="flex flex-col gap-3">
+ <div className="mx-auto flex w-full max-w-xl flex-col gap-4">
{/* kea-loaders keeps the last value on failure, so a later filter or date change can fail
with cards still on screen. Show the error above them rather than replacing them. */}
{feedFailed && (
diff --git a/products/replay_vision/frontend/replay_scanners/watchFeedLogic.test.ts b/products/replay_vision/frontend/replay_scanners/watchFeedLogic.test.ts
index 36070a64e372..d60b2bffef04 100644
--- a/products/replay_vision/frontend/replay_scanners/watchFeedLogic.test.ts
+++ b/products/replay_vision/frontend/replay_scanners/watchFeedLogic.test.ts
@@ -1,9 +1,9 @@
import { waitFor } from '@testing-library/react'
-import { router } from 'kea-router'
import { expectLogic } from 'kea-test-utils'
import posthog from 'posthog-js'
import { lemonToast } from 'lib/lemon-ui/LemonToast'
+import { userLogic } from 'scenes/userLogic'
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
@@ -59,112 +59,25 @@ describe('watchFeedLogic', () => {
{ results: [item('o1', 'jev_watchable')], ranker: 'jev', ranker_variant: 'jev' },
])
await expectLogic(logic, () => {
- logic.actions.setScannerTypeFilter('monitor')
+ logic.actions.setOnlyMyScanners(true)
})
.toDispatchActions(['loadFeed', 'loadFeedSuccess'])
.toFinishAllListeners()
const lastUrl = new URL(feedSpy.mock.calls.at(-1)[0].request.url)
- expect(lastUrl.searchParams.get('scanner_type')).toBe('monitor')
+ expect(lastUrl.searchParams.get('created_by')).toBe(String(userLogic.values.user?.id))
// The response names the ranker that ordered the feed, and the feed-viewed event reports the
// project's variant, which is the exposure the experiment counts.
expect(logic.values.feedRanker).toBe('jev')
expect(lastFeedViewed()).toMatchObject({ ranker: 'jev', '$feature/vision-watch-feed-ranker': 'jev' })
await expectLogic(logic, () => {
- logic.actions.setDateRange('-30d', null)
+ logic.actions.setDateFrom('-30d')
})
.toDispatchActions(['loadFeed', 'loadFeedSuccess'])
.toFinishAllListeners()
expect(new URL(feedSpy.mock.calls.at(-1)[0].request.url).searchParams.get('date_from')).toBe('-30d')
})
- it('sends scanner, tag and search filters, and keeps persisted picks on a filterless URL', async () => {
- logic.mount()
- await expectLogic(logic).toDispatchActions(['loadFeedSuccess']).toFinishAllListeners()
-
- await expectLogic(logic, () => {
- logic.actions.setScannerIdsFilter(['scanner-a', 'scanner-b'])
- })
- .toDispatchActions(['loadFeedSuccess'])
- .toFinishAllListeners()
- let params = new URL(feedSpy.mock.calls.at(-1)[0].request.url).searchParams
- expect(params.get('scanner_ids')).toBe('scanner-a,scanner-b')
-
- await expectLogic(logic, () => {
- logic.actions.setTagsFilter(['checkout'])
- })
- .toDispatchActions(['loadFeedSuccess'])
- .toFinishAllListeners()
- params = new URL(feedSpy.mock.calls.at(-1)[0].request.url).searchParams
- expect(params.get('tags')).toBe('checkout')
-
- await expectLogic(logic, () => {
- logic.actions.setCreatedByFilter(['7', '12'])
- })
- .toDispatchActions(['loadFeedSuccess'])
- .toFinishAllListeners()
- params = new URL(feedSpy.mock.calls.at(-1)[0].request.url).searchParams
- expect(params.get('created_by')).toBe('7,12')
-
- await expectLogic(logic, () => {
- logic.actions.setSearch(' coupon ')
- })
- .toDispatchActions(['loadFeedSuccess'])
- .toFinishAllListeners()
- expect(new URL(feedSpy.mock.calls.at(-1)[0].request.url).searchParams.get('search')).toBe('coupon')
-
- // A URL with no feed params must not silently widen the reader's feed back to every scanner.
- await expectLogic(logic, () => {
- router.actions.push('/replay-vision')
- }).toFinishAllListeners()
- expect(logic.values.scannerIdsFilter).toEqual(['scanner-a', 'scanner-b'])
- })
-
- it('restores a shared link as a full snapshot, clearing filters it omits', async () => {
- logic.mount()
- await expectLogic(logic).toDispatchActions(['loadFeedSuccess']).toFinishAllListeners()
-
- await expectLogic(logic, () => {
- logic.actions.setScannerIdsFilter(['scanner-a'])
- logic.actions.setCreatedByFilter(['7'])
- })
- .toDispatchActions(['loadFeedSuccess'])
- .toFinishAllListeners()
-
- // A link that names only tags is a full snapshot: tags apply and the remembered scanner and creator
- // clear, in a single load, so the same link shows the same feed to every recipient.
- await expectLogic(logic, () => {
- router.actions.push('/replay-vision?feed_tags=checkout')
- })
- .toDispatchActions(['restoreFeedFilters', 'loadFeed', 'loadFeedSuccess'])
- .toFinishAllListeners()
- expect(logic.values.tagsFilter).toEqual(['checkout'])
- expect(logic.values.scannerIdsFilter).toEqual([])
- expect(logic.values.createdByFilter).toEqual([])
- const params = new URL(feedSpy.mock.calls.at(-1)[0].request.url).searchParams
- expect(params.get('tags')).toBe('checkout')
- expect(params.get('scanner_ids')).toBeNull()
- expect(params.get('created_by')).toBeNull()
- })
-
- it('clears every filter at once', async () => {
- logic.mount()
- logic.actions.setScannerIdsFilter(['scanner-a'])
- logic.actions.setTagsFilter(['checkout'])
- logic.actions.setCreatedByFilter(['7'])
- await expectLogic(logic, () => {
- logic.actions.clearFeedFilters()
- })
- .toMatchValues({
- scannerIdsFilter: [],
- tagsFilter: [],
- createdByFilter: [],
- search: '',
- hasFeedFilters: false,
- })
- .toFinishAllListeners()
- })
-
it('names the empty reason only once the fleet and budget have answered', async () => {
feedSpy.mockImplementation(() => [200, { results: [] }])
useMocks({
@@ -202,7 +115,7 @@ describe('watchFeedLogic', () => {
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()
+ await expectLogic(logic, () => logic.actions.setDateFrom('-30d')).toFinishAllListeners()
const undo = jest.mocked(lemonToast.success).mock.calls.at(-1)?.[1]?.button?.action
expect(undo).toBeTruthy()
await undo?.()
@@ -266,9 +179,7 @@ describe('watchFeedLogic', () => {
)
logic.actions.loadMoreFeed({})
// Waiting for every listener would wait on the held page too, so wait for the new load alone.
- await expectLogic(logic, () => logic.actions.setScannerTypeFilter('monitor')).toDispatchActions([
- 'loadFeedSuccess',
- ])
+ await expectLogic(logic, () => logic.actions.setDateFrom('-30d')).toDispatchActions(['loadFeedSuccess'])
failPage()
await expectLogic(logic).toFinishAllListeners()
diff --git a/products/replay_vision/frontend/replay_scanners/watchFeedLogic.ts b/products/replay_vision/frontend/replay_scanners/watchFeedLogic.ts
index 057f941b42b6..61b5bc1a651c 100644
--- a/products/replay_vision/frontend/replay_scanners/watchFeedLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/watchFeedLogic.ts
@@ -1,26 +1,20 @@
import { MakeLogicType, actions, afterMount, connect, kea, listeners, path, reducers, selectors } from 'kea'
import { loaders } from 'kea-loaders'
-import { router, urlToAction } from 'kea-router'
-import { trackedActionToUrl } from 'lib/logic/scenes/trackedActionToUrl'
+import { FEATURE_FLAGS } from 'lib/constants'
import posthog from 'lib/posthog-typed'
import { getCurrentTeamIdOrNone } from 'lib/utils/getAppContext'
-import { objectsEqual } from 'lib/utils/objects'
import { teamLogic } from 'scenes/teamLogic'
-import { urls } from 'scenes/urls'
-
-import { tagsModel } from '~/models/tagsModel'
+import { userLogic } from 'scenes/userLogic'
+import type { UserType } from '../../../../frontend/src/types'
import { visionScannersWatchFeedRetrieve } from '../generated/api'
import type { ReplayScannerApi, VisionQuotaApi, WatchFeedResponseApi } from '../generated/api.schemas'
import type { VisionScannersWatchFeedRetrieveParams, WatchFeedItemApi } from '../generated/api.schemas'
-import type { ScannerTypeEnumApi } from '../generated/api.schemas'
import type { WatchFeedRankerEnumApi } 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 { recordFeedImpressions } from './watchFeedImpressionCounts'
@@ -35,14 +29,12 @@ import {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface watchFeedLogicValues {
- allTags: string[] // tagsModel
+ user: UserType | null // userLogic
quota: VisionQuotaApi | null // visionQuotaLogic
quotaLoading: boolean // visionQuotaLogic
scanners: ReplayScannerApi[] // visionScannersListLogic
scannersLoading: boolean // visionScannersListLogic
- createdByFilter: string[]
dateFrom: string
- dateTo: string | null
emptyReason: WatchFeedEmptyReason | null
feedAsOf: string | null
feedFailed: boolean
@@ -54,22 +46,11 @@ export interface watchFeedLogicValues {
feedRanker: WatchFeedRanker
feedRankerVariant: string | null
feedServed: number
- hasFeedFilters: boolean
- scannerIdsFilter: string[]
- scannerTypeFilter: ScannerType | null
- search: string
- tagOptions: {
- label: string
- value: string
- }[]
- tagsFilter: string[]
+ onlyMyScanners: boolean
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface watchFeedLogicActions {
- loadTags: () => {
- value: true
- } // tagsModel
cardSeen: (
item: WatchFeedItemApi,
position: number
@@ -77,9 +58,6 @@ export interface watchFeedLogicActions {
item: WatchFeedItemApi
position: number
}
- clearFeedFilters: () => {
- value: true
- }
dismissItem: (
item: WatchFeedItemApi,
position: number,
@@ -128,17 +106,6 @@ export interface watchFeedLogicActions {
feedItems: WatchFeedItemApi[] | null
payload?: any
}
- restoreFeedFilters: (
- search: string,
- scannerIds: string[],
- tags: string[],
- createdBy: string[]
- ) => {
- createdBy: string[]
- scannerIds: string[]
- search: string
- tags: string[]
- }
restoreItem: (
item: WatchFeedItemApi,
position: number
@@ -146,15 +113,8 @@ export interface watchFeedLogicActions {
item: WatchFeedItemApi
position: number
}
- setCreatedByFilter: (userIds: string[]) => {
- userIds: string[]
- }
- setDateRange: (
- dateFrom: string | null,
- dateTo: string | null
- ) => {
- dateFrom: string | null
- dateTo: string | null
+ setDateFrom: (dateFrom: string) => {
+ dateFrom: string
}
setFeedLoad: (load: WatchFeedLoad) => {
load: WatchFeedLoad
@@ -175,17 +135,8 @@ export interface watchFeedLogicActions {
ranker: WatchFeedRankerEnumApi
variant: string | null
}
- setScannerIdsFilter: (scannerIds: string[]) => {
- scannerIds: string[]
- }
- setScannerTypeFilter: (scannerType: ScannerType | null) => {
- scannerType: ScannerTypeEnumApi | null
- }
- setSearch: (search: string) => {
- search: string
- }
- setTagsFilter: (tags: string[]) => {
- tags: string[]
+ setOnlyMyScanners: (onlyMyScanners: boolean) => {
+ onlyMyScanners: boolean
}
}
@@ -197,22 +148,8 @@ export interface watchFeedLogicMeta {
scannersLoading: boolean,
quota: VisionQuotaApi | null,
quotaLoading: boolean,
- hasFeedFilters: boolean
+ onlyMyScanners: boolean
) => WatchFeedEmptyReason | null
- hasFeedFilters: (
- scannerIdsFilter: string[],
- tagsFilter: string[],
- createdByFilter: string[],
- scannerTypeFilter: ScannerTypeEnumApi | null,
- search: string
- ) => boolean
- tagOptions: (
- allTags: string[],
- tagsFilter: string[]
- ) => {
- label: string
- value: string
- }[]
}
}
@@ -230,30 +167,10 @@ export const FEED_PAGE_SIZE = 20
* team, not the viewer), so the client reads it from the response instead of checking the flag. */
export type WatchFeedRanker = WatchFeedResponseApi['ranker']
-/** The ranker experiment's flag. The server decides its variant per project, so the client can't
- * evaluate it and reports the variant the response carries instead. */
-const WATCH_FEED_RANKER_FLAG = 'vision-watch-feed-ranker'
-
function feedParams(values: watchFeedLogicValues): VisionScannersWatchFeedRetrieveParams {
const params: VisionScannersWatchFeedRetrieveParams = { date_from: values.dateFrom, limit: FEED_PAGE_SIZE }
- if (values.dateTo) {
- params.date_to = values.dateTo
- }
- if (values.scannerTypeFilter) {
- params.scanner_type = values.scannerTypeFilter
- }
- if (values.scannerIdsFilter.length > 0) {
- params.scanner_ids = values.scannerIdsFilter.join(',')
- }
- if (values.tagsFilter.length > 0) {
- params.tags = values.tagsFilter.join(',')
- }
- if (values.createdByFilter.length > 0) {
- params.created_by = values.createdByFilter.join(',')
- }
- const trimmedSearch = values.search.trim()
- if (trimmedSearch) {
- params.search = trimmedSearch
+ if (values.onlyMyScanners && values.user) {
+ params.created_by = String(values.user.id)
}
return params
}
@@ -261,12 +178,7 @@ function feedParams(values: watchFeedLogicValues): VisionScannersWatchFeedRetrie
function reportFiltered(values: watchFeedLogicValues): void {
posthog.capture('replay_vision_watch_feed_filtered', {
date_from: values.dateFrom,
- date_to: values.dateTo,
- scanner_type: values.scannerTypeFilter,
- scanner_ids_count: values.scannerIdsFilter.length,
- tags_count: values.tagsFilter.length,
- created_by_count: values.createdByFilter.length,
- has_search: values.search.trim().length > 0,
+ only_my_scanners: values.onlyMyScanners,
})
}
@@ -276,8 +188,8 @@ export const watchFeedLogic = kea<watchFeedLogicType>([
connect(() => ({
values: [
- tagsModel,
- ['tags as allTags'],
+ userLogic,
+ ['user'],
// An empty feed cannot be explained from the feed alone: the reason lives in the fleet's
// state and the org's budget.
visionScannersListLogic,
@@ -285,25 +197,11 @@ export const watchFeedLogic = kea<watchFeedLogicType>([
visionQuotaLogic,
['quota', 'quotaLoading'],
],
- actions: [tagsModel, ['loadTags']],
})),
actions({
- setDateRange: (dateFrom: string | null, dateTo: string | null) => ({ dateFrom, dateTo }),
- setScannerTypeFilter: (scannerType: ScannerType | null) => ({ scannerType }),
- setSearch: (search: string) => ({ search }),
- setScannerIdsFilter: (scannerIds: string[]) => ({ scannerIds }),
- setTagsFilter: (tags: string[]) => ({ tags }),
- setCreatedByFilter: (userIds: string[]) => ({ userIds }),
- // Restores every shared-link filter at once so one request runs and every recipient sees the
- // same feed, regardless of the scanner/tag selections their browser remembered.
- restoreFeedFilters: (search: string, scannerIds: string[], tags: string[], createdBy: string[]) => ({
- search,
- scannerIds,
- tags,
- createdBy,
- }),
- clearFeedFilters: true,
+ setDateFrom: (dateFrom: string) => ({ dateFrom }),
+ setOnlyMyScanners: (onlyMyScanners: boolean) => ({ onlyMyScanners }),
loadFeed: true,
setFeedRanker: (ranker: WatchFeedRanker, variant: string | null) => ({ ranker, variant }),
setFeedLoad: (load: WatchFeedLoad) => ({ load }),
@@ -432,59 +330,15 @@ export const watchFeedLogic = kea<watchFeedLogicType>([
dateFrom: [
DEFAULT_FEED_DATE_FROM,
{
- setDateRange: (_, { dateFrom }) => dateFrom ?? DEFAULT_FEED_DATE_FROM,
+ setDateFrom: (_, { dateFrom }) => dateFrom,
},
],
- dateTo: [
- null as string | null,
- {
- setDateRange: (_, { dateTo }) => dateTo,
- },
- ],
- scannerTypeFilter: [
- null as ScannerType | null,
- {
- setScannerTypeFilter: (_, { scannerType }) => scannerType,
- clearFeedFilters: () => null,
- },
- ],
- search: [
- '',
- {
- setSearch: (_, { search }) => search,
- restoreFeedFilters: (_, { search }) => search,
- clearFeedFilters: () => '',
- },
- ],
- // Persisted so a team with many scanners lands on the ones they follow instead of the whole
- // fleet on every visit. Keyed by team so a selection made on one team never carries into
- // another team's feed, where those scanner ids do not exist and would hide every result.
- // Browser-local until per-user pins exist, so it does not cross devices.
- scannerIdsFilter: [
- [] as string[],
- { persist: true, prefix: `${getCurrentTeamIdOrNone() ?? 'unknown'}__` },
- {
- setScannerIdsFilter: (_, { scannerIds }) => scannerIds,
- restoreFeedFilters: (_, { scannerIds }) => scannerIds,
- clearFeedFilters: () => [],
- },
- ],
- tagsFilter: [
- [] as string[],
- { persist: true, prefix: `${getCurrentTeamIdOrNone() ?? 'unknown'}__` },
- {
- setTagsFilter: (_, { tags }) => tags,
- restoreFeedFilters: (_, { tags }) => tags,
- clearFeedFilters: () => [],
- },
- ],
- createdByFilter: [
- [] as string[],
+ // Keyed by team, so the choice made on one team does not carry into another team's feed.
+ onlyMyScanners: [
+ false,
{ persist: true, prefix: `${getCurrentTeamIdOrNone() ?? 'unknown'}__` },
{
- setCreatedByFilter: (_, { userIds }) => userIds,
- restoreFeedFilters: (_, { createdBy }) => createdBy,
- clearFeedFilters: () => [],
+ setOnlyMyScanners: (_, { onlyMyScanners }) => onlyMyScanners,
},
],
feedFailed: [
@@ -533,37 +387,11 @@ export const watchFeedLogic = kea<watchFeedLogicType>([
restore: () => values.feedLoad?.feedLoadId === loadId && actions.restoreItem(item, position),
})
},
- setDateRange: () => {
- reportFiltered(values)
- actions.loadFeed()
- },
- setScannerTypeFilter: () => {
- reportFiltered(values)
- actions.loadFeed()
- },
- setScannerIdsFilter: () => {
- reportFiltered(values)
- actions.loadFeed()
- },
- setTagsFilter: () => {
- reportFiltered(values)
- actions.loadFeed()
- },
- setCreatedByFilter: () => {
- reportFiltered(values)
- actions.loadFeed()
- },
- clearFeedFilters: () => {
+ setDateFrom: () => {
reportFiltered(values)
actions.loadFeed()
},
- setSearch: async (_, breakpoint) => {
- // Debounce keystrokes; a shared-link restore loads once through restoreFeedFilters instead.
- await breakpoint(300)
- reportFiltered(values)
- actions.loadFeed()
- },
- restoreFeedFilters: () => {
+ setOnlyMyScanners: () => {
reportFiltered(values)
actions.loadFeed()
},
@@ -583,7 +411,7 @@ export const watchFeedLogic = kea<watchFeedLogicType>([
ranker: values.feedRanker,
// The ranker experiment counts this event as its exposure, so it carries the project's variant.
...(values.feedRankerVariant
- ? { [`$feature/${WATCH_FEED_RANKER_FLAG}`]: values.feedRankerVariant }
+ ? { [`$feature/${FEATURE_FLAGS.VISION_WATCH_FEED_RANKER}`]: values.feedRankerVariant }
: {}),
signal_share: items.length > 0 ? (countByReasonKind.signal_emitted ?? 0) / items.length : 0,
// Which dead end the reader hit, so the empty screens can be counted and ranked
@@ -596,95 +424,26 @@ export const watchFeedLogic = kea<watchFeedLogicType>([
selectors({
/** Null until both probes answer, so an empty screen is never drawn from unresolved data. */
emptyReason: [
- (s) => [s.scanners, s.scannersLoading, s.quota, s.quotaLoading, s.hasFeedFilters],
+ (s) => [s.scanners, s.scannersLoading, s.quota, s.quotaLoading, s.onlyMyScanners],
(
scanners: ReplayScannerApi[],
scannersLoading: boolean,
quota: VisionQuotaApi | null,
quotaLoading: boolean,
- hasFeedFilters: boolean
+ onlyMyScanners: boolean
): WatchFeedEmptyReason | null =>
scannersLoading || quotaLoading
? null
: // The feed does not say anything about recording being off; that card lives in the picks column.
- resolveWatchFeedEmptyReason({ scanners, quota, sessionRecordingOptIn: null, hasFeedFilters }),
- ],
- hasFeedFilters: [
- (s) => [s.scannerIdsFilter, s.tagsFilter, s.createdByFilter, s.scannerTypeFilter, s.search],
- (
- scannerIds: string[],
- tags: string[],
- createdBy: string[],
- scannerType: ScannerType | null,
- search: string
- ): boolean =>
- scannerIds.length > 0 ||
- tags.length > 0 ||
- createdBy.length > 0 ||
- !!scannerType ||
- search.trim().length > 0,
- ],
- tagOptions: [
- (s) => [s.allTags, s.tagsFilter],
- (allTags: string[], tagsFilter: string[]): { value: string; label: string }[] =>
- // Keep a tag restored from a shared link selectable even when the team list doesn't know it.
- Array.from(new Set([...allTags.filter((tag) => !tag.includes(',')), ...tagsFilter]))
- .sort()
- .map((tag) => ({ value: tag, label: tag })),
+ resolveWatchFeedEmptyReason({
+ scanners,
+ quota,
+ sessionRecordingOptIn: null,
+ hasFeedFilters: onlyMyScanners,
+ }),
],
}),
- trackedActionToUrl(({ values }) => {
- const buildUrl = (): [string, Record<string, string | undefined>, undefined, { replace: true }] => [
- urls.replayVision(),
- {
- ...router.values.searchParams,
- feed_search: values.search.trim() || undefined,
- feed_scanners: csvParam(values.scannerIdsFilter),
- feed_tags: csvParam(values.tagsFilter),
- feed_created_by: csvParam(values.createdByFilter),
- },
- undefined,
- { replace: true },
- ]
- return {
- setSearch: buildUrl,
- setScannerIdsFilter: buildUrl,
- setTagsFilter: buildUrl,
- setCreatedByFilter: buildUrl,
- clearFeedFilters: buildUrl,
- }
- }),
-
- urlToAction(({ actions, values }) => ({
- [urls.replayVision()]: (_, searchParams) => {
- // A link that carries any feed_* param is a full filter snapshot, so restore all of them and
- // clear the ones it omits — otherwise the reader's remembered scanner/tag picks would leak
- // in and the same link would show different feeds to different people. A link with no feed_*
- // param leaves those remembered picks alone rather than widening the feed to the whole fleet.
- const hasFeedParams =
- searchParams.feed_search !== undefined ||
- searchParams.feed_scanners !== undefined ||
- searchParams.feed_tags !== undefined ||
- searchParams.feed_created_by !== undefined
- if (!hasFeedParams) {
- return
- }
- const search = typeof searchParams.feed_search === 'string' ? searchParams.feed_search : ''
- const scanners = parseCsvParam(searchParams.feed_scanners)
- const tags = parseCsvParam(searchParams.feed_tags)
- const createdBy = parseCsvParam(searchParams.feed_created_by)
- const unchanged =
- search === values.search &&
- objectsEqual(scanners, values.scannerIdsFilter) &&
- objectsEqual(tags, values.tagsFilter) &&
- objectsEqual(createdBy, values.createdByFilter)
- if (!unchanged) {
- actions.restoreFeedFilters(search, scanners, tags, createdBy)
- }
- },
- })),
-
// The tab content mounts only while the tab is active, so mount is the fetch signal.
afterMount(({ actions, cache }) => {
cache.impressions = new WatchFeedImpressions('feed_tab', (load, ids) =>
@@ -693,7 +452,5 @@ export const watchFeedLogic = kea<watchFeedLogicType>([
// 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()
}),
])