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.

fix(workflows): fill in broadcasts list filters saved before tag filtering (#125617)

Daniel Marchukcb04514fed93
diff --git a/products/workflows/frontend/Broadcasts/broadcastsLogic.test.ts b/products/workflows/frontend/Broadcasts/broadcastsLogic.test.ts
index a3f5c6e85109..81fdbcfe4ed4 100644
--- a/products/workflows/frontend/Broadcasts/broadcastsLogic.test.ts
+++ b/products/workflows/frontend/Broadcasts/broadcastsLogic.test.ts
@@ -32,4 +32,18 @@ describe('broadcastsLogic', () => {
expect(logic.values.filters.search).toEqual('welcome')
expect(router.values.searchParams).toMatchObject({ status: 'sent', search: 'welcome' })
})
+
+ it('defaults the tags filter when the saved filters have none', () => {
+ logic.actions.setFilters({ search: 'welcome' })
+ const key = Object.keys(localStorage).find((k) => k.includes('broadcasts_list_filters'))!
+ const { tags: _, ...savedBeforeTags } = JSON.parse(localStorage.getItem(key)!)
+ localStorage.setItem(key, JSON.stringify(savedBeforeTags))
+ logic.unmount()
+ router.actions.push('/broadcasts')
+
+ logic = broadcastsLogic()
+ logic.mount()
+
+ expect(logic.values.filters).toMatchObject({ search: 'welcome', tags: [] })
+ })
})
diff --git a/products/workflows/frontend/Broadcasts/broadcastsLogic.ts b/products/workflows/frontend/Broadcasts/broadcastsLogic.ts
index 2504e34c3e92..75d2f208e46c 100644
--- a/products/workflows/frontend/Broadcasts/broadcastsLogic.ts
+++ b/products/workflows/frontend/Broadcasts/broadcastsLogic.ts
@@ -260,6 +260,9 @@ export interface broadcastsLogicActions {
deleteBroadcast: (broadcast: ManagedBroadcast) => {
broadcast: ManagedBroadcast
}
+ fillMissingFilters: () => {
+ value: true
+ }
loadBroadcasts: () => {
value: true
}
@@ -333,6 +336,7 @@ export const broadcastsLogic = kea<broadcastsLogicType>([
loadBroadcasts: true,
setFilters: (filters: Partial<BroadcastsFilters>) => ({ filters }),
setFiltersFromUrl: (filters: BroadcastsFilters) => ({ filters }),
+ fillMissingFilters: true,
setRowDetails: (id: string, details: BroadcastRowDetails) => ({ id, details }),
clearRowDetails: (id: string) => ({ id }),
setLoadedFilters: (filters: BroadcastsFilters) => ({ filters }),
@@ -452,9 +456,14 @@ export const broadcastsLogic = kea<broadcastsLogicType>([
// Any change other than the page itself starts the list over from the first page.
setFilters: (state, { filters }) => ({ ...state, page: 1, ...filters }),
setFiltersFromUrl: (_, { filters }) => filters,
+ fillMissingFilters: (state) => ({ ...DEFAULT_FILTERS, ...state }),
},
],
})),
+ // Filters saved before a field existed come back without it. This runs before urlToAction reads them.
+ afterMount(({ actions }) => {
+ actions.fillMissingFilters()
+ }),
selectors({
filtersPending: [
(s) => [s.filters, s.loadedFilters],