예제 #1
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(**data)
예제 #2
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(**data)
예제 #3
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(**data)
예제 #4
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(**data)
예제 #5
0
def mixpanel_data_from_view_request_user(view, request=None, user=None):
    """Extracts basic data from a view, request, and user for mixpanel.
    If request and user are not explicitly passed, this function will
    attempt to extract both from the view.
    """
    data = mixpanel_view_data(view)
    request = request or getattr(view, 'request', None)
    user = user or getattr(request, 'user', None)
    if request:
        data.update(mixpanel_request_data(view.request))
    if user and getattr(user, 'is_authenticated', False):
        data.update(mixpanel_user_data(user))
    return data
예제 #6
0
def mixpanel_data_from_view_request_user(view, request=None, user=None):
    """Extracts basic data from a view, request, and user for mixpanel.
    If request and user are not explicitly passed, this function will
    attempt to extract both from the view.
    """
    data = mixpanel_view_data(view)
    request = request or getattr(view, 'request', None)
    user = user or getattr(request, 'user', None)
    if request:
        data.update(mixpanel_request_data(view.request))
    if user and getattr(user, 'is_authenticated', False):
        data.update(mixpanel_user_data(user))
    return data