Skip to content

Commit

Permalink
fix: [VAN-1292] Remove personalized recommendation cookie (#31748)
Browse files Browse the repository at this point in the history
  • Loading branch information
attiyaIshaque authored Feb 17, 2023
1 parent dc7c74e commit bf36c42
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 51 deletions.
2 changes: 0 additions & 2 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2681,8 +2681,6 @@
# keys for big blue button live provider
COURSE_LIVE_GLOBAL_CREDENTIALS = {}

PERSONALIZED_RECOMMENDATION_COOKIE_NAME = 'edx-user-personalized-recommendation'

######################## Registration ########################

# Social-core setting that allows inactive users to be able to
Expand Down
6 changes: 0 additions & 6 deletions common/djangoapps/student/models/course_enrollment.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,12 +605,6 @@ def emit_event(self, event_name, enterprise_uuid=None):
segment_properties['course_start'] = self.course.start
segment_properties['course_pacing'] = self.course.pacing

from .user import is_course_recommended_on_user_dashboard
course_key = f'{self.course_id.org}+{self.course_id.course}'
is_recommended_course, control_group = is_course_recommended_on_user_dashboard(course_key)
if is_recommended_course:
segment_properties['dashboard_recommendations_group'] = control_group

with tracker.get_tracker().context(event_name, context):
tracker.emit(event_name, data)
segment.track(self.user_id, event_name, segment_properties, traits=segment_traits)
Expand Down
24 changes: 1 addition & 23 deletions common/djangoapps/student/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from datetime import datetime, timedelta # lint-amnesty, pylint: disable=wrong-import-order
from functools import total_ordering # lint-amnesty, pylint: disable=wrong-import-order
from importlib import import_module # lint-amnesty, pylint: disable=wrong-import-order
from urllib.parse import unquote, urlencode
from urllib.parse import urlencode

from .course_enrollment import (
ALLOWEDTOENROLL_TO_ENROLLED,
Expand Down Expand Up @@ -374,28 +374,6 @@ def get_potentially_retired_user_by_username_and_hash(username, hashed_username)
return User.objects.get(username__in=locally_hashed_usernames)


def is_course_recommended_on_user_dashboard(course_id):
"""
Tells whether the course was recommended on the user dashboard.
Return values:
Personalized recommendation: Returns whether the course was recommended on user dashboard
Control group: Returns the user segmentation group a user belonged in. This is useful when we
show different recommendations based on the group a user belongs in i.e general
vs personalized.
"""
request = crum.get_current_request()
recommended_courses = \
request.COOKIES.get(settings.PERSONALIZED_RECOMMENDATION_COOKIE_NAME, None) if request else None

if recommended_courses:
recommended_courses = json.loads(unquote(recommended_courses))
if course_id in recommended_courses['course_keys']:
return True, recommended_courses.get('is_control')

return False, None


class UserStanding(models.Model):
"""
This table contains a student's account's status.
Expand Down
2 changes: 0 additions & 2 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5205,8 +5205,6 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring
# keys for big blue button live provider
COURSE_LIVE_GLOBAL_CREDENTIALS = {}

PERSONALIZED_RECOMMENDATION_COOKIE_NAME = 'edx-user-personalized-recommendation'

# .. toggle_name: ENABLE_MFE_CONFIG_API
# .. toggle_implementation: DjangoSetting
# .. toggle_default: False
Expand Down
18 changes: 0 additions & 18 deletions lms/static/js/learner_dashboard/RecommendationsPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class RecommendationsPanel extends React.Component {
constructor(props) {
super(props);
this.domainInfo = { domain: props.sharedCookieDomain, expires: 365, path: '/' };
this.cookieName = props.cookieName;
this.onCourseSelect = this.onCourseSelect.bind(this);
this.getCourseList = this.getCourseList.bind(this);
this.state = {
Expand All @@ -23,23 +22,6 @@ class RecommendationsPanel extends React.Component {
page: 'dashboard',
});

let recommendedCourses = Cookies.get(this.cookieName);
if (typeof recommendedCourses === 'undefined') {
recommendedCourses = { course_keys: [courseKey] };
} else {
recommendedCourses = JSON.parse(recommendedCourses);
if (!recommendedCourses.course_keys.includes(courseKey)) {
if (recommendedCourses.course_keys.length < 5) {
recommendedCourses.course_keys.push(courseKey);
} else {
recommendedCourses.course_keys.shift();
recommendedCourses.course_keys.push(courseKey);
}
}
}
recommendedCourses['is_personalized_recommendation'] = this.state.isControl;
recommendedCourses['is_control'] = this.state.isControl;
Cookies.set(this.cookieName, JSON.stringify(recommendedCourses), this.domainInfo);
window.location.href = marketingUrl;
};

Expand Down

0 comments on commit bf36c42

Please sign in to comment.