C++ Client-Side SDK
LaunchDarkly SDK
|
#include <launchdarkly/bindings/c/context.h>
#include <launchdarkly/bindings/c/export.h>
#include <launchdarkly/bindings/c/value.h>
#include <stdbool.h>
Go to the source code of this file.
Typedefs | |
typedef struct _LDContextBuilder * | LDContextBuilder |
Functions | |
LDContextBuilder_New () | |
LDContextBuilder_Free (LDContextBuilder builder) | |
LDContextBuilder_Build (LDContextBuilder builder) | |
LDContextBuilder_AddKind (LDContextBuilder builder, char const *kind, char const *key) | |
LDContextBuilder_Attributes_Set (LDContextBuilder builder, char const *kind, char const *attr_name, LDValue val) | |
LDContextBuilder_Attributes_SetPrivate (LDContextBuilder builder, char const *kind, char const *attr_key, LDValue val) | |
LDContextBuilder_Attributes_SetName (LDContextBuilder builder, char const *kind, char const *name) | |
LDContextBuilder_Attributes_SetAnonymous (LDContextBuilder builder, char const *kind, bool anonymous) | |
LDContextBuilder_Attributes_AddPrivateAttribute (LDContextBuilder builder, char const *kind, char const *attr_ref) | |
LDContextBuilder_AddKind | ( | LDContextBuilder | builder, |
char const * | kind, | ||
char const * | key | ||
) |
Add a kind instance to the context builder. The kind will have the specified key.
Attributes may be set for the kind by calling the LDContextBuilder_Attributes_* methods with the same "kind".
You must first add the kind to the context builder before setting attributes.
If you call this a second time, with an already specified kind, but a different key, then the key for that kind will be updated.
builder | The builder to add the kind to. Must not be NULL. |
kind | The kind to add. Must not be NULL. |
key | The key for that kind. Must not be NULL. |
LDContextBuilder_Attributes_AddPrivateAttribute | ( | LDContextBuilder | builder, |
char const * | kind, | ||
char const * | attr_ref | ||
) |
Designate a context attribute, or properties within them, as private: that is, their values will not be sent to LaunchDarkly in analytics events.
Each parameter can be a simple attribute name, such as "email". Or, if the first character is a slash, the parameter is interpreted as a slash-delimited path to a property within a JSON object, where the first path component is a Context attribute name and each following component is a nested property name: for example, suppose the attribute "address" had the following JSON object value:
Using ["/address/street/line1"] in this case would cause the "line1" property to be marked as private. This syntax deliberately resembles JSON Pointer, but other JSON Pointer features such as array indexing are not supported for Private.
This action only affects analytics events that involve this particular context. To mark some (or all) context attributes as private for all contexts, use the overall configuration for the SDK. See
and
The attributes "kind" and "key", and the "_meta" attributes cannot be made private.
builder | The builder. Must not be NULL. |
kind | The kind to set the attribute as private for. Must not be NULL. |
attr_ref | An attribute reference. Must not be NULL. |
LDContextBuilder_Attributes_Set | ( | LDContextBuilder | builder, |
char const * | kind, | ||
char const * | attr_name, | ||
LDValue | val | ||
) |
Add or update a top-level attribute in the specified kind.
Adding a LDValue to the builder will consume that value. You should not access the value after adding it to the builder, and you do not need to call LDValue_Free on the value.
builder | The builder. Must not be NULL. |
kind | The kind to add the attribute to. Must not be NULL. |
attr_name | The name of the attribute to add. Must not be NULL. |
val | The value of the attribute to add. Must not be NULL. |
LDContextBuilder_Attributes_SetAnonymous | ( | LDContextBuilder | builder, |
char const * | kind, | ||
bool | anonymous | ||
) |
Set the anonymous attribute for the specified kind.
If true, the context will not appear on the Contexts page in the LaunchDarkly dashboard.
builder | The builder. Must not be NULL. |
kind | The kind to set the anonymous attribute for. Must not be NULL. |
anonymous | The value to set the anonymous attribute to. |
LDContextBuilder_Attributes_SetName | ( | LDContextBuilder | builder, |
char const * | kind, | ||
char const * | name | ||
) |
Set the name attribute for the specified kind.
You can search for contexts on the LaunchDarkly Contexts page by name.
This method will make a copy of the name string, and the caller remains responsible for the original name string.
builder | The builder. Must not be NULL. |
kind | The kind to set the name for. Must not be NULL. |
name | The name to set. Must not be NULL. |
LDContextBuilder_Attributes_SetPrivate | ( | LDContextBuilder | builder, |
char const * | kind, | ||
char const * | attr_key, | ||
LDValue | val | ||
) |
Add or update a private attribute. Once an attribute has been set as private using this method it will remain private.
A subsequent call to LDContextBuilder_Attributes_Set, for the same attribute, will not remove the private status.
This method cannot be used to set the key
, kind
, name
, or anonymous
property of a context.
Adding a LDValue to the builder will consume that value.
You should not access the value after adding it to the builder, and you do not need to call LDValue_Free on the value. This method is just a convenience which also adds the attribute to the private attributes list, as if using LDContextBuilder_Attributes_AddPrivateAttribute.
builder | The builder. Must not be NULL. |
kind | The kind to set the private attribute for. Must not be NULL. |
attr_key | The key of the private attribute. Must not be NULL. |
val | The value of the private attribute. Must not be NULL. |
LDContextBuilder_Build | ( | LDContextBuilder | builder | ) |
Construct a context from a context builder. The builder is automatically freed.
WARNING: Do not call any other LDContextBuilder function on the provided LDContextBuilder after calling this function. It is undefined behavior.
builder | The builder to build a context from. Must not be NULL. |
LDContextBuilder_Free | ( | LDContextBuilder | builder | ) |
Free a context builder.
This method only needs to be used when not building the context. If you use LDContextBuilder_Build, then the builder will be consumed, and you do not need to call LDContextBuilder_Free.
builder | The builder to free. |
LDContextBuilder_New | ( | ) |
Create a new context builder.