def log_event
      if params[:category].present? && params[:event_action].present? && params[:label].present?
        # if an action isn't passed in, assume that it is a click
        action = params.fetch(:action_type, 'click')

        # create a new event on the current session
        @session.events.create(category: params[:category], item: params[:event_action], query: params[:label][0..250], action: action)

        if params[:ga].present? and params[:ga]
          send_event_to_ga(params[:category], params[:event_action], params[:label])
        end

        # check whether this is a jsonp request
        if params[:callback].present?
          render :json => { 'response': 'success' }, :callback => params[:callback]
        else
          render :json => { 'response': 'success' }
        end
      else
        head :bad_request
      end
    end
def log_event
      if params[:category].present? && params[:event_action].present? && params[:label].present?
        # if an action isn't passed in, assume that it is a click
        action = params.fetch(:action_type, 'click')

        # create a new event on the current session
        @session.events.create(category: params[:category], item: params[:event_action], query: params[:label][0..250], action: action)

        if params[:ga].present? and params[:ga]
          send_event_to_ga(params[:category], params[:event_action], params[:label])
        end

        # check whether this is a jsonp request
        if params[:callback].present?
          render :json => { 'response': 'success' }, :callback => params[:callback]
        else
          render :json => { 'response': 'success' }
        end
      else
        head :bad_request
      end
    end
Logs an event to the database. Typically, these can be clicks or serves.

 This is an API endpoint for logging an event. It requires that at least a TODO are
 present in the query parameters. It returns a 200 OK HTTP status if the request was successful, or
 an 400 BAD REQUEST HTTP status if any parameters are missing. This endpoint supports JSONP requests.