-
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 2 commits
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 |
|---|---|---|
|
|
@@ -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 |
|---|---|---|
|
|
@@ -30,8 +30,7 @@ | |
|
|
||
| import static java.util.Arrays.asList; | ||
| import static org.hamcrest.CoreMatchers.is; | ||
| import static org.junit.Assert.assertNull; | ||
| import static org.junit.Assert.assertThat; | ||
| import static org.junit.Assert.*; | ||
|
||
|
|
||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
|
|
@@ -179,4 +178,15 @@ public void verifyGetVariationToLiveVariableUsageInstanceMapping() throws Except | |
| assertThat(projectConfig.getVariationToLiveVariableUsageInstanceMapping(), | ||
| is(expectedVariationToLiveVariableUsageInstanceMapping)); | ||
| } | ||
|
|
||
| /** | ||
| * Asserts that anonymizeIP is set to false if not explicitly passed into the constructor (in the case of V1 or V2 | ||
| * projects). | ||
| * @throws Exception | ||
| */ | ||
| @Test | ||
| public void verifyAnonymizeIPIsFalseByDefault() throws Exception { | ||
| ProjectConfig v2ProjectConfig = ProjectConfigTestUtils.validProjectConfigV2(); | ||
| assertFalse(v2ProjectConfig.getAnonymizeIP()); | ||
| } | ||
| } | ||
| 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