Skip to content

feat(api): Feature variable APIs now return default variable value when featureEnabled property is false. #276

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

Merged
merged 7 commits into from
Apr 4, 2019

Conversation

mnoman09
Copy link
Contributor

Summary

  • Feature variable APIs now return default variable value when featureEnabled property is false.

Test plan

Added unit tests.

@mnoman09 mnoman09 requested a review from aliabbasrizvi March 26, 2019 11:51
@aliabbasrizvi aliabbasrizvi requested a review from a team March 26, 2019 17:55
genericUserId,
Collections.singletonMap(ATTRIBUTE_HOUSE_KEY, AUDIENCE_SLYTHERIN_VALUE)),
Math.PI, 2);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. Remove this extraneous line.

genericUserId,
Collections.singletonMap(ATTRIBUTE_HOUSE_KEY, AUDIENCE_GRYFFINDOR_VALUE)),
(long) expectedValue);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. Remove this extraneous line.

@@ -649,7 +649,7 @@ String getFeatureVariableValueForType(@Nonnull String featureKey,
String variableValue = variable.getDefaultValue();
Map<String, ?> copiedAttributes = copyAttributes(attributes);
FeatureDecision featureDecision = decisionService.getVariationForFeature(featureFlag, userId, copiedAttributes);
if (featureDecision.variation != null) {
if (featureDecision.variation != null && featureDecision.variation.getFeatureEnabled()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar feedback as given in Ruby SDK. Here the log message is incorrect for the new scenario, as the user is bucketed into the variation, but because feature is disabled we return default value. Please fix log message corresponding to this scenario.

@aliabbasrizvi aliabbasrizvi requested a review from a team March 27, 2019 21:28
Copy link
Contributor

@aliabbasrizvi aliabbasrizvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review and revise docstrings. They seem to be inaccurate.

} else {
variableValue = variable.getDefaultValue();
logger.info("Feature \"{}\" for variation \"{}\" was not enabled. " +
"The default value \"{}\" for \"{}\" is being returned.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO mentioning variable key and value is too much information in log message. Just saying The default value is being returned. is enough here.

* returns the variable value of the variation the user is bucketed into
* if the variation is not null and the variable has a usage within the variation.
* returns the default variable value
* if the variation is not null featureEnabled is false.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. The docstring looks ill formatted. Please fix this.

Also, missing and. ...variation is not null and featureEnabled is false.

testUserId,
Collections.singletonMap(ATTRIBUTE_HOUSE_KEY, AUDIENCE_GRYFFINDOR_VALUE)),
expectedValue);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. extraneous line.

assertEquals(expectedValue, value);
}

/**
* Verify that the {@link Optimizely#getFeatureVariableString(String, String, String, Map)}
* notification listener of getFeatureVariableString is called when feature is in experiment and feature is true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does notification listener have to do with this change? Please fix docstring.


/**
* Verify that the {@link Optimizely#getFeatureVariableString(String, String, String, Map)}
* notification listener of getFeatureVariableString is called when feature is in experiment and feature enabled is false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@mnoman09 mnoman09 requested a review from aliabbasrizvi March 28, 2019 16:20
Copy link
Contributor

@aliabbasrizvi aliabbasrizvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@coveralls
Copy link

Pull Request Test Coverage Report for Build 940

  • 8 of 8 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 89.049%

Totals Coverage Status
Change from base Build 929: 0.01%
Covered Lines: 2651
Relevant Lines: 2977

💛 - Coveralls

1 similar comment
@coveralls
Copy link

Pull Request Test Coverage Report for Build 940

  • 8 of 8 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 89.049%

Totals Coverage Status
Change from base Build 929: 0.01%
Covered Lines: 2651
Relevant Lines: 2977

💛 - Coveralls

@aliabbasrizvi aliabbasrizvi merged commit dfdcf2a into master Apr 4, 2019
@aliabbasrizvi aliabbasrizvi deleted the mnoman/returnDefaultFeatEnabFalse branch April 4, 2019 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants