From 5c05b2e2d955e83983b2f0a52907da33a6873fc8 Mon Sep 17 00:00:00 2001 From: Yusinto Ngadiman Date: Wed, 6 Mar 2024 21:49:42 -0800 Subject: [PATCH] fix: Add new Android only config option generateAnonymousKeysAndroid. (#186) --- .../LaunchdarklyReactNativeClientModule.java | 7 ++++++- index.d.ts | 10 ++++++++++ yarn.lock | 8 ++++---- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/android/src/main/java/com/launchdarkly/reactnative/LaunchdarklyReactNativeClientModule.java b/android/src/main/java/com/launchdarkly/reactnative/LaunchdarklyReactNativeClientModule.java index f8762a2..0ae2360 100644 --- a/android/src/main/java/com/launchdarkly/reactnative/LaunchdarklyReactNativeClientModule.java +++ b/android/src/main/java/com/launchdarkly/reactnative/LaunchdarklyReactNativeClientModule.java @@ -330,7 +330,12 @@ private LDConfig.Builder buildConfiguration(ReadableMap config) { } LDConfig.Builder builder = new LDConfig.Builder(autoEnvAttributes); - builder.generateAnonymousKeys(true); + + if (validateConfig("generateAnonymousKeysAndroid", config, ReadableType.Boolean)) { + builder.generateAnonymousKeys(config.getBoolean("generateAnonymousKeysAndroid")); + } else { + builder.generateAnonymousKeys(true); + } // configure trivial options for (ConfigMapping entry : ConfigMapping.values()) { diff --git a/index.d.ts b/index.d.ts index 5fe6edd..0819f33 100644 --- a/index.d.ts +++ b/index.d.ts @@ -226,6 +226,16 @@ declare module 'launchdarkly-react-native-client-sdk' { * You can also specify this on a per-context basis with {@link LDContextMeta.privateAttributes} */ privateAttributes?: string[]; + + /** + * Android only. + * + * Set to true to make the SDK provide unique keys for anonymous contexts. + * Read more at https://launchdarkly.github.io/android-client-sdk/com/launchdarkly/sdk/android/LDConfig.Builder.html#generateAnonymousKeys(boolean). + * + * The default is true. + */ + generateAnonymousKeysAndroid?: boolean; }; /** diff --git a/yarn.lock b/yarn.lock index 341949a..99a8a41 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3887,10 +3887,10 @@ react-is@^17.0.1: resolved "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz" integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== -"react-native@*", "react-native@^0.73.2": - "integrity" "sha512-7zj9tcUYpJUBdOdXY6cM8RcXYWkyql4kMyGZflW99E5EuFPoC7Ti+ZQSl7LP9ZPzGD0vMfslwyDW0I4tPWUCFw==" - "resolved" "https://registry.npmjs.org/react-native/-/react-native-0.73.2.tgz" - "version" "0.73.2" +react-native@^0.73.2: + version "0.73.2" + resolved "https://registry.npmjs.org/react-native/-/react-native-0.73.2.tgz" + integrity sha512-7zj9tcUYpJUBdOdXY6cM8RcXYWkyql4kMyGZflW99E5EuFPoC7Ti+ZQSl7LP9ZPzGD0vMfslwyDW0I4tPWUCFw== dependencies: "@jest/create-cache-key-function" "^29.6.3" "@react-native-community/cli" "12.3.0"