Skip to content

Commit

Permalink
feat: productize course review experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
zamanafzal committed Jul 25, 2023
1 parent 5d50e9d commit e936725
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 36 deletions.
33 changes: 2 additions & 31 deletions src/components/course/course-header/CourseHeader.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext, useEffect, useMemo } from 'react';
import React, { useContext, useMemo } from 'react';
import classNames from 'classnames';
import {
Breadcrumb,
Expand All @@ -8,8 +8,6 @@ import {
} from '@edx/paragon';
import { Link } from 'react-router-dom';
import { AppContext } from '@edx/frontend-platform/react';
import { getConfig } from '@edx/frontend-platform/config';
import { sendEnterpriseTrackEvent } from '@edx/frontend-enterprise-utils';

import { CourseContext } from '../CourseContextProvider';
import CourseSkills from '../CourseSkills';
Expand All @@ -25,7 +23,6 @@ import LicenseRequestedAlert from '../LicenseRequestedAlert';
import SubsidyRequestButton from '../SubsidyRequestButton';
import CourseReview from '../CourseReview';

import { isExperimentVariant } from '../../../utils/optimizely';
import CoursePreview from './CoursePreview';

const CourseHeader = () => {
Expand All @@ -34,7 +31,6 @@ const CourseHeader = () => {
state: {
course,
catalog,
courseReviews,
},
isPolicyRedemptionEnabled,
} = useContext(CourseContext);
Expand All @@ -44,31 +40,6 @@ const CourseHeader = () => {
() => getDefaultProgram(course.programs),
[course],
);
const config = getConfig();
const isExperimentVariationA = isExperimentVariant(
config.EXPERIMENT_5_ID,
config.EXPERIMENT_5_VARIANT_1_ID,
);
const hasSufficientReviewCount = courseReviews?.reviewsCount >= 5;
useEffect(() => {
if (hasSufficientReviewCount && isExperimentVariationA) {
sendEnterpriseTrackEvent(
enterpriseConfig.uuid,
'edx.ui.enterprise.learner_portal.course.viewedWithReviewsVariation',
{
course_key: course.key,
},
);
} else {
sendEnterpriseTrackEvent(
enterpriseConfig.uuid,
'edx.ui.enterprise.learner_portal.course.viewedWithoutReviewsVariation',
{
course_key: course.key,
},
);
}
}, [hasSufficientReviewCount, isExperimentVariationA, enterpriseConfig.uuid, course.key]);

return (
<div className="course-header">
Expand Down Expand Up @@ -137,7 +108,7 @@ const CourseHeader = () => {
<Col xs={12} lg={12}>
{catalog.containsContentItems ? (
<>
{hasSufficientReviewCount && isExperimentVariationA && <CourseReview />}
<CourseReview />
{defaultProgram && (
<p className="font-weight-bold mt-3 mb-0">
This course is part of a {formatProgramType(defaultProgram.type)}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import CourseHeader from '../CourseHeader';
import { COURSE_PACING_MAP } from '../../data/constants';
import { TEST_OWNER } from '../../tests/data/constants';
import { CourseEnrollmentsContext } from '../../../dashboard/main-content/course-enrollments/CourseEnrollmentsContextProvider';
import * as optimizelyUtils from '../../../../utils/optimizely';

jest.mock('react-router-dom', () => ({
useLocation: jest.fn(),
Expand Down Expand Up @@ -162,7 +161,6 @@ describe('<CourseHeader />', () => {
});

test('renders course reviews section', () => {
jest.spyOn(optimizelyUtils, 'isExperimentVariant').mockImplementation(() => true);
render(
<CourseHeaderWrapper
initialAppState={initialAppState}
Expand All @@ -177,7 +175,6 @@ describe('<CourseHeader />', () => {
});

test('renders course reviews section and change the review information content', () => {
jest.spyOn(optimizelyUtils, 'isExperimentVariant').mockImplementation(() => true);
render(
<CourseHeaderWrapper
initialAppState={initialAppState}
Expand Down
2 changes: 0 additions & 2 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ initialize({
GETSMARTER_PRIVACY_POLICY_URL: process.env.GETSMARTER_PRIVACY_POLICY_URL || null,
GETSMARTER_LEARNER_DASHBOARD_URL: process.env.GETSMARTER_LEARNER_DASHBOARD_URL || null,
FEATURE_CONTENT_HIGHLIGHTS: process.env.FEATURE_CONTENT_HIGHLIGHTS || null,
EXPERIMENT_5_ID: process.env.EXPERIMENT_5_ID || null,
EXPERIMENT_5_VARIANT_1_ID: process.env.EXPERIMENT_5_VARIANT_1_ID || null,
FEATURE_ENABLE_EMET_REDEMPTION: process.env.FEATURE_ENABLE_EMET_REDEMPTION || null,
ENTERPRISE_SUBSIDY_BASE_URL: process.env.ENTERPRISE_SUBSIDY_BASE_URL || null,
});
Expand Down

0 comments on commit e936725

Please sign in to comment.