Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ func (o *OptimizelyClient) decide(userContext *OptimizelyUserContext, key string
decisionContext.Variable = entities.Variable{}
var featureDecision decision.FeatureDecision
var reasons decide.DecisionReasons
var experimentID string
var variationID string

// To avoid cyclo-complexity warning
findRegularDecision := func() {
Expand Down Expand Up @@ -210,6 +212,8 @@ func (o *OptimizelyClient) decide(userContext *OptimizelyUserContext, key string
if featureDecision.Variation != nil {
variationKey = featureDecision.Variation.Key
flagEnabled = featureDecision.Variation.FeatureEnabled
experimentID = featureDecision.Experiment.ID
variationID = featureDecision.Variation.ID
}

if !allOptions.DisableDecisionEvent {
Expand All @@ -230,7 +234,7 @@ func (o *OptimizelyClient) decide(userContext *OptimizelyUserContext, key string
ruleKey := featureDecision.Experiment.Key

if o.notificationCenter != nil {
decisionNotification := decision.FlagNotification(key, variationKey, ruleKey, flagEnabled, eventSent, usrContext, variableMap, reasonsToReport)
decisionNotification := decision.FlagNotification(key, variationKey, ruleKey, experimentID, variationID, flagEnabled, eventSent, usrContext, variableMap, reasonsToReport)
o.logger.Debug(fmt.Sprintf(`Feature %q is enabled for user %q? %v`, key, usrContext.ID, flagEnabled))
if e := o.notificationCenter.Send(notification.Decision, *decisionNotification); e != nil {
o.logger.Warning("Problem with sending notification")
Expand Down
4 changes: 4 additions & 0 deletions pkg/client/optimizely_user_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,8 @@ func (s *OptimizelyUserContextTestSuite) TestDecisionNotification() {
enabled := true
variablesExpected, err := s.OptimizelyClient.GetAllFeatureVariables(flagKey, entities.UserContext{ID: s.userID})
s.Nil(err)
experimentId := "10420810910"
variationId := "10418551353"

ruleKey := "exp_no_audience"
reasons := []string{}
Expand All @@ -839,6 +841,8 @@ func (s *OptimizelyUserContextTestSuite) TestDecisionNotification() {
"ruleKey": ruleKey,
"reasons": reasons,
"decisionEventDispatched": true,
"experimentId": experimentId,
"variationId": variationId,
}
s.OptimizelyClient.DecisionService.OnDecision(callback)
_ = user.Decide(flagKey, nil)
Expand Down
4 changes: 3 additions & 1 deletion pkg/decision/flag_notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
)

// FlagNotification constructs default flag notification
func FlagNotification(flagKey, variationKey, ruleKey string, enabled, decisionEventDispatched bool, userContext entities.UserContext, variables map[string]interface{}, reasons []string) *notification.DecisionNotification {
func FlagNotification(flagKey, variationKey, ruleKey, experimentID, variationID string, enabled, decisionEventDispatched bool, userContext entities.UserContext, variables map[string]interface{}, reasons []string) *notification.DecisionNotification {

if flagKey == "" {
return nil
Expand All @@ -37,6 +37,8 @@ func FlagNotification(flagKey, variationKey, ruleKey string, enabled, decisionEv
"ruleKey": ruleKey,
"reasons": reasons,
"decisionEventDispatched": decisionEventDispatched,
"experimentId": experimentID,
"variationId": variationID,
}

decisionNotification := &notification.DecisionNotification{
Expand Down