def user_track(request):
 try:
  username = request.user.username
 except:
  username = 'anonymous'
 name = _get_request_value(request, 'event_type')
 data = _get_request_value(request, 'event', {})
 page = _get_request_value(request, 'page')
 if (isinstance(data, basestring) and (len(data) > 0)):
  try:
   data = json.loads(data)
  except ValueError:
   pass
 context_override = contexts.course_context_from_url(page)
 context_override['username'] = username
 context_override['event_source'] = 'browser'
 context_override['page'] = page
 with eventtracker.get_tracker().context('edx.course.browser', context_override):
  eventtracker.emit(name=name, data=data)
 return HttpResponse('success')

def user_track ( request ) : try : username = request . user . username except : username = 'anonymous' name = _get_request_value ( request , 'event_type' ) data = _get_request_value ( request , 'event' , { } ) page = _get_request_value ( request , 'page' ) if ( isinstance ( data , basestring ) and ( len ( data ) > 0 ) ) : try : data = json . loads ( data ) except ValueError : pass context_override = contexts . course_context_from_url ( page ) context_override [ 'username' ] = username context_override [ 'event_source' ] = 'browser' context_override [ 'page' ] = page with eventtracker . get_tracker ( ) . context ( 'edx.course.browser' , context_override ) : eventtracker . emit ( name = name , data = data ) return HttpResponse ( 'success' )
log when post call to "event" url is made by a user .