Click or drag to resize

User Class

Attributes of a user for whom you are evaluating feature flags.
Inheritance Hierarchy
SystemObject
  LaunchDarkly.ClientUser

Namespace:  LaunchDarkly.Client
Assembly:  LaunchDarkly.CommonSdk (in LaunchDarkly.CommonSdk.dll) Version: 2.11.0
Syntax
public class User : IEquatable<User>

The User type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyAnonymous
Whether or not the user is anonymous.
Public propertyAvatar
The user's avatar.
Public propertyCountry
The country code for the user.
Public propertyCustom
Custom attributes for the user. These can be more conveniently set via the extension methods AndCustomAttribute or AndPrivateCustomAttribute.
Public propertyEmail
The user's email address.
Public propertyFirstName
The user's first name.
Public propertyIpAddress Obsolete.
The IP address of the user (deprecated property name; use IPAddress).
Public propertyIPAddress
The IP address of the user.
Public propertyKey
The unique key for the user.
Public propertyLastName
The user's last name.
Public propertyName
The user's full name.
Public propertyPrivateAttributeNames
Used internally to track which attributes are private. To set private attributes, you should use extension methods such as AndPrivateName.
Public propertySecondary
The secondary key for a user, which can be used in feature flag targeting.
Public propertySecondaryKey Obsolete.
Obsolete name for Secondary.
Top
Methods
  NameDescription
Public methodStatic memberCode exampleBuilder(String)
Creates an IUserBuilder for constructing a user object using a fluent syntax.
Public methodStatic memberCode exampleBuilder(User)
Creates an IUserBuilder for constructing a user object, with its initial properties copied from an existeing user.
Public methodEquals(Object)
Determines whether the specified object is equal to the current object.
(Overrides ObjectEquals(Object).)
Public methodEquals(User)
Indicates whether the current object is equal to another object of the same type.
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Overrides ObjectGetHashCode.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodStatic memberWithKey
Creates a user with the given key.
Top
Extension Methods
  NameDescription
Public Extension MethodAndAnonymous
Sets whether this user is anonymous.
(Defined by UserExtensions.)
Public Extension MethodAndAvatar
Sets the user's avatar.
(Defined by UserExtensions.)
Public Extension MethodAndCountry
Sets the country for a user to a two-character country code.
(Defined by UserExtensions.)
Public Extension MethodAndCustomAttribute(String, String)Overloaded.
Adds a string-valued custom attribute. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
(Defined by UserExtensions.)
Public Extension MethodAndCustomAttribute(String, Boolean)Overloaded.
Adds a bool-valued custom attribute. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
(Defined by UserExtensions.)
Public Extension MethodAndCustomAttribute(String, Int32)Overloaded.
Adds an int-valued custom attribute. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
(Defined by UserExtensions.)
Public Extension MethodAndCustomAttribute(String, Single)Overloaded.
Adds a float-valued custom attribute. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
(Defined by UserExtensions.)
Public Extension MethodAndCustomAttribute(String, Int64)Overloaded.
Adds a long-valued custom attribute. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
(Defined by UserExtensions.)
Public Extension MethodAndCustomAttribute(String, ListString)Overloaded.
Adds a custom attribute whose value is a list of strings. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
(Defined by UserExtensions.)
Public Extension MethodAndCustomAttribute(String, ListInt32)Overloaded.
Adds a custom attribute whose value is a list of ints. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
(Defined by UserExtensions.)
Public Extension MethodAndCustomAttribute(String, JToken)Overloaded.
Adds a custom attribute whose value is a JSON value of any kind. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
(Defined by UserExtensions.)
Public Extension MethodAndEmail
Sets the user's email address.
(Defined by UserExtensions.)
Public Extension MethodAndFirstName
Sets the user's first name.
(Defined by UserExtensions.)
Public Extension MethodAndIpAddress
Sets the IP for a user.
(Defined by UserExtensions.)
Public Extension MethodAndLastName
Sets the user's last name.
(Defined by UserExtensions.)
Public Extension MethodAndName
Sets the user's full name.
(Defined by UserExtensions.)
Public Extension MethodAndPrivateAvatar
Sets the user's avatar, and ensures that the avatar attribute will not be sent back to LaunchDarkly.
(Defined by UserExtensions.)
Public Extension MethodAndPrivateCountry
Sets the country for a user, and ensures that the country attribute will not be sent back to LaunchDarkly.
(Defined by UserExtensions.)
Public Extension MethodAndPrivateCustomAttribute(String, String)Overloaded.
Adds a string-valued custom attribute, and ensures that the attribute will not be sent back to LaunchDarkly. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
(Defined by UserExtensions.)
Public Extension MethodAndPrivateCustomAttribute(String, Boolean)Overloaded.
Adds a bool-valued custom attribute, and ensures that the attribute will not be sent back to LaunchDarkly. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
(Defined by UserExtensions.)
Public Extension MethodAndPrivateCustomAttribute(String, Int32)Overloaded.
Adds an int-valued custom attribute, and ensures that the attribute will not be sent back to LaunchDarkly. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
(Defined by UserExtensions.)
Public Extension MethodAndPrivateCustomAttribute(String, Single)Overloaded.
Adds a float-valued custom attribute, and ensures that the attribute will not be sent back to LaunchDarkly. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
(Defined by UserExtensions.)
Public Extension MethodAndPrivateCustomAttribute(String, Int64)Overloaded.
Adds a long-valued custom attribute, and ensures that the attribute will not be sent back to LaunchDarkly. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
(Defined by UserExtensions.)
Public Extension MethodAndPrivateCustomAttribute(String, ListString)Overloaded.
Adds a custom attribute who value is a list of strings, and ensures that the attribute will not be sent back to LaunchDarkly. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
(Defined by UserExtensions.)
Public Extension MethodAndPrivateCustomAttribute(String, ListInt32)Overloaded.
Adds a custom attribute who value is a list of ints, and ensures that the attribute will not be sent back to LaunchDarkly. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
(Defined by UserExtensions.)
Public Extension MethodAndPrivateCustomAttribute(String, JToken)Overloaded.
Adds a custom attribute whose value is a JSON value of any kind, and ensures that the attribute will not be sent back to LaunchDarkly. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
(Defined by UserExtensions.)
Public Extension MethodAndPrivateEmail
Sets the user's email address, and ensures that the email attribute will not be sent back to LaunchDarkly.
(Defined by UserExtensions.)
Public Extension MethodAndPrivateFirstName
Sets the user's first name, and ensures that the first name attribute will not be sent back to LaunchDarkly.
(Defined by UserExtensions.)
Public Extension MethodAndPrivateIpAddress
Sets the IP for a user, and ensures that the IP attribute is not sent back to LaunchDarkly.
(Defined by UserExtensions.)
Public Extension MethodAndPrivateLastName
Sets the user's last name, and ensures that the last name attribute will not be sent back to LaunchDarkly.
(Defined by UserExtensions.)
Public Extension MethodAndPrivateName
Sets the user's full name, and ensures that the name attribute will not be sent back to LaunchDarkly.
(Defined by UserExtensions.)
Public Extension MethodAndSecondaryKey
Sets the secondary key for a user. This affects feature flag targeting as follows: if you have chosen to bucket users by a specific attribute, the secondary key (if set) is used to further distinguish between users who are otherwise identical according to that attribute.
(Defined by UserExtensions.)
Top
Remarks

User contains any user-specific properties that may be used in feature flag configurations to produce different flag variations for different users. You may define these properties however you wish.

The only mandatory property is the Key, which must uniquely identify each user. For authenticated users, this may be a username or e-mail address. For anonymous users, this could be an IP address or session ID.

Besides the mandatory key, User supports two kinds of optional attributes: interpreted attributes (e.g. IPAddress and Country) and custom attributes. LaunchDarkly can parse interpreted attributes and attach meaning to them. For example, from an IPAddress, LaunchDarkly can do a geo IP lookup and determine the user's country.

Custom attributes are not parsed by LaunchDarkly. They can be used in custom rules-- for example, a custom attribute such as "customer_ranking" can be used to launch a feature to the top 10% of users on a site. Custom attributes can have values of any type supported by JSON.

Note that the properties of User are mutable. In future versions of the SDK, this class will be immutable. The preferred method of setting user properties is to obtain a builder with Builder(String); avoid using the UserExtensions methods or an object initializer expression such as new User("key") { Name = "name" }, since these will no longer work once User is immutable. Modifying properties after creating a User could result in unexpected inconsistencies in your analytics events, since events that have not yet been delivered retain a reference to the original User.

See Also