Sha256: 831c971e563d3215261d93817c74d08e3a87ba2d1fc4c685b5ba6b932b9ee834

Contents?: true

Size: 942 Bytes

Versions: 3

Compression:

Stored size: 942 Bytes

Contents

require 'json'
require 'keen'

# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
  helper :all # include all helpers, all the time
  protect_from_forgery # See ActionController::RequestForgeryProtection for details
  before_filter :track_pageview


  # Runs before every request:
  def track_pageview

    # Get these from the keen.io website:
    project_id = "4f5775ad163d666a6100000e"
    auth_token = "a5d4eaf432914823a94ecd7e0cb547b9"

    # First you must setup the client:
    keen = Keen::Client.new(project_id, auth_token, :storage_mode => :redis)

    # Log the event with Keen:
    keen.add_event("pageviews", {
      :params   => params,
      :url      => request.url,
    })

  end

  # Scrub sensitive parameters from your log
  # filter_parameter_logging :password
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
keen-0.1.0 examples/rails_2/CoolForums/app/controllers/application_controller.rb
keen-0.0.53 examples/rails_2/CoolForums/app/controllers/application_controller.rb
keen-0.0.52 examples/rails_2/CoolForums/app/controllers/application_controller.rb