From 7f585154f2ac3a8b72724d4352ae2b05da5accba Mon Sep 17 00:00:00 2001 From: Lucas Garfield Date: Thu, 17 Apr 2025 09:55:01 -0500 Subject: [PATCH] Wizard/Oscap: Add analytics (HMS-5990) The Intercom team has some ideas about helping new users determine which security profile is right for them. Tracking differentiates between "vanilla" OpenSCAP and Compliance so that any messages from Intercom can be targeted. --- .../CreateImageWizard/steps/Oscap/index.tsx | 17 ++++++++++++++++- src/test/setup.ts | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Components/CreateImageWizard/steps/Oscap/index.tsx b/src/Components/CreateImageWizard/steps/Oscap/index.tsx index 78e5fe10..a1a82ff9 100644 --- a/src/Components/CreateImageWizard/steps/Oscap/index.tsx +++ b/src/Components/CreateImageWizard/steps/Oscap/index.tsx @@ -9,6 +9,7 @@ import { Title, } from '@patternfly/react-core'; import { ExternalLinkAltIcon } from '@patternfly/react-icons'; +import useChrome from '@redhat-cloud-services/frontend-components/useChrome'; import OscapOnPremSpinner from './components/OnPremSpinner'; import OscapOnPremWarning from './components/OnPremWarning'; @@ -38,16 +39,22 @@ import { selectComplianceType, clearKernelAppend, } from '../../../../store/wizardSlice'; -import { useFlag } from '../../../../Utilities/useGetEnvironment'; +import { + useFlag, + useGetEnvironment, +} from '../../../../Utilities/useGetEnvironment'; import { useOnPremOpenSCAPAvailable } from '../../../../Utilities/useOnPremOpenSCAP'; const OscapContent = () => { const dispatch = useAppDispatch(); + const { analytics } = useChrome(); + const { isFedoraEnv } = useGetEnvironment(); const complianceEnabled = useFlag('image-builder.compliance.enabled'); const complianceType = useAppSelector(selectComplianceType); const profileID = useAppSelector(selectComplianceProfileID); const prefetchOscapProfile = useBackendPrefetch('getOscapProfiles', {}); const release = removeBetaFromRelease(useAppSelector(selectDistribution)); + const { data: currentProfileData } = useGetOscapCustomizationsQuery( { distribution: release, @@ -87,6 +94,14 @@ const OscapContent = () => { dispatch(clearKernelAppend()); }; + if (!process.env.IS_ON_PREMISE && !isFedoraEnv) { + if (complianceEnabled) { + analytics.screen('ib-createimagewizard-step-security-compliance'); + } else { + analytics.screen('ib-createimagewizard-step-security-openscap'); + } + } + return (
diff --git a/src/test/setup.ts b/src/test/setup.ts index 07321509..4b95a225 100644 --- a/src/test/setup.ts +++ b/src/test/setup.ts @@ -40,6 +40,7 @@ vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({ analytics: { track: () => 'test', group: () => 'test', + screen: () => 'test', }, isBeta: () => true, }),