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

Unable to get feature flag using variation method #154

Closed

Description

@VarshaKamble159

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.

Activity

  1. changed the title [-]Unable to get enable flags through variation method[/-] [+]Unable to get feature flag using variation method[/+] on Jul 24, 2019
  2. bwoskow-ld commented on Jul 24, 2019

    @bwoskow-ld
    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 support@launchdarkly.com for additional help adopting the Node Server SDK in your application.

    Cheers,
    Ben

  3. eli-darkly commented on Jul 24, 2019

    @eli-darkly
    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().

  4. VarshaKamble159 commented on Jul 25, 2019

    @VarshaKamble159
    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

  5. added a commit that references this issue on Dec 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions