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

feat(OptimizelyConfig): add new fields to OptimizelyConfig #418

Merged
merged 14 commits into from
Jun 23, 2021

Conversation

jaeopt
Copy link
Collaborator

@jaeopt jaeopt commented Jun 17, 2021

The following new public properties are added to OptimizelyConfig:

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

@jaeopt jaeopt requested a review from a team as a code owner June 17, 2021 20:26
@jaeopt jaeopt removed their assignment Jun 17, 2021
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 89.781% when pulling 8d5def4 on jae/optconfig-v2 into 4b5565c on master.

@coveralls
Copy link

coveralls commented Jun 17, 2021

Coverage Status

Coverage decreased (-0.2%) to 89.781% when pulling d91c49c on jae/optconfig-v2 into 4b5565c on master.

Copy link
Contributor

@yasirfolio3 yasirfolio3 left a comment

Choose a reason for hiding this comment

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

Minor suggestions

case .logicalOp:
return ""
case .leaf(.audienceId(let audienceId)):
return "AUDIENCE(\(audienceId))"
Copy link
Contributor

Choose a reason for hiding this comment

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

can we have comments here to explain .leaf and .array cases? why these are required?

return "\(result)"
}

switch firstItem {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we have comments here?

var collect = false

var replaced = ""
for ch in 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 we have some comments here for explanation?

let updatedRollouts = projectConfig.project.rollouts.map { rollout -> Rollout in
let feature = project.featureFlags.filter({ $0.rolloutId == rollout.id }).first

var rollout = rollout
Copy link
Contributor

Choose a reason for hiding this comment

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

can we name this better? this is a bit confusing?

yasirfolio3
yasirfolio3 previously approved these changes Jun 22, 2021
Copy link
Contributor

@yasirfolio3 yasirfolio3 left a comment

Choose a reason for hiding this comment

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

LGTM, just some minor nits.

///
/// Examples:
/// - "123" => "AUDIENCE("123")"
/// - ["and", "123", "456"] => "AUDIENCE("123") AND (AUDIENCE("456")"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// - ["and", "123", "456"] => "AUDIENCE("123") AND (AUDIENCE("456")"
/// - ["and", "123", "456"] => "AUDIENCE("123") AND AUDIENCE("456")"

Comment on lines +104 to +106
} else {
return false
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not important but i think this would look cleaner.

Suggested change
} else {
return false
}
}
return false

}

// The first item of the array is supposed to be a logical op (and, or, not)
// extract it first and joined the rest of the array items with the logical op
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// extract it first and joined the rest of the array items with the logical op
// extract it first and join the rest of the array items with the logical op

// - copy feature's variable data to variables in all variations
// - serialize experiment audiences to a string

// prepare an audience [id: name] mapping for audicens serialization
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// prepare an audience [id: name] mapping for audicens serialization
// prepare an audience [id: name] mapping for audience serialization

{"id": "20348452263", "conditions": ["and", ["or", ["or", {"value": 18, "type": "custom_attribute", "name": "age", "match": "gt"}]]], "name": "adult"},
{"id": "20348352569", "conditions": ["and", ["or", ["or", {"value": 18, "type": "custom_attribute", "name": "age", "match": "lt"}]]], "name": "kid"}
],
"audiences": [
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have 1 or 2 unique audiences in both typedAudiences and audiences to verify if they are being merged correctly?

///
/// - Parameter string: before replacement
/// - Returns: string after replacement
func replaceAudienceIdsWithNames(string: String, audiencesMap: [String: String]) -> 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 we have unit test for this method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We have a unit test case covering this audience mapping -

func testAudiencesSerialization() {

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.

@jaeopt jaeopt merged commit c9b996a into master Jun 23, 2021
@jaeopt jaeopt deleted the jae/optconfig-v2 branch June 23, 2021 23:48
@@ -1,7 +1,65 @@
{
Copy link

Choose a reason for hiding this comment

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

optmizelyConfig is spelled wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants