LDUser

public struct LDUser
extension LDUser: Equatable

LDUser allows clients to collect information about users in order to refine the feature flag values sent to the SDK. For example, the client app may launch with the SDK defined anonymous user. As the user works with the client app, information may be collected as needed and sent to LaunchDarkly. The client app controls the information collected, which LaunchDarkly does not use except as the client directs to refine feature flags. Client apps should follow Apple’s Privacy Policy when collecting user information. The SDK caches last known feature flags for use on app startup to provide continuity with the last app run. Provided the LDClient is online and can establish a connection with LaunchDarkly servers, cached information will only be used a very short time. Once the latest feature flags arrive at the SDK, the SDK no longer uses cached feature flags. The SDK retains feature flags on the last 5 client defined users. The SDK will retain feature flags until they are overwritten by a different user’s feature flags, or until the user removes the app from the device. The SDK does not cache user information collected, except for the user key. The user key is used to identify the cached feature flags for that user. Client app developers should use caution not to use sensitive user information as the user-key.

  • String keys associated with LDUser properties.

    See more

    Declaration

    Swift

    public enum CodingKeys : String, CodingKey
  • LDUser attributes that can be marked private. The SDK will not include private attribute values in analytics events, but private attribute names will be sent. See Also: LDConfig.allUserAttributesPrivate, LDConfig.privateUserAttributes, and privateAttributes.

    Declaration

    Swift

    public static var privatizableAttributes: [String] { get }
  • key

    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
  • The secondary key for the user. See the documentation for more information on it’s use for percentage rollout bucketing.

    Declaration

    Swift

    public var secondary: 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. 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)

    Declaration

    Swift

    public var custom: [String : Any]?
  • 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: true)

    Declaration

    Swift

    public var isAnonymous: Bool
  • Client app defined device for the user. The SDK will determine the device automatically, however the client app can override the value. The SDK will insert the device into the custom dictionary. The device cannot be made private. (Default: the system identified device)

    Declaration

    Swift

    public var device: String?
  • Client app defined operatingSystem for the user. The SDK will determine the operatingSystem automatically, however the client app can override the value. The SDK will insert the operatingSystem into the custom dictionary. The operatingSystem cannot be made private. (Default: the system identified operating system)

    Declaration

    Swift

    public var operatingSystem: String?
  • 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 with LDConfig.privateUserAttributes. The SDK considers attributes appearing in either list as private. Client apps may define attributes found in privatizableAttributes and top level custom dictionary keys here. (Default: nil) See Also: LDConfig.allUserAttributesPrivate and LDConfig.privateUserAttributes.

    Declaration

    Swift

    public var privateAttributes: [String]?
  • An NSObject wrapper for the Swift LDUser struct. Intended for use in mixed apps when Swift code needs to pass a user into an Objective-C method.

    Declaration

    Swift

    public var objcLdUser: ObjcLDUser { get }
  • 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, and isAnonymous attributes if the client does not provide them. The SDK embeds device and operatingSystem into the custom 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: Any]? = nil,
                isAnonymous: Bool? = nil,
                device: String? = nil,
                operatingSystem: String? = nil,
                privateAttributes: [String]? = nil,
                secondary: String? = 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)

    device

    Client app defined device for the user. The SDK will determine the device automatically, however the client app can override the value. The SDK will insert the device into the custom dictionary. (Default: nil)

    operatingSystem

    Client app defined operatingSystem for the user. The SDK will determine the operatingSystem automatically, however the client app can override the value. The SDK will insert the operatingSystem into the custom dictionary. (Default: nil)

    privateAttributes

    Client app defined privateAttributes for the user. (Default: nil)

    secondary

    Secondary attribute value. (Default: nil)

  • Initializer that takes a [String: Any] and creates a LDUser from the contents. Uses any keys present to define corresponding attribute values. Initializes attributes not present in the dictionary to their default value. Attempts to set device and operatingSystem from corresponding values embedded in custom. DEPRECATED: Attempts to set feature flags from values set in config.

    Declaration

    Swift

    public init(userDictionary: [String : Any])

    Parameters

    userDictionary

    Dictionary with LDUser attribute keys and values.

  • Compares users by comparing their user keys only, to allow the client app to collect user information over time

    Declaration

    Swift

    public static func == (lhs: LDUser, rhs: LDUser) -> Bool