private bool IsActive( string name, User user, Func <ABTestEnrollment, int> getTestBucket, Func <IABTestConfiguration, int> getTestPercentage) { var isAuthenticated = user != null; var authStatus = isAuthenticated ? "authenticated" : "anonymous"; const string inactive = "inactive"; const string active = "active"; if (!_cookieComplianceService.CanWriteNonEssentialCookies(_httpContext.Request)) { _logger.LogInformation( "A/B test {Name} is {TestStatus} for an {AuthStatus} user due to no cookie consent.", name, inactive, authStatus); return(false); } if (!_featureFlagService.IsABTestingEnabled(user)) { _logger.LogInformation( "A/B test {Name} is {TestStatus} for an {AuthStatus} user due to the general A/B testing " + "feature flag.", name, inactive, authStatus); return(false); } var testBucket = getTestBucket(Enrollment); var testPercentage = getTestPercentage(Config); var isActive = testBucket <= testPercentage; _telemetryService.TrackABTestEvaluated( name, isActive, isAuthenticated, testBucket, testPercentage); _logger.LogInformation( "A/B test {Name} is {TestStatus} for an {AuthStatus} user due to enrollment value " + "{EnrollmentValue} and config value {ConfigValue}.", name, isActive ? active : inactive, authStatus, testBucket, testPercentage); return(isActive); }