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(data-warehouse): poll sources list only on pages that render it (#73534)

Daniel RCeae396c22ff8
diff --git a/products/data_warehouse/frontend/shared/logics/sourceManagementLogic.ts b/products/data_warehouse/frontend/shared/logics/sourceManagementLogic.ts
index 4d9ecd12e338..806f461466ad 100644
--- a/products/data_warehouse/frontend/shared/logics/sourceManagementLogic.ts
+++ b/products/data_warehouse/frontend/shared/logics/sourceManagementLogic.ts
@@ -41,6 +41,19 @@ import { sourcesDataLogic } from './sourcesDataLogic'
const REFRESH_INTERVAL = 10000
+// Pages that actually render the sources list and want live sync-status updates. The 10s poll
+// runs only on these. Every other page that mounts this logic (the new-source wizard, SQL editor,
+// person/group profiles, debug, etc.) reads the sources once on mount without polling. This
+// matters because the list response is large and was previously re-fetched every REFRESH_INTERVAL
+// on pages that never display it.
+const SOURCE_LIST_PATHS = [
+ '/data-management/sources', // SourcesScene: managed + self-managed sources tables
+ '/data-management/revenue', // Revenue analytics settings: external source configuration
+ '/settings/environment-marketing-analytics', // Marketing analytics settings: source configuration
+]
+
+const shouldPollSources = (): boolean => SOURCE_LIST_PATHS.includes(router.values.location.pathname)
+
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface sourceManagementLogicValues {
availableSources: Record<string, SourceConfig> | null // availableSourcesLogic
@@ -373,11 +386,12 @@ export const sourceManagementLogic = kea<sourceManagementLogicType>([
},
],
}),
- urlToAction(({ actions }) => ({
- '/data-warehouse/*': () => {
- actions.loadSources()
- },
- })),
+ urlToAction(({ actions }) => {
+ const reload = (): void => actions.loadSources()
+ // Reload (and restart polling) when landing on a page that renders the sources list, in
+ // case this shared logic was already mounted by another scene and afterMount won't re-run.
+ return Object.fromEntries(SOURCE_LIST_PATHS.map((sourcePath) => [sourcePath, reload]))
+ }),
listeners(({ actions, values, cache }) => ({
deleteSelfManagedTable: async ({ tableId }) => {
await api.dataWarehouseTables.delete(tableId)
@@ -437,20 +451,27 @@ export const sourceManagementLogic = kea<sourceManagementLogicType>([
posthog.capture('schema updated', { shouldSync: schema.should_sync, syncType: schema.sync_type })
},
loadSourcesSuccess: () => {
- if (router.values.location.pathname.includes('data-warehouse')) {
+ if (shouldPollSources()) {
cache.disposables.add(() => {
const timerId = setTimeout(() => {
- actions.loadSources()
+ // Re-check at fire time: this shared logic stays mounted across navigation
+ // and the timeout is only disposed on unmount, so skip the refresh if the
+ // user has since left a page that displays the sources list.
+ if (shouldPollSources()) {
+ actions.loadSources()
+ }
}, REFRESH_INTERVAL)
return () => clearTimeout(timerId)
}, 'refreshTimeout')
}
},
loadSourcesFailure: () => {
- if (router.values.location.pathname.includes('data-warehouse')) {
+ if (shouldPollSources()) {
cache.disposables.add(() => {
const timerId = setTimeout(() => {
- actions.loadSources()
+ if (shouldPollSources()) {
+ actions.loadSources()
+ }
}, REFRESH_INTERVAL)
return () => clearTimeout(timerId)
}, 'refreshTimeout')