Skip to content

Conversation

@mikeproeng37
Copy link
Contributor

@optimizely/fullstack-devs

private final String projectId;
private final String revision;
private final String version;
private final boolean anonymizeIP;
Copy link
Contributor

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 toString to include anonymizeIP as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do

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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

we only need to add anonymizeIP to one ProjectConfig constructor. You can remove it here and call the other constructor with false as the default value.

Copy link
Contributor

Choose a reason for hiding this comment

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

why not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do. This will ensure that we always have it initialized to false unless explicitly passed in to the constructor.

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);
Copy link
Contributor

Choose a reason for hiding this comment

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

don't need to modify this if you change the constructor


return new ProjectConfig("789", "1234", "1", "42", Collections.<Group>emptyList(), experiments, attributes,
events, Collections.<Audience>emptyList());
events, Collections.<Audience>emptyList(), true);
Copy link
Contributor

Choose a reason for hiding this comment

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

don't need to modify

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);
Copy link
Contributor

Choose a reason for hiding this comment

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

don't need to modify


return new ProjectConfig("789", "1234", "2", "42", Collections.<Group>emptyList(), experiments, attributes,
events, Collections.<Audience>emptyList());
events, Collections.<Audience>emptyList(), true);
Copy link
Contributor

Choose a reason for hiding this comment

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

don't need to modify

assertThat(impression.getVisitorId(), is(userId));
assertThat((double)impression.getTimestamp(), closeTo((double)System.currentTimeMillis(), 60.0));
assertFalse(impression.getIsGlobalHoldback());
assertThat(impression.getAnonymizeIP(), is(projectConfig.getAnonymizeIP()));
Copy link
Contributor

@vraja2 vraja2 Dec 14, 2016

Choose a reason for hiding this comment

The 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, anonymizeIP should be false by default, while v3 will vary

Copy link
Contributor Author

@mikeproeng37 mikeproeng37 Dec 14, 2016

Choose a reason for hiding this comment

The 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 false by default as that should be tested elsewhere. We should just make sure that the event value corresponds to what the project config shows. That said, I'll add a test for this case on the ProjectConfigTest

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks! that makes sense

", eventMetrics=" + eventMetrics +
", eventFeatures=" + eventFeatures +
", isGlobalHoldback=" + isGlobalHoldback +
", anonymizeIP=" + anonymizeIP +
Copy link
Contributor

Choose a reason for hiding this comment

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

should we have constants for all these param values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah we should at some point since we share these with Impression.java. Just don't think it's worth refactoring for this diff :)

Copy link
Contributor

@vraja2 vraja2 left a comment

Choose a reason for hiding this comment

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

just had some small comments, thanks for addressing the feedback!

this.userFeatures = userFeatures;
}

public boolean getAnonymizeIP() { return anonymizeIP; }
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can you format this to be on multiple lines?


public boolean getAnonymizeIP() { return anonymizeIP; }

public void setAnonymizeIP(boolean anonymizeIP) { this.anonymizeIP = anonymizeIP; }
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can you format this to be on multiple lines?

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

let's keep explicit imports instead of wildcard imports

assertThat(impression.getVisitorId(), is(userId));
assertThat((double)impression.getTimestamp(), closeTo((double)System.currentTimeMillis(), 60.0));
assertFalse(impression.getIsGlobalHoldback());
assertThat(impression.getAnonymizeIP(), is(projectConfig.getAnonymizeIP()));
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks! that makes sense

@mikeproeng37 mikeproeng37 merged commit 030d2bc into master Dec 14, 2016
mikeproeng37 added a commit that referenced this pull request Dec 14, 2016
Add IP anonymization to event payload.
@vraja2 vraja2 deleted the mng/add-ip-anon branch December 22, 2016 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants