diff --git a/src/Core/Context/CurrentContext.cs b/src/Core/Context/CurrentContext.cs index cbbcb9f20480..e6461575360a 100644 --- a/src/Core/Context/CurrentContext.cs +++ b/src/Core/Context/CurrentContext.cs @@ -39,6 +39,7 @@ public class CurrentContext : ICurrentContext public virtual int? BotScore { get; set; } public virtual string ClientId { get; set; } public virtual Version ClientVersion { get; set; } + public virtual bool ClientVersionIsPrerelease { get; set; } public virtual IdentityClientType IdentityClientType { get; set; } public virtual Guid? ServiceAccountOrganizationId { get; set; } @@ -97,6 +98,11 @@ public async virtual Task BuildAsync(HttpContext httpContext, GlobalSettings glo { ClientVersion = cVersion; } + + if (httpContext.Request.Headers.TryGetValue("Is-Prerelease", out var clientVersionIsPrerelease)) + { + ClientVersionIsPrerelease = clientVersionIsPrerelease == "1"; + } } public async virtual Task BuildAsync(ClaimsPrincipal user, GlobalSettings globalSettings) diff --git a/src/Core/Context/ICurrentContext.cs b/src/Core/Context/ICurrentContext.cs index e3f737698614..3d3a5960b7e8 100644 --- a/src/Core/Context/ICurrentContext.cs +++ b/src/Core/Context/ICurrentContext.cs @@ -29,12 +29,13 @@ public interface ICurrentContext int? BotScore { get; set; } string ClientId { get; set; } Version ClientVersion { get; set; } + bool ClientVersionIsPrerelease { get; set; } + Task BuildAsync(HttpContext httpContext, GlobalSettings globalSettings); Task BuildAsync(ClaimsPrincipal user, GlobalSettings globalSettings); Task SetContextAsync(ClaimsPrincipal user); - Task OrganizationUser(Guid orgId); Task OrganizationAdmin(Guid orgId); Task OrganizationOwner(Guid orgId); diff --git a/src/Core/Services/Implementations/LaunchDarklyFeatureService.cs b/src/Core/Services/Implementations/LaunchDarklyFeatureService.cs index b65aa7525046..48d8fa122263 100644 --- a/src/Core/Services/Implementations/LaunchDarklyFeatureService.cs +++ b/src/Core/Services/Implementations/LaunchDarklyFeatureService.cs @@ -20,6 +20,7 @@ public class LaunchDarklyFeatureService : IFeatureService private const string _contextKindServiceAccount = "service-account"; private const string _contextAttributeClientVersion = "client-version"; + private const string _contextAttributeClientVersionIsPrerelease = "client-version-is-prerelease"; private const string _contextAttributeDeviceType = "device-type"; private const string _contextAttributeClientType = "client-type"; private const string _contextAttributeOrganizations = "organizations"; @@ -145,6 +146,7 @@ void SetCommonContextAttributes(ContextBuilder builder) if (_currentContext.ClientVersion != null) { builder.Set(_contextAttributeClientVersion, _currentContext.ClientVersion.ToString()); + builder.Set(_contextAttributeClientVersionIsPrerelease, _currentContext.ClientVersionIsPrerelease); } if (_currentContext.DeviceType.HasValue) diff --git a/test/Core.Test/Services/LaunchDarklyFeatureServiceTests.cs b/test/Core.Test/Services/LaunchDarklyFeatureServiceTests.cs index 08de8e320d71..35b5e4ea729d 100644 --- a/test/Core.Test/Services/LaunchDarklyFeatureServiceTests.cs +++ b/test/Core.Test/Services/LaunchDarklyFeatureServiceTests.cs @@ -24,6 +24,7 @@ private static SutProvider GetSutProvider(IGlobalSet var currentContext = Substitute.For(); currentContext.UserId.Returns(Guid.NewGuid()); currentContext.ClientVersion.Returns(new Version(AssemblyHelpers.GetVersion())); + currentContext.ClientVersionIsPrerelease.Returns(true); currentContext.DeviceType.Returns(Enums.DeviceType.ChromeBrowser); var client = Substitute.For();