jam-cloud/web/app/controllers/application_controller.rb

41 lines
1.0 KiB
Ruby

require 'bugsnag'
class ApplicationController < ActionController::Base
protect_from_forgery
include ApplicationHelper
include SessionsHelper
include ClientHelper
# inject username/email into bugsnag data
before_bugsnag_notify :add_user_info_to_bugsnag
before_filter do
gon_setup
end
before_filter do
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)
end
end
end
def affiliate_code
cookies[AffiliatePartner::PARAM_COOKIE]
end
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
end