Class: StatsigUser
- Inherits:
-
Object
- Object
- StatsigUser
- Defined in:
- lib/statsig_user.rb
Instance Attribute Summary collapse
-
#app_version ⇒ Object
Returns the value of attribute app_version.
-
#country ⇒ Object
Returns the value of attribute country.
-
#custom_ids ⇒ Object
Returns the value of attribute custom_ids.
-
#email ⇒ Object
Returns the value of attribute email.
-
#ip ⇒ Object
Returns the value of attribute ip.
-
#locale ⇒ Object
Returns the value of attribute locale.
-
#private_attributes ⇒ Object
Returns the value of attribute private_attributes.
-
#statsig_environment ⇒ Object
Returns the value of attribute statsig_environment.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
-
#user_id ⇒ Object
Returns the value of attribute user_id.
Instance Method Summary collapse
- #custom ⇒ Object
- #custom=(value) ⇒ Object
-
#initialize(user_hash) ⇒ StatsigUser
constructor
A new instance of StatsigUser.
- #serialize(for_logging) ⇒ Object
- #value_lookup ⇒ Object
Constructor Details
#initialize(user_hash) ⇒ StatsigUser
Returns a new instance of StatsigUser.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/statsig_user.rb', line 21 def initialize(user_hash) @user_id = nil @email = nil @ip = nil @user_agent = nil @country = nil @locale = nil @app_version = nil @custom = nil @private_attributes = nil @custom_ids = nil @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'] if user_hash['custom'].is_a? Hash @statsig_environment = user_hash['statsigEnvironment'] @private_attributes = user_hash['privateAttributes'] if user_hash['privateAttributes'].is_a? Hash custom_ids = user_hash['customIDs'] || user_hash['custom_ids'] @custom_ids = custom_ids if custom_ids.is_a? Hash end end |
Instance Attribute Details
#app_version ⇒ Object
Returns the value of attribute app_version.
8 9 10 |
# File 'lib/statsig_user.rb', line 8 def app_version @app_version end |
#country ⇒ Object
Returns the value of attribute country.
6 7 8 |
# File 'lib/statsig_user.rb', line 6 def country @country end |
#custom_ids ⇒ Object
Returns the value of attribute custom_ids.
10 11 12 |
# File 'lib/statsig_user.rb', line 10 def custom_ids @custom_ids end |
#email ⇒ Object
Returns the value of attribute email.
3 4 5 |
# File 'lib/statsig_user.rb', line 3 def email @email end |
#ip ⇒ Object
Returns the value of attribute ip.
4 5 6 |
# File 'lib/statsig_user.rb', line 4 def ip @ip end |
#locale ⇒ Object
Returns the value of attribute locale.
7 8 9 |
# File 'lib/statsig_user.rb', line 7 def locale @locale end |
#private_attributes ⇒ Object
Returns the value of attribute private_attributes.
11 12 13 |
# File 'lib/statsig_user.rb', line 11 def private_attributes @private_attributes end |
#statsig_environment ⇒ Object
Returns the value of attribute statsig_environment.
9 10 11 |
# File 'lib/statsig_user.rb', line 9 def statsig_environment @statsig_environment end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
5 6 7 |
# File 'lib/statsig_user.rb', line 5 def user_agent @user_agent end |
#user_id ⇒ Object
Returns the value of attribute user_id.
2 3 4 |
# File 'lib/statsig_user.rb', line 2 def user_id @user_id end |
Instance Method Details
#custom ⇒ Object
13 14 15 |
# File 'lib/statsig_user.rb', line 13 def custom @custom end |
#custom=(value) ⇒ Object
17 18 19 |
# File 'lib/statsig_user.rb', line 17 def custom=(value) @custom = value.is_a?(Hash) ? value : Hash.new end |
#serialize(for_logging) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/statsig_user.rb', line 50 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, 'customIDs' => @custom_ids, } if for_logging hash.delete('privateAttributes') end hash.compact end |
#value_lookup ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/statsig_user.rb', line 70 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 |