-
Notifications
You must be signed in to change notification settings - Fork 32
Add IP anonymization to event payload. #42
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 1 commit
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 |
|---|---|---|
|
|
@@ -58,6 +58,7 @@ public String toString() { | |
| private final String projectId; | ||
| private final String revision; | ||
| private final String version; | ||
| private final boolean anonymizeIP; | ||
| private final List<Group> groups; | ||
| private final List<Experiment> experiments; | ||
| private final List<Attribute> attributes; | ||
|
|
@@ -78,19 +79,20 @@ public String toString() { | |
|
|
||
| public ProjectConfig(String accountId, String projectId, String version, String revision, List<Group> groups, | ||
| List<Experiment> experiments, List<Attribute> attributes, List<EventType> eventType, | ||
| List<Audience> audiences) { | ||
| this(accountId, projectId, version, revision, groups, experiments, attributes, eventType, audiences, | ||
| List<Audience> audiences, boolean anonymizeIP) { | ||
|
||
| this(accountId, projectId, version, revision, groups, experiments, attributes, eventType, audiences, anonymizeIP, | ||
| null); | ||
| } | ||
|
|
||
| public ProjectConfig(String accountId, String projectId, String version, String revision, List<Group> groups, | ||
| List<Experiment> experiments, List<Attribute> attributes, List<EventType> eventType, | ||
| List<Audience> audiences, List<LiveVariable> liveVariables) { | ||
| List<Audience> audiences, boolean anonymizeIP, List<LiveVariable> liveVariables) { | ||
|
|
||
| this.accountId = accountId; | ||
| this.projectId = projectId; | ||
| this.version = version; | ||
| this.revision = revision; | ||
| this.anonymizeIP = anonymizeIP; | ||
|
|
||
| this.groups = Collections.unmodifiableList(groups); | ||
| List<Experiment> allExperiments = new ArrayList<Experiment>(); | ||
|
|
@@ -151,6 +153,10 @@ public String getRevision() { | |
| return revision; | ||
| } | ||
|
|
||
| public boolean getAnonymizeIP() { | ||
| return anonymizeIP; | ||
| } | ||
|
|
||
| public List<Group> getGroups() { | ||
| return groups; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,12 +31,13 @@ public class Conversion extends Event { | |
| private List<EventMetric> eventMetrics; | ||
| private List<Feature> eventFeatures; | ||
| private boolean isGlobalHoldback; | ||
| private boolean anonymizeIP; | ||
|
|
||
| public Conversion() { } | ||
|
|
||
| public Conversion(String visitorId, long timestamp, String projectId, String accountId, List<Feature> userFeatures, | ||
| List<LayerState> layerStates, String eventEntityId, String eventName, | ||
| List<EventMetric> eventMetrics, List<Feature> eventFeatures, boolean isGlobalHoldback) { | ||
| List<EventMetric> eventMetrics, List<Feature> eventFeatures, boolean isGlobalHoldback, boolean anonymizeIP) { | ||
| this.visitorId = visitorId; | ||
| this.timestamp = timestamp; | ||
| this.projectId = projectId; | ||
|
|
@@ -48,6 +49,7 @@ public Conversion(String visitorId, long timestamp, String projectId, String acc | |
| this.eventMetrics = eventMetrics; | ||
| this.eventFeatures = eventFeatures; | ||
| this.isGlobalHoldback = isGlobalHoldback; | ||
| this.anonymizeIP = anonymizeIP; | ||
| } | ||
|
|
||
| public String getVisitorId() { | ||
|
|
@@ -138,6 +140,10 @@ public void setIsGlobalHoldback(boolean globalHoldback) { | |
| this.isGlobalHoldback = globalHoldback; | ||
| } | ||
|
|
||
| public boolean getAnonymizeIP() { return anonymizeIP; } | ||
|
|
||
| public void setAnonymizeIP(boolean anonymizeIP) { this.anonymizeIP = anonymizeIP; } | ||
|
|
||
| @Override | ||
| public boolean equals(Object other) { | ||
| if (!(other instanceof Conversion)) | ||
|
|
@@ -192,6 +198,7 @@ public String toString() { | |
| ", eventMetrics=" + eventMetrics + | ||
| ", eventFeatures=" + eventFeatures + | ||
| ", isGlobalHoldback=" + isGlobalHoldback + | ||
| ", anonymizeIP=" + anonymizeIP + | ||
|
Contributor
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. should we have constants for all these param values?
Contributor
Author
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. Yeah we should at some point since we share these with |
||
| ", clientEngine='" + clientEngine + | ||
| ", clientVersion='" + clientVersion + '}'; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,11 +28,12 @@ public class Impression extends Event { | |
| private String layerId; | ||
| private String accountId; | ||
| private List<Feature> userFeatures; | ||
| private boolean anonymizeIP; | ||
|
|
||
| public Impression() { } | ||
|
|
||
| public Impression(String visitorId, long timestamp, boolean isGlobalHoldback, String projectId, Decision decision, | ||
| String layerId, String accountId, List<Feature> userFeatures) { | ||
| String layerId, String accountId, List<Feature> userFeatures, boolean anonymizeIP) { | ||
| this.visitorId = visitorId; | ||
| this.timestamp = timestamp; | ||
| this.isGlobalHoldback = isGlobalHoldback; | ||
|
|
@@ -41,6 +42,7 @@ public Impression(String visitorId, long timestamp, boolean isGlobalHoldback, St | |
| this.layerId = layerId; | ||
| this.accountId = accountId; | ||
| this.userFeatures = userFeatures; | ||
| this.anonymizeIP = anonymizeIP; | ||
| } | ||
|
|
||
| public String getVisitorId() { | ||
|
|
@@ -107,6 +109,10 @@ public void setUserFeatures(List<Feature> userFeatures) { | |
| this.userFeatures = userFeatures; | ||
| } | ||
|
|
||
| public boolean getAnonymizeIP() { return anonymizeIP; } | ||
|
||
|
|
||
| public void setAnonymizeIP(boolean anonymizeIP) { this.anonymizeIP = anonymizeIP; } | ||
|
||
|
|
||
| @Override | ||
| public boolean equals(Object other) { | ||
| if (!(other instanceof Impression)) | ||
|
|
@@ -147,6 +153,7 @@ public String toString() { | |
| "visitorId='" + visitorId + '\'' + | ||
| ", timestamp=" + timestamp + | ||
| ", isGlobalHoldback=" + isGlobalHoldback + | ||
| ", anonymizeIP=" + anonymizeIP + | ||
| ", projectId='" + projectId + '\'' + | ||
| ", decision=" + decision + | ||
| ", layerId='" + layerId + '\'' + | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -139,7 +139,7 @@ private static ProjectConfig generateValidProjectConfigV1() { | |
| Collections.<TrafficAllocation>emptyList()); | ||
| List<Group> groups = asList(randomPolicyGroup, overlappingPolicyGroup); | ||
|
|
||
| return new ProjectConfig("789", "1234", "1", "42", groups, experiments, attributes, events, audiences); | ||
| return new ProjectConfig("789", "1234", "1", "42", groups, experiments, attributes, events, audiences, true); | ||
|
||
| } | ||
|
|
||
| private static final ProjectConfig NO_AUDIENCE_PROJECT_CONFIG_V1 = generateNoAudienceProjectConfigV1(); | ||
|
|
@@ -176,7 +176,7 @@ private static ProjectConfig generateNoAudienceProjectConfigV1() { | |
| new EventType("099", "clicked_purchase", multipleExperimentIds)); | ||
|
|
||
| return new ProjectConfig("789", "1234", "1", "42", Collections.<Group>emptyList(), experiments, attributes, | ||
| events, Collections.<Audience>emptyList()); | ||
| events, Collections.<Audience>emptyList(), true); | ||
|
||
| } | ||
|
|
||
| private static final ProjectConfig VALID_PROJECT_CONFIG_V2 = generateValidProjectConfigV2(); | ||
|
|
@@ -270,7 +270,7 @@ private static ProjectConfig generateValidProjectConfigV2() { | |
| Collections.<TrafficAllocation>emptyList()); | ||
| List<Group> groups = asList(randomPolicyGroup, overlappingPolicyGroup); | ||
|
|
||
| return new ProjectConfig("789", "1234", "2", "42", groups, experiments, attributes, events, audiences); | ||
| return new ProjectConfig("789", "1234", "2", "42", groups, experiments, attributes, events, audiences, true); | ||
|
||
| } | ||
|
|
||
| private static final ProjectConfig NO_AUDIENCE_PROJECT_CONFIG_V2 = generateNoAudienceProjectConfigV2(); | ||
|
|
@@ -307,7 +307,7 @@ private static ProjectConfig generateNoAudienceProjectConfigV2() { | |
| new EventType("099", "clicked_purchase", multipleExperimentIds)); | ||
|
|
||
| return new ProjectConfig("789", "1234", "2", "42", Collections.<Group>emptyList(), experiments, attributes, | ||
| events, Collections.<Audience>emptyList()); | ||
| events, Collections.<Audience>emptyList(), true); | ||
|
||
| } | ||
|
|
||
| private static final ProjectConfig VALID_PROJECT_CONFIG_V3 = generateValidProjectConfigV3(); | ||
|
|
@@ -437,7 +437,7 @@ private static ProjectConfig generateValidProjectConfigV3() { | |
| ); | ||
|
|
||
| return new ProjectConfig("789", "1234", "3", "42", groups, experiments, attributes, events, audiences, | ||
| liveVariables); | ||
| true, liveVariables); | ||
| } | ||
|
|
||
| private static final ProjectConfig NO_AUDIENCE_PROJECT_CONFIG_V3 = generateNoAudienceProjectConfigV3(); | ||
|
|
@@ -474,7 +474,7 @@ private static ProjectConfig generateNoAudienceProjectConfigV3() { | |
| new EventType("099", "clicked_purchase", multipleExperimentIds)); | ||
|
|
||
| return new ProjectConfig("789", "1234", "3", "42", Collections.<Group>emptyList(), experiments, attributes, | ||
| events, Collections.<Audience>emptyList(), Collections.<LiveVariable>emptyList()); | ||
| events, Collections.<Audience>emptyList(), true, Collections.<LiveVariable>emptyList()); | ||
| } | ||
|
|
||
| private ProjectConfigTestUtils() { } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,6 +90,7 @@ public void createImpressionEvent() throws Exception { | |
| assertThat(impression.getVisitorId(), is(userId)); | ||
| assertThat((double)impression.getTimestamp(), closeTo((double)System.currentTimeMillis(), 60.0)); | ||
| assertFalse(impression.getIsGlobalHoldback()); | ||
| assertThat(impression.getAnonymizeIP(), is(projectConfig.getAnonymizeIP())); | ||
|
Contributor
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. let's make this comparison explicit. assertFalse in this case since it's a v2 datafile. We should also pass in v2 datafile to the eventbuilder as well as a v3 datafile since for v2,
Contributor
Author
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 don't think testing for that is needed here. This tests that events are built correctly and not the fact that IPAnon should be
Contributor
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. thanks! that makes sense |
||
| assertThat(impression.getProjectId(), is(projectConfig.getProjectId())); | ||
| assertThat(impression.getDecision(), is(expectedDecision)); | ||
| assertThat(impression.getLayerId(), is(activatedExperiment.getLayerId())); | ||
|
|
@@ -207,6 +208,7 @@ public void createConversionEvent() throws Exception { | |
| assertThat(conversion.getEventMetrics(), is(Collections.<EventMetric>emptyList())); | ||
| assertThat(conversion.getEventFeatures(), is(Collections.<Feature>emptyList())); | ||
| assertFalse(conversion.getIsGlobalHoldback()); | ||
| assertThat(conversion.getAnonymizeIP(), is(projectConfig.getAnonymizeIP())); | ||
| assertThat(conversion.getClientEngine(), is(ClientEngine.JAVA_SDK.getClientEngineValue())); | ||
| assertThat(conversion.getClientVersion(), is(BuildVersionInfo.VERSION)); | ||
| } | ||
|
|
||
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.
just for consistency, can you modify
toStringto includeanonymizeIPas well?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.
Will do