Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENT-9791] Add segment event to track the selected value for "Learning Type" dropdown #415

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions packages/catalog-search/src/LearningTypeRadioFacet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,25 @@ 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';
import { features } from './config';
import {
LEARNING_TYPE_COURSE, LEARNING_TYPE_PROGRAM, LEARNING_TYPE_PATHWAY, LEARNING_TYPE_VIDEO,
LEARNING_TYPE_COURSE,
LEARNING_TYPE_PROGRAM,
LEARNING_TYPE_PATHWAY,
LEARNING_TYPE_VIDEO,
LEARNING_TYPE_SELECTED_EVENT,
} 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 +36,12 @@ const LearningTypeRadioFacet = ({ enablePathways }) => {
} else {
dispatch(setRefinementAction('content_type', [type]));
}
if (trackingName) {
mahamakifdar19 marked this conversation as resolved.
Show resolved Hide resolved
const learningType = type || 'any';
sendTrackEvent(`${SEARCH_EVENT_NAME_PREFIX}.${trackingName}.${LEARNING_TYPE_SELECTED_EVENT}`, {
learningType,
});
}
};

return (
Expand Down
1 change: 1 addition & 0 deletions packages/catalog-search/src/data/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export const LEARNING_TYPE_PROGRAM = 'program';
export const LEARNING_TYPE_PATHWAY = 'learnerpathway';
export const LEARNING_TYPE_VIDEO = 'video';
export const LEARNING_TYPE_EXECUTIVE_EDUCATION = 'Executive Education';
export const LEARNING_TYPE_SELECTED_EVENT = 'catalog_search.learning_type_selected';

export const COURSE_TYPE_EXECUTIVE_EDUCATION = 'executive-education-2u';

Expand Down
Loading