OpenFeature.Contrib.Providers.Statsig
0.0.8
Prefix Reserved
See the version list below for details.
dotnet add package OpenFeature.Contrib.Providers.Statsig --version 0.0.8
NuGet\Install-Package OpenFeature.Contrib.Providers.Statsig -Version 0.0.8
<PackageReference Include="OpenFeature.Contrib.Providers.Statsig" Version="0.0.8" />
paket add OpenFeature.Contrib.Providers.Statsig --version 0.0.8
#r "nuget: OpenFeature.Contrib.Providers.Statsig, 0.0.8"
// Install OpenFeature.Contrib.Providers.Statsig as a Cake Addin #addin nuget:?package=OpenFeature.Contrib.Providers.Statsig&version=0.0.8 // Install OpenFeature.Contrib.Providers.Statsig as a Cake Tool #tool nuget:?package=OpenFeature.Contrib.Providers.Statsig&version=0.0.8
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
Requirements
- open-feature/dotnet-sdk v1.5 > v2.0
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.Providers.Statsig
Package Manager
NuGet\Install-Package OpenFeature.Contrib.Providers.Statsig
Package Reference
<PackageReference Include=" OpenFeature.Contrib.Providers.Statsig" />
Packet cli
paket add OpenFeature.Contrib.Providers.Statsig
Cake
// Install OpenFeature.Contrib.Providers.Statsig as a Cake Addin
#addin nuget:?package= OpenFeature.Contrib.Providers.Statsig
// Install OpenFeature.Contrib.Providers.Statsig as a Cake Tool
#tool nuget:?package= OpenFeature.Contrib.Providers.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.Providers.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);
var eb = EvaluationContext.Builder();
eb.SetTargetingKey("john@doe.acme");
IFeatureClient client = Api.Instance.GetClient(context: eb.Build());
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 StatsigServerOptions
object to the constructor.
var statsigProvider = new StatsigProvider("#YOUR-SDK-KEY#", new StatsigServerOptions() { 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 now
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 is compatible. 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 && < 2.0.0)
- Statsig (>= 1.26.0)
-
.NETStandard 2.0
- OpenFeature (> 1.5.0 && < 2.0.0)
- Statsig (>= 1.26.0)
-
net5.0
- OpenFeature (> 1.5.0 && < 2.0.0)
- Statsig (>= 1.26.0)
-
net6.0
- OpenFeature (> 1.5.0 && < 2.0.0)
- Statsig (>= 1.26.0)
-
net7.0
- OpenFeature (> 1.5.0 && < 2.0.0)
- Statsig (>= 1.26.0)
-
net8.0
- OpenFeature (> 1.5.0 && < 2.0.0)
- Statsig (>= 1.26.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.1.0 | 137 | 8/22/2024 |
0.0.9 | 128 | 8/21/2024 |
0.0.8 | 128 | 8/20/2024 |
0.0.7 | 101 | 6/24/2024 |
0.0.6 | 1,514 | 6/9/2024 |
0.0.5-preview | 207 | 5/13/2024 |
0.0.4-preview | 194 | 4/16/2024 |