launchdarkly / react-native-client-sdk

LaunchDarkly Client-side SDK for React Native
Other
45 stars 32 forks source link

Unable to get LaunchDarkly feature flag values on Android (React Native) #219

Closed meramos closed 1 year ago

meramos commented 1 year ago

Description: I am using React Native version 0.70.6 with Typescript and the latest LaunchDarkly SDK package, version 7.1.4. I have implemented feature flags in my app using the LaunchDarkly SDK and I am trying to get the value of the feature flags. The feature flags work as expected on iOS, but on Android, I am only getting the default value and not the actual feature flag value. When I called the allFlags method on the client, it returned an empty object in Android, but in iOS it returned all our feature flags.

Steps to reproduce:

Expected result: The app should retrieve the actual feature flag value from LaunchDarkly SDK on Android, as it does on iOS.

Actual result: The app only retrieves the default feature flag value on Android, and the allFlags method returns an empty object.

Reproducibility: This issue is consistently reproducible on Android, but not on iOS.

Additional information: I previously used an older version of the LaunchDarkly SDK (version 5.1.1) with an older version of React Native and it was able to retrieve the feature flag values on Android. I believe this issue is a bug on LaunchDarkly's side and not an issue with my own implementation.

Environment: React Native version: 0.70.6 LaunchDarkly SDK version: 7.1.4 Operating system: Android and Mac M2

Please let me know if you need any additional information to help resolve this issue.

louis-launchdarkly commented 1 year ago

Hello @meramos, can you try to use the https://github.com/launchdarkly/react-native-client-sdk/tree/main/ManualTestApp and see can retrieve the flag values for your Mobile Key? Once you tried that, can you file a Support ticket with us using this link: https://support.launchdarkly.com/hc/en-us - we may need to ask about your config and code and we do that through support tickets.

meramos commented 1 year ago

Okay I will try it and get back to you, thank you

meramos commented 1 year ago

@louis-launchdarkly I was able to run the Manual Test App and I got the correct feature flag values on Android, confirming that it was an issue in my setup and not with the library. I debugged my project and it turned out I was sending an undefined key in the user context when configuring the client, and it seems Android was not okay with that (strangely though, iOS didn't have a problem with that). Once I changed it so I was sending a value for the user key, I started getting the feature flag values on Android. Thank you for your help!


const config = { mobileKey: MOBILE_KEY };
const user = { 
    key: userId,    // userId was coming in as undefined, which caused the issue specifically on Android
    kind: "user" 
};
await client.configure(config, user);