Skip to content

Commit

Permalink
add source tags to users created via email
Browse files Browse the repository at this point in the history
  • Loading branch information
John Tordoff committed Aug 8, 2024
1 parent 47dcbe1 commit 1fec032
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion osf/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
from website import settings as website_settings
from website import filters, mails
from website.project import new_bookmark_collection
from website.util.metrics import OsfSourceTags
from website.util.metrics import OsfSourceTags, unregistered_created_source_tag
from importlib import import_module
from osf.utils.requests import get_headers_from_request

Expand Down Expand Up @@ -1215,6 +1215,7 @@ def create_unregistered(cls, fullname, email=None):
user.set_unusable_username()
user.set_unusable_password()
user.update_guessed_names()
user.add_system_tag(unregistered_created_source_tag(email))

return user

Expand Down
1 change: 1 addition & 0 deletions osf_tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def test_create_unregistered(self):
assert not u.emails.filter(address=email).exists()
parsed = impute_names_model(name)
assert u.given_name == parsed['given_name']
assert f'source:unregistered_created|{email}' in u.system_tags

@mock.patch('osf.models.user.OSFUser.update_search')
def test_search_not_updated_for_unreg_users(self, update_search):
Expand Down
4 changes: 4 additions & 0 deletions website/util/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def campaign_source_tag(campaign_name):
return f'source:campaign|{campaign_name}'


def unregistered_created_source_tag(creator_email):
return f'source:unregistered_created|{creator_email}'


def institution_source_tag(institution_id):
return f'source:institution|{institution_id}'

Expand Down

0 comments on commit 1fec032

Please sign in to comment.