Skip to main content

Server-side SDKs

Here are the configuration options for private context and user attributes in server-side SDKs:

.NET (server-side)

In the server-side .NET SDK there are two ways to define private attributes for the entire LaunchDarkly client:
  • When creating the LaunchDarkly Configuration object, you can configure Events with AllAttributesPrivate, which takes in a boolean parameter. If true, the SDK removes all attributes for all contexts before sending the context to LaunchDarkly, except the key.
  • Or, you can configure Events with PrivateAttributes, which takes any number of attribute names or slash-delimited paths to designated a JSON property within an attribute, such as /address/street. If any context has a custom or built-in attribute that matches one of these names, the SDK removes it before sending the context to LaunchDarkly.
For example:
You can also mark attributes as private when building the context object by calling Private() after setting the attribute on the context builder.For example:
When the SDK sends this context back to LaunchDarkly, it removes the email attribute.

Apex

You can configure the Apex SDK to treat some or all user attributes as private user attributes, either using the LDConfig object or on a per-user basis.When creating the LDConfig object, you can use setAllAttributesPrivate(true). When you do this, all user attributes, except the key, are redacted before the SDK sends the user to LaunchDarkly.Here’s how:
You can also define private attribute names on a per-user basis:

C++ (server-side)

In the C++ SDK there are three ways to define private attributes for the LaunchDarkly client:
  • When creating the config object, you can use AllAttributesPrivate. When you do this, the SDK only sends the context key and kind to LaunchDarkly. For example:
  • When creating the config object, you can list specific private attributes with PrivateAttributes. The SDK removes all attributes in this list before sending the context to LaunchDarkly. Here’s how:
  • You can also define private attributes on a per-context basis. For example:
To learn more, read ContextBuilder.

Erlang

Here’s how to set context attributes as private for all or just some contexts:
Here’s how to set context attributes as private for a specific context:
In the example, only the name and /address/street attributes are private for this context.

Go

In the Go SDK there are two ways to define private attributes for the entire LaunchDarkly client:
  • You can set the configuration option AllAttributesPrivate to true. If you enable this, the SDK removes all attributes for all contexts before it sends the context to LaunchDarkly, except the key and kind.
  • You can set the configuration option PrivateAttributes to a list of attribute names. If any context has an attribute named in this list, the SDK removes it before sending the context to LaunchDarkly.
Here’s how to to define private attributes:
You can also define a set of private attributes on the context object itself. In the following example, “email” and the “street” field of the “address” attribute are private for this context, in addition to any private attributes that were specified globally:

Haskell

Optionally, you can configure the Haskell SDK to treat some or all context attributes as private attributes. You can use private context attributes for targeting purposes, but the SDK removes private context attributes from the data it sends to LaunchDarkly.There are two ways to define private attributes for the entire LaunchDarkly client:
  • When you create the Config object, use configSetAllAttributesPrivate to set all context attributes as private. When you do this, all context attributes, except the key and kind, are removed before the SDK sends the context to LaunchDarkly.
  • When you create the Config object, you can list specific private attributes with configSetPrivateAttributeNames. If any context has attributes named in this list, the SDK removes them before sending the context to LaunchDarkly.
Here’s how:
You can also define private attribute names on a per-context basis.For example:

Java

In the Java SDK there are two ways to define private attributes for the entire LaunchDarkly client:
  • When creating the LDConfig object, you can call the allAttributesPrivate method, which takes in a boolean parameter. If true, all context attributes except the key for all contexts are removed before the SDK sends the context to LaunchDarkly.
  • When creating the LDConfig object, you can call the privateAttributes method, which takes in a set of custom or built-in attributes as a parameter. If any context has a custom or built-in attribute named in this list, the SDK removes it before sending the context to LaunchDarkly.
Here’s how to define private attributes:
You can also mark attributes as private when building the context object by calling the privateAttributes builder method. For example:
When the SDK sends this context back to LaunchDarkly, it removes the email attribute.

Lua

In the Lua SDK there are two ways to define private attributes for the LaunchDarkly client:
  • Use allAttributesPrivate to remove all context attributes except for the kind and key from all contexts before the SDK sends the contexts to LaunchDarkly.
  • Use privateAttributes to designate a list of private attributes. If any context has an attribute named in this list, the SDK removes that attribute before sending the context to LaunchDarkly.
Here’s how to mark attributes as private:
You can also define private attributes for a particular context using a list of privateAttributes:
To learn more, read clientInit and makeContext.

Node.js (server-side)

In the Node.js SDK there are two ways to define private attributes for the entire LaunchDarkly client:
  • In the LaunchDarkly LDOptions, you can set allAttributesPrivate to true. If you enable this, the SDK removes all attributes for all contexts before sending the context to LaunchDarkly, except the kind and key.
  • In the LaunchDarkly LDOptions object, you can define a list of privateAttributes. If any context has a custom or built-in attribute named in this list, the SDK removes it before sending the context to LaunchDarkly.
For example:
You can also define a set of privateAttributes on the context object. For example:
When the SDK sends this context back to LaunchDarkly, it removes the email attribute.

PHP

In the PHP SDK there are two ways to define private attributes for the entire LaunchDarkly client:
  • In the LaunchDarkly config, you can set all_attributes_private to true. If you enable this, the SDK removes all attributes except the key and kind from a context before sending the context to LaunchDarkly.
  • In the LaunchDarkly config object, you can define a list of private_attribute_names. If any context has a custom or built-in attribute named in this list, the SDK removes it before sending the context to LaunchDarkly.
For example:
You can also mark attributes as private when building the context object by calling the equivalent “private” LDContextBuilder method.For example:
When the SDK sends this context back to LaunchDarkly, it removes the email attribute.

Python

In the Python SDK there are two ways to define private attributes for the LaunchDarkly client:
  • In the LaunchDarkly config, you can set all_attributes_private to true. If you enable this, the SDK removes all context attributes for all contexts before sending the context to LaunchDarkly, except the key.
  • In the LaunchDarkly config object, you can define a list of attributes in private_attributes. If any context has a custom or built-in attribute named in this list, the SDK removes it before sending the context to LaunchDarkly.
For example:
You can also mark attributes as private when building the context object by calling the private builder method. For example:
When the SDK sends this context back to LaunchDarkly, it removes the email attribute.

Ruby

In the Ruby SDK there are two ways to define private attributes for the entire LaunchDarkly client:
  • In the LaunchDarkly config, you can set all_attributes_private to true. If you enable this, the SDK removes all context attributes for all contexts before sending the context to LaunchDarkly, except the key.
  • In the LaunchDarkly config object, you can define a list of private_attributes. If any context has a custom or built-in attribute named in this list, the SDK removes it before sending the context to LaunchDarkly.
For example:
You can also define a set of privateAttributes on the context object. For example:
When the SDK sends this context back to LaunchDarkly, it removes the email attribute.

Rust

In the Rust SDK there are two ways to define private attributes for the entire LaunchDarkly client:
  • In the LaunchDarkly config object, you can set all_attributes_private to true. If you enable this, the SDK removes all attributes for all contexts before sending the context to LaunchDarkly, except the key and kind.
  • In the LaunchDarkly config object, you can define a list of private_attributes. If any contexts has an attribute named in this list, the SDK removes it before sending the context to LaunchDarkly.
For example:
You can also define private attributes on the context object. For example:
When the SDK sends this context back to LaunchDarkly, it removes the email attribute.