: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(alerts): clarify snoozed alert status (#86972)
Vasco de Krijger17e98594788c
diff --git a/products/alerts/frontend/components/AlertDefinition.tsx b/products/alerts/frontend/components/AlertDefinition.tsxindex cd7e4ad03609..3f1901e8185e 100644--- a/products/alerts/frontend/components/AlertDefinition.tsx+++ b/products/alerts/frontend/components/AlertDefinition.tsx@@ -33,7 +33,7 @@ export function AlertStateIndicator({ alert }: { alert: AlertType }): JSX.Elemencase AlertState.ERRORED:return <LemonTag type="danger">Errored</LemonTag>case AlertState.SNOOZED:- return <LemonTag type="muted">Snoozed</LemonTag>+ return <LemonTag type="completion">Snoozed</LemonTag>case AlertState.NOT_FIRING:return <LemonTag type="success">Not firing</LemonTag>}diff --git a/products/alerts/frontend/logic/alertFormLogic.ts b/products/alerts/frontend/logic/alertFormLogic.tsindex 4637dd7a809f..541dbdb6da7c 100644--- a/products/alerts/frontend/logic/alertFormLogic.ts+++ b/products/alerts/frontend/logic/alertFormLogic.ts@@ -274,6 +274,7 @@ export interface alertFormLogicValues {alertFormTouched: booleanalertFormTouches: Record<string, boolean>alertFormValidationErrors: DeepPartialMap<AlertFormType, ValidationErrorType>+ clearSnoozeLoading: booleanfunnelAlertPreview: FunnelAlertPreview | nullhogqlAlertPreview: HogQLAlertPreview | nullhogqlConfigPrefill: Partial<Pick<HogQLAlertConfig, 'column' | 'label_column'>> | null@@ -345,6 +346,9 @@ export interface alertFormLogicActions {setAlertFormValues: (values: DeepPartial<AlertFormType>) => {values: DeepPartial<AlertFormType>}+ setClearSnoozeLoading: (loading: boolean) => {+ loading: boolean+ }setSimulationDateFrom: (dateFrom: string) => {dateFrom: string}@@ -473,6 +477,7 @@ export const alertFormLogic = kea<alertFormLogicType>([clearSimulation: true,setSimulationDateFrom: (dateFrom: string) => ({ dateFrom }),setAlertFormSubmitAttempted: true,+ setClearSnoozeLoading: (loading: boolean) => ({ loading }),}),reducers({@@ -489,6 +494,12 @@ export const alertFormLogic = kea<alertFormLogicType>([submitAlertFormSuccess: () => false,},],+ clearSnoozeLoading: [+ false,+ {+ setClearSnoozeLoading: (_, { loading }) => loading,+ },+ ],}),loaders(({ props, values }) => ({@@ -883,14 +894,25 @@ export const alertFormLogic = kea<alertFormLogicType>([if (!values.alertForm.id) {throw new Error("Cannot resolve alert that doesn't exist")}- const updatedAlert: AlertType = await api.alerts.update(values.alertForm.id, {- snoozed_until: null,- })- hydrateAlertLogicFromSaveResponse(updatedAlert)- const parent = getParentLogic()- if (parent) {- parent.actions.upsertAlert(updatedAlert)- parent.actions.loadAlerts()+ actions.setClearSnoozeLoading(true)+ try {+ const updatedAlert: AlertType = await api.alerts.update(values.alertForm.id, {+ snoozed_until: null,+ })+ hydrateAlertLogicFromSaveResponse(updatedAlert)+ const parent = getParentLogic()+ if (parent) {+ parent.actions.upsertAlert(updatedAlert)+ parent.actions.loadAlerts()+ }+ } catch (error) {+ lemonToast.error("We couldn't unsnooze this alert. Please try again.")+ posthog.captureException(error, {+ action: 'clear alert snooze',+ alertId: values.alertForm.id,+ })+ } finally {+ actions.setClearSnoozeLoading(false)}},submitAlertForm: () => {diff --git a/products/alerts/frontend/views/EditAlertModal.tsx b/products/alerts/frontend/views/EditAlertModal.tsxindex 3b65c83bf659..dd7563fff046 100644--- a/products/alerts/frontend/views/EditAlertModal.tsx+++ b/products/alerts/frontend/views/EditAlertModal.tsx@@ -166,6 +166,7 @@ export function EditAlertModal(props: AlertModalProps): JSX.Element {simulationResult,simulationResultLoading,simulationDateFrom,+ clearSnoozeLoading,thresholdBoundsFormError,hogqlAlertPreview,funnelAlertPreview,@@ -306,6 +307,7 @@ export function EditAlertModal(props: AlertModalProps): JSX.Element {onDeleteAlert={deleteAlert}onSnoozeAlert={snoozeAlert}onClearSnooze={clearSnooze}+ clearSnoozeLoading={clearSnoozeLoading}onSendTestDelivery={sendTestDelivery}testDeliveryLoading={testDeliveryResultLoading}testDeliveryDisabledReason={diff --git a/products/alerts/frontend/views/EditAlertModal/AlertLeadingActions.test.tsx b/products/alerts/frontend/views/EditAlertModal/AlertLeadingActions.test.tsxindex 9e08d0b22ca9..2f887f8ee3ca 100644--- a/products/alerts/frontend/views/EditAlertModal/AlertLeadingActions.test.tsx+++ b/products/alerts/frontend/views/EditAlertModal/AlertLeadingActions.test.tsx@@ -28,6 +28,7 @@ describe('AlertLeadingActions', () => {onDeleteAlert={() => {}}onSnoozeAlert={() => {}}onClearSnooze={() => {}}+ clearSnoozeLoading={false}onSendTestDelivery={() => {}}testDeliveryLoading={false}showTestDelivery={false}@@ -41,4 +42,35 @@ describe('AlertLeadingActions', () => {}expect(deleteAction).toBeNull()})++ it.each([+ ['with an expiry', '2026-08-21T14:30:00Z', false, /Snoozed until/],+ ['without an expiry', null, false, /^Snoozed$/],+ ['while unsnoozing', '2026-08-21T14:30:00Z', true, /Snoozed until/],+ ])('shows the snoozed state %s', (_, snoozedUntil, loading, expectedLabel) => {+ const snoozedAlert = {+ ...alert,+ state: AlertState.SNOOZED,+ snoozed_until: snoozedUntil,+ } as AlertType++ render(+ <AlertLeadingActions+ alertForm={alertForm}+ alert={snoozedAlert}+ onDeleteAlert={() => {}}+ onSnoozeAlert={() => {}}+ onClearSnooze={() => {}}+ clearSnoozeLoading={loading}+ onSendTestDelivery={() => {}}+ testDeliveryLoading={false}+ showTestDelivery={false}+ />+ )++ expect(screen.getByText(expectedLabel)).not.toBeNull()+ expect(screen.getByLabelText('Unsnooze alert').getAttribute('aria-disabled')).toBe(String(loading))+ expect(screen.queryByText('Snooze until')).toBeNull()+ expect(screen.queryByText('Clear snooze')).toBeNull()+ })})diff --git a/products/alerts/frontend/views/EditAlertModal/AlertLeadingActions.tsx b/products/alerts/frontend/views/EditAlertModal/AlertLeadingActions.tsxindex 5be5df2e91f4..856ffb941909 100644--- a/products/alerts/frontend/views/EditAlertModal/AlertLeadingActions.tsx+++ b/products/alerts/frontend/views/EditAlertModal/AlertLeadingActions.tsx@@ -1,3 +1,4 @@+import { IconClock, IconX } from '@posthog/icons'import { LemonDialog } from '@posthog/lemon-ui'import { dayjs } from 'lib/dayjs'@@ -18,6 +19,7 @@ interface AlertLeadingActionsProps {onDeleteAlert: () => voidonSnoozeAlert: (snoozeUntil: string) => voidonClearSnooze: () => void+ clearSnoozeLoading: booleanonSendTestDelivery: () => voidtestDeliveryLoading: booleantestDeliveryDisabledReason?: string@@ -30,11 +32,14 @@ export function AlertLeadingActions({onDeleteAlert,onSnoozeAlert,onClearSnooze,+ clearSnoozeLoading,onSendTestDelivery,testDeliveryLoading,testDeliveryDisabledReason,showTestDelivery,}: AlertLeadingActionsProps): JSX.Element {+ const isSnoozed = alert?.state === AlertState.SNOOZED+return (<div className="flex flex-wrap items-center gap-2">{alert ? (@@ -59,11 +64,14 @@ export function AlertLeadingActions({Delete alert</LemonButton>) : null}- <SnoozeButton- onChange={onSnoozeAlert}- value={alert?.snoozed_until}- disabledReason={alert?.state === AlertState.FIRING ? undefined : 'Only firing alerts can be snoozed'}- />+ {!isSnoozed ? (+ <SnoozeButton+ onChange={onSnoozeAlert}+ disabledReason={+ alert?.state === AlertState.FIRING ? undefined : 'Only firing alerts can be snoozed'+ }+ />+ ) : null}{showTestDelivery ? (<LemonButtontype="secondary"@@ -74,15 +82,24 @@ export function AlertLeadingActions({Test delivery</LemonButton>) : null}- {alert?.state === AlertState.SNOOZED ? (- <LemonButton- type="secondary"- status="default"- onClick={onClearSnooze}- tooltip={`Currently snoozed until ${formatDate(dayjs(alert.snoozed_until), 'MMM D, HH:mm')}`}- >- Clear snooze- </LemonButton>+ {isSnoozed ? (+ <div className="flex items-center gap-1.5 text-sm text-muted-alt">+ <IconClock className="size-4" />+ <span>+ {alert.snoozed_until+ ? `Snoozed until ${formatDate(dayjs(alert.snoozed_until), 'MMM D, HH:mm')}`+ : 'Snoozed'}+ </span>+ <LemonButton+ type="tertiary"+ size="xsmall"+ icon={<IconX />}+ onClick={onClearSnooze}+ loading={clearSnoozeLoading}+ tooltip="Unsnooze alert"+ aria-label="Unsnooze alert"+ />+ </div>) : null}</div>)