Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
Add secondary user attribute (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
torchhound authored May 11, 2021
1 parent 5ad0499 commit 4ca1a1f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ declare module 'launchdarkly-react-native-client-sdk' {
*/
key: string;

/**
* The secondary key for the user. See the
* [documentation](https://docs.launchdarkly.com/home/managing-flags/targeting-users#percentage-rollout-logic)
* for more information on it's use for percentage rollout bucketing.
*/
secondary?: string;

/**
* The user's name.
*
Expand Down
4 changes: 4 additions & 0 deletions ios/LaunchdarklyReactNativeClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ class LaunchdarklyReactNativeClient: RCTEventEmitter {
private func userBuild(userDict: NSDictionary) -> LDUser? {
var user = LDUser()
user.key = userDict["key"] as! String

if userDict["secondary"] != nil {
user.secondary = userDict["secondary"] as? String
}

if userDict["name"] != nil {
user.name = userDict["name"] as? String
Expand Down
3 changes: 2 additions & 1 deletion test-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ async function tests() {
const userWithKeyOnly: LDUser = { key: 'user' };
const user: LDUser = {
key: 'user',
secondary: 'user.secondary',
name: 'name',
firstName: 'first',
lastName: 'last',
Expand All @@ -65,7 +66,7 @@ async function tests() {
const timeoutClient: LDClient = new LDClient();

const configure: null = await client.configure(configWithAllOptions, user);
const configureWithTimeout: null = await timeoutClient.configure(configWithAllOptions, user, 10);
const configureWithTimeout: null = await timeoutClient.configure(configWithAllOptions, userWithKeyOnly, 10);
const identify: null = await client.identify(user);

const boolFlagValue: boolean = await client.boolVariation('key', false);
Expand Down

0 comments on commit 4ca1a1f

Please sign in to comment.