statsig-io / statsig-feedback

Issue Tracker for Statsig. Leave your feedback on anything we do!
5 stars 0 forks source link

LocalMode in .NET Server SDK doesn't work #39

Closed jjanuszkiewicz closed 1 year ago

jjanuszkiewicz commented 1 year ago

I'm setting up the .NET Server SDK and I want to use the LocalMode option while developing locally. The documentation on https://docs.statsig.com/server/dotnetSDK says:

LocalMode: bool, default false

Pass true to this option to turn on Local Mode for the SDK, which will stop the SDK from issuing any network requests and make it only operate with only local overrides and cache. Note: Since no network requests will be made, a dummy SDK key starting with "server-" can be used. (eg "server-key")

However, when I set LocalMode=true and provide server-key as the key value, I get an exception:

Statsig.Lib.StatsigArgumentException: Invalid key provided. Please check your Statsig console to get the right server key.
   at Statsig.Server.ServerDriver..ctor(String serverSecret, StatsigOptions options)
   at Statsig.Server.StatsigServer.Initialize(String serverSecret, StatsigOptions options)

It comes from this line in the SDK:

if (!serverSecret.StartsWith("secret-") && options2.AdditionalHeaders.Count == 0)
{
    throw new StatsigArgumentException("Invalid key provided. Please check your Statsig console to get the right server key.");
}

It looks like it doesn't take the special server-* keys and local mode into account.

I'd also appreciate some guidance on how to use the "local overrides" that are mentioned in the above docs, as I can't find anything related in StatsigServer and StatsigServerOptions.

daniel-statsig commented 1 year ago

@jjanuszkiewicz, this is actually a bug in the docs. It should be "secret-key", not "server-key". I'll update the docs. Also looks like local overrides support hasn't been added to .NET yet. We will address this in the next release.

jjanuszkiewicz commented 1 year ago

@daniel-statsig thanks, it works now. And thanks for looking into the local overrides, I'll be watching the releases!