add email to segment traits
This commit is contained in:
@@ -1495,6 +1495,10 @@ class CourseEnrollment(models.Model):
|
||||
segment_traits = dict(segment_properties)
|
||||
# Add course_title to the traits, as it is used by Hubspot filters
|
||||
segment_traits['course_title'] = self.course_overview.display_name if self.course_overview else None
|
||||
# Hubspot requires all incoming events have an email address to link it
|
||||
# to a Contact object.
|
||||
segment_traits['email'] = self.user.email
|
||||
|
||||
if event_name == EVENT_NAME_ENROLLMENT_ACTIVATED:
|
||||
segment_properties['email'] = self.user.email
|
||||
# This next property is for an experiment, see method's comments for more information
|
||||
|
||||
@@ -174,6 +174,7 @@ class EnrollmentTest(UrlResetMixin, SharedModuleStoreTestCase):
|
||||
traits = mock_segment.track.call_args[1]['traits']
|
||||
assert traits['course_title'] == self.course.display_name
|
||||
assert traits['mode'] == 'audit'
|
||||
assert traits['email'] == self.EMAIL
|
||||
|
||||
with patch('common.djangoapps.student.models.segment') as mock_segment:
|
||||
enrollment.update_enrollment(mode='verified')
|
||||
@@ -182,6 +183,7 @@ class EnrollmentTest(UrlResetMixin, SharedModuleStoreTestCase):
|
||||
traits = mock_segment.track.call_args[1]['traits']
|
||||
assert traits['course_title'] == self.course.display_name
|
||||
assert traits['mode'] == 'verified'
|
||||
assert traits['email'] == self.EMAIL
|
||||
|
||||
@patch.dict(settings.FEATURES, {'ENABLE_MKTG_EMAIL_OPT_IN': True})
|
||||
@patch('openedx.core.djangoapps.user_api.preferences.api.update_email_opt_in')
|
||||
|
||||
Reference in New Issue
Block a user