FunkyVerb
FunkyVerb

Reputation: 361

How can I troubleshoot Launch Darkly SDK when it fails to get flag values?

I'm trying to set up a simple Launch Darkly integration in .NET but it isn't working. The code seems to run just fine, but it doesn't actually get the flag value. It always returns false regardless of whether I turn the flag on or off in my Launch Darkly dashboard.

Here's my code:

LdClient client = new LdClient("my sdk key");

var user = LaunchDarkly.Sdk.User.WithKey("12345");
var anonymous = LaunchDarkly.Sdk.User.Builder(Session.SessionID).Anonymous(true).Build();

bool enabledForUser = client.BoolVariation("website-poc", user);
bool enabledForAnonymous = client.BoolVariation("website-poc", anonymous);

client.Dispose();

The variables "enabledForUser" and "enabledForAnonymous" always return false. How can I troubleshoot the issue? What are some possible reasons why it's not working? (Note: the client object's "Initialized" property shows up as true, so I assume that means the connection was successful.)

Here's what my flag looks like on the Launch Darkly dashboard. The green "On" toggle means that it should be returning true, right?

screenshot

Upvotes: 3

Views: 8229

Answers (1)

FunkyVerb
FunkyVerb

Reputation: 361

I figured out the issue. I was using the SDK key for the wrong project. You can use the yellow drop-down on the dashboard to see which project you're working with.

enter image description here

Upvotes: 2

Related Questions