> ## Documentation Index
> Fetch the complete documentation index at: https://launchdarkly-preview.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Private attributes: Client-side SDKs

> This topic explains how to configure private context and user attributes in LaunchDarkly SDKs. These features are available for client-side, server-side, and AI SDKs. This page covers client-side sdks.

> For the complete documentation index, see [llms.txt](/llms.txt). For the full documentation snapshot, see [llms-full.txt](/llms-full.txt).

## Client-side SDKs

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

* [.NET (client-side)](#net-client-side)
* [Android](#android)
* [C++ (client-side)](#c-client-side)
* [Electron](#electron)
* [Flutter](#flutter)
* [iOS](#ios)
* [JavaScript](#javascript)
* [Node.js (client-side)](#nodejs-client-side)
* [React Native](#react-native)
* [React Web](#javascript): The React Web SDK relies on the JavaScript SDK for context-related functionality.
* [Roku](#roku)

### .NET (client-side)

<Accordion title="Expand .NET (client-side) code sample">
  In the client-side .NET SDK there are two ways to define private attributes for the entire LaunchDarkly client:

  * When creating the LaunchDarkly `Configuration` object, you can call the `AllAttributesPrivate` method, which takes in a boolean parameter. If `true`, all context attributes except the kind and key are removed for all contexts before the SDK sends the context to LaunchDarkly.
  * When creating the LaunchDarkly `Configuration` object, you can call the `PrivateAttributes` method, which takes any number of attribute names or slash-delimited paths to designated JSON properties 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:

  <CodeGroup>
    ```csharp title=".NET SDK v4.0 (C#)" theme={null}
          // All attributes marked private
          var configAllPrivate = Configuration
            .Builder("example-mobile-key", ConfigurationBuilder.AutoEnvAttributes.Enabled)
            .AllAttributesPrivate(true)
            .Build();
          LdClient client = LdClient.Init(configAllPrivate, context);

          // Two attributes marked private
          var configSomePrivate = Configuration.Builder("example-mobile-key")
            .PrivateAttributes("email", "address")
            .Build();
          LdClient client = LdClient.Init(configSomePrivate, context);
    ```

    ```csharp title=".NET SDK v3.0 (C#)" theme={null}
          // All attributes marked private
          var configAllPrivate = Configuration.Builder("example-mobile-key")
            .AllAttributesPrivate(true)
            .Build();
          LdClient client = LdClient.Init(configAllPrivate, context);

          // Two attributes marked private
          var configSomePrivate = Configuration.Builder("example-mobile-key")
            .PrivateAttributes("email", "address")
            .Build();
          LdClient client = LdClient.Init(configSomePrivate, context);
    ```
  </CodeGroup>

  You can also mark attributes as private when building the context object by calling `Private()` on the context builder.

  For example:

  <CodeGroup>
    ```csharp title=".NET SDK v3.0+ (C#)" theme={null}
          var context = Context.Builder("example-context-key")
              .Set("email", "sandy@example.com")
              .Private("email")
              .Build();
    ```
  </CodeGroup>

  When the SDK sends this context back to LaunchDarkly, it removes the `email` attribute.
</Accordion>

### Android

<Accordion title="Expand Android code sample">
  In the Android SDK you can define private attributes for the entire LaunchDarkly client. When creating the `LDConfig` object, 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 set, the SDK removes it before sending the context to LaunchDarkly.

  Here's how to configure private attributes:

  <CodeGroup>
    ```java title="Android SDK v5.x (Java)" theme={null}
          // All attributes marked private
          LDConfig ldConfig = new LDConfig.Builder(AutoEnvAttributes.Enabled)
              .mobileKey("example-mobile-key")
              .events(
                Components.sendEvents()
                    .allAttributesPrivate(true)
              )
              .build();

          // Two attributes marked private
          LDConfig ldConfig = new LDConfig.Builder(AutoEnvAttributes.Enabled)
              .mobileKey("example-mobile-key")
              .events(
                  Components.sendEvents()
                      .privateAttributes("name", "group")
              )
              .build();
    ```

    ```kotlin title="Android SDK v5.x (Kotlin)" theme={null}
          // All attributes marked private
          val ldConfig = LDConfig.Builder(AutoEnvAttributes.Enabled)
              .mobileKey("example-mobile-key")
              .events(
                  Components.sendEvents()
                    .allAttributesPrivate(true)
               )
               .build()

          // Two attributes marked private
          val ldConfig = LDConfig.Builder(AutoEnvAttributes.Enabled)
              .mobileKey("example-mobile-key")
              .events(
                  Components.sendEvents()
                      .privateAttributes("name", "group")
              )
              .build();
    ```

    ```java title="Android SDK v4.x (Java)" theme={null}
          // All attributes marked private
          LDConfig config = new LDConfig.Builder()
              .mobileKey("example-mobile-key")
              .events(
                Components.sendEvents()
                    .allAttributesPrivate(true)
              )
              .build();

          // Two attributes marked private
          LDConfig ldConfig = new LDConfig.Builder()
              .mobileKey("example-mobile-key")
              .events(
                  Components.sendEvents()
                      .privateAttributes("name", "group")
              )
              .build();
    ```

    ```kotlin title="Android SDK v4.x (Kotlin)" theme={null}
          // All attributes marked private
          val config = LDConfig.Builder()
              .events(
                  Components.sendEvents()
                      .allAttributesPrivate(true)
              )
              .build();

          // Two attributes marked private
          val config = LDConfig.Builder()
              .mobileKey("example-mobile-key")
              .events(
                  Components.sendEvents()
                      .privateAttributes("name", "group")
              )
              .build();
    ```
  </CodeGroup>

  You can also mark attributes as private when building the context object by using the private versions of the builder methods to set the attributes. For example:

  <CodeGroup>
    ```java title="Android SDK v4.0+ (Java)" theme={null}
          LDContext context = LDContext.builder("example-context-key")
              .set("email", "sandy@example.com")
              .set("name", "Sandy")
              .set("group", "Global Health Services")
              .privateAttributes("name", "group")
    ```

    ```kotlin title="Android SDK v4.0+ (Kotlin)" theme={null}
          val context: LDContext = LDContext.builder("example-context-key")
              .set("email", "sandy@example.com")
              .set("name", "Sandy")
              .set("group", "Global Health Services")
              .privateAttributes("name", "group")
              .build()
    ```
  </CodeGroup>

  When the SDK sends this context back to LaunchDarkly, it removes the `name` and `group` attributes.
</Accordion>

### C++ (client-side)

<Accordion title="Expand C++ (client-side) code sample">
  In the C++ SDK there are two ways to define private attributes for the LaunchDarkly client:

  * When using the `ConfigBuilder`, you can call `AllAttributesPrivate()`. When you do this, all context attributes except the kind and key are removed before the SDK sends the context to LaunchDarkly.
  * When using the `ConfigBuilder`, you can configure a set of `PrivateAttributes()`. If any context has an attribute named in this list, the SDK removes it before sending the context to LaunchDarkly.

  Here's how:

  <CodeGroup>
    ```cpp title="C++ SDK v3.0 (native)" theme={null}
          /* sets all attributes private */
          auto config_builder = client_side::ConfigBuilder("example-mobile-key");
          config_builder.Events().AllAttributesPrivate(true);
          auto config_all_private = config_builder.Build();

          /* sets "email" and "address" private */
          auto config_builder = client_side::ConfigBuilder("example-mobile-key");
          config_builder.Events().PrivateAttributes({"email", "address"});
          auto configSomePrivate = config_builder.Build();
    ```

    ```c title="C++ SDK v3.0 (C binding)" theme={null}
          /* sets all attributes private */
          LDClientConfigBuilder config_builder = LDClientConfigBuilder_New("example-mobile-key");
          LDClientConfigBuilder_Events_AllAttributesPrivate(config_builder, true);

          LDClientConfig config;
          LDStatus config_status = LDClientConfigBuilder_Build(config_builder, &config);

          /* sets "email" and "address" private */
          LDClientConfigBuilder config_builder = LDClientConfigBuilder_New("example-mobile-key");
          LDClientConfigBuilder_Events_PrivateAttribute(config_builder, "email");
          LDClientConfigBuilder_Events_PrivateAttribute(config_builder, "address");

          LDClientConfig config;
          LDStatus config_status = LDClientConfigBuilder_Build(config_builder, &config);
    ```

    ```c title="C SDK v2.x" theme={null}
          struct LDConfig *config = LDConfigNew("example-mobile-key");
          // Mark all attributes private
          LDConfigSetAllAttributesPrivate(config, true);
    ```
  </CodeGroup>

  You can also define private attributes for a particular context by calling `.SetPrivate()` in the `ContextBuilder`.

  Here's how:

  <CodeGroup>
    ```cpp title="C++ SDK v3.0" theme={null}
          auto context = ContextBuilder()
            .Kind("user", "example-user-key")
            .Name("Sandy Smith")
            .SetPrivate("email", "sandy@example.com")
            .Build();
    ```
  </CodeGroup>

  To learn more, read [`ContextBuilder`](https://launchdarkly.github.io/cpp-sdks/libs/client-sdk/docs/html/classlaunchdarkly_1_1ContextBuilder.html).
</Accordion>

### Electron

<Accordion title="Expand Electron code sample">
  To mark all user attributes except the key as private, use the `allAttributesPrivate` option:

  <CodeGroup>
    ```js title="JavaScript" theme={null}
          const user = {
            key: 'example-user-key',
            name: 'Sandy Smith',
            email: 'sandy@example.com'
          };

          const client = LDElectron.initialize('example-client-side-id', user, {
            allAttributesPrivate: true
          });
    ```

    ```ts title="TypeScript" theme={null}
          import * as LDElectron from 'launchdarkly-electron-client-sdk';

          const user: LDElectron.LDUser = {
            key: 'example-user-key',
            name: 'Sandy Smith',
            email: 'sandy@example.com',
          };

          const client = LDElectron.initializeInMain('example-client-side-id', user, {
            allAttributesPrivate: true,
          });
    ```
  </CodeGroup>

  In the above example, the SDK removes the `name` and `email` attributes.

  You can also specify an array of which attributes should be private with the `privateAttributeNames` option. You can configure this option on a per-user basis by specifying which attributes should be private in your user object.

  This option is configured in both the user object and the configuration object:

  <CodeGroup>
    ```js title="JavaScript" theme={null}
          const user = {
            key: 'example-user-key',
            name: 'Sandy Smith',
            email: 'sandy@example.com',
            privateAttributeNames: ['email']
          };

          const client = LDElectron.initialize('example-client-side-id', user, {
            privateAttributeNames: ['email']
          });
    ```

    ```ts title="TypeScript" theme={null}
          import * as LDElectron from 'launchdarkly-electron-client-sdk';

          const user: LDElectron.LDUser = {
            key: 'example-user-key',
            name: 'Sandy Smith',
            email: 'sandy@example.com',
            privateAttributeNames: ['email'],
          };

          const client = LDElectron.initializeInMain('example-client-side-id', user, {
            privateAttributeNames: ['email'],
          });
    ```
  </CodeGroup>

  In the above example, the SDK sends only the `key` and `name` back to LaunchDarkly.
</Accordion>

### Flutter

<Accordion title="Expand Flutter code sample">
  In the Flutter SDK, you can define private attributes for the **entire** LaunchDarkly client. When you create the `LDConfig` object, you can set all attributes private for all contexts. You can also provide a list of attributes to the `globalPrivateAttributes` option. If any context has an attribute named in this set, the SDK removes it before sending the context to LaunchDarkly.

  <CodeGroup>
    ```dart title="Flutter SDK v4" theme={null}
          final config = LDConfig(
            CredentialSource.fromEnvironment(),
            AutoEnvAttributes.enabled,
            allAttributesPrivate: true, // all attributes marked private
            globalPrivateAttributes: ['user/email', 'user/group'], // two attributes marked private for the 'user' context kind
          )
    ```

    ```dart title="Flutter SDK v3.x" theme={null}
          // All attributes marked private
          LDConfig config = LDConfigBuilder('example-mobile-key', AutoEnvAttributes.Enabled)
              .allAttributesPrivate(true)
              .build();

          // Two attributes marked private
          LDConfig ldConfig = new LDConfigBuilder('example-mobile-key', AutoEnvAttributes.Enabled)
              .privateAttributeNames(['email', 'group'])
              .build();
    ```
  </CodeGroup>

  You can also mark attributes as private when building the context object by using the `private` optional parameter. For example:

  <CodeGroup>
    ```dart title="Flutter SDK v4" theme={null}
          final context = LDContextBuilder()
            .kind('user', 'example-user-key'),
            .setString('name', 'Sandy')
            .setString('email', 'sandy@example.com', private: true)
            .setString('group', 'microsoft', private: true)
            .build();
    ```

    ```dart title="Flutter SDK v2.x+" theme={null}
          LDContextBuilder builder = LDContextBuilder();
          builder.kind('user', 'example-user-key')
              .name('Sandy')
              .set('email', LDValue.ofString('sandy@example.com'))
              .set('group', LDValue.ofString('microsoft'))
              .privateAttributes(['email', 'group'])
          LDContext context = builder.build();
    ```

    ```dart title="Flutter SDK v1.x" theme={null}
          LDUser user = LDUserBuilder('example-user-key')
              .name('Sandy')
              .privateEmail('sandy@example.com')
              .privateCustom('group', LDValue.ofString('microsoft'))
              .build();
    ```
  </CodeGroup>

  When the SDK sends this context back to LaunchDarkly, the `email` and `group` attributes are removed.

  To learn more about the configuration options for private attributes, read [`allAttributesPrivate`](https://pub.dev/documentation/launchdarkly_flutter_client_sdk/latest/launchdarkly_flutter_client_sdk/LDConfig/allAttributesPrivate.html) and [`globalPrivateAttributes`](https://pub.dev/documentation/launchdarkly_flutter_client_sdk/latest/launchdarkly_flutter_client_sdk/LDConfig/globalPrivateAttributes.html). To learn more about setting private attributes for a specific context, read [`LDContext`](https://pub.dev/documentation/launchdarkly_flutter_client_sdk/latest/launchdarkly_flutter_client_sdk/LDContext-class.html).
</Accordion>

### iOS

<Accordion title="Expand iOS code sample">
  In the iOS SDK there are two ways to define private attributes for the entire LaunchDarkly client:

  * When creating the `LDConfig` object, you can set the `allContextAttributesPrivate` attribute to `true`.
  * When creating the LDConfig object, you can set the `privateContextAttributes` property to a list of `Reference`s, such as `[Reference("name"), Reference("/address/state")]`. 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:

  <CodeGroup>
    ```swift title="iOS SDK v9.0 (Swift)" theme={null}
          // All attributes marked private
          config = LDConfig(mobileKey: "example-mobile-key", autoEnvAttributes: .enabled)
          config.allContextAttributesPrivate = true

          // Two attributes marked private
          config = LDConfig(mobileKey: "example-mobile-key", autoEnvAttributes: .enabled)
          config.privateContextAttributes = [Reference("email"), Reference("address")]
    ```

    ```objectivec title="iOS SDK v9.0 (Objective-C)" theme={null}
          // All attributes marked private
          LDConfig *config = [[LDConfig alloc] initWithMobileKey:@"example-mobile-key" autoEnvAttributes:AutoEnvAttributesEnabled];
          [config setAllContextAttributesPrivate:YES];
          [LDClient startWithConfiguration:config context:context completion:nil];

          // Two attributes marked private
          LDConfig *config = [[LDConfig alloc] initWithMobileKey:@"example-mobile-key" autoEnvAttributes:AutoEnvAttributesEnabled];
          [builder nameWithName:@"name"];
          [builder trySetValueWithName:@"email" value:[LDValue ofString:@"example@email.com"]];
          NSDictionary<NSString *, LDValue *> *address = @{
              @"street": [LDValue ofString:@"Main St"],
              @"city": [LDValue ofString:@"Springfield"]
          };
          LDContext *context = builder.build.success;

          LDConfig *config = [[LDConfig alloc] initWithMobileKey:@"example-mobile-key"];
          [config setPrivateContextAttributes:@[@"email", @"address"]];
    ```

    ```swift title="iOS SDK v8.x (Swift)" theme={null}
          // All attributes marked private
          var config = LDConfig(mobileKey: "example-mobile-key")
          config.allContextAttributesPrivate = true

          // Two attributes marked private
          var config = LDConfig(mobileKey: "example-mobile-key")
          config.privateContextAttributes = [Reference("email"), Reference("address")]
    ```

    ```objectivec title="iOS SDK v8.x (Objective-C)" theme={null}
          // All attributes marked private
          LDConfig *config = [[LDConfig alloc] initWithMobileKey:@"example-mobile-key"];
          [config setAllContextAttributesPrivate:YES];
          [LDClient startWithConfiguration:config context:context completion:nil];

          // Two attributes marked private
          LDContextBuilder *builder = [[LDContextBuilder alloc] initWithKey:@"example-context-key"];
          [builder nameWithName:@"name"];
          [builder trySetValueWithName:@"email" value:[LDValue ofString:@"example@email.com"]];
          NSDictionary<NSString *, LDValue *> *address = @{
              @"street": [LDValue ofString:@"Main St"],
              @"city": [LDValue ofString:@"Springfield"]
          };
          LDContext *context = builder.build.success;

          LDConfig *config = [[LDConfig alloc] initWithMobileKey:@"example-mobile-key"];
          [config setPrivateContextAttributes:@[@"email", @"address"]];
    ```
  </CodeGroup>

  You can also mark attributes as private on a particular `LDContext` instance, for example:

  <CodeGroup>
    ```swift title="iOS SDK v8.0+ (Swift)" theme={null}
          var contextBuilder = LDContextBuilder(key: "example-context-key")
          contextBuilder.trySetValue("name", .string("Sandy"))
          contextBuilder.trySetValue("group", .array([LDValue(stringLiteral: "microsoft")]))
          contextBuilder.addPrivateAttribute(Reference("name"))
          contextBuilder.addPrivateAttribute(Reference("group"))

          let context = try contextBuilder.build().get()
    ```

    ```objectivec title="iOS SDK v8.0+ (Objective-C)" theme={null}
          LDContextBuilder *builder = [[LDContextBuilder alloc] initWithKey:@"example-context-key"];
          [builder trySetValueWithName:@"name" value:[LDValue ofString:@"Sandy"]];

          NSArray *groups = [NSArray arrayWithObjects:[LDValue ofString:@"microsoft"], nil];
          [builder trySetValueWithName:@"group" value:[LDValue ofArray:groups]];

          [builder addPrivateAttributeWithReference:[[Reference alloc] initWithValue:@"email"]];
          [builder addPrivateAttributeWithReference:[[Reference alloc] initWithValue:@"group"]];

          LDContext *context = builder.build.success;
    ```
  </CodeGroup>
</Accordion>

### Java

Script

<Accordion title="Expand JavaScript code sample">
  You can configure the private attributes option either in the configuration object or in the context object.

  In the configuration object, to mark all attributes except the key as private in the JavaScript SDK, use the `allAttributesPrivate` option:

  <CodeGroup>
    ```js title="JavaScript SDK v3.x+" theme={null}

          // All attributes marked private
          const ldclient = ld.initialize('example-client-side-id', context, options = {
            allAttributesPrivate: true
          });

          try {
            await client.waitForInitialization(5);
            proceedWithSuccessfullyInitializedClient();
          } catch(err) {
            // Client failed to initialized or timed out
            // variation() calls return fallback values until initialization completes
          }

    ```

    ```ts title="JavaScript SDK v3.x+ (TypeScript)" theme={null}
          import { LDClient } as ld from 'launchdarkly-js-client-sdk';

          // All attributes marked private
          const options: ld.LDOptions = { allAttributesPrivate: true };

          const client = ld.initialize('example-client-side-id', context, options);

          try {
            await client.waitForInitialization(5);
            proceedWithSuccessfullyInitializedClient();
          } catch(err) {
            // Client failed to initialized or timed out
            // variation() calls return fallback values until initialization completes
          }
    ```
  </CodeGroup>

  To learn more, read [`allAttributesPrivate`](https://launchdarkly.github.io/js-client-sdk/interfaces/LDOptions.html#allAttributesPrivate).

  In the configuration object, to mark some attributes as private specify your array of attributes in the `privateAttributes` configuration option:

  <CodeGroup>
    ```js title="JavaScript SDK v3.x+" theme={null}

          // Two attributes marked private
          const ldclient = ld.initialize('example-client-side-id', context, options = {
            privateAttributes: ['email', 'name']
          });

          try {
            await client.waitForInitialization(5);
            proceedWithSuccessfullyInitializedClient();
          } catch(err) {
            // Client failed to initialized or timed out
            // variation() calls return fallback values until initialization completes
          }

    ```

    ```ts title="JavaScript SDK v3.x+ (TypeScript)" theme={null}
          import { LDClient } as ld from 'launchdarkly-js-client-sdk';

          // Two attributes marked private
          const options = { privateAttributes: ['email', 'name'] };

          const client = ld.initialize('example-client-side-id', context, options);

          try {
            await client.waitForInitialization(5);
            proceedWithSuccessfullyInitializedClient();
          } catch(err) {
            // Client failed to initialized or timed out
            // variation() calls return fallback values until initialization completes
          }

    ```
  </CodeGroup>

  To learn more, read [`privateAttributes`](https://launchdarkly.github.io/js-client-sdk/interfaces/LDOptions.html#privateAttributes).

  In the context object, specify your array of attributes in the `privateAttributes` field of the reserved `_meta` property.

  Here's how:

  <CodeGroup>
    ```js title="JavaScript SDK v3.x+" theme={null}
          const context = {
            kind: 'user',
            key: 'example-context-key',
            name: 'Sandy Smith',
            email: 'sandy@example.com',
            _meta: {
              privateAttributes: ['email']
            }
          };

    ```

    ```ts title="JavaScript SDK v3.x+ (TypeScript)" theme={null}
          import { LDClient } as ld from 'launchdarkly-js-client-sdk';

          const context: ld.LDContext = {
            key: 'example-context-key',
            name: 'Sandy Smith',
            email: 'sandy@example.com',
            _meta: {
              privateAttributes: ['email'],
            }
          };

    ```
  </CodeGroup>

  To learn more, read [`privateAttributes`](https://launchdarkly.github.io/js-client-sdk/interfaces/LDContextMeta.html#privateAttributes).
</Accordion>

### Node.js (client-side)

<Accordion title="Expand Node.js (client-side) code sample">
  To mark all attributes except the key as private in the Node.js SDK, you can use the `allAttributesPrivate` option:

  <CodeGroup>
    ```js title="Node.js SDK v3.0 (JavaScript)" theme={null}
          const context = {
            kind: 'user',
            key: 'example-user-key',
            name: 'Sandy Smith',
            email: 'sandy@example.com'
          };
          // All attributes marked private
          const client = ld.initialize('example-client-side-id', context, {
            allAttributesPrivate: true
          });
          // Two attributes marked private
          const client = ld.initialize('example-client-side-id', context, {
            privateAttributes: ['email', 'name']
          });
    ```

    ```ts title="Node.js SDK v3.0 (TypeScript)" theme={null}
          import * as ld from 'launchdarkly-node-client-sdk';

          const context: ld.LDcontext = {
            kind: 'user',
            key: 'example-user-key',
            name: 'Sandy Smith',
            email: 'sandy@example.com',
          };
          // All attributes marked private
          const options: ld.LDOptions = { allAttributesPrivate: true };

          const client = ld.initialize('example-client-side-id', context, options);
          // Two attributes marked private
          const options = { privateAttributes: ['email', 'name'] };

          const client = LaunchDarkly.initialize('example-client-side-id', context, options);
    ```
  </CodeGroup>

  You can also specify an array of which attributes should be private with the `privateAttributes` option. You can configure this option on a per-context basis by specifying which attributes should be private in your context object.

  You can configure this option in both the context object and the configuration object:

  <CodeGroup>
    ```js title="Node.js SDK v3.0 (JavaScript)" theme={null}
          const context = {
            kind: 'user',
            key: 'example-user-key',
            name: 'Sandy Smith',
            email: 'sandy@example.com'
            _meta: {
              privateAttributes: ['email']
            }
          };

          const client = ld.initialize('example-client-side-id', context, {
            privateAttributes: ['email']
          });
    ```

    ```ts title="Node.js SDK v3.0 (TypeScript)" theme={null}
          import * as ld from 'launchdarkly-node-client-sdk';

          const context: ld.LDContext = {
            kind: 'user',
            key: 'example-user-key',
            name: 'Sandy Smith',
            email: 'sandy@example.com',
            _meta: {
              privateAttributes: ['email'],
            }
          };
          const options: ld.LDOptions = { privateAttributes: ['email'] };

          const client = ld.initialize('example-client-side-id', context, options);
    ```
  </CodeGroup>

  In the above example, the SDK sends only the context key and name back to LaunchDarkly.
</Accordion>

### React Native

<Accordion title="Expand React Native code sample">
  You can configure this option in the configuration object, to apply to all contexts, either for all attributes or some attributes:

  <CodeGroup>
    ```js title="React Native SDK v10" theme={null}
          // All attributes marked private
          const options = {
            allAttributesPrivate: true
          }
          const client = new ReactNativeLDClient('example-mobile-key', AutoEnvAttributes.Enabled, options);

          // Two attributes marked private
          const options = {
            privateAttributes: ['email', 'address']
          }
          const client = new ReactNativeLDClient('example-mobile-key', AutoEnvAttributes.Enabled, options);
    ```
  </CodeGroup>

  To learn more, read [`allAttributesPrivate`](https://launchdarkly.github.io/js-core/packages/sdk/react-native/docs/interfaces/LDOptions.html#allAttributesPrivate) and [`privateAttributes`](https://launchdarkly.github.io/js-core/packages/sdk/react-native/docs/interfaces/LDOptions.html#privateAttributes).

  You can also mark an attribute as private for a particular context:

  <CodeGroup>
    ```js title="React Native SDK v7+" theme={null}
          const context = {
            kind: 'user',
            key: 'example-user-key',
            firstName: 'Sandy',
            lastName: 'Smith',
            email: 'sandy@example.com',
            address: {
              street: '123 Main St',
              city: 'Springfield'
            },
            _meta: {
              privateAttributes: ['email', '/address/street']
            }
          };
    ```
  </CodeGroup>

  For attributes that are objects, you can mark specific fields private, using the `/` delimiter followed by the attribute name, then the `/` delimiter followed by the JSON property within the value. In the example, the attribute `"address": { "street": "Main St", "city": "Springfield" }` has only the `/address/street` marked as private.
</Accordion>

### React Web

All context-related functionality provided by the [JavaScript SDK](#javascript) is also available in the React Web SDK.

### Roku

<Accordion title="Expand Roku code sample">
  You can configure this option in the configuration object, to apply to all contexts, either for all attributes or some attributes:

  <CodeGroup>
    ```brightscript title="Brightscript" theme={null}
          ' All attributes marked private
          config = LaunchDarklyConfig("example-mobile-key", launchDarklyTaskNode)
          config.setAllAttributesPrivate(true)

          LaunchDarklySGInit(config, context)
          client = LaunchDarklySG(launchDarklyTaskNode)

          ' Two attributes marked private
          config = LaunchDarklyConfig("example-mobile-key", launchDarklyTaskNode)
          config.addPrivateAttribute("email")
          config.addPrivateAttribute("address")

          LaunchDarklySGInit(config, context)
          client = LaunchDarklySG(launchDarklyTaskNode)
    ```
  </CodeGroup>

  You can also mark an attribute as private for a particular context:

  <CodeGroup>
    ```brightscript title="BrightScript" theme={null}
          ' when creating a context
          context = LaunchDarklyCreateContext({
              "kind": "user",
              "key": "context-key-123-abc",
              "email": "sandy@example.com",
              "_meta": { privateAttributes: ["email"] }
          })

          ' for an existing context
          context.addPrivateAttribute("email")
          context.addPrivateAttribute("/address/street")
    ```
  </CodeGroup>
</Accordion>
