module Framed

Constants

DEFAULT_EXCLUDED_PARAMS
FRAMED_API_ENDPOINT
LOG_PREFIX
SEGMENT_API_ENDPOINT
VERSION

Attributes

client[RW]
emitter[RW]

Public Class Methods

configuration() click to toggle source
# File lib/framed_rails.rb, line 28
def configuration
  @configuration ||= {
    :emitter => Framed::Emitters::Blocking,
    :user_id_controller_method => 'framed_current_user_id',
    :endpoint => Framed::FRAMED_API_ENDPOINT,
    :logger => Logger.new(STDERR),
    :anonymous_cookie => Framed::COOKIE_NAME,
    :include_xhr => false,
    :excluded_params => []
  }
end
configure() { |configuration| ... } click to toggle source
# File lib/framed_rails.rb, line 44
def configure
  yield configuration
  self.client = Client.new(configuration)

  @emitter.stop(true) if @emitter
  @emitter = configuration[:emitter].new(self.client)
end
drain() click to toggle source
# File lib/framed_rails.rb, line 80
def drain
  @emitter.stop(true) if @emitter
end
excluded_params() click to toggle source
# File lib/framed_rails.rb, line 40
def excluded_params
  (configuration[:excluded_params] + DEFAULT_EXCLUDED_PARAMS).uniq
end
log_error(msg) click to toggle source
# File lib/framed_rails.rb, line 76
def log_error(msg)
  logger.error(LOG_PREFIX + msg)
end
log_info(msg) click to toggle source
# File lib/framed_rails.rb, line 72
def log_info(msg)
  logger.info(LOG_PREFIX + msg)
end
logger() click to toggle source
# File lib/framed_rails.rb, line 68
def logger
  configuration[:logger]
end
new_anonymous_id() click to toggle source
# File lib/framed_rails.rb, line 92
def new_anonymous_id
  Framed::Utils.uuid
end
report(event) click to toggle source
# File lib/framed_rails.rb, line 52
def report(event)
  event[:lib] = 'framed_ruby'
  event[:lib_version] = Framed::VERSION
  event[:type] ||= :track
  event[:context] ||= {}
  event[:context].merge!({
    :channel => 'server'
  })

  event[:properties] ||= {}

  # fill in if needed, in case it sits in queue for a while.
  event[:timestamp] ||= Framed::Utils.serialize_date(Time.now)
  @emitter.enqueue(event)
end
user_id_controller_method() click to toggle source
# File lib/framed_rails.rb, line 84
def user_id_controller_method
  configuration[:user_id_controller_method]
end