Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update usage of StatsigServerOptions #169

Merged
merged 3 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace OpenFeature.Contrib.Providers.Statsig
{
internal static class EvaluationContextExtensions
{
//These keys match the keys of the statsiguser object as descibed here
//These keys match the keys of the statsiguser object as described here
//https://docs.statsig.com/client/concepts/user
internal const string CONTEXT_APP_VERSION = "appVersion";
internal const string CONTEXT_COUNTRY = "country";
Expand Down
18 changes: 9 additions & 9 deletions src/OpenFeature.Contrib.Providers.Statsig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,32 @@ The first things we will do is install the **Open Feature SDK** and the **Statsi

### .NET Cli
```shell
dotnet add package OpenFeature.Contrib.Providers.Statsig
dotnet add package OpenFeature.Contrib.Provider.Statsig
```
### Package Manager

```shell
NuGet\Install-Package OpenFeature.Contrib.Providers.Statsig
NuGet\Install-Package OpenFeature.Contrib.Provider.Statsig
```
### Package Reference

```xml
<PackageReference Include="OpenFeature.Contrib.Providers.Statsig" />
<PackageReference Include=" OpenFeature.Contrib.Provider.Statsig" />
```
### Packet cli

```shell
paket add OpenFeature.Contrib.Providers.Statsig
paket add OpenFeature.Contrib.Provider.Statsig
```

### Cake

```shell
// Install OpenFeature.Contrib.Providers.Statsig as a Cake Addin
#addin nuget:?package=OpenFeature.Contrib.Providers.Statsig
// Install OpenFeature.Contrib.Provider.Statsig as a Cake Addin
#addin nuget:?package= OpenFeature.Contrib.Provider.Statsig

// Install OpenFeature.Contrib.Providers.Statsig as a Cake Tool
#tool nuget:?package=OpenFeature.Contrib.Providers.Statsig
// Install OpenFeature.Contrib.Provider.Statsig as a Cake Tool
#tool nuget:?package= OpenFeature.Contrib.Provider.Statsig
```

## Using the Statsig Provider with the OpenFeature SDK
Expand All @@ -44,7 +44,7 @@ The following example shows how to use the Statsig provider with the OpenFeature

```csharp
using OpenFeature;
using OpenFeature.Contrib.Providers.Statsig;
using OpenFeature.Contrib.Provider.Statsig;
using System;

StatsigProvider statsigProvider = new StatsigProvider("#YOUR-SDK-KEY#");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,20 @@ public sealed class StatsigProvider : FeatureProvider
volatile bool initialized = false;
private readonly Metadata _providerMetadata = new Metadata("Statsig provider");
private readonly string _sdkKey = "secret-"; //Dummy sdk key that works with local mode
private readonly StatsigServerOptions _options;
internal readonly ServerDriver ServerDriver;

/// <summary>
/// Creates new instance of <see cref="StatsigProvider"/>
/// </summary>
/// <param name="sdkKey">SDK Key to access Statsig.</param>
/// <param name="configurationAction">The action used to configure the client.</param>
public StatsigProvider(string sdkKey = null, Action<StatsigServerOptions> configurationAction = null)
/// <param name="statsigServerOptions">The StatsigServerOptions to configure the provider.</param>
public StatsigProvider(string sdkKey = null, StatsigServerOptions statsigServerOptions = null)
{
if (sdkKey != null)
{
_sdkKey = sdkKey;
}
_options = new StatsigServerOptions();
configurationAction?.Invoke(_options);
ServerDriver = new ServerDriver(_sdkKey, _options);
ServerDriver = new ServerDriver(_sdkKey, statsigServerOptions);
}

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using OpenFeature.Model;
using System.Threading.Tasks;
using Xunit;
using Statsig;
namespace OpenFeature.Contrib.Providers.Statsig.Test;

public class StatsigProviderTest
Expand All @@ -12,7 +13,7 @@ public class StatsigProviderTest

public StatsigProviderTest()
{
statsigProvider = new StatsigProvider("secret-", x => x.LocalMode = true);
statsigProvider = new StatsigProvider("secret-", new StatsigServerOptions() { LocalMode = true });
}

[Fact]
Expand Down
Loading