-
Notifications
You must be signed in to change notification settings - Fork 19
feat(integrations): Added support for integrations in datafile and evaluation. #350
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(integrations): Added support for integrations in datafile and evaluation. #350
Conversation
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.
partial review. need to check matcher
conditions code.
@@ -7,7 +7,7 @@ import ( | |||
"fmt" | |||
"time" | |||
|
|||
"github.com/optimizely/go-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.
what's the need?
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 was forced by linter since we are using optimizely
keyword to access the package in the sample code.
@@ -160,3 +189,11 @@ func copyUserAttributes(attributes map[string]interface{}) (attributesCopy map[s | |||
} | |||
return attributesCopy | |||
} | |||
|
|||
func copyQualifiedSegments(qualifiedSegments []string) (qualifiedSegmentsCopy []string) { |
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.
need to check offline.
@@ -17,7 +17,7 @@ | |||
package client | |||
|
|||
import ( | |||
"io/ioutil" | |||
"os" |
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.
why this is changed?
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.
Suggested by linter as "io/ioutil
is now depreceated in go 1.16 onwards.
var hostForODP, publicKeyForODP string | ||
if len(datafile.Integrations) > 0 { | ||
integration := datafile.Integrations[0] | ||
if integration.Key == "odp" { |
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 seems weird, can we 'iterate
integrationsand check
odp, assign it and get out of
loop`
attributeMap, attributeKeyToIDMap := mappers.MapAttributes(datafile.Attributes) | ||
allExperiments := mappers.MergeExperiments(datafile.Experiments, datafile.Groups) | ||
groupMap, experimentGroupMap := mappers.MapGroups(datafile.Groups) | ||
experimentIDMap, experimentKeyMap := mappers.MapExperiments(allExperiments, experimentGroupMap) | ||
|
||
rollouts, rolloutMap := mappers.MapRollouts(datafile.Rollouts) | ||
integrations := mappers.MapIntegrations(datafile.Integrations) |
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.
is this map? integrationsMap?
) | ||
|
||
// MapIntegrations maps the raw datafile integration entities to SDK Integration entities | ||
func MapIntegrations(integrations []datafileEntities.Integration) (integrationsList []entities.Integration) { |
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 is not a map, simple list either return map
along with list
or no need of this method.
reasons := decide.NewDecisionReasons(options) | ||
if condition.Type != customAttributeType { | ||
isValid := false | ||
for _, validType := range validTypes { |
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.
why nchanged?
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 have two valid types that we support now, this can be seen here: https://github.com/optimizely/go-sdk/pull/350/files#diff-4b69e47626e15aedb2e8d1bb3b34fdb04fd57af036e7c00f9f968a5490d24750R35
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.
Looks great. A few changes suggested.
if qualifiedSegments == nil { | ||
qualifiedSegments = []string{} | ||
} |
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.
qualifiedSegments
are nullable. When null, it indicates non-determined (fetchSegments are not completed yet). Empty segments is valid one (fetchSegments returns an empty list).
@@ -46,6 +47,7 @@ func newOptimizelyUserContext(optimizely *OptimizelyClient, userID string, attri | |||
return OptimizelyUserContext{ | |||
UserID: userID, | |||
Attributes: attributesCopy, | |||
qualifiedSegments: []string{}, |
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.
Why passing empty array instead of a copy of current qualifiedSegments?
@@ -33,6 +33,8 @@ var datafileVersions = map[string]struct{}{ | |||
// DatafileProjectConfig is a project config backed by a datafile | |||
type DatafileProjectConfig struct { | |||
datafile string | |||
hostForODP string | |||
publicKeyForODP string |
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 see that a logic to get all segments used in datafile audiences is missing. We need it later when we call fetchSegments
. See https://github.com/optimizely/swift-sdk/blob/ec83c87d53b17ea58f8c73eb581b27fa52b6305c/Sources/Data%20Model/ProjectConfig.swift#L151
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 was originally holding it off for the next PR but have now implemented it in this one. Please have a look at the new changes.
2. Suggested changes made.
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
if err == nil { | ||
audience.ConditionTree = conditionTree | ||
} | ||
|
||
for _, s := range fSegments { |
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 add comments.
Summary
integrations
section of the datafileEvaluate()
using UserContextTest plan
Issues
FSSDK-8518