Skip to content

Commit

Permalink
Merge branch 'main' into feat/add-configcat-provider
Browse files Browse the repository at this point in the history
Signed-off-by: Luiz Bon <292532+luizbon@users.noreply.github.com>
  • Loading branch information
luizbon authored Dec 21, 2023
2 parents f4d16fe + 500cfe4 commit 257a3db
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"src/OpenFeature.Contrib.Hooks.Otel": "0.1.2",
"src/OpenFeature.Contrib.Providers.Flagd": "0.1.7",
"src/OpenFeature.Contrib.Providers.GOFeatureFlag": "0.1.4",
"src/OpenFeature.Contrib.Providers.Flagsmith": "0.1.4",
"src/OpenFeature.Contrib.Providers.Flagsmith": "0.1.5",
"src/OpenFeature.Contrib.Providers.ConfigCat": "0.0.1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
</AssemblyAttribute>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<PackageReference Include="System.Net.Http.WinHttpHandler" Version="7.0.0" />
<PackageReference Include="System.Net.Http.WinHttpHandler" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<!-- The schema.proto file referenced here will be used to automatically generate the Grpc client when executing 'dotnet build' -->
<!-- The generated files will be placed in ./obj/Debug/netstandard2.0/Protos -->
<Protobuf Include="schemas\protobuf\schema\v1\schema.proto" GrpcServices="Client" />
<PackageReference Include="Google.Protobuf" Version="3.23.4" />
<PackageReference Include="Grpc.Net.Client" Version="2.59.0" />
<PackageReference Include="Grpc.Tools" Version="2.59.0">
<PackageReference Include="Grpc.Tools" Version="2.60.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
7 changes: 7 additions & 0 deletions src/OpenFeature.Contrib.Providers.Flagsmith/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [0.1.5](https://github.com/open-feature/dotnet-sdk-contrib/compare/OpenFeature.Contrib.Providers.Flagsmith-v0.1.4...OpenFeature.Contrib.Providers.Flagsmith-v0.1.5) (2023-12-21)


### 🐛 Bug Fixes

* do not send targeting key as separate trait in flagsmith ([#120](https://github.com/open-feature/dotnet-sdk-contrib/issues/120)) ([0725f8f](https://github.com/open-feature/dotnet-sdk-contrib/commit/0725f8f3c726c05a6ccd2580f04b896f0aff4810))

## [0.1.4](https://github.com/open-feature/dotnet-sdk-contrib/compare/OpenFeature.Contrib.Providers.Flagsmith-v0.1.3...OpenFeature.Contrib.Providers.Flagsmith-v0.1.4) (2023-11-28)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ private Task<IFlags> GetFlags(EvaluationContext ctx)

return string.IsNullOrEmpty(key)
? _flagsmithClient.GetEnvironmentFlags()
: _flagsmithClient.GetIdentityFlags(key, ctx.AsDictionary().Select(x => new Trait(x.Key, x.Value.AsObject) as ITrait).ToList());
: _flagsmithClient.GetIdentityFlags(key, ctx
.AsDictionary()
.Where(x => x.Key != Configuration.TargetingKey)
.Select(x => new Trait(x.Key, x.Value.AsObject) as ITrait)
.ToList());
}

private async Task<ResolutionDetails<T>> ResolveValue<T>(string flagKey, T defaultValue, TryParseDelegate<T> tryParse, EvaluationContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
/// </summary>
public class FlagsmithProviderConfiguration : IFlagsmithProviderConfiguration
{
/// <summary>
/// Default value for targeting key
/// </summary>
public const string DefaultTargetingKey = "targetingKey";

/// <summary>
/// Key that will be used as identity for Flagsmith requests. Default: "targetingKey"
/// </summary>
public string TargetingKey { get; set; } = "targetingKey";
public string TargetingKey { get; set; } = DefaultTargetingKey;

/// <inheritdoc/>
public bool UsingBooleanConfigValue { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard20</TargetFrameworks>
<PackageId>OpenFeature.Contrib.Providers.Flagsmith</PackageId>
<VersionNumber>0.1.4</VersionNumber> <!--x-release-please-version -->
<VersionNumber>0.1.5</VersionNumber> <!--x-release-please-version -->
<Version>$(VersionNumber)</Version>
<AssemblyVersion>$(VersionNumber)</AssemblyVersion>
<FileVersion>$(VersionNumber)</FileVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/OpenFeature.Contrib.Providers.Flagsmith/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.4
0.1.5
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="7.0.4" />
<PackageReference Include="System.Text.Json" Version="8.0.0" />
</ItemGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public async Task GetValue_ForEnabledFeatureWithEvaluationContext_ReturnCorrectV
var date = DateTime.Now;
flags.GetFeatureValue("example-feature").Returns("true");
flags.IsFeatureEnabled("example-feature").Returns(true);
flagsmithClient.GetIdentityFlags("233", Arg.Is<List<ITrait>>(x => x.Count == 7 && x.Any(c => c.GetTraitKey() == "key1"))).Returns(flags);
flagsmithClient.GetIdentityFlags("233", Arg.Is<List<ITrait>>(x => x.Count == 6 && x.Any(c => c.GetTraitKey() == "key1"))).Returns(flags);

var providerConfig = GetDefaultFlagsmithProviderConfigurationConfiguration();
var flagsmithProvider = new FlagsmithProvider(providerConfig, flagsmithClient);
Expand All @@ -77,7 +77,7 @@ public async Task GetValue_ForEnabledFeatureWithEvaluationContext_ReturnCorrectV
.Set("key4", date)
.Set("key5", Structure.Empty)
.Set("key6", 1.0)
.Set("targetingKey", "233");
.Set(FlagsmithProviderConfiguration.DefaultTargetingKey, "233");
// Act
var result = await flagsmithProvider.ResolveBooleanValue("example-feature", false, contextBuilder.Build());

Expand Down

0 comments on commit 257a3db

Please sign in to comment.