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): add alert creation to the action editor (#69569)

Kim Svatos Duganebe23902ba72
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 0f40ac7e5c38..b05ef338760c 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -5003,21 +5003,21 @@ snapshots:
scenes-app-ai-observability-conversation-display--anthropic--light:
hash: v1.k794b7964.153d5fe9eafbb67eb746a3ff3f516c67e65a84542325171764b68f6effbc3393.1EGkU0sySBFFoIO7iHUB6iLLycQqtjlgq7wInrBMgLc
scenes-app-ai-observability-conversation-display--basic--dark:
- hash: v1.k794b7964.78f996e5b3fa17c9273ac0b919698921f80b86d7116879a94139cbcd28c2fcf0.z0zclhoP9A1J7cgadBSK6Y1KE1t39NkaqYffkTuXyzk
+ hash: v1.k794b7964.9ea11684de93cf0bf2fabc01d05a7b4fed8d0e540084b01ec27ab8a29d0f3823.vJCRxMCRSHVE9xVry1hOYTeYimJdH1PyeD0guOSQu4k
scenes-app-ai-observability-conversation-display--basic--light:
- hash: v1.k794b7964.d71dd9f0b151a925a9a984b79fb81295fe803800f909c2ae1091c8a89b6f339e.MPJYfBbGOyJlJwUaARyBMnrwC1Bl8ifBnXVICkivs48
+ hash: v1.k794b7964.3cb142d720e0576d3b92310d75f791cf42452f5f32d38674f79d434790589239.7q-Lw22M7R633hrsN-ZnuIgkAWP9l4i9iRbu5jpnOG8
scenes-app-ai-observability-conversation-display--error--dark:
hash: v1.k794b7964.477b40a99b407806f5a85839a94004a899be31370ea6861518dd11cf5c883c45.EQEZzP2enfzFprXAhyqSbD8Um6pvTD1cGa3yq6qn4VU
scenes-app-ai-observability-conversation-display--error--light:
hash: v1.k794b7964.ac8507542eecfdaec76482cb232e677a0d0abe4b4c6ecdbac613ec4757cbfacd.jWQdUiUTDBIvtwDA-nQxlWMkAnWRT2mFrGrtmr3q_ys
scenes-app-ai-observability-conversation-display--markdown--dark:
- hash: v1.k794b7964.e5be16b83690b4e4f1c275be8c9806440f882c7b8f28c3859529b9f46a0dd10b.o_k_Yq7HgYD7AO6ZREBAA2oK4USO5eXGZ-fwVCce11I
+ hash: v1.k794b7964.479524503d84d5795c027718559d41efcba3103a6a9e11a66854d4bedf300247.dkazWcFlzQhfdiEy_8W9vix5XwB2ROB6Z0k6S2vRKl4
scenes-app-ai-observability-conversation-display--markdown--light:
- hash: v1.k794b7964.a32669ce02fb47f7bb7ad3ae6484fe7327a847d1df1d1e28a0e8dcacdfe4000e.wAkd9vHYwtDzb0ieO_xo7BHCYQ7kIu5zGydHtqMVssc
+ hash: v1.k794b7964.031e91a251072760a2430dd98ba5e87374d77adebd27db1ed5ed08242d9b0537.FLdMLi2pEXuK08SP_gNnEB7gWrSV9iAYY6JMCD9xASI
scenes-app-ai-observability-conversation-display--tools--dark:
- hash: v1.k794b7964.2cfe071a064ceb24f0d335ede9776c5baf4f9bd29a4d0614054a2b0f9ab6323e.D-lly0WcYDtubBh1ijhde5QQ8-RFUMN9lsIIZqNblvY
+ hash: v1.k794b7964.c9cf0f699197f208ec18e3ad326c29d43b8034f37f5fc101a9e25773510895a5.f_qTgpzSlQlCRirQv0iD791ajpL-x8WnVi8T8qNYr1o
scenes-app-ai-observability-conversation-display--tools--light:
- hash: v1.k794b7964.8cef3e2b4016ddd7acd4573fc58711be40ebe7d669371df7b7d4a35324dfce8a.exvwcwzA0A82p-3LqqXM3F04g3shIirvtOlCd3H7Z8c
+ hash: v1.k794b7964.cc6f7770155f4b720ff0597c3dd5deff699a267cfbdd8fe76a131cb51740215d.lKCAOsQBSoBkK46EHSYdGmWxAi4CQ4wUrx2J1iRF_f0
scenes-app-ai-observability-prompts--empty-state--dark:
hash: v1.k794b7964.c8d83f25e82f659e199c0514b7eab4a0b1dab1e7a6a1c4e1de97a162a007b9f0.iR50GK7W2Ghw5_0tV7K5HMTfGuVyUSWQfYO-waZI_SA
scenes-app-ai-observability-prompts--empty-state--light:
diff --git a/products/replay_vision/frontend/replay_scanners/ActionEditorScene.tsx b/products/replay_vision/frontend/replay_scanners/ActionEditorScene.tsx
index 2481d2d49101..2c39083bd732 100644
--- a/products/replay_vision/frontend/replay_scanners/ActionEditorScene.tsx
+++ b/products/replay_vision/frontend/replay_scanners/ActionEditorScene.tsx
@@ -2,7 +2,7 @@ import { useActions, useValues } from 'kea'
import { Form } from 'kea-forms'
import { useMemo } from 'react'
-import { LemonButton, LemonInput, LemonInputSelect, LemonSegmentedButton } from '@posthog/lemon-ui'
+import { LemonButton, LemonInput, LemonInputSelect, LemonSegmentedButton, LemonSelect } from '@posthog/lemon-ui'
import { IntegrationChoice } from 'lib/components/CyclotronJob/integrations/IntegrationChoice'
import { NotFound } from 'lib/components/NotFound'
@@ -12,6 +12,7 @@ import { SlackChannelPicker, SlackNotConfiguredBanner } from 'lib/integrations/S
import { LemonField } from 'lib/lemon-ui/LemonField'
import { LemonSearchableSelect } from 'lib/lemon-ui/LemonSelect/LemonSearchableSelect'
import { LemonTextArea } from 'lib/lemon-ui/LemonTextArea/LemonTextArea'
+import { Spinner } from 'lib/lemon-ui/Spinner'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { timeZoneLabel } from 'lib/utils/timezones'
import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
@@ -23,6 +24,11 @@ import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
import { ProductKey } from '~/queries/schema/schema-general'
import { ReplayVisionFeedbackButton } from '../components/ReplayVisionFeedbackButton'
+import {
+ AlertConfigFrequencyEnumApi,
+ VisionActionModeEnumApi,
+ VisionAlertMetricEnumApi,
+} from '../generated/api.schemas'
import { actionEditorSceneLogic } from './actionEditorSceneLogic'
import { DEFAULT_CADENCE } from './cadence'
import { replayScannerLogic } from './replayScannerLogic'
@@ -274,13 +280,223 @@ function TargetingSection({ scannerId }: { scannerId: string }): JSX.Element | n
)
}
+const WINDOW_OPTIONS = [
+ { value: 1, label: 'the last 24 hours' },
+ { value: 3, label: 'the last 3 days' },
+ { value: 7, label: 'the last 7 days' },
+ { value: 14, label: 'the last 14 days' },
+ { value: 30, label: 'the last 30 days' },
+]
+
+// The type-specific match controls (verdict chips / tag picker / score range), shared by both alert
+// flavors. Empty controls mean any observation matches.
+function MatchControls({ scannerId }: { scannerId: string }): JSX.Element {
+ const { actionForm } = useValues(actionEditorSceneLogic)
+ const { setActionFormValue } = useActions(actionEditorSceneLogic)
+ const { scanner } = useValues(replayScannerLogic({ id: scannerId }))
+
+ const toNumberOrNull = (val: number | undefined): number | null => (val === undefined || isNaN(val) ? null : val)
+ const isAvg = actionForm.alert_metric === VisionAlertMetricEnumApi.AvgScore
+
+ switch (scanner?.scanner_type) {
+ case 'monitor':
+ return (
+ <>
+ <span className="text-sm">with verdict</span>
+ <div className="flex gap-1">
+ {VERDICT_OPTIONS.map(({ value, label }) => (
+ <LemonButton
+ key={value}
+ size="xsmall"
+ type={actionForm.verdict.includes(value) ? 'primary' : 'secondary'}
+ onClick={() =>
+ setActionFormValue(
+ 'verdict',
+ actionForm.verdict.includes(value)
+ ? actionForm.verdict.filter((v) => v !== value)
+ : [...actionForm.verdict, value]
+ )
+ }
+ data-attr={`vision-action-alert-verdict-${value}`}
+ >
+ {label}
+ </LemonButton>
+ ))}
+ </div>
+ {actionForm.verdict.length === 0 && <span className="text-sm text-muted">(any verdict)</span>}
+ </>
+ )
+ case 'classifier': {
+ const configuredTags: string[] = scanner.scanner_config?.tags ?? []
+ const allowFreeform = !!scanner.scanner_config?.allow_freeform_tags
+ return (
+ <>
+ <span className="text-sm">tagged</span>
+ <div className="min-w-48">
+ <LemonInputSelect
+ mode="multiple"
+ size="small"
+ allowCustomValues={allowFreeform}
+ placeholder="any tag"
+ value={actionForm.tags}
+ onChange={(tags) => setActionFormValue('tags', tags)}
+ options={[...new Set([...configuredTags, ...actionForm.tags])].map((tag) => ({
+ key: tag,
+ label: tag,
+ }))}
+ data-attr="vision-action-alert-tags"
+ />
+ </div>
+ </>
+ )
+ }
+ case 'scorer':
+ if (isAvg) {
+ return <></>
+ }
+ return (
+ <>
+ <span className="text-sm">scored between</span>
+ <LemonInput
+ type="number"
+ size="small"
+ placeholder={scanner.scanner_config?.scale ? String(scanner.scanner_config.scale.min) : 'min'}
+ value={actionForm.min_score ?? undefined}
+ onChange={(val) => setActionFormValue('min_score', toNumberOrNull(val))}
+ className="w-20"
+ data-attr="vision-action-alert-min-score"
+ />
+ <span className="text-sm">and</span>
+ <LemonInput
+ type="number"
+ size="small"
+ placeholder={scanner.scanner_config?.scale ? String(scanner.scanner_config.scale.max) : 'max'}
+ value={actionForm.max_score ?? undefined}
+ onChange={(val) => setActionFormValue('max_score', toNumberOrNull(val))}
+ className="w-20"
+ data-attr="vision-action-alert-max-score"
+ />
+ </>
+ )
+ default:
+ return <></>
+ }
+}
+
+// The alert condition: pick a frequency, then either "every new match" (just the match controls) or
+// a threshold sentence over a rolling window.
+function ConditionSection({ scannerId }: { scannerId: string }): JSX.Element {
+ const { actionForm, actionFormErrors } = useValues(actionEditorSceneLogic)
+ const { setActionFormValue } = useActions(actionEditorSceneLogic)
+ const { scanner } = useValues(replayScannerLogic({ id: scannerId }))
+
+ const everyMatch = actionForm.alert_frequency === AlertConfigFrequencyEnumApi.EveryMatch
+ const isScorer = scanner?.scanner_type === 'scorer'
+
+ // Summarizer observations have no verdict/tags/score to threshold on, so the only sensible
+ // alert is "every new summary" — no frequency or threshold controls to configure. The logic
+ // normalizes the form to every_match to match (actionEditorSceneLogic.setScannerType).
+ if (scanner?.scanner_type === 'summarizer') {
+ return (
+ <div className="flex flex-col gap-2">
+ <span className="text-sm">Get notified about every new summary this scanner produces.</span>
+ <span className="text-xs text-muted">
+ Checked every few minutes; each notification covers the new summaries since the last check.
+ </span>
+ </div>
+ )
+ }
+
+ return (
+ <div className="flex flex-col gap-2">
+ <LemonSegmentedButton
+ size="small"
+ value={actionForm.alert_frequency}
+ onChange={(value) => {
+ setActionFormValue('alert_frequency', value)
+ if (value === AlertConfigFrequencyEnumApi.EveryMatch) {
+ // every_match counts new matches; an average makes no sense there.
+ setActionFormValue('alert_metric', VisionAlertMetricEnumApi.Count)
+ }
+ }}
+ options={[
+ { value: AlertConfigFrequencyEnumApi.EveryMatch, label: 'Every new match' },
+ { value: AlertConfigFrequencyEnumApi.OnBreach, label: 'When a threshold is crossed' },
+ ]}
+ data-attr="vision-action-alert-frequency"
+ />
+
+ {everyMatch ? (
+ <div className="flex flex-wrap items-center gap-2">
+ <span className="text-sm">Notify me about every new observation</span>
+ <MatchControls scannerId={scannerId} />
+ </div>
+ ) : (
+ <div className="flex flex-wrap items-center gap-2">
+ <span className="text-sm">Notify me when</span>
+ {isScorer ? (
+ <LemonSelect
+ size="small"
+ value={actionForm.alert_metric}
+ onChange={(value) => value && setActionFormValue('alert_metric', value)}
+ options={[
+ { value: VisionAlertMetricEnumApi.Count, label: 'the number of observations' },
+ { value: VisionAlertMetricEnumApi.AvgScore, label: 'the average score' },
+ ]}
+ data-attr="vision-action-alert-metric"
+ />
+ ) : (
+ <span className="text-sm">the number of observations</span>
+ )}
+ <MatchControls scannerId={scannerId} />
+ <span className="text-sm">over</span>
+ <LemonSelect
+ size="small"
+ value={actionForm.alert_window_days}
+ onChange={(value) => value != null && setActionFormValue('alert_window_days', value)}
+ options={WINDOW_OPTIONS}
+ data-attr="vision-action-alert-window"
+ />
+ <span className="text-sm">reaches</span>
+ <LemonInput
+ type="number"
+ size="small"
+ value={actionForm.alert_threshold ?? undefined}
+ onChange={(val) =>
+ setActionFormValue('alert_threshold', val === undefined || isNaN(val) ? null : val)
+ }
+ className="w-24"
+ data-attr="vision-action-alert-threshold"
+ />
+ </div>
+ )}
+ {actionFormErrors?.alert_threshold ? (
+ <span className="text-xs text-danger">{String(actionFormErrors.alert_threshold)}</span>
+ ) : null}
+ {actionFormErrors?.min_score ? (
+ <span className="text-xs text-danger">{String(actionFormErrors.min_score)}</span>
+ ) : null}
+ <span className="text-xs text-muted">
+ {everyMatch
+ ? 'Checked every few minutes; each notification covers the new matches since the last check.'
+ : "Checked about every hour over a rolling window; you're notified when the condition starts being met, and again only after it clears first."}
+ </span>
+ </div>
+ )
+}
+
function DeliverySection(): JSX.Element {
const { actionForm } = useValues(actionEditorSceneLogic)
const { setActionFormValue } = useActions(actionEditorSceneLogic)
- const { slackIntegrations } = useValues(integrationsLogic)
+ const { slackIntegrations, integrationsLoading } = useValues(integrationsLogic)
const { integration_id } = actionForm
if (!slackIntegrations?.length) {
+ // Don't flash the "add to Slack" banner (which also builds an authorize URL) while the
+ // integrations list is still loading.
+ if (integrationsLoading) {
+ return <Spinner />
+ }
return <SlackNotConfiguredBanner />
}
@@ -320,6 +536,7 @@ function DeliverySection(): JSX.Element {
export function ActionEditorSceneComponent(): JSX.Element {
const { isNew, actionLoading, loadedAction, actionForm, isActionFormSubmitting, effectiveScannerId, scannerName } =
useValues(actionEditorSceneLogic)
+ const { setActionFormValue } = useActions(actionEditorSceneLogic)
const { featureFlags } = useValues(featureFlagLogic)
if (!featureFlags[FEATURE_FLAGS.REPLAY_VISION] || !featureFlags[FEATURE_FLAGS.REPLAY_VISION_ACTIONS]) {
@@ -348,11 +565,13 @@ export function ActionEditorSceneComponent(): JSX.Element {
)
}
+ const isAlert = actionForm.mode === VisionActionModeEnumApi.Alert
+ const noun = isAlert ? 'alert' : 'group summary'
const title = isNew
? scannerName
- ? `New summary for ${scannerName}`
- : 'New summary'
- : loadedAction?.name || 'Edit summary'
+ ? `New ${noun} for ${scannerName}`
+ : `New ${noun}`
+ : loadedAction?.name || `Edit ${noun}`
const noDays = actionForm.cadence.weekdays.length === 0
const backTo = isNew
? `${urls.replayVision(effectiveScannerId)}?tab=actions`
@@ -364,7 +583,11 @@ export function ActionEditorSceneComponent(): JSX.Element {
<div className="w-full max-w-3xl px-4 flex flex-col gap-6">
<SceneTitleSection
name={title}
- description="Schedule an AI summary of this scanner's observations and deliver it to Slack."
+ description={
+ isAlert
+ ? 'Watch this scanner on a schedule and get notified only when the condition is met.'
+ : "Schedule an AI summary of this scanner's observations and deliver it to Slack."
+ }
resourceType={{ type: 'replay_vision' }}
actions={<ReplayVisionFeedbackButton />}
/>
@@ -377,36 +600,71 @@ export function ActionEditorSceneComponent(): JSX.Element {
>
<div className="bg-bg-light border rounded-lg shadow-sm p-6 flex flex-col gap-4">
<LemonField name="name" label="Name">
- <LemonInput placeholder="Daily checkout summary" autoFocus />
+ <LemonInput
+ placeholder={isAlert ? 'Rage click alert' : 'Daily checkout summary'}
+ autoFocus
+ />
</LemonField>
<div>
- <h4 className="mb-1">Schedule</h4>
- <ScheduleSection />
+ <h4 className="mb-1">Type</h4>
+ <LemonSegmentedButton
+ size="small"
+ value={actionForm.mode}
+ onChange={(value) => setActionFormValue('mode', value)}
+ options={[
+ {
+ value: VisionActionModeEnumApi.GroupSummary,
+ label: 'Scheduled group summary',
+ },
+ { value: VisionActionModeEnumApi.Alert, label: 'Alert' },
+ ]}
+ data-attr="vision-action-mode"
+ />
</div>
- {effectiveScannerId ? <TargetingSection scannerId={effectiveScannerId} /> : null}
-
- <LemonField
- name="prompt_guide"
- label="Additional guidance (optional)"
- info="Steers how the AI writes the summary."
- >
- <LemonTextArea
- placeholder="e.g. focus on issues, bugs, and friction users face — or focus on general user behavior and flows."
- maxLength={500}
- />
- </LemonField>
+ {!isAlert && (
+ <div>
+ <h4 className="mb-1">Schedule</h4>
+ <ScheduleSection />
+ </div>
+ )}
+
+ {!isAlert && effectiveScannerId ? (
+ <TargetingSection scannerId={effectiveScannerId} />
+ ) : null}
+
+ {isAlert && effectiveScannerId ? (
+ <div>
+ <h4 className="mb-1">Condition</h4>
+ <ConditionSection scannerId={effectiveScannerId} />
+ </div>
+ ) : null}
+
+ {!isAlert && (
+ <LemonField
+ name="prompt_guide"
+ label="Additional guidance (optional)"
+ info="Steers how the AI writes the summary."
+ >
+ <LemonTextArea
+ placeholder="e.g. focus on issues, bugs, and friction users face — or focus on general user behavior and flows."
+ maxLength={500}
+ />
+ </LemonField>
+ )}
<div>
<h4 className="mb-1">Deliver to Slack (optional)</h4>
<DeliverySection />
</div>
- <div className="text-xs text-muted">
- Each scheduled run generates an AI summary using your PostHog AI credits. Runs are
- skipped while you're over your AI-credit budget.
- </div>
+ {!isAlert && (
+ <div className="text-xs text-muted">
+ Each scheduled run generates an AI summary using your PostHog AI credits. Runs are
+ skipped while you're over your AI-credit budget.
+ </div>
+ )}
<div className="flex gap-2 justify-end border-t pt-4">
<LemonButton type="secondary" to={backTo} data-attr="vision-action-editor-cancel">
@@ -417,10 +675,10 @@ export function ActionEditorSceneComponent(): JSX.Element {
htmlType="submit"
form="action-editor-form"
loading={isActionFormSubmitting}
- disabledReason={noDays ? 'Pick at least one day to run on' : undefined}
+ disabledReason={!isAlert && noDays ? 'Pick at least one day to run on' : undefined}
data-attr="vision-action-editor-save"
>
- {isNew ? 'Create summary' : 'Save'}
+ {isNew ? (isAlert ? 'Create alert' : 'Create summary') : 'Save'}
</LemonButton>
</div>
</div>
diff --git a/products/replay_vision/frontend/replay_scanners/VisionActionScene.tsx b/products/replay_vision/frontend/replay_scanners/VisionActionScene.tsx
index f753dba8603c..75cf60007c95 100644
--- a/products/replay_vision/frontend/replay_scanners/VisionActionScene.tsx
+++ b/products/replay_vision/frontend/replay_scanners/VisionActionScene.tsx
@@ -16,6 +16,7 @@ import { ProductKey } from '~/queries/schema/schema-general'
import { AccessControlLevel, AccessControlResourceType } from '~/types'
import type { VisionActionApi } from '../generated/api.schemas'
+import { VisionActionModeEnumApi } from '../generated/api.schemas'
import { humanizeCadence, parseRruleToCadence } from './cadence'
import { VisionActionRuns } from './components/VisionActionRuns'
import { visionActionRunsLogic } from './visionActionRunsLogic'
@@ -37,12 +38,22 @@ function ActionOverview({
scheduleLabel: string | null
}): JSX.Element {
const guidance = action.synthesis_config?.prompt_guide?.trim()
+ const isAlert = action.mode === VisionActionModeEnumApi.Alert
+ const everyMatch = action.alert_config?.frequency === 'every_match'
return (
<>
<SceneTitleSection
name={action.name}
- description={scheduleLabel ? `Runs ${scheduleLabel.toLowerCase()}` : undefined}
+ description={
+ isAlert
+ ? everyMatch
+ ? 'Checked every few minutes; each alert covers the new matches since the last check'
+ : 'Checked about every hour; notifies when the threshold starts being crossed'
+ : scheduleLabel
+ ? `Runs ${scheduleLabel.toLowerCase()}`
+ : undefined
+ }
resourceType={{ type: 'replay_vision' }}
actions={
<AccessControlAction
@@ -60,17 +71,19 @@ function ActionOverview({
</AccessControlAction>
}
/>
- <LemonCard hoverEffect={false} className="p-4">
- <div className="text-xs font-semibold uppercase text-secondary mb-1">Summary guidance</div>
- {guidance ? (
- <p className="m-0 whitespace-pre-wrap">{guidance}</p>
- ) : (
- <p className="m-0 text-muted italic">
- No guidance set — the AI summarizes this scanner's observations freely. Edit the action to steer
- it.
- </p>
- )}
- </LemonCard>
+ {!isAlert && (
+ <LemonCard hoverEffect={false} className="p-4">
+ <div className="text-xs font-semibold uppercase text-secondary mb-1">Summary guidance</div>
+ {guidance ? (
+ <p className="m-0 whitespace-pre-wrap">{guidance}</p>
+ ) : (
+ <p className="m-0 text-muted italic">
+ No guidance set — the AI summarizes this scanner's observations freely. Edit the action to
+ steer it.
+ </p>
+ )}
+ </LemonCard>
+ )}
</>
)
}
diff --git a/products/replay_vision/frontend/replay_scanners/actionEditorSceneLogic.test.ts b/products/replay_vision/frontend/replay_scanners/actionEditorSceneLogic.test.ts
index 77ce7f1b15bb..3e47be44a677 100644
--- a/products/replay_vision/frontend/replay_scanners/actionEditorSceneLogic.test.ts
+++ b/products/replay_vision/frontend/replay_scanners/actionEditorSceneLogic.test.ts
@@ -21,14 +21,34 @@ const existingAction = {
delivery_config: [{ type: 'slack', integration_id: 5, channel: 'C123' }],
} as unknown as VisionActionApi
+const existingAlert = {
+ ...existingAction,
+ id: 'al1',
+ name: 'alert-a',
+ mode: 'alert',
+ selection: { tags: ['rage-click'] },
+ alert_config: { frequency: 'on_breach', metric: 'count', operator: 'gte', threshold: 3, window_days: 7 },
+} as unknown as VisionActionApi
+
+const summarizerAlert = {
+ ...existingAlert,
+ id: 'al2',
+ scanner: 's2',
+ selection: {},
+} as unknown as VisionActionApi
+
describe('actionEditorSceneLogic', () => {
let logic: ReturnType<typeof actionEditorSceneLogic.build>
beforeEach(() => {
useMocks({
get: {
- '/api/projects/:team/vision/actions/:id/': existingAction,
- '/api/projects/:team/vision/scanners/:id/': { id: 's1', name: 'Checkout scanner' },
+ '/api/projects/:team/vision/actions/:id/': ({ params }) =>
+ params.id === 'al1' ? existingAlert : params.id === 'al2' ? summarizerAlert : existingAction,
+ '/api/projects/:team/vision/scanners/:id/': ({ params }) =>
+ params.id === 's2'
+ ? { id: 's2', name: 'Digest scanner', scanner_type: 'summarizer' }
+ : { id: 's1', name: 'Checkout scanner', scanner_type: 'monitor' },
},
post: {
'/api/projects/:team/vision/actions/': () => [201, { ...existingAction, id: 'created' }],
@@ -74,6 +94,11 @@ describe('actionEditorSceneLogic', () => {
tags: [],
min_score: 2,
max_score: null,
+ mode: 'group_summary',
+ alert_frequency: 'every_match',
+ alert_metric: 'count',
+ alert_threshold: 1,
+ alert_window_days: 1,
},
})
@@ -85,6 +110,40 @@ describe('actionEditorSceneLogic', () => {
})
})
+ it('editing an alert seeds the mode and condition instead of flipping to summary', async () => {
+ router.actions.push(urls.replayVisionActionEdit('al1'))
+ await expectLogic(logic)
+ .toFinishAllListeners()
+ .toMatchValues({
+ targetingMode: 'filtered',
+ actionForm: expect.objectContaining({
+ mode: 'alert',
+ alert_frequency: 'on_breach',
+ alert_metric: 'count',
+ alert_threshold: 3,
+ alert_window_days: 7,
+ tags: ['rage-click'],
+ }),
+ })
+ })
+
+ it('summarizer scanners force alerts to every-match', async () => {
+ // Summarizer observations have no verdict/tags/score, so a stored on_breach threshold config
+ // must normalize to every_match — otherwise the editor shows "every new summary" while the
+ // submit would silently keep the threshold condition.
+ router.actions.push(urls.replayVisionActionEdit('al2'))
+ await expectLogic(logic)
+ .toFinishAllListeners()
+ .toMatchValues({
+ scannerType: 'summarizer',
+ actionForm: expect.objectContaining({
+ mode: 'alert',
+ alert_frequency: 'every_match',
+ alert_metric: 'count',
+ }),
+ })
+ })
+
it('creating an action submits and navigates to the new action page', async () => {
await expectLogic(logic, () => {
router.actions.push(urls.replayVisionActionNew('s1'))
diff --git a/products/replay_vision/frontend/replay_scanners/actionEditorSceneLogic.ts b/products/replay_vision/frontend/replay_scanners/actionEditorSceneLogic.ts
index 0e55ef56fae3..92c5756a859e 100644
--- a/products/replay_vision/frontend/replay_scanners/actionEditorSceneLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/actionEditorSceneLogic.ts
@@ -15,6 +15,11 @@ import {
visionActionsRetrieve,
visionScannersRetrieve,
} from '../generated/api'
+import {
+ AlertConfigFrequencyEnumApi,
+ VisionActionModeEnumApi,
+ VisionAlertMetricEnumApi,
+} from '../generated/api.schemas'
import type { VisionActionApi } from '../generated/api.schemas'
import type { actionEditorSceneLogicType } from './actionEditorSceneLogicType'
import { parseRruleToCadence } from './cadence'
@@ -27,6 +32,7 @@ export const actionEditorSceneLogic = kea<actionEditorSceneLogicType>([
actions({
setScannerId: (scannerId: string) => ({ scannerId }),
setScannerName: (scannerName: string) => ({ scannerName }),
+ setScannerType: (scannerType: string) => ({ scannerType }),
setActionId: (actionId: string) => ({ actionId }),
setTargetingMode: (mode: 'all' | 'filtered') => ({ mode }),
loadAction: (actionId: string) => ({ actionId }),
@@ -50,6 +56,15 @@ export const actionEditorSceneLogic = kea<actionEditorSceneLogicType>([
setScannerName: (_, { scannerName }) => scannerName,
},
],
+ // The bound scanner's type — drives which alert condition shapes make sense (summarizers
+ // have no verdict/tags/score, so their alerts collapse to "every new summary").
+ scannerType: [
+ '',
+ {
+ setScannerId: () => '',
+ setScannerType: (_, { scannerType }) => scannerType,
+ },
+ ],
actionId: [
'new' as string,
{
@@ -115,7 +130,7 @@ export const actionEditorSceneLogic = kea<actionEditorSceneLogicType>([
path: `${urls.replayVision(effectiveScannerId)}?tab=actions`,
})
}
- crumbs.push({ key: 'new-action', name: 'New summary' })
+ crumbs.push({ key: 'new-action', name: 'New' })
return crumbs
}
crumbs.push(
@@ -134,15 +149,33 @@ export const actionEditorSceneLogic = kea<actionEditorSceneLogicType>([
forms(({ values }) => ({
actionForm: {
defaults: NEW_ACTION_FORM(),
- errors: ({ name, cadence, min_score, max_score }: VisionActionForm) => ({
+ errors: ({
+ name,
+ cadence,
+ min_score,
+ max_score,
+ mode,
+ alert_frequency,
+ alert_threshold,
+ }: VisionActionForm) => ({
name: !name?.trim() ? 'Give this summary a name' : undefined,
// kea-forms can't carry a string error on the weekdays array, so hang it on `hour` to
// mark the form invalid and block Enter-to-submit; the visible copy is the inline text.
- cadence: cadence.weekdays.length === 0 ? { hour: 'Pick at least one day' } : undefined,
+ // Alerts have no schedule UI (checked continuously on every sweep), so weekdays don't apply.
+ cadence:
+ mode !== VisionActionModeEnumApi.Alert && cadence.weekdays.length === 0
+ ? { hour: 'Pick at least one day' }
+ : undefined,
min_score:
min_score != null && max_score != null && min_score > max_score
? "Min score can't exceed max score"
: undefined,
+ alert_threshold:
+ mode === VisionActionModeEnumApi.Alert &&
+ alert_frequency === AlertConfigFrequencyEnumApi.OnBreach &&
+ alert_threshold == null
+ ? 'Set a threshold'
+ : undefined,
}),
submit: async (form: VisionActionForm) => {
const teamId = teamLogic.values.currentTeamId
@@ -156,13 +189,17 @@ export const actionEditorSceneLogic = kea<actionEditorSceneLogicType>([
const body = buildActionBody(form, scannerId)
if (values.isNew) {
const created = await visionActionsCreate(String(teamId), body)
- lemonToast.success('Summary created')
+ lemonToast.success(
+ form.mode === VisionActionModeEnumApi.Alert ? 'Alert created' : 'Group summary created'
+ )
visionActionsLogic.findMounted({ scannerId })?.actions.loadActions()
router.actions.push(urls.replayVisionAction(created.id))
return
}
const updated = await visionActionsPartialUpdate(String(teamId), values.actionId, body)
- lemonToast.success('Summary updated')
+ lemonToast.success(
+ form.mode === VisionActionModeEnumApi.Alert ? 'Alert updated' : 'Group summary updated'
+ )
visionActionsLogic.findMounted({ scannerId })?.actions.loadActions()
const runsLogic = visionActionRunsLogic.findMounted({ actionId: updated.id })
runsLogic?.actions.loadAction()
@@ -181,10 +218,8 @@ export const actionEditorSceneLogic = kea<actionEditorSceneLogicType>([
},
setScannerId: async ({ scannerId }, breakpoint) => {
- // Only fetch the scanner name on the new-action route — the edit title uses the action name instead.
- if (!values.isNew) {
- return
- }
+ // Fetched on both routes: the new-action title needs the name, and alert-condition
+ // normalization needs the scanner type (see setScannerType below).
const teamId = teamLogic.values.currentTeamId
if (!scannerId || !teamId) {
return
@@ -193,11 +228,35 @@ export const actionEditorSceneLogic = kea<actionEditorSceneLogicType>([
const scanner = await visionScannersRetrieve(String(teamId), scannerId)
breakpoint()
actions.setScannerName(scanner.name)
+ actions.setScannerType(scanner.scanner_type)
} catch {
// Display-only — the title falls back to "New summary".
}
},
+ setScannerType: ({ scannerType }) => {
+ // Summarizer observations carry no verdict/tags/score, so threshold alerts don't apply:
+ // their alerts are always "every new summary". Normalizing the form (not just the UI)
+ // keeps validation and the submitted alert_config consistent with what the editor shows.
+ if (scannerType === 'summarizer' && values.actionForm.mode === VisionActionModeEnumApi.Alert) {
+ actions.setActionFormValues({
+ alert_frequency: AlertConfigFrequencyEnumApi.EveryMatch,
+ alert_metric: VisionAlertMetricEnumApi.Count,
+ })
+ }
+ },
+
+ setActionFormValue: ({ name, value }) => {
+ // Switching an existing action to alert mode on a summarizer scanner gets the same
+ // normalization as loading one.
+ if (name === 'mode' && value === VisionActionModeEnumApi.Alert && values.scannerType === 'summarizer') {
+ actions.setActionFormValues({
+ alert_frequency: AlertConfigFrequencyEnumApi.EveryMatch,
+ alert_metric: VisionAlertMetricEnumApi.Count,
+ })
+ }
+ },
+
loadAction: async ({ actionId }, breakpoint) => {
const teamId = teamLogic.values.currentTeamId
if (!teamId) {
@@ -234,6 +293,17 @@ export const actionEditorSceneLogic = kea<actionEditorSceneLogicType>([
prompt_guide: action.synthesis_config?.prompt_guide ?? '',
integration_id: action.delivery_config?.[0]?.integration_id ?? null,
channel: action.delivery_config?.[0]?.channel ?? '',
+ mode: action.mode ?? VisionActionModeEnumApi.GroupSummary,
+ // Stored alerts without a frequency predate the field and behaved as on_breach; anything
+ // else gets the fresh-form default so flipping a summary to an alert starts at every_match.
+ alert_frequency:
+ action.alert_config?.frequency ??
+ (action.mode === VisionActionModeEnumApi.Alert
+ ? AlertConfigFrequencyEnumApi.OnBreach
+ : AlertConfigFrequencyEnumApi.EveryMatch),
+ alert_metric: action.alert_config?.metric ?? VisionAlertMetricEnumApi.Count,
+ alert_threshold: action.alert_config?.threshold ?? 1,
+ alert_window_days: action.alert_config?.window_days ?? 1,
verdict: action.selection?.verdict ?? [],
tags: action.selection?.tags ?? [],
min_score: action.selection?.min_score ?? null,
diff --git a/products/replay_vision/frontend/replay_scanners/components/VisionActionRuns.tsx b/products/replay_vision/frontend/replay_scanners/components/VisionActionRuns.tsx
index 1455613dd78d..97fcc775672e 100644
--- a/products/replay_vision/frontend/replay_scanners/components/VisionActionRuns.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/VisionActionRuns.tsx
@@ -9,6 +9,7 @@ import { humanFriendlyNumber } from 'lib/utils/numbers'
import { urls } from 'scenes/urls'
import type { VisionActionRunListApi } from '../../generated/api.schemas'
+import { VisionActionModeEnumApi } from '../../generated/api.schemas'
import { visionActionRunsLogic } from '../visionActionRunsLogic'
import { RunStatusTag } from '../visionActionRunStatus'
import { visionActionSceneLogic } from '../visionActionSceneLogic'
@@ -34,11 +35,20 @@ function StatCell({
function RunStats(): JSX.Element {
const { action, runsCount } = useValues(visionActionRunsLogic)
const disabled = action?.enabled === false
+ // Quiet alert checks (condition not met) don't appear in the run list, so for alerts the time
+ // cells speak in terms of checks: "last checked" can be much more recent than the newest row.
+ const isAlert = action?.mode === VisionActionModeEnumApi.Alert
+ // every_match rides each scanner sweep; on_breach thresholds are re-checked hourly.
+ const everyMatch = action?.alert_config?.frequency === 'every_match'
return (
<div className="flex flex-wrap sm:flex-nowrap items-stretch border rounded bg-surface-primary">
- <StatCell title="Total runs" value={humanFriendlyNumber(runsCount)} description="all time" />
<StatCell
- title="Last run"
+ title={isAlert ? 'Alerts' : 'Total runs'}
+ value={humanFriendlyNumber(runsCount)}
+ description="all time"
+ />
+ <StatCell
+ title={isAlert ? 'Last checked' : 'Last run'}
value={
action?.last_run_at ? (
<TZLabel time={action.last_run_at} formatDate="MMM D, YYYY" formatTime="HH:mm" />
@@ -46,32 +56,43 @@ function RunStats(): JSX.Element {
'Never'
)
}
+ description={
+ isAlert ? (everyMatch ? 'checked every few minutes' : 'checked about every hour') : undefined
+ }
/>
<StatCell
- title="Next run"
+ title={isAlert ? 'Next check' : 'Next run'}
value={
disabled ? (
'N/A'
+ ) : isAlert && everyMatch ? (
+ // every_match checks ride each sweep; the rrule cursor is vestigial there and
+ // showing it would overstate the gap between checks. on_breach follows the cursor.
+ 'Within minutes'
) : action?.next_run_at ? (
<TZLabel time={action.next_run_at} formatDate="MMM D, YYYY" formatTime="HH:mm" />
) : (
'—'
)
}
- description={disabled ? 'Action disabled' : undefined}
+ description={disabled ? (isAlert ? 'Alert disabled' : 'Action disabled') : undefined}
/>
</div>
)
}
function EmptyRuns(): JSX.Element {
+ const { action } = useValues(visionActionRunsLogic)
+ const isAlert = action?.mode === VisionActionModeEnumApi.Alert
+ const everyMatch = action?.alert_config?.frequency === 'every_match'
return (
<div className="flex flex-col items-center text-center gap-3 py-10">
<SleepingHog className="w-40 h-40" />
- <h3 className="m-0">Your action is live</h3>
+ <h3 className="m-0">{isAlert ? 'Your alert is live' : 'Your action is live'}</h3>
<p className="text-muted max-w-md">
- Results will show up after its next scheduled run. Once it runs, you'll see the summaries here — check
- back soon.
+ {isAlert
+ ? `Checks run ${everyMatch ? 'every few minutes' : 'about every hour'}. When the condition is met, the alert and its matching observations show up here.`
+ : "Results will show up after its next scheduled run. Once it runs, you'll see the summaries here — check back soon."}
</p>
</div>
)
diff --git a/products/replay_vision/frontend/replay_scanners/components/VisionActionsTab.tsx b/products/replay_vision/frontend/replay_scanners/components/VisionActionsTab.tsx
index 2816ee5231c3..3fffd77c5c99 100644
--- a/products/replay_vision/frontend/replay_scanners/components/VisionActionsTab.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/VisionActionsTab.tsx
@@ -22,6 +22,13 @@ import { visionActionsLogic } from '../visionActionsLogic'
const HedgehogXRay = pngHoggie(xRayPng)
function humanizeSchedule(action: VisionActionApi): string {
+ // Alerts don't run on their stored rrule: every_match checks ride each scanner sweep, and
+ // on_breach thresholds are re-checked hourly.
+ if (action.mode === 'alert') {
+ return action.alert_config?.frequency === 'every_match'
+ ? 'Continuous (checked every few minutes)'
+ : 'Continuous (hourly checks)'
+ }
const rrule = action.trigger_config?.rrule
if (!rrule) {
return '—'
@@ -78,11 +85,11 @@ function VisionActionsTable({ scannerId }: { scannerId: string }): JSX.Element {
if (!visionActionsLoading && visionActions.length === 0) {
return (
<ProductIntroduction
- productName="Scheduled summaries"
- thingName="summary"
+ productName="Summaries and alerts"
+ thingName="group summary or alert"
isEmpty
customHog={HedgehogXRay}
- description="Set up scheduled summaries of this scanner's observations — synthesized by AI and delivered to Slack on the cadence you choose. Great for a daily digest of what the scanner has been finding."
+ description="Get scheduled group summaries of this scanner's observations — synthesized by AI on the cadence you choose — or alerts that notify you when new matches appear or a threshold is reached. Both can deliver to Slack."
actionElementOverride={
<EditorGate>
<LemonButton
@@ -91,7 +98,7 @@ function VisionActionsTable({ scannerId }: { scannerId: string }): JSX.Element {
to={urls.replayVisionActionNew(scannerId)}
data-attr="vision-action-new-empty"
>
- New summary
+ New group summary or alert
</LemonButton>
</EditorGate>
}
@@ -113,6 +120,7 @@ function VisionActionsTable({ scannerId }: { scannerId: string }): JSX.Element {
{action.name}
</Link>
{action.is_scanner_digest && <LemonTag type="highlight">Default</LemonTag>}
+ {action.mode === 'alert' && <LemonTag type="warning">Alert</LemonTag>}
</span>
),
},
@@ -218,7 +226,7 @@ function VisionActionsTable({ scannerId }: { scannerId: string }): JSX.Element {
to={urls.replayVisionActionNew(scannerId)}
data-attr="vision-action-new"
>
- New summary
+ New group summary or alert
</LemonButton>
</EditorGate>
</div>
@@ -228,7 +236,7 @@ function VisionActionsTable({ scannerId }: { scannerId: string }): JSX.Element {
loading={visionActionsLoading}
rowKey="id"
data-attr="vision-actions-table"
- emptyState="No summaries scheduled for this scanner yet."
+ emptyState="No group summaries or alerts set up for this scanner yet."
/>
</div>
)
diff --git a/products/replay_vision/frontend/replay_scanners/visionActionsLogic.test.ts b/products/replay_vision/frontend/replay_scanners/visionActionsLogic.test.ts
index 9f2b3ee6e756..c4bc91411ef5 100644
--- a/products/replay_vision/frontend/replay_scanners/visionActionsLogic.test.ts
+++ b/products/replay_vision/frontend/replay_scanners/visionActionsLogic.test.ts
@@ -100,10 +100,16 @@ describe('visionActionsLogic', () => {
tags: ['bug'],
min_score: 1,
max_score: 5,
+ mode: 'group_summary',
+ alert_frequency: 'on_breach',
+ alert_metric: 'count',
+ alert_threshold: 1,
+ alert_window_days: 1,
}
expect(buildActionBody(form, 's1')).toEqual({
name: 'Daily digest', // trimmed
scanner: 's1',
+ mode: 'group_summary',
trigger_config: { rrule: 'FREQ=WEEKLY;BYDAY=MO,WE;BYHOUR=14;BYMINUTE=30', timezone: 'Europe/Prague' },
selection: { verdict: ['yes'], tags: ['bug'], min_score: 1, max_score: 5 },
synthesis_config: { prompt_guide: 'focus on checkout' },
@@ -125,9 +131,55 @@ describe('visionActionsLogic', () => {
tags: [],
min_score: null,
max_score: null,
+ mode: 'group_summary',
+ alert_frequency: 'on_breach',
+ alert_metric: 'count',
+ alert_threshold: 1,
+ alert_window_days: 1,
}
- expect(buildActionBody(form, 's1').delivery_config).toEqual([])
+ const body = buildActionBody(form, 's1')
+ expect(body.delivery_config).toEqual([])
// Empty selection is sent explicitly so clearing targeting on edit persists as "run on everything".
- expect(buildActionBody(form, 's1').selection).toEqual({})
+ expect(body.selection).toEqual({})
+ // A summary must not carry an alert condition even though the form holds the defaults.
+ expect(body.alert_config).toBeUndefined()
+ })
+
+ it('buildActionBody sends the alert condition and drops the prompt guide for alert mode', () => {
+ const form: VisionActionForm = {
+ name: 'Rage click alert',
+ cadence: { weekdays: [0, 1, 2, 3, 4, 5, 6], hour: 9, minute: 0 },
+ timezone: 'UTC',
+ prompt_guide: 'leftover from summary mode',
+ integration_id: null,
+ channel: '',
+ verdict: [],
+ tags: ['rage-click'],
+ min_score: null,
+ max_score: null,
+ mode: 'alert',
+ alert_frequency: 'on_breach',
+ alert_metric: 'count',
+ alert_threshold: 1,
+ alert_window_days: 1,
+ }
+ const body = buildActionBody(form, 's1')
+ expect(body.mode).toEqual('alert')
+ expect(body.alert_config).toEqual({
+ frequency: 'on_breach',
+ metric: 'count',
+ threshold: 1,
+ window_days: 1,
+ })
+ expect(body.selection).toEqual({ tags: ['rage-click'] })
+ // Alerts have no user-facing schedule; the stored rrule keeps the trigger well-formed while
+ // the engine checks them on every sweep.
+ expect(body.trigger_config).toEqual({ rrule: 'FREQ=HOURLY', timezone: 'UTC' })
+ // Alerts never synthesize, so a stale guide from a mode switch must not persist.
+ expect(body.synthesis_config).toEqual({ prompt_guide: '' })
+
+ // Every-match alerts carry no threshold machinery — just the frequency and the count metric.
+ const everyMatch = buildActionBody({ ...form, alert_frequency: 'every_match' }, 's1')
+ expect(everyMatch.alert_config).toEqual({ frequency: 'every_match', metric: 'count' })
})
})
diff --git a/products/replay_vision/frontend/replay_scanners/visionActionsLogic.ts b/products/replay_vision/frontend/replay_scanners/visionActionsLogic.ts
index a902983042f3..dccf1afe8c8d 100644
--- a/products/replay_vision/frontend/replay_scanners/visionActionsLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/visionActionsLogic.ts
@@ -10,7 +10,13 @@ import {
visionActionsList,
visionActionsPartialUpdate,
} from '../generated/api'
-import { DeliveryTargetTypeEnumApi } from '../generated/api.schemas'
+import {
+ AlertConfigFrequencyEnumApi,
+ DeliveryTargetTypeEnumApi,
+ VisionActionModeEnumApi,
+ VisionAlertMetricEnumApi,
+ WindowDaysEnumApi,
+} from '../generated/api.schemas'
import type { VerdictEnumApi, VisionActionApi } from '../generated/api.schemas'
import { CadenceState, cadenceToRrule, DEFAULT_CADENCE } from './cadence'
import type { visionActionsLogicType } from './visionActionsLogicType'
@@ -32,6 +38,12 @@ export interface VisionActionForm {
tags: string[]
min_score: number | null
max_score: number | null
+ // What the action produces; alerts carry a condition instead of synthesizing a summary.
+ mode: VisionActionModeEnumApi
+ alert_frequency: AlertConfigFrequencyEnumApi
+ alert_metric: VisionAlertMetricEnumApi
+ alert_threshold: number | null
+ alert_window_days: WindowDaysEnumApi
}
export const NEW_ACTION_FORM = (): VisionActionForm => ({
@@ -45,6 +57,12 @@ export const NEW_ACTION_FORM = (): VisionActionForm => ({
tags: [],
min_score: null,
max_score: null,
+ mode: VisionActionModeEnumApi.GroupSummary,
+ // Default alert flavor: notify about every new match ("every time the result is X, tell me").
+ alert_frequency: AlertConfigFrequencyEnumApi.EveryMatch,
+ alert_metric: VisionAlertMetricEnumApi.Count,
+ alert_threshold: 1,
+ alert_window_days: 1,
})
// Map the UI form shape to the API body shared by create + partial-update. Kept standalone so the
@@ -66,12 +84,31 @@ export function buildActionBody(form: VisionActionForm, scannerId: string): Para
if (form.max_score != null) {
selection.max_score = form.max_score
}
+ const isAlert = form.mode === VisionActionModeEnumApi.Alert
return {
name: form.name.trim(),
scanner: scannerId,
- trigger_config: { rrule: cadenceToRrule(form.cadence), timezone: form.timezone },
+ mode: form.mode,
+ // Alerts have no user-facing schedule: the engine checks them on every scanner sweep and
+ // ignores this rrule (kept so the trigger stays well-formed); summaries run on the picked days/time.
+ trigger_config: isAlert
+ ? { rrule: 'FREQ=HOURLY', timezone: form.timezone }
+ : { rrule: cadenceToRrule(form.cadence), timezone: form.timezone },
selection,
- synthesis_config: { prompt_guide: form.prompt_guide },
+ synthesis_config: { prompt_guide: isAlert ? '' : form.prompt_guide },
+ ...(isAlert
+ ? {
+ alert_config:
+ form.alert_frequency === AlertConfigFrequencyEnumApi.EveryMatch
+ ? { frequency: form.alert_frequency, metric: VisionAlertMetricEnumApi.Count }
+ : {
+ frequency: form.alert_frequency,
+ metric: form.alert_metric,
+ threshold: form.alert_threshold ?? 1,
+ window_days: form.alert_window_days,
+ },
+ }
+ : {}),
delivery_config:
form.integration_id && form.channel
? [