: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(logs): refresh the facet rail on a manual re-run (#89593)
posthog[bot]f88f30bb41de
diff --git a/products/logs/frontend/components/LogsViewer/FacetRail/facetPresenceLogic.ts b/products/logs/frontend/components/LogsViewer/FacetRail/facetPresenceLogic.tsindex b996a276b030..e7ad8ffb7f90 100644--- a/products/logs/frontend/components/LogsViewer/FacetRail/facetPresenceLogic.ts+++ b/products/logs/frontend/components/LogsViewer/FacetRail/facetPresenceLogic.ts@@ -1,8 +1,10 @@-import { MakeLogicType, connect, events, kea, key, path, props, selectors } from 'kea'+import { MakeLogicType, connect, events, kea, key, listeners, path, props, selectors } from 'kea'import { loaders } from 'kea-loaders'import { teamLogic } from 'scenes/teamLogic'+import { logsViewerFiltersLogic } from 'products/logs/frontend/components/LogsViewer/Filters/logsViewerFiltersLogic'+import { logsAttributesRetrieve } from '../../../generated/api'import { customFacetsLogic } from './customFacetsLogic'import { FACETS, FacetConfig, resolveFacets } from './facets'@@ -27,6 +29,9 @@ export interface facetPresenceLogicValues {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface facetPresenceLogicActions {+ bumpFacetRefresh: () => {+ value: true+ }loadPresentResourceKeys: () => anyloadPresentResourceKeysFailure: (error: string,@@ -71,8 +76,9 @@ export const facetPresenceLogic = kea<facetPresenceLogicType>([key((props) => props.id),path((key) => ['products', 'logs', 'frontend', 'components', 'LogsViewer', 'FacetRail', 'facetPresenceLogic', key]),- connect(() => ({+ connect((props: FacetPresenceLogicProps) => ({values: [teamLogic, ['currentTeamId'], customFacetsLogic, ['customFacets']],+ actions: [logsViewerFiltersLogic({ id: props.id }), ['bumpFacetRefresh']],})),loaders(({ values }) => ({@@ -115,6 +121,10 @@ export const facetPresenceLogic = kea<facetPresenceLogicType>([],}),+ listeners(({ actions }) => ({+ bumpFacetRefresh: () => actions.loadPresentResourceKeys(),+ })),+events(({ actions }) => ({afterMount: () => actions.loadPresentResourceKeys(),})),diff --git a/products/logs/frontend/components/LogsViewer/FacetRail/facetValuesLogic.test.ts b/products/logs/frontend/components/LogsViewer/FacetRail/facetValuesLogic.test.tsindex 3378ee98b710..b6856adf290f 100644--- a/products/logs/frontend/components/LogsViewer/FacetRail/facetValuesLogic.test.ts+++ b/products/logs/frontend/components/LogsViewer/FacetRail/facetValuesLogic.test.ts@@ -133,6 +133,32 @@ describe('facetValuesLogic', () => {expect(mockFacetValues).not.toHaveBeenCalled()})+ it('a manual refresh refetches an expanded facet even when the scope is unchanged', async () => {+ const logic = mountFacet(SERVICE)+ await expectLogic(logic).toDispatchActions(['loadFacetValuesSuccess'])+ mockFacetValues.mockClear()++ filtersLogic.actions.bumpFacetRefresh()+ await expectLogic(logic).toDispatchActions(['loadFacetValues', 'loadFacetValuesSuccess'])+ expect(mockFacetValues).toHaveBeenCalledTimes(1)+ })++ it('a manual refresh leaves a collapsed facet unfetched until it is expanded', async () => {+ railLogic.actions.toggleFacetCollapsed(SERVICE.key)+ const logic = mountFacet(SERVICE)+ const other = mountFacet(LEVEL)+ await expectLogic(other).toDispatchActions(['loadFacetValuesSuccess'])+ mockFacetValues.mockClear()++ filtersLogic.actions.bumpFacetRefresh()+ await expectLogic(other).toDispatchActions(['loadFacetValuesSuccess'])+ expect(logic.values.facetValues).toEqual([])++ railLogic.actions.toggleFacetCollapsed(SERVICE.key)+ await expectLogic(logic).toDispatchActions(['loadFacetValuesSuccess'])+ expect(mockFacetValues).toHaveBeenCalledTimes(2)+ })+it('collapsing while a fetch is still debouncing drops it, and expanding fetches again', async () => {// The request is debounced, so a facet collapsed within that window would otherwise still// hit the endpoint — and, having recorded the signature, look fresh enough to skip thediff --git a/products/logs/frontend/components/LogsViewer/FacetRail/facetValuesLogic.ts b/products/logs/frontend/components/LogsViewer/FacetRail/facetValuesLogic.tsindex aa06c31cb22c..daccd0e863ac 100644--- a/products/logs/frontend/components/LogsViewer/FacetRail/facetValuesLogic.ts+++ b/products/logs/frontend/components/LogsViewer/FacetRail/facetValuesLogic.ts@@ -23,6 +23,7 @@ export interface FacetValuesLogicProps {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface facetValuesLogicValues {collapsedFacets: string[] // facetRailLogic+ facetRefreshCounter: number // logsViewerFiltersLogicfilters: LogsViewerFilters // logsViewerFiltersLogicpersonId: string | undefined // logsViewerFiltersLogicqueryFilterGroup: UniversalFiltersGroup // logsViewerFiltersLogic@@ -87,6 +88,7 @@ export interface facetValuesLogicMeta {explicitDate: boolean | null | undefined},currentTeamId: number | null,+ facetRefreshCounter: number,arg: FacetConfig) => stringfetchSignature: (scopeSignature: string, facetSearch: string) => string@@ -120,7 +122,7 @@ export const facetValuesLogic = kea<facetValuesLogicType>([connect((props: FacetValuesLogicProps) => ({values: [logsViewerFiltersLogic({ id: props.id }),- ['filters', 'utcDateRange', 'queryFilterGroup', 'personId'],+ ['filters', 'utcDateRange', 'queryFilterGroup', 'personId', 'facetRefreshCounter'],teamLogic,['currentTeamId'],facetRailLogic({ id: props.id }),@@ -211,6 +213,7 @@ export const facetValuesLogic = kea<facetValuesLogicType>([s.personId,s.utcDateRange,s.currentTeamId,+ s.facetRefreshCounter,(_, p) => p.facet as FacetConfig,],(@@ -223,15 +226,16 @@ export const facetValuesLogic = kea<facetValuesLogicType>([explicitDate: boolean | null | undefined},currentTeamId: number | null,+ facetRefreshCounter: number,facet: FacetConfig): string =>- facetScopeSignature(facet, {+ `${facetScopeSignature(facet, {currentTeamId,utcDateRange,searchTerm: filters.searchTerm,queryFilterGroup,personId,- }),+ })}|r${facetRefreshCounter}`,],// One trigger for the one in-flight request: a scope change and a keystroke in this facet's// search box supersede each other rather than racing.diff --git a/products/logs/frontend/components/LogsViewer/Filters/LogsFilterBar/LogsFilterBar.tsx b/products/logs/frontend/components/LogsViewer/Filters/LogsFilterBar/LogsFilterBar.tsxindex b686d30997d2..748e6e768ea7 100644--- a/products/logs/frontend/components/LogsViewer/Filters/LogsFilterBar/LogsFilterBar.tsx+++ b/products/logs/frontend/components/LogsViewer/Filters/LogsFilterBar/LogsFilterBar.tsx@@ -56,7 +56,7 @@ const taxonomicGroupTypes = [*/export const LogsQueryControls = (): JSX.Element => {const { logsLoading, liveTailRunning } = useValues(logsViewerDataLogic)- const { runQuery } = useActions(logsViewerDataLogic)+ const { refreshQuery } = useActions(logsViewerDataLogic)const { setDateRange } = useActions(logsViewerFiltersLogic)const { filters } = useValues(logsViewerFiltersLogic)const { dateRange } = filters@@ -69,7 +69,7 @@ export const LogsQueryControls = (): JSX.Element => {size="small"icon={<IconRefresh />}type="secondary"- onClick={() => runQuery()}+ onClick={() => refreshQuery()}loading={logsLoading || liveTailRunning}disabledReason={liveTailRunning ? 'Disable live tail to manually refresh' : undefined}/>diff --git a/products/logs/frontend/components/LogsViewer/Filters/logsViewerFiltersLogic.ts b/products/logs/frontend/components/LogsViewer/Filters/logsViewerFiltersLogic.tsindex 5d1f06616992..dfd03003fe39 100644--- a/products/logs/frontend/components/LogsViewer/Filters/logsViewerFiltersLogic.ts+++ b/products/logs/frontend/components/LogsViewer/Filters/logsViewerFiltersLogic.ts@@ -131,6 +131,7 @@ export function unsetColumnQueryFields(): Pick<LogsQuery, 'severityLevels' | 'se// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface logsViewerFiltersLogicValues {dateRange: DateRange+ facetRefreshCounter: numberfilterGroup: UniversalFiltersGroupfilters: LogsViewerFiltersfocusedFilter: LogsFilterTarget | null@@ -160,6 +161,9 @@ export interface logsViewerFiltersLogicActions {propertyType: PropertyFilterTypevalue: string}+ bumpFacetRefresh: () => {+ value: true+ }focusFilter: (target: LogsFilterTarget | null) => {target: FacetFilterTarget | null}@@ -255,6 +259,8 @@ export const logsViewerFiltersLogic = kea<logsViewerFiltersLogicType>([zoomDateRange: (multiplier: number) => ({ multiplier }),+ bumpFacetRefresh: true,+addFilter: (key: string,value: string,@@ -269,6 +275,12 @@ export const logsViewerFiltersLogic = kea<logsViewerFiltersLogicType>([}),reducers({+ facetRefreshCounter: [+ 0,+ {+ bumpFacetRefresh: (state) => state + 1,+ },+ ],dateRange: [DEFAULT_DATE_RANGE as DateRange,{diff --git a/products/logs/frontend/components/LogsViewer/LogsViewer.tsx b/products/logs/frontend/components/LogsViewer/LogsViewer.tsxindex 14c3d0224cf9..f28361588141 100644--- a/products/logs/frontend/components/LogsViewer/LogsViewer.tsx+++ b/products/logs/frontend/components/LogsViewer/LogsViewer.tsx@@ -133,7 +133,7 @@ function LogsViewerContent({hasMoreLogsToLoad,totalLogsMatchingFilters,} = useValues(logsViewerDataLogic)- const { runQuery, fetchNextLogsPage } = useActions(logsViewerDataLogic)+ const { refreshQuery, fetchNextLogsPage } = useActions(logsViewerDataLogic)const { setDateRange, zoomDateRange } = useActions(logsViewerFiltersLogic)const { cellScrollLefts } = useValues(virtualizedLogsListLogic({ id }))const { setCellScrollLeft } = useActions(virtualizedLogsListLogic({ id }))@@ -249,7 +249,7 @@ function LogsViewerContent({action: () => {if (!logsLoading) {resetCursor()- runQuery()+ refreshQuery()}},disabled: !isFocused,@@ -290,7 +290,7 @@ function LogsViewerContent({parsedLogs,openLogDetails,closeLogDetails,- runQuery,+ refreshQuery,logsLoading,resetCursor,moveCursorDown,diff --git a/products/logs/frontend/components/LogsViewer/data/logsViewerDataLogic.test.ts b/products/logs/frontend/components/LogsViewer/data/logsViewerDataLogic.test.tsindex f889ec0fd1ca..0ebb5d3ebfbd 100644--- a/products/logs/frontend/components/LogsViewer/data/logsViewerDataLogic.test.ts+++ b/products/logs/frontend/components/LogsViewer/data/logsViewerDataLogic.test.ts@@ -385,6 +385,18 @@ describe('logsViewerDataLogic', () => {}).toDispatchActions(['handleQueryChange', 'runQuery'])})+ it('a manual refresh runs the query and bumps the facet refresh so the rail re-fetches its counts', async () => {+ await expectLogic(logic, () => {+ logic.actions.refreshQuery()+ }).toDispatchActions(['runQuery', filtersLogic.actionCreators.bumpFacetRefresh()])+ })++ it('an automatic query run does not bump the facet refresh', async () => {+ await expectLogic(logic, () => {+ logic.actions.runQuery()+ }).toNotHaveDispatchedActions([filtersLogic.actionCreators.bumpFacetRefresh()])+ })+it('setFilters triggers runQuery', async () => {await expectLogic(logic, () => {filtersLogic.actions.setFilters({ searchTerm: 'new search' })diff --git a/products/logs/frontend/components/LogsViewer/data/logsViewerDataLogic.ts b/products/logs/frontend/components/LogsViewer/data/logsViewerDataLogic.tsindex 6e4301562d5b..a4c30fa0e8ca 100644--- a/products/logs/frontend/components/LogsViewer/data/logsViewerDataLogic.ts+++ b/products/logs/frontend/components/LogsViewer/data/logsViewerDataLogic.ts@@ -202,6 +202,9 @@ export interface logsViewerDataLogicActions {orderBy: LogsOrderBysource: 'header' | 'toolbar'} // logsViewerConfigLogic+ bumpFacetRefresh: () => {+ value: true+ } // logsViewerFiltersLogicsetDateRange: (dateRange: DateRange) => {dateRange: DateRange} // logsViewerFiltersLogic@@ -316,6 +319,9 @@ export interface logsViewerDataLogicActions {pollForNewLogs: () => {value: true}+ refreshQuery: () => {+ value: true+ }runQuery: (debounce?: integer) => {debounce: number | undefined}@@ -475,7 +481,7 @@ export const logsViewerDataLogic = kea<logsViewerDataLogicType>([teamLogic,['addProductIntent'],logsViewerFiltersLogic({ id }),- ['setDateRange', 'setFilterGroup', 'setFilters', 'setSearchTerm'],+ ['setDateRange', 'setFilterGroup', 'setFilters', 'setSearchTerm', 'bumpFacetRefresh'],logsViewerConfigLogic({ id }),['setOrderBy', 'setColumns', 'addColumn', 'removeColumn'],],@@ -493,6 +499,7 @@ export const logsViewerDataLogic = kea<logsViewerDataLogicType>([extraProps,}),runQuery: (debounce?: integer) => ({ debounce }),+ refreshQuery: true,fetchNextLogsPage: (limit?: number) => ({ limit }),truncateLogs: (limit: number) => ({ limit }),clearLogs: true,@@ -1093,6 +1100,10 @@ export const logsViewerDataLogic = kea<logsViewerDataLogicType>([actions.fetchSparkline()actions.cancelInProgressLiveTail(null)},+ refreshQuery: () => {+ actions.runQuery()+ actions.bumpFacetRefresh()+ },cancelInProgressLogs: ({ logsAbortController }) => {if (values.logsAbortController !== null) {values.logsAbortController.abort(new DOMException(NEW_QUERY_STARTED_ERROR_MESSAGE, 'AbortError'))