OpenFeature.Contrib.Providers.Statsig 0.0.5-preview

Prefix Reserved
This is a prerelease version of OpenFeature.Contrib.Providers.Statsig.
There is a newer version of this package available.
See the version list below for details.
dotnet add package OpenFeature.Contrib.Providers.Statsig --version 0.0.5-preview                
NuGet\Install-Package OpenFeature.Contrib.Providers.Statsig -Version 0.0.5-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.Providers.Statsig" Version="0.0.5-preview" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OpenFeature.Contrib.Providers.Statsig --version 0.0.5-preview                
#r "nuget: OpenFeature.Contrib.Providers.Statsig, 0.0.5-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.Providers.Statsig as a Cake Addin
#addin nuget:?package=OpenFeature.Contrib.Providers.Statsig&version=0.0.5-preview&prerelease

// Install OpenFeature.Contrib.Providers.Statsig as a Cake Tool
#tool nuget:?package=OpenFeature.Contrib.Providers.Statsig&version=0.0.5-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.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 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.

Version Downloads Last updated
0.1.0 149 8/22/2024
0.0.9 137 8/21/2024
0.0.8 135 8/20/2024
0.0.7 110 6/24/2024
0.0.6 1,922 6/9/2024
0.0.5-preview 212 5/13/2024
0.0.4-preview 197 4/16/2024