Skip to content

Commit

Permalink
Merge pull request dimagi#14651 from dimagi/ce/atypical-users
Browse files Browse the repository at this point in the history
adding url param to mark atypical users
  • Loading branch information
calellowitz authored Jan 27, 2017
2 parents e4de521 + aaa018e commit 2b3bc28
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions corehq/apps/analytics/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ def track_user_sign_in_on_hubspot(webuser, cookies, meta, path):
tracking_dict.update({
'phone': webuser.phone_numbers[0],
})
if webuser.atypical_user:
tracking_dict.update({
'atypical_user': True
})
tracking_dict.update(get_ab_test_properties(webuser))
_track_on_hubspot(webuser, tracking_dict)
_send_form_to_hubspot(HUBSPOT_SIGNUP_FORM_ID, webuser, cookies, meta)
Expand Down
2 changes: 2 additions & 0 deletions corehq/apps/registration/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class RegisterWebUserForm(forms.Form):
href='#eulaModal'>
CommCare HQ End User License Agreement</a>.""")))
xform = forms.CharField(required=False, widget=forms.HiddenInput())
atypical_user = forms.BooleanField(required=False, widget=forms.HiddenInput())

def __init__(self, *args, **kwargs):
self.show_phone_number = kwargs.pop('show_number', False)
Expand Down Expand Up @@ -114,6 +115,7 @@ def __init__(self, *args, **kwargs):
hqcrispy.ValidationMessage('passwordDelayed'),
crispy.Div(*phone_number_fields),
hqcrispy.InlineField('xform'),
hqcrispy.InlineField('atypical_user'),
twbscrispy.StrictButton(
ugettext("Next"),
css_class="btn btn-success btn-lg",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ hqDefine('registration/js/new_user.ko.js', function () {
eula_confirmed: self.eulaConfirmed(),
phone_number: _private.getPhoneNumberFn() || self.phoneNumber(),
xform: defaults.xform,
atypical_user: defaults.atypical_user
};
};

Expand Down
1 change: 1 addition & 0 deletions corehq/apps/registration/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def activate_new_user(form, is_domain_admin=True, domain=None, ip=None):
new_user.last_login = now
new_user.date_joined = now
new_user.last_password_set = now
new_user.atypical_user = form.cleaned_data.get('atypical_user', False)
new_user.save()

return new_user
Expand Down
7 changes: 6 additions & 1 deletion corehq/apps/registration/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ def prefilled_email(self):
def prefilled_xform(self):
return self.request.POST.get('xform', '')

@property
def atypical_user(self):
return self.request.GET.get('internal', False)

@property
@memoized
def ab(self):
Expand All @@ -176,11 +180,12 @@ def page_context(self):
prefills = {
'email': self.prefilled_email,
'xform': self.prefilled_xform,
'atypical_user': True if self.atypical_user else False
}
return {
'reg_form': RegisterWebUserForm(
initial=prefills,
show_number=(self.ab.version == ab_tests.NEW_USER_NUMBER_OPTION_SHOW_NUM)
show_number=(self.ab.version == ab_tests.NEW_USER_NUMBER_OPTION_SHOW_NUM),
),
'reg_form_defaults': prefills,
'hide_password_feedback': settings.ENABLE_DRACONIAN_SECURITY_FEATURES,
Expand Down
4 changes: 4 additions & 0 deletions corehq/apps/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2022,6 +2022,10 @@ class WebUser(CouchUser, MultiMembershipMixin, CommCareMobileContactMixin):
login_attempts = IntegerProperty(default=0)
attempt_date = DateProperty()
fcm_device_token = StringProperty()
# this property is used to mark users who signed up from internal invitations
# such as those going through the recruiting pipeline
# to better mark them in our analytics
atypical_user = BooleanProperty(default=False)

def sync_from_old_couch_user(self, old_couch_user):
super(WebUser, self).sync_from_old_couch_user(old_couch_user)
Expand Down

0 comments on commit 2b3bc28

Please sign in to comment.