Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>1.0.2</Version>
<Version>1.0.3</Version>
<LangVersion>13.0</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
2 changes: 1 addition & 1 deletion samples/HogTied.Web/Pages/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
else {
<div class="alert alert-info mt-3" role="alert">
<strong>
The Project API Key (@Model.PostHogOptions.ProjectApiKey) is set pointing to
The Project API Key <code>@Model.PostHogOptions.ProjectApiKey</code> is set pointing to
<code>@Model.PostHogOptions.HostUrl!</code>
<br />We're ready to go!
</strong>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using PostHog.Features;

namespace PostHog.FeatureManagement;

internal static class FeatureManagementExtensions
{
public static async Task<LocalEvaluator?> GetLocalEvaluatorAsync(this IPostHogClient posthog, CancellationToken cancellationToken)
{
// Get the local evaluator from the PostHog client so that we can return a list of the feature flags.
// This makes me feel dirty, but I don't yet want to add a method to `IPostHogClient` for this just
// yet because I'll have to support it and I want time to think about it. For example, should it be
// IAsyncEnumerable or IReadOnlyList? Should it be a method on `IPostHogClient` or a separate interface?
Func<CancellationToken, Task<LocalEvaluator?>> getAsync = posthog is PostHogClient posthogClient
#pragma warning disable CS0618 // Type or member is obsolete: It's for our internal use only, so we're good.
? posthogClient.GetLocalEvaluatorAsync
#pragma warning restore CS0618 // Type or member is obsolete
: cancelToken =>
{
var method = typeof(PostHogClient).GetMethod("GetLocalEvaluatorAsync", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic, [typeof(CancellationToken)]);
return method?.Invoke(posthog, [cancelToken]) as Task<LocalEvaluator?>
?? Task.FromResult<LocalEvaluator?>(null);
};
return await getAsync(cancellationToken);
}
}
2 changes: 1 addition & 1 deletion src/PostHog/Generated/VersionConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ This is generated by an MSBuild task in PostHog.csproj
namespace PostHog.Versioning;
public static class VersionConstants
{
public const string Version = "1.0.2";
public const string Version = "1.0.3";
}
7 changes: 0 additions & 7 deletions src/PostHog/IPostHogClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,4 @@ Task<IReadOnlyDictionary<string, FeatureFlag>> GetAllFeatureFlagsAsync(
/// The version of this library.
/// </summary>
string Version { get; }

/// <summary>
/// Retrieves the local evaluator for evaluating feature flags locally.
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
internal Task<LocalEvaluator?> GetLocalEvaluatorAsync(CancellationToken cancellationToken);
}
5 changes: 4 additions & 1 deletion src/PostHog/PostHogClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,10 @@ async Task<IReadOnlyDictionary<string, FeatureFlag>> FetchDecideAsync()
/// <inheritdoc/>
public string Version => VersionConstants.Version;

async Task<LocalEvaluator?> IPostHogClient.GetLocalEvaluatorAsync(CancellationToken cancellationToken)
// HACK: Temporary hack until we come up with a better approach. This is to support Feature Management
// in the PostHog.AspNetCore package, which is why I don't want to make it public here.
[Obsolete("This method is for internal use only and may go away soon.")]
internal async Task<LocalEvaluator?> GetLocalEvaluatorAsync(CancellationToken cancellationToken)
{
try
{
Expand Down