-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(logs): Added and refactored audience and feature variable evaluation logs #229
Conversation
@@ -126,7 +126,7 @@ public void TestIsUserInExperimentReturnsTrueIfAllAudiencesInANDConditionPass() | |||
{ "favorite_ice_cream", "walls" } | |||
}; | |||
|
|||
Assert.True(ExperimentUtils.IsUserInExperiment(Config, experiment, userAttributes, Logger)); | |||
Assert.True(ExperimentUtils.IsUserInExperiment(Config, experiment, userAttributes, "experiment", experiment.Key, Logger)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IsUserInExperiment
Please rename it.
@@ -120,7 +120,7 @@ public virtual Variation GetVariation(Experiment experiment, string userId, Proj | |||
} | |||
} | |||
|
|||
if (ExperimentUtils.IsUserInExperiment(config, experiment, filteredAttributes, Logger)) | |||
if (ExperimentUtils.IsUserInExperiment(config, experiment, filteredAttributes, "experiment", experiment.Key, Logger)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use const experiment
, don't pass string as it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mostly looks good. please rename method name and add AUDIENCE_FOR_EXPERIMENT and AUDIENCE_FOR_ROLLOUT as const.
OptimizelySDK/Optimizely.cs
Outdated
@@ -489,9 +489,9 @@ public virtual bool IsFeatureEnabled(string featureKey, string userId, UserAttri | |||
} | |||
|
|||
if (featureEnabled == true) | |||
Logger.Log(LogLevel.INFO, $@"Feature flag ""{featureKey}"" is enabled for user ""{userId}""."); | |||
Logger.Log(LogLevel.INFO, $@"Feature ""{featureKey}"" is enabled for user ""{userId}""."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following logs doesn't seem correct to me.
} | ||
else | ||
{ | ||
Logger.Log(LogLevel.INFO, $@"Feature ""{featureKey}"" is not enabled for user {userId}. Returning default value for variable ""{variableKey}""."); | ||
Logger.Log(LogLevel.INFO, $@"Feature ""{featureKey}"" is not enabled for user {userId}. Returning the default variable value ""{variableValue}""."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Feature "%s" is not enabled for user "%s". '
'Returning the default variable value "%s".' % (feature_key, user_id, variable_value)
)```
OptimizelySDK/Optimizely.cs
Outdated
@@ -569,11 +569,11 @@ public virtual bool IsFeatureEnabled(string featureKey, string userId, UserAttri | |||
if (variation.FeatureEnabled == true) | |||
{ | |||
variableValue = featureVariableUsageInstance.Value; | |||
Logger.Log(LogLevel.INFO, $@"Returning variable value ""{variableValue}"" for variation ""{variation.Key}"" of feature flag ""{featureKey}""."); | |||
Logger.Log(LogLevel.INFO, $@"Feature ""{featureKey}"" is enabled for user ""{userId}""."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Got variable value "%s" for variable "%s" of feature flag "%s".'
% (variable_value, variable_key, feature_key)
)```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small changes needed. Looks good mostly.
@@ -81,15 +81,15 @@ public void TestValidateJsonSchemaNoJsonContent() | |||
[Test] | |||
public void TestIsUserInExperimentNoAudienceUsedInExperiment() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of the method has changed to: DoesUserMeetAudienceConditions
. Please update test names accordingly.
public const string AUDIENCE_FOR_EXPERIMENT = "experiment"; | ||
public const string AUDIENCE_FOR_RULE = "rule"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These variable names and the docstring above it do not make sense.
public static bool DoesUserMeetAudienceConditions(ProjectConfig config, | ||
Experiment experiment, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parameter descriptions above need to be updated.
public static bool DoesUserMeetAudienceConditions(ProjectConfig config, | ||
Experiment experiment, | ||
UserAttributes userAttributes, | ||
string audienceFor, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
audienceFor
? Why not something like loggingKeyType
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Small change needed in docstring.
@@ -42,11 +42,13 @@ public static bool IsExperimentActive(Experiment experiment, ILogger logger) | |||
/// <param name="config">ProjectConfig Configuration for the project</param> | |||
/// <param name="experiment">Experiment Entity representing the experiment</param> | |||
/// <param name="userAttributes">Attributes of the user. Defaults to empty attributes array if not provided</param> | |||
/// <param name="loggingKeyType">It can be either experiment or rule.</param> | |||
/// <param name="loggingKey">In case of loggingKeyType is experiment it will be experiment key or else it will be rule number.</param> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit. In case loggingKeyType is experiment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Summary
Test plan
added unit tests must pass and all FSC scenarios should pass