public struct LDContext : Encodable, Equatable
extension LDContext: Decodable
LDContext is a collection of attributes that can be referenced in flag evaluations and analytics events.
To create an LDContext of a single kind, such as a user, you may use
To create an LDContext with multiple kinds, use
public func encode(to encoder: Encoder) throws
FullyQualifiedKey returns a string that describes the entire Context based on Kind and Key values.
This value is used whenever LaunchDarkly needs a string identifier based on all of the Kind and Key values in the context; the SDK may use this for caching previously seen contexts, for instance.
public func fullyQualifiedKey() -> String
public func isMulti() -> Bool
true if the
LDContextis a multi-context; false otherwise.
/ - Returns: A hash mapping a context’s kind to its key.
public func contextKeys() -> [String : String]
Looks up the value of any attribute of the
LDContext, or a value contained within an attribute, based on a
Reference. This includes only attributes that are addressable in evaluations.
This implements the same behavior that the SDK uses to resolve attribute references during a flag evaluation. In a context, the
Referencecan represent a simple attribute name– either a built-in one like “name” or “key”, or a custom attribute that was set by
LDContextBuilder.trySetValue(...)– or, it can be a slash-delimited path using a JSON-Pointer-like syntax. See
Referencefor more details.
For a multi-context, the only supported attribute name is “kind”.
If the value is found, the return value is the attribute value, using the type
LDValueto represent a value of any JSON type.
If there is no such attribute, or if the
Referenceis invalid, the return value is nil.
public init(from decoder: Decoder) throws