Merge pull request #22006 from edx/bderusha/remove-mailchimp
remove mailchimp tracking
This commit is contained in:
@@ -773,34 +773,9 @@ class Registration(models.Model):
|
||||
|
||||
def activate(self):
|
||||
self.user.is_active = True
|
||||
self._track_activation()
|
||||
self.user.save(update_fields=['is_active'])
|
||||
log.info(u'User %s (%s) account is successfully activated.', self.user.username, self.user.email)
|
||||
|
||||
def _track_activation(self):
|
||||
"""
|
||||
Update the isActive flag in mailchimp for activated users.
|
||||
"""
|
||||
has_segment_key = getattr(settings, 'LMS_SEGMENT_KEY', None)
|
||||
has_mailchimp_id = hasattr(settings, 'MAILCHIMP_NEW_USER_LIST_ID')
|
||||
if has_segment_key and has_mailchimp_id:
|
||||
# .. pii: Username and email are sent to Segment here. Retired directly through Segment API call in Tubular.
|
||||
# .. pii_types: email_address, username
|
||||
# .. pii_retirement: third_party
|
||||
segment.identify(
|
||||
self.user.id, # pylint: disable=no-member
|
||||
{
|
||||
'email': self.user.email,
|
||||
'username': self.user.username,
|
||||
'activated': 1,
|
||||
},
|
||||
{
|
||||
"MailChimp": {
|
||||
"listId": settings.MAILCHIMP_NEW_USER_LIST_ID
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class PendingNameChange(DeletableByUserValue, models.Model):
|
||||
"""
|
||||
|
||||
@@ -70,49 +70,6 @@ class TestActivateAccount(TestCase):
|
||||
self.assertTrue(self.user.is_active)
|
||||
self.assertFalse(mock_segment_identify.called)
|
||||
|
||||
@override_settings(
|
||||
LMS_SEGMENT_KEY="testkey",
|
||||
MAILCHIMP_NEW_USER_LIST_ID="listid"
|
||||
)
|
||||
@patch('student.models.segment.identify')
|
||||
def test_activation_with_keys(self, mock_segment_identify):
|
||||
expected_segment_payload = {
|
||||
'email': self.email,
|
||||
'username': self.username,
|
||||
'activated': 1,
|
||||
}
|
||||
expected_segment_mailchimp_list = {
|
||||
"MailChimp": {
|
||||
"listId": settings.MAILCHIMP_NEW_USER_LIST_ID
|
||||
}
|
||||
}
|
||||
|
||||
# Ensure that the user starts inactive
|
||||
self.assertFalse(self.user.is_active)
|
||||
|
||||
# Until you explicitly activate it
|
||||
self.registration.activate()
|
||||
self.assertTrue(self.user.is_active)
|
||||
mock_segment_identify.assert_called_with(
|
||||
self.user.id,
|
||||
expected_segment_payload,
|
||||
expected_segment_mailchimp_list
|
||||
)
|
||||
|
||||
@override_settings(LMS_SEGMENT_KEY="testkey")
|
||||
@patch('student.models.segment.identify')
|
||||
def test_activation_without_mailchimp_key(self, mock_segment_identify):
|
||||
self.assert_no_tracking(mock_segment_identify)
|
||||
|
||||
@override_settings(MAILCHIMP_NEW_USER_LIST_ID="listid")
|
||||
@patch('student.models.segment.identify')
|
||||
def test_activation_without_segment_key(self, mock_segment_identify):
|
||||
self.assert_no_tracking(mock_segment_identify)
|
||||
|
||||
@patch('student.models.segment.identify')
|
||||
def test_activation_without_keys(self, mock_segment_identify):
|
||||
self.assert_no_tracking(mock_segment_identify)
|
||||
|
||||
def test_account_activation_message(self):
|
||||
"""
|
||||
Verify that account correct activation message is displayed.
|
||||
|
||||
@@ -588,9 +588,6 @@ if 'DATADOG_API' in AUTH_TOKENS:
|
||||
ANALYTICS_API_KEY = AUTH_TOKENS.get("ANALYTICS_API_KEY", ANALYTICS_API_KEY)
|
||||
ANALYTICS_API_URL = ENV_TOKENS.get("ANALYTICS_API_URL", ANALYTICS_API_URL)
|
||||
|
||||
# Mailchimp New User List
|
||||
MAILCHIMP_NEW_USER_LIST_ID = ENV_TOKENS.get("MAILCHIMP_NEW_USER_LIST_ID")
|
||||
|
||||
# Zendesk
|
||||
ZENDESK_USER = AUTH_TOKENS.get("ZENDESK_USER")
|
||||
ZENDESK_API_KEY = AUTH_TOKENS.get("ZENDESK_API_KEY")
|
||||
|
||||
@@ -266,14 +266,6 @@ def _track_user_registration(user, profile, params, third_party_provider):
|
||||
'country': text_type(profile.country),
|
||||
}
|
||||
]
|
||||
# Provide additional context only if needed.
|
||||
if hasattr(settings, 'MAILCHIMP_NEW_USER_LIST_ID'):
|
||||
identity_args.append({
|
||||
"MailChimp": {
|
||||
"listId": settings.MAILCHIMP_NEW_USER_LIST_ID
|
||||
}
|
||||
})
|
||||
|
||||
# .. pii: Many pieces of PII are sent to Segment here. Retired directly through Segment API call in Tubular.
|
||||
# .. pii_types: email_address, username, name, birth_date, location, gender
|
||||
# .. pii_retirement: third_party
|
||||
|
||||
Reference in New Issue
Block a user