Skip to content

Commit

Permalink
fixup! Support tracking
Browse files Browse the repository at this point in the history
Signed-off-by: christian.lutnik <[email protected]>
  • Loading branch information
chrfwow committed Dec 10, 2024
1 parent f3c1997 commit c8dc923
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/OpenFeature/OpenFeatureClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ private async Task TriggerFinallyHooksAsync<T>(IReadOnlyList<Hook> hooks, HookCo
/// <exception cref="ArgumentException">When trackingEventName is null or empty</exception>
public void Track(string trackingEventName, EvaluationContext? evaluationContext = default, TrackingEventDetails? trackingEventDetails = default)
{
if (string.IsNullOrEmpty(trackingEventName))
if (string.IsNullOrWhiteSpace(trackingEventName))
{
throw new ArgumentException("Tracking event cannot be null or empty.", nameof(trackingEventName));
}
Expand Down
10 changes: 10 additions & 0 deletions test/OpenFeature.Tests/OpenFeatureClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,16 @@ public async Task PassingAnEmptyStringAsTrackingEventName_ThrowsArgumentExceptio
Assert.Throws<ArgumentException>(() => client.Track(""));
}

[Fact]
public async Task PassingABlankStringAsTrackingEventName_ThrowsArgumentException()
{
var provider = new TestProvider();
await Api.Instance.SetProviderAsync(provider);
var client = Api.Instance.GetClient();

Assert.Throws<ArgumentException>(() => client.Track(" \n "));
}

public static TheoryData<string, EvaluationContext?, EvaluationContext?, EvaluationContext?, string> GenerateMergeEvaluationContextTestData()
{
const string key = "key";
Expand Down

0 comments on commit c8dc923

Please sign in to comment.