From b8f98b9019543d29e0585e4411befccd3bc1325b Mon Sep 17 00:00:00 2001 From: Maham Date: Fri, 22 Nov 2024 15:14:08 +0500 Subject: [PATCH] feat: add segment event to track the selected value for learning type dropdown --- .../catalog-search/src/LearningTypeRadioFacet.jsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/catalog-search/src/LearningTypeRadioFacet.jsx b/packages/catalog-search/src/LearningTypeRadioFacet.jsx index fc9254b5..93a55f14 100644 --- a/packages/catalog-search/src/LearningTypeRadioFacet.jsx +++ b/packages/catalog-search/src/LearningTypeRadioFacet.jsx @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import classNames from 'classnames'; import { Dropdown, Input, Badge } from '@openedx/paragon'; import { FormattedMessage } from '@edx/frontend-platform/i18n'; +import { sendTrackEvent } from '@edx/frontend-platform/analytics'; import { SearchContext } from './SearchContext'; import { setRefinementAction, @@ -13,7 +14,9 @@ import { } from './data/constants'; const LearningTypeRadioFacet = ({ enablePathways }) => { - const { refinements, dispatch, enableVideos } = useContext(SearchContext); + const { + refinements, dispatch, enableVideos, trackingName, + } = useContext(SearchContext); // only bold the dropdown title if the learning type is Course or Program const typeCourseSelected = refinements.content_type && refinements.content_type.includes(LEARNING_TYPE_COURSE); @@ -28,6 +31,12 @@ const LearningTypeRadioFacet = ({ enablePathways }) => { } else { dispatch(setRefinementAction('content_type', [type])); } + if (trackingName) { + const learningType = type || 'any'; + sendTrackEvent(`edx.enterprise.${trackingName}.search.learning_type_selected`, { + learningType, + }); + } }; return (