: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(insights): report the tile kind on page loads (#106285)
Andy Zhao168c33f53432
diff --git a/frontend/src/queries/nodes/DataNode/dataNodeCollectionLogic.test.ts b/frontend/src/queries/nodes/DataNode/dataNodeCollectionLogic.test.tsindex bf16d045a03f..45d2b9dfcac9 100644--- a/frontend/src/queries/nodes/DataNode/dataNodeCollectionLogic.test.ts+++ b/frontend/src/queries/nodes/DataNode/dataNodeCollectionLogic.test.ts@@ -29,7 +29,6 @@ describe('dataNodeCollectionLogic', () => {id,loadData: jest.fn(),cancelQuery: jest.fn(),- kind: 'TrendsQuery',})}@@ -123,8 +122,8 @@ describe('dataNodeCollectionLogic', () => {mountTile('tile-a')mountTile('tile-b')- logic.actions.collectionNodeLoadData('tile-a')- logic.actions.collectionNodeLoadData('tile-b')+ logic.actions.collectionNodeLoadData('tile-a', 'TrendsQuery')+ logic.actions.collectionNodeLoadData('tile-b', 'TrendsQuery')logic.actions.collectionNodeLoadDataSuccess('tile-a', { isCached: true })expect(capturedLoads()).toHaveLength(0)diff --git a/frontend/src/queries/nodes/DataNode/dataNodeCollectionLogic.ts b/frontend/src/queries/nodes/DataNode/dataNodeCollectionLogic.tsindex 85544201e4b7..c79946b9401e 100644--- a/frontend/src/queries/nodes/DataNode/dataNodeCollectionLogic.ts+++ b/frontend/src/queries/nodes/DataNode/dataNodeCollectionLogic.ts@@ -12,7 +12,6 @@ export interface DataNodeRegisteredProps {id: stringloadData: (refresh?: RefreshType) => voidcancelQuery: () => void- kind?: string}export interface CollectionNodeLoadMeta {@@ -57,8 +56,12 @@ export interface dataNodeCollectionLogicValues {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface dataNodeCollectionLogicActions {cancelAllLoading: () => {}- collectionNodeLoadData: (id: string) => {+ collectionNodeLoadData: (+ id: string,+ kind?: string+ ) => {id: string+ kind: string | undefined}collectionNodeLoadDataFailure: (id: string) => {id: string@@ -112,7 +115,7 @@ export const dataNodeCollectionLogic = kea<dataNodeCollectionLogicType>([unmountDataNode: (id: string) => ({ id }),reloadAll: () => ({}),cancelAllLoading: () => ({}),- collectionNodeLoadData: (id: string) => ({ id }),+ collectionNodeLoadData: (id: string, kind?: string) => ({ id, kind }),collectionNodeLoadDataSuccess: (id: string, meta?: CollectionNodeLoadMeta) => ({ id, meta }),collectionNodeLoadDataFailure: (id: string) => ({ id }),pageHidden: true,@@ -189,22 +192,12 @@ export const dataNodeCollectionLogic = kea<dataNodeCollectionLogicType>([posthog.capture('time to see data', payload, options)}- const setTile = (- cycle: DataCollectionLoadCycle,- id: string,- status: DataCollectionLoadTile['status'],- cached = false- ): void => {- const kind = values.mountedDataNodes.find((node) => node.id === id)?.kind ?? null- cycle.tiles.set(id, { kind, status, cached })- }-const finishTile = (id: string, status: 'success' | 'failure', cached = false): void => {const cycle = cache.cycleif (!cycle) {return}- setTile(cycle, id, status, cached)+ cycle.tiles.set(id, { kind: cycle.tiles.get(id)?.kind ?? null, status, cached })cycle.lastTileId = idif (!values.areAnyLoading) {settle(cycle)@@ -266,7 +259,7 @@ export const dataNodeCollectionLogic = kea<dataNodeCollectionLogicType>([}})},- collectionNodeLoadData: ({ id }) => {+ collectionNodeLoadData: ({ id, kind }) => {if (!cache.cycle) {cache.cycle = {id: uuid(),@@ -277,7 +270,7 @@ export const dataNodeCollectionLogic = kea<dataNodeCollectionLogicType>([lastTileId: null,} satisfies DataCollectionLoadCycle}- setTile(cache.cycle, id, 'loading')+ cache.cycle.tiles.set(id, { kind: kind ?? null, status: 'loading', cached: false })},collectionNodeLoadDataSuccess: ({ id, meta }) => {finishTile(id, 'success', !!meta?.isCached)diff --git a/frontend/src/queries/nodes/DataNode/dataNodeLogic.test.ts b/frontend/src/queries/nodes/DataNode/dataNodeLogic.test.tsindex 295c915bcf1a..a5dcfe223ab0 100644--- a/frontend/src/queries/nodes/DataNode/dataNodeLogic.test.ts+++ b/frontend/src/queries/nodes/DataNode/dataNodeLogic.test.ts@@ -1,7 +1,9 @@import { expectLogic, partial } from 'kea-test-utils'import { useMocks } from '~/mocks/jest'+import { dataNodeCollectionLogic } from '~/queries/nodes/DataNode/dataNodeCollectionLogic'import {+ DataNodeLogicProps,QUERY_SCAN_POLL_DEADLINE_MS,QUERY_SCAN_POLL_DELAYS_MS,dataNodeLogic,@@ -125,6 +127,32 @@ describe('dataNodeLogic', () => {.toMatchValues({ responseLoading: false, response: partial({ results: results3 }) })})+ it('reports the query kind to its collection when the query arrives after mount', async () => {+ mockedQuery.mockResolvedValueOnce({ results: [] })+ const collection = dataNodeCollectionLogic({ key: 'test-collection' })+ collection.mount()+ logic = dataNodeLogic({ key: testUniqueKey, dataNodeCollectionId: 'test-collection' } as DataNodeLogicProps)+ logic.mount()++ await expectLogic(collection, () => {+ dataNodeLogic({+ key: testUniqueKey,+ dataNodeCollectionId: 'test-collection',+ query: setLatestVersionsOnQuery({ kind: NodeKind.EventsQuery, select: ['*'] }),+ })+ }).toDispatchActions([collection.actionCreators.collectionNodeLoadData(testUniqueKey, NodeKind.EventsQuery)])++ mockedQuery.mockResolvedValueOnce({ results: [] })+ await expectLogic(collection, () => {+ logic.actions.loadData(+ undefined,+ undefined,+ setLatestVersionsOnQuery({ kind: NodeKind.HogQLQuery, query: 'select 1' })+ )+ }).toDispatchActions([collection.actionCreators.collectionNodeLoadData(testUniqueKey, NodeKind.HogQLQuery)])+ collection.unmount()+ })+it('force refreshes account table results when filters change', async () => {const assignedQuery = {kind: NodeKind.AccountsTableQuery,diff --git a/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts b/frontend/src/queries/nodes/DataNode/dataNodeLogic.tsindex 2f92b2fbe306..b8033de9b195 100644--- a/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts+++ b/frontend/src/queries/nodes/DataNode/dataNodeLogic.ts@@ -342,8 +342,12 @@ export interface dataNodeLogicValues {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface dataNodeLogicActions {- collectionNodeLoadData: (id: string) => {+ collectionNodeLoadData: (+ id: string,+ kind?: string | undefined+ ) => {id: string+ kind: string | undefined} // dataNodeCollectionLogiccollectionNodeLoadDataFailure: (id: string) => {id: string@@ -2110,8 +2114,8 @@ export const dataNodeLogic = kea<dataNodeLogicType>([actions.abortAnyRunningQuery()actions.resetLoadingTimer()},- loadData: () => {- actions.collectionNodeLoadData(props.key)+ loadData: ({ overrideQuery }) => {+ actions.collectionNodeLoadData(props.key, (overrideQuery ?? props.query)?.kind)actions.resetLoadingTimer()},loadDataSuccess: ({ response }) => {@@ -2217,7 +2221,6 @@ export const dataNodeLogic = kea<dataNodeLogicType>([id: props.key,loadData: actions.loadData,cancelQuery: actions.cancelQuery,- kind: props.query?.kind,})if (props.cachedResults) {diff --git a/frontend/src/scenes/web-analytics/webAnalyticsLoadTimeLogic.ts b/frontend/src/scenes/web-analytics/webAnalyticsLoadTimeLogic.tsindex 2f1231a67ac2..02cbb7e255cd 100644--- a/frontend/src/scenes/web-analytics/webAnalyticsLoadTimeLogic.ts+++ b/frontend/src/scenes/web-analytics/webAnalyticsLoadTimeLogic.ts@@ -38,8 +38,12 @@ export interface webAnalyticsLoadTimeLogicValues {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface webAnalyticsLoadTimeLogicActions {- collectionNodeLoadData: (id: string) => {+ collectionNodeLoadData: (+ id: string,+ kind?: string | undefined+ ) => {id: string+ kind: string | undefined} // dataNodeCollectionLogiccollectionNodeLoadDataFailure: (id: string) => {id: string