-
Notifications
You must be signed in to change notification settings - Fork 32
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
feat(flag-decisions): Add support for sending flag decisions along with decision metadata. #405
Conversation
- Added unit tests
Pull Request Test Coverage Report for Build 1580
💛 - Coveralls |
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 address.
@@ -216,7 +216,7 @@ private Variation activate(@Nullable ProjectConfig projectConfig, | |||
return null; | |||
} | |||
|
|||
sendImpression(projectConfig, experiment, userId, copiedAttributes, variation); | |||
sendImpression(projectConfig, experiment, userId, copiedAttributes, variation, experiment.getKey(), "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.
please make experiment
const or enum
logger.info("Experiment has \"Launched\" status so not dispatching event during activation."); | ||
return; | ||
} | ||
@Nonnull Variation variation, |
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.
I will appreciate if you can add header doc because of no. of args.
return; | ||
} | ||
@Nonnull Variation variation, | ||
@Nonnull String flagKey, |
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.
it should be featureFlagKey or featureKey
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.
we are calling it flagKey and flagType in all other sdks. So should I change it in java-sdk?
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.
I like flagKey which we use in Decide-API
} | ||
@Nonnull Variation variation, | ||
@Nonnull String flagKey, | ||
@Nonnull String flagType) { |
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.
It should be featureSource,
@@ -386,16 +390,22 @@ private Boolean isFeatureEnabled(@Nonnull ProjectConfig projectConfig, | |||
FeatureDecision featureDecision = decisionService.getVariationForFeature(featureFlag, userId, copiedAttributes, projectConfig); | |||
Boolean featureEnabled = false; | |||
SourceInfo sourceInfo = new RolloutSourceInfo(); | |||
if (featureDecision.decisionSource != null) { |
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.
in which case, decisionSource can be null.
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.
when experiment and variation is null.
the cases are
- When The feature flag is not used in a rollout
- The rollout with id was not found in the datafile for feature flag
added documentation of sendImpression
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.
Can we have a test checking if impression event's meta data has null variationKey
when variation
is null.
core-api/src/main/java/com/optimizely/ab/event/internal/UserEventFactory.java
Show resolved
Hide resolved
String layerID = null; | ||
String experimentId = null; | ||
String experimentKey = null; | ||
if (activatedExperiment != null) { |
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.
This check for experiment shouldn't be required since it is already checked by the caller?
core-api/src/main/java/com/optimizely/ab/event/internal/payload/DecisionMetadata.java
Outdated
Show resolved
Hide resolved
set flagKey to empty in activate case
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
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
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.
Overall it looks good. Need some changes in tests and comments.
return; | ||
} | ||
@Nonnull Variation variation, | ||
@Nonnull String flagKey, |
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.
I like flagKey which we use in Decide-API
core-api/src/test/java/com/optimizely/ab/event/internal/UserEventFactoryTest.java
Outdated
Show resolved
Hide resolved
Variation variation = optimizely.activate(launchedExperiment.getKey(), testUserId); | ||
assertNotNull(variation); | ||
assertThat(variation.getKey(), is(expectedVariation.getKey())); | ||
eventHandler.expectImpression(launchedExperiment.getId(), expectedVariation.getId(), testUserId); |
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.
Not sure if I miss it, but I do not see validation of new metadata in expected events.
Updated userEventFactory create impression test to avoid sending experiment key as flag key in case of ruletype 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
Metadata
field to EventBatch.Decisions to capture flag type, key and variation key.Test plan