Skip to content
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

Add support for sending flag decisions along with decision metadata. #292

Merged
merged 16 commits into from
Oct 12, 2020

Conversation

mikecdavis
Copy link
Contributor

@mikecdavis mikecdavis commented Aug 28, 2020

Summary

  • Add experiment/feature flag key, variation key and type to impression events.
  • Send events for ALL decision types.
  • Add Metadata field to EventBatch.Decisions to capture flag type, key and variation key.

This change outline the proposed logical and structural changes required to support capturing all decision instances. The new eventbatch field is backwards compatible with the current pipeline.

@mikecdavis mikecdavis added the RFP Request for proposal label Aug 28, 2020
@mikecdavis mikecdavis requested a review from a team as a code owner August 28, 2020 20:40
@mikecdavis mikecdavis added RFC Request for Comments and removed RFP Request for proposal labels Aug 28, 2020
@mikecdavis mikecdavis changed the title [RFP] Add support for decision metadata. [RFC] Add support for decision metadata. Sep 2, 2020
@mikecdavis mikecdavis removed the RFC Request for Comments label Sep 21, 2020
@mikecdavis mikecdavis changed the title [RFC] Add support for decision metadata. Add support for sending flag decisions along with decision metadata. Sep 21, 2020

var variationID string
if variation != nil {
metadata["VARIAITON_KEY"] = variation.Key
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: should be VARIATION_KEY

Copy link
Contributor Author

@mikecdavis mikecdavis Sep 22, 2020

Choose a reason for hiding this comment

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

We've exposed the flaw behind open-ended maps :P

}

// CreateImpressionUserEvent creates and returns ImpressionEvent for user
func CreateImpressionUserEvent(projectConfig config.ProjectConfig, experiment entities.Experiment,
variation entities.Variation,
userContext entities.UserContext) UserEvent {
variation *entities.Variation, userContext entities.UserContext, flagKey, flagType string) (UserEvent, bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

ٍvariation *entities.Variation won't it break existing apps? e.g. Agent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, this is public only due to our package structure and is technically should be a private function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FWIW, Agent does not call this directly

Copy link
Contributor

Choose a reason for hiding this comment

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

got it.

EntityID string `json:"entity_id"`
ExperimentID string `json:"experiment_id"`
Key string `json:"key"`
Metadata map[string]string `json:"metadata"`
Copy link
Contributor

Choose a reason for hiding this comment

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

strictly typed representation would be great here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 I've replaced this with a struct

Copy link
Contributor

@msohailhussain msohailhussain left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@pawels-optimizely pawels-optimizely left a comment

Choose a reason for hiding this comment

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

lgtm

type DecisionMetadata struct {
FlagType string `json:"flag_type"`
FlagKey string `json:"flag_key"`
VariationKey string `json:"variation_key"`
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be defined with omitempty since this is an optional value?

Suggested change
VariationKey string `json:"variation_key"`
VariationKey string `json:"variation_key,omitempty"`

@pawels-optimizely pawels-optimizely merged commit 754558b into master Oct 12, 2020
@pawels-optimizely pawels-optimizely deleted the mikecdavis/flag-decisions branch October 12, 2020 21:43
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.

5 participants