Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix(logs): render log details v2 only on the logs explorer route (#12616)

Aditya Singh1aa6346a4cd9
diff --git a/frontend/src/components/LogDetail/__tests__/LogDetail.test.tsx b/frontend/src/components/LogDetail/__tests__/LogDetail.test.tsx
index 4d3171daf9..20a44c648b 100644
--- a/frontend/src/components/LogDetail/__tests__/LogDetail.test.tsx
+++ b/frontend/src/components/LogDetail/__tests__/LogDetail.test.tsx
@@ -18,10 +18,9 @@ jest.mock('periscope/components/DataViewer', () => ({
DataViewer: (): JSX.Element => <div data-testid="overview-data-viewer" />,
}));
-// The flag to be removed later
-jest.mock('../constants', () => ({
- ...jest.requireActual('../constants'),
- isLogDetailsV2: true,
+// Force v2 for these tests regardless of route.
+jest.mock('../useIsLogDetailsV2', () => ({
+ useIsLogDetailsV2: (): boolean => true,
}));
const mockLog: ILog = {
diff --git a/frontend/src/components/LogDetail/constants.ts b/frontend/src/components/LogDetail/constants.ts
index 0e51910536..fa7c7c45bd 100644
--- a/frontend/src/components/LogDetail/constants.ts
+++ b/frontend/src/components/LogDetail/constants.ts
@@ -1,6 +1,3 @@
-// temporary flag to be removed with old log details code.
-export const isLogDetailsV2 = true;
-
export const VIEW_TYPES = {
OVERVIEW: 'OVERVIEW',
JSON: 'JSON',
diff --git a/frontend/src/components/LogDetail/index.tsx b/frontend/src/components/LogDetail/index.tsx
index e9cdf1d441..5ae8f9f503 100644
--- a/frontend/src/components/LogDetail/index.tsx
+++ b/frontend/src/components/LogDetail/index.tsx
@@ -51,11 +51,12 @@ import { ILogBody } from 'types/api/logs/log';
import { Query, TagFilter } from 'types/api/queryBuilder/queryBuilderData';
import { DataSource, StringOperators } from 'types/common/queryBuilder';
-import { isLogDetailsV2, RESOURCE_KEYS, VIEW_TYPES, VIEWS } from './constants';
+import { RESOURCE_KEYS, VIEW_TYPES, VIEWS } from './constants';
import { LogDetailInnerProps, LogDetailProps } from './LogDetail.interfaces';
import LogDetailsHeader from './LogDetailsHeader/LogDetailsHeader';
import { useLogNavigation } from './LogDetailsHeader/useLogNavigation';
import LogHighlights from './LogHighlights/LogHighlights';
+import { useIsLogDetailsV2 } from './useIsLogDetailsV2';
import './LogDetails.styles.scss';
@@ -92,6 +93,8 @@ function LogDetailInner({
const [isEdit, setIsEdit] = useState<boolean>(false);
const { stagedQuery } = useQueryBuilder();
+ const isLogDetailsV2 = useIsLogDetailsV2();
+
// Handle clicks outside to close drawer, except on explicitly ignored regions
useEffect(() => {
const handleClickOutside = (e: MouseEvent): void => {
diff --git a/frontend/src/components/LogDetail/useIsLogDetailsV2.ts b/frontend/src/components/LogDetail/useIsLogDetailsV2.ts
new file mode 100644
index 0000000000..2b15a48693
--- /dev/null
+++ b/frontend/src/components/LogDetail/useIsLogDetailsV2.ts
@@ -0,0 +1,9 @@
+import ROUTES from 'constants/routes';
+import { useLocation } from 'react-router-dom';
+
+// v2 is rolled out only on the logs explorer route for now; every other surface
+// (dashboards, infra monitoring, etc.) keeps the v1 log details view.
+export function useIsLogDetailsV2(): boolean {
+ const { pathname } = useLocation();
+ return pathname === ROUTES.LOGS_EXPLORER;
+}
diff --git a/frontend/src/container/LogDetailedView/Overview.tsx b/frontend/src/container/LogDetailedView/Overview.tsx
index 7cd35162da..bb128c7990 100644
--- a/frontend/src/container/LogDetailedView/Overview.tsx
+++ b/frontend/src/container/LogDetailedView/Overview.tsx
@@ -13,7 +13,7 @@ import { ChangeViewFunctionType } from 'container/ExplorerOptions/types';
import { OptionsQuery } from 'container/OptionsMenu/types';
import { useIsDarkMode } from 'hooks/useDarkMode';
import { ChevronDown, ChevronRight, Search } from '@signozhq/icons';
-import { isLogDetailsV2 } from 'components/LogDetail/constants';
+import { useIsLogDetailsV2 } from 'components/LogDetail/useIsLogDetailsV2';
import { DataViewer } from 'periscope/components/DataViewer';
import { IField } from 'types/api/logs/fields';
import { ILog } from 'types/api/logs/log';
@@ -69,6 +69,8 @@ function Overview({
isListViewPanel,
});
+ const isLogDetailsV2 = useIsLogDetailsV2();
+
if (isLogDetailsV2) {
const raw = aggregateAttributesResourcesToObject(logData);
const prettyData = buildPrettyViewData(raw);