class StatsigUser

Attributes

app_version[RW]
country[RW]
email[RW]
ip[RW]
locale[RW]
private_attributes[RW]
statsig_environment[RW]
user_agent[RW]
user_id[RW]

Public Class Methods

new(user_hash) click to toggle source
# File lib/statsig_user.rb, line 20
def initialize(user_hash)
  @statsig_environment = Hash.new
  if user_hash.is_a?(Hash)
    @user_id = user_hash['userID'] || user_hash['user_id']
    @user_id = @user_id.to_s unless @user_id.nil?
    @email = user_hash['email']
    @ip = user_hash['ip']
    @user_agent = user_hash['userAgent'] || user_hash['user_agent']
    @country = user_hash['country']
    @locale = user_hash['locale']
    @app_version = user_hash['appVersion'] || user_hash['app_version']
    @custom = user_hash['custom']
    @statsig_environment = user_hash['statsigEnvironment']
    @private_attributes = user_hash['privateAttributes']
  end
end

Public Instance Methods

custom() click to toggle source
# File lib/statsig_user.rb, line 12
def custom
  @custom
end
custom=(value) click to toggle source
# File lib/statsig_user.rb, line 16
def custom=(value)
  @custom = value.is_a?(Hash) ? value : Hash.new
end
serialize(for_logging) click to toggle source
# File lib/statsig_user.rb, line 37
def serialize(for_logging)
  hash = {
    'userID' => @user_id,
    'email' => @email,
    'ip' => @ip,
    'userAgent' => @user_agent,
    'country' => @country,
    'locale' => @locale,
    'appVersion' => @app_version,
    'custom' => @custom,
    'statsigEnvironment' => @statsig_environment,
    'privateAttributes' => @private_attributes,
  }
  if for_logging
    hash.delete('privateAttributes')
  end
  hash
end
value_lookup() click to toggle source
# File lib/statsig_user.rb, line 56
def value_lookup
  {
    'userID' => @user_id,
    'userid' => @user_id,
    'user_id' => @user_id,
    'email' => @email,
    'ip' => @ip,
    'userAgent' => @user_agent,
    'useragent' => @user_agent,
    'user_agent' => @user_agent,
    'country' => @country,
    'locale' => @locale,
    'appVersion' => @app_version,
    'appversion' => @app_version,
    'app_version' => @app_version,
    'custom' => @custom,
    'privateAttributes' => @private_attributes,
  }
end