-
Notifications
You must be signed in to change notification settings - Fork 32
feat: Add ODP Segments support in Audience Evaluation #474
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
Changes from all commits
2ba5621
6d1924a
0d9d3b8
a8d0c3f
b461f82
8ccd995
f449dda
a9c8d05
315a9c9
0469623
15bfe93
b8eaae1
eb2e8c8
1ba1b3e
9910be8
6af28aa
226d3ae
24396e9
12d92ee
889e405
29750c4
cc4ee31
4f61e54
99a7f0a
aad5d0b
c0f0284
d6ec898
5df10d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,6 +63,8 @@ public class DatafileProjectConfig implements ProjectConfig { | |
private final boolean anonymizeIP; | ||
private final boolean sendFlagDecisions; | ||
private final Boolean botFiltering; | ||
private final String hostForODP; | ||
private final String publicKeyForODP; | ||
Comment on lines
+66
to
+67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For acronyms in names, are we using |
||
private final List<Attribute> attributes; | ||
private final List<Audience> audiences; | ||
private final List<Audience> typedAudiences; | ||
|
@@ -71,6 +73,7 @@ public class DatafileProjectConfig implements ProjectConfig { | |
private final List<FeatureFlag> featureFlags; | ||
private final List<Group> groups; | ||
private final List<Rollout> rollouts; | ||
private final List<Integration> integrations; | ||
|
||
// key to entity mappings | ||
private final Map<String, Attribute> attributeKeyMapping; | ||
|
@@ -121,6 +124,7 @@ public DatafileProjectConfig(String accountId, String projectId, String version, | |
experiments, | ||
null, | ||
groups, | ||
null, | ||
null | ||
); | ||
} | ||
|
@@ -142,8 +146,8 @@ public DatafileProjectConfig(String accountId, | |
List<Experiment> experiments, | ||
List<FeatureFlag> featureFlags, | ||
List<Group> groups, | ||
List<Rollout> rollouts) { | ||
|
||
List<Rollout> rollouts, | ||
List<Integration> integrations) { | ||
this.accountId = accountId; | ||
this.projectId = projectId; | ||
this.version = version; | ||
|
@@ -182,6 +186,24 @@ public DatafileProjectConfig(String accountId, | |
allExperiments.addAll(aggregateGroupExperiments(groups)); | ||
this.experiments = Collections.unmodifiableList(allExperiments); | ||
|
||
String publicKeyForODP = ""; | ||
String hostForODP = ""; | ||
if (integrations == null) { | ||
this.integrations = Collections.emptyList(); | ||
} else { | ||
this.integrations = Collections.unmodifiableList(integrations); | ||
for (Integration integration: this.integrations) { | ||
if (integration.getKey().equals("odp")) { | ||
hostForODP = integration.getHost(); | ||
publicKeyForODP = integration.getPublicKey(); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
this.publicKeyForODP = publicKeyForODP; | ||
this.hostForODP = hostForODP; | ||
|
||
Map<String, Experiment> variationIdToExperimentMap = new HashMap<String, Experiment>(); | ||
for (Experiment experiment : this.experiments) { | ||
for (Variation variation : experiment.getVariations()) { | ||
|
@@ -448,6 +470,11 @@ public List<Audience> getTypedAudiences() { | |
return typedAudiences; | ||
} | ||
|
||
@Override | ||
public List<Integration> getIntegrations() { | ||
return integrations; | ||
} | ||
|
||
@Override | ||
public Audience getAudience(String audienceId) { | ||
return audienceIdMapping.get(audienceId); | ||
|
@@ -524,6 +551,16 @@ public Variation getFlagVariationByKey(String flagKey, String variationKey) { | |
return null; | ||
} | ||
|
||
@Override | ||
public String getHostForODP() { | ||
return hostForODP; | ||
} | ||
|
||
@Override | ||
public String getPublicKeyForODP() { | ||
return publicKeyForODP; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ProjectConfig{" + | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/** | ||
* | ||
* Copyright 2022, Optimizely and contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.optimizely.ab.config; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
import javax.annotation.concurrent.Immutable; | ||
|
||
/** | ||
* Represents the Optimizely Integration configuration. | ||
* | ||
* @see <a href="http://developers.optimizely.com/server/reference/index.html#json">Project JSON</a> | ||
*/ | ||
@Immutable | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class Integration { | ||
private final String key; | ||
private final String host; | ||
private final String publicKey; | ||
|
||
@JsonCreator | ||
public Integration(@JsonProperty("key") String key, | ||
@JsonProperty("host") String host, | ||
@JsonProperty("publicKey") String publicKey) { | ||
this.key = key; | ||
this.host = host; | ||
this.publicKey = publicKey; | ||
} | ||
|
||
@Nonnull | ||
public String getKey() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
return key; | ||
} | ||
|
||
@Nullable | ||
public String getHost() { return host; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
@Nullable | ||
public String getPublicKey() { return publicKey; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is nullable in java unless specified the other way round? |
||
|
||
@Override | ||
public String toString() { | ||
return "Integration{" + | ||
"key='" + key + '\'' + | ||
((this.host != null) ? (", host='" + host + '\'') : "") + | ||
((this.publicKey != null) ? (", publicKey='" + publicKey + '\'') : "") + | ||
'}'; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* | ||
* Copyright 2022, Optimizely and contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.optimizely.ab.config.audience; | ||
|
||
public enum AttributeType { | ||
CUSTOM_ATTRIBUTE("custom_attribute"), | ||
THIRD_PARTY_DIMENSION("third_party_dimension"); | ||
|
||
private final String key; | ||
|
||
AttributeType(String key) { | ||
this.key = key; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return key; | ||
} | ||
} |
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 macos?
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.
Because some tests were failing for no apparent reason on linux. we have changes it to macox for now. will fix it later as part of a separate ticket