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(workflows): archive, restore and delete broadcasts (#107865)

Daniel Marchuk2229c0193181
diff --git a/products/workflows/frontend/Broadcasts/BroadcastSummary.tsx b/products/workflows/frontend/Broadcasts/BroadcastSummary.tsx
index 22b8d6fa70bc..11c127b6d62d 100644
--- a/products/workflows/frontend/Broadcasts/BroadcastSummary.tsx
+++ b/products/workflows/frontend/Broadcasts/BroadcastSummary.tsx
@@ -27,6 +27,7 @@ import type { HogFlowBatchJobApi } from 'products/workflows/frontend/generated/a
import { EmailViewerModal } from '../Workflows/EmailViewerModal'
import type { MessageAsset } from '../Workflows/messageAssetsApi'
import { BroadcastEmailPreview } from './BroadcastEmailPreview'
+import { archiveDisabledReason, manageDisabledReason } from './broadcastLifecycle'
import { BroadcastPerformance } from './BroadcastPerformance'
import { BroadcastSceneHeader } from './BroadcastSceneHeader'
import { broadcastSentLogic } from './broadcastSentLogic'
@@ -261,6 +262,7 @@ export function BroadcastSummary(): JSX.Element {
scheduleSummary,
batchJobs,
batchJobsLoading,
+ hasLoadedBatchJobs,
canMoveToDraft,
movingToDraft,
canEditContent,
@@ -268,7 +270,8 @@ export function BroadcastSummary(): JSX.Element {
summaryStatus,
summaryTab,
} = useValues(broadcastWizardLogic)
- const { moveToDraft, duplicateBroadcast, setSummaryTab } = useActions(broadcastWizardLogic)
+ const { moveToDraft, duplicateBroadcast, setSummaryTab, archiveBroadcast, restoreBroadcast, deleteBroadcast } =
+ useActions(broadcastWizardLogic)
const pendingSchedule = broadcast?.schedules?.find((schedule) => schedule.status === 'active')
const confirmMoveToDraft = (): void => {
@@ -311,44 +314,62 @@ export function BroadcastSummary(): JSX.Element {
},
]
- const actionsMenu =
- canMoveToDraft || canEditContent ? (
- <LemonMenu
- items={[
- canMoveToDraft
- ? {
- label: 'Stop and edit',
- onClick: confirmMoveToDraft,
- 'data-attr': 'broadcast-move-to-draft',
- }
- : null,
- canEditContent
- ? {
- label: 'Send again as a new broadcast',
- onClick: duplicateBroadcast,
- 'data-attr': 'broadcast-send-again',
- }
- : null,
- ]}
+ const isArchived = broadcast?.status === 'archived'
+ const accessReason = manageDisabledReason(broadcast?.user_access_level)
+ const actionItems = [
+ canMoveToDraft
+ ? { label: 'Stop and edit', onClick: confirmMoveToDraft, 'data-attr': 'broadcast-move-to-draft' }
+ : null,
+ canEditContent
+ ? {
+ label: 'Send again as a new broadcast',
+ onClick: duplicateBroadcast,
+ 'data-attr': 'broadcast-send-again',
+ }
+ : null,
+ isArchived
+ ? {
+ label: 'Restore as draft',
+ onClick: restoreBroadcast,
+ disabledReason: accessReason,
+ 'data-attr': 'broadcast-restore',
+ }
+ : {
+ label: 'Archive',
+ status: 'danger' as const,
+ onClick: archiveBroadcast,
+ disabledReason:
+ accessReason ??
+ archiveDisabledReason(hasLoadedBatchJobs ? batchJobs.map((job) => job.status) : null),
+ 'data-attr': 'broadcast-archive',
+ },
+ isArchived
+ ? {
+ label: 'Delete',
+ status: 'danger' as const,
+ onClick: deleteBroadcast,
+ disabledReason: accessReason,
+ 'data-attr': 'broadcast-delete',
+ }
+ : null,
+ ]
+ const actionsMenu = (
+ <LemonMenu items={actionItems}>
+ <LemonButton
+ type="secondary"
+ size="small"
+ sideIcon={<IconChevronDown />}
+ loading={movingToDraft || duplicating}
+ data-attr="broadcast-actions"
>
- <LemonButton
- type="secondary"
- size="small"
- sideIcon={<IconChevronDown />}
- loading={movingToDraft || duplicating}
- data-attr="broadcast-actions"
- >
- Actions
- </LemonButton>
- </LemonMenu>
- ) : null
+ Actions
+ </LemonButton>
+ </LemonMenu>
+ )
return (
<SceneContent className="@container min-h-full w-full shrink-0" data-attr="broadcast-summary">
- <BroadcastSceneHeader
- nameSuffix={<BroadcastStatusTag status={summaryStatus} />}
- actions={actionsMenu ?? undefined}
- />
+ <BroadcastSceneHeader nameSuffix={<BroadcastStatusTag status={summaryStatus} />} actions={actionsMenu} />
<div className="mx-auto w-full max-w-6xl space-y-4">
{summaryStatus === 'failed' && !latestBatchJob && !batchJobsLoading ? (
<LemonBanner
diff --git a/products/workflows/frontend/Broadcasts/BroadcastWizard.tsx b/products/workflows/frontend/Broadcasts/BroadcastWizard.tsx
index 554115c11938..1064c38d1ec6 100644
--- a/products/workflows/frontend/Broadcasts/BroadcastWizard.tsx
+++ b/products/workflows/frontend/Broadcasts/BroadcastWizard.tsx
@@ -1,9 +1,13 @@
import { useActions, useValues } from 'kea'
+import { IconChevronDown } from '@posthog/icons'
import { LemonButton } from '@posthog/lemon-ui'
+import { LemonMenu } from 'lib/lemon-ui/LemonMenu'
+
import { SceneContent } from '~/layout/scenes/components/SceneContent'
+import { manageDisabledReason } from './broadcastLifecycle'
import { BroadcastSceneHeader } from './BroadcastSceneHeader'
import { broadcastWizardLogic } from './broadcastWizardLogic'
import { BroadcastWizardStepper } from './BroadcastWizardStepper'
@@ -16,11 +20,41 @@ import { BroadcastScheduleStep } from './steps/BroadcastScheduleStep'
export function BroadcastWizard(): JSX.Element {
const { currentStep, stepValidationErrors, currentStepHasErrors, saving, launching, scheduleMode } =
useValues(broadcastWizardLogic)
- const { setStep, prevStep, continueStep, launchBroadcast } = useActions(broadcastWizardLogic)
+ const { setStep, prevStep, continueStep, launchBroadcast, archiveBroadcast } = useActions(broadcastWizardLogic)
+ const { broadcastId, broadcast } = useValues(broadcastWizardLogic)
return (
<SceneContent className="min-h-full w-full shrink-0" data-attr="broadcast-wizard">
- <BroadcastSceneHeader canEdit />
+ <BroadcastSceneHeader
+ canEdit
+ actions={
+ // A draft not saved yet has nothing to archive.
+ broadcastId ? (
+ <LemonMenu
+ items={[
+ {
+ label: 'Archive',
+ status: 'danger',
+ onClick: archiveBroadcast,
+ disabledReason:
+ manageDisabledReason(broadcast?.user_access_level) ??
+ (saving || launching ? 'Wait for the broadcast to finish saving' : undefined),
+ 'data-attr': 'broadcast-archive',
+ },
+ ]}
+ >
+ <LemonButton
+ type="secondary"
+ size="small"
+ sideIcon={<IconChevronDown />}
+ data-attr="broadcast-actions"
+ >
+ Actions
+ </LemonButton>
+ </LemonMenu>
+ ) : undefined
+ }
+ />
<div className="mx-auto w-full max-w-4xl space-y-5">
<div className="space-y-3">
<div className="flex justify-center">
diff --git a/products/workflows/frontend/Broadcasts/BroadcastsTable.tsx b/products/workflows/frontend/Broadcasts/BroadcastsTable.tsx
index e9b32c96de70..784586811134 100644
--- a/products/workflows/frontend/Broadcasts/BroadcastsTable.tsx
+++ b/products/workflows/frontend/Broadcasts/BroadcastsTable.tsx
@@ -4,6 +4,7 @@ import { LemonInput, LemonSelect, LemonTag } from '@posthog/lemon-ui'
import { MemberSelect } from 'lib/components/MemberSelect'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
+import { More } from 'lib/lemon-ui/LemonButton/More'
import { LemonTable, LemonTableColumns } from 'lib/lemon-ui/LemonTable'
import { createdAtColumn, createdByColumn } from 'lib/lemon-ui/LemonTable/columnUtils'
import { LemonTableLink } from 'lib/lemon-ui/LemonTable/LemonTableLink'
@@ -12,6 +13,7 @@ import { urls } from 'scenes/urls'
import type { HogFlowMinimalApi } from 'products/workflows/frontend/generated/api.schemas'
+import { archiveDisabledReason, manageDisabledReason } from './broadcastLifecycle'
import {
BROADCASTS_PAGE_SIZE,
BroadcastsStatusFilter,
@@ -34,7 +36,7 @@ export function BroadcastsTable(): JSX.Element {
useValues(broadcastsLogic)
// Rows from other filters stay behind the loading state, and are dropped once the load for these fails.
const hideRows = loadFailed && filtersPending
- const { setFilters } = useActions(broadcastsLogic)
+ const { setFilters, archiveBroadcast, restoreBroadcast, deleteBroadcast } = useActions(broadcastsLogic)
const { page } = filters
const isFiltered = !!filters.search || filters.status !== 'all' || !!filters.createdBy
@@ -85,6 +87,53 @@ export function BroadcastsTable(): JSX.Element {
})),
createdByColumn() as LemonTableColumns<HogFlowMinimalApi>[number],
createdAtColumn() as LemonTableColumns<HogFlowMinimalApi>[number],
+ {
+ width: 0,
+ render: function Render(_, item) {
+ const isArchived = item.status === 'archived'
+ const accessReason = manageDisabledReason(item.user_access_level)
+ return (
+ <More
+ overlay={
+ isArchived ? (
+ <>
+ <LemonButton
+ fullWidth
+ onClick={() => restoreBroadcast(item)}
+ disabledReason={accessReason}
+ data-attr="broadcast-row-restore"
+ >
+ Restore as draft
+ </LemonButton>
+ <LemonButton
+ fullWidth
+ status="danger"
+ onClick={() => deleteBroadcast(item)}
+ disabledReason={accessReason}
+ data-attr="broadcast-row-delete"
+ >
+ Delete
+ </LemonButton>
+ </>
+ ) : (
+ <LemonButton
+ fullWidth
+ status="danger"
+ onClick={() => archiveBroadcast(item)}
+ disabledReason={
+ accessReason ??
+ archiveDisabledReason(rowDetailsById[item.id]?.batchJobStatuses ?? null)
+ }
+ data-attr="broadcast-row-archive"
+ >
+ Archive
+ </LemonButton>
+ )
+ }
+ />
+ )
+ },
+ },
]
const isEmpty =
diff --git a/products/workflows/frontend/Broadcasts/broadcastLifecycle.test.ts b/products/workflows/frontend/Broadcasts/broadcastLifecycle.test.ts
new file mode 100644
index 000000000000..dc5a3ac9f38a
--- /dev/null
+++ b/products/workflows/frontend/Broadcasts/broadcastLifecycle.test.ts
@@ -0,0 +1,14 @@
+import { archiveDisabledReason } from './broadcastLifecycle'
+
+describe('archiveDisabledReason', () => {
+ it.each([
+ { runs: 'runs not loaded yet', statuses: null, blocked: true },
+ { runs: 'no runs', statuses: [], blocked: false },
+ { runs: 'a finished and a failed run', statuses: ['completed', 'failed'], blocked: false },
+ { runs: 'rows whose runs have not loaded', statuses: [undefined], blocked: false },
+ { runs: 'a queued run', statuses: ['queued'], blocked: true },
+ { runs: 'an older run still sending', statuses: ['completed', 'active'], blocked: true },
+ ])('with $runs blocks archiving: $blocked', ({ statuses, blocked }) => {
+ expect(!!archiveDisabledReason(statuses)).toBe(blocked)
+ })
+})
diff --git a/products/workflows/frontend/Broadcasts/broadcastLifecycle.ts b/products/workflows/frontend/Broadcasts/broadcastLifecycle.ts
new file mode 100644
index 000000000000..51ffb7865e04
--- /dev/null
+++ b/products/workflows/frontend/Broadcasts/broadcastLifecycle.ts
@@ -0,0 +1,119 @@
+import { LemonDialog, lemonToast } from '@posthog/lemon-ui'
+
+import { getAccessControlDisabledReason } from 'lib/utils/accessControlUtils'
+
+import { AccessControlLevel, AccessControlResourceType } from '~/types'
+
+import {
+ hogFlowsBatchJobsList,
+ hogFlowsDestroy,
+ hogFlowsPartialUpdate,
+} from 'products/workflows/frontend/generated/api'
+
+export interface ManagedBroadcast {
+ id: string
+ name?: string | null
+}
+
+/** Archive, restore and delete need editor access to the broadcast, as they do for a workflow. */
+export function manageDisabledReason(userAccessLevel: string | null | undefined): string | undefined {
+ return (
+ getAccessControlDisabledReason(
+ AccessControlResourceType.Workflow,
+ AccessControlLevel.Editor,
+ (userAccessLevel as AccessControlLevel | null) ?? undefined
+ ) ?? undefined
+ )
+}
+
+const RUNNING_BATCH_JOB_STATUSES = ['waiting', 'queued', 'active']
+
+/**
+ * Archiving only cancels a running send's people as they come up, so a send in flight is stopped first.
+ * Null means the runs haven't loaded, and a send could be running.
+ */
+export function archiveDisabledReason(batchJobStatuses: (string | null | undefined)[] | null): string | undefined {
+ if (batchJobStatuses === null) {
+ return 'Checking whether a send is running'
+ }
+ return batchJobStatuses.some((status) => RUNNING_BATCH_JOB_STATUSES.includes(status ?? ''))
+ ? 'This broadcast is sending. Wait for it to finish before archiving it.'
+ : undefined
+}
+
+function label(broadcast: ManagedBroadcast): string {
+ return broadcast.name || 'Untitled broadcast'
+}
+
+function errorDetail(error: any): string {
+ return error?.detail || error?.message || 'unknown error'
+}
+
+export function confirmArchiveBroadcast(projectId: string, broadcast: ManagedBroadcast, onDone: () => void): void {
+ LemonDialog.open({
+ width: 500,
+ title: 'Archive broadcast?',
+ description: `"${label(broadcast)}" moves to the archived list and any schedule stops sending. You can restore it later as a draft.`,
+ primaryButton: {
+ children: 'Archive',
+ type: 'primary',
+ status: 'danger',
+ 'data-attr': 'broadcast-archive-confirm',
+ onClick: async () => {
+ try {
+ // A send can start between opening the menu and confirming, so the runs are checked again here.
+ const jobs = await hogFlowsBatchJobsList(projectId, broadcast.id)
+ const runningReason = archiveDisabledReason(jobs.map((job) => job.status))
+ if (runningReason) {
+ lemonToast.error(runningReason)
+ return
+ }
+ await hogFlowsPartialUpdate(projectId, broadcast.id, { status: 'archived' })
+ lemonToast.success(`Archived "${label(broadcast)}"`)
+ onDone()
+ } catch (error: any) {
+ lemonToast.error(`Couldn't archive the broadcast: ${errorDetail(error)}`)
+ }
+ },
+ },
+ secondaryButton: { children: 'Cancel' },
+ })
+}
+
+export async function restoreBroadcast(
+ projectId: string,
+ broadcast: ManagedBroadcast,
+ onDone: () => void
+): Promise<void> {
+ try {
+ await hogFlowsPartialUpdate(projectId, broadcast.id, { status: 'draft' })
+ lemonToast.success(`Restored "${label(broadcast)}" as a draft`)
+ onDone()
+ } catch (error: any) {
+ lemonToast.error(`Couldn't restore the broadcast: ${errorDetail(error)}`)
+ }
+}
+
+export function confirmDeleteBroadcast(projectId: string, broadcast: ManagedBroadcast, onDone: () => void): void {
+ LemonDialog.open({
+ width: 500,
+ title: 'Delete broadcast?',
+ description: `"${label(broadcast)}" and its settings are deleted for good. This can't be undone.`,
+ primaryButton: {
+ children: 'Delete',
+ type: 'primary',
+ status: 'danger',
+ 'data-attr': 'broadcast-delete-confirm',
+ onClick: async () => {
+ try {
+ await hogFlowsDestroy(projectId, broadcast.id)
+ lemonToast.success(`Deleted "${label(broadcast)}"`)
+ onDone()
+ } catch (error: any) {
+ lemonToast.error(`Couldn't delete the broadcast: ${errorDetail(error)}`)
+ }
+ },
+ },
+ secondaryButton: { children: 'Cancel' },
+ })
+}
diff --git a/products/workflows/frontend/Broadcasts/broadcastWizardLogic.ts b/products/workflows/frontend/Broadcasts/broadcastWizardLogic.ts
index 73315d702b3e..6067df5101c3 100644
--- a/products/workflows/frontend/Broadcasts/broadcastWizardLogic.ts
+++ b/products/workflows/frontend/Broadcasts/broadcastWizardLogic.ts
@@ -47,6 +47,7 @@ import {
stateToRRule,
} from '../Workflows/hogflows/steps/components/rrule-helpers'
import { ResourceSaveQueue } from '../Workflows/resourceSaveQueue'
+import { confirmArchiveBroadcast, confirmDeleteBroadcast, restoreBroadcast } from './broadcastLifecycle'
import {
BroadcastStatus,
StoppableBroadcast,
@@ -188,12 +189,18 @@ export interface broadcastWizardLogicActions {
base: HogFlowApi | null
broadcast: HogFlowApi
}
+ archiveBroadcast: () => {
+ value: true
+ }
collapseRun: (runId: string) => {
runId: string
}
continueStep: () => {
value: true
}
+ deleteBroadcast: () => {
+ value: true
+ }
draftAutosaved: (broadcast: HogFlowApi) => {
broadcast: HogFlowApi
}
@@ -278,6 +285,9 @@ export interface broadcastWizardLogicActions {
replayDeferredEdit: () => {
value: true
}
+ restoreBroadcast: () => {
+ value: true
+ }
saveBroadcastFinished: (broadcast: HogFlowApi | null) => {
broadcast: HogFlowApi | null
}
@@ -467,6 +477,9 @@ export const broadcastWizardLogic = kea<broadcastWizardLogicType>([
moveToDraft: true,
moveToDraftFinished: true,
duplicateBroadcast: true,
+ archiveBroadcast: true,
+ restoreBroadcast: true,
+ deleteBroadcast: true,
duplicateBroadcastFinished: true,
}),
@@ -1363,6 +1376,23 @@ export const broadcastWizardLogic = kea<broadcastWizardLogicType>([
}
actions.moveToDraftFinished()
},
+ archiveBroadcast: () => {
+ if (values.currentProjectId && values.broadcast) {
+ confirmArchiveBroadcast(String(values.currentProjectId), values.broadcast, actions.loadBroadcast)
+ }
+ },
+ restoreBroadcast: async () => {
+ if (values.currentProjectId && values.broadcast) {
+ await restoreBroadcast(String(values.currentProjectId), values.broadcast, actions.loadBroadcast)
+ }
+ },
+ deleteBroadcast: () => {
+ if (values.currentProjectId && values.broadcast) {
+ confirmDeleteBroadcast(String(values.currentProjectId), values.broadcast, () =>
+ router.actions.push(urls.broadcasts())
+ )
+ }
+ },
duplicateBroadcast: async () => {
if (!values.currentProjectId) {
actions.duplicateBroadcastFinished()
diff --git a/products/workflows/frontend/Broadcasts/broadcastsLogic.ts b/products/workflows/frontend/Broadcasts/broadcastsLogic.ts
index febd2ddecfa2..7457eeea3b89 100644
--- a/products/workflows/frontend/Broadcasts/broadcastsLogic.ts
+++ b/products/workflows/frontend/Broadcasts/broadcastsLogic.ts
@@ -22,6 +22,13 @@ import type {
PaginatedHogFlowMinimalListApi,
} from 'products/workflows/frontend/generated/api.schemas'
+import {
+ ManagedBroadcast,
+ confirmArchiveBroadcast,
+ confirmDeleteBroadcast,
+ restoreBroadcast,
+} from './broadcastLifecycle'
+
export type BroadcastStatus = 'draft' | 'scheduled' | 'sending' | 'sent' | 'failed' | 'archived' | 'unknown'
export interface BroadcastRowDetails {
@@ -30,6 +37,8 @@ export interface BroadcastRowDetails {
totals: Record<string, number> | null
/** Whether an active schedule has sends still to come. Unset when the schedules couldn't load. */
hasPendingSchedule?: boolean
+ /** Every run's status, newest first. An older run can still be sending after a newer one finished. */
+ batchJobStatuses?: (string | null | undefined)[]
}
/** Rows per page. Each row loads its latest run and metrics, so a page stays small enough to enrich. */
@@ -195,9 +204,15 @@ export interface broadcastsLogicValues {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface broadcastsLogicActions {
+ archiveBroadcast: (broadcast: ManagedBroadcast) => {
+ broadcast: ManagedBroadcast
+ }
clearRowDetails: (id: string) => {
id: string
}
+ deleteBroadcast: (broadcast: ManagedBroadcast) => {
+ broadcast: ManagedBroadcast
+ }
loadBroadcasts: () => {
value: true
}
@@ -219,6 +234,9 @@ export interface broadcastsLogicActions {
value: true
}
}
+ restoreBroadcast: (broadcast: ManagedBroadcast) => {
+ broadcast: ManagedBroadcast
+ }
setFilters: (filters: Partial<BroadcastsFilters>) => {
filters: Partial<BroadcastsFilters>
}
@@ -263,6 +281,9 @@ export const broadcastsLogic = kea<broadcastsLogicType>([
setRowDetails: (id: string, details: BroadcastRowDetails) => ({ id, details }),
clearRowDetails: (id: string) => ({ id }),
setLoadedFilters: (filters: BroadcastsFilters) => ({ filters }),
+ archiveBroadcast: (broadcast: ManagedBroadcast) => ({ broadcast }),
+ restoreBroadcast: (broadcast: ManagedBroadcast) => ({ broadcast }),
+ deleteBroadcast: (broadcast: ManagedBroadcast) => ({ broadcast }),
}),
loaders(({ actions, values }) => ({
broadcasts: [
@@ -295,6 +316,12 @@ export const broadcastsLogic = kea<broadcastsLogicType>([
{} as Record<string, BroadcastRowDetails>,
{
setRowDetails: (state, { id, details }) => ({ ...state, [id]: details }),
+ // A send can start between loads, so the run statuses that gate Archive are refetched with the
+ // list. The status tags and counts stay on screen until then.
+ loadBroadcasts: (state) =>
+ Object.fromEntries(
+ Object.entries(state).map(([id, { batchJobStatuses: _, ...details }]) => [id, details])
+ ),
clearRowDetails: (state, { id }) => {
const { [id]: _, ...rest } = state
return rest
@@ -345,6 +372,22 @@ export const broadcastsLogic = kea<broadcastsLogicType>([
],
}),
listeners(({ actions, values }) => ({
+ // Each change moves the row between status filters, so the page reloads rather than patching the row.
+ archiveBroadcast: ({ broadcast }) => {
+ if (values.currentProjectId) {
+ confirmArchiveBroadcast(String(values.currentProjectId), broadcast, actions.loadBroadcasts)
+ }
+ },
+ restoreBroadcast: async ({ broadcast }) => {
+ if (values.currentProjectId) {
+ await restoreBroadcast(String(values.currentProjectId), broadcast, actions.loadBroadcasts)
+ }
+ },
+ deleteBroadcast: ({ broadcast }) => {
+ if (values.currentProjectId) {
+ confirmDeleteBroadcast(String(values.currentProjectId), broadcast, actions.loadBroadcasts)
+ }
+ },
loadBroadcastsSuccess: ({ broadcasts }) => {
const projectId = values.currentProjectId
if (!projectId) {
@@ -365,6 +408,7 @@ export const broadcastsLogic = kea<broadcastsLogicType>([
for (const broadcast of broadcasts.results ?? []) {
void (async () => {
let latestBatchJob: HogFlowBatchJobApi | null
+ let batchJobStatuses: (string | null | undefined)[]
let hasPendingSchedule: boolean | undefined
try {
// The list rows carry no schedules, and a recurring broadcast between runs needs them
@@ -377,6 +421,7 @@ export const broadcastsLogic = kea<broadcastsLogicType>([
hogFlowsSchedulesList(String(projectId), broadcast.id).catch(() => undefined),
])
latestBatchJob = batchJobs[0] ?? null
+ batchJobStatuses = batchJobs.map((job) => job.status)
hasPendingSchedule = schedules?.some((schedule) => schedule.status === 'active')
} catch {
if (isCurrent()) {
@@ -391,6 +436,7 @@ export const broadcastsLogic = kea<broadcastsLogicType>([
latestBatchJob,
totals: latestBatchJob ? null : {},
hasPendingSchedule,
+ batchJobStatuses,
})
if (!latestBatchJob) {
return
@@ -398,7 +444,12 @@ export const broadcastsLogic = kea<broadcastsLogicType>([
try {
const totals = await loadRunMetricTotals(latestBatchJob, values.currentTeam?.timezone ?? 'UTC')
if (isCurrent()) {
- actions.setRowDetails(broadcast.id, { latestBatchJob, totals, hasPendingSchedule })
+ actions.setRowDetails(broadcast.id, {
+ latestBatchJob,
+ totals,
+ hasPendingSchedule,
+ batchJobStatuses,
+ })
}
} catch {
// The counts stay unknown; the status already rendered from the run.