@csrf_exempt
@never_cache
@transaction.atomic
def client_stats(request, group, _now=None):
    """
    Save stats about a client.

    Args:
        request: Django request object.
        group: Group to save stats about.
        _now: A datetime.datetime object to pretend is "now". Used for testing
              only.

    Returns:
        Django response object.
    """
    response, group, user = client_common(request, group)
    if response is not None:
        return response

    try:
        data = json.loads(request.POST.get('data', "{}"))
    except __HOLE__, e:
        response = http.HttpResponse(content_type='application/javascript')
        response.write(json.dumps({
            'code': error.ERROR_JSON,
            'error': 'Invalid JSON: %s' % e,
            'next': -1,
            }))
        return response

    data['user-agent'] = request.META['HTTP_USER_AGENT']
    data['ip'] = request.META[settings.HTTP_REMOTE_ADDR_META]
    if 'HTTP_REFERER' in request.META:
        data['referrer'] = request.META['HTTP_REFERER']

    # Save the stats
    s = models.ClientStats(
        group=group,
        created_by=user)
    if _now is not None:
        s.created_on = _now
    s.save()
    s.from_dict(data)

    # Return success
    response = http.HttpResponse(content_type='application/javascript')
    response.write(json.dumps({
        'code': error.SUCCESS,
        'next': 5,
        }))
    return response

###########################################################################################
# Code which collects the endpoint system reporting.
###########################################################################################
dataset/ETHPy150Open timvideos/streaming-system/website/tracker/views.py/client_stats