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: fixed logEvent breaking page due to lack of null checks (#5511)

SagarRajput-7add2d196144c
diff --git a/frontend/src/container/AllError/index.tsx b/frontend/src/container/AllError/index.tsx
index d571c3dba7..0dd46c0a64 100644
--- a/frontend/src/container/AllError/index.tsx
+++ b/frontend/src/container/AllError/index.tsx
@@ -423,9 +423,9 @@ function AllErrors(): JSX.Element {
)?.tagValue;
logEvent('Exception: List page visited', {
- numberOfExceptions: errorCountResponse.data?.payload,
+ numberOfExceptions: errorCountResponse?.data?.payload,
selectedEnvironments,
- resourceAttributeUsed: !!queries.length,
+ resourceAttributeUsed: !!queries?.length,
});
logEventCalledRef.current = true;
}
diff --git a/frontend/src/container/CreateAlertChannels/index.tsx b/frontend/src/container/CreateAlertChannels/index.tsx
index 85d609c24c..7345fa4ef9 100644
--- a/frontend/src/container/CreateAlertChannels/index.tsx
+++ b/frontend/src/container/CreateAlertChannels/index.tsx
@@ -449,8 +449,8 @@ function CreateAlertChannels({
const result = await functionToCall();
logEvent('Alert Channel: Save channel', {
type: value,
- sendResolvedAlert: selectedConfig.send_resolved,
- name: selectedConfig.name,
+ sendResolvedAlert: selectedConfig?.send_resolved,
+ name: selectedConfig?.name,
new: 'true',
status: result?.status,
statusMessage: result?.statusMessage,
@@ -530,8 +530,8 @@ function CreateAlertChannels({
logEvent('Alert Channel: Test notification', {
type: channelType,
- sendResolvedAlert: selectedConfig.send_resolved,
- name: selectedConfig.name,
+ sendResolvedAlert: selectedConfig?.send_resolved,
+ name: selectedConfig?.name,
new: 'true',
status:
response && response.statusCode === 200 ? 'Test success' : 'Test failed',
diff --git a/frontend/src/container/EditAlertChannels/index.tsx b/frontend/src/container/EditAlertChannels/index.tsx
index b4fe30d557..0fc46beb33 100644
--- a/frontend/src/container/EditAlertChannels/index.tsx
+++ b/frontend/src/container/EditAlertChannels/index.tsx
@@ -370,8 +370,8 @@ function EditAlertChannels({
}
logEvent('Alert Channel: Save channel', {
type: value,
- sendResolvedAlert: selectedConfig.send_resolved,
- name: selectedConfig.name,
+ sendResolvedAlert: selectedConfig?.send_resolved,
+ name: selectedConfig?.name,
new: 'false',
status: result?.status,
statusMessage: result?.statusMessage,
@@ -441,8 +441,8 @@ function EditAlertChannels({
}
logEvent('Alert Channel: Test notification', {
type: channelType,
- sendResolvedAlert: selectedConfig.send_resolved,
- name: selectedConfig.name,
+ sendResolvedAlert: selectedConfig?.send_resolved,
+ name: selectedConfig?.name,
new: 'false',
status:
response && response.statusCode === 200 ? 'Test success' : 'Test failed',
diff --git a/frontend/src/container/ErrorDetails/index.tsx b/frontend/src/container/ErrorDetails/index.tsx
index 2c87279e3d..c6b0d5fa22 100644
--- a/frontend/src/container/ErrorDetails/index.tsx
+++ b/frontend/src/container/ErrorDetails/index.tsx
@@ -114,10 +114,10 @@ function ErrorDetails(props: ErrorDetailsProps): JSX.Element {
const onClickTraceHandler = (): void => {
logEvent('Exception: Navigate to trace detail page', {
- groupId: errorDetail.groupID,
+ groupId: errorDetail?.groupID,
spanId: errorDetail.spanID,
traceId: errorDetail.traceID,
- exceptionId: errorDetail.errorId,
+ exceptionId: errorDetail?.errorId,
});
history.push(`/trace/${errorDetail.traceID}?spanId=${errorDetail.spanID}`);
};
@@ -126,10 +126,10 @@ function ErrorDetails(props: ErrorDetailsProps): JSX.Element {
useEffect(() => {
if (!logEventCalledRef.current && !isUndefined(data)) {
logEvent('Exception: Detail page visited', {
- groupId: errorDetail.groupID,
+ groupId: errorDetail?.groupID,
spanId: errorDetail.spanID,
traceId: errorDetail.traceID,
- exceptionId: errorDetail.errorId,
+ exceptionId: errorDetail?.errorId,
});
logEventCalledRef.current = true;
}
diff --git a/frontend/src/container/ExplorerOptions/ExplorerOptions.tsx b/frontend/src/container/ExplorerOptions/ExplorerOptions.tsx
index e925a60a8a..138694058e 100644
--- a/frontend/src/container/ExplorerOptions/ExplorerOptions.tsx
+++ b/frontend/src/container/ExplorerOptions/ExplorerOptions.tsx
@@ -256,12 +256,12 @@ function ExplorerOptions({
if (sourcepage === DataSource.TRACES) {
logEvent('Traces Explorer: Select view', {
panelType,
- viewName: option.value,
+ viewName: option?.value,
});
} else if (sourcepage === DataSource.LOGS) {
logEvent('Logs Explorer: Select view', {
panelType,
- viewName: option.value,
+ viewName: option?.value,
});
}
if (ref.current) {
diff --git a/frontend/src/container/FormAlertRules/BasicInfo.tsx b/frontend/src/container/FormAlertRules/BasicInfo.tsx
index 40edb7977e..d047ed617b 100644
--- a/frontend/src/container/FormAlertRules/BasicInfo.tsx
+++ b/frontend/src/container/FormAlertRules/BasicInfo.tsx
@@ -88,7 +88,7 @@ function BasicInfo({
if (!channels.loading && isNewRule) {
logEvent('Alert: New alert creation page visited', {
dataSource: ALERTS_DATA_SOURCE_MAP[alertDef?.alertType as AlertTypes],
- numberOfChannels: channels.payload?.length,
+ numberOfChannels: channels?.payload?.length,
});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
diff --git a/frontend/src/container/ListAlertRules/utils.ts b/frontend/src/container/ListAlertRules/utils.ts
index 32da7eaad5..1556b28274 100644
--- a/frontend/src/container/ListAlertRules/utils.ts
+++ b/frontend/src/container/ListAlertRules/utils.ts
@@ -49,9 +49,9 @@ export const alertActionLogEvent = (
break;
}
logEvent('Alert: Action', {
- ruleId: record.id,
+ ruleId: record?.id,
dataSource: ALERTS_DATA_SOURCE_MAP[record.alertType as AlertTypes],
- name: record.alert,
+ name: record?.alert,
action: actionValue,
});
};
diff --git a/frontend/src/container/MetricsApplication/Tabs/DBCall.tsx b/frontend/src/container/MetricsApplication/Tabs/DBCall.tsx
index a520d98936..3ee49ddc9a 100644
--- a/frontend/src/container/MetricsApplication/Tabs/DBCall.tsx
+++ b/frontend/src/container/MetricsApplication/Tabs/DBCall.tsx
@@ -108,7 +108,7 @@ function DBCall(): JSX.Element {
logEvent('APM: Service detail page visited', {
selectedEnvironments,
- resourceAttributeUsed: !!queries.length,
+ resourceAttributeUsed: !!queries?.length,
section: 'dbMetrics',
});
logEventCalledRef.current = true;
diff --git a/frontend/src/container/MetricsApplication/Tabs/External.tsx b/frontend/src/container/MetricsApplication/Tabs/External.tsx
index d224135175..69abd6696d 100644
--- a/frontend/src/container/MetricsApplication/Tabs/External.tsx
+++ b/frontend/src/container/MetricsApplication/Tabs/External.tsx
@@ -124,7 +124,7 @@ function External(): JSX.Element {
logEvent('APM: Service detail page visited', {
selectedEnvironments,
- resourceAttributeUsed: !!queries.length,
+ resourceAttributeUsed: !!queries?.length,
section: 'externalMetrics',
});
logEventCalledRef.current = true;
diff --git a/frontend/src/container/MetricsApplication/Tabs/Overview.tsx b/frontend/src/container/MetricsApplication/Tabs/Overview.tsx
index 96cc821fb8..4fb9a2ccf3 100644
--- a/frontend/src/container/MetricsApplication/Tabs/Overview.tsx
+++ b/frontend/src/container/MetricsApplication/Tabs/Overview.tsx
@@ -91,7 +91,7 @@ function Application(): JSX.Element {
logEvent('APM: Service detail page visited', {
selectedEnvironments,
- resourceAttributeUsed: !!queries.length,
+ resourceAttributeUsed: !!queries?.length,
section: 'overview',
});
logEventCalledRef.current = true;
diff --git a/frontend/src/container/ServiceApplication/ServiceTraces/index.tsx b/frontend/src/container/ServiceApplication/ServiceTraces/index.tsx
index 8d6238c68a..59c7a294bb 100644
--- a/frontend/src/container/ServiceApplication/ServiceTraces/index.tsx
+++ b/frontend/src/container/ServiceApplication/ServiceTraces/index.tsx
@@ -59,7 +59,7 @@ function ServiceTraces(): JSX.Element {
logEvent('APM: List page visited', {
numberOfServices: data?.length,
selectedEnvironments,
- resourceAttributeUsed: !!queries.length,
+ resourceAttributeUsed: !!queries?.length,
rps,
});
logEventCalledRef.current = true;
diff --git a/frontend/src/container/SideNav/SideNav.tsx b/frontend/src/container/SideNav/SideNav.tsx
index b5eb240af8..d4ad27908c 100644
--- a/frontend/src/container/SideNav/SideNav.tsx
+++ b/frontend/src/container/SideNav/SideNav.tsx
@@ -324,8 +324,8 @@ function SideNav({
onClickHandler(item?.key as string, event);
}
logEvent('Sidebar: Menu clicked', {
- menuRoute: item.key,
- menuLabel: item.label,
+ menuRoute: item?.key,
+ menuLabel: item?.label,
});
};
@@ -455,8 +455,8 @@ function SideNav({
onClick={(event: MouseEvent): void => {
handleUserManagentMenuItemClick(item?.key as string, event);
logEvent('Sidebar: Menu clicked', {
- menuRoute: item.key,
- menuLabel: item.label,
+ menuRoute: item?.key,
+ menuLabel: item?.label,
});
}}
/>
@@ -475,8 +475,8 @@ function SideNav({
history.push(`${inviteMemberMenuItem.key}`);
}
logEvent('Sidebar: Menu clicked', {
- menuRoute: inviteMemberMenuItem.key,
- menuLabel: inviteMemberMenuItem.label,
+ menuRoute: inviteMemberMenuItem?.key,
+ menuLabel: inviteMemberMenuItem?.label,
});
}}
/>
@@ -493,7 +493,7 @@ function SideNav({
event,
);
logEvent('Sidebar: Menu clicked', {
- menuRoute: userSettingsMenuItem.key,
+ menuRoute: userSettingsMenuItem?.key,
menuLabel: 'User',
});
}}
diff --git a/frontend/src/pages/SaveView/index.tsx b/frontend/src/pages/SaveView/index.tsx
index efcd3f2a4b..7088c4a78c 100644
--- a/frontend/src/pages/SaveView/index.tsx
+++ b/frontend/src/pages/SaveView/index.tsx
@@ -149,11 +149,11 @@ function SaveView(): JSX.Element {
if (!logEventCalledRef.current && !isLoading) {
if (sourcepage === DataSource.TRACES) {
logEvent('Traces Views: Views visited', {
- number: viewsData?.data.data.length,
+ number: viewsData?.data?.data?.length,
});
} else if (sourcepage === DataSource.LOGS) {
logEvent('Logs Views: Views visited', {
- number: viewsData?.data.data.length,
+ number: viewsData?.data?.data?.length,
});
}
logEventCalledRef.current = true;