Skip to content

Conversation

@yasirfolio3
Copy link
Contributor

@yasirfolio3 yasirfolio3 commented Aug 31, 2021

Summary

The following new public properties are added to OptimizelyConfig:

  • sdkKey
  • environmentKey
  • attributes
  • audiences
  • events
  • experimentRules and deliveryRules to OptimizelyFeature
  • audiences to OptimizelyExperiment

Test plan

All FSC tests OPTIMIZELY_CONFIG_V2 tests should pass.
FSC OptimizelyConfig link

Dependent PR

https://github.com/optimizely/fullstack-sdk-compatibility-suite/pull/526

Issues

Here's the simple snippet when you will run multiple times, it will give you different result. Maps are randomly picked.

package main

import (
	"fmt"
)

func main() {
	m := map[string]int {
	  "key1": 1,
	  "key6": 6,
	  "key4": 4,
	  "key3": 3,
	  "key7": 7,
	  "key2": 2,					
	}
	
	for key, val := range m {
		fmt.Println(key)
		fmt.Println(val)		
	}
	fmt.Println("Hello, playground")
}

https://stackoverflow.com/questions/55925822/why-are-iterations-over-maps-random


rolloutMap := mappers.MapRollouts(datafile.Rollouts)
rollouts, rolloutMap := mappers.MapRollouts(datafile.Rollouts)
events := []entities.Event{}
Copy link
Contributor

Choose a reason for hiding this comment

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

move this code to MapEvents?

featureMap := mappers.MapFeatures(datafile.FeatureFlags, rolloutMap, experimentMap)
features, featureMap := mappers.MapFeatures(datafile.FeatureFlags, rolloutMap, experimentMap)
attributes := []entities.Attribute{}
for _, attribute := range datafile.Attributes {
Copy link
Contributor

Choose a reason for hiding this comment

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

same here.

var json = jsoniter.ConfigCompatibleWithStandardLibrary

// GetDefaultOperators returns default conditional operators
func GetDefaultOperators() []string {
Copy link
Contributor

Choose a reason for hiding this comment

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

can't you directly assign instead of method.

@msohailhussain msohailhussain marked this pull request as ready for review August 31, 2021 17:28
@msohailhussain msohailhussain requested a review from a team as a code owner August 31, 2021 17:28
conditionTree, err := buildConditionTree(audience.Conditions)
if err != nil {
// @TODO: handle error
func() {}() // cheat the linters

Choose a reason for hiding this comment

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

Should we clean this up maybe, while we are touching the audiences.?

// if audience condition is "NOT" then add "NOT" at start.
// Otherwise check if there is already audience id in serializedAudience
// then append condition between serializedAudience and item
if serializedAudience != "" || cond == "NOT" {
Copy link

@The-inside-man The-inside-man Aug 31, 2021

Choose a reason for hiding this comment

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

Should use a constant for the Operands here.

func evaluateSubAudience(subAudience, serializedAudience, cond *string) {
// Checks if sub audience is empty or not
if *subAudience != "" {
if *serializedAudience != "" || *cond == "NOT" {

Choose a reason for hiding this comment

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

Same comment here for the operands, then we can reuse the constants.

if experiment.AudienceConditions == nil {
return ""
}
return getSerializedAudiences(experiment.AudienceConditions, audiencesByID)

Choose a reason for hiding this comment

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

if getSerializedAudiences returns an empty string when experiment.AudienceConditions is nil then we dont need the first check here and can just use the getSerializedAudiences function.

Copy link

@The-inside-man The-inside-man left a comment

Choose a reason for hiding this comment

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

Overall LGTM just a few suggestions. Please see comments.

Copy link

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

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

Overall looks great. Some changes suggested.

dustin-sier
dustin-sier approved these changes Sep 1, 2021
Copy link

@dustin-sier dustin-sier left a comment

Choose a reason for hiding this comment

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

LGTM baring changes discussed

Copy link

@dustin-sier dustin-sier left a comment

Choose a reason for hiding this comment

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

This will approve it

Copy link

@jaeopt jaeopt left a comment

Choose a reason for hiding this comment

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

LGTM with nits

Comment on lines 31 to 37
tmpAttribute := entities.Attribute{
ID: attribute.ID,
Key: attribute.Key,
}
_, ok := attributeMap[attribute.ID]
if !ok {
attributeMap[attribute.ID] = entities.Attribute{
ID: attribute.ID,
Key: attribute.Key,
}
attributeMap[attribute.ID] = tmpAttribute
Copy link

Choose a reason for hiding this comment

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

What's the point of this change?

experimentGroupMap := map[string]string{"11111": "15"}

experiments, experimentKeyMap := MapExperiments(rawExperiments, experimentGroupMap)
experimentsId, experimentKeyMap := MapExperiments(rawExperiments, experimentGroupMap)
Copy link

Choose a reason for hiding this comment

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

"experimentsId" name misleading. Shouldn't it be experimentMap or experimentIdMap?

experimentGroupMap := map[string]string{"11111": "15"}

experiments, experimentKeyMap := MapExperiments(rawExperiments, experimentGroupMap)
experimentsIdMap, experimentKeyMap := MapExperiments(rawExperiments, experimentGroupMap)
Copy link

Choose a reason for hiding this comment

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

experimentIdMap? to be consistent with experimentKeyMap

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

@msohailhussain msohailhussain merged commit 9d97c16 into master Sep 3, 2021
@msohailhussain msohailhussain deleted the yasir/config-v2 branch September 3, 2021 18:41
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.

7 participants