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

Unable to get feature flag using variation method #154

Closed
VarshaKamble159 opened this issue Jul 24, 2019 · 3 comments
Closed

Unable to get feature flag using variation method #154

VarshaKamble159 opened this issue Jul 24, 2019 · 3 comments

Comments

@VarshaKamble159
Copy link

VarshaKamble159 commented Jul 24, 2019

Hi,

I am trying to integrate node-server-sdk in my application. I am able to initialize Launch darkly with sdk-key. Also i am getting available flags using allFlagsState .

     ldClient = LaunchDarkly.init("sdk-key");
     ldClient.allFlagsState({}, function(err, flagsState) {
           //Here I am getting all available feature flags
            var flagStateProps = flagsState.toJSON()['$flagsState'];
            console.log("All available feature flags", flagStateProps);           
        });

When i am trying to check flag availability using variation method, i am always getting false as response, where this flag is available in allFlags.
Following is the code for the same.

 ldClient.variation("feature_flag", {}, false, function(err, show_feature) {
     if (show_feature) {
        console.log("TRUE");
    } else {
     // Always returning false
          console.log("FALSE");
      }
});

Please suggest for the same.

installed npm LaunchDarkly version :
"launchdarkly-node-server-sdk": "5.8.2"

NOTE: I am able to get feature flag in JAVA launchdarkly sdk with same sdk-key.

ldClient = new LDClient(sdk-key, {});  
LDUser ldUser = null;
boolean boolVariation = ldClient.boolVariation(feature, ldUser, false); // It returns true for same feature flag.
@VarshaKamble159 VarshaKamble159 changed the title Unable to get enable flags through variation method Unable to get feature flag using variation method Jul 24, 2019
@bwoskow-ld
Copy link
Member

Hi @VarshaKamble159 ,

I see that you've already closed your issue. As a result I assume that you've identified and resolved your problem.

While I'm here, I want to point you to our SDK documentation which has information about how to use the variation method as well as other SDK features.

This particular issue is actually a support request and not a SDK bug report. Don't hesitate to reach out to [email protected] for additional help adopting the Node Server SDK in your application.

Cheers,
Ben

@eli-darkly
Copy link
Contributor

For the record, briefly, the two problems I see in this code are 1. you don't have a valid user object (users should have at least a key) and 2. var flagStateProps = flagsState.toJSON()['$flagsState'] does not give you the flag values, it gives you some metadata containing objects which might look like a true flag value to you because objects are always "truthy"; what you want is just var flagStateProps = flagsState.allValues().

@VarshaKamble159
Copy link
Author

Hi @eli-darkly and @bwoskow-ld ,

Thank you so much guys for your replies. Yes, i identified the issue in my code and was able to solve it.
I appreciate your response.

Will surely reach out to you guys in case of any further help.

Thanks,
Varsha

LaunchDarklyCI pushed a commit that referenced this issue Dec 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants