Promact.FeatureFlagService.PostHog 1.0.0

dotnet add package Promact.FeatureFlagService.PostHog --version 1.0.0
                    
NuGet\Install-Package Promact.FeatureFlagService.PostHog -Version 1.0.0
                    
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="Promact.FeatureFlagService.PostHog" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Promact.FeatureFlagService.PostHog" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Promact.FeatureFlagService.PostHog" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Promact.FeatureFlagService.PostHog --version 1.0.0
                    
#r "nuget: Promact.FeatureFlagService.PostHog, 1.0.0"
                    
#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.
#:package Promact.FeatureFlagService.PostHog@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Promact.FeatureFlagService.PostHog&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Promact.FeatureFlagService.PostHog&version=1.0.0
                    
Install as a Cake Tool

FeatureFlagService

Generic feature flag service implementation for checking flag state via different providers (PostHog, LaunchDarkly, Unleash).

Usage

IFeatureFlagService lives in the Promact.FeatureFlag namespace (the core package).

using Promact.FeatureFlag;

private IFeatureFlagService _featureFlagService;

public async Task MyMethod()
{
    var isEnabled = await _featureFlagService.IsFeatureEnabledAsync("my-feature-flag");

    if (isEnabled)
    {
        // ...
    }
}

PostHog

Add nuget package

Promact.FeatureFlagService.PostHog

ASP.NET Core projects

Add below in Program.cs (or Startup.cs inside ConfigureServices)

services.AddPostHogFeatureFlagService(options =>
{
    options.ApiKey = configuration["PostHog:ApiKey"];
    options.Host = configuration["PostHog:Host"];
    options.ProjectId = int.Parse(configuration["PostHog:ProjectId"]);
});

Add relevant appsettings.json values

"PostHog": {
  "ApiKey": "",
  "Host": "",
  "ProjectId": 0
}

Inject IFeatureFlagService in class constructor from where you want to check flags

public MyClass(IFeatureFlagService featureFlagService)
{
...
}

LaunchDarkly

Add nuget package

Promact.FeatureFlagService.LaunchDarkly

ASP.NET Core projects

Add below in Program.cs (or Startup.cs inside ConfigureServices)

services.AddLaunchDarklyFeatureFlagService(options =>
{
    options.SdkKey = configuration["LaunchDarkly:SdkKey"];
    options.Environment = configuration["LaunchDarkly:Environment"];
});

Add relevant appsettings.json values

"LaunchDarkly": {
  "SdkKey": "",
  "Environment": ""
}

By default, the per-request LaunchDarkly user context (user key, email, subscription) is built from well-known claim types on the current HttpContext. If your app uses different claim types, supply your own factory:

services.AddLaunchDarklyFeatureFlagService(options =>
{
    options.SdkKey = configuration["LaunchDarkly:SdkKey"];
    options.Environment = configuration["LaunchDarkly:Environment"];
    options.UserContextFactory = provider =>
    {
        var httpContext = provider.GetRequiredService<IHttpContextAccessor>().HttpContext;
        return new LaunchDarklyUserContextDetails
        {
            UserKey = httpContext?.User.FindFirst("sub")?.Value ?? "anonymous",
            Email = httpContext?.User.FindFirst("email")?.Value ?? "",
            Subscription = httpContext?.User.FindFirst("subscription")?.Value ?? "Basic",
        };
    };
});

Set options.Offline = true in tests or local development to avoid contacting LaunchDarkly's servers -- every flag then evaluates to its default value.

Inject IFeatureFlagService in class constructor from where you want to check flags

public MyClass(IFeatureFlagService featureFlagService)
{
...
}

Unleash

Add nuget package

Promact.FeatureFlagService.Unleash

ASP.NET Core projects

Add below in Program.cs (or Startup.cs inside ConfigureServices)

services.AddUnleashFeatureFlagService(options =>
{
    options.AppName = configuration["Unleash:AppName"];
    options.Environment = configuration["Unleash:Environment"];
    options.UnleashApi = configuration["Unleash:APIUrl"];
    options.ApiToken = configuration["Unleash:ApiToken"];
});

Add relevant appsettings.json values

"Unleash": {
  "AppName": "",
  "Environment": "",
  "APIUrl": "",
  "ApiToken": ""
}

Inject IFeatureFlagService in class constructor from where you want to check flags

public MyClass(IFeatureFlagService featureFlagService)
{
...
}

Unleash also supports subscription-level flag checks, which aren't part of the shared IFeatureFlagService contract -- inject the concrete UnleashFeatureFlagService directly:

public MyClass(UnleashFeatureFlagService unleashFeatureFlagService)
{
...
}

var isEnabledForSubscription = await unleashFeatureFlagService.IsFeatureForSubscriptionEnabledAsync("my-feature-flag");

By default, the subscription context (user id, subscription level) is built from well-known claim types on the current HttpContext. Supply your own factory via options.SubscriptionContextFactory if your app uses different claim types.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows 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
1.0.0 99 7/25/2026
1.0.0-beta-1.0.0 51 7/25/2026