Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import type { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public';

export const APP_NAME = 'cloud-security';

export const MISCONFIGURATION_INSIGHT = 'misconfiguration-insight' as const;
export const VULNERABILITIES_INSIGHT = 'vulnerabilities-insight' as const;
export const MISCONFIGURATION_INSIGHT = 'misconfiguration-insight-v2' as const;
export const VULNERABILITIES_INSIGHT = 'vulnerabilities-insight-v2' as const;
export const MISCONFIGURATION_INSIGHT_HOST_DETAILS =
`${MISCONFIGURATION_INSIGHT}-host-details` as const;
export const MISCONFIGURATION_INSIGHT_USER_DETAILS =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,19 @@ export const MisconfigurationsInsight: React.FC<MisconfigurationsInsightProps> =
'newExpandableFlyoutNavigationEnabled'
);

useEffect(() => {
if (telemetryKey) {
uiMetricService.trackUiMetric(METRIC_TYPE.COUNT, telemetryKey);
}
}, [telemetryKey, renderingId]);

const passedFindings = data?.count.passed || 0;
const failedFindings = data?.count.failed || 0;
const totalFindings = useMemo(
() => passedFindings + failedFindings,
[passedFindings, failedFindings]
);
const hasMisconfigurationFindings = totalFindings > 0;
const shouldRender = totalFindings > 0; // this component only renders if there are findings

useEffect(() => {
if (shouldRender && telemetryKey) {
uiMetricService.trackUiMetric(METRIC_TYPE.COUNT, telemetryKey);
}
}, [shouldRender, telemetryKey, renderingId]);

const misconfigurationsStats = useMemo(
() => getFindingsStats(passedFindings, failedFindings),
Expand Down Expand Up @@ -161,7 +161,7 @@ export const MisconfigurationsInsight: React.FC<MisconfigurationsInsightProps> =
]
);

if (!hasMisconfigurationFindings) return null;
if (!shouldRender) return null;

return (
<EuiFlexItem data-test-subj={dataTestSubj}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,14 @@ export const VulnerabilitiesInsight: React.FC<VulnerabilitiesInsightProps> = ({
'newExpandableFlyoutNavigationEnabled'
);

useEffect(() => {
if (telemetryKey) {
uiMetricService.trackUiMetric(METRIC_TYPE.COUNT, telemetryKey);
}
}, [telemetryKey, renderingId]);

const { CRITICAL = 0, HIGH = 0, MEDIUM = 0, LOW = 0, NONE = 0 } = data?.count || {};
const totalVulnerabilities = useMemo(
() => CRITICAL + HIGH + MEDIUM + LOW + NONE,
[CRITICAL, HIGH, MEDIUM, LOW, NONE]
);

const hasVulnerabilitiesFindings = useMemo(
// this component only renders if there are findings
const shouldRender = useMemo(
() =>
hasVulnerabilitiesData({
critical: CRITICAL,
Expand All @@ -106,6 +101,12 @@ export const VulnerabilitiesInsight: React.FC<VulnerabilitiesInsightProps> = ({
[CRITICAL, HIGH, MEDIUM, LOW, NONE]
);

useEffect(() => {
if (shouldRender && telemetryKey) {
uiMetricService.trackUiMetric(METRIC_TYPE.COUNT, telemetryKey);
}
}, [shouldRender, telemetryKey, renderingId]);

const vulnerabilitiesStats = useMemo(
() =>
getVulnerabilityStats({
Expand Down Expand Up @@ -172,7 +173,7 @@ export const VulnerabilitiesInsight: React.FC<VulnerabilitiesInsightProps> = ({
]
);

if (!hasVulnerabilitiesFindings) return null;
if (!shouldRender) return null;

return (
<EuiFlexItem data-test-subj={dataTestSubj}>
Expand Down