OpenFeature.Contrib.Provider.Statsig
0.0.3-preview
Prefix Reserved
dotnet add package OpenFeature.Contrib.Provider.Statsig --version 0.0.3-preview
NuGet\Install-Package OpenFeature.Contrib.Provider.Statsig -Version 0.0.3-preview
<PackageReference Include="OpenFeature.Contrib.Provider.Statsig" Version="0.0.3-preview" />
paket add OpenFeature.Contrib.Provider.Statsig --version 0.0.3-preview
#r "nuget: OpenFeature.Contrib.Provider.Statsig, 0.0.3-preview"
// Install OpenFeature.Contrib.Provider.Statsig as a Cake Addin #addin nuget:?package=OpenFeature.Contrib.Provider.Statsig&version=0.0.3-preview&prerelease // Install OpenFeature.Contrib.Provider.Statsig as a Cake Tool #tool nuget:?package=OpenFeature.Contrib.Provider.Statsig&version=0.0.3-preview&prerelease
Statsig Feature Flag .NET Provider
The Statsig Flag provider allows you to connect to Statsig. Please note this is a minimal implementation - only ResolveBooleanValue
is implemented.
.Net SDK usage
Install dependencies
The first things we will do is install the Open Feature SDK and the Statsig Feature Flag provider.
.NET Cli
dotnet add package OpenFeature.Contrib.Provider.Statsig
Package Manager
NuGet\Install-Package OpenFeature.Contrib.Provider.Statsig
Package Reference
<PackageReference Include=" OpenFeature.Contrib.Provider.Statsig" />
Packet cli
paket add OpenFeature.Contrib.Provider.Statsig
Cake
// Install OpenFeature.Contrib.Provider.Statsig as a Cake Addin
#addin nuget:?package= OpenFeature.Contrib.Provider.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
The following example shows how to use the Statsig provider with the OpenFeature SDK.
using OpenFeature;
using OpenFeature.Contrib.Provider.Statsig;
using System;
StatsigProvider statsigProvider = new StatsigProvider("#YOUR-SDK-KEY#");
// Set the statsigProvider as the provider for the OpenFeature SDK
await Api.Instance.SetProviderAsync(statsigProvider);
IFeatureClient client = OpenFeature.Api.Instance.GetClient();
bool isMyAwesomeFeatureEnabled = await client.GetBooleanValue("isMyAwesomeFeatureEnabled", false);
if (isMyAwesomeFeatureEnabled)
{
Console.WriteLine("New Feature enabled!");
}
Customizing the Statsig Provider
The Statsig provider can be customized by passing a Action<StatsigServerOptions>
object to the constructor.
var statsigProvider = new StatsigProvider("#YOUR-SDK-KEY#", options => options.LocalMode = true);
For a full list of options see the Statsig documentation.
EvaluationContext and Statsig User relationship
Statsig has the concept of a StatsigUser where you can evaluate a flag based on properties. The OpenFeature SDK has the concept of an EvaluationContext which is a dictionary of string keys and values. The Statsig provider will map the EvaluationContext to a StatsigUser.
The following parameters are mapped to the corresponding Statsig pre-defined parameters
EvaluationContext Key | Statsig User Parameter |
---|---|
appVersion |
AppVersion |
country |
Country |
email |
Email |
ip |
Ip |
locale |
Locale |
userAgent |
UserAgent |
privateAttributes |
PrivateAttributes |
Known issues and limitations
Only
ResolveBooleanValue
implemented for nowGate BooleanEvaluation with default value true cannot fallback to true. https://github.com/statsig-io/dotnet-sdk/issues/33
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- OpenFeature (>= 1.5.0)
- Statsig (>= 1.24.0)
-
.NETStandard 2.0
- OpenFeature (>= 1.5.0)
- Statsig (>= 1.24.0)
-
net5.0
- OpenFeature (>= 1.5.0)
- Statsig (>= 1.24.0)
-
net6.0
- OpenFeature (>= 1.5.0)
- Statsig (>= 1.24.0)
-
net7.0
- OpenFeature (>= 1.5.0)
- Statsig (>= 1.24.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
0.0.3-preview | 175 | 4/3/2024 | |
0.0.2-preview | 137 | 3/14/2024 |