LDUser
public struct LDUser : Encodable, Equatable
LDUser allows clients to collect information about users in order to refine the feature flag values sent to the SDK.
The usage of LDUser is no longer recommended and is retained only to ease the adoption of the LDContext
class. New
code using this SDK should make use of the LDContextBuilder
to construct an equivalent Kind.user
kind context.
-
Client app defined string that uniquely identifies the user. If the client app does not define a key, the SDK will assign an identifier associated with the anonymous user. The key cannot be made private.
Declaration
Swift
public var key: String
-
Client app defined name for the user. (Default: nil)
Declaration
Swift
public var name: String?
-
Client app defined first name for the user. (Default: nil)
Declaration
Swift
public var firstName: String?
-
Client app defined last name for the user. (Default: nil)
Declaration
Swift
public var lastName: String?
-
Client app defined country for the user. (Default: nil)
Declaration
Swift
public var country: String?
-
Client app defined ipAddress for the user. (Default: nil)
Declaration
Swift
public var ipAddress: String?
-
Client app defined email address for the user. (Default: nil)
Declaration
Swift
public var email: String?
-
Client app defined avatar for the user. (Default: nil)
Declaration
Swift
public var avatar: String?
-
Client app defined dictionary for the user. The client app may declare top level dictionary items as private, see
privateAttributes
for details. (Default: [:])Declaration
Swift
public var custom: [String : LDValue]
-
Client app defined isAnonymous for the user. If the client app does not define isAnonymous, the SDK will use the
key
to set this attribute. isAnonymous cannot be made private. (Default: false)Declaration
Swift
public var isAnonymous: Bool
-
Client app defined privateAttributes for the user. The SDK will not include private attribute values in analytics events, but private attribute names will be sent. This attribute is ignored if
LDConfig.allUserAttributesPrivate
is true. Combined withLDConfig.privateUserAttributes
. The SDK considers attributes appearing in either list as private. Client apps may define most built-in attributes and all top levelcustom
dictionary keys here. (Default: []]) See Also:LDConfig.allUserAttributesPrivate
andLDConfig.privateUserAttributes
.Declaration
Swift
public var privateAttributes: [UserAttribute]
-
init(key:
name: firstName: lastName: country: ipAddress: email: avatar: custom: isAnonymous: privateAttributes: ) Initializer to create a LDUser. Client configurable attributes each have an optional parameter to facilitate setting user information into the LDUser. The SDK will automatically set
key
,device
,operatingSystem
, andisAnonymous
attributes if the client does not provide them. The SDK embedsdevice
andoperatingSystem
into thecustom
dictionary for transmission to LaunchDarkly.Declaration
Swift
public init(key: String? = nil, name: String? = nil, firstName: String? = nil, lastName: String? = nil, country: String? = nil, ipAddress: String? = nil, email: String? = nil, avatar: String? = nil, custom: [String: LDValue]? = nil, isAnonymous: Bool? = nil, privateAttributes: [UserAttribute]? = nil)
Parameters
key
String that uniquely identifies the user. If the client app does not define a key, the SDK will assign an identifier associated with the anonymous user.
name
Client app defined name for the user. (Default: nil)
firstName
Client app defined first name for the user. (Default: nil)
lastName
Client app defined last name for the user. (Default: nil)
country
Client app defined country for the user. (Default: nil)
ipAddress
Client app defined ipAddress for the user. (Default: nil)
email
Client app defined email address for the user. (Default: nil)
avatar
Client app defined avatar for the user. (Default: nil)
custom
Client app defined dictionary for the user. The client app may declare top level dictionary items as private. If the client app defines custom as private, the SDK considers the dictionary private except for device & operatingSystem (which cannot be made private). See
privateAttributes
for details. (Default: nil)isAnonymous
Client app defined isAnonymous for the user. If the client app does not define isAnonymous, the SDK will use the
key
to set this attribute. (Default: nil)privateAttributes
Client app defined privateAttributes for the user. (Default: nil)
-
Declaration
Swift
public func encode(to encoder: Encoder) throws