OpenFeature.Contrib.Provider.Statsig 0.0.3-preview

Prefix Reserved
Suggested Alternatives

OpenFeature.Contrib.Providers.Statsig

This is a prerelease version of OpenFeature.Contrib.Provider.Statsig.
dotnet add package OpenFeature.Contrib.Provider.Statsig --version 0.0.3-preview                
NuGet\Install-Package OpenFeature.Contrib.Provider.Statsig -Version 0.0.3-preview                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OpenFeature.Contrib.Provider.Statsig" Version="0.0.3-preview" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OpenFeature.Contrib.Provider.Statsig --version 0.0.3-preview                
#r "nuget: OpenFeature.Contrib.Provider.Statsig, 0.0.3-preview"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.