Skip to content

Instantly share code, notes, and snippets.

@ilyakatz
Created March 1, 2012 21:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilyakatz/1953445 to your computer and use it in GitHub Desktop.
Save ilyakatz/1953445 to your computer and use it in GitHub Desktop.
Mouseflow session support with Rails
require 'net/http'
require 'uri'
class Admin::MouseflowController < ApplicationController
#these are optional if you using authentication and ssl
skip_before_filter :authenticate_login!
def ssl_required?
false
end
def ssl_allowed?
true
end
########################################################
def create
render :text=> mouseflow(params.slice('website', 'session', 'page', 'encoding', 'html', 'ajax', 'sequence', 'test'))
end
def index
render :text=> mouseflow(params.slice('test'))
end
protected
def mouseflow(post_args)
if post_args['test'] == '1'
post_args = {'website' => 'test'}
end
protocol = request.ssl? ? "https" : "http"
resp = Net::HTTP.post_form(URI.parse("#{protocol}://c.mouseflow.com/b.gif"), post_args)
resp.body
end
end
# Add this to your config/routes.rb file
#namespace :admin do
# resources :mouseflow, :only=>[:create, :index]
#end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment