Sha256: 47b2d268304f18607094baf4c20b98c9906ef2b0c447151802e40f932862fcb7

Contents?: true

Size: 917 Bytes

Versions: 2

Compression:

Stored size: 917 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)

    # 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

2 entries across 2 versions & 1 rubygems

Version Path
keen-0.0.5 examples/rails_2/CoolForums/app/controllers/application_controller.rb
keen-0.0.4 examples/rails_2/CoolForums/app/controllers/application_controller.rb