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): test asking for recordings before the prompt in the scanner wizard (#125111)

Kim Svatos Dugane768b93fe848
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 1f7db71eb495..76d478186f96 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -15054,6 +15054,10 @@ snapshots:
hash: v1.k794b7964.e0c4064c632065d2d85178d1022c720ae82c1dc35734e1f3e057cb3967fc6f12.QezpH6V2c3BF8QzeOEYIKHMyIoApGYrqB9S6rKLMxGQ
scenes-app-replay-vision--scanner-editor-goal-overview-long-filters--light:
hash: v1.k794b7964.7a8ee25c52a654a3714bfa0f25ff8e64c5752dd25f878678e9db4a70690e0615.Qm6ln1Dyw24XjxE87KRXp-qqMO0dxdjOrOSvBJvjCZU
+ scenes-app-replay-vision--scanner-editor-goal-overview-recordings-first--dark:
+ hash: v1.k794b7964.63bd74ec2abd193ab3cb0d04509713d41897c883aa6ba25db3c9a271a0cd275d.JqhvghWMvId3J4gZxKzd1vOyBgODIGntn3iHjwFhNiM
+ scenes-app-replay-vision--scanner-editor-goal-overview-recordings-first--light:
+ hash: v1.k794b7964.100ca576d8fbc2e0c19e9e34859d7b6425d3f4518a26d0643cc1f1fad53f4d16.NOL4t1PGpUq4JIzjKuq06FD1dC5smr3FlrZQK5eMiN8
scenes-app-replay-vision--scanner-editor-triggers--dark:
hash: v1.k794b7964.9f1bb49fff5845e0b4fa240c76f160d11f6c3191fd9a70e818f6381ccbf73233.4oEBUb1L-2niWMCoHVODRY57bXqKEUrEnBKF0tdmsCc
scenes-app-replay-vision--scanner-editor-triggers--light:
@@ -15062,6 +15066,10 @@ snapshots:
hash: v1.k794b7964.6840daeb52b0dd348e8c84a00b15ff2b6ad55aa1524644114909f7835cf136e2.uVGB9n2x91ojCZtbjTG75aqwdBbS2H6Du9erZCHGcnc
scenes-app-replay-vision--scanner-editor-triggers-experiment--light:
hash: v1.k794b7964.d4b09a024eb703d39795d30163abcc944075d571d25bdd2487c2240668a8503d.vz8tgcbgNGUkJaO7uOOf1MVey6BKMh7nw5HxBXLNOCc
+ scenes-app-replay-vision--scanner-editor-triggers-recordings-first--dark:
+ hash: v1.k794b7964.cd7dc17b3cc9810b046e482be7ca3e9a7c69704ae1d20f83703d9f2182313e0d.1XoO-LQZMLzrlQZu_bJRaHNWPoQ3ismnZlAKoOQt60I
+ scenes-app-replay-vision--scanner-editor-triggers-recordings-first--light:
+ hash: v1.k794b7964.e6af0d6ae39ce04a5fe9455cfba1b4305c25c650b44c451783d4f70b77a60a09.NWNHU3zZKTcxW-3zh02O6tvXSc1vZ5DKQwcR0PB_TSU
scenes-app-replay-vision--scanner-observations--dark:
hash: v1.k794b7964.a730efb9cf4a682d5618dd924bcc733bdb602478dc338e1511ab0eb1e5fc580a.HMSJ-jDOOMyzClRBvAXqP4EdZDWu_oNBrvObUQPQT3A
scenes-app-replay-vision--scanner-observations--light:
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index a48f7d552a69..a965e912f4e2 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -574,6 +574,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_SCANNER_WIZARD_RECORDINGS_FIRST: 'vision-scanner-wizard-recordings-first', // owner: #team-replay multivariate=control,test, new scanner wizard and goal overview ask which recordings to watch before the prompt; gate on === 'test'
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 d9107fbbe1a1..6808f1cb3d95 100644
--- a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx
+++ b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx
@@ -1,6 +1,6 @@
import { MOCK_DEFAULT_BASIC_USER, MOCK_DEFAULT_USER } from 'lib/api.mock'
-import type { Meta, StoryObj } from '@storybook/react'
+import type { Decorator, Meta, StoryObj } from '@storybook/react'
import { waitFor, within } from '@testing-library/dom'
import userEvent from '@testing-library/user-event'
@@ -1885,6 +1885,14 @@ export const ScannerEditorBudget: StoryObj = {
parameters: { pageUrl: urls.replayVisionScannerBudget(summarizerScanner.id) },
}
+// The recordings-first experiment arm only applies while creating, so this story starts a new scanner.
+export const ScannerEditorTriggersRecordingsFirst: StoryObj = {
+ parameters: {
+ pageUrl: urls.replayVisionScannerTriggers('new'),
+ featureFlags: { [FEATURE_FLAGS.VISION_SCANNER_WIZARD_RECORDINGS_FIRST]: 'test' },
+ },
+}
+
export const ObservationDetail: StoryObj = {
parameters: { pageUrl: urls.replayVisionObservation(observationDetail.id) },
}
@@ -2022,29 +2030,38 @@ const goalDraft: DraftScannerResponseApi = {
// The landing step after a goal draft: the whole config ordered by comprehension, each section
// deep-linking into the wizard step that edits it. Seeded through the same action the loader fires.
+const seedGoalOverviewDraft: Decorator = (StoryFn) => {
+ const logic = replayScannerLogic({ id: 'new' })
+ logic.mount()
+ // The success listener's stale-navigation guard sees the overview URL and skips its own
+ // reset + redirect, so only the goalDraft reducer applies; the form is seeded by hand.
+ logic.actions.draftScannerFromGoalSuccess(goalDraft)
+ logic.actions.setScannerValues({
+ name: goalDraft.name,
+ description: goalDraft.description,
+ scanner_type: goalDraft.scanner_type as ScannerType,
+ scanner_config: goalDraft.scanner_config as ScannerConfig,
+ query: goalDraft.query as RecordingsQuery,
+ sampling_mode: goalDraft.sampling_mode as SamplingMode,
+ sampling_rate: goalDraft.sampling_rate ?? 1,
+ })
+ return <StoryFn />
+}
+
export const ScannerEditorGoalOverview: StoryObj = {
parameters: {
pageUrl: urls.replayVisionScannerOverview('new'),
},
- decorators: [
- (StoryFn) => {
- const logic = replayScannerLogic({ id: 'new' })
- logic.mount()
- // The success listener's stale-navigation guard sees the overview URL and skips its own
- // reset + redirect, so only the goalDraft reducer applies; the form is seeded by hand.
- logic.actions.draftScannerFromGoalSuccess(goalDraft)
- logic.actions.setScannerValues({
- name: goalDraft.name,
- description: goalDraft.description,
- scanner_type: goalDraft.scanner_type as ScannerType,
- scanner_config: goalDraft.scanner_config as ScannerConfig,
- query: goalDraft.query as RecordingsQuery,
- sampling_mode: goalDraft.sampling_mode as SamplingMode,
- sampling_rate: goalDraft.sampling_rate ?? 1,
- })
- return <StoryFn />
- },
- ],
+ decorators: [seedGoalOverviewDraft],
+}
+
+// The recordings-first experiment arm reviews the eligible recordings before the prompt.
+export const ScannerEditorGoalOverviewRecordingsFirst: StoryObj = {
+ parameters: {
+ pageUrl: urls.replayVisionScannerOverview('new'),
+ featureFlags: { [FEATURE_FLAGS.VISION_SCANNER_WIZARD_RECORDINGS_FIRST]: 'test' },
+ },
+ decorators: [seedGoalOverviewDraft],
}
// The same landing step for a goal that named an experiment: the eligible-recordings section
diff --git a/products/replay_vision/frontend/replay_scanners/ScannerEditorScene.tsx b/products/replay_vision/frontend/replay_scanners/ScannerEditorScene.tsx
index 3b43d413c341..be9c7539468c 100644
--- a/products/replay_vision/frontend/replay_scanners/ScannerEditorScene.tsx
+++ b/products/replay_vision/frontend/replay_scanners/ScannerEditorScene.tsx
@@ -1,7 +1,7 @@
import { useActions, useValues } from 'kea'
import { Form } from 'kea-forms'
import { router } from 'kea-router'
-import { useState } from 'react'
+import { FormEvent, useState } from 'react'
import * as construction2Png from '@posthog/brand/hoggies/png/construction-2'
import * as imTheDriverPng from '@posthog/brand/hoggies/png/im-the-driver'
@@ -51,13 +51,11 @@ import { ScannerTriggers } from './components/ScannerTriggers'
import { ScannerTypeConfigEditor } from './components/ScannerTypeConfigEditor'
import { leaveScannerEditor, replayScannerLogic } from './replayScannerLogic'
import {
- SCANNER_EDITOR_STEPS,
- SCANNER_EDITOR_STEP_ORDER,
- SCANNER_STEPPER_STEPS,
- STEP_LABELS,
ScannerEditorStep,
- UNVALIDATED_SCANNER_STEPS,
+ advancesWithoutSubmit,
+ nextScannerEditorStep,
scannerEditorSceneLogic,
+ scannerEditorStepOrder,
scannerStepUrlWithParams,
} from './scannerEditorSceneLogic'
import { scannerSelfDrivingStatsLogic } from './scannerSelfDrivingStatsLogic'
@@ -102,9 +100,14 @@ const STEP_HEADERS: Record<
subtitle: 'How much of the matching traffic to scan, and what to spend on it.',
},
}
+const RECORDINGS_FIRST_STEP_TITLES: Partial<Record<keyof typeof STEP_HEADERS, string>> = {
+ configure: 'Tell it what to look for',
+ budget: 'Set sampling and limits',
+}
export function ScannerEditorSceneComponent(): JSX.Element {
- const { scannerId, step, isNew } = useValues(scannerEditorSceneLogic)
+ // Read before the loading return, so every entry into a new scanner reports the experiment exposure.
+ const { scannerId, step, isNew, recordingsFirst, steps, stepperSteps } = useValues(scannerEditorSceneLogic)
const { searchParams } = useValues(router)
// Reached a form step by clicking Edit on the goal overview: the overview is home, not a wizard
// stop, so the linear stepper is hidden and the footer returns there instead of marching on.
@@ -113,8 +116,15 @@ export function ScannerEditorSceneComponent(): JSX.Element {
const scannerLogic = replayScannerLogic({ id: scannerId })
useAttachedLogic(scannerLogic, scannerEditorSceneLogic)
- const { scanner, scannerLoading, isScannerSubmitting, stepErrors, lockedToExperimentScanner } =
- useValues(scannerLogic)
+ const {
+ scanner,
+ scannerLoading,
+ isScannerSubmitting,
+ stepErrors,
+ lockedToExperimentScanner,
+ scannerValidationErrors,
+ durationValidationError,
+ } = useValues(scannerLogic)
const { submitScanner } = useActions(scannerLogic)
if (step !== 'goal' && (scannerLoading || !scanner)) {
@@ -130,12 +140,16 @@ export function ScannerEditorSceneComponent(): JSX.Element {
// Validate the current step and move on: submit routes to the next step on success. A step with
// nothing to validate navigates straight on, so it can't fail on fields the user hasn't reached.
const advance = (): void => {
- if (UNVALIDATED_SCANNER_STEPS.includes(step)) {
- const next = SCANNER_EDITOR_STEPS[SCANNER_EDITOR_STEPS.indexOf(step) + 1]
- if (next) {
- router.actions.push(scannerStepUrlWithParams(next, scannerId, searchParams))
- return
- }
+ const next = nextScannerEditorStep(step, steps)
+ if (
+ next &&
+ advancesWithoutSubmit(step, recordingsFirst, {
+ ...scannerValidationErrors,
+ duration: durationValidationError,
+ })
+ ) {
+ router.actions.push(scannerStepUrlWithParams(next, scannerId, searchParams))
+ return
}
submitScanner()
}
@@ -144,7 +158,8 @@ export function ScannerEditorSceneComponent(): JSX.Element {
if (isScannerSubmitting) {
return
}
- if (SCANNER_EDITOR_STEP_ORDER[next] > SCANNER_EDITOR_STEP_ORDER[step]) {
+ const stepOrder = scannerEditorStepOrder(recordingsFirst)
+ if (stepOrder[next] > stepOrder[step]) {
if (step === 'goal') {
router.actions.push(urls.replayVisionScannerDetails(scannerId))
return
@@ -166,7 +181,7 @@ export function ScannerEditorSceneComponent(): JSX.Element {
/>
{step === 'goal' || step === 'overview' || fromOverview ? null : (
<GuidedWizardStepper
- steps={SCANNER_STEPPER_STEPS}
+ steps={stepperSteps}
currentStep={step}
onStepClick={goToStep}
stepErrors={stepErrors}
@@ -217,12 +232,24 @@ export function ScannerEditorSceneComponent(): JSX.Element {
formKey="scanner"
enableFormOnSubmit
className="max-w-4xl w-full mx-auto"
+ // Enter must act like Next, or the recordings step would flag the prompt it comes before.
+ {...(recordingsFirst
+ ? {
+ onSubmit: (event: FormEvent<HTMLFormElement>) => {
+ event.preventDefault()
+ advance()
+ },
+ }
+ : {})}
>
<div className="bg-bg-light border rounded-lg shadow-sm p-4 sm:p-6 flex flex-col gap-6 [&_.Field--error_.input-like]:!border-danger">
<div className="flex items-center gap-3">
{STEP_HEADERS[step].hedgehog}
<div>
- <div className="text-base font-semibold">{STEP_HEADERS[step].title}</div>
+ <div className="text-base font-semibold">
+ {(recordingsFirst && RECORDINGS_FIRST_STEP_TITLES[step]) ||
+ STEP_HEADERS[step].title}
+ </div>
<div className="text-sm text-muted">{STEP_HEADERS[step].subtitle}</div>
</div>
</div>
@@ -449,6 +476,7 @@ function EditorFooter({
replayScannerLogic({ id: scannerId })
)
const { searchParams } = useValues(router)
+ const { steps, stepLabels } = useValues(scannerEditorSceneLogic)
const { discardScannerDraft } = useActions(replayScannerLogic({ id: scannerId }))
const { dataProcessingAccepted, dataProcessingApprovalDisabledReason } = useValues(aiConsentLogic)
const [consentRequested, setConsentRequested] = useState(false)
@@ -456,14 +484,14 @@ function EditorFooter({
// Save instead of letting the request 400.
const needsConsent = isNew && !dataProcessingAccepted
const canApproveConsent = !dataProcessingApprovalDisabledReason
- const stepIndex = SCANNER_EDITOR_STEPS.indexOf(step)
- const previous = stepIndex > 0 ? SCANNER_EDITOR_STEPS[stepIndex - 1] : null
+ const stepIndex = steps.indexOf(step)
+ const previous = stepIndex > 0 ? steps[stepIndex - 1] : null
const prevStep = previous === 'goal' && (!isNew || lockedToExperimentScanner) ? null : previous
- const nextStep = stepIndex < SCANNER_EDITOR_STEPS.length - 1 ? SCANNER_EDITOR_STEPS[stepIndex + 1] : null
+ const nextStep = nextScannerEditorStep(step, steps)
// A broken duration filter blocks the save, but only from the triggers step onward: gating an
// earlier step's button on it blocks the wizard with a reason nothing on screen explains. RBAC
// takes priority and must match the backend's create/update requirement exactly.
- const ownsDurationFilter = step === 'triggers' || step === 'budget'
+ const ownsDurationFilter = stepIndex !== -1 && stepIndex >= steps.indexOf('triggers')
const durationError = ownsDurationFilter ? durationValidationError : null
const saveDisabledReason = getReplayVisionEditDisabledReason(scanner?.user_access_level) ?? durationError
// Editing one section from the goal overview: the edit is already in the form state, so the only
@@ -493,8 +521,8 @@ function EditorFooter({
return (
<div className="flex flex-col gap-2">
- {/* The duration field lives on the recordings step, so budget needs the error spelled out. */}
- {step === 'budget' && durationError ? <div className="text-danger text-sm">{durationError}</div> : null}
+ {/* The duration field lives on the recordings step, so later steps need the error spelled out. */}
+ {step !== 'triggers' && durationError ? <div className="text-danger text-sm">{durationError}</div> : null}
{fromOverview ? (
<div className="flex flex-wrap items-center justify-end gap-2">
<ScannerDraftStatus scannerId={scannerId} fromOverview />
@@ -544,7 +572,7 @@ function EditorFooter({
onClick={onAdvance}
data-attr="vision-editor-next"
>
- Next: {STEP_LABELS[nextStep]}
+ Next: {stepLabels[nextStep]}
</LemonButton>
) : (
<AIConsentPopoverWrapper
diff --git a/products/replay_vision/frontend/replay_scanners/components/ScannerGoalOverview.test.ts b/products/replay_vision/frontend/replay_scanners/components/ScannerGoalOverview.test.ts
index f4bf7d62fe54..43ec2b8ac4d9 100644
--- a/products/replay_vision/frontend/replay_scanners/components/ScannerGoalOverview.test.ts
+++ b/products/replay_vision/frontend/replay_scanners/components/ScannerGoalOverview.test.ts
@@ -2,7 +2,7 @@ import { NodeKind } from '~/queries/schema/schema-general'
import { PropertyFilterType, PropertyOperator } from '~/types'
import type { ReplayScanner } from '../types'
-import { eligibleFilterGroups } from './ScannerGoalOverview'
+import { eligibleFilterGroups, goalOverviewSectionLabels } from './ScannerGoalOverview'
const scanner = (overrides: Partial<ReplayScanner> = {}): ReplayScanner =>
({
@@ -171,3 +171,22 @@ describe('eligibleFilterGroups', () => {
expect(eligibleFilterGroups(scanner({ query: { kind: NodeKind.RecordingsQuery } }))).toEqual([])
})
})
+
+describe('goalOverviewSectionLabels', () => {
+ it('reviews the eligible recordings before the prompt in the recordings-first arm', () => {
+ expect(goalOverviewSectionLabels(false)).toEqual([
+ 'What it understood',
+ 'Name',
+ 'What it will ask',
+ 'Eligible recordings',
+ 'Sampling and budget',
+ ])
+ expect(goalOverviewSectionLabels(true)).toEqual([
+ 'What it understood',
+ 'Name',
+ 'Eligible recordings',
+ 'What it will ask',
+ 'Sampling and limits',
+ ])
+ })
+})
diff --git a/products/replay_vision/frontend/replay_scanners/components/ScannerGoalOverview.tsx b/products/replay_vision/frontend/replay_scanners/components/ScannerGoalOverview.tsx
index 7f889c87ef9d..55dfe1bcf20b 100644
--- a/products/replay_vision/frontend/replay_scanners/components/ScannerGoalOverview.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/ScannerGoalOverview.tsx
@@ -22,7 +22,7 @@ import { creditsToUsd, formatCreditCount } from '../../utils/credits'
import { freeCreditsCoverage } from '../../utils/quotaProjection'
import { scannerExperimentScope, scopeVariantsLabel } from '../experimentTargeting'
import { replayScannerLogic } from '../replayScannerLogic'
-import { ScannerEditorStep, scannerStepUrlWithParams } from '../scannerEditorSceneLogic'
+import { ScannerEditorStep, scannerEditorSceneLogic, scannerStepUrlWithParams } from '../scannerEditorSceneLogic'
import {
OBSERVATION_CREDITS_BY_MODEL,
SCANNER_TYPE_TAG_TYPE,
@@ -33,7 +33,7 @@ import {
/** Why the draft chose this model, doubling as the guidance on when each tier fits. Keyed by the
* concrete model id so a retired model just falls through to the generic line. */
-function modelRoleLabel(model: string): string {
+function modelRoleLabel(model: string, configureStepLabel: string): string {
if (model === 'gemini-3.5-flash-lite') {
return 'Cheapest tier. Best for simple yes/no checks.'
}
@@ -43,7 +43,7 @@ function modelRoleLabel(model: string): string {
if (model === 'gemini-3-flash-preview') {
return 'Balanced tier. A good default for everyday scanners.'
}
- return 'Change the model on the Configure step to trade cost for capability.'
+ return `Change the model on the ${configureStepLabel} step to trade cost for capability.`
}
/** The activity-filter badge label for each quality mode: how much of the eligible pool it keeps by
@@ -269,6 +269,7 @@ export function ScannerGoalOverview({ scannerId }: { scannerId: string }): JSX.E
experimentContext,
} = useValues(logic)
const { freeCreditsAllowance } = useValues(visionQuotaLogic)
+ const { recordingsFirst, stepLabels } = useValues(scannerEditorSceneLogic)
// Names the drafted cohort, which the query carries only by id.
const { cohortsById } = useValues(cohortsModel)
const { submitScanner, loadScannerEstimate } = useActions(logic)
@@ -291,7 +292,7 @@ export function ScannerGoalOverview({ scannerId }: { scannerId: string }): JSX.E
// The draft is still generating: show the page's shape so the wait reads as progress.
if (goalDraftLoading) {
- return <ScannerGoalOverviewSkeleton />
+ return <ScannerGoalOverviewSkeleton recordingsFirst={recordingsFirst} />
}
const zeroMatches = scannerEstimate !== null && scannerEstimate.matched_sessions_in_window === 0
@@ -315,6 +316,31 @@ export function ScannerGoalOverview({ scannerId }: { scannerId: string }): JSX.E
getReplayVisionEditDisabledReason(scanner.user_access_level) ??
(zeroMatches ? 'No recordings are eligible. Change the filter first.' : undefined)
+ // The recordings-first experiment arm reviews what the scanner watches before what it asks.
+ const askSection = (
+ <OverviewSection label="What it will ask" editStep="configure" scannerId={scannerId}>
+ <div className="space-y-3">
+ <LemonTag type={SCANNER_TYPE_TAG_TYPE[scanner.scanner_type]}>
+ {scannerTypeLabel(scanner.scanner_type)}
+ </LemonTag>
+ <div className="text-sm whitespace-pre-wrap">{scanner.scanner_config.prompt}</div>
+ <div className="grid grid-cols-[auto_minmax(0,1fr)] items-center gap-x-3 gap-y-1 text-sm border-t pt-3">
+ <StatRow label="Model">
+ <span className="inline-flex items-center gap-2">
+ <LemonTag type="muted">{modelName(scanner.model)}</LemonTag>
+ {creditsPerObservation != null ? (
+ <span className="text-muted">
+ {formatCreditCount(creditsPerObservation)} / observation
+ </span>
+ ) : null}
+ </span>
+ </StatRow>
+ </div>
+ <div className="text-xs text-muted">{modelRoleLabel(scanner.model, stepLabels.configure)}</div>
+ </div>
+ </OverviewSection>
+ )
+
return (
<div className="flex flex-col gap-3">
<OverviewSection label="What it understood" scannerId={scannerId}>
@@ -326,27 +352,7 @@ export function ScannerGoalOverview({ scannerId }: { scannerId: string }): JSX.E
{scanner.description ? <div className="text-sm text-muted">{scanner.description}</div> : null}
</OverviewSection>
- <OverviewSection label="What it will ask" editStep="configure" scannerId={scannerId}>
- <div className="space-y-3">
- <LemonTag type={SCANNER_TYPE_TAG_TYPE[scanner.scanner_type]}>
- {scannerTypeLabel(scanner.scanner_type)}
- </LemonTag>
- <div className="text-sm whitespace-pre-wrap">{scanner.scanner_config.prompt}</div>
- <div className="grid grid-cols-[auto_minmax(0,1fr)] items-center gap-x-3 gap-y-1 text-sm border-t pt-3">
- <StatRow label="Model">
- <span className="inline-flex items-center gap-2">
- <LemonTag type="muted">{modelName(scanner.model)}</LemonTag>
- {creditsPerObservation != null ? (
- <span className="text-muted">
- {formatCreditCount(creditsPerObservation)} / observation
- </span>
- ) : null}
- </span>
- </StatRow>
- </div>
- <div className="text-xs text-muted">{modelRoleLabel(scanner.model)}</div>
- </div>
- </OverviewSection>
+ {recordingsFirst ? null : askSection}
<OverviewSection label="Eligible recordings" editStep="triggers" scannerId={scannerId}>
{filterGroups.length > 0 ? (
@@ -384,8 +390,10 @@ export function ScannerGoalOverview({ scannerId }: { scannerId: string }): JSX.E
) : null}
</OverviewSection>
+ {recordingsFirst ? askSection : null}
+
<OverviewSection
- label="Sampling and budget"
+ label={recordingsFirst ? 'Sampling and limits' : 'Sampling and budget'}
info="Estimated from your last 7 days of recordings, projected to a month. Your real volume follows your future traffic, so treat this as a guide."
editStep="budget"
scannerId={scannerId}
@@ -528,20 +536,25 @@ function DraftLoadingBar(): JSX.Element {
)
}
+/** The overview's section titles in render order, which the recordings-first experiment arm changes. */
+export function goalOverviewSectionLabels(recordingsFirst: boolean): string[] {
+ return recordingsFirst
+ ? ['What it understood', 'Name', 'Eligible recordings', 'What it will ask', 'Sampling and limits']
+ : ['What it understood', 'Name', 'What it will ask', 'Eligible recordings', 'Sampling and budget']
+}
+
/** The overview's shape while the draft is still generating, so navigating there reads as progress. */
-function ScannerGoalOverviewSkeleton(): JSX.Element {
+function ScannerGoalOverviewSkeleton({ recordingsFirst }: { recordingsFirst: boolean }): JSX.Element {
return (
<div className="flex flex-col gap-3">
<DraftLoadingBar />
- {['What it understood', 'Name', 'What it will ask', 'Eligible recordings', 'Sampling and budget'].map(
- (label) => (
- <div key={label} className="bg-bg-light border rounded-lg p-4 space-y-2">
- <div className="text-xs text-tertiary uppercase tracking-wide">{label}</div>
- <LemonSkeleton className="h-4 w-3/4" />
- <LemonSkeleton className="h-4 w-1/2" />
- </div>
- )
- )}
+ {goalOverviewSectionLabels(recordingsFirst).map((label) => (
+ <div key={label} className="bg-bg-light border rounded-lg p-4 space-y-2">
+ <div className="text-xs text-tertiary uppercase tracking-wide">{label}</div>
+ <LemonSkeleton className="h-4 w-3/4" />
+ <LemonSkeleton className="h-4 w-1/2" />
+ </div>
+ ))}
</div>
)
}
diff --git a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.test.ts b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.test.ts
index 9f073af08ea3..c720d6d5ae58 100644
--- a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.test.ts
+++ b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.test.ts
@@ -742,6 +742,47 @@ describe('replayScannerLogic', () => {
})
})
+ describe('submit intent in the recordings-first arm', () => {
+ beforeEach(() => {
+ featureFlagLogic.actions.setFeatureFlags([], {
+ [FEATURE_FLAGS.VISION_SCANNER_WIZARD_RECORDINGS_FIRST]: 'test',
+ })
+ })
+
+ afterEach(() => {
+ // Flags persist across kea resets, so the variant would leak into later tests.
+ featureFlagLogic.actions.setFeatureFlags([], {})
+ })
+
+ it('moves from the recordings step to the prompt step', async () => {
+ router.actions.push('/replay-vision/new/triggers')
+ logic.actions.setScannerValues({ name: 'Test scanner', scanner_config: { prompt: 'Q?' } })
+ await expectLogic(logic, () => logic.actions.submitScanner()).toFinishAllListeners()
+ expect(router.values.location.pathname).toContain('/replay-vision/new/configure')
+ })
+
+ it('does not hold the recordings step back on the prompt the user has not reached', async () => {
+ router.actions.push('/replay-vision/new/triggers')
+ await expectLogic(logic, () => logic.actions.submitScanner()).toFinishAllListeners()
+ expect(createSpy).not.toHaveBeenCalled()
+ expect(router.values.location.pathname).toContain('/replay-vision/new/configure')
+ })
+
+ it('moves from the prompt step to the budget step', async () => {
+ router.actions.push('/replay-vision/new/configure')
+ logic.actions.setScannerValues({ name: 'Test scanner', scanner_config: { prompt: 'Q?' } })
+ await expectLogic(logic, () => logic.actions.submitScanner()).toFinishAllListeners()
+ expect(router.values.location.pathname).toContain('/replay-vision/new/budget')
+ })
+
+ it('creates the scanner from the budget step', async () => {
+ router.actions.push('/replay-vision/new/budget')
+ logic.actions.setScannerValues({ name: 'Test scanner', scanner_config: { prompt: 'Q?' } })
+ await expectLogic(logic, () => logic.actions.submitScanner()).toFinishAllListeners()
+ expect(createSpy).toHaveBeenCalledTimes(1)
+ })
+ })
+
describe('new scanner draft', () => {
beforeEach(() => {
teamLogic.mount()
diff --git a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts
index ba3aabf511f2..c36cf757d1b7 100644
--- a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts
@@ -87,14 +87,15 @@ import { newScanner } from './newScanner'
import { ReplayScannerTab } from './replayScannerSceneLogic'
import { clearScannerDraft, readScannerDraft, writeScannerDraft } from './scannerDraft'
import {
- SCANNER_EDITOR_STEPS,
ScannerEditorStep,
+ advancesWithoutSubmit,
firstErroredScannerStep,
+ nextScannerEditorStep,
scannerEditorSceneLogic,
+ scannerEditorSteps,
scannerStepErrors,
scannerStepUrl,
scannerStepUrlWithParams,
- UNVALIDATED_SCANNER_STEPS,
} from './scannerEditorSceneLogic'
import { consumeScannerGoalDraftIntent, consumeScannerHandoffIntent } from './scannerHandoffIntent'
import type { ObservationStatusStats } from './scannerStats'
@@ -1170,11 +1171,11 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
submit: async (scanner: ScannerFormValues) => {
// A non-final step only ever offers "Next", so any submit there advances rather than persisting.
// Enter would otherwise save an existing scanner and leave the wizard from the middle of it.
- const currentStep = scannerEditorSceneLogic.findMounted()?.values.step ?? 'configure'
- // The overview step sits outside the manual wizard's step list (indexOf -1), so its
- // submit must persist rather than resolve to the list's first step and navigate there.
- const currentStepIndex = SCANNER_EDITOR_STEPS.indexOf(currentStep)
- const nextStep = currentStepIndex === -1 ? undefined : SCANNER_EDITOR_STEPS[currentStepIndex + 1]
+ const editor = scannerEditorSceneLogic.findMounted()
+ const currentStep = editor?.values.step ?? 'configure'
+ // The overview step sits outside the manual wizard's step list, so its submit must
+ // persist rather than resolve to the list's first step and navigate there.
+ const nextStep = nextScannerEditorStep(currentStep, editor?.values.steps ?? scannerEditorSteps(false))
if (nextStep) {
router.actions.push(scannerStepUrlWithParams(nextStep, props.id, router.values.searchParams))
return
@@ -1986,20 +1987,21 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
if (error?.message !== 'Validation Failed') {
return
}
- const currentStep = scannerEditorSceneLogic.findMounted()?.values.step
- // Enter submits the whole form, so leaving a step that validates nothing must behave like
+ const editor = scannerEditorSceneLogic.findMounted()
+ const currentStep = editor?.values.step
+ const recordingsFirst = editor?.values.recordingsFirst ?? false
+ const steps = scannerEditorSteps(recordingsFirst)
+ const errors = { ...values.scannerValidationErrors, duration: values.durationValidationError }
+ // Enter submits the whole form, so leaving a step whose own fields are clean must behave like
// its Next button: move on, rather than red-flag fields the user has not reached yet.
- if (currentStep && UNVALIDATED_SCANNER_STEPS.includes(currentStep)) {
- const next = SCANNER_EDITOR_STEPS[SCANNER_EDITOR_STEPS.indexOf(currentStep) + 1]
+ if (currentStep && advancesWithoutSubmit(currentStep, recordingsFirst, errors)) {
+ const next = nextScannerEditorStep(currentStep, steps)
if (next) {
router.actions.push(scannerStepUrlWithParams(next, props.id, router.values.searchParams))
}
return
}
- const erroredStep = firstErroredScannerStep({
- ...values.scannerValidationErrors,
- duration: values.durationValidationError,
- })
+ const erroredStep = firstErroredScannerStep(errors, steps)
if (erroredStep && erroredStep !== currentStep) {
router.actions.push(scannerStepUrlWithParams(erroredStep, props.id, router.values.searchParams))
}
@@ -2945,7 +2947,7 @@ export function leaveScannerEditor(scannerId: string, destination: string): void
/** The step URLs of a scanner's editor wizard. */
function scannerEditorPaths(scannerId: string): string[] {
return [
- ...SCANNER_EDITOR_STEPS.map((step) => scannerStepUrl(step, scannerId)),
+ ...scannerEditorSteps(false).map((step) => scannerStepUrl(step, scannerId)),
// The goal flow's overview step is editor territory too, though it sits outside the manual stepper.
scannerStepUrl('overview', scannerId),
]
diff --git a/products/replay_vision/frontend/replay_scanners/scannerEditorSceneLogic.test.ts b/products/replay_vision/frontend/replay_scanners/scannerEditorSceneLogic.test.ts
index 43d245b4d015..9837c7544305 100644
--- a/products/replay_vision/frontend/replay_scanners/scannerEditorSceneLogic.test.ts
+++ b/products/replay_vision/frontend/replay_scanners/scannerEditorSceneLogic.test.ts
@@ -1,19 +1,28 @@
import { router } from 'kea-router'
import { expectLogic } from 'kea-test-utils'
+import { FEATURE_FLAGS } from 'lib/constants'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { urls } from 'scenes/urls'
import { initKeaTests } from '~/test/init'
import {
- SCANNER_EDITOR_STEPS,
+ advancesWithoutSubmit,
firstErroredScannerStep,
isScannerEditorPath,
+ nextScannerEditorStep,
scannerEditorSceneLogic,
+ scannerEditorStepOrder,
+ scannerEditorSteps,
scannerStepErrors,
+ scannerStepperSteps,
scannerStepUrl,
} from './scannerEditorSceneLogic'
+const PROMPT_ERROR = { scanner_config: { prompt: 'Prompt is required' } }
+const DURATION_ERROR = { duration: 'Duration filters above 1 hour match nothing' }
+
describe('firstErroredScannerStep', () => {
it.each([
['config error lands on configure', { scanner_config: { prompt: 'Required' } }, 'configure'],
@@ -25,6 +34,69 @@ describe('firstErroredScannerStep', () => {
})
})
+describe('step order by experiment arm', () => {
+ it('asks for the prompt before the recordings in control, and after them in recordings-first', () => {
+ expect(scannerEditorSteps(false)).toEqual(['goal', 'details', 'configure', 'triggers', 'budget'])
+ expect(scannerEditorSteps(true)).toEqual(['goal', 'details', 'triggers', 'configure', 'budget'])
+ })
+
+ it.each([false, true])('keeps the overview between goal and details (recordingsFirst=%s)', (recordingsFirst) => {
+ const order = scannerEditorStepOrder(recordingsFirst)
+ expect(order.goal).toBeLessThan(order.overview)
+ expect(order.overview).toBeLessThan(order.details)
+ })
+
+ it('derives the recordings-first order from its step list', () => {
+ const order = scannerEditorStepOrder(true)
+ expect(order.triggers).toBeLessThan(order.configure)
+ expect(order.configure).toBeLessThan(order.budget)
+ })
+
+ it('ends the stepper on budget and leaves the overview outside it', () => {
+ expect(nextScannerEditorStep('triggers', scannerEditorSteps(true))).toBe('configure')
+ expect(nextScannerEditorStep('budget', scannerEditorSteps(true))).toBeNull()
+ expect(nextScannerEditorStep('overview', scannerEditorSteps(true))).toBeNull()
+ })
+
+ it('renames the steps in recordings-first but keeps their autocapture data-attrs', () => {
+ const labels = (recordingsFirst: boolean): Record<string, string> =>
+ Object.fromEntries(scannerStepperSteps(recordingsFirst).map(({ step, label }) => [step, label]))
+ const dataAttrs = (recordingsFirst: boolean): Record<string, string | undefined> =>
+ Object.fromEntries(scannerStepperSteps(recordingsFirst).map(({ step, dataAttr }) => [step, dataAttr]))
+ expect(labels(true)).toEqual({
+ goal: 'Goal',
+ details: 'Details',
+ triggers: 'Target recordings',
+ configure: 'Prompt & output',
+ budget: 'Sampling & limits',
+ })
+ expect(dataAttrs(true)).toEqual(dataAttrs(false))
+ })
+
+ it('routes a failed submit to the earliest errored step in the arm’s order', () => {
+ const errors = { ...PROMPT_ERROR, ...DURATION_ERROR }
+ expect(firstErroredScannerStep(errors, scannerEditorSteps(false))).toBe('configure')
+ expect(firstErroredScannerStep(errors, scannerEditorSteps(true))).toBe('triggers')
+ })
+})
+
+describe('advancesWithoutSubmit', () => {
+ it.each([
+ ['control goal', 'goal', false, PROMPT_ERROR, true],
+ ['control details', 'details', false, PROMPT_ERROR, true],
+ ['control configure even when clean', 'configure', false, {}, false],
+ ['control triggers with a prompt error', 'triggers', false, PROMPT_ERROR, false],
+ ['recordings-first triggers past an unreached prompt', 'triggers', true, PROMPT_ERROR, true],
+ ['recordings-first triggers with its own duration error', 'triggers', true, DURATION_ERROR, false],
+ ['recordings-first configure with a prompt error', 'configure', true, PROMPT_ERROR, false],
+ ['recordings-first configure past a later budget error', 'configure', true, { sampling_rate: 'Bad' }, true],
+ ['recordings-first budget, the final step', 'budget', true, {}, false],
+ ['recordings-first overview, outside the stepper', 'overview', true, {}, false],
+ ] as const)('%s → %s', (_label, step, recordingsFirst, errors, expected) => {
+ expect(advancesWithoutSubmit(step, recordingsFirst, errors)).toBe(expected)
+ })
+})
+
describe('scannerStepErrors', () => {
it('carries the field-level messages through to each step', () => {
expect(
@@ -60,7 +132,7 @@ describe('scannerEditorSceneLogic', () => {
describe('isScannerEditorPath', () => {
it.each<[string, boolean]>([
- ...SCANNER_EDITOR_STEPS.map((step): [string, boolean] => [scannerStepUrl(step, 'abc'), true]),
+ ...scannerEditorSteps(false).map((step): [string, boolean] => [scannerStepUrl(step, 'abc'), true]),
[scannerStepUrl('overview', 'new'), true],
[`/project/123${urls.replayVisionScannerBudget('abc')}`, true],
[urls.replayVision('abc'), false],
@@ -92,6 +164,41 @@ describe('scannerEditorSceneLogic', () => {
})
})
+ describe('recordings-first experiment', () => {
+ afterEach(() => {
+ // Flags persist across kea resets, so the variant would leak into later tests.
+ featureFlagLogic.actions.setFeatureFlags([], {})
+ })
+
+ it.each([
+ ['test', urls.replayVisionScannerTriggers('new'), true],
+ ['control', urls.replayVisionScannerTriggers('new'), false],
+ // Editing an existing scanner stays on the control order, so only creation is exposed.
+ ['test', urls.replayVisionScannerTriggers('abc-123'), false],
+ ])('variant %s at %s → %s', async (variant, url, expected) => {
+ featureFlagLogic.actions.setFeatureFlags([], {
+ [FEATURE_FLAGS.VISION_SCANNER_WIZARD_RECORDINGS_FIRST]: variant,
+ })
+ router.actions.push(url)
+ await expectLogic(logic).toMatchValues({
+ recordingsFirst: expected,
+ steps: scannerEditorSteps(expected),
+ })
+ })
+
+ it('names the current step with the arm’s label in the breadcrumb', async () => {
+ featureFlagLogic.actions.setFeatureFlags([], {
+ [FEATURE_FLAGS.VISION_SCANNER_WIZARD_RECORDINGS_FIRST]: 'test',
+ })
+ router.actions.push(urls.replayVisionScannerTriggers('new'))
+ await expectLogic(logic).toMatchValues({
+ breadcrumbs: expect.arrayContaining([
+ expect.objectContaining({ key: 'new-scanner-step', name: 'Target recordings' }),
+ ]),
+ })
+ })
+ })
+
describe('URL → state', () => {
it('reflects the goal step for a new scanner', async () => {
router.actions.push(urls.replayVisionScannerGoal('new'))
diff --git a/products/replay_vision/frontend/replay_scanners/scannerEditorSceneLogic.ts b/products/replay_vision/frontend/replay_scanners/scannerEditorSceneLogic.ts
index 33b5bd409814..6611f6d08066 100644
--- a/products/replay_vision/frontend/replay_scanners/scannerEditorSceneLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/scannerEditorSceneLogic.ts
@@ -3,6 +3,8 @@ import { combineUrl, router, urlToAction } from 'kea-router'
import type { LocationChangedPayload } from 'kea-router/lib/types'
import { GuidedWizardStep } from 'lib/components/GuidedWizard/GuidedWizardStepper'
+import { FEATURE_FLAGS } from 'lib/constants'
+import { type FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { removeProjectIdIfPresent } from 'lib/utils/kea-router'
import { urls } from 'scenes/urls'
@@ -13,15 +15,38 @@ import { VISION_ROOT_BREADCRUMB, scannerBreadcrumb } from '../utils/breadcrumbs'
export type ScannerEditorStep = 'goal' | 'overview' | 'details' | 'configure' | 'triggers' | 'budget'
// The manual wizard's stepper; overview belongs to the goal-based flow only, so it stays out.
-export const SCANNER_EDITOR_STEPS: readonly ScannerEditorStep[] = ['goal', 'details', 'configure', 'triggers', 'budget']
-export const SCANNER_EDITOR_STEP_ORDER: Record<ScannerEditorStep, number> = {
- goal: 0,
- overview: 1,
- details: 2,
- configure: 3,
- triggers: 4,
- budget: 5,
+const SCANNER_EDITOR_STEPS: readonly ScannerEditorStep[] = ['goal', 'details', 'configure', 'triggers', 'budget']
+// The recordings-first experiment arm asks which recordings to watch before what to look for in them.
+const RECORDINGS_FIRST_SCANNER_EDITOR_STEPS: readonly ScannerEditorStep[] = [
+ 'goal',
+ 'details',
+ 'triggers',
+ 'configure',
+ 'budget',
+]
+
+export function scannerEditorSteps(recordingsFirst: boolean): readonly ScannerEditorStep[] {
+ return recordingsFirst ? RECORDINGS_FIRST_SCANNER_EDITOR_STEPS : SCANNER_EDITOR_STEPS
}
+
+/** Position of every step, with the goal flow's overview between the goal and the manual steps. */
+export function scannerEditorStepOrder(recordingsFirst: boolean): Record<ScannerEditorStep, number> {
+ const [first, ...rest] = scannerEditorSteps(recordingsFirst)
+ return Object.fromEntries([first, 'overview', ...rest].map((step, index) => [step, index])) as Record<
+ ScannerEditorStep,
+ number
+ >
+}
+
+/** The step after `step` in the stepper, or null on the last step and on the overview, which is outside it. */
+export function nextScannerEditorStep(
+ step: ScannerEditorStep,
+ steps: readonly ScannerEditorStep[]
+): ScannerEditorStep | null {
+ const index = steps.indexOf(step)
+ return index === -1 ? null : (steps[index + 1] ?? null)
+}
+
export const STEP_LABELS: Record<ScannerEditorStep, string> = {
goal: 'Goal',
overview: 'Overview',
@@ -30,13 +55,26 @@ export const STEP_LABELS: Record<ScannerEditorStep, string> = {
triggers: 'Recordings',
budget: 'Budget',
}
+const RECORDINGS_FIRST_STEP_LABELS: Record<ScannerEditorStep, string> = {
+ ...STEP_LABELS,
+ configure: 'Prompt & output',
+ triggers: 'Target recordings',
+ budget: 'Sampling & limits',
+}
-export const SCANNER_STEPPER_STEPS: GuidedWizardStep<ScannerEditorStep>[] = SCANNER_EDITOR_STEPS.map((step) => ({
- step,
- label: STEP_LABELS[step],
- // pinned: data-attr for autocapture, renaming breaks dashboards, so the goal step keeps its old name
- dataAttr: `vision-editor-step-${step === 'goal' ? 'template' : step}`,
-}))
+export function scannerStepLabels(recordingsFirst: boolean): Record<ScannerEditorStep, string> {
+ return recordingsFirst ? RECORDINGS_FIRST_STEP_LABELS : STEP_LABELS
+}
+
+export function scannerStepperSteps(recordingsFirst: boolean): GuidedWizardStep<ScannerEditorStep>[] {
+ const labels = scannerStepLabels(recordingsFirst)
+ return scannerEditorSteps(recordingsFirst).map((step) => ({
+ step,
+ label: labels[step],
+ // pinned: data-attr for autocapture, renaming breaks dashboards, so the goal step keeps its old name
+ dataAttr: `vision-editor-step-${step === 'goal' ? 'template' : step}`,
+ }))
+}
export interface ScannerFieldErrors {
scanner_config?: unknown
@@ -46,7 +84,7 @@ export interface ScannerFieldErrors {
}
/** Steps that mount no validated field, so leaving them must not run whole-form validation. */
-export const UNVALIDATED_SCANNER_STEPS: readonly ScannerEditorStep[] = ['goal', 'details']
+const UNVALIDATED_SCANNER_STEPS: readonly ScannerEditorStep[] = ['goal', 'details']
// Fallback for error shapes that carry no message, so an errored step is never silently clean
function fieldErrorMessages(error: unknown): string[] {
@@ -78,9 +116,33 @@ export function scannerStepErrors(errors: ScannerFieldErrors): Record<ScannerEdi
}
/** Earliest step rendering an errored field, so a failed submit lands where the user can fix it. */
-export function firstErroredScannerStep(errors: ScannerFieldErrors): ScannerEditorStep | null {
+export function firstErroredScannerStep(
+ errors: ScannerFieldErrors,
+ steps: readonly ScannerEditorStep[] = SCANNER_EDITOR_STEPS
+): ScannerEditorStep | null {
+ const stepErrors = scannerStepErrors(errors)
+ return steps.find((step) => stepErrors[step].length > 0) ?? null
+}
+
+/**
+ * Whether Next can leave `step` without running whole-form validation. In the recordings-first arm the
+ * required prompt comes after the recordings step, so only this step's and earlier steps' fields may hold it back.
+ */
+export function advancesWithoutSubmit(
+ step: ScannerEditorStep,
+ recordingsFirst: boolean,
+ errors: ScannerFieldErrors
+): boolean {
+ if (!recordingsFirst) {
+ return UNVALIDATED_SCANNER_STEPS.includes(step)
+ }
+ const steps = scannerEditorSteps(true)
+ const index = steps.indexOf(step)
+ if (index === -1 || index === steps.length - 1) {
+ return false
+ }
const stepErrors = scannerStepErrors(errors)
- return SCANNER_EDITOR_STEPS.find((step) => stepErrors[step].length > 0) ?? null
+ return steps.slice(0, index + 1).every((s) => stepErrors[s].length === 0)
}
/**
@@ -135,7 +197,7 @@ interface RouterPayload {
const LEAVE_EDITOR_POPSTATE_TIMEOUT_MS = 10000
-// The goal flow's overview sits outside the manual stepper.
+// The goal flow's overview sits outside the manual stepper. Membership only, so either arm's order works.
const EDITOR_PATH_SEGMENTS = new Set<string>([...SCANNER_EDITOR_STEPS, 'overview'])
export function isScannerEditorPath(pathname: string): boolean {
@@ -176,10 +238,15 @@ function trackEditorHistory(
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface scannerEditorSceneLogicValues {
+ featureFlags: FeatureFlagsSet // featureFlagLogic
breadcrumbs: Breadcrumb[]
isNew: boolean
+ recordingsFirst: boolean
scannerId: string
step: ScannerEditorStep
+ stepLabels: Record<ScannerEditorStep, string>
+ stepperSteps: GuidedWizardStep<ScannerEditorStep>[]
+ steps: readonly ScannerEditorStep[]
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -202,10 +269,15 @@ export interface scannerEditorSceneLogicActions {
export interface scannerEditorSceneLogicMeta {
__keaTypeGenInternalSelectorTypes: {
isNew: (scannerId: string) => boolean
+ recordingsFirst: (isNew: boolean, featureFlags: FeatureFlagsSet) => boolean
+ steps: (recordingsFirst: boolean) => readonly ScannerEditorStep[]
+ stepLabels: (recordingsFirst: boolean) => Record<ScannerEditorStep, string>
+ stepperSteps: (recordingsFirst: boolean) => GuidedWizardStep<ScannerEditorStep>[]
breadcrumbs: (
scannerId: string,
isNew: boolean,
step: ScannerEditorStep,
+ stepLabels: Record<ScannerEditorStep, string>,
searchParams: Record<string, any>
) => Breadcrumb[]
}
@@ -248,6 +320,7 @@ export const scannerEditorSceneLogic = kea<scannerEditorSceneLogicType>([
path(['products', 'replay_vision', 'frontend', 'replay_scanners', 'scannerEditorSceneLogic']),
connect(() => ({
+ values: [featureFlagLogic, ['featureFlags']],
actions: [tagsModel, ['loadTags']],
})),
@@ -274,12 +347,31 @@ export const scannerEditorSceneLogic = kea<scannerEditorSceneLogicType>([
selectors({
isNew: [(s) => [s.scannerId], (scannerId: string): boolean => scannerId === 'new'],
+ // Creation only, so the experiment exposes people who start a scanner rather than everyone who edits one.
+ recordingsFirst: [
+ (s) => [s.isNew, s.featureFlags],
+ (isNew: boolean, featureFlags: FeatureFlagsSet): boolean =>
+ isNew && featureFlags[FEATURE_FLAGS.VISION_SCANNER_WIZARD_RECORDINGS_FIRST] === 'test',
+ ],
+ steps: [
+ (s) => [s.recordingsFirst],
+ (recordingsFirst: boolean): readonly ScannerEditorStep[] => scannerEditorSteps(recordingsFirst),
+ ],
+ stepLabels: [
+ (s) => [s.recordingsFirst],
+ (recordingsFirst: boolean): Record<ScannerEditorStep, string> => scannerStepLabels(recordingsFirst),
+ ],
+ stepperSteps: [
+ (s) => [s.recordingsFirst],
+ (recordingsFirst: boolean): GuidedWizardStep<ScannerEditorStep>[] => scannerStepperSteps(recordingsFirst),
+ ],
breadcrumbs: [
- (s) => [s.scannerId, s.isNew, s.step, router.selectors.searchParams],
+ (s) => [s.scannerId, s.isNew, s.step, s.stepLabels, router.selectors.searchParams],
(
scannerId: string,
isNew: boolean,
step: ScannerEditorStep,
+ stepLabels: Record<ScannerEditorStep, string>,
searchParams: Record<string, any>
): Breadcrumb[] => {
const crumbs: Breadcrumb[] = [VISION_ROOT_BREADCRUMB]
@@ -298,11 +390,11 @@ export const scannerEditorSceneLogic = kea<scannerEditorSceneLogicType>([
const { from: _from, ...overviewParams } = searchParams
crumbs.push({
key: 'new-scanner-overview',
- name: STEP_LABELS.overview,
+ name: stepLabels.overview,
path: scannerStepUrlWithParams('overview', scannerId, overviewParams),
})
}
- crumbs.push({ key: 'new-scanner-step', name: STEP_LABELS[step] })
+ crumbs.push({ key: 'new-scanner-step', name: stepLabels[step] })
}
return crumbs
}