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 src/PostHog/Api/LocalEvaluationApiResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace PostHog.Api;

/// <summary>
/// The API Payload from the <c>/api/feature_flag/local_evaluation</c> endpoint used to evaluate feature flags
/// The API Payload from the <c>/flags/definitions</c> endpoint used to evaluate feature flags
/// locally.
/// </summary>
internal record LocalEvaluationApiResult
Expand Down
4 changes: 2 additions & 2 deletions src/PostHog/Api/PostHogApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public async Task<ApiResult> SendEventAsync(

/// <summary>
/// Retrieves all the feature flags for the project by making a request to the
/// <c>/api/feature_flag/local_evaluation</c> endpoint. This requires that a Personal API Key is set in
/// <c>/flags/definitions</c> endpoint. This requires that a Personal API Key is set in
/// <see cref="PostHogOptions"/>.
/// </summary>
/// <param name="etag">Optional ETag from a previous request for conditional fetching.</param>
Expand All @@ -155,7 +155,7 @@ public async Task<LocalEvaluationResponse> GetFeatureFlagsForLocalEvaluationAsyn
string? etag,
CancellationToken cancellationToken)
{
var uriBuilder = new UriBuilder(new Uri(HostUrl, "/api/feature_flag/local_evaluation"))
var uriBuilder = new UriBuilder(new Uri(HostUrl, "/flags/definitions"))
{
Query = $"token={Uri.EscapeDataString(ProjectApiKey)}&send_cohorts"
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static void AddRepeatedFlagsResponse(this FakeHttpMessageHandler handler,
public static void AddRepeatedFlagsResponse(this FakeHttpMessageHandler handler, int count, string responseBody)
=> handler.AddRepeatedFlagsResponse(count, _ => responseBody);

static readonly Uri LocalEvaluationUrl = new("https://us.i.posthog.com/api/feature_flag/local_evaluation?token=fake-project-api-key&send_cohorts");
internal static readonly Uri LocalEvaluationUrl = new("https://us.i.posthog.com/flags/definitions?token=fake-project-api-key&send_cohorts");

public static FakeHttpMessageHandler.RequestHandler AddLocalEvaluationResponse(
this FakeHttpMessageHandler handler,
Expand Down
6 changes: 3 additions & 3 deletions tests/UnitTests/Features/FeatureFlagsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3354,7 +3354,7 @@ public async Task ReturnsEmptyDictionaryWhenPersonalApiKeyIncorrect()
FeatureFlagPayloads = new Dictionary<string, string>(),
});
container.FakeHttpMessageHandler.AddResponse(
new Uri("https://us.i.posthog.com/api/feature_flag/local_evaluation?token=fake-project-api-key&send_cohorts"),
FakeHttpMessageHandlerExtensions.LocalEvaluationUrl,
HttpMethod.Get,
new HttpResponseMessage(HttpStatusCode.Unauthorized)
{
Expand Down Expand Up @@ -3510,7 +3510,7 @@ public async Task ReturnsEmptyDictionaryWhenLocalEvaluationQuotaExceeded()
// When local evaluation is quota limited, we do not want to fallback to /decide.
var decideHandler = container.FakeHttpMessageHandler.AddFlagsResponseException(new InvalidOperationException());
container.FakeHttpMessageHandler.AddResponse(
new Uri("https://us.i.posthog.com/api/feature_flag/local_evaluation?token=fake-project-api-key&send_cohorts"),
FakeHttpMessageHandlerExtensions.LocalEvaluationUrl,
HttpMethod.Get,
new HttpResponseMessage(HttpStatusCode.PaymentRequired)
{
Expand Down Expand Up @@ -3542,7 +3542,7 @@ public async Task ReturnsFalseWhenSingleFlagLocalEvaluationRequestQuotaExceeded(
var container = new TestContainer("fake-personal-api-key");
var decideHandler = container.FakeHttpMessageHandler.AddFlagsResponseException(new InvalidOperationException());
container.FakeHttpMessageHandler.AddResponse(
new Uri("https://us.i.posthog.com/api/feature_flag/local_evaluation?token=fake-project-api-key&send_cohorts"),
FakeHttpMessageHandlerExtensions.LocalEvaluationUrl,
HttpMethod.Get,
new HttpResponseMessage(HttpStatusCode.PaymentRequired)
{
Expand Down
3 changes: 1 addition & 2 deletions tests/UnitTests/Features/LocalFeatureFlagsLoaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public class TheDisposeAsyncMethod
}
""";

static readonly Uri LocalEvaluationUrl =
new("https://us.i.posthog.com/api/feature_flag/local_evaluation?token=fake-project-api-key&send_cohorts");
static readonly Uri LocalEvaluationUrl = FakeHttpMessageHandlerExtensions.LocalEvaluationUrl;

[Fact]
public async Task CompletesGracefullyDuringInFlightPoll()
Expand Down
4 changes: 2 additions & 2 deletions tests/UnitTests/PostHogClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1510,7 +1510,7 @@ public async Task RespectsCancellationToken()
{
var container = new TestContainer(personalApiKey: "fake-personal-api-key");
// Add a handler that will throw OperationCanceledException
var uri = new Uri("https://us.i.posthog.com/api/feature_flag/local_evaluation?token=fake-project-api-key&send_cohorts");
var uri = FakeHttpMessageHandlerExtensions.LocalEvaluationUrl;
container.FakeHttpMessageHandler.AddResponseException(uri, HttpMethod.Get, new OperationCanceledException());
var client = container.Activate<PostHogClient>();

Expand All @@ -1529,7 +1529,7 @@ public async Task DoesNotLogErrorForCancellation()
{
var container = new TestContainer(personalApiKey: "fake-personal-api-key");
// Add a handler that will throw OperationCanceledException
var uri = new Uri("https://us.i.posthog.com/api/feature_flag/local_evaluation?token=fake-project-api-key&send_cohorts");
var uri = FakeHttpMessageHandlerExtensions.LocalEvaluationUrl;
container.FakeHttpMessageHandler.AddResponseException(uri, HttpMethod.Get, new OperationCanceledException());
var client = container.Activate<PostHogClient>();

Expand Down
Loading