: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
feat(logs): allow full screen on scoped log viewers (#79618)
Jon McCallum5d7fbc08bb91
diff --git a/frontend/src/scenes/persons/PersonLogsTab.tsx b/frontend/src/scenes/persons/PersonLogsTab.tsxindex 5c2048f96382..1ea1cb57011f 100644--- a/frontend/src/scenes/persons/PersonLogsTab.tsx+++ b/frontend/src/scenes/persons/PersonLogsTab.tsx@@ -44,7 +44,6 @@ export function PersonLogsTab({ person }: { person: PersonType }): JSX.Element {<LogsViewerid={`person-${person.uuid ?? person.id}`}personId={String(person.uuid ?? person.id)}- showFullScreenButton={false}showSavedViewsButton={false}/></div>diff --git a/products/logs/frontend/components/LogsViewer/Filters/LogsFilterBar/LogsQueryBar.tsx b/products/logs/frontend/components/LogsViewer/Filters/LogsFilterBar/LogsQueryBar.tsxindex 4cbb456b7732..39f0aee341ab 100644--- a/products/logs/frontend/components/LogsViewer/Filters/LogsFilterBar/LogsQueryBar.tsx+++ b/products/logs/frontend/components/LogsViewer/Filters/LogsFilterBar/LogsQueryBar.tsx@@ -1,5 +1,6 @@import { useValues } from 'kea'+import { LogsViewerScope } from 'products/logs/frontend/components/LogsViewer/config/types'import { logsViewerFiltersLogic } from 'products/logs/frontend/components/LogsViewer/Filters/logsViewerFiltersLogic'import { LogsFullScreenButton } from 'products/logs/frontend/components/LogsViewer/LogsFullScreenButton'import { SavedViewsButton } from 'products/logs/frontend/components/LogsViews/SavedViewsButton'@@ -17,9 +18,11 @@ import { LogsAppliedFilters, LogsFilterGroup, LogsFilterSearch, LogsQueryControlexport const LogsQueryBar = ({showSavedViewsButton = false,showFullScreenButton = false,+ scope,}: {showSavedViewsButton?: booleanshowFullScreenButton?: boolean+ scope?: LogsViewerScope}): JSX.Element => {const { id } = useValues(logsViewerFiltersLogic)@@ -36,7 +39,7 @@ export const LogsQueryBar = ({</div><div className="flex shrink-0 gap-1.5"><LogsQueryControls />- {showFullScreenButton && <LogsFullScreenButton id={id} />}+ {showFullScreenButton && <LogsFullScreenButton id={id} scope={scope} />}</div></div><LogsAppliedFilters />diff --git a/products/logs/frontend/components/LogsViewer/LogsFullScreenButton.tsx b/products/logs/frontend/components/LogsViewer/LogsFullScreenButton.tsxindex 24f034ff64d7..ba40d780cd80 100644--- a/products/logs/frontend/components/LogsViewer/LogsFullScreenButton.tsx+++ b/products/logs/frontend/components/LogsViewer/LogsFullScreenButton.tsx@@ -3,13 +3,17 @@ import { useActions } from 'kea'import { IconExpand45 } from '@posthog/icons'import { LemonButton } from '@posthog/lemon-ui'+import { LogsViewerScope } from './config/types'import { logsViewerModalLogic } from './LogsViewerModal/logsViewerModalLogic'/*** Maximises the whole viewer surface. Viewer-scoped (not scene-scoped: it only applies to the* Logs Viewer tab), so it lives at the top-right of the query bar rather than in the results bar.+ *+ * `scope` carries the embedding scene's scope (a person, a pinned trace filter) into the modal,+ * which mounts its own viewer under the same id.*/-export const LogsFullScreenButton = ({ id }: { id: string }): JSX.Element => {+export const LogsFullScreenButton = ({ id, scope }: { id: string; scope?: LogsViewerScope }): JSX.Element => {const { openLogsViewerModal } = useActions(logsViewerModalLogic)return (@@ -17,7 +21,7 @@ export const LogsFullScreenButton = ({ id }: { id: string }): JSX.Element => {size="small"type="secondary"icon={<IconExpand45 />}- onClick={() => openLogsViewerModal({ id })}+ onClick={() => openLogsViewerModal({ id, ...scope })}tooltip="Full screen"/>)diff --git a/products/logs/frontend/components/LogsViewer/LogsViewer.tsx b/products/logs/frontend/components/LogsViewer/LogsViewer.tsxindex b48f631de09f..1ea5aecd6488 100644--- a/products/logs/frontend/components/LogsViewer/LogsViewer.tsx+++ b/products/logs/frontend/components/LogsViewer/LogsViewer.tsx@@ -11,7 +11,7 @@ import { UniversalFiltersGroup } from '~/types'import { LogsGroupByResults } from 'products/logs/frontend/components/LogsGroupBy/LogsGroupByResults'import { LogsPatterns } from 'products/logs/frontend/components/LogsPatterns/LogsPatterns'import { logsViewerConfigLogic } from 'products/logs/frontend/components/LogsViewer/config/logsViewerConfigLogic'-import { LogsViewerFilters } from 'products/logs/frontend/components/LogsViewer/config/types'+import { LogsViewerFilters, LogsViewerScope } from 'products/logs/frontend/components/LogsViewer/config/types'import { logsViewerDataLogic } from 'products/logs/frontend/components/LogsViewer/data/logsViewerDataLogic'import { FacetRail } from 'products/logs/frontend/components/LogsViewer/FacetRail/FacetRail'import { LogsQueryBar } from 'products/logs/frontend/components/LogsViewer/Filters/LogsFilterBar/LogsQueryBar'@@ -68,6 +68,7 @@ export function LogsViewer({<LogsViewerContentshowFullScreenButton={showFullScreenButton}showSavedViewsButton={showSavedViewsButton}+ scope={{ initialFilters, pinnedFilters, personId }}/></BindLogic></BindLogic>@@ -82,9 +83,11 @@ export function LogsViewer({function LogsViewerContent({showFullScreenButton,showSavedViewsButton,+ scope,}: {showFullScreenButton: booleanshowSavedViewsButton: boolean+ scope: LogsViewerScope}): JSX.Element {const {id,@@ -377,7 +380,11 @@ function LogsViewerContent({// row of [facet rail | display bar (operate on the data) + the log lists].return (<div className="flex flex-col gap-2 h-full" data-attr="logs-viewer">- <LogsQueryBar showSavedViewsButton={showSavedViewsButton} showFullScreenButton={showFullScreenButton} />+ <LogsQueryBar+ showSavedViewsButton={showSavedViewsButton}+ showFullScreenButton={showFullScreenButton}+ scope={scope}+ />{sparklineSection}<div className="flex flex-row gap-2 flex-1 min-h-0">{!facetRailCollapsed && <FacetRail id={id} />}diff --git a/products/logs/frontend/components/LogsViewer/LogsViewerModal/LogsViewerModal.tsx b/products/logs/frontend/components/LogsViewer/LogsViewerModal/LogsViewerModal.tsxindex 23601c5a7231..32939cae7543 100644--- a/products/logs/frontend/components/LogsViewer/LogsViewerModal/LogsViewerModal.tsx+++ b/products/logs/frontend/components/LogsViewer/LogsViewerModal/LogsViewerModal.tsx@@ -12,7 +12,7 @@ import { LogsViewer } from 'products/logs/frontend/components/LogsViewer'import { logsViewerModalLogic } from './logsViewerModalLogic'export function LogsViewerModal(): JSX.Element | null {- const { isOpen, viewerId, fullScreen, initialFilters } = useValues(logsViewerModalLogic)+ const { isOpen, viewerId, fullScreen, initialFilters, pinnedFilters, personId } = useValues(logsViewerModalLogic)const { closeLogsViewerModal } = useActions(logsViewerModalLogic)const [floatingContainer, setFloatingContainer] = useState<HTMLDivElement | null>(null)const floatingContainerRef = useCallback((el: HTMLDivElement | null) => setFloatingContainer(el), [])@@ -45,6 +45,8 @@ export function LogsViewerModal(): JSX.Element | null {id={viewerId}showFullScreenButton={false}initialFilters={initialFilters ?? undefined}+ pinnedFilters={pinnedFilters ?? undefined}+ personId={personId ?? undefined}/></div></LemonModal.Content>diff --git a/products/logs/frontend/components/LogsViewer/LogsViewerModal/logsViewerModalLogic.test.ts b/products/logs/frontend/components/LogsViewer/LogsViewerModal/logsViewerModalLogic.test.tsindex c74056066f0c..563e25fe9ca6 100644--- a/products/logs/frontend/components/LogsViewer/LogsViewerModal/logsViewerModalLogic.test.ts+++ b/products/logs/frontend/components/LogsViewer/LogsViewerModal/logsViewerModalLogic.test.ts@@ -2,6 +2,7 @@ import { router } from 'kea-router'import { expectLogic } from 'kea-test-utils'import { initKeaTests } from '~/test/init'+import { FilterLogicalOperator, PropertyFilterType, PropertyOperator, UniversalFiltersGroup } from '~/types'import { logsViewerModalLogic } from './logsViewerModalLogic'@@ -105,13 +106,53 @@ describe('logsViewerModalLogic', () => {}).toMatchValues({ initialFilters: null })})- it('clears initialFilters on close', async () => {- logic.actions.openLogsViewerModal({ initialFilters: { searchTerm: 'test' } })+ it('keeps initialFilters on close, while the modal renders out its exit animation', async () => {+ const filters = { searchTerm: 'test' }+ logic.actions.openLogsViewerModal({ initialFilters: filters })await expectLogic(logic).toFinishAllListeners()await expectLogic(logic, () => {logic.actions.closeLogsViewerModal()- }).toMatchValues({ initialFilters: null })+ }).toMatchValues({ initialFilters: filters })+ })+ })++ describe('viewer scope', () => {+ const pinnedFilters: UniversalFiltersGroup = {+ type: FilterLogicalOperator.And,+ values: [+ {+ key: 'trace_id',+ type: PropertyFilterType.Log,+ operator: PropertyOperator.Exact,+ value: ['abc'],+ },+ ],+ }++ it('keeps the scope the opening viewer was embedded with', async () => {+ await expectLogic(logic, () => {+ logic.actions.openLogsViewerModal({ id: 'person-1', pinnedFilters, personId: 'a-person-uuid' })+ }).toMatchValues({ pinnedFilters, personId: 'a-person-uuid' })+ })++ it('holds the scope through close, so the closing viewer never queries unscoped', async () => {+ logic.actions.openLogsViewerModal({ id: 'person-1', pinnedFilters, personId: 'a-person-uuid' })+ await expectLogic(logic).toFinishAllListeners()++ await expectLogic(logic, () => {+ logic.actions.closeLogsViewerModal()+ }).toMatchValues({ pinnedFilters, personId: 'a-person-uuid' })+ })++ it('drops the scope when reopened from an unscoped entry point', async () => {+ logic.actions.openLogsViewerModal({ id: 'person-1', pinnedFilters, personId: 'a-person-uuid' })+ await expectLogic(logic).toFinishAllListeners()+ logic.actions.closeLogsViewerModal()++ await expectLogic(logic, () => {+ logic.actions.openLogsViewerModal({ id: 'modal' })+ }).toMatchValues({ pinnedFilters: null, personId: null })})})diff --git a/products/logs/frontend/components/LogsViewer/LogsViewerModal/logsViewerModalLogic.ts b/products/logs/frontend/components/LogsViewer/LogsViewerModal/logsViewerModalLogic.tsindex 496938e5e495..0c94c575f258 100644--- a/products/logs/frontend/components/LogsViewer/LogsViewerModal/logsViewerModalLogic.ts+++ b/products/logs/frontend/components/LogsViewer/LogsViewerModal/logsViewerModalLogic.ts@@ -2,12 +2,13 @@ import { MakeLogicType, actions, afterMount, connect, kea, listeners, path, reduimport { router } from 'kea-router'import type { LocationChangedPayload } from 'kea-router/lib/types'-import { LogsViewerFilters } from 'products/logs/frontend/components/LogsViewer/config/types'+import { UniversalFiltersGroup } from '~/types'-export interface OpenLogsViewerModalOptions {+import { LogsViewerFilters, LogsViewerScope } from 'products/logs/frontend/components/LogsViewer/config/types'++export interface OpenLogsViewerModalOptions extends LogsViewerScope {id?: stringfullScreen?: boolean- initialFilters?: Partial<LogsViewerFilters>}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -15,6 +16,8 @@ export interface logsViewerModalLogicValues {fullScreen: booleaninitialFilters: Partial<LogsViewerFilters> | nullisOpen: boolean+ personId: string | null+ pinnedFilters: UniversalFiltersGroup | nullviewerId: string}@@ -48,6 +51,8 @@ export interface logsViewerModalLogicActions {fullScreen: booleanid: stringinitialFilters: Partial<LogsViewerFilters> | null+ personId: string | null+ pinnedFilters: UniversalFiltersGroup | null}}@@ -63,6 +68,8 @@ export const logsViewerModalLogic = kea<logsViewerModalLogicType>([id: options?.id ?? 'modal',fullScreen: options?.fullScreen ?? true,initialFilters: options?.initialFilters ?? null,+ pinnedFilters: options?.pinnedFilters ?? null,+ personId: options?.personId ?? null,}),closeLogsViewerModal: true,}),@@ -86,11 +93,28 @@ export const logsViewerModalLogic = kea<logsViewerModalLogicType>([openLogsViewerModal: (_, { fullScreen }) => fullScreen,},],+ // The three props below are what the modal binds its viewer with, and they deliberately+ // survive close. useKeepMountedWhileOpen holds the modal rendered for 300ms so the exit+ // animation can finish, so clearing them on close would rebind the viewer logics (shared+ // with the embedding tab, which is keyed by the same id) with no filters and no scope for+ // that beat, firing an unscoped project-wide query. Nothing leaks into the next open+ // because openLogsViewerModal always writes all three, falling back to null.initialFilters: [null as Partial<LogsViewerFilters> | null,{openLogsViewerModal: (_, { initialFilters }) => initialFilters,- closeLogsViewerModal: () => null,+ },+ ],+ pinnedFilters: [+ null as UniversalFiltersGroup | null,+ {+ openLogsViewerModal: (_, { pinnedFilters }) => pinnedFilters,+ },+ ],+ personId: [+ null as string | null,+ {+ openLogsViewerModal: (_, { personId }) => personId,},],}),diff --git a/products/logs/frontend/components/LogsViewer/config/types.ts b/products/logs/frontend/components/LogsViewer/config/types.tsindex f127135902b1..0c2fb22219a2 100644--- a/products/logs/frontend/components/LogsViewer/config/types.ts+++ b/products/logs/frontend/components/LogsViewer/config/types.ts@@ -12,3 +12,13 @@ export interface LogsViewerFilters {export interface LogsViewerConfig {filters: LogsViewerFilters}++// The scope an embedding scene puts a viewer in. The full-screen modal re-applies it when it+// mounts a viewer under the same id, because the logics are keyed by id: opening full screen+// with these left out would rebind the same logics with no scope, so the maximised viewer would+// query project-wide and the embedded viewer would lose its scope once the modal closes.+export interface LogsViewerScope {+ initialFilters?: Partial<LogsViewerFilters>+ pinnedFilters?: UniversalFiltersGroup+ personId?: string+}diff --git a/products/tracing/frontend/components/TraceDrawer/SpanLogsTab.tsx b/products/tracing/frontend/components/TraceDrawer/SpanLogsTab.tsxindex d42d80e85a1a..a348c375e81e 100644--- a/products/tracing/frontend/components/TraceDrawer/SpanLogsTab.tsx+++ b/products/tracing/frontend/components/TraceDrawer/SpanLogsTab.tsx@@ -67,10 +67,6 @@ export function SpanLogsTab({ span }: { span: Span }): JSX.Element {id={`tracing-logs-${span.trace_id}`}pinnedFilters={pinnedFilters}initialFilters={initialFilters}- // Full-screen is off (like PersonLogsTab): the shared modal can't carry pinnedFilters,- // so it would open unscoped and clear this viewer's scope. "Open in Logs" preserves- // the scope via the URL filterGroup instead.- showFullScreenButton={false}showSavedViewsButton={false}// Start with the facet/filter rail hidden — the drawer is narrow and the pinned// scope already covers the common case; "Show filters" re-expands it.