Wizard: Add isPreview property to analytics tracking

This adds `isPreview` property to the analytics tracking with the use of chrome's `isBeta()`.
This commit is contained in:
regexowl 2024-09-11 13:46:06 +02:00 committed by Klara Simickova
parent 77a57db014
commit 39d2f91f03
3 changed files with 14 additions and 4 deletions

View file

@ -38,7 +38,7 @@ import { releaseToVersion } from '../../../../Utilities/releaseToVersion';
import useDebounce from '../../../../Utilities/useDebounce';
const PackageRecommendations = () => {
const { analytics } = useChrome();
const { analytics, isBeta } = useChrome();
const dispatch = useDispatch();
const arch = useAppSelector(selectArchitecture);
@ -82,6 +82,7 @@ const PackageRecommendations = () => {
`${AMPLITUDE_MODULE_NAME}-packageRecommendationsShown`,
{
module: AMPLITUDE_MODULE_NAME,
isPreview: isBeta(),
shownRecommendations: response.data.packages,
selectedPackages: packages.map((pkg) => pkg.name),
}
@ -232,6 +233,7 @@ const PackageRecommendations = () => {
`${AMPLITUDE_MODULE_NAME}-recommendedPackageAdded`,
{
module: AMPLITUDE_MODULE_NAME,
isPreview: isBeta(),
packageName: pkg,
selectedPackages: packages.map(
(pkg) => pkg.name

View file

@ -14,12 +14,13 @@ import useChrome from '@redhat-cloud-services/frontend-components/useChrome';
import { AMPLITUDE_MODULE_NAME } from '../../../../../constants';
import { setBlueprintId } from '../../../../../store/BlueprintSlice';
import { useAppDispatch } from '../../../../../store/hooks';
import { useAppDispatch, useAppSelector } from '../../../../../store/hooks';
import {
CreateBlueprintRequest,
useComposeBlueprintMutation,
useCreateBlueprintMutation,
} from '../../../../../store/imageBuilderApi';
import { selectPackages } from '../../../../../store/wizardSlice';
type CreateDropdownProps = {
getBlueprintPayload: () => Promise<'' | CreateBlueprintRequest | undefined>;
@ -32,7 +33,8 @@ export const CreateSaveAndBuildBtn = ({
setIsOpen,
isDisabled,
}: CreateDropdownProps) => {
const { analytics } = useChrome();
const { analytics, isBeta } = useChrome();
const packages = useAppSelector(selectPackages);
const [buildBlueprint] = useComposeBlueprintMutation();
const [createBlueprint] = useCreateBlueprintMutation({
@ -45,7 +47,9 @@ export const CreateSaveAndBuildBtn = ({
analytics.track(`${AMPLITUDE_MODULE_NAME}-blueprintCreated`, {
module: AMPLITUDE_MODULE_NAME,
isPreview: isBeta(),
type: 'createBlueprintAndBuildImages',
packages: packages.map((pkg) => pkg.name),
});
const blueprint =
@ -78,7 +82,8 @@ export const CreateSaveButton = ({
getBlueprintPayload,
isDisabled,
}: CreateDropdownProps) => {
const { analytics } = useChrome();
const { analytics, isBeta } = useChrome();
const packages = useAppSelector(selectPackages);
const [createBlueprint, { isLoading }] = useCreateBlueprintMutation({
fixedCacheKey: 'createBlueprintKey',
@ -133,7 +138,9 @@ export const CreateSaveButton = ({
analytics.track(`${AMPLITUDE_MODULE_NAME}-blueprintCreated`, {
module: AMPLITUDE_MODULE_NAME,
isPreview: isBeta(),
type: 'createBlueprint',
packages: packages.map((pkg) => pkg.name),
});
const blueprint =

View file

@ -36,6 +36,7 @@ vi.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
analytics: {
track: () => 'test',
},
isBeta: () => true,
}),
}));