2014-01-25 23:48:17 +00:00
|
|
|
require 'bugsnag'
|
2012-08-31 02:09:02 +00:00
|
|
|
class ApplicationController < ActionController::Base
|
|
|
|
|
protect_from_forgery
|
2013-10-01 18:57:02 +00:00
|
|
|
include ApplicationHelper
|
2012-08-31 03:01:52 +00:00
|
|
|
include SessionsHelper
|
2014-05-19 21:57:08 +00:00
|
|
|
include ClientHelper
|
2013-09-22 01:25:20 +00:00
|
|
|
|
|
|
|
|
# inject username/email into bugsnag data
|
|
|
|
|
before_bugsnag_notify :add_user_info_to_bugsnag
|
|
|
|
|
|
2014-05-19 21:57:08 +00:00
|
|
|
before_filter do
|
|
|
|
|
gon_setup
|
|
|
|
|
end
|
|
|
|
|
|
2015-03-12 01:55:11 +00:00
|
|
|
before_filter :set_tracking_cookie
|
|
|
|
|
|
2014-04-22 01:55:40 +00:00
|
|
|
before_filter do
|
2014-04-22 02:14:22 +00:00
|
|
|
if params[AffiliatePartner::PARAM_REFERRAL].present? && current_user.nil?
|
|
|
|
|
if cookies[AffiliatePartner::PARAM_COOKIE].blank?
|
|
|
|
|
code = params[AffiliatePartner::PARAM_REFERRAL].downcase
|
|
|
|
|
cookies[AffiliatePartner::PARAM_COOKIE] = code if AffiliatePartner.is_code?(code)
|
2014-04-22 01:55:40 +00:00
|
|
|
end
|
|
|
|
|
end
|
2014-04-20 22:54:49 +00:00
|
|
|
end
|
|
|
|
|
|
2014-04-22 01:55:40 +00:00
|
|
|
def affiliate_code
|
|
|
|
|
cookies[AffiliatePartner::PARAM_COOKIE]
|
2014-04-20 22:54:49 +00:00
|
|
|
end
|
|
|
|
|
|
2015-03-12 01:55:11 +00:00
|
|
|
|
|
|
|
|
# http://stackoverflow.com/questions/15807214/where-to-set-a-tracking-permanent-cookie-in-rails
|
|
|
|
|
def set_tracking_cookie
|
|
|
|
|
cookies.permanent[:user_uuid] = SecureRandom.uuid unless cookies[:user_uuid]
|
|
|
|
|
end
|
|
|
|
|
|
2013-09-22 01:25:20 +00:00
|
|
|
private
|
|
|
|
|
def add_user_info_to_bugsnag(notif)
|
|
|
|
|
# Add some app-specific data which will be displayed on a custom
|
|
|
|
|
# "User Info" tab on each error page on bugsnag.com
|
|
|
|
|
|
|
|
|
|
unless current_user.nil?
|
|
|
|
|
notif.add_tab(:user_info, {
|
|
|
|
|
name: current_user.name,
|
|
|
|
|
email: current_user.email
|
|
|
|
|
})
|
|
|
|
|
end
|
|
|
|
|
end
|
2012-08-31 02:09:02 +00:00
|
|
|
end
|