Skip to content

Commit

Permalink
feat: add segment event to track the selected value for learning type…
Browse files Browse the repository at this point in the history
… dropdown
  • Loading branch information
mahamakifdar19 committed Nov 25, 2024
1 parent 850515a commit 69ac85f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/catalog-search/src/LearningTypeRadioFacet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand All @@ -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 (
Expand Down

0 comments on commit 69ac85f

Please sign in to comment.