diff --git a/packages/catalog-search/src/LearningTypeRadioFacet.jsx b/packages/catalog-search/src/LearningTypeRadioFacet.jsx index fc9254b5..2fc7c492 100644 --- a/packages/catalog-search/src/LearningTypeRadioFacet.jsx +++ b/packages/catalog-search/src/LearningTypeRadioFacet.jsx @@ -3,7 +3,9 @@ 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 { SEARCH_EVENT_NAME_PREFIX } from './SearchBox'; import { setRefinementAction, } from './data/actions'; @@ -12,8 +14,12 @@ import { LEARNING_TYPE_COURSE, LEARNING_TYPE_PROGRAM, LEARNING_TYPE_PATHWAY, LEARNING_TYPE_VIDEO, } from './data/constants'; +const LEARNING_TYPE_SELECTED_EVENT = 'catalog_search.learning_type_selected'; + 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 +34,12 @@ const LearningTypeRadioFacet = ({ enablePathways }) => { } else { dispatch(setRefinementAction('content_type', [type])); } + if (trackingName) { + const learningType = type || 'any'; + sendTrackEvent(`${SEARCH_EVENT_NAME_PREFIX}.${trackingName}.${LEARNING_TYPE_SELECTED_EVENT}`, { + learningType, + }); + } }; return (