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.

refactor(frontend): remove defunct tabId from logs scene (#62032)

Paul D'Ambra14c7e58ae129
diff --git a/products/logs/frontend/LogsScene.tsx b/products/logs/frontend/LogsScene.tsx
index 3ab5d65ef4e2..4e3e1142fba5 100644
--- a/products/logs/frontend/LogsScene.tsx
+++ b/products/logs/frontend/LogsScene.tsx
@@ -23,7 +23,7 @@ import { logsIngestionLogic } from 'products/logs/frontend/components/SetupPromp
import { LogsSetupPrompt } from 'products/logs/frontend/components/SetupPrompt/SetupPrompt'
import { useOpenLogsSettingsPanel } from './hooks/useOpenLogsSettingsPanel'
-import { LogsSceneActiveTab, logsSceneLogic } from './logsSceneLogic'
+import { LOGS_SCENE_VIEWER_ID, LogsSceneActiveTab, logsSceneLogic } from './logsSceneLogic'
export const LOGS_LOGIC_KEY = 'logs'
@@ -44,7 +44,6 @@ export function LogsScene(): JSX.Element {
}
const LogsSceneContent = (): JSX.Element => {
- const { tabId } = useValues(logsSceneLogic)
const { hasLogs, teamHasLogsCheckFailed } = useValues(logsIngestionLogic)
const openLogsSettings = useOpenLogsSettingsPanel()
@@ -80,7 +79,7 @@ const LogsSceneContent = (): JSX.Element => {
)}
<LogsSetupPrompt>
<div className="flex flex-col gap-2 py-2 flex-1 min-h-0">
- <LogsViewer id={tabId} showSavedViewsButton />
+ <LogsViewer id={LOGS_SCENE_VIEWER_ID} showSavedViewsButton />
</div>
</LogsSetupPrompt>
</>
@@ -88,7 +87,7 @@ const LogsSceneContent = (): JSX.Element => {
}
const LogsSceneTabbedContent = (): JSX.Element => {
- const { tabId, activeTab } = useValues(logsSceneLogic)
+ const { activeTab } = useValues(logsSceneLogic)
const { setActiveTab } = useActions(logsSceneLogic)
const { hasLogs, teamHasLogsCheckFailed } = useValues(logsIngestionLogic)
const showServicesView = useFeatureFlag('LOGS_SERVICES_VIEW')
@@ -139,7 +138,7 @@ const LogsSceneTabbedContent = (): JSX.Element => {
{activeTab === 'viewer' && (
<LogsSetupPrompt>
<div className="flex flex-col gap-2 py-2 flex-1 min-h-0">
- <LogsViewer id={tabId} showSavedViewsButton />
+ <LogsViewer id={LOGS_SCENE_VIEWER_ID} showSavedViewsButton />
</div>
</LogsSetupPrompt>
)}
@@ -150,7 +149,7 @@ const LogsSceneTabbedContent = (): JSX.Element => {
</>
)}
{activeTab === 'alerts' && showAlerting && <LogsAlertingSection />}
- {activeTab === 'sql' && showSqlView && <LogsSqlEditor id={tabId} />}
+ {activeTab === 'sql' && showSqlView && <LogsSqlEditor id={LOGS_SCENE_VIEWER_ID} />}
{activeTab === 'configuration' && (
<Settings logicKey={LOGS_LOGIC_KEY} sectionId="environment-logs" settingId="logs" handleLocally />
)}
diff --git a/products/logs/frontend/components/LogsViews/logsViewsLogic.ts b/products/logs/frontend/components/LogsViews/logsViewsLogic.ts
index 0b72253a3a68..4cfc85a7b1a4 100644
--- a/products/logs/frontend/components/LogsViews/logsViewsLogic.ts
+++ b/products/logs/frontend/components/LogsViews/logsViewsLogic.ts
@@ -27,12 +27,7 @@ export const logsViewsLogic = kea<logsViewsLogicType>([
connect((props: LogsViewsLogicProps) => ({
values: [teamLogic, ['currentTeamId']],
- actions: [
- logsViewerFiltersLogic({ id: props.id }),
- ['setFilters'],
- logsSceneLogic({ tabId: props.id }),
- ['setActiveTab'],
- ],
+ actions: [logsViewerFiltersLogic({ id: props.id }), ['setFilters'], logsSceneLogic(), ['setActiveTab']],
})),
actions({
diff --git a/products/logs/frontend/logsSceneLogic.test.ts b/products/logs/frontend/logsSceneLogic.test.ts
index 4f682d6b871e..5ccf5fa40a51 100644
--- a/products/logs/frontend/logsSceneLogic.test.ts
+++ b/products/logs/frontend/logsSceneLogic.test.ts
@@ -17,7 +17,7 @@ describe('logsSceneLogic', () => {
},
})
initKeaTests()
- logic = logsSceneLogic({ tabId: 'test-tab' })
+ logic = logsSceneLogic()
logic.mount()
await expectLogic(logic).toFinishAllListeners()
diff --git a/products/logs/frontend/logsSceneLogic.tsx b/products/logs/frontend/logsSceneLogic.tsx
index 59bc2f33b619..c73c1278cbc9 100644
--- a/products/logs/frontend/logsSceneLogic.tsx
+++ b/products/logs/frontend/logsSceneLogic.tsx
@@ -1,11 +1,10 @@
import equal from 'fast-deep-equal'
-import { actions, connect, kea, listeners, path, props, reducers, selectors } from 'kea'
+import { actions, connect, kea, listeners, path, reducers } from 'kea'
import { router, urlToAction } from 'kea-router'
import { syncSearchParams, updateSearchParams } from '@posthog/products-error-tracking/frontend/utils'
import { DEFAULT_UNIVERSAL_GROUP_FILTER } from 'lib/components/UniversalFilters/universalFiltersLogic'
-import { tabAwareScene } from 'lib/logic/scenes/tabAwareScene'
import { trackedActionToUrl } from 'lib/logic/scenes/trackedActionToUrl'
import { parseTagsFilter } from 'lib/utils'
import { sqlEditorLogic } from 'scenes/data-warehouse/editor/sqlEditorLogic'
@@ -36,6 +35,10 @@ import type { logsSceneLogicType } from './logsSceneLogicType'
export const getLogsSqlEditorTabId = (id: string): string => `logs-sql-editor-${id}`
+// Scope the viewer id (and so its persisted state: pinned logs, filters, config) per project.
+// A static id would persist across projects in the same browser, leaking one project's pinned log payloads into another.
+export const LOGS_SCENE_VIEWER_ID = `logs-scene-${window.POSTHOG_APP_CONTEXT?.current_team?.id ?? 'unknown'}`
+
export type LogsSceneActiveTab = 'viewer' | 'services' | 'alerts' | 'sql' | 'configuration'
const VALID_ACTIVE_TABS: LogsSceneActiveTab[] = ['viewer', 'services', 'alerts', 'sql', 'configuration']
export const DEFAULT_ACTIVE_TAB: LogsSceneActiveTab = 'viewer'
@@ -50,37 +53,31 @@ const resolveActiveTabFromParams = (params: Params): LogsSceneActiveTab | null =
return null
}
-export interface LogsLogicProps {
- tabId: string
-}
-
export const logsSceneLogic = kea<logsSceneLogicType>([
- props({} as LogsLogicProps),
path(['products', 'logs', 'frontend', 'logsSceneLogic']),
- tabAwareScene(),
- connect((props: LogsLogicProps) => ({
+ connect(() => ({
actions: [
- logsViewerFiltersLogic({ id: props.tabId }),
+ logsViewerFiltersLogic({ id: LOGS_SCENE_VIEWER_ID }),
['setFilters'],
- logsFilterHistoryLogic({ id: props.tabId }),
+ logsFilterHistoryLogic({ id: LOGS_SCENE_VIEWER_ID }),
['pushToFilterHistory'],
- logsViewerConfigLogic({ id: props.tabId }),
+ logsViewerConfigLogic({ id: LOGS_SCENE_VIEWER_ID }),
['setOrderBy'],
- logsViewerDataLogic({ id: props.tabId }),
+ logsViewerDataLogic({ id: LOGS_SCENE_VIEWER_ID }),
['setInitialLogsLimit', 'fetchLogsSuccess', 'handleQueryChange'],
- logsViewerLogic({ id: props.tabId }),
+ logsViewerLogic({ id: LOGS_SCENE_VIEWER_ID }),
['setLinkToLogId', 'clearLinkToLogId'],
- logDetailsModalLogic({ id: props.tabId }),
+ logDetailsModalLogic({ id: LOGS_SCENE_VIEWER_ID }),
['closeLogDetails'],
],
values: [
- logsViewerFiltersLogic({ id: props.tabId }),
+ logsViewerFiltersLogic({ id: LOGS_SCENE_VIEWER_ID }),
['filters', 'utcDateRange'],
- logsViewerConfigLogic({ id: props.tabId }),
+ logsViewerConfigLogic({ id: LOGS_SCENE_VIEWER_ID }),
['orderBy'],
- logsViewerDataLogic({ id: props.tabId }),
+ logsViewerDataLogic({ id: LOGS_SCENE_VIEWER_ID }),
['initialLogsLimit'],
- logsViewerLogic({ id: props.tabId }),
+ logsViewerLogic({ id: LOGS_SCENE_VIEWER_ID }),
['linkToLogId'],
],
})),
@@ -261,10 +258,6 @@ export const logsSceneLogic = kea<logsSceneLogicType>([
],
}),
- selectors({
- tabId: [(_, p) => [p.tabId], (tabId: string) => tabId],
- }),
-
listeners(({ values, actions, cache }) => ({
toggleAttributeBreakdown: ({ key }) => {
const breakdowns = [...values.expandedAttributeBreaksdowns]