def note_added(view, submission):
    event_name = 'app_note_added'
    log_to_mixpanel.delay(
        distinct_id=submission.get_uuid(),
        event_name=event_name,
        **mixpanel_applicant_data(submission.applicant),
        **mixpanel_data_from_view_request_user(view))
def user_status_updated(view, status_update):
    event_name = 'user_status_updated'
    event_kwargs = dict(
        distinct_id=status_update.author.profile.get_uuid(),
        event_name=event_name,
        applicant_uuid=status_update.application.form_submission.get_uuid(),
        application_id=status_update.application.id,
        status_type=status_update.status_type.display_name,
        next_steps=[
            step.display_name for step in status_update.next_steps.all()],
        additional_info_length=len(status_update.additional_information),
        other_next_steps_length=len(status_update.other_next_step),
        message_change_ratio=SNService.get_message_change_ratio(status_update),
        contact_info_keys=SNService.get_contact_info_keys(status_update),
        has_unsent_additional_info=SNService.has_unsent_additional_info(
            status_update),
        has_unsent_other_next_step=SNService.has_unsent_other_next_step(
            status_update),
        **mixpanel_applicant_data(
            status_update.application.form_submission.applicant),
        **mixpanel_data_from_view_request_user(view))
    if hasattr(status_update, 'notification'):
        event_kwargs.update(
            notification_contact_info_types=list(
                status_update.notification.contact_info.keys()))
    log_to_mixpanel.delay(**event_kwargs)
def tags_added(tag_links):
    event_name = 'app_tag_added'
    for tag_link in tag_links:
        log_to_mixpanel.delay(distinct_id=tag_link.content_object.get_uuid(),
                              event_name=event_name,
                              tag_name=tag_link.tag.name,
                              author_email=tag_link.user.email)
def user_reset_password(view, email):
    event_name = 'user_reset_password'
    log_to_mixpanel.delay(
        distinct_id=view.request.visitor.get_uuid(),
        event_name=event_name,
        email=email,
        **mixpanel_data_from_view_request_user(view))
def site_entered(visitor, url):
    event_name = 'site_entered'
    log_to_mixpanel.delay(distinct_id=visitor.get_uuid(),
                          event_name=event_name,
                          url=url,
                          referrer=visitor.referrer,
                          source=visitor.source)
def user_failed_login(view):
    event_name = 'user_failed_login'
    log_to_mixpanel.delay(
        distinct_id=view.request.visitor.get_uuid(),
        event_name=event_name,
        attempted_login=view.request.POST.get('login', ''),
        **mixpanel_data_from_view_request_user(view))
def user_account_created(view):
    # this doesn't appear to be used
    event_name = 'user_account_created'
    log_to_mixpanel.delay(
        distinct_id=view.user.profile.get_uuid(),
        event_name=event_name,
        **mixpanel_data_from_view_request_user(view))
def form_submitted(submission):
    event_name = 'application_submitted'
    log_to_mixpanel.delay(distinct_id=submission.get_uuid(),
                          event_name=event_name,
                          organizations=list(
                              submission.organizations.values_list('name',
                                                                   flat=True)))
def confirmation_sent(submission, contact_methods):
    event_name = 'app_confirmation_sent'
    log_to_mixpanel.delay(
        distinct_id=submission.get_uuid(),
        event_name=event_name,
        contact_info_types=contact_methods,
        **mixpanel_applicant_data(submission.applicant))
Exemple #10
0
def status_updated(status_update):
    event_name = 'app_status_updated'
    event_kwargs = dict(
        distinct_id=status_update.application.form_submission.get_uuid(),
        event_name=event_name,
        user_email=status_update.author.email,
        application_id=status_update.application.id,
        status_type=status_update.status_type.display_name,
        next_steps=[
            step.display_name for step in status_update.next_steps.all()],
        additional_info_length=len(status_update.additional_information),
        other_next_steps_length=len(status_update.other_next_step),
        organization_name=status_update.author.profile.organization.name,
        message_change_ratio=SNService.get_message_change_ratio(status_update),
        contact_info_keys=SNService.get_contact_info_keys(status_update),
        has_unsent_additional_info=SNService.has_unsent_additional_info(
            status_update),
        has_unsent_other_next_step=SNService.has_unsent_other_next_step(
            status_update),
        )
    if hasattr(status_update, 'notification'):
        event_kwargs.update(
            notification_contact_info_types=list(
                status_update.notification.contact_info.keys()))
    log_to_mixpanel.delay(**event_kwargs)
def user_email_link_clicked(view):
    event_name = 'user_email_link_clicked'
    log_to_mixpanel.delay(
        distinct_id=view.request.user.profile.get_uuid(),
        event_name=event_name,
        target_url=view.get_redirect_url(),
        **mixpanel_data_from_view_request_user(view))
Exemple #12
0
def tags_added(tag_links):
    event_name = 'app_tag_added'
    for tag_link in tag_links:
        log_to_mixpanel.delay(
            distinct_id=tag_link.content_object.get_uuid(),
            event_name=event_name,
            tag_name=tag_link.tag.name,
            author_email=tag_link.user.email)
Exemple #13
0
def site_entered(visitor, url):
    event_name = 'site_entered'
    log_to_mixpanel.delay(
        distinct_id=visitor.get_uuid(),
        event_name=event_name,
        url=url,
        referrer=visitor.referrer,
        source=visitor.source)
Exemple #14
0
def form_submitted(submission):
    event_name = 'application_submitted'
    log_to_mixpanel.delay(
        distinct_id=submission.get_uuid(),
        event_name=event_name,
        organizations=list(
            submission.organizations.values_list('name', flat=True))
        )
def tags_added(tag_links):
    event_name = 'app_tag_added'
    for tag_link in tag_links:
        log_to_mixpanel.delay(
            distinct_id=tag_link.content_object.get_uuid(),
            event_name=event_name,
            tag_name=tag_link.tag.name,
            **mixpanel_applicant_data(tag_link.content_object.applicant),
            **mixpanel_user_data(tag_link.user))
Exemple #16
0
def page_viewed(request, response):
    event_name = 'page_viewed'
    data = dict(distinct_id=request.visitor.get_uuid(),
                event_name=event_name,
                http_status_code=response.status_code,
                **mixpanel_request_data(request))
    if response.view:
        data.update(mixpanel_view_data(response.view))
    log_to_mixpanel.delay(**data)
Exemple #17
0
def form_started(view, counties):
    event_name = 'application_started'
    applicant = ApplicantsService.get_applicant_from_request_or_session(
        view.request)
    log_to_mixpanel.delay(distinct_id=applicant.get_uuid(),
                          event_name=event_name,
                          counties=counties,
                          **mixpanel_applicant_data(applicant),
                          **mixpanel_data_from_view_request_user(view))
Exemple #18
0
def user_page_viewed(request, response):
    event_name = 'user_page_viewed'
    data = dict(distinct_id=request.visitor.get_uuid(),
                event_name=event_name,
                **mixpanel_request_data(request),
                **mixpanel_user_data(request.user))
    if response.view:
        data.update(mixpanel_view_data(response.view))
    log_to_mixpanel.delay(**data)
def form_submitted(view, submission):
    event_name = 'application_submitted'
    log_to_mixpanel.delay(
        distinct_id=submission.get_uuid(),
        event_name=event_name,
        organizations=list(
            submission.organizations.values_list('name', flat=True)),
        **mixpanel_applicant_data(submission.applicant),
        **mixpanel_data_from_view_request_user(view))
Exemple #20
0
def form_page_complete(view):
    """page_name should be the class name of the view instance.
    """
    event_name = 'application_page_complete'
    applicant = ApplicantsService.get_applicant_from_request_or_session(
        view.request)
    log_to_mixpanel.delay(distinct_id=applicant.get_uuid(),
                          event_name=event_name,
                          **mixpanel_applicant_data(applicant),
                          **mixpanel_data_from_view_request_user(view))
Exemple #21
0
def form_page_complete(request, page_name):
    """page_name should be the class name of the view instance.
    """
    event_name = 'application_page_complete'
    applicant = ApplicantsService.get_applicant_from_request_or_session(
        request)
    log_to_mixpanel.delay(distinct_id=applicant.get_uuid(),
                          event_name=event_name,
                          url=request.path,
                          page_name=page_name)
Exemple #22
0
def bundle_opened(bundle, user):
    event_name = 'app_bundle_opened'
    for submission in bundle.submissions.all():
        log_to_mixpanel.delay(
            distinct_id=submission.get_uuid(),
            event_name=event_name,
            bundle_id=bundle.id,
            bundle_organization_name=bundle.organization.name,
            user_email=user.email,
            user_organization_name=user.profile.organization.name)
Exemple #23
0
def app_transferred(old_application, new_application, user):
    event_name = 'app_transferred'
    log_to_mixpanel.delay(
        distinct_id=old_application.form_submission.get_uuid(),
        event_name=event_name,
        user_email=user.email,
        from_application_id=old_application.id,
        to_application_id=new_application.id,
        from_organization_name=old_application.organization.name,
        to_organization_name=new_application.organization.name)
Exemple #24
0
def form_started(request, counties):
    event_name = 'application_started'
    applicant = ApplicantsService.get_applicant_from_request_or_session(
        request)
    log_to_mixpanel.delay(distinct_id=applicant.get_uuid(),
                          event_name=event_name,
                          counties=counties,
                          referrer=applicant.visitor.referrer,
                          source=applicant.visitor.source,
                          user_agent=request.META.get('HTTP_USER_AGENT'))
Exemple #25
0
def app_transferred(old_application, new_application, user):
    event_name = 'app_transferred'
    log_to_mixpanel.delay(
        distinct_id=old_application.form_submission.get_uuid(),
        event_name=event_name,
        user_email=user.email,
        from_application_id=old_application.id,
        to_application_id=new_application.id,
        from_organization_name=old_application.organization.name,
        to_organization_name=new_application.organization.name)
Exemple #26
0
 def send_filtered_data_to_mixpanel(self):
     filtered_data = {}
     for key, value in self.data.items():
         if key in PII_FILTERS:
             filtered_data[key] = PII_FILTERS[key](value)
         else:
             if key not in PII_EXCLUSIONS:
                 filtered_data[key] = value
     log_to_mixpanel.delay(
         self.applicant_id, self.name, filtered_data)
Exemple #27
0
def apps_opened(applications, user):
    event_name = 'app_opened'
    for application in applications:
        log_to_mixpanel.delay(
            distinct_id=application.form_submission.get_uuid(),
            event_name=event_name,
            application_id=application.id,
            application_organization_name=application.organization.name,
            user_email=user.email,
            user_organization_name=user.profile.organization.name)
Exemple #28
0
def bundle_opened(bundle, user):
    event_name = 'app_bundle_opened'
    for submission in bundle.submissions.all():
        log_to_mixpanel.delay(
            distinct_id=submission.get_uuid(),
            event_name=event_name,
            bundle_id=bundle.id,
            bundle_organization_name=bundle.organization.name,
            user_email=user.email,
            user_organization_name=user.profile.organization.name)
Exemple #29
0
def apps_opened(applications, user):
    event_name = 'app_opened'
    for application in applications:
        log_to_mixpanel.delay(
            distinct_id=application.form_submission.get_uuid(),
            event_name=event_name,
            application_id=application.id,
            application_organization_name=application.organization.name,
            user_email=user.email,
            user_organization_name=user.profile.organization.name)
def user_app_transferred(old_application, new_application, user):
    event_name = 'user_app_transferred'
    log_to_mixpanel.delay(
        distinct_id=user.profile.get_uuid(),
        event_name=event_name,
        applicant_uuid=old_application.form_submission.get_uuid(),
        from_org=old_application.organization.name,
        to_org=new_application.organization.name,
        **mixpanel_applicant_data(old_application.form_submission.applicant),
        **mixpanel_user_data(user))
def apps_opened(view, applications):
    event_name = 'app_opened'
    for application in applications:
        log_to_mixpanel.delay(
            distinct_id=application.form_submission.get_uuid(),
            event_name=event_name,
            application_id=application.id,
            application_organization_name=application.organization.name,
            **mixpanel_applicant_data(application.form_submission.applicant),
            **mixpanel_data_from_view_request_user(view))
Exemple #32
0
def form_page_complete(request, page_name):
    """page_name should be the class name of the view instance.
    """
    event_name = 'application_page_complete'
    applicant = ApplicantsService.get_applicant_from_request_or_session(
        request)
    log_to_mixpanel.delay(
        distinct_id=applicant.get_uuid(),
        event_name=event_name,
        url=request.path,
        page_name=page_name)
Exemple #33
0
def form_started(request, counties):
    event_name = 'application_started'
    applicant = ApplicantsService.get_applicant_from_request_or_session(
        request)
    log_to_mixpanel.delay(
        distinct_id=applicant.get_uuid(),
        event_name=event_name,
        counties=counties,
        referrer=applicant.visitor.referrer,
        source=applicant.visitor.source,
        user_agent=request.META.get('HTTP_USER_AGENT'))
Exemple #34
0
def unread_pdf_opened(request, view):
    # not currently used
    applicant_event_name = 'app_unread_pdf_opened'
    user_event_name = 'user_unread_pdf_opened'
    log_to_mixpanel.delay(distinct_id=request.user.get_uuid(),
                          event_name=user_event_name,
                          organization_name=view.organization.name)
    for app in view.applications:
        log_to_mixpanel.delay(
            distinct_id=app.get_uuid(),
            event_name=applicant_event_name,
            bundle_organization_name=app.organization.name,
            user_email=request.user.email,
            user_organization_name=request.user.profile.organization.name)
def form_validation_failed(view, errors):
    """
    security concerns addressed here:
    MP gets just keys (avoid PII)
    std_out gets k-v pair for errors, but misses application identifiers
    """
    event_name = 'application_errors'
    applicant = ApplicantsService.get_applicant_from_request_or_session(
        view.request)
    for error_key, errors in errors.items():
        log_to_mixpanel.delay(
            distinct_id=applicant.get_uuid(),
            event_name=event_name,
            error=error_key,
            **mixpanel_applicant_data(applicant),
            **mixpanel_data_from_view_request_user(view))
        LoggingService.format_and_log(
            event_name, url=view.request.path,
            view_name=view.__class__.__name__, field=error_key, errors=errors)
Exemple #36
0
def form_validation_failed(view, request, errors):
    """
    security concerns addressed here:
    MP gets just keys (avoid PII)
    std_out gets k-v pair for errors, but misses application identifiers
    """
    event_name = 'application_errors'
    applicant = ApplicantsService.get_applicant_from_request_or_session(
        request)
    for error_key, errors in errors.items():
        log_to_mixpanel.delay(
            distinct_id=applicant.get_uuid(),
            event_name=event_name,
            url=request.path,
            view_name=view.__class__.__name__,
            error=error_key)
        LoggingService.format_and_log(
            event_name, url=request.path, view_name=view.__class__.__name__,
            field=error_key, errors=errors)
def site_entered(visitor, request):
    event_name = 'site_entered'
    log_to_mixpanel.delay(
        distinct_id=visitor.get_uuid(),
        event_name=event_name,
        **mixpanel_request_data(request))
Exemple #38
0
def note_added(submission, user):
    event_name = 'app_note_added'
    log_to_mixpanel.delay(
        distinct_id=submission.get_uuid(),
        event_name=event_name,
        author_email=user.email)
def user_apps_searched(view):
    event_name = 'user_apps_searched'
    log_to_mixpanel.delay(
        distinct_id=view.request.user.profile.get_uuid(),
        event_name=event_name,
        **mixpanel_data_from_view_request_user(view))
Exemple #40
0
def confirmation_sent(submission, contact_methods):
    event_name = 'app_confirmation_sent'
    log_to_mixpanel.delay(
        distinct_id=submission.get_uuid(),
        event_name=event_name,
        contact_info_types=contact_methods)
Exemple #41
0
def partnership_interest_submitted(partnership_lead):
    event_name = 'partnership_interest_submitted'
    log_to_mixpanel.delay(
        distinct_id=partnership_lead.visitor.get_uuid(),
        event_name=event_name)
def empty_print_all_opened(request, view):
    # not currently used
    event_name = 'user_empty_print_all_opened'
    log_to_mixpanel.delay(
        distinct_id=request.user.get_uuid(),
        event_name=event_name)
def partnership_interest_submitted(view, partnership_lead):
    event_name = 'partnership_interest_submitted'
    log_to_mixpanel.delay(
        distinct_id=partnership_lead.visitor.get_uuid(),
        event_name=event_name,
        **mixpanel_data_from_view_request_user(view))