def METHOD_NAME(data):
    """
    If data contains a username, adds the corresponding user_id to the data.
    In certain use cases, the caller may have the username and not the
    user_id. This enables us to standardize on user_id in event data,
    even when the caller only has access to the username.
    """
    if data and ('username' in data) and ('user_id' not in data):
        try:
            user = User.objects.get(username=data.get('username'))
            data['user_id'] = user.id
        except User.DoesNotExist:
            pass